carlos / platform Public

feat: integrate replica routing across hub views

Route validated replica sets through the shared fleet verdict and live-copy
proxy. Sync probe jobs on reload and carry copy health, build and worker
evidence through the existing five-minute upstream status report.

Cover alias authority, legacy fallback refusal, reload and binding races,
real tunnel failover and bucket request budgets. Keep HA and legacy
forwarding unchanged.
Co-Authored-By: Codex (gpt-6-astra) <noreply@openai.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 9a054d08e2a579aef9fd4d21bbb5b6ac8526264e parent c5da45a
10 files changed, +756 −30
  • docs/superpowers/notes/census-proposal-stateless-replicas-3.md +10 −4
  • internal/edge/edge.go +24 −2
  • internal/edge/fleetforward.go +13 −3
  • internal/edge/replicaforward_test.go +294 −0
  • internal/edge/replicaprober.go +16 −10
  • internal/host/replica_request_budget_test.go +94 −0
  • internal/host/replica_tunnel_e2e_test.go +281 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-stateless-replicas-3.tsv +14 −5
  • internal/status/snapshot.go +9 −5

Intent

Human

<task-notification> <task-id>abae9afdd4b750ff5</task-id> <tool-use-id>toolu_01BDWFNoFrjCpFqWztgBiVd5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/195ef15b-aac6-42d6-b49b-41ffb7a4abbc/tasks/abae9afdd4b750ff5.output</output-file> <status>completed</status> <summary>Agent "Task 2 scoped re-review" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>- **I1 (Q17)**: ADDRESSED. The 3 s timer now starts only for a GET/HEAD with no body or a replayable body, no 1xx yet, and another copy still live (`internal/edge/replicaproxy.go:121-133`, `:141`). An attempt with a body starts it only after the upload is written (`:169-175`). A 1xx stops it (`:164-168`). POST, one-shot bodies and the last copy wait with no timeout, as on the legacy proxies. New tests cover the slow POST and slow last-copy GET cases, plus slow uploads and a 103 before a slow answer. The existing 3 s retry test is unchanged. - **M1**: ADDRESSED. `anyDispatched` is tracked across attempts (`:83`, `:187`), and the 503 SR-3-C01 now requires that nothing was dispatched (`:218`). `TestReplicaDispatchedThenMissingIsNotFleetDark` checks for a 502 with two attempts and no Retry-After. - **M4**: ADDRESSED. Any response that comes back without an error is returned, never replaced by a 502 (`:192-198`). Timer firing and stopping share one mutex (`:138-158`). `TestReplicaHeadersWinTimerRace` forces the race through a test-only hook. - **New breakage**: none Critical or Important. One Minor (N1): in that same tiny race, the request is already cancelled, so a response with a body gets its headers through and then a stream reset. The h2 transport keeps cancelling the stream until it ends (x/net v0.60.0 `http2/transport.go:1226-1238`). Responses with no body (204/304/HEAD) are fine, and that is the only case the test checks. Stopping the timer on `GotFirstResponseByte` would narrow the window. Not blocking. - **Census**: APPROVE, seal `00eef8089c6cd9ba4725c22c618e871d3b038c958b3db906e1fc6af49ef9a65f`. `make census-card` at c5da45ae says the census is clean with that seal. The overlay diff changes one line, the `internal/edge` coverage pin from `ab38d53c…` to `b9b517d1…`, and no unit's rows. The only changed code in scope is the replica request loop (`RoundTrip`). It adds a timer, a mutex and trace hooks, and no new file, registry, bucket or network reads. No reads or writes changed beyond the approved claims, so `task-2-claims.tsv` still holds. - **Deferred**: M2, M3, M5, M6 and census N6 (the shared `started` flag, now also read at `:122`). The report is in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/stateless-replicas-3/.superpowers/sdd/2026-11-01-stateless-replicas-3-routing/task-2-rereview-1.md`.</result> <usage><subagent_tokens>75093</subagent_tokens><tool_uses>9</tool_uses><duration_ms>126727</duration_ms></usage> </task-notification>

