Phase B: Agent registers routes with mc-proxy on deploy #2
Reference in New Issue
Block a user
Delete Branch "phase-b-route-registration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary\n\n- Agent connects to mc-proxy via Unix socket and registers/removes routes automatically\n- Deploy: after container starts, registers routes with mc-proxy using assigned host ports\n- Stop: removes routes from mc-proxy before stopping containers\n- Config:
[mcproxy] socketandcert_dirfields in agent config\n- Nil-safe: if socket not configured, route registration is silently skipped\n\n## Changes\n\n-internal/agent/proxy.go—ProxyRouterwrapping mc-proxy client library\n-internal/agent/proxy_test.go— tests for listener mapping, nil safety\n-internal/agent/agent.go— wire ProxyRouter into Agent, connect on startup\n-internal/agent/deploy.go— register routes after container starts\n-internal/agent/lifecycle.go— remove routes before container stops\n-internal/config/agent.go—MCProxyConfigwith socket and cert_dir\n-go.mod— add mc-proxy v1.0.0 dependency\n\n## Design\n\n- L7 routes: mc-proxy terminates TLS using certs at<cert_dir>/<service>.pem\n- L4 routes: TLS passthrough (backend_tls=true), backend handles its own TLS\n- Hostnames default to<service>.svc.mcp.metacircular.net\n- Route registration failures are logged but don't fail the deploy\n\n## Test plan\n\n- [x]TestListenerForMode— port→listener address mapping\n- [x]TestNilProxyRouterIsNoop— all methods safe on nil receiver\n- [x]TestRegisterRoutesSkipsZeroHostPort— zero host ports skipped\n- [x] All existing tests pass