edge: find the console for replica calls whatever its account
Tito's staging hub answered every box replica call (coordinator, release, retire-ack) with 503 replica-console-missing, so a stateless deploy never left pending. serveReplicaConsole required the console route to have no account. The platform's consoles carry none, but a self-hosted console is installed into its operator account (Tito's row: account bab, app console, unit console.service, 127.0.0.1:8090). The unit is what marks the console: only platform or operator records name one, and a tenant instance record never does. So the account test goes; app console, unit console.service, a loopback upstream or socket, not an alias, regional, via tunnel or activator-owned, and exactly one match all stay. Witness TestReplicaConsoleRouteShape: system console, console in an operator account, a tenant app named console (refused), two console units (ambiguous). Red before the fix with Tito's answer. Census: Edge.serveReplicaConsole (sites: one fewer Account read) and the internal/edge envelope, proposal replica-console-account.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-proposal-replica-console-account.md+19 −0internal/edge/replicaconsole.go+9 −1internal/edge/replicaconsole_test.go+50 −11internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-replica-console-account.tsv+5 −0
CI failed — run details
Intent
<task-notification> <task-id>boikj50nu</task-id> <tool-use-id>toolu_01AdNegzwVzVQoxR7eJ8mhnq</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/boikj50nu.output</output-file> <status>completed</status> <summary>Background command "Tell Tito the fix is a release" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 64.1 g CO₂e (7,806,163 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on replica-console-account, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/notes/census-proposal-replica-console-account.md b/docs/superpowers/notes/census-proposal-replica-console-account.md| new file mode 100644 |
| index 000000000..e60d3f52e |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-replica-console-account.md |
| @@ -0,0 +1,19 @@ |
| +# Census approval: replica-console-account |
| + |
| +Ruling `census-ruling-replica-console-account`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/edge/replicaconsole.go` `Edge.serveReplicaConsole` | sites | -registry:Account | selection drops the account-empty test (one fewer read of the in-memory route Account) so a self-hosted console installed into its operator account (Tito: account bab) is found; it still requires app console, unit console.service, a loopback upstream or socket, not alias, regional, via tunnel or activator-owned, and exactly one match. Tenant routes stay refused: a unit is set only by platform or operator records (provision.Record.Unit, named units), never by a tenant instance record. Witness TestReplicaConsoleRouteShape. No new read, no write. | |
| + |
| +Envelopes re-pinned: `internal/edge`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/edge/replicaconsole.go` `Edge.serveReplicaConsole`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-stateless-coordinator-route;basis=Reads existing in-memory route fields to select a unique accountless console.service local upstream; refuses missing or ambiguous console, tenant routes, remote and tunnel upstreams. Reuses proxy and version wrapper; leaves fleet identity authentication at console.;rev3=census-ruling-retry-after-503;basis=the missing/ambiguous-console 503s go through UnavailableHeader (adds Retry-After 2 and answer/box headers); selection unchanged; no read added |
| + |
| +Seal: `846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332` → `7ce05776898a80913f5970dfac4d713da5516b17f632aefa9c159a88a282ed84`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-replica-console-account.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/edge/replicaconsole.go b/internal/edge/replicaconsole.go| index 6af26c9f5..43b60e69f 100644 |
| --- a/internal/edge/replicaconsole.go |
| +++ b/internal/edge/replicaconsole.go |
| @@ -5,11 +5,19 @@ import "net/http" |
| // serveReplicaConsole reuses the local console route, including its version |
| // header. Only POSTs on the reserved tunnel host enter here; other methods |
| // keep the hub's 404. Authentication remains the console's fleetIdentityOK. |
| +// |
| +// The console route is the one row whose unit is console.service, for app |
| +// console, on a loopback upstream (or a socket), not an activator-owned |
| +// instance. Its account is not part of the test: the platform's own |
| +// consoles carry none, but a self-hosted deployment's console is installed |
| +// into its operator account, and that row is the console all the same. The |
| +// unit is what marks it: only a platform or operator record names one, and |
| +// a tenant's instance record never does. Two such rows answer ambiguous. |
| func (e *Edge) serveReplicaConsole(w http.ResponseWriter, r *http.Request) { |
| var console http.Handler |
| for host, up := range *e.upstreams.Load() { |
| rt := up.route |
| - if host != rt.Host || up.alias || up.regional != 0 || up.viaTunnel || rt.Account != "" || rt.App != "console" || rt.Unit != "console.service" || rt.ActivatorOwned() { |
| + if host != rt.Host || up.alias || up.regional != 0 || up.viaTunnel || rt.App != "console" || rt.Unit != "console.service" || rt.ActivatorOwned() { |
| continue |
| } |
| if rt.Socket == "" { |
diff --git a/internal/edge/replicaconsole_test.go b/internal/edge/replicaconsole_test.go| index 277102b77..eccf6148c 100644 |
| --- a/internal/edge/replicaconsole_test.go |
| +++ b/internal/edge/replicaconsole_test.go |
| @@ -86,17 +86,56 @@ func TestFleetReplicaConsoleOnTunnelHost(t *testing.T) { |
| } |
| }) |
| } |
| - // A tenant app named console must not become the reserved API upstream. |
| - rt.Account = "a" |
| - if err := reg.Upsert(rt); err != nil { |
| - t.Fatal(err) |
| - } |
| - if err := e.Reload(); err != nil { |
| - t.Fatal(err) |
| +} |
| + |
| +// TestReplicaConsoleRouteShape (#511): which local route the hub hands a |
| +// box's replica call to. A console installed into an operator account, as |
| +// a self-hosted deployment's is, is the console: its unit, console.service, |
| +// marks it, and only a platform or operator record names a unit. A tenant |
| +// app named console on a loopback upstream is not. Two console units are |
| +// ambiguous. |
| +func TestReplicaConsoleRouteShape(t *testing.T) { |
| + var hits atomic.Int32 |
| + console := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + hits.Add(1) |
| + _, _ = io.WriteString(w, `{"lease":{}}`) |
| + })) |
| + defer console.Close() |
| + addr := console.Listener.Addr().String() |
| + consoleRow := func(host, account string) registry.Route { |
| + return registry.Route{Host: host, Account: account, App: "console", Unit: "console.service", Kind: "instance", Addr: addr, Status: "ready", Version: "v-test"} |
| } |
| - w := httptest.NewRecorder() |
| - e.ServeHTTP(w, httptest.NewRequest("POST", "https://tunnel.test"+prefix+"coordinator", nil)) |
| - if w.Code != http.StatusServiceUnavailable { |
| - t.Fatalf("tenant console: %d", w.Code) |
| + for _, tc := range []struct { |
| + name string |
| + routes []registry.Route |
| + code int |
| + answer string |
| + }{ |
| + {"system console", []registry.Route{consoleRow("console.test", "")}, 200, ""}, |
| + {"console in an operator account", []registry.Route{consoleRow("console.test", "bab"), |
| + {Host: "console.bab.test", Account: "bab", App: "console", Kind: "instance", Addr: addr, Status: "ready", Platform: true}}, 200, ""}, |
| + {"tenant app named console", []registry.Route{{Host: "console.tenant.test", Account: "a", App: "console", Kind: "service", Addr: addr, Status: "ready"}}, 503, "replica-console-missing"}, |
| + {"two console units", []registry.Route{consoleRow("console.test", "bab"), consoleRow("console2.test", "")}, 503, "replica-console-ambiguous"}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + reg := openReg(t) |
| + for _, rt := range tc.routes { |
| + if err := reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + e, err := New(reg, nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer e.probers.Stop() |
| + e.EnableTunnels(NewTunnelHub("tunnel.test", nil)) |
| + before := hits.Load() |
| + w := httptest.NewRecorder() |
| + e.ServeHTTP(w, httptest.NewRequest("POST", "https://tunnel.test/api/fleet/replicas/a/app/h/coordinator", strings.NewReader(`{"op":"acquire"}`))) |
| + if w.Code != tc.code || w.Header().Get("X-Carlos-Answer") != tc.answer || (hits.Load() > before) != (tc.code == 200) { |
| + t.Fatalf("got %d %q, console hits %d", w.Code, w.Header().Get("X-Carlos-Answer"), hits.Load()-before) |
| + } |
| + }) |
| } |
| } |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 35086f2cf..b5145683c 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -210,3 +210,4 @@ plan14-root-reads-same-box-edge-fence.tsv 76c986ad534d23071100a9a573ffb38afc60b2 |
| plan14-root-reads-g6-fence.tsv 3f43afa4b0c18ad678a952b48b511e74e849992cd629b9aa1442bbe0055d5631 |
| plan14-root-reads-offline-move-stage-refusals-339.tsv 846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332 |
| plan14-root-reads-fleet-tunnel-tls-state.tsv 846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332 |
| +plan14-root-reads-replica-console-account.tsv 7ce05776898a80913f5970dfac4d713da5516b17f632aefa9c159a88a282ed84 |
diff --git a/internal/provision/testdata/plan14-root-reads-replica-console-account.tsv b/internal/provision/testdata/plan14-root-reads-replica-console-account.tsv| new file mode 100644 |
| index 000000000..e61032333 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-replica-console-account.tsv |
| @@ -0,0 +1,5 @@ |
| +# Census overlay replica-console-account, written by census-propose (#369). census-ruling-replica-console-account, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-replica-console-account.md. |
| +# 0 body, 1 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy ecdf217f2500175e5b51bacaa538dbe01f67893b08f94f7afef475f3bdc10c2d internal/edge/replicaconsole.go Edge.serveReplicaConsole legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-coordinator-route;basis=Reads existing in-memory route fields to select a unique accountless console.service local upstream; refuses missing or ambiguous console, tenant routes, remote and tunnel upstreams. Reuses proxy and version wrapper; leaves fleet identity authentication at console.;rev3=census-ruling-retry-after-503;basis=the missing/ambiguous-console 503s go through UnavailableHeader (adds Retry-After 2 and answer/box headers); selection unchanged; no read added;rev3=census-ruling-replica-console-account;basis=selection drops the account-empty test (one fewer read of the in-memory route Account) so a self-hosted console installed into its operator account (Tito: account bab) is found; it still requires app console, unit console.service, a loopback upstream or socket, not alias, regional, via tunnel or activator-owned, and exactly one match. Tenant routes stay refused: a unit is set only by platform or operator records (provision.Record.Unit, named units), never by a tenant instance record. Witness TestReplicaConsoleRouteShape. No new read, no write. registry:App@237,registry:Host@178,registry:Socket@335,registry:Unit@260,whole:Route@159 3e70f505ece85f692d1864ec8a74de58f1b4318477a13458aa4f783ef4a229da |
| +internal/edge/replicaconsole.go Edge.serveReplicaConsole legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-coordinator-route;basis=Reads existing in-memory route fields to select a unique accountless console.service local upstream; refuses missing or ambiguous console, tenant routes, remote and tunnel upstreams. Reuses proxy and version wrapper; leaves fleet identity authentication at console.;rev3=census-ruling-retry-after-503;basis=the missing/ambiguous-console 503s go through UnavailableHeader (adds Retry-After 2 and answer/box headers); selection unchanged; no read added;rev3=census-ruling-replica-console-account;basis=selection drops the account-empty test (one fewer read of the in-memory route Account) so a self-hosted console installed into its operator account (Tito: account bab) is found; it still requires app console, unit console.service, a loopback upstream or socket, not alias, regional, via tunnel or activator-owned, and exactly one match. Tenant routes stay refused: a unit is set only by platform or operator records (provision.Record.Unit, named units), never by a tenant instance record. Witness TestReplicaConsoleRouteShape. No new read, no write. registry:App@237,registry:Host@178,registry:Socket@335,registry:Unit@260,whole:Route@159 3e70f505ece85f692d1864ec8a74de58f1b4318477a13458aa4f783ef4a229da |
| +@coverage internal/edge b5dcd8dfc99988c7db9fa9666310d9d4c6992077200e3116e27cb952bf6987c3 |