Attributed to this commit: 32.2 g CO₂e (3,843,776 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on stateless-replicas-3-routing, 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-stateless-replicas-3.md b/docs/superpowers/notes/census-proposal-stateless-replicas-3.md
index f07cb874e..75b722a48 100644
--- a/docs/superpowers/notes/census-proposal-stateless-replicas-3.md
+++ b/docs/superpowers/notes/census-proposal-stateless-replicas-3.md
@@ -1,23 +1,27 @@
# Census approval: stateless-replicas-3
-Ruling `census-ruling-stateless-replicas-3`. The independent reviewer approves or rejects every change below, 17 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+Ruling `census-ruling-stateless-replicas-3`. The independent reviewer approves or rejects every change below, 19 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
| unit | change | read sites | what changed |
|---|---|---|---|
| `internal/edge/edge.go` `RunWithActivatorReady` | body | unchanged (5) | Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority. |
+| `internal/edge/fleetforward.go` `FleetArmVerdict` | body | unchanged (19) | Task 3: classify ArmReplica as fleet-served for the existing shared routing, edges-file and alias verdict. Existing field reads unchanged; pure in-memory decision, same owner and alias checks. |
| `internal/edge/reqrecords.go` `requestResponse` | body | unchanged (4) | Task 2: copy the final replica box and attempt count from the existing per-request outcome into additive reqrec.Response fields. Existing four Route reads unchanged; no new external read, path, credential or authority. The observer still records one client response at the hub; ordinary requests retain zero fields. |
| `internal/host/agent.go` `runAgent` | body | unchanged (5) | Task 1 fix round 1 M3: retain the private snapshot source and cancel/join ownership, but use the replica-health-specific retry loop. It logs its first failure only and retains the existing exponential backoff capped at 30 seconds; unsupported builds return nil. Existing five direct read sites unchanged; no new credentials, bucket reader or app lifecycle action. |
+| `internal/edge/edge.go` `Edge.Reload` | sites | +registry:Host ×4, +whole:Route ×8 | Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. |
| `internal/edge/edge.go` `Edge.ServeHTTP` | sites | +whole:Route | Task 1a: pass the already-resolved Route to the reserved replica-probe handler after acceptHop and existing admissionRefuses, requiring tunnel context plus private marker and refusing door/backhaul ingress. Added whole Route use only; scrub marker before forwarding; HA calls remain unchanged. |
-Envelopes re-pinned: `internal/activator`, `internal/edge`, `internal/host`, `internal/replicas`, `internal/reqrec`, `internal/tunnelclient`.
+Envelopes re-pinned: `internal/activator`, `internal/edge`, `internal/host`, `internal/replicas`, `internal/reqrec`, `internal/status`, `internal/tunnelclient`.
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/edge.go` `RunWithActivatorReady`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.
+- `internal/edge/fleetforward.go` `FleetArmVerdict`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 fix round 3: the single fleet-arm refusal decision over one listing, used by Edge.Reload, the edges-file writer and the alias pass (parity by construction); returns the refused set with reasons and the accountless notes (+registry:Host x3, +registry:Status, +whole:Route x3). Pure; no I/O. Review R1 finding 2: also returns Served, each admitted row Reload sends through the fleet arm (a forward row, or a fleet-placed row with no Tunnel) with its fleet, app and the fleet owner from owners; a host the alias step refuses is dropped from it (+registry:App, +registry:Host, +registry:Region, +registry:Tunnel on the listing it already holds). Pure; no I/O. Review R2: the pre-fold fleet rows are now Arm; Served is the destination after the platform-alias fold: every ready, unrefused, non-sidecar row DispatchArm gives an entry, with its Arm fleet when its arm is a fleet's, folded by foldPlatformAliases (Reload's own fold), keeping the hosts that go to a fleet (+registry:Host, +registry:Status, +whole:Route on the listing it already holds). Pure; no I/O; refusals unchanged.
- `internal/edge/reqrecords.go` `requestResponse`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-edge-request-records;identity=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=new: a pure constructor: copies the account (release.RouteAccount of the route), app, host and environment of the route row the edge already resolved for this request, and the request's method, path, raw query, User-Agent, client address and GeoIP country (from the request context), with the status, into a reqrec.Response; the recorder masks the path, keeps only the query's names, and stores the client address only as its /24 (IPv6 /48) prefix and a day-salted hash before anything is stored; the account and app come from the route row, never the Host header; it reads no file, no store and no box state, writes nothing, and makes no decision; the class of Edge.emitEdgeError and UsageMeter.Record (J1 root-route)
- `internal/host/agent.go` `runAgent`: authority, task B,C,D,F. Basis: rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-region-ha-p1b3b-t;basis=Wire Service.SetDutyView to the live edge DutySnapshot in the ready callback. No new read; no new loop or cloud operation. B2 wires the registry as the persistent DutyStore before service startup; no new cloud or filesystem path. B3b: arm one journal-backed termination consumer before service startup using agentCtx and the shared confirmer; expose edge tick and join at edge shutdown. No new direct read sites.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. Merge resolution against origin/main 9bd45488 retains main's HA departure controller, lifecycle and duty wiring alongside the demo data store and worker; no read site added by the resolution.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: install closed fixed admission before every launch source, bind activator/backend and edge, wire the real termination Started lifecycle and role reader after the change index; close before cancellation/child shutdown. No new external reads or cloud authority. Fix R1: move bind/lifecycle/edge-option wiring into wireAgentAdmission and worker listing into runWorkerBootPassAfterAdmission. Worker boot waits for admission before listing then uses unchanged bounded wakes and per-host serialization; whole Route read moves to the helper. No new storage, cloud, or root execution authority. Preserve merged main's agent wiring and census basis; the branch removes one whole Route use by moving worker iteration to the helper, with no added read kind.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: arms a fleet-only worker using the existing registry, activator, backend and authenticated console transport. Owned worker stops and joins at shutdown. No new bucket reader. merge of origin/main 9b8b2c50: retain HA duty/departure lifecycle, wake-slot and existing agent wiring alongside the replica placement worker; no new read introduced by resolution. merge of origin/main 6be08467: Retain main demo configuration, admission, build and expiry wiring alongside the replica worker; merge-only body change, no additional read. merge of origin/main 7920cccf: Retain main box-role/group admission wiring and boot publication beside the owned replica worker and shutdown; main moves the boot registry List into runWorkerBootPassAfterAdmission, removing its inline whole Route site. No new read introduced by conflict resolution.
+- `internal/edge/edge.go` `Edge.Reload`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.
- `internal/edge/edge.go` `Edge.ServeHTTP`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here.;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read;rev3=census-ruling-edge-asset-cache-3;basis=the asset cache's three hooks (asset cache plan 3): the request's reserved asset headers are deleted at entry (the fill assertion kept only beside a verified hop); on the exact-remote and lookup-miss branches the far catch (serveAssetFar) is tried before backhaulTo and backhaul; after the observer defer and main's hard and probe checks, a verified hop with a valid fill assertion is answered by serveAssetFillForHop; after the upgrade branch and before gzip and the shared cache, the local catch (serveAssetLocal); the observer defer skips only the usage meter for an acknowledged home fill (out.unbilled); the new reads live in the new units of the edge-asset-cache-3-decisions overlay; the same route row and read sites (25); no read added;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: straight after lookupUpstreamPath it calls regionalGate (regional.go), which for an entry built from a regional_domains row answers 503 to a hop or a deny entry before any arm that can leave the box (the exact-home backhaul, the far asset catch, the door dial, the miss backhaul), and lets a star match through only to the exact-home arm when ExactHome names another box for that distinct exact name; after the exact-home arm a regional deny entry the arm did not answer is refused (regionalRefuse, 503); refusals only, on the route map the edge already holds; read sites unchanged (25);rev3=census-ruling-static-headers;basis=the shared response cache is no longer looked up or filled for a static-kind route: one more read of the route row the edge already resolved (up.route.Kind == "static") in the cacheable expression; a refusal only, nothing new opened or followed;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2 (N-HA10): one call, frontForwardHA, right after the route lookup's !ok block and before the login POST; same reads;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4: loginPost and cacheable treat a forward row as not this box's to answer (IsForward(), +whole:Route x2): no login form and no shared cache for a forward host. Serving only.;rev3=census-ruling-tunnel-websockets;basis=Deletes the Carlos-Upgrade marker header from incoming requests and puts the upgrade admission (host, path, the entry tenancy, all in hand) on a tunnel arm request. For a login POST on an ungated ArmTunnel row it reads the visitor request body (bounded by gate.MaxFormBody, 413 past it; a request body, not a file) and resolves next against the entry Reload built (Gate, Route); the bytes pass on only when loginPassesThrough holds (spec 7, Tasks 3, 5 and 6).;rev3=census-ruling-console-protection-tab;basis=one more call in the observer defer, observeGuardCount(up.route, out), beside the observeRecords call that files the guard Match: it passes on the route row the defer already holds (+whole:Route) and the request outcome to the usage meter, which counts the check in memory. Called whether or not the request was unbilled, as observeRecords is. Nothing is opened, read or followed; no new kind of read; no check, refusal or serving decision changes.;rev3=census-ruling-probe-burst-limit;basis=answers a probe-burst notice POST (serveBurstNotice) ahead of every route for a non-door caller; builds the guard state for up.route and stamps its account and app (RouteAccount, App) for the cool-down's this-app/other-app label; for a catalogue match on a non-static or tunnelled route, offers the burst rule (in-memory limiter, burstDecide: 429 or a watch verdict, never a block for a fleet or forward row); the observer defer calls noteBurst(up.route, ...); the added sites are the route value already in hand (+registry:App, +whole:Route x5); no new root read or write kind;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): parses the request's query once (stripHoldMarker) to record the carlos_hold=1 mark in the request context; calls classifyHold on the upstream already resolved from the loaded map (the +whole:Route is that in-memory Route), including a second pass for a login POST; gives a marked request on a door-refused route the plain 404; adds the hold branch (planThrottleAdmit, rateAdmit, serveHeld) after the gate; and excludes marked requests from the shared cache. Reads only the request and the already-loaded upstream map; no registry or bucket read added.;rev3=census-ruling-region-ha-p3a;basis=Complete the P3a cut: an exact peer name with no dial target answers the approved admission 503 before local wildcard dispatch or asset serving. ExactHome and lookupHome stop fallback at a present non-dial entry; backhaulTo refuses an empty target before signing or dialing. Retain Task 3 local admission and fixed platform/unit exemptions. Two added whole Route uses feed the local in-memory admission predicate; existing Route values and store/path reads are unchanged.;rev3=census-ruling-stateless-coordinator-route;basis=P24/P25: POST only, exact /api/fleet/replicas/ prefix on the reserved tunnel host calls the existing local console proxy only for an unescaped, already-clean path; malformed forms remain on the hub. No new read sites relative to origin/main. Merge with main 3487d6f6 retains its region HA admission checks before routing and after login target lookup, its empty-home refusal, and their two existing whole:Route reads; these change this unit's digest relative to the previously approved branch tip 92b24a7d.
New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
@@ -25,7 +29,7 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/activator/replicaprobe.go:Service.ProbeCopy`: reads +registry:Account, +registry:App, +registry:FleetBoxes, +registry:HA ×2, +registry:Hibernate ×2, +registry:Incarnation ×2, +registry:Kind, +registry:Region ×3, +registry:ReplicaIncarnation ×3, +registry:ReplicaRevision, +registry:Stateless, +whole:Route ×6; written legacy, accepted-legacy, frozen
- new `internal/edge/replicaprobe.go:Edge.replicaCopyMatches`: reads +registry:Account, +registry:App, +registry:Host, +registry:Region, +registry:ReplicaIncarnation, +registry:ReplicaRevision; written legacy, accepted-legacy, frozen
- new `internal/edge/replicaprobe.go:Edge.serveReplicaProbe`: reads +registry:FleetBoxes, +registry:HA, +registry:Hibernate, +registry:Host, +registry:Kind, +whole:Route ×4; written legacy, accepted-legacy, frozen
-- new `internal/edge/replicaprober.go:Edge.syncReplicaProbes`: reads +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/edge/replicaprober.go:Edge.syncReplicaProbes`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/edge/replicaprober.go:TunnelHub.probeReplica`: reads +file:ReadAll; written legacy, accepted-legacy, frozen
- new `internal/edge/replicaprober.go:newReplicaProber`: reads +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/edge/replicaprober.go:replicaIdentityMatches`: reads +registry:Account, +registry:App, +registry:Host, +registry:Region, +whole:Route; written legacy, accepted-legacy, frozen
@@ -39,7 +43,9 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/edge/replicaprober.go:sameReplicaJob`: reads +registry:Account ×2, +registry:App ×2, +registry:Host, +registry:Region ×2, +registry:ReplicaIncarnation, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/edge/tunnel.go:tunnelWire.Read`: reads +file:Read ×2; written legacy, accepted-legacy, frozen
- new `internal/host/replicahealth_linux.go:serveReplicaHealth`: reads +file:Lstat ×2, +file:Open; written legacy, accepted-legacy, frozen
+- reads `internal/edge/fleetforward.go:DispatchArm`: +registry:FleetBoxes; keeps legacy, task accepted-legacy
+- reads `internal/edge/fleetforward.go:FleetServeEligible`: +registry:Account, +registry:App, +registry:FleetBoxes, +registry:HA, +registry:Hibernate, +registry:Kind, +registry:Platform, +registry:Tunnel; keeps legacy, task accepted-legacy
-Seal: `59c0891618b9befae27ebe04d0a67b08c7f7658bca9f1c78bf6d05eb7a708e82` → `00eef8089c6cd9ba4725c22c618e871d3b038c958b3db906e1fc6af49ef9a65f`.
+Seal: `59c0891618b9befae27ebe04d0a67b08c7f7658bca9f1c78bf6d05eb7a708e82` → `94200054efc8bc2fce33fba728d6578bb9f7742105f4a266ed92c9365931bf9c`.
Overlay: `internal/provision/testdata/plan14-root-reads-stateless-replicas-3.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/edge/edge.go b/internal/edge/edge.go
index eb863ff68..b31b578eb 100644
--- a/internal/edge/edge.go
+++ b/internal/edge/edge.go
@@ -856,6 +856,7 @@ func (e *Edge) Reload() error {
// absent from it have their probers stopped, exactly as RetireExcept
// retires activator children for hosts absent from `managed`.
probeSpecs := make(map[string]probeSpec)
+ var replicaRoutes []registry.Route
// Fleet channel auth and the fleets table, read BEFORE the routes loop
// (fleet public routes spec §4.4): the loop's fleet arm asks
// FleetServeEligible, which needs each fleet's owning account. Both are
@@ -946,7 +947,7 @@ func (e *Edge) Reload() error {
// from the same value that picks the arm's destination below.
var ten tenancy
// served is the fleet arm's answer for this row (FleetArmVerdict's
- // Arm): both fleet cases below take their fleet from it, and nothing
+ // Arm): the fleet cases below take their fleet from it, and nothing
// else reaches a fleet's tunnel. The arm itself is DispatchArm, the
// one statement of this switch's order, which FleetArmVerdict also
// asks to know which rows have an entry before the platform-alias
@@ -955,6 +956,12 @@ func (e *Edge) Reload() error {
served, viaFleet := verdict.Arm[t.Host]
arm := DispatchArm(t, viaFleet, e.tunnels != nil)
switch arm {
+ case ArmReplica:
+ p := replicaProxy(t.Host, served.Fleet, e.replicaProberForRouting(), e.tunnels)
+ p.ModifyResponse = e.responseModifier(t)
+ proxy, viaTunnel = p, true
+ ten = tenancy{Arm: ArmReplica, Account: served.Account, App: served.App, Fleet: served.Fleet}
+ replicaRoutes = append(replicaRoutes, t)
// A forward row (fleet public routes spec §4.2) is the hub's row for
// an app placed on a fleet: it runs nothing here, and the only way it
// is ever served is through its fleet's tunnel. FIRST, ahead of the
@@ -966,6 +973,7 @@ func (e *Edge) Reload() error {
// one rule: the hub only, inert, on a fleet in this box's fleets
// table, its raw account the fleet's owner. An admitted forward row
// is always in Arm; one that is not is ArmNone, never another arm.
+
case ArmForward:
box, authoritative := fleetBoxOf(t)
p := fleetProxy(served.Fleet, box, authoritative, e.tunnels)
@@ -1367,6 +1375,12 @@ func (e *Edge) Reload() error {
// host being deleted is a moment early, a 503 for a host being added is
// simply wrong.
e.probers.Sync(probeSpecs)
+ // Only surviving source entries may create jobs; aliases share their source.
+ replicaRoutes = slices.DeleteFunc(replicaRoutes, func(rt registry.Route) bool {
+ up, ok := m[rt.Host]
+ return !ok || up.route.Host != rt.Host || up.tenancy.Arm != ArmReplica
+ })
+ e.syncReplicaProbes(replicaRoutes)
if h := e.hooks; h != nil && h.beforePublish != nil {
if err := h.beforePublish(id); err != nil {
return err
@@ -1542,7 +1556,15 @@ func (e *Edge) deploymentHosts() []string {
// route that stopped being probed is simply gone from the next call rather
// than lingering as a stale entry someone has to remember to evict.
func (e *Edge) UpstreamStates() map[string][]UpstreamState {
- return e.probers.State()
+ out := e.probers.State()
+ for host, snapshot := range e.ReplicaSnapshots() {
+ states := make([]UpstreamState, 0, len(snapshot.Copies))
+ for _, copy := range snapshot.Copies {
+ states = append(states, UpstreamState{Addr: copy.Fleet + "/" + copy.Box, Up: copy.Healthy, Since: copy.ObservedAt, LastError: copy.Reason, ReplicaCopy: &copy})
+ }
+ out[host] = states
+ }
+ return out
}
// Allowed reports whether host is configured — used as the autocert
diff --git a/internal/edge/fleetforward.go b/internal/edge/fleetforward.go
index 5e12b092f..4c134b4e7 100644
--- a/internal/edge/fleetforward.go
+++ b/internal/edge/fleetforward.go
@@ -56,6 +56,9 @@ func TunnelsArmed(getenv func(string) string) bool {
// invalid account into OpsAccount.
func FleetServeEligible(rt registry.Route, hub bool, owners map[string]string) (ok bool, why string) {
fleet, placed := registry.FleetPlacement(rt.Region)
+ if rt.FleetBoxes != "" && (!hub || !rt.ValidReplicaProjection() || rt.Account == "" || rt.App == "" || rt.Platform || rt.HA || rt.Hibernate || rt.Tunnel != "" || (rt.Kind != "instance" && !rt.IsForward())) {
+ return false, replicaUnavailable
+ }
if rt.IsForward() {
if !hub {
return false, "forward row on a box that is not the hub"
@@ -109,7 +112,7 @@ type FleetVerdict struct {
Noted map[string]string
// Arm maps every row the fleet arm takes, by its host, to that row's
// own fleet (FleetServed): which dispatch arm, before any fold.
- // Reload's two fleet cases (DispatchArm's ArmForward and ArmFleet) take
+ // Reload's fleet cases (ArmForward, ArmFleet and ArmReplica) take
// the fleet from it and nothing else reaches a fleet's tunnel.
Arm map[string]FleetServed
// Served maps every host Reload's map sends through a fleet's tunnel
@@ -133,10 +136,12 @@ const (
ArmAddrs // TCP upstreams (AddrList)
ArmStatic // the edge's static handler
ArmStatus // the edge's status handler
+ ArmReplica // a validated set, through healthy assigned copies
)
// DispatchArm is the one statement of Reload's dispatch order for a row it
-// serves at all (not a sidecar, ready, not refused): a forward row only
+// serves at all (not a sidecar, ready, not refused): a validated set through
+// ArmReplica when tunnels are on; otherwise a forward row only
// through the fleet arm, and only when fleetArm (FleetVerdict.Arm holds
// it); then the row's own Tunnel where tunnels are on; then the fleet arm;
// then socket, TCP upstreams, static and status. Reload switches on it,
@@ -144,6 +149,11 @@ const (
// platform-alias fold.
func DispatchArm(rt registry.Route, fleetArm, tunnels bool) Arm {
switch {
+ case rt.FleetBoxes != "" && tunnels:
+ if fleetArm && rt.ValidReplicaProjection() {
+ return ArmReplica
+ }
+ return ArmNone
case rt.IsForward():
if fleetArm {
return ArmForward
@@ -286,7 +296,7 @@ func FleetArmVerdict(routes []registry.Route, owners map[string]string, hub, tun
at, fleetArm := v.Arm[rt.Host]
switch DispatchArm(rt, fleetArm, tunnels) {
case ArmNone:
- case ArmForward, ArmFleet:
+ case ArmForward, ArmFleet, ArmReplica:
entries[rt.Host] = entry{at: at, fleet: true}
default:
entries[rt.Host] = entry{}
diff --git a/internal/edge/replicaforward_test.go b/internal/edge/replicaforward_test.go
new file mode 100644
index 000000000..d08d47eb3
--- /dev/null
+++ b/internal/edge/replicaforward_test.go
@@ -0,0 +1,294 @@
+package edge
+
+import (
+ "context"
+ "net/http"
+ "net/http/httptest"
+ "reflect"
+ "strings"
+ "sync"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/replicas"
+)
+
+func replicaRoutingFixture(t *testing.T, handler http.HandlerFunc) (*Edge, registry.Route, *replicaTestClock) {
+ t.Helper()
+ hub, _, rt := replicaProxyFixture(t, handler, handler)
+ reg := openReg(t)
+ if err := reg.UpsertFleet(registry.Fleet{Name: "pi", Account: rt.Account, Bucket: "pi-data"}); err != nil {
+ t.Fatal(err)
+ }
+ e, err := New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Setenv("CARLOS_TUNNEL_HOST", "tunnel.example.com")
+ t.Setenv("CARLOS_FLEET", "")
+ e.EnableTunnels(hub)
+ clock := newReplicaTestClock()
+ e.replicaProbes = newReplicaProber(hub, func(_ context.Context, channel, host string) (replicas.Copy, error) {
+ row, err := reg.Get(host)
+ if err != nil {
+ return replicas.Copy{}, err
+ }
+ return replicaTestCopy(*row, strings.TrimPrefix(channel, "pi/")), nil
+ }, clock)
+ t.Cleanup(e.stopReplicaProbes)
+ t.Cleanup(e.probers.Stop)
+ rt.Status = "ready"
+ return e, rt, clock
+}
+
+func replicaRoutingGet(e *Edge, host string) *httptest.ResponseRecorder {
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ r := httptest.NewRequest("GET", "https://"+host+"/", nil).WithContext(ctx)
+ w := httptest.NewRecorder()
+ e.ServeHTTP(w, r)
+ return w
+}
+
+func TestLegacyFleetRoutingUnchanged(t *testing.T) {
+ var dials atomic.Int32
+ e, set, _ := replicaRoutingFixture(t, func(w http.ResponseWriter, r *http.Request) { dials.Add(1); w.Write([]byte("fallback")) })
+ legacy := set
+ legacy.Host = "legacy.example.com"
+ legacy.FleetBoxes = ""
+ legacy.Copies = 0
+ legacy.ReplicaRevision = 0
+ legacy.ReplicaIncarnation = ""
+ legacy.Stateless = false
+ labelled := legacy
+ labelled.Host = "labelled.example.com"
+ labelled.Kind = registry.KindForward
+ labelled.FleetBox = "missing"
+ labelled.FleetLabel = "missing"
+ set.FleetBoxes = `["missing"]`
+ trap := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { dials.Add(1); w.Write([]byte("address fallback")) }))
+ t.Cleanup(trap.Close)
+ set.Addr = strings.TrimPrefix(trap.URL, "http://")
+ set.Health = `{"path":"/"}`
+ for _, rt := range []registry.Route{legacy, labelled, set} {
+ put := e.reg.Upsert
+ if rt.IsForward() {
+ put = e.reg.PutForward
+ }
+ if err := put(rt); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if w := replicaRoutingGet(e, legacy.Host); w.Code != 200 || w.Body.String() != "fallback" {
+ t.Fatalf("legacy fallback: %d %s", w.Code, w.Body)
+ }
+ if w := replicaRoutingGet(e, labelled.Host); w.Code != 503 || w.Header().Get("Retry-After") != "2" {
+ t.Fatalf("labelled dark: %d %s", w.Code, w.Body)
+ }
+ before := dials.Load()
+ if w := replicaRoutingGet(e, set.Host); w.Code != 503 || w.Body.String() != replicaUnavailable+"\n" || w.Header().Get("Retry-After") != "2" {
+ t.Fatalf("set fell back: %d %s", w.Code, w.Body)
+ }
+ if dials.Load() != before {
+ t.Fatal("set dialled unassigned fallback")
+ }
+ if len(e.probers.State()) != 0 {
+ t.Fatal("set used address health")
+ }
+}
+
+func TestReplicaAliasesPreserveSetAuthority(t *testing.T) {
+ var dials atomic.Int32
+ e, source, clock := replicaRoutingFixture(t, func(w http.ResponseWriter, r *http.Request) { dials.Add(1); w.Write([]byte("set")) })
+ source.Socket = "/unreachable/shop.sock"
+ platform := registry.Route{Host: "platform.example.com", Kind: "instance", Status: "ready", Platform: true, Account: source.Account, App: source.App, Socket: source.Socket}
+ wrong := source
+ wrong.Host = "wrong.example.com"
+ wrong.Account = "bah"
+ wrong.Socket = "/unreachable/wrong.sock"
+ sidecar := source
+ sidecar.Host = "sidecar.example.com"
+ sidecar.Kind = "sidecar"
+ conflict := platform
+ conflict.Host = "conflict.example.com"
+ conflict.Account = "bah"
+ forward := source
+ forward.Host = "forward.example.com"
+ forward.Kind = registry.KindForward
+ forward.Socket = ""
+ for _, row := range []registry.Route{source, platform, wrong, sidecar, conflict, forward} {
+ put := e.reg.Upsert
+ if row.IsForward() {
+ put = e.reg.PutForward
+ }
+ if err := put(row); err != nil {
+ t.Fatal(err)
+ }
+ }
+ for _, a := range []registry.RouteAlias{{Alias: "custom.example.com", Host: source.Host}, {Alias: "*.shops.example.com", Host: source.Host}, {Alias: "wrong-alias.example.com", Host: wrong.Host}, {Alias: "sidecar-alias.example.com", Host: sidecar.Host}} {
+ a.App = source.App
+ if err := e.reg.UpsertAlias(a); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if len(e.ReplicaSnapshots()) != 2 {
+ t.Fatalf("validated source and forward sets missing: %+v", e.ReplicaSnapshots())
+ }
+ replicaSettled(t, clock, 4)
+ clock.advance(time.Second)
+ replicaSettled(t, clock, 8)
+ var sourceSet, aliasSet string
+ for _, host := range []string{source.Host, platform.Host, "custom.example.com", "branch.shops.example.com", forward.Host} {
+ w := replicaRoutingGet(e, host)
+ if w.Code != 200 || w.Body.String() != "set" {
+ t.Fatalf("%s: %d %s", host, w.Code, w.Body)
+ }
+ up, ok := e.lookupUpstream(host)
+ if !ok || up.route.Account != source.Account || up.hibernating || !up.viaTunnel {
+ t.Fatalf("alias tenancy %s: %+v", host, up)
+ }
+ if host == source.Host {
+ sourceSet = up.route.FleetBoxes
+ } else {
+ aliasSet = up.route.FleetBoxes
+ }
+ if sourceSet != "" && aliasSet != "" && sourceSet != aliasSet {
+ t.Fatal("alias changed set")
+ }
+ }
+ before := dials.Load()
+ for _, host := range []string{wrong.Host, "wrong-alias.example.com", conflict.Host} {
+ if w := replicaRoutingGet(e, host); w.Code == 200 || e.Allowed(host) {
+ t.Fatalf("refused owner served %s", host)
+ }
+ }
+ wrongOwnerDials := dials.Load() - before
+ before = dials.Load()
+ for _, host := range []string{sidecar.Host, "sidecar-alias.example.com"} {
+ if w := replicaRoutingGet(e, host); w.Code == 200 || e.Allowed(host) {
+ t.Fatalf("sidecar served %s", host)
+ }
+ }
+ sidecarDials := dials.Load() - before
+ // TestReplicaAliasesPreserveSetAuthority
+ if sourceSet != aliasSet || wrongOwnerDials != 0 || sidecarDials != 0 {
+ t.Fatal("alias or dispatch escaped set authority")
+ }
+ // The same verdict also controls edges-file and alias-parent consumers.
+ rows, _ := e.reg.List()
+ verdict := FleetArmVerdict(rows, map[string]string{"pi": source.Account}, true, true)
+ for _, host := range []string{source.Host, platform.Host, forward.Host} {
+ if verdict.Served[host].Account != source.Account {
+ t.Fatalf("verdict lost %s", host)
+ }
+ }
+ t.Setenv("CARLOS_FLEET", "pi")
+ if err := e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if w := replicaRoutingGet(e, forward.Host); w.Code == 200 || e.Allowed(forward.Host) {
+ t.Fatal("non-hub forward served")
+ }
+ t.Setenv("CARLOS_FLEET", "")
+ // PutForward refuses backend columns; inject one as an on-disk corruption.
+ corruptRow(t, e.reg.Path(), forward.Host, "addr", "127.0.0.1:1")
+ if err := e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if w := replicaRoutingGet(e, forward.Host); w.Code == 200 || e.Allowed(forward.Host) {
+ t.Fatal("forbidden forward column served")
+ }
+}
+
+func TestReplicaReloadAndBindingRace(t *testing.T) {
+ e, rt, clock := replicaRoutingFixture(t, func(http.ResponseWriter, *http.Request) {})
+ if err := e.reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ if err := e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ p := e.replicaProbes
+ p.mu.Lock()
+ removed, survivor := p.jobs[replicaSlot{rt.Host, "box-00"}], p.jobs[replicaSlot{rt.Host, "box-01"}]
+ p.mu.Unlock()
+ if removed == nil || survivor == nil {
+ t.Fatal("Reload did not create probe jobs")
+ }
+ replicaSettled(t, clock, 2)
+ clock.advance(time.Second)
+ replicaSettled(t, clock, 4)
+ rt.FleetBoxes = `["box-01"]`
+ rt.ReplicaRevision++
+ if err := e.reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ var wg sync.WaitGroup
+ for i := 0; i < 8; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ if err := e.Reload(); err != nil {
+ t.Error(err)
+ }
+ }()
+ }
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for i := 0; i < 20; i++ {
+ e.tunnels.CloseChannel("pi/box-00")
+ replicaConnect(e.tunnels, "pi/box-00")
+ }
+ }()
+ done := make(chan struct{})
+ go func() { wg.Wait(); close(done) }()
+ select {
+ case <-done:
+ case <-time.After(5 * time.Second):
+ t.Fatal("Reload deadlock")
+ }
+ select {
+ case <-removed.done:
+ case <-time.After(5 * time.Second):
+ t.Fatal("removed job leaked")
+ }
+ p.mu.Lock()
+ same := p.jobs[replicaSlot{rt.Host, "box-01"}] == survivor
+ n := len(p.jobs)
+ p.mu.Unlock()
+ if !same || n != 1 {
+ t.Fatalf("survivor restarted or removed job kept: %v %d", same, n)
+ }
+ live := p.Live(rt.Host)
+ if len(live) != 1 || live[0].Box != "box-01" {
+ t.Fatalf("revision filtered survivor or removed box live: %+v", live)
+ }
+ rt.ReplicaIncarnation = "next-life"
+ if err := e.reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ if err := e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ if len(p.Live(rt.Host)) != 0 {
+ t.Fatal("old lifetime health survived")
+ }
+ select {
+ case <-survivor.done:
+ case <-time.After(5 * time.Second):
+ t.Fatal("old lifetime job leaked")
+ }
+ e.stopReplicaProbes()
+ if !reflect.DeepEqual(e.ReplicaSnapshots(), map[string]replicas.Snapshot{}) {
+ t.Fatal("shutdown retained jobs")
+ }
+}
diff --git a/internal/edge/replicaprober.go b/internal/edge/replicaprober.go
index f3509529e..4e238c724 100644
--- a/internal/edge/replicaprober.go
+++ b/internal/edge/replicaprober.go
@@ -93,9 +93,8 @@ func newReplicaProber(hub *TunnelHub, probe replicaProbeFunc, clock replicaProbe
return &replicaProber{hub: hub, probe: probe, clock: clock, jobs: make(map[replicaSlot]*replicaJob), routes: make(map[string]registry.Route)}
}
-// Sync is deliberately not called by Reload until Task 3 supplies the fleet
-// arm's validated set. This additional fence keeps legacy rows inert even if
-// a caller accidentally supplies the complete route listing.
+// Sync receives the fleet verdict's validated sets. The second check keeps
+// legacy rows inert if a caller supplies the complete route listing.
func (p *replicaProber) Sync(routes []registry.Route) {
p.mu.Lock()
defer p.mu.Unlock()
@@ -399,18 +398,25 @@ func (h *TunnelHub) probeReplica(ctx context.Context, channel, host string) (rep
return c, nil
}
-// syncReplicaProbes is the explicit Task 3 integration seam. Merely creating
-// an edge, reloading legacy routes or reading snapshots starts no job.
-func (e *Edge) syncReplicaProbes(routes []registry.Route) {
- if e.tunnels == nil {
- return
- }
+// Creating the table starts no jobs; Reload syncs only after its reads succeed.
+func (e *Edge) replicaProberForRouting() *replicaProber {
e.replicaMu.Lock()
defer e.replicaMu.Unlock()
if e.replicaProbes == nil {
e.replicaProbes = newReplicaProber(e.tunnels, e.ReplicaProbe, nil)
}
- e.replicaProbes.Sync(routes)
+ return e.replicaProbes
+}
+func (e *Edge) syncReplicaProbes(routes []registry.Route) {
+ e.replicaMu.Lock()
+ p := e.replicaProbes
+ e.replicaMu.Unlock()
+ if p == nil && len(routes) > 0 && e.tunnels != nil {
+ p = e.replicaProberForRouting()
+ }
+ if p != nil {
+ p.Sync(routes)
+ }
}
func (e *Edge) ReplicaSnapshots() map[string]replicas.Snapshot {
e.replicaMu.Lock()
diff --git a/internal/host/replica_request_budget_test.go b/internal/host/replica_request_budget_test.go
index 91105d93c..7a7dc876e 100644
--- a/internal/host/replica_request_budget_test.go
+++ b/internal/host/replica_request_budget_test.go
@@ -18,6 +18,7 @@ import (
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/replicas"
+ "github.com/carlosframework/platform/internal/status"
)
type replicaTraceStore struct {
@@ -43,6 +44,7 @@ func (s *replicaTraceStore) ListDirs(ctx context.Context, key string) ([]string,
}
func TestReplicaRequestBudget(t *testing.T) {
+ t.Run("routing-and-status", replicaRoutingRequestBudget)
t.Run("reconcile-versus-1b", replicaReconcileBudget)
ctx := context.Background()
var baseline [][]string
@@ -410,3 +412,95 @@ func TestReplicaBlockedACKDoesNotBlockReconcile(t *testing.T) {
t.Fatal("blocked ACK held reconcileMu")
}
}
+
+func replicaRoutingRequestBudget(t *testing.T) {
+ w := replicaTunnelFixture(t)
+ prev := upstreamSource.Load()
+ setUpstreamSource(w.e.UpstreamStates)
+ t.Cleanup(func() {
+ if prev != nil {
+ upstreamSource.Store(prev)
+ } else {
+ setUpstreamSource(nil)
+ }
+ })
+ const cycles, requests = 5, 100
+ calls := w.store.count(func() {
+ w.ready(t, 2)
+ replicaHostWait(t, "five probe cycles per copy", func() bool { return w.probes[0].Load() >= cycles && w.probes[1].Load() >= cycles })
+ for i := 0; i < requests; i++ {
+ w.get(t)
+ }
+ })
+ if len(calls) != 0 {
+ t.Fatalf("bucket calls over %d cycles and %d forwards:%s", cycles, requests, showCalls(calls))
+ }
+ ctx := context.Background()
+ tick := func(with bool) map[string]int {
+ return w.store.count(func() {
+ p := status.Probes{MachineID: "replica-budget"}
+ if with {
+ p.Upstreams = upstreamStates()
+ }
+ if err := statusTick(ctx, w.store, w.reg, p, false, ""); err != nil {
+ t.Fatal(err)
+ }
+ })
+ }
+ before, after := tick(false), tick(true)
+ if !reflect.DeepEqual(before, after) || len(after) != 2 {
+ t.Fatalf("status added bucket calls: before%s after%s", showCalls(before), showCalls(after))
+ }
+ for call, n := range after {
+ if (!strings.HasPrefix(call, "PUT status/boxes/") && !strings.HasPrefix(call, "GET status/boxes/")) || n != 1 {
+ t.Fatalf("unexpected heartbeat: %s x%d", call, n)
+ }
+ }
+ if status.SnapshotPeriod != 5*time.Minute {
+ t.Fatal("heartbeat cadence changed")
+ }
+ raw, _, err := w.store.Get(ctx, "status/boxes/"+status.Label("replica-budget")+".json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var box struct {
+ Metrics struct {
+ Upstreams map[string][]struct {
+ Copy map[string]any `json:"replica_copy"`
+ } `json:"upstreams"`
+ } `json:"metrics"`
+ }
+ if err = json.Unmarshal(raw, &box); err != nil {
+ t.Fatal(err)
+ }
+ copies := box.Metrics.Upstreams[w.rt.Host]
+ if len(copies) != 2 || copies[0].Copy["box"] != "box-a" || copies[1].Copy["box"] != "box-b" || copies[1].Copy["workers_running"] != float64(2) {
+ t.Fatalf("historical copies missing: %s", raw)
+ }
+ // Caller-owned maps must not mutate live health.
+ states := upstreamStates()
+ states[w.rt.Host][0].ReplicaCopy.Box = "changed"
+ delete(states, w.rt.Host)
+ if upstreamStates()[w.rt.Host][0].ReplicaCopy.Box != "box-a" {
+ t.Fatal("heartbeat shares live storage")
+ }
+ snap := w.e.ReplicaSnapshots()
+ snap[w.rt.Host].Copies[0].Box = "changed"
+ if w.e.ReplicaSnapshots()[w.rt.Host].Copies[0].Box != "box-a" {
+ t.Fatal("snapshot shares live storage")
+ }
+ if _, err := w.reg.DeleteForward(w.rt.Host); err != nil {
+ t.Fatal(err)
+ }
+ if err := w.e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ tick(true)
+ raw, _, err = w.store.Get(ctx, "status/boxes/"+status.Label("replica-budget")+".json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if strings.Contains(string(raw), "replica_copy") {
+ t.Fatalf("retired copies remain: %s", raw)
+ }
+}
diff --git a/internal/host/replica_tunnel_e2e_test.go b/internal/host/replica_tunnel_e2e_test.go
new file mode 100644
index 000000000..f5e8e154b
--- /dev/null
+++ b/internal/host/replica_tunnel_e2e_test.go
@@ -0,0 +1,281 @@
+package host
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/hex"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "path/filepath"
+ "strings"
+ "sync"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/edge"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/replicas"
+ "github.com/carlosframework/platform/internal/tunnelclient"
+)
+
+type replicaTunnelWorld struct {
+ e *edge.Edge
+ hub *edge.TunnelHub
+ reg *registry.Registry
+ store *budgetStore
+ rt registry.Route
+ url string
+ probes, requests [2]atomic.Int32
+ stops [2]func()
+}
+
+func replicaHostWait(t *testing.T, what string, fn func() bool) {
+ t.Helper()
+ deadline := time.Now().Add(8 * time.Second)
+ for time.Now().Before(deadline) {
+ if fn() {
+ return
+ }
+ time.Sleep(10 * time.Millisecond)
+ }
+ t.Fatalf("timeout: %s", what)
+}
+
+func replicaTunnelFixture(t *testing.T) *replicaTunnelWorld {
+ t.Helper()
+ reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ w := &replicaTunnelWorld{reg: reg, store: &budgetStore{Store: release.NewDirStore(t.TempDir())}, rt: registry.Route{Host: "shop.example.com", Kind: registry.KindForward, Account: "bah", App: "shop", Slug: "shop", Region: "fleet/home", Stateless: true, FleetBoxes: `["box-a","box-b"]`, Copies: 2, ReplicaRevision: 7, ReplicaIncarnation: "life"}}
+ if err = reg.UpsertFleet(registry.Fleet{Name: "home", Account: "bah", Bucket: "home-data"}); err != nil {
+ t.Fatal(err)
+ }
+ for _, box := range []string{"box-a", "box-b"} {
+ hash := sha256.Sum256([]byte(box + "-token"))
+ if err = reg.AddFleetBox(registry.FleetBox{Fleet: "home", Label: box, TokenHash: hex.EncodeToString(hash[:]), Status: "active"}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ w.e, err = edge.New(reg, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ srv := httptest.NewServer(w.e)
+ w.url = srv.URL
+ t.Cleanup(srv.Close)
+ u, _ := url.Parse(srv.URL)
+ t.Setenv("CARLOS_TUNNEL_HOST", u.Hostname())
+ t.Setenv("CARLOS_FLEET", "")
+ w.hub = edge.NewTunnelHub(u.Hostname(), nil)
+ w.e.EnableTunnels(w.hub)
+ if err = reg.PutForward(w.rt); err != nil {
+ t.Fatal(err)
+ }
+ w.e.EnableStatic(w.store, nil, t.TempDir())
+ if err = w.e.Reload(); err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() {
+ for _, stop := range w.stops {
+ if stop != nil {
+ stop()
+ }
+ }
+ if _, err := reg.DeleteForward(w.rt.Host); err != nil {
+ t.Error(err)
+ }
+ if err := w.e.Reload(); err != nil {
+ t.Error(err)
+ }
+ })
+ w.start(t, 0, "boot-a")
+ w.start(t, 1, "boot-b")
+ return w
+}
+
+func (w *replicaTunnelWorld) start(t *testing.T, i int, boot string) {
+ t.Helper()
+ box := []string{"box-a", "box-b"}[i]
+ app := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
+ w.requests[i].Add(1)
+ rw.Header().Set("X-App-Box", box)
+ fmt.Fprint(rw, box)
+ })
+ handler := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
+ if r.URL.Path == "/__carlos/replica-probe" {
+ if !tunnelclient.FromTunnel(r.Context()) || r.Header.Get(tunnelclient.ReplicaProbeHeader) != "1" {
+ http.NotFound(rw, r)
+ return
+ }
+ w.probes[i].Add(1)
+ json.NewEncoder(rw).Encode(replicas.Copy{Host: w.rt.Host, Account: w.rt.Account, App: w.rt.App, Fleet: "home", Box: box, Incarnation: w.rt.ReplicaIncarnation, AssignmentRevision: w.rt.ReplicaRevision, BootID: boot, Generation: 1, Version: "v1", Digest: strings.Repeat("a", 64), State: "running", Healthy: true, WorkersDeclared: 2, WorkersRunning: i + 1})
+ return
+ }
+ app.ServeHTTP(rw, r)
+ })
+ ctx, cancel := context.WithCancel(context.Background())
+ done := make(chan struct{})
+ go func() {
+ defer close(done)
+ tunnelclient.Loop(ctx, tunnelclient.Config{URL: w.url, Name: "home/" + box, Token: box + "-token", Handler: handler, Logf: func(string, ...any) {}})
+ }()
+ var once sync.Once
+ w.stops[i] = func() {
+ once.Do(func() {
+ cancel()
+ w.hub.CloseChannel("home/" + box)
+ select {
+ case <-done:
+ case <-time.After(5 * time.Second):
+ t.Error("tunnel did not stop")
+ }
+ })
+ }
+ replicaHostWait(t, "connected "+box, func() bool { return w.hub.State("home/"+box) == "connected" })
+}
+
+func (w *replicaTunnelWorld) ready(t *testing.T, n int) {
+ t.Helper()
+ replicaHostWait(t, "healthy copy set", func() bool {
+ count := 0
+ for _, c := range w.e.ReplicaSnapshots()[w.rt.Host].Copies {
+ if c.Healthy {
+ count++
+ }
+ }
+ return count == n
+ })
+}
+func (w *replicaTunnelWorld) get(t *testing.T) string {
+ t.Helper()
+ req, err := http.NewRequest("GET", w.url+"/", nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ req.Host = w.rt.Host
+ client := &http.Client{Timeout: 5 * time.Second}
+ res, err := client.Do(req)
+ if err != nil {
+ t.Fatal(err)
+ }
+ body, err := io.ReadAll(res.Body)
+ res.Body.Close()
+ if err != nil || res.StatusCode != 200 {
+ t.Fatalf("forward: %d %q %v", res.StatusCode, body, err)
+ }
+ if res.Header.Get("X-App-Box") != string(body) {
+ t.Fatal("wrong app response")
+ }
+ return string(body)
+}
+
+func TestReplicaTwoBoxTunnelFailover(t *testing.T) {
+ w := replicaTunnelFixture(t)
+ calls := w.store.count(func() {
+ w.ready(t, 2)
+ for i := 0; i < 100; i++ {
+ w.get(t)
+ }
+ if a, b := w.requests[0].Load(), w.requests[1].Load(); a != 50 || b != 50 {
+ t.Fatalf("unbalanced %d/%d", a, b)
+ }
+ snapshot := w.e.ReplicaSnapshots()[w.rt.Host]
+ if len(snapshot.Copies) != 2 || snapshot.Copies[0].WorkersRunning != 1 || snapshot.Copies[1].WorkersRunning != 2 || snapshot.Copies[0].WorkersDeclared != 2 {
+ t.Fatalf("worker metadata: %+v", snapshot)
+ }
+ w.stops[0]()
+ for i := 0; i < 30; i++ {
+ if box := w.get(t); box != "box-b" {
+ t.Fatalf("lost-box request reached %s", box)
+ }
+ }
+ w.ready(t, 1)
+ before := w.probes[0].Load()
+ w.start(t, 0, "boot-a-return")
+ // A new tunnel must earn new health even though its assignment is unchanged.
+ for _, c := range w.e.ReplicaSnapshots()[w.rt.Host].Copies {
+ if c.Box == "box-a" && c.Healthy {
+ t.Fatal("reconnected copy inherited health")
+ }
+ }
+ w.ready(t, 2)
+ if w.probes[0].Load()-before < 2 {
+ t.Fatal("readmission without two probes")
+ }
+ a, b := w.requests[0].Load(), w.requests[1].Load()
+ for i := 0; i < 100; i++ {
+ w.get(t)
+ }
+ if w.requests[0].Load()-a != 50 || w.requests[1].Load()-b != 50 {
+ t.Fatal("return did not rebalance")
+ }
+ })
+ if len(calls) != 0 {
+ t.Fatalf("probes/forwarding touched bucket:%s", showCalls(calls))
+ }
+}
+
+func TestReplicaReloadAndBindingRace(t *testing.T) {
+ w := replicaTunnelFixture(t)
+ w.ready(t, 2)
+ ctx := context.Background()
+ raw, _ := json.Marshal(FleetBinding{Host: w.rt.Host, Fleet: "home", Box: "box-a"})
+ if _, err := w.store.Put(ctx, fleetBindingKey("home", w.rt.Host), raw, ""); err != nil {
+ t.Fatal(err)
+ }
+ next := w.rt
+ next.FleetBoxes = `["box-b"]`
+ next.ReplicaRevision++
+ if err := w.reg.PutForward(next); err != nil {
+ t.Fatal(err)
+ }
+ var wg sync.WaitGroup
+ for i := 0; i < 6; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ if err := ReconcileFleetBindings(ctx, w.store, w.reg); err != nil {
+ t.Error(err)
+ }
+ if err := w.e.Reload(); err != nil {
+ t.Error(err)
+ }
+ }()
+ }
+ w.stops[0]()
+ w.start(t, 0, "removed-reconnect")
+ done := make(chan struct{})
+ go func() { wg.Wait(); close(done) }()
+ select {
+ case <-done:
+ case <-time.After(5 * time.Second):
+ t.Fatal("binding/reload deadlock")
+ }
+ got, err := w.reg.Get(w.rt.Host)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got.FleetBoxes != next.FleetBoxes || got.FleetBox != "" || got.FleetLabel != "" || got.ReplicaRevision != next.ReplicaRevision {
+ t.Fatalf("legacy binding overwrote set: %+v", got)
+ }
+ before := w.requests[0].Load()
+ for i := 0; i < 20; i++ {
+ if box := w.get(t); box != "box-b" {
+ t.Fatalf("removed member dispatched: %s", box)
+ }
+ }
+ if w.requests[0].Load() != before {
+ t.Fatal("removed member dialled")
+ }
+ snap := w.e.ReplicaSnapshots()[w.rt.Host]
+ if len(snap.Copies) != 1 || snap.Copies[0].Box != "box-b" {
+ t.Fatalf("removed probe retained: %+v", snap)
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index ae7f319fd..aa9aea569 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -82,4 +82,4 @@ plan14-root-reads-region-ha-followups.tsv cfb026f1f9d59f325937cbddf26df2d94d5240
plan14-root-reads-region-ha-p3a.tsv f44d209a054eee55fdee54227d419b74c34a9b2fc174c7a0bb74d5c2711a68bb
plan14-root-reads-stateless-coordinator-route.tsv 7974cb078e82272605cbc8ef6809c9ae5e0b02edc22ca843cd2ef4b38d9e44e9
plan14-root-reads-stateless-replicas-2.tsv 59c0891618b9befae27ebe04d0a67b08c7f7658bca9f1c78bf6d05eb7a708e82
-plan14-root-reads-stateless-replicas-3.tsv 00eef8089c6cd9ba4725c22c618e871d3b038c958b3db906e1fc6af49ef9a65f
+plan14-root-reads-stateless-replicas-3.tsv 94200054efc8bc2fce33fba728d6578bb9f7742105f4a266ed92c9365931bf9c
diff --git a/internal/provision/testdata/plan14-root-reads-stateless-replicas-3.tsv b/internal/provision/testdata/plan14-root-reads-stateless-replicas-3.tsv
index 08ed48bd6..3caa2b12e 100644
--- a/internal/provision/testdata/plan14-root-reads-stateless-replicas-3.tsv
+++ b/internal/provision/testdata/plan14-root-reads-stateless-replicas-3.tsv
@@ -1,12 +1,13 @@
# Census overlay stateless-replicas-3, written by census-propose (#369). census-ruling-stateless-replicas-3, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-stateless-replicas-3.md.
-# 3 body, 1 sites, 6 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
-# 17 new dispositions: 0 reads re-frozen at their disposition with the claim, 17 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+# 4 body, 2 sites, 7 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 19 new dispositions: 2 reads re-frozen at their disposition with the claim, 17 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
@legacy a02e5c799c0ab4fefc6cbd35bc424a93c61924373619e65ef0af15d99d97bd12 internal/edge/edge.go RunWithActivatorReady legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority. data-literal@129,data-literal@148,data-literal@284,data-literal@417,file:Open@1013 141655c4967b15b262faaa0f21a9e3514e8844162ef6c62db699e78638456c10
+@legacy 4e896298c4fc9d37f3c50efde3284977a1d5af8fb1ee85211570c867b1e9f25f internal/edge/fleetforward.go FleetArmVerdict legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 fix round 3: the single fleet-arm refusal decision over one listing, used by Edge.Reload, the edges-file writer and the alias pass (parity by construction); returns the refused set with reasons and the accountless notes (+registry:Host x3, +registry:Status, +whole:Route x3). Pure; no I/O. Review R1 finding 2: also returns Served, each admitted row Reload sends through the fleet arm (a forward row, or a fleet-placed row with no Tunnel) with its fleet, app and the fleet owner from owners; a host the alias step refuses is dropped from it (+registry:App, +registry:Host, +registry:Region, +registry:Tunnel on the listing it already holds). Pure; no I/O. Review R2: the pre-fold fleet rows are now Arm; Served is the destination after the platform-alias fold: every ready, unrefused, non-sidecar row DispatchArm gives an entry, with its Arm fleet when its arm is a fleet's, folded by foldPlatformAliases (Reload's own fold), keeping the hosts that go to a fleet (+registry:Host, +registry:Status, +whole:Route on the listing it already holds). Pure; no I/O; refusals unchanged.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: classify ArmReplica as fleet-served for the existing shared routing, edges-file and alias verdict. Existing field reads unchanged; pure in-memory decision, same owner and alias checks. registry:App@798,registry:Host@1436,registry:Host@1496,registry:Host@1619,registry:Host@1679,registry:Host@380,registry:Host@563,registry:Host@622,registry:Host@756,registry:Region@687,registry:Status@1368,registry:Status@320,registry:Tunnel@728,whole:Route@1336,whole:Route@1526,whole:Route@1735,whole:Route@268,whole:Route@522,whole:Route@870 45a015c3eee5a73cf4f07aa7e0b2501cf8cb9587aae1e6218a733540b3219094
@legacy d1fceb749957ef6abc6e2c02bdfae532fcdaba22eb152dc0acbfe00051699e16 internal/edge/reqrecords.go requestResponse legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-request-records;identity=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=new: a pure constructor: copies the account (release.RouteAccount of the route), app, host and environment of the route row the edge already resolved for this request, and the request's method, path, raw query, User-Agent, client address and GeoIP country (from the request context), with the status, into a reqrec.Response; the recorder masks the path, keeps only the query's names, and stores the client address only as its /24 (IPv6 /48) prefix and a day-salted hash before anything is stored; the account and app come from the route row, never the Host header; it reads no file, no store and no box state, writes nothing, and makes no decision; the class of Edge.emitEdgeError and UsageMeter.Record (J1 root-route);rev3=census-ruling-stateless-replicas-3;basis=Task 2: copy the final replica box and attempt count from the existing per-request outcome into additive reqrec.Response fields. Existing four Route reads unchanged; no new external read, path, credential or authority. The observer still records one client response at the hub; ordinary requests retain zero fields. registry:App@190,registry:Environment@226,registry:Host@204,whole:Route@180 0eb4f75b1d48476ac610f69e0c3621a44995eb6c4ebf63d002c95a3496ad7c0e
@legacy eef846cad40472c4151369c696b1da1835b1e24c5b3d317d81667571039ffcc8 internal/activator/replicaprobe.go Service.ProbeCopy legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: read the local registry assignment and the already-awake entry's launch/worker evidence under the held-leg predicate; compare account, app, fleet, box membership and lifetime; no bucket call, wake, authority acquisition or activity update. Added registry field and whole Route reads are the existing local projection, not tenant-selected paths. registry:Account@1564,registry:App@1581,registry:FleetBoxes@306,registry:HA@402,registry:HA@891,registry:Hibernate@386,registry:Hibernate@874,registry:Incarnation@819,registry:Incarnation@838,registry:Kind@361,registry:Region@1135,registry:Region@792,registry:Region@806,registry:ReplicaIncarnation@1658,registry:ReplicaIncarnation@741,registry:ReplicaIncarnation@767,registry:ReplicaRevision@1703,registry:Stateless@857,whole:Route@1083,whole:Route@1089,whole:Route@296,whole:Route@683,whole:Route@714,whole:Route@719 efe551a9cdf45284360710a083d19813120343f843ae9db9d3b4636d5f96d57c
@legacy 1852ab27b5e9593b9d9bc0f7c604e1f97d35a60368cdb6c7835a31307b90c13c internal/edge/replicaprobe.go Edge.replicaCopyMatches legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: compare Copy identity against the loaded Route's host, account, app, fleet, incarnation and assignment revision; local box must remain a member. Only in-memory registry field reads; no file or bucket reads. registry:Account@213,registry:App@251,registry:Host@170,registry:Region@115,registry:ReplicaIncarnation@325,registry:ReplicaRevision@374 503766598b5be534178a0c843ad160082961a96577c7c591416f9921712614ce
@legacy 14804d70792904629f6a6c21a6c46994a723b86dee0c5b60ebf5bb8c8721aa55 internal/edge/replicaprobe.go Edge.serveReplicaProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 I4/F1: the dialled pathname comes from the serving Gen.Socket and, for shared/foreign layouts, can originate in the registry row Socket. Dial through unixdial.Checked: refuse the instance-control directory before connect and require getpeername to match the dialled path before sending HTTP, including symlink refusal. Existing Route reads unchanged. M5 handles request construction errors before RoundTrip; M2 uses the shared reason constant. Authenticated private landing, held-leg admission, one-second bound and post-response identity checks remain. registry:FleetBoxes@390,registry:HA@459,registry:Hibernate@443,registry:Host@346,registry:Kind@365,whole:Route@1025,whole:Route@1215,whole:Route@2268,whole:Route@706 8b158b6a5f414bc8290e9b13b0c27da2002920e837b7c9e98aea0771c98bac5e
-@legacy 25360f01e12d3e11dc94e974d2a499b43446540fc95132bbb97e89ce6d8bc0a9 internal/edge/replicaprober.go Edge.syncReplicaProbes legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: explicit integration seam passes supplied routes to the hub prober only when a tunnel hub exists. Not called from Reload or live routing in this slice. Whole Route use is in-memory; no registry query or bucket read. whole:Route@266 067356c5f648c50deed9ff3216dc2f4e61377f2de5328c86bd88d4bea4ae7175
+@legacy 3a540bf3e5aae4829b6f1f7767a744fb1808dc4e272641216b29323edfeaac3a internal/edge/replicaprober.go Edge.syncReplicaProbes legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 3: Reload now supplies only validated surviving replica source routes after its registry reads and alias folds. Reuse the edge-owned in-memory prober and sync supplied Route values, cancelling removed members and retaining surviving jobs. No new registry query, bucket read, pathname, or wake authority. whole:Route@144,whole:Route@239 df124ea61a025e3f463301eabf6c60d45c5189affb8a968d22b881c71c165837
@legacy 9e62a31cf6e58105bcd5f2c17836a0cdcab581d29b9065c57beb3f5eb444ad81 internal/edge/replicaprober.go TunnelHub.probeReplica legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: file:ReadAll is io.ReadAll of an HTTP response body from the existing authenticated tunnel transport, limited to 64 KiB plus an overflow byte and closed. Sends a fresh private GET with no visitor credentials, rejects non-200/non-JSON responses, never follows redirects. No filesystem path is opened. file:ReadAll@618 7514dbfa020b4da77546960850b279972a00dd8ec4404af719651925b23297ca
@legacy 53d7ac393dafdce750c86672f955dda2f3cdc7a1880b812edac521e83e96fc75 internal/edge/replicaprober.go newReplicaProber legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: allocate empty in-memory job and route maps; choose the existing tunnel transport adapter and clock. Whole Route is a map value type, not an external read. Construction starts no job. whole:Route@306 8090869d116edd4340609068c605baefe9e9ac7a71d9c882d65508ae01c79043
@legacy daf4b80f7b5335ec7d5347e38f8e498cd5da945e003e935cd054c82b4fbd488a internal/edge/replicaprober.go replicaIdentityMatches legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 Q13: compare reported host/account/app/fleet/box/incarnation against the surviving job and its current route view, before the revision-skew decision. Boot must be present; the connection pin is checked by record. In-memory Route fields only, no external read. registry:Account@169,registry:App@191,registry:Host@146,registry:Region@118,whole:Route@75 e20949646de55dab02bb4caf3e6e81c5edf5228696712c643e5027ce8add04fc
@@ -20,14 +21,18 @@
@legacy 51cdab60291494c5eee44a1a454be8ebf44abe3fc2f1f408e90d668e5a955f78 internal/edge/replicaprober.go sameReplicaJob legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 Q13/Q14: compare host/incarnation and owner/fleet only; the slot supplies the box and Sync checks current membership. Remove revision, copy count, FleetBoxes and per-host serving/good-build stamp comparisons. Pure comparisons of captured and supplied route fields; no external read. registry:Account@154,registry:Account@167,registry:App@181,registry:App@190,registry:Host@97,registry:Region@200,registry:Region@212,registry:ReplicaIncarnation@129,whole:Route@69 117b6aece8fee1e121c6a6b65f5a901ec752c30bedcb5bc64d64694b467ef23e
@legacy 5af61b9be2ebcc76b4871899e03d72ff5f5c5e8a86da58e9ccb435025f024165 internal/edge/tunnel.go tunnelWire.Read legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: the scanner's file:Read sites are net.Conn.Read on the existing authenticated reverse-channel connection, not filesystem reads. Notify closure on reader failure so copy health excludes closed connections immediately. No pathname, root-owned file or new network destination is introduced. file:Read@21,file:Read@62 eff57b35dc5f4f7e2f54e08b07e07b0a21d571c41704be0a3d1997db362b8234
@legacy 84e1fa64113c54c580f5f77b91da2456f49432aeae923f0ebf3b4d92e7e60c1b internal/host/replicahealth_linux.go serveReplicaHealth legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: Lstat checks the fixed agent-owned /run/carlos/.replicas directory and health.sock; Open opens that directory read-only for flock. Require directory ownership and mode 0700, socket 0600, preserve live/non-socket/ambiguous existing paths, and only remove proven stale sockets under the lock. Read-only snapshot handler, bounded shutdown and listener-owned unlink; not mounted into tenant namespaces. No root read of tenant-controlled input. file:Lstat@252,file:Lstat@906,file:Open@650 1ff1e05ec8222c2adf684421e40eb55c7590beba28a725e5035b08da04042cb2
+@legacy ef5572f16b111fccc40c8744df6df5613386e8880844be62ec786c9fd718934b internal/edge/fleetforward.go DispatchArm legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R2: Reload's dispatch order as one function over a row it serves (forward only when admitted to the fleet arm, own Tunnel where tunnels are on, fleet arm, socket, AddrList, static, status, else none), moved out of Reload's switch unchanged; read by Reload and FleetArmVerdict. Pure; no I/O.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: read FleetBoxes and ValidReplicaProjection on the supplied row before the legacy forward/tunnel/fleet arms. An admitted valid set selects ArmReplica; a set without fleet authority selects no arm. Local non-hub resident socket dispatch remains unchanged. No external read. registry:FleetBoxes@82,registry:Kind@466,registry:Kind@512,registry:Socket@376,registry:Tunnel@289 27183e653005eeb8b48fd9ed55a79b153a7ae6cf1536f51fd4586843d4975064
+@legacy 3ff362714db025c57a447061fbb76debe0c72f726dec64e050db774cc6e10598 internal/edge/fleetforward.go FleetServeEligible legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4 (§4.4 tenancy): a forward row is eligible only on a hub, inert, fleet-placed, its fleet in the fleets table and its raw Account non-empty and equal to the owner; a non-forward fleet-placed row: empty raw Account served and noted, else release.RouteAccount must equal the owner; raw field before RouteAccount (+registry:Account x7, +registry:Region x2, +registry:Tunnel, +whole:Route). Pure; no I/O.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: gate set routing on hub role, valid projection, nonempty account/app, instance or inert forward kind, no platform ownership, HA, hibernation or explicit tunnel. New reads are fields of the already-supplied Route. Existing fleet-owner and inert-forward checks still apply; no external read or expansion of destination authority. registry:Account@1100,registry:Account@1256,registry:Account@1354,registry:Account@1610,registry:Account@224,registry:Account@841,registry:Account@912,registry:Account@998,registry:App@244,registry:FleetBoxes@160,registry:HA@275,registry:Hibernate@284,registry:Kind@320,registry:Platform@260,registry:Region@145,registry:Region@679,registry:Tunnel@1057,registry:Tunnel@300,whole:Route@1532 c7caa48b160438d34219e899dbdcf8b7fc5f0a2b989f2de1f562500a9463e574
+@legacy c96003c22f327131507288de511ce1d1c82555e606504b69d6a35c98a56a23bd internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. registry:Account@9839,registry:Alias@24783,registry:Alias@24870,registry:Alias@25450,registry:App@9855,registry:Health@13580,registry:Health@13706,registry:Hibernate@29297,registry:Host@11166,registry:Host@11223,registry:Host@11259,registry:Host@12002,registry:Host@14189,registry:Host@14284,registry:Host@14572,registry:Host@14598,registry:Host@14650,registry:Host@19245,registry:Host@21152,registry:Host@21460,registry:Host@21487,registry:Host@22302,registry:Host@22874,registry:Host@25204,registry:Host@25253,registry:Host@27868,registry:Host@27893,registry:Host@27910,registry:Host@4397,registry:Host@4766,registry:Host@4820,registry:Host@4870,registry:Host@5890,registry:Host@6005,registry:Kind@17581,registry:Kind@17603,registry:Prefix@22849,registry:Socket@12066,registry:Socket@17460,registry:Socket@21468,registry:Status@4691,registry:Target@22861,registry:Tunnel@9699,registry:Tunnel@9870,registry:Version@17562,registry:Version@17664,whole:RegionalDomain@26092,whole:Route@11314,whole:Route@11422,whole:Route@12122,whole:Route@14723,whole:Route@14787,whole:Route@14838,whole:Route@21520,whole:Route@21527,whole:Route@21623,whole:Route@22737,whole:Route@23905,whole:Route@26084,whole:Route@26129,whole:Route@27774,whole:Route@27808,whole:Route@27896,whole:Route@27975,whole:Route@29299,whole:Route@294,whole:Route@3417,whole:Route@3475,whole:Route@4405,whole:Route@5919,whole:Route@6108,whole:Route@6241,whole:Route@6264,whole:Route@6279,whole:Route@7126,whole:Route@7234,whole:Route@9761,whole:RouteAlias@24754,whole:RoutePath@22280 3a0bdd66ab99319f58599ade38bd49a8a0a96ac656de2c62be2fd8f255ebd8a5
@legacy 7543220573485e822d13d2cf145e49bf557d9c0b4937327f0bfcba23e52a59a9 internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here.;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read;rev3=census-ruling-edge-asset-cache-3;basis=the asset cache's three hooks (asset cache plan 3): the request's reserved asset headers are deleted at entry (the fill assertion kept only beside a verified hop); on the exact-remote and lookup-miss branches the far catch (serveAssetFar) is tried before backhaulTo and backhaul; after the observer defer and main's hard and probe checks, a verified hop with a valid fill assertion is answered by serveAssetFillForHop; after the upgrade branch and before gzip and the shared cache, the local catch (serveAssetLocal); the observer defer skips only the usage meter for an acknowledged home fill (out.unbilled); the new reads live in the new units of the edge-asset-cache-3-decisions overlay; the same route row and read sites (25); no read added;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: straight after lookupUpstreamPath it calls regionalGate (regional.go), which for an entry built from a regional_domains row answers 503 to a hop or a deny entry before any arm that can leave the box (the exact-home backhaul, the far asset catch, the door dial, the miss backhaul), and lets a star match through only to the exact-home arm when ExactHome names another box for that distinct exact name; after the exact-home arm a regional deny entry the arm did not answer is refused (regionalRefuse, 503); refusals only, on the route map the edge already holds; read sites unchanged (25);rev3=census-ruling-static-headers;basis=the shared response cache is no longer looked up or filled for a static-kind route: one more read of the route row the edge already resolved (up.route.Kind == "static") in the cacheable expression; a refusal only, nothing new opened or followed;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2 (N-HA10): one call, frontForwardHA, right after the route lookup's !ok block and before the login POST; same reads;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4: loginPost and cacheable treat a forward row as not this box's to answer (IsForward(), +whole:Route x2): no login form and no shared cache for a forward host. Serving only.;rev3=census-ruling-tunnel-websockets;basis=Deletes the Carlos-Upgrade marker header from incoming requests and puts the upgrade admission (host, path, the entry tenancy, all in hand) on a tunnel arm request. For a login POST on an ungated ArmTunnel row it reads the visitor request body (bounded by gate.MaxFormBody, 413 past it; a request body, not a file) and resolves next against the entry Reload built (Gate, Route); the bytes pass on only when loginPassesThrough holds (spec 7, Tasks 3, 5 and 6).;rev3=census-ruling-console-protection-tab;basis=one more call in the observer defer, observeGuardCount(up.route, out), beside the observeRecords call that files the guard Match: it passes on the route row the defer already holds (+whole:Route) and the request outcome to the usage meter, which counts the check in memory. Called whether or not the request was unbilled, as observeRecords is. Nothing is opened, read or followed; no new kind of read; no check, refusal or serving decision changes.;rev3=census-ruling-probe-burst-limit;basis=answers a probe-burst notice POST (serveBurstNotice) ahead of every route for a non-door caller; builds the guard state for up.route and stamps its account and app (RouteAccount, App) for the cool-down's this-app/other-app label; for a catalogue match on a non-static or tunnelled route, offers the burst rule (in-memory limiter, burstDecide: 429 or a watch verdict, never a block for a fleet or forward row); the observer defer calls noteBurst(up.route, ...); the added sites are the route value already in hand (+registry:App, +whole:Route x5); no new root read or write kind;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): parses the request's query once (stripHoldMarker) to record the carlos_hold=1 mark in the request context; calls classifyHold on the upstream already resolved from the loaded map (the +whole:Route is that in-memory Route), including a second pass for a login POST; gives a marked request on a door-refused route the plain 404; adds the hold branch (planThrottleAdmit, rateAdmit, serveHeld) after the gate; and excludes marked requests from the shared cache. Reads only the request and the already-loaded upstream map; no registry or bucket read added.;rev3=census-ruling-region-ha-p3a;basis=Complete the P3a cut: an exact peer name with no dial target answers the approved admission 503 before local wildcard dispatch or asset serving. ExactHome and lookupHome stop fallback at a present non-dial entry; backhaulTo refuses an empty target before signing or dialing. Retain Task 3 local admission and fixed platform/unit exemptions. Two added whole Route uses feed the local in-memory admission predicate; existing Route values and store/path reads are unchanged.;rev3=census-ruling-stateless-coordinator-route;basis=P24/P25: POST only, exact /api/fleet/replicas/ prefix on the reserved tunnel host calls the existing local console proxy only for an unescaped, already-clean path; malformed forms remain on the hub. No new read sites relative to origin/main. Merge with main 3487d6f6 retains its region HA admission checks before routing and after login target lookup, its empty-home refusal, and their two existing whole:Route reads; these change this unit's digest relative to the previously approved branch tip 92b24a7d.;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: pass the already-resolved Route to the reserved replica-probe handler after acceptHop and existing admissionRefuses, requiring tunnel context plus private marker and refusing door/backhaul ingress. Added whole Route use only; scrub marker before forwarding; HA calls remain unchanged. file:ReadAll@15522,registry:App@21679,registry:Gate@14496,registry:Gate@26070,registry:Gate@26130,registry:Gate@26188,registry:Host@26173,registry:ImportGate@33573,registry:Kind@20541,registry:Kind@23979,registry:Kind@33515,registry:Kind@33544,whole:Route@14391,whole:Route@14502,whole:Route@17319,whole:Route@18103,whole:Route@18561,whole:Route@18753,whole:Route@20544,whole:Route@21605,whole:Route@21671,whole:Route@21682,whole:Route@21935,whole:Route@22030,whole:Route@22106,whole:Route@22150,whole:Route@22452,whole:Route@22482,whole:Route@23982,whole:Route@24267,whole:Route@26073,whole:Route@26133,whole:Route@26176,whole:Route@26191,whole:Route@27109,whole:Route@29172,whole:Route@33518,whole:Route@33547,whole:Route@33576,whole:Route@33608,whole:Route@35456,whole:Route@5576,whole:Route@5671 d86bb163dfe6c165cad91eb2a4713f3f862d6128a8ec59808e6dc638c3d44a49
internal/edge/edge.go RunWithActivatorReady legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-certwarm-wake;basis=registers the cert warm's nudge on OnReload and on the home map's new served-hosts wake (#386); nudge only sends on a buffered channel; no read added, same 5 sites;rev3=census-ruling-edge-roll-blip;basis=the :80/:443 (and dev) listeners are bound on the calling goroutine with net.Listen via listen()/listenAddr (same empty-address defaults as ListenAndServe) before the serve goroutines, which now call Serve/ServeTLS on them, and one log line names the bound addresses; no read added, same 5 sites;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): the inline home-map arming (newHomeMap, one boot Refresh, Store, run) moves unchanged into the new Edge.ArmHomeMap and is called here as e.ArmHomeMap(); same refresh, same timeout, same order. The reads are moved, none added.;rev3=census-ruling-agent-start-demo-1;basis=Logs the combined explicit wildcard parents through demoWildcardDomains; no new watcher or read loop.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: invoke the local admission Close before HTTP/HTTPS draining and door shutdown in both dev and normal listeners. Preserve merged main's startup behavior and its census basis; the same five read sites, no new reads.;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: defer stopping and joining the edge's replica jobs at shutdown. Existing five direct read sites unchanged; no new reader or authority. data-literal@129,data-literal@148,data-literal@284,data-literal@417,file:Open@1013 141655c4967b15b262faaa0f21a9e3514e8844162ef6c62db699e78638456c10
+internal/edge/fleetforward.go FleetArmVerdict legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 6 fix round 3: the single fleet-arm refusal decision over one listing, used by Edge.Reload, the edges-file writer and the alias pass (parity by construction); returns the refused set with reasons and the accountless notes (+registry:Host x3, +registry:Status, +whole:Route x3). Pure; no I/O. Review R1 finding 2: also returns Served, each admitted row Reload sends through the fleet arm (a forward row, or a fleet-placed row with no Tunnel) with its fleet, app and the fleet owner from owners; a host the alias step refuses is dropped from it (+registry:App, +registry:Host, +registry:Region, +registry:Tunnel on the listing it already holds). Pure; no I/O. Review R2: the pre-fold fleet rows are now Arm; Served is the destination after the platform-alias fold: every ready, unrefused, non-sidecar row DispatchArm gives an entry, with its Arm fleet when its arm is a fleet's, folded by foldPlatformAliases (Reload's own fold), keeping the hosts that go to a fleet (+registry:Host, +registry:Status, +whole:Route on the listing it already holds). Pure; no I/O; refusals unchanged.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: classify ArmReplica as fleet-served for the existing shared routing, edges-file and alias verdict. Existing field reads unchanged; pure in-memory decision, same owner and alias checks. registry:App@798,registry:Host@1436,registry:Host@1496,registry:Host@1619,registry:Host@1679,registry:Host@380,registry:Host@563,registry:Host@622,registry:Host@756,registry:Region@687,registry:Status@1368,registry:Status@320,registry:Tunnel@728,whole:Route@1336,whole:Route@1526,whole:Route@1735,whole:Route@268,whole:Route@522,whole:Route@870 45a015c3eee5a73cf4f07aa7e0b2501cf8cb9587aae1e6218a733540b3219094
internal/edge/reqrecords.go requestResponse legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-request-records;identity=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=new: a pure constructor: copies the account (release.RouteAccount of the route), app, host and environment of the route row the edge already resolved for this request, and the request's method, path, raw query, User-Agent, client address and GeoIP country (from the request context), with the status, into a reqrec.Response; the recorder masks the path, keeps only the query's names, and stores the client address only as its /24 (IPv6 /48) prefix and a day-salted hash before anything is stored; the account and app come from the route row, never the Host header; it reads no file, no store and no box state, writes nothing, and makes no decision; the class of Edge.emitEdgeError and UsageMeter.Record (J1 root-route);rev3=census-ruling-stateless-replicas-3;basis=Task 2: copy the final replica box and attempt count from the existing per-request outcome into additive reqrec.Response fields. Existing four Route reads unchanged; no new external read, path, credential or authority. The observer still records one client response at the hub; ordinary requests retain zero fields. registry:App@190,registry:Environment@226,registry:Host@204,whole:Route@180 0eb4f75b1d48476ac610f69e0c3621a44995eb6c4ebf63d002c95a3496ad7c0e
internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-region-ha-p1b3b-t;basis=Wire Service.SetDutyView to the live edge DutySnapshot in the ready callback. No new read; no new loop or cloud operation. B2 wires the registry as the persistent DutyStore before service startup; no new cloud or filesystem path. B3b: arm one journal-backed termination consumer before service startup using agentCtx and the shared confirmer; expose edge tick and join at edge shutdown. No new direct read sites.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. Merge resolution against origin/main 9bd45488 retains main's HA departure controller, lifecycle and duty wiring alongside the demo data store and worker; no read site added by the resolution.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: install closed fixed admission before every launch source, bind activator/backend and edge, wire the real termination Started lifecycle and role reader after the change index; close before cancellation/child shutdown. No new external reads or cloud authority. Fix R1: move bind/lifecycle/edge-option wiring into wireAgentAdmission and worker listing into runWorkerBootPassAfterAdmission. Worker boot waits for admission before listing then uses unchanged bounded wakes and per-host serialization; whole Route read moves to the helper. No new storage, cloud, or root execution authority. Preserve merged main's agent wiring and census basis; the branch removes one whole Route use by moving worker iteration to the helper, with no added read kind.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: arms a fleet-only worker using the existing registry, activator, backend and authenticated console transport. Owned worker stops and joins at shutdown. No new bucket reader. merge of origin/main 9b8b2c50: retain HA duty/departure lifecycle, wake-slot and existing agent wiring alongside the replica placement worker; no new read introduced by resolution. merge of origin/main 6be08467: Retain main demo configuration, admission, build and expiry wiring alongside the replica worker; merge-only body change, no additional read. merge of origin/main 7920cccf: Retain main box-role/group admission wiring and boot publication beside the owned replica worker and shutdown; main moves the boot registry List into runWorkerBootPassAfterAdmission, removing its inline whole Route site. No new read introduced by conflict resolution.;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 M3: retain the private snapshot source and cancel/join ownership, but use the replica-health-specific retry loop. It logs its first failure only and retains the existing exponential backoff capped at 30 seconds; unsupported builds return nil. Existing five direct read sites unchanged; no new credentials, bucket reader or app lifecycle action. file:Exec@18226,file:Open@1517,file:Statfs@47850,registry:App@11938,whole:Route@11930 916ecf4ddcec9c37f1233710a3e8dbba4d0c8b952d60b6a4831d45258b7591bc
internal/activator/replicaprobe.go Service.ProbeCopy legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: read the local registry assignment and the already-awake entry's launch/worker evidence under the held-leg predicate; compare account, app, fleet, box membership and lifetime; no bucket call, wake, authority acquisition or activity update. Added registry field and whole Route reads are the existing local projection, not tenant-selected paths. registry:Account@1564,registry:App@1581,registry:FleetBoxes@306,registry:HA@402,registry:HA@891,registry:Hibernate@386,registry:Hibernate@874,registry:Incarnation@819,registry:Incarnation@838,registry:Kind@361,registry:Region@1135,registry:Region@792,registry:Region@806,registry:ReplicaIncarnation@1658,registry:ReplicaIncarnation@741,registry:ReplicaIncarnation@767,registry:ReplicaRevision@1703,registry:Stateless@857,whole:Route@1083,whole:Route@1089,whole:Route@296,whole:Route@683,whole:Route@714,whole:Route@719 efe551a9cdf45284360710a083d19813120343f843ae9db9d3b4636d5f96d57c
internal/edge/replicaprobe.go Edge.replicaCopyMatches legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: compare Copy identity against the loaded Route's host, account, app, fleet, incarnation and assignment revision; local box must remain a member. Only in-memory registry field reads; no file or bucket reads. registry:Account@213,registry:App@251,registry:Host@170,registry:Region@115,registry:ReplicaIncarnation@325,registry:ReplicaRevision@374 503766598b5be534178a0c843ad160082961a96577c7c591416f9921712614ce
internal/edge/replicaprobe.go Edge.serveReplicaProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 I4/F1: the dialled pathname comes from the serving Gen.Socket and, for shared/foreign layouts, can originate in the registry row Socket. Dial through unixdial.Checked: refuse the instance-control directory before connect and require getpeername to match the dialled path before sending HTTP, including symlink refusal. Existing Route reads unchanged. M5 handles request construction errors before RoundTrip; M2 uses the shared reason constant. Authenticated private landing, held-leg admission, one-second bound and post-response identity checks remain. registry:FleetBoxes@390,registry:HA@459,registry:Hibernate@443,registry:Host@346,registry:Kind@365,whole:Route@1025,whole:Route@1215,whole:Route@2268,whole:Route@706 8b158b6a5f414bc8290e9b13b0c27da2002920e837b7c9e98aea0771c98bac5e
-internal/edge/replicaprober.go Edge.syncReplicaProbes legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: explicit integration seam passes supplied routes to the hub prober only when a tunnel hub exists. Not called from Reload or live routing in this slice. Whole Route use is in-memory; no registry query or bucket read. whole:Route@266 067356c5f648c50deed9ff3216dc2f4e61377f2de5328c86bd88d4bea4ae7175
+internal/edge/replicaprober.go Edge.syncReplicaProbes legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 3: Reload now supplies only validated surviving replica source routes after its registry reads and alias folds. Reuse the edge-owned in-memory prober and sync supplied Route values, cancelling removed members and retaining surviving jobs. No new registry query, bucket read, pathname, or wake authority. whole:Route@144,whole:Route@239 df124ea61a025e3f463301eabf6c60d45c5189affb8a968d22b881c71c165837
internal/edge/replicaprober.go TunnelHub.probeReplica legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: file:ReadAll is io.ReadAll of an HTTP response body from the existing authenticated tunnel transport, limited to 64 KiB plus an overflow byte and closed. Sends a fresh private GET with no visitor credentials, rejects non-200/non-JSON responses, never follows redirects. No filesystem path is opened. file:ReadAll@618 7514dbfa020b4da77546960850b279972a00dd8ec4404af719651925b23297ca
internal/edge/replicaprober.go newReplicaProber legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: allocate empty in-memory job and route maps; choose the existing tunnel transport adapter and clock. Whole Route is a map value type, not an external read. Construction starts no job. whole:Route@306 8090869d116edd4340609068c605baefe9e9ac7a71d9c882d65508ae01c79043
internal/edge/replicaprober.go replicaIdentityMatches legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 Q13: compare reported host/account/app/fleet/box/incarnation against the surviving job and its current route view, before the revision-skew decision. Boot must be present; the connection pin is checked by record. In-memory Route fields only, no external read. registry:Account@169,registry:App@191,registry:Host@146,registry:Region@118,whole:Route@75 e20949646de55dab02bb4caf3e6e81c5edf5228696712c643e5027ce8add04fc
@@ -41,10 +46,14 @@ internal/edge/replicaprober.go replicaProber.snapshots legacy accepted-legacy ac
internal/edge/replicaprober.go sameReplicaJob legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 Q13/Q14: compare host/incarnation and owner/fleet only; the slot supplies the box and Sync checks current membership. Remove revision, copy count, FleetBoxes and per-host serving/good-build stamp comparisons. Pure comparisons of captured and supplied route fields; no external read. registry:Account@154,registry:Account@167,registry:App@181,registry:App@190,registry:Host@97,registry:Region@200,registry:Region@212,registry:ReplicaIncarnation@129,whole:Route@69 117b6aece8fee1e121c6a6b65f5a901ec752c30bedcb5bc64d64694b467ef23e
internal/edge/tunnel.go tunnelWire.Read legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1b: the scanner's file:Read sites are net.Conn.Read on the existing authenticated reverse-channel connection, not filesystem reads. Notify closure on reader failure so copy health excludes closed connections immediately. No pathname, root-owned file or new network destination is introduced. file:Read@21,file:Read@62 eff57b35dc5f4f7e2f54e08b07e07b0a21d571c41704be0a3d1997db362b8234
internal/host/replicahealth_linux.go serveReplicaHealth legacy accepted-legacy accepted-legacy;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: Lstat checks the fixed agent-owned /run/carlos/.replicas directory and health.sock; Open opens that directory read-only for flock. Require directory ownership and mode 0700, socket 0600, preserve live/non-socket/ambiguous existing paths, and only remove proven stale sockets under the lock. Read-only snapshot handler, bounded shutdown and listener-owned unlink; not mounted into tenant namespaces. No root read of tenant-controlled input. file:Lstat@252,file:Lstat@906,file:Open@650 1ff1e05ec8222c2adf684421e40eb55c7590beba28a725e5035b08da04042cb2
+internal/edge/fleetforward.go DispatchArm legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): review R2: Reload's dispatch order as one function over a row it serves (forward only when admitted to the fleet arm, own Tunnel where tunnels are on, fleet arm, socket, AddrList, static, status, else none), moved out of Reload's switch unchanged; read by Reload and FleetArmVerdict. Pure; no I/O.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: read FleetBoxes and ValidReplicaProjection on the supplied row before the legacy forward/tunnel/fleet arms. An admitted valid set selects ArmReplica; a set without fleet authority selects no arm. Local non-hub resident socket dispatch remains unchanged. No external read. registry:FleetBoxes@82,registry:Kind@466,registry:Kind@512,registry:Socket@376,registry:Tunnel@289 27183e653005eeb8b48fd9ed55a79b153a7ae6cf1536f51fd4586843d4975064
+internal/edge/fleetforward.go FleetServeEligible legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4 (§4.4 tenancy): a forward row is eligible only on a hub, inert, fleet-placed, its fleet in the fleets table and its raw Account non-empty and equal to the owner; a non-forward fleet-placed row: empty raw Account served and noted, else release.RouteAccount must equal the owner; raw field before RouteAccount (+registry:Account x7, +registry:Region x2, +registry:Tunnel, +whole:Route). Pure; no I/O.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: gate set routing on hub role, valid projection, nonempty account/app, instance or inert forward kind, no platform ownership, HA, hibernation or explicit tunnel. New reads are fields of the already-supplied Route. Existing fleet-owner and inert-forward checks still apply; no external read or expansion of destination authority. registry:Account@1100,registry:Account@1256,registry:Account@1354,registry:Account@1610,registry:Account@224,registry:Account@841,registry:Account@912,registry:Account@998,registry:App@244,registry:FleetBoxes@160,registry:HA@275,registry:Hibernate@284,registry:Kind@320,registry:Platform@260,registry:Region@145,registry:Region@679,registry:Tunnel@1057,registry:Tunnel@300,whole:Route@1532 c7caa48b160438d34219e899dbdcf8b7fc5f0a2b989f2de1f562500a9463e574
+internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. registry:Account@9839,registry:Alias@24783,registry:Alias@24870,registry:Alias@25450,registry:App@9855,registry:Health@13580,registry:Health@13706,registry:Hibernate@29297,registry:Host@11166,registry:Host@11223,registry:Host@11259,registry:Host@12002,registry:Host@14189,registry:Host@14284,registry:Host@14572,registry:Host@14598,registry:Host@14650,registry:Host@19245,registry:Host@21152,registry:Host@21460,registry:Host@21487,registry:Host@22302,registry:Host@22874,registry:Host@25204,registry:Host@25253,registry:Host@27868,registry:Host@27893,registry:Host@27910,registry:Host@4397,registry:Host@4766,registry:Host@4820,registry:Host@4870,registry:Host@5890,registry:Host@6005,registry:Kind@17581,registry:Kind@17603,registry:Prefix@22849,registry:Socket@12066,registry:Socket@17460,registry:Socket@21468,registry:Status@4691,registry:Target@22861,registry:Tunnel@9699,registry:Tunnel@9870,registry:Version@17562,registry:Version@17664,whole:RegionalDomain@26092,whole:Route@11314,whole:Route@11422,whole:Route@12122,whole:Route@14723,whole:Route@14787,whole:Route@14838,whole:Route@21520,whole:Route@21527,whole:Route@21623,whole:Route@22737,whole:Route@23905,whole:Route@26084,whole:Route@26129,whole:Route@27774,whole:Route@27808,whole:Route@27896,whole:Route@27975,whole:Route@29299,whole:Route@294,whole:Route@3417,whole:Route@3475,whole:Route@4405,whole:Route@5919,whole:Route@6108,whole:Route@6241,whole:Route@6264,whole:Route@6279,whole:Route@7126,whole:Route@7234,whole:Route@9761,whole:RouteAlias@24754,whole:RoutePath@22280 3a0bdd66ab99319f58599ade38bd49a8a0a96ac656de2c62be2fd8f255ebd8a5
internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here.;rev3=census-ruling-edge-protection-2;basis=runs the guard, a pure in-memory matcher on r.URL.Path and RawQuery (internal/edgeguard), once per request after the meter and observer defer and before the password gate, the upgrade branch, the cache and the activator, for a request that is not a door call, a backhauled door hop or a tunnel delivery; a matched block answers a 404 itself through guardDecide; the two new sites are one expression, up.route.Kind == "static" (a static route this box serves checks only the hard tier here and leaves the probe tier to serveTree), a read of the route row the edge already resolved; no new kind of read;rev3=census-ruling-edge-asset-cache-3;basis=the asset cache's three hooks (asset cache plan 3): the request's reserved asset headers are deleted at entry (the fill assertion kept only beside a verified hop); on the exact-remote and lookup-miss branches the far catch (serveAssetFar) is tried before backhaulTo and backhaul; after the observer defer and main's hard and probe checks, a verified hop with a valid fill assertion is answered by serveAssetFillForHop; after the upgrade branch and before gzip and the shared cache, the local catch (serveAssetLocal); the observer defer skips only the usage meter for an acknowledged home fill (out.unbilled); the new reads live in the new units of the edge-asset-cache-3-decisions overlay; the same route row and read sites (25); no read added;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: straight after lookupUpstreamPath it calls regionalGate (regional.go), which for an entry built from a regional_domains row answers 503 to a hop or a deny entry before any arm that can leave the box (the exact-home backhaul, the far asset catch, the door dial, the miss backhaul), and lets a star match through only to the exact-home arm when ExactHome names another box for that distinct exact name; after the exact-home arm a regional deny entry the arm did not answer is refused (regionalRefuse, 503); refusals only, on the route map the edge already holds; read sites unchanged (25);rev3=census-ruling-static-headers;basis=the shared response cache is no longer looked up or filled for a static-kind route: one more read of the route row the edge already resolved (up.route.Kind == "static") in the cacheable expression; a refusal only, nothing new opened or followed;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2 (N-HA10): one call, frontForwardHA, right after the route lookup's !ok block and before the login POST; same reads;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 4: loginPost and cacheable treat a forward row as not this box's to answer (IsForward(), +whole:Route x2): no login form and no shared cache for a forward host. Serving only.;rev3=census-ruling-tunnel-websockets;basis=Deletes the Carlos-Upgrade marker header from incoming requests and puts the upgrade admission (host, path, the entry tenancy, all in hand) on a tunnel arm request. For a login POST on an ungated ArmTunnel row it reads the visitor request body (bounded by gate.MaxFormBody, 413 past it; a request body, not a file) and resolves next against the entry Reload built (Gate, Route); the bytes pass on only when loginPassesThrough holds (spec 7, Tasks 3, 5 and 6).;rev3=census-ruling-console-protection-tab;basis=one more call in the observer defer, observeGuardCount(up.route, out), beside the observeRecords call that files the guard Match: it passes on the route row the defer already holds (+whole:Route) and the request outcome to the usage meter, which counts the check in memory. Called whether or not the request was unbilled, as observeRecords is. Nothing is opened, read or followed; no new kind of read; no check, refusal or serving decision changes.;rev3=census-ruling-probe-burst-limit;basis=answers a probe-burst notice POST (serveBurstNotice) ahead of every route for a non-door caller; builds the guard state for up.route and stamps its account and app (RouteAccount, App) for the cool-down's this-app/other-app label; for a catalogue match on a non-static or tunnelled route, offers the burst rule (in-memory limiter, burstDecide: 429 or a watch verdict, never a block for a fleet or forward row); the observer defer calls noteBurst(up.route, ...); the added sites are the route value already in hand (+registry:App, +whole:Route x5); no new root read or write kind;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): parses the request's query once (stripHoldMarker) to record the carlos_hold=1 mark in the request context; calls classifyHold on the upstream already resolved from the loaded map (the +whole:Route is that in-memory Route), including a second pass for a login POST; gives a marked request on a door-refused route the plain 404; adds the hold branch (planThrottleAdmit, rateAdmit, serveHeld) after the gate; and excludes marked requests from the shared cache. Reads only the request and the already-loaded upstream map; no registry or bucket read added.;rev3=census-ruling-region-ha-p3a;basis=Complete the P3a cut: an exact peer name with no dial target answers the approved admission 503 before local wildcard dispatch or asset serving. ExactHome and lookupHome stop fallback at a present non-dial entry; backhaulTo refuses an empty target before signing or dialing. Retain Task 3 local admission and fixed platform/unit exemptions. Two added whole Route uses feed the local in-memory admission predicate; existing Route values and store/path reads are unchanged.;rev3=census-ruling-stateless-coordinator-route;basis=P24/P25: POST only, exact /api/fleet/replicas/ prefix on the reserved tunnel host calls the existing local console proxy only for an unescaped, already-clean path; malformed forms remain on the hub. No new read sites relative to origin/main. Merge with main 3487d6f6 retains its region HA admission checks before routing and after login target lookup, its empty-home refusal, and their two existing whole:Route reads; these change this unit's digest relative to the previously approved branch tip 92b24a7d.;rev3=census-ruling-stateless-replicas-3;basis=Task 1a: pass the already-resolved Route to the reserved replica-probe handler after acceptHop and existing admissionRefuses, requiring tunnel context plus private marker and refusing door/backhaul ingress. Added whole Route use only; scrub marker before forwarding; HA calls remain unchanged. file:ReadAll@15522,registry:App@21679,registry:Gate@14496,registry:Gate@26070,registry:Gate@26130,registry:Gate@26188,registry:Host@26173,registry:ImportGate@33573,registry:Kind@20541,registry:Kind@23979,registry:Kind@33515,registry:Kind@33544,whole:Route@14391,whole:Route@14502,whole:Route@17319,whole:Route@18103,whole:Route@18561,whole:Route@18753,whole:Route@20544,whole:Route@21605,whole:Route@21671,whole:Route@21682,whole:Route@21935,whole:Route@22030,whole:Route@22106,whole:Route@22150,whole:Route@22452,whole:Route@22482,whole:Route@23982,whole:Route@24267,whole:Route@26073,whole:Route@26133,whole:Route@26176,whole:Route@26191,whole:Route@27109,whole:Route@29172,whole:Route@33518,whole:Route@33547,whole:Route@33576,whole:Route@33608,whole:Route@35456,whole:Route@5576,whole:Route@5671 d86bb163dfe6c165cad91eb2a4713f3f862d6128a8ec59808e6dc638c3d44a49
@coverage internal/activator c5b02ec2a8b43a6ec7472b2f70d2d2a7d81a6e9fea126d398aca21ae46b5ca6f
-@coverage internal/edge b9b517d13731206a94d26de4b625366f9e629350d325f09c73402a23dad348f3
+@coverage internal/edge bfa19b4a843629a3a81b654c04d2521b600d63909b7c339d4171488f544ba56b
@coverage internal/host 8202b947824702b5897bdb32875ea7ab1386bd0b8f077f5ec1d506c2038f565a
@coverage internal/replicas 550a02209630a661b8d786822fd51607a4d0481af9ea79e91d270faa1a70d942
@coverage internal/reqrec 384ce988cf87bb60daac7b64f4f398f79b6e09d475698263c5c5b0f36a512ae9
+@coverage internal/status aa303f7d776f78c88272b64c7f0f0f4f4fb10e704bc3ac6acde778c463410b1d
@coverage internal/tunnelclient a5bd418d97ee5e5d2bb9550dd35e2456b1c06fc541b82fe1e40a5594ed6fba30
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go
index 414dfb7af..a78a32670 100644
--- a/internal/status/snapshot.go
+++ b/internal/status/snapshot.go
@@ -34,6 +34,7 @@ import (
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/replicas"
)
// Probes carries everything CollectBox may not read from the registry —
@@ -508,11 +509,14 @@ type ProofWait struct {
// BuildFleet never copies Metrics into the public fleet.json (see the package
// doc comment).
type UpstreamState struct {
- Addr string `json:"addr"`
- Up bool `json:"up"`
- Since time.Time `json:"since"` // last transition (or the sync that started this prober)
- Fails int `json:"fails"` // consecutive probe failures
- LastError string `json:"last_error,omitempty"` // dial vs status, for the log/dashboard
+ // ReplicaCopy carries build and worker evidence through the existing heartbeat.
+ // It is absent on address probes and never used as live routing authority.
+ ReplicaCopy *replicas.Copy `json:"replica_copy,omitempty"`
+ Addr string `json:"addr"`
+ Up bool `json:"up"`
+ Since time.Time `json:"since"` // last transition (or the sync that started this prober)
+ Fails int `json:"fails"` // consecutive probe failures
+ LastError string `json:"last_error,omitempty"` // dial vs status, for the log/dashboard
}
// SystemState is the last platform self-update outcome root recorded on the