carlos / platform Public

Fleet public routes design rev 2: Astra round 1 (8 P1, 5 P2) resolved

Bindings applied only from their own key and a registered box (R1-1);
rate limit and plan throttle enforced once at the hub (R1-2); the fleet
edge owns the gate and the hub forwards the login POST uncached (R1-3);
root egress skips the inert forward shape (R1-4); FleetForwardFloor with
--allow-below-fleet-forward-floor and a fleet-create barrier (R1-5); one
eligibility predicate for Reload and the edges file (R1-6); PutForward/
DeleteForward, no conversion of existing rows (R1-7); explicit trash
decisions (R1-8); full request budget (R1-9); Slug kept (R1-10); no platform
names in 1a (R1-11); raw-account check (R1-12); census claims per unit
(R1-13). Also: retention now skips forward rows, which would otherwise have
let the hub prune a fleet app's running build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev e1e628a6f34a9e4998a50047cbbf2ee9b83ba4e0 parent ce2bce3
2 files changed, +731 −536
  • docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R1.md +27 −0
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +704 −536
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R1.md
new file mode 100644
index 000000000..13b44f4e2
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R1.md
@@ -0,0 +1,27 @@
+1. **P1 — §4.4: a fleet box can forge another fleet’s binding.** The store door permits writes anywhere under the caller’s fleet prefix ([storedoor.go:648](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/edge/storedoor.go:648)). The binding reader trusts `Host`, `Fleet`, and `Box` from JSON, checking the route against the body’s fleet without checking the object’s path ([fleetbind.go:227](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/host/fleetbind.go:227), lines 232–264). Fleet A can therefore write a binding under A’s prefix naming fleet B’s host and a different B box. The new edge owner check still passes because the route belongs to B. This permits cross-account steering and can send requests to a non-holder that returns 503. **Fix:** require the key to equal `fleetBindingKey(b.Fleet, b.Host)` before applying it, and validate the box label. Add a witness through the authenticated store door. **Boundary:** a fleet’s writable namespace must confer authority only over that fleet.
+
+2. **P1 — §4.11: forward rows bypass rate limits and plan throttling entirely.** `rateAdmit` rejects every kind except `instance`, then exempts tunneled requests ([ratelimit.go:124](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/edge/ratelimit.go:124)). `planThrottleOf` has the same two exclusions ([planthrottle.go:53](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/edge/planthrottle.go:53)); `planThrottleFor` and upgrade tracking also require `instance`. Consequently, the hub skips enforcement for `forward`, and the fleet edge skips it because the request arrived through the tunnel. **Fix:** explicitly admit instance-forwarding rows to the request-policy selectors, retain the necessary rate-limit settings, and test throttled HTTP requests and upgrades through both edges. **Invariant:** forwarding must preserve one effective enforcement point.
+
+3. **P1 — §§4.2, 4.11: password-protected fleet apps cannot complete login.** The proposed forward row has an empty `Gate`. The hub returns 404 for a login POST when that field is empty ([edge.go:1966](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/edge/edge.go:1966)). A GET reaches the fleet edge and returns its login form, but submitting that form stops at the hub. **Fix:** explicitly forward the gate login path when the fleet edge owns authentication, preserving its cookie handling. Copying the gate onto both edges also needs care because the first gate strips its cookie before forwarding. Add a complete login-and-authenticated-request witness. **Invariant:** a protected public route must remain usable without weakening authentication.
+
+4. **P1 — §4.14: the missed root egress reader can disable unrelated apps’ private access.** `boxWhollyNested` refuses any kind other than its recognized kinds; `forward` reaches the unknown-kind refusal ([egress_source.go:85](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/host/egress_source.go:85)). That decision examines the whole registry when evaluating a local instance’s egress policy and returns `EgressNotNested` ([egress_source.go:255](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/host/egress_source.go:255)). Adding one fleet route on an otherwise eligible hub therefore closes private egress for unrelated resident apps. **Fix:** explicitly recognize the inert forward shape in this root gate while preserving rejection of unknown kinds and the independent runtime evidence checks. Add a nested-local-instance-plus-forward-row witness and include the root change in the census review. **Invariant:** a route with no local process must not invalidate other tenants’ isolation eligibility.
+
+5. **P1 — §9: rollback leaves an indefinitely serving, unretirable route.** The current edge serves fleet placement without recognizing its kind ([edge.go:820](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/edge/edge.go:820)). The current instance removal gate excludes that placement on a platform hub through `inScope` ([reconcile.go:2044](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/provision/reconcile.go:2044)). Thus the stated rollback behavior is unsafe: after rollback, deleting or reassigning the record leaves the public host pointing at the former fleet indefinitely. A customer-controlled former fleet can continue answering that hostname. **Fix:** enforce a downgrade floor while forward rows exist, or require a verified cleanup before an older hub starts serving. Test rollback followed by deletion and host reassignment. **Boundary:** routing authority must end when the owning record ends.
+
+6. **P1 — §§4.4, 4.8–4.9: removing the local map entry does not prevent certificate orders.** The edges-file writer publishes ready rows independently of `Edge.Reload`’s proposed owner check ([edgesfile.go:543](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/host/edgesfile.go:543), lines 555–598). A remote issuer admits names from that file through `deploymentHost`, which accepts `KnownHost` even when local `Allowed` is false ([edge.go:1363](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/edge/edge.go:1363); `certsync.go:207`). A mismatched row can therefore remain advertised and trigger ACME attempts despite the promised refusal, consuming validation budget. **Fix:** apply the fleet-owner eligibility rule to publication, including aliases and wildcard inputs, and test with a separate issuer reading the hub’s file. **Invariant:** a refused fleet route must confer no deployment-wide certificate authority.
+
+7. **P1 — §§4.2, 4.7: generic Upsert does not produce the promised inert conversion.** `Upsert` preserves empty incoming `Tunnel`, `Caps`, `Unit`, `Seed`, and other fields ([registry.go:1512](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/registry/registry.go:1512)). Provisioned rows can acquire operator columns, as `reconcile.go:1985–1990` explicitly documents. A qualifying legacy row with a tunnel stamp retains it after conversion; the edge dispatches that tunnel before fleet placement ([edge.go:805](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/edge/edge.go:805)). The resulting forward row can keep using the previous backend. **Fix:** define an atomic conversion with explicit field clearing and eligibility checks; refuse operator-owned authority columns unless their migration is specified. Verify the stored row after conversion. **Invariant:** a forward row must have exactly the declared forwarding authority.
+
+8. **P1 — §§4.3, 4.6: the desired-set algorithm omits the trash decision.** The scan retains records before trash filtering; the existing instance mint checks trash later ([reconcile.go:1533](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/provision/reconcile.go:1533)). None of §4.3’s desired-set conditions excludes a trashed app. Its record therefore remains desired, contradicting the retirement table. Simply treating an unreadable marker as “not desired” would instead permit unsafe removal: the existing code distinguishes `declineMint` from production-guarded `removable` ([reconcile.go:1465](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/provision/reconcile.go:1465)). **Fix:** carry both decisions explicitly into forward reconciliation, preserve existing rows on uncertainty, and reuse the production guard and fresh-store confirmation for retirement. **Boundary:** unreadable state must not become deletion authority, and confirmed trash must stop routing.
+
+9. **P2 — §6: the request budget omits reads induced by the new rows.** Forward rows introduce newly hosted apps into telemetry resolution, which reads account and app settings ([telemetry_pass.go:143](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/host/telemetry_pass.go:143)). Plans read newly represented accounts; retention also selects every route with an app and reads its retention policy. Without the change index, telemetry alone adds roughly `2 × 262` GETs daily per newly represented account/app pair. With it, periodic backstop reads remain. Trash checks also are not already prefetched for out-of-scope fleet records (`reconcile.go:1281–1298`). **Fix:** budget the complete production pass set and correct the net-savings formula. Compare old and new behavior over identical records; a provision-only counting test misses these costs. **Invariant:** request accounting must include downstream consumers.
+
+10. **P2 — §§4.2, 4.10: omitting `Slug` breaks instance catch-all domains.** Alias derivation requires a provisioned route’s non-empty, valid `Slug` ([aliases.go:170](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/domains/aliases.go:170)). Ordinary `RouteFor` copies it from the record (`reconcile.go:524`); the proposed exact forward shape omits it. The primary public host can work while `<slug>.<custom-parent>` is never derived on the hub. **Fix:** retain and converge `Slug`, and exercise an instance catch-all through the hub and fleet edge. **Invariant:** forwarding must preserve the identity used to derive existing custom names.
+
+11. **P2 — §4.14: the claimed domains-source behavior does not occur.** `firstReadyUpstream` accepts only a socket, an address, or a static channel ([reconcile.go:823](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/domains/reconcile.go:823)). A forward row qualifies for none, so it never reaches `mintedRoute`. If source selection is widened, §4.3’s deletion of every undesired forward row would also claim the resulting domains-owned row. **Fix:** specify whether forward sources produce platform names, then define source eligibility and disjoint removal ownership explicitly. **Invariant:** each derived row needs one lifecycle owner.
+
+12. **P2 — §4.4: `RouteAccount` cannot detect the required accountless exception.** `release.RouteAccount` returns `OpsAccount` when `Account` is empty or invalid ([adopt.go:1363](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/release/adopt.go:1363)). Checking whether its result “is set” rejects accountless hand rows on ordinary customer fleets, contrary to fixed Q4. **Fix:** detect the empty raw account before applying effective-account comparison, and test both accountless compatibility and explicit mismatches. **Invariant:** the tenancy check must preserve the approved compatibility exception.
+
+13. **P2 — §7: “no root read is added” is not an accurate census claim.** The proposed owner-map callback introduces accesses to registry `Fleet` fields, and `Route.IsForward()` introduces a `Kind` read. The census recognizes fields of registry structs and whole-struct uses, not only new tables or filesystem paths ([plan14_root_reads_test.go:192](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-public-routes/internal/provision/plan14_root_reads_test.go:192)). **Fix:** distinguish unchanged input sources from added read sites, and claim the new helpers, changed selectors, and envelopes individually. **Invariant:** census approval must describe the actual source and authority changes.
+
+NOT READY
\ No newline at end of file
diff --git a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
index 6487be64e..dff34f3b3 100644
--- a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
+++ b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
@@ -1,10 +1,19 @@
# Fleet public routes: an app on a fleet serves at its URL with no hand row
-Status: DRAFT rev 1, 2026-10-29, for Paul's read. No review rounds yet.
-Discussion: amadan carlos/platform #457 (this is its Phase 1a, pulled out
-on its own because it needs no rented boxes and no billing). Branch
-`design-fleet-public-routes`, cut from main `1fa2a99b`. Every file:line
-below is on that commit.
+Status: DRAFT rev 2, 2026-10-30. Discussion: amadan carlos/platform #457
+(this is its Phase 1a, pulled out on its own because it needs no rented
+boxes and no billing). Branch `design-fleet-public-routes`, cut from main
+`1fa2a99b`. Every file:line below is on that commit.
+
+Revisions:
+- Rev 1 (855b514e): first draft.
+- Rev 2: Astra round 1 (`docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R1.md`,
+ NOT READY, 8 P1 and 5 P2), every finding taken, with the controller's
+ rulings (platform-39) on P1-1, P1-2, P1-3, P1-4, P1-5, P1-6, P1-7, P1-8 and
+ P2-9 to P2-13. Changes are marked **(R1-n)**. Also found while checking
+ R1-9: the retention pass would have started pruning fleet apps' releases
+ from the hub (§4.15, marked **(rev 2)**). Round 1 of 3 is spent; this
+ is the text for round 2.
## 1. Intent
@@ -31,24 +40,29 @@ Goals:
- G1. Every record placed on a fleet gets a row on the box that holds that
fleet's tunnels (the hub), within seconds of the record appearing, and
- loses it when the record goes, moves or stops qualifying.
-- G2. The row forwards over the fleet's tunnel. It runs nothing on the
- hub: no release is staged, no process started, no database replicated.
+ loses it when the record goes, is trashed, moves or stops qualifying.
+- G2. The row forwards over the fleet's tunnel and does nothing else on
+ the hub: no release staged, no process started, no database replicated,
+ no release pruned, no gate interpreted.
- G3. A fleet's tunnel carries only hostnames of the account that owns the
- fleet. Checked where the row is written and again where it is served.
-- G4. Certificates, custom domains, backhaul from other platform boxes and
- `X-Carlos-Version` work for these hosts through machinery that exists.
-- G5. No new steady-state bucket requests on any box.
+ fleet, and a fleet's writable bucket corner gives authority over that
+ fleet alone. One predicate decides serving and publication.
+- G4. The app's request policy (rate limit, plan throttle, lapse page,
+ password gate) is enforced exactly once.
+- G5. Certificates, custom domains, backhaul from other platform boxes and
+ `X-Carlos-Version` work through machinery that exists.
+- G6. The request budget is stated whole, for every pass a new row reaches.
Non-goals (other work):
- Managed provisioning, billing, enrolment (#457 phases 2 and 3).
-- 1b, which box in a multi-box fleet runs an instance. §4.5 states what 1a
- assumes and what it leaves broken.
+- 1b, which box in a multi-box fleet runs an instance (§4.5 states what 1a
+ assumes and what it leaves).
- 1c, the reboot lease (#451).
- Fleet boxes not ordering certificates they can never be validated for
- (box-1's failing autocert, §3.6). Noise, not a blocker; a follow-up.
-- Regional domains (#447) and path maps over fleet hosts.
+ (box-1's failing autocert, §3.6). Noise; a follow-up.
+- Platform names (the domains pass's `<app>.<acct>.<domain>` aliases),
+ regional domains (#447) and path maps for fleet apps (§4.11).
## 3. What happens today
@@ -60,159 +74,133 @@ write bumps the serial) and on a 5-minute backstop
(`internal/host/agent.go:3878`). The scan reads every instance record in
the bucket, judges it, validates it, and only then asks scope
(`internal/provision/reconcile.go:1217`). A record in scope becomes a row
-through `RouteFor`, the one renderer. A row the pass minted or adopted is
-`Provisioned`, which is what grants the removal phase authority over it
-(`reconcile.go:2044`).
+through `RouteFor`. A row the pass minted or adopted is `Provisioned`,
+which is what grants the removal phase authority over it
+(`reconcile.go:2044`). Trash is decided later, per app: `declineMint`
+(also on an unreadable marker) stops minting, and `removable` (a marker
+positively read, production flag clear) allows removal
+(`reconcile.go:1465-1520`, `:1533`).
### 3.2 `inScope` refuses fleet records from both sides
`inScope` (`reconcile.go:487-499`): region equality is the home-box test,
widened only for the everywhere classes, and never across the fleet
-boundary. A record with `Region == "fleet/<f>"` is in scope only on a box
-whose own region is `fleet/<f>`, that is, the fleet's own boxes. A
-platform box reads the record and skips it. The removal phase asks the
-same `inScope` of the row (`reconcile.go:2044`), so a fleet-placed row on
-a platform box is never retired by this pass either.
+boundary. A record with `Region == "fleet/<f>"` is in scope only on the
+fleet's own boxes. A platform box reads the record and skips it, and its
+removal phase cannot see a fleet-placed row either (`reconcile.go:2044`).
-That boundary is right and stays: a platform box never runs a fleet
-record, and a fleet box never runs a platform record.
+That boundary stays: a platform box never runs a fleet record, and a fleet
+box never runs a platform record.
### 3.3 The hub and the tunnel
A fleet box dials out. `tunnelLoop` (`internal/host/tunnel_client.go:35`)
reads `CARLOS_TUNNEL_URL`, `CARLOS_TUNNEL_NAME` (`<fleet>/<label>`) and
-`CARLOS_TUNNEL_TOKEN`, dials the hub's ordinary :443 listener, sends
-`GET /register` with the bearer token, and the connection inverts: the hub
-becomes the HTTP/2 client, and the box serves its WHOLE edge over it
-(`go tunnelLoop(e)`, `agent.go:1026`; `internal/tunnelclient`).
+`CARLOS_TUNNEL_TOKEN`, dials the hub's :443 listener with `GET /register`
+and a bearer token, and the connection inverts: the hub becomes the
+HTTP/2 client and the box serves its WHOLE edge over it (`go tunnelLoop(e)`,
+`agent.go:1026`; `internal/tunnelclient`).
The hub is the box whose edge has `CARLOS_TUNNEL_HOST` set
(`enableTunnelsFromEnv`, `internal/edge/edge.go:4066`). It authenticates a
-fleet dial against the `fleet_boxes` table in its own registry
-(`FleetChannelAuth`, `internal/registry/fleets.go:625`, active boxes only),
-reloaded with the routes (`edge.go:1112-1134`), which also loads each
-fleet's owning account for the store door (`fleetAccounts`). That table is
-written by the console (`internal/console/fleets.go`), which opens the
-same `/data/registry.db` (`cmd/console/main.go:447`). So the hub is, in
-practice, the console's box: it is the only registry that has fleets in
-it, and `carlos fleets` says boxes "dial this console".
+fleet dial against `fleet_boxes` in its own registry (`FleetChannelAuth`,
+`internal/registry/fleets.go:625`, active boxes only), reloaded with the
+routes (`edge.go:1112-1134`), which also loads each fleet's owning account
+(`fleetAccounts`). The console writes that table into the same
+`/data/registry.db` (`cmd/console/main.go:447`), so the hub is in practice
+the console's box.
On dev:
| name | resolves to |
|---|---|
| `platform.dev.carlosframework.com` (console) | 99.80.78.4 |
-| `tunnel.dev.carlosframework.com` (`CARLOS_TUNNEL_URL` in `platform-infrastructure/dev/region-pi.md`) | 99.80.78.4 |
+| `tunnel.dev.carlosframework.com` (`CARLOS_TUNNEL_URL`, `platform-infrastructure/dev/region-pi.md`) | 99.80.78.4 |
| `shop.bab.dev.oncarlos.com`, any `*.bab.dev.oncarlos.com` | 99.80.78.4 |
| `bab.dev.oncarlos.com` (apex) | 18.135.60.181 (dennis, uk) |
99.80.78.4 is sophie-knitting (`carlos-dev-ie`, i-05498eada6f0afd23), the
-dev console box. So on dev the hub, the console and the box the apps
-domain points at are one box. `carlos fleets ls --account bab` (read-only,
-2026-10-29): `r10r` bucket `carlos-r10r-fleet-640012953448`, box `box-1`
-active, secrets key `c71cc5c26233`; `r10w` box-1 detached. box-1 reaches
-the bucket only through the hub's store door (it logs `fleetapi:` errors,
-#366), so it is a door-backed box with no bucket credentials.
+dev console box: hub, console and apps-domain target are one box.
+`carlos fleets ls --account bab` (read-only, 2026-10-29): `r10r` bucket
+`carlos-r10r-fleet-640012953448`, `box-1` active, secrets key
+`c71cc5c26233`; `r10w` `box-1` detached. box-1 reaches the bucket only
+through the hub's store door.
### 3.4 What the hub does with a fleet-placed row
`Edge.Reload` binds any ready row whose `Region` parses as a fleet
-placement to `fleetProxy`, on placement alone, ahead of socket and addr
-(`edge.go:766`, `:821-825`). `fleetProxy` (`edge.go:3106`) picks the
-channel per request with `fleetChannelFor` (`edge.go:3086`): the row's
-`FleetBox` if that box is connected, else the first connected box of the
-fleet in sorted order, else 503 with `Retry-After: 2` and cause
-`fleet_dark` (`errFleetDark`, `edge.go:3071`). The request keeps its Host
-and goes over HTTP/2 inside the box's own TLS session to the hub. The
-row's process is never the hub's to manage (`viaTunnel`, `edge.go:965`).
-
-`FleetBox` comes from bindings. A fleet box publishes
-`fleets/<f>/bindings/<host>.json` through the door on every wake
-(`fleetBindingHook`, `internal/host/fleetbind.go:302`, takeover) and once at
-start (`publishResidentFleetBindings`, `:336`, never stealing).
-`ReconcileFleetBindings` (`fleetbind.go:210`) runs on EVERY platform box on
-the 5-minute loop (`agent.go:3894-3898`) and stamps `FleetBox` on an
-EXISTING row placed on the binding's own fleet. It never creates a row.
-
-So the serving half exists and works. What is missing is the row.
-
-### 3.5 The only ways a fleet row has ever reached the hub
+placement to `fleetProxy`, on placement alone, after the `Tunnel` case
+(`edge.go:805`, `:821-825`). `fleetProxy` (`edge.go:3106`) picks the
+channel per request (`fleetChannelFor`, `edge.go:3086`): the row's
+`FleetBox` if connected, else the first connected box of the fleet, else
+503 with `Retry-After: 2` (`errFleetDark`, `edge.go:3071`). The hub never
+manages the process (`viaTunnel`, `edge.go:965`).
+
+`FleetBox` comes from bindings: a fleet box writes
+`fleets/<f>/bindings/<host>.json` through the store door on wake and at
+start (`internal/host/fleetbind.go:302`, `:336`), and
+`ReconcileFleetBindings` (`fleetbind.go:210`) runs on every platform box
+every five minutes (`agent.go:3894-3898`) and stamps `FleetBox` on an
+existing row. It trusts the body's `Host`, `Fleet` and `Box` and never
+compares them with the object's key (`fleetbind.go:227-264`), while the
+door lets a box write anything under its own `fleets/<f>/`
+(`internal/edge/storedoor.go:648`). So a box of fleet A can write
+`fleets/A/bindings/x.json` naming fleet B's host and any label, and steer
+B's traffic. A hole today, independent of this work **(R1-1)**.
+
+### 3.5 The only ways a fleet row has reached the hub
- `apps place` (`placeAppTarget`, `internal/console/fleets.go:817-829`)
- stamps `Region` on the console box's existing rows of the app
- (`reg.SetPlacement`). That was the customer-fleets design's answer
- ("placement subsumes" the route ceremony,
- `platform-infrastructure/platform-design/superpowers/specs/2026-08-05-customer-fleets-design.md`).
- It never adds a row, so an app born placed (`apps create --place`) gets
- nothing, and rootfs apps cannot be placed at all (`rootfsPlaceWords`,
- `internal/console/seedmove.go:174`). The Pi runbook has recorded the gap
- since August (`platform-infrastructure/dev/region-pi.md`: "Placement does
- NOT yet produce a route in the platform edge's own registry").
-- A hand row. The recipe in use (`2026-10-24-rootfs-apps-2-verify.md` D7):
- `carlos add --account-id bab --app <app> --channel r10-proxy <host>` on
- sophie, then `apps place --target fleet/<f>`. The channel is a name that
- exists nowhere, so the hub's adopt pass finds no pointer and stages
- nothing. That trick is the tell: a fleet row with a real channel and
- `Kind = "instance"` is `release.Adoptable` (`internal/release/adopt.go:1302`),
- and the hub would stage and run the app's release locally.
- `railsdemo.bab.dev.oncarlos.com` serves through such a row today:
- `curl -sI .../up` gives 200 with one `x-carlos-version: r3b`.
-
-A placed row also has no retirement: the removal phase cannot see it
-(§3.2), so it outlives its record.
+ re-stamps `Region` on the console box's existing rows. It never adds
+ one, so an app born placed gets nothing, and rootfs apps cannot be
+ placed at all (`internal/console/seedmove.go:174`). The Pi runbook has
+ recorded the gap since August (`platform-infrastructure/dev/region-pi.md`).
+- A hand row: `carlos add --account-id bab --app <app> --channel r10-proxy <host>`
+ on sophie, then `apps place` (`2026-10-24-rootfs-apps-2-verify.md` D7).
+ The channel exists nowhere, so the hub's adopt pass stages nothing; a
+ real channel on a `Kind = "instance"` row is `release.Adoptable`
+ (`internal/release/adopt.go:1302`). `railsdemo.bab.dev.oncarlos.com`
+ serves through such a row: 200, one `x-carlos-version: r3b`.
+
+A placed row has no retirement: the removal phase cannot see it (§3.2).
### 3.6 Certificates and where TLS ends
-TLS for the public name ends at the hub. The box never presents a
-certificate for the app's host: tunnel traffic is HTTP/2 inside a TLS
-session the box itself dialed to the tunnel host.
+TLS for the public name ends at the hub; tunnel traffic is HTTP/2 inside a
+TLS session the box dialed. The hub's autocert asks `issuerHostPolicy`
+(`internal/edge/certsync.go:197`), which admits `deploymentHost`: a name in
+this edge's map or named by another box's edges file (`edge.go:1363`). On
+a deployment with a store one elected issuer orders and publishes to
+`control/certs/` (`certsync.go:107-150`). With no row for `shop.bab...`,
+sophie refuses the name: `TLS alert, internal error (592)`. box-1 issues
+for itself (`certsync.go:122`) and fails, since validations reach sophie.
-The hub's autocert asks `issuerHostPolicy` (`internal/edge/certsync.go:197`),
-which admits exact names of routes in the deployment, and on a box with a
-deployment store one elected issuer orders and publishes to
-`control/certs/` while the others mirror it (`armCertIssuance`,
-`certsync.go:107-150`). With no row anywhere for `shop.bab...`, sophie's
-policy refuses the name and the handshake ends in the alert seen today:
+### 3.7 DNS
- TLSv1.3 (IN), TLS alert, internal error (592)
+The apps domain's names are the deployment's DNS, set in its roots; dev
+points `*.dev.oncarlos.com` and the per-account wildcards at sophie. No
+DNS change is needed for a fleet app.
-box-1 has no deployment store, so it issues for itself (`certsync.go:122`)
-and fails, because the name resolves to sophie and validations never reach
-box-1. Harmless to serving; noise in its journal.
+### 3.8 Request policy at the two edges
-### 3.7 DNS
+The fleet edge exempts every request that arrived over the tunnel from the
+rate limit, plan throttle, guard and request records (`fromTunnel`:
+`ratelimit.go:128`, `planthrottle.go:58`, `edge.go:1895`,
+`reqrecords.go:64`), on the reasoning that the hub, which has the real
+client, enforces them. But the hub enforces the rate limit and the plan
+throttle only on `Kind == "instance"` (`ratelimit.go:124`,
+`planthrottle.go:53`, upgrade tracking `planthrottle.go:99`,
+`internal/host/plans_pass.go:208`). Analytics count once, at the hub
+(`analytics.go:117`).
+
+The password gate runs at the edge that holds the row's `Gate`
+(`edge.go:1966-1972`). A login POST (`gate.LoginPath`, `/.carlos/gate`)
+on a row with no gate is answered 404 and never proxied.
-The apps domain's names are the deployment's own DNS, set in the
-deployment roots (dev: `*.dev.oncarlos.com` and the per-account wildcards
-point at sophie's address). On a steering deployment the steering
-converger writes per-host latency records from the boxes' edges files. No
-DNS changes for a fleet app: its platform name already resolves to the
-platform's edges.
-
-### 3.8 Custom domains
-
-A custom domain is a bucket claim; every box's alias pass
-(`aliasPassReporting`, `agent.go:1176`) writes `route_aliases` rows, and
-the edge serves an alias only through a local primary row
-(`edge.go:1083`). With no hub row, a fleet app's custom domain is not
-served anywhere today.
-
-### 3.9 Headers, cache, analytics
-
-- `X-Carlos-Version` is stamped by the edge that holds the row's version
- (`versionHeader`, `edge.go:2748`; `genproxy.go:312` for generations). The
- box sets it; a hub row with an empty `Version` adds nothing, so the
- box's header passes through once (railsdemo above).
-- Analytics count once: the hub counts, and the box skips requests that
- arrived over the tunnel (`fromTunnel`, `internal/edge/analytics.go:117`).
- Plan throttle, rate limits, the guard and request records do the same
- (`planthrottle.go:58`, `ratelimit.go:128`, `edge.go:1895`,
- `reqrecords.go:64`). Edge errors are filed by the box, the hub files only
- a failed hop (`emitEdgeError`, `edge.go:581`).
-- The hub's response cache stores tunnel responses like any other
- (`edge.go:2083`). The app's `Carlos-Purge` is applied and stripped by the
- box's edge (`purge_header.go:219`, `:331`), so the hub's copy cannot be
- purged. A live gap with hand rows today; §4.11.
+`X-Carlos-Version` is stamped by the edge holding the row's version
+(`versionHeader`, `edge.go:2748`; `genproxy.go:312`). The hub's response
+cache stores tunnel responses (`edge.go:2083`); the app's `Carlos-Purge`
+is applied and stripped at the box (`purge_header.go:219`, `:331`).
## 4. Design
@@ -220,452 +208,632 @@ served anywhere today.
The hub's own instance pass, which already reads every record, gives each
fleet-placed record whose fleet is in the hub's local fleets table, owned
-by the record's account, a forward row: a row of a new kind, `forward`,
-that carries the host, the app, the account and the placement and nothing
-that makes any pass on the hub run it. The edge already serves such a row
-through `fleetProxy`; it now also refuses one whose account is not the
-fleet owner's. The same pass retires the row when the record goes, moves
-off the fleet, or stops qualifying. Certificates, custom domains,
-backhaul and the version header follow from the row through code that
-exists. Nothing new is read from the bucket.
-
-### 4.2 The forward row
-
-A row with exactly these columns:
+by the record's account, and whose app is not trashed, a forward row: a
+row of a new kind, `forward`, written and deleted only through two
+registry calls that touch nothing but forward rows, carrying the host,
+slug, app, account, placement and rate-limit settings and nothing that
+makes any pass on the hub run, prune or gate it. The edge serves a forward
+row only through `fleetProxy`, only when it is inert and its account owns
+the fleet, and the edges file publishes exactly the rows the edge serves,
+by the same predicate. The hub enforces the app's rate limit and plan
+throttle once; the fleet edge owns the gate, and the hub forwards every
+path to it, uncached. Bindings are honoured only from their own key and a
+registered box. A release floor stops a channel moving below the first
+release that writes forward rows while fleets exist.
+
+### 4.2 The forward row **(R1-7, R1-10, R1-2, R1-3)**
+
+Columns:
| column | value |
|---|---|
| `Host` | the record's host |
-| `Kind` | `forward` (new constant `registry.KindForward`, `Route.IsForward()`) |
+| `Kind` | `forward` (`registry.KindForward`, `Route.IsForward()`) |
+| `Slug` | the record's, converged (R1-10: instance catch-alls derive from it, `internal/domains/aliases.go:170`) |
| `App`, `Account` | the record's |
| `Region` | the record's `fleet/<f>` |
-| `Channel` | the record's, for display only |
+| `Channel` | the record's, display only |
+| `RateLimit` | `rec.RateLimitColumn()`, as `RouteFor` renders it (R1-2) |
| `Status` | `ready` |
| `Provisioned` | true |
-| `FleetBox` | left to the bindings pass (§4.5) |
-
-Everything else is empty: no `Socket`, `Addr(s)`, `DBPath`, `Version`,
-`Runtime`, `Unit`, `Backing`, `Caps`, `Tunnel`, `Hibernate`, `Seed`,
-`Health`, `Replicas`. `Upsert` preserves a non-empty `FleetBox`, so the
-forward pass and the bindings pass do not undo each other.
-
-Why a new kind rather than the old placed-row shape (`Kind = instance`)
-or the domains pass's minted shape (`Platform = true`,
-`internal/domains/reconcile.go:875-893`):
-
-- `instance` is what the hub's root adopt pass, capability pass, fast
- sweep and config sync select on (`release.Adoptable`, `CapabilityRoute`,
- `adopt.go:1302`). The hand-row recipe dodges that with a channel that
- does not exist. A design cannot.
-- `Platform` belongs to the domains pass, which removes `Platform` rows on
- its own inferences. Sharing the flag shares the removal authority.
-- Every selector that names a kind positively (`Kind == "instance"`,
- `IsSidecar()`) skips an unknown kind. A pass that does not know about
- `forward` fails toward ignoring the row. The edge's fleet arm keys on
- placement, not kind (`edge.go:821`), so serving needs no new arm.
-
-The cost is the sidecar lesson (AGENTS.md): every reader of `reg.List()`
-is a consumer of the new kind and has to be audited (§4.14).
-
-### 4.3 Who writes it, from what, and when
-
-The writer is `provision.Reconcile` on the hub, in a phase of the same
-call, over the same scan:
-
-1. The scan, at the `inScope` skip (`reconcile.go:1217`), keeps the
- records it skips only because they are fleet-placed and this box is
- not on that fleet. Same judge, same validation, same `protect`,
- `unread` and `readFailed` bookkeeping as an in-scope record. Their
- bodies are already read; nothing new is fetched.
-2. `ReconcileConfig` gains `FleetOwners func() (map[string]string, error)`,
- nil on every box that is not a hub. The agent sets it when
- `CARLOS_TUNNEL_HOST` is set and `CARLOS_FLEET` is not, reading
- `reg.ListFleets()` from the local registry once per pass. A read error
- aborts the forward phase for the pass, mints nothing and retires
- nothing.
-3. The desired set: a kept record gets a forward row when
- - `FleetOwners` is set and names the record's fleet;
- - that fleet's account equals the record's `Account`;
- - the record is not `role: replica`, and its host is not claimed by an
- in-scope record of this same pass (a host in both sets is a
- collision, logged and given neither). Instance moves refuse fleet
- records (`apiinstancemove.go:91`), so no move is in flight;
- - no row other than a forward row already holds the host (§4.7).
- Sidecar records never reach this pass (`ReconcileSidecars` owns them).
-4. Mint and converge: a missing forward row is written; an existing one
- whose `App`, `Account`, `Region` or `Channel` differs is rewritten in
- place. `FleetBox` is cleared when `Region` changes (the old binding
- names a box of the old fleet).
-5. Retire, only on a pass where nothing failed to read and the scan was
- whole (the instance pass's rule, `reconcile.go:1968-2044`, including the
- re-check against the bucket's own walk over a snapshot): every forward
- row not in the desired set is deleted. A host in `protect` is kept.
-6. Order: the forward phase runs BEFORE the instance phase's mint. A
- record that moved from a fleet to this box's region sees its forward
- row gone before the instance phase looks for a row to mint or adopt.
-
-On a box that is not a hub, `FleetOwners` is nil, the desired set is
-empty, and step 5 retires any forward row it holds. That is what makes a
-box that stops being the hub clean up after itself, and why only the hub
-ever holds one.
-
-When it appears: the console's create of a fleet-placed record bumps the
-serial; the hub's change-index pass runs in seconds; `Edge.Reload` picks
-the row up on its 2-second registry watch. Until the fleet box has minted
-its own row, a request reaches the box and gets the box's unknown-host
-answer. With claims on (`ClaimEnabled`, shelved), the forward phase does
-nothing and logs once; claims are off everywhere.
-
-### 4.4 Tenancy: one rule, checked twice
-
-The rule: a fleet's tunnel carries only hostnames whose account is the
-fleet's owner.
-
-- The pass checks it before writing (§4.3, step 3). The source of the
- owner is the hub's own `fleets` table, written only by the console and
- already the authority for the fleet's tunnel credentials and its store
- door scope. Not the bucket owner record
- (`accounts/<acct>/fleets/<f>.json`, `internal/console/fleetowner.go`):
- it costs a read per fleet per pass, and the hub already holds the better
- answer locally.
-- The edge checks it where traffic is forwarded. `Edge.Reload` reads the
- fleets table before building the map (today it reads it after,
- `edge.go:1112`), and a fleet-placed row whose `release.RouteAccount` is
- set and differs from the fleet's account gets no map entry: no proxy,
- and `Allowed` says no, so no certificate order either. Logged, throttled
- per host. This covers forward rows, hand rows, legacy placed rows and
- aliases (an alias inherits its primary's entry). A fleet-placed row with
- no account (a pre-account hand row) is served as today and logged.
-
-What the record itself is trusted for is unchanged: records are written by
-the console, and a door-backed fleet box cannot write one (`aclWrite`,
-`internal/edge/storedoor.go:644`). A grandfathered fleet box that still
-holds bucket credentials could; that is the customer-fleets v1 trust
-statement and 1a does not widen it, because the edge check means such a
-record can only point at its own account's fleet.
-
-Bindings stay as they are: a box can only steer a host to a box of its own
-fleet (`fleetbind.go:255`), which the edge check now also confines to the
-owner's hosts.
-
-### 4.5 Naming the box, and multi-box fleets
-
-The record does not name a box and 1a does not add one. The forward row
-starts with `FleetBox` empty, so `fleetChannelFor` takes the first
-connected box of the fleet. The bindings pass stamps `FleetBox` when a box
-publishes a binding.
-
-1a makes `ReconcileFleetBindings` hub-only: it only ever stamps rows that
-exist, and only the hub holds fleet rows that can be served (a box with no
-tunnel hub has no fleet arm). Today it lists `fleets/` on every platform
-box every five minutes.
-
-Single-box fleet (the witness): fully correct. There is one channel, the
-fallback finds it, and the binding is cosmetic.
-
-Multi-box fleet, what happens today and with 1a alike: every box of the
-fleet mints the record's row (its region is `fleet/<f>`), the instance
-runs on whichever box holds its lease, and the hub routes to the bound box
-if connected, otherwise to the first connected box, which wakes the
-instance or loses the lease race and answers 503 with `Retry-After`. The
-binding lags a move by up to one bindings pass (about 5.5 minutes), and
-in that window requests can land on a box that does not hold the lease.
-1a does not fix this. 1b owns box choice, and the likely fix (the hub's
-store door stamps `FleetBox` the moment a binding PUT passes through it,
-since the door runs on the hub) is noted there, not built here.
+| `FleetBox` | written only by the bindings pass; kept while `Region` is unchanged, cleared when it changes |
+
+Every other column is empty, deliberately including `Gate` (the fleet
+edge owns the gate, §4.8), `Version` (the box stamps it), `Steering`,
+`Socket`, `Addr`, `Addrs`, `DBPath`, `Runtime`, `Unit`, `Backing`, `Caps`,
+`Tunnel`, `Hibernate`, `Seed`, `Health`, `Replicas`, `EgressAllow`.
+
+`Route.InertForward()` is the shape predicate: `IsForward()` and every
+column in the last sentence empty. Every reader below that admits a
+forward row admits only an inert one.
+
+Writes go through two new registry calls, never `Upsert` (R1-7: `Upsert`
+keeps a non-empty existing `Tunnel`, `Caps`, `Unit`, `Seed` and others,
+`internal/registry/registry.go:1512`):
+
+- `PutForward(rt)`: one transaction. If a row exists at the host and is
+ not a forward row, it returns `ErrHostHeld` and writes nothing. Otherwise
+ it writes every column, the forward set above and zero for the rest, so
+ an operator column that reached a forward row is cleared on the next
+ pass. `FleetBox` is carried from the existing row only when `Region` is
+ unchanged.
+- `DeleteForward(host)`: deletes the row only if it is still a forward row,
+ in the same statement.
+
+`carlos route` and `carlos add` refuse a forward row's host, naming the
+record, as `carlos route` already refuses a provisioned row's channel.
+
+Why a new kind (Q1, fixed): `instance` is what root adopt, capability,
+config sync and the fast sweep select (`adopt.go:1302`); `Platform`
+belongs to the domains pass's removal. A selector that names a kind
+positively skips `forward`, so an unaware reader fails toward ignoring it.
+The cost is the audit of every reader (§4.15).
+
+### 4.3 The writer: the forward phase of the hub's instance pass **(R1-8, R1-7)**
+
+`provision.Reconcile` gains a forward phase over the same scan:
+
+1. **Collect.** At the `inScope` skip (`reconcile.go:1217`) the scan keeps
+ the records it skips only because they are fleet-placed and this box is
+ not on that fleet. Same judge, validation, `protect`, `unread` and
+ `readFailed` bookkeeping as an in-scope record. Their bodies are already
+ read. Their apps join the trash prefetch (`reconcile.go:1281-1298`), so
+ the marker read happens once per app per pass, in the existing parallel
+ prefetch (budgeted in §6).
+2. **Owners.** `ReconcileConfig.FleetOwners func() (map[string]string, error)`
+ is set by the agent when `CARLOS_TUNNEL_HOST` is set and `CARLOS_FLEET`
+ is not, reading `reg.ListFleets()` once per pass (local SQLite). A read
+ error stops the phase for the pass: nothing minted, nothing retired.
+3. **Decide, per kept record.** Using the instance pass's own trash lookup
+ (`trashFor`):
+ - **mint**: `FleetOwners` names the record's fleet, the fleet's account
+ equals the record's raw `Account`, the record is not `role: replica`,
+ its host is not also an in-scope record's (a collision: logged, given
+ neither), and `declineMint` is false;
+ - **keep**: `declineMint` is true but `removable` is false (an
+ unreadable marker, or a trashed production app): an existing forward
+ row is kept as it is, nothing is minted;
+ - **retire**: `removable` is true.
+
+ Instance moves refuse fleet records (`internal/console/apiinstancemove.go:91`),
+ so no move is in flight.
+4. **Write.** `PutForward` for each mint. `ErrHostHeld` (any non-forward
+ row at the host, a hand row, a legacy placed row, another account's
+ row) leaves that row exactly as it is and is reported: one log line per
+ host per pass through the provision pass's existing throttled report,
+ plus a REASON on `instances list` (copy review) **(R1-7, ruling: no
+ conversion)**.
+5. **Retire.** Only on a pass where nothing failed to read and the scan
+ was whole, under the instance pass's rules (`reconcile.go:1968-2044`):
+ over a record view snapshot, every removal is decided again against the
+ bucket's own walk and a fresh-store trash read (`trashOver(freshStore(s), ...)`),
+ and `removable` keeps its production guard (`productionClear`,
+ `reconcile.go:290`). `DeleteForward` for: a forward row whose record is
+ gone, whose decision is retire, whose fleet is unknown or owned by
+ another account, or whose record is no longer fleet-placed. A host in
+ `protect`, or whose decision is keep, is not touched.
+6. **Order.** The forward phase runs before the instance phase mints, so a
+ record that moved from a fleet into this box's region finds its forward
+ row gone before the instance phase looks for a row.
+
+Ownership is disjoint by kind: the forward phase writes and deletes only
+`IsForward()` rows; the instance pass's `retirable` excludes them (the
+sidecar rule, `reconcile.go:2044`); the domains pass removes only
+`Platform` rows, which a forward row never is **(R1-11)**.
+
+On a box that is not a hub, `FleetOwners` is nil and every forward row is
+retired on its next whole pass. With claims on (`ClaimEnabled`, shelved),
+the phase does nothing and logs once.
+
+When it appears: a console create of a fleet-placed record bumps the
+serial, the hub's change-index pass runs in seconds, and `Edge.Reload`
+picks the row up on its 2-second registry watch.
+
+### 4.4 Tenancy: one predicate for serving and publishing **(R1-6, R1-12)**
+
+`edge.FleetServeEligible(rt registry.Route, hub bool, owners map[string]string) (ok bool, why string)`
+decides whether a row may take the fleet arm, and is the one place the
+rule is written:
+
+- a forward row: eligible only when `hub`, `rt.InertForward()`, its
+ `Region` is a fleet placement, the fleet is in `owners`, and the raw
+ `rt.Account` is non-empty and equals the owner;
+- any other fleet-placed row that would take the fleet arm (no `Tunnel`,
+ `hub` true): when the raw `rt.Account` is empty, eligible (the approved
+ pre-account compatibility case, logged); otherwise eligible only when
+ `release.RouteAccount(rt)` equals the owner (R1-12: the raw field is
+ checked for empty BEFORE `RouteAccount`, which turns an empty account
+ into `OpsAccount`, `adopt.go:1363`);
+- any row that does not take the fleet arm: not this predicate's
+ business (unchanged dispatch, including a hand row's socket fallback on
+ a box with no hub).
+
+Callers:
+
+- `Edge.Reload` reads the fleets table before the routes loop (today it
+ reads it after, `edge.go:1112`). A new first dispatch case for forward
+ rows serves an eligible one through `fleetProxy` and gives an ineligible
+ one no map entry: it never falls through to the `Tunnel` or socket arms.
+ The existing fleet case asks the same predicate. No map entry means
+ `Allowed` is false.
+- The edges-file writer (`internal/host/edgesfile.go:543-598`) reads the
+ local fleets table once per write and the hub predicate from the same
+ env test, and leaves out every row the predicate refuses, a forward row
+ on a box with no hub, and with them every alias, instance catch-all and
+ wildcard entry whose primary is left out. A forward row publishes no
+ `assets` block. So a refused row is in no edges file, `KnownHost` never
+ names it, and no issuer anywhere orders for it (`deploymentHost`,
+ `edge.go:1363`; `certsync.go:207`).
+
+The source of the owner is the hub's local `fleets` table, written only by
+the console and already the authority for tunnel credentials and the store
+door's scope. Records themselves are console-written; a door-backed fleet
+box cannot write one (`aclWrite`, `storedoor.go:644`).
+
+### 4.5 Bindings and box choice **(R1-1)**
+
+`ReconcileFleetBindings` changes in three ways:
+
+1. A binding is applied only when the object's key equals
+ `fleetBindingKey(b.Fleet, b.Host)`. A body naming another fleet or host
+ than its key is skipped and logged.
+2. `b.Box` must be a registered, active box of `b.Fleet` in the local
+ `fleet_boxes` table (`ListFleetBoxes`).
+3. It runs on the hub only (the same predicate as §4.3 step 2). Only the
+ hub holds rows the fleet arm serves.
+
+With the existing check that the row is placed on the binding's fleet
+(`fleetbind.go:255`), a box can steer only its own fleet's hosts, and only
+to a box of that fleet.
+
+Box choice: the forward row starts with no `FleetBox`, so the hub takes
+the first connected box. Single-box fleet (the witness): fully correct.
+Multi-box fleet, unchanged by 1a: every box of the fleet mints the
+record's row, the instance runs where its lease is held, and the hub
+routes to the bound box or else the first connected one, which may lose
+the lease race and answer 503 with `Retry-After`. The binding lags a move
+by up to one bindings pass (about 5.5 minutes). 1b owns this.
### 4.6 Retirement and moves
| event | forward row |
|---|---|
-| record deleted, or app trashed | retired on the next whole pass |
-| app placed back on the platform (`apps place --target ""`) | retired; the instance pass on the box in scope (maybe the hub) mints the real row, after, in the same pass |
-| app placed on another fleet of the same account | rewritten in place, `FleetBox` cleared |
-| fleet's owner changes, or the fleet row goes (no fleet removal exists yet) | edge stops serving on its next reload; the pass retires the row |
-| every box of the fleet detached | kept; requests get 503 `fleet unreachable` with `Retry-After` |
-| hub stops being the hub (`CARLOS_TUNNEL_HOST` removed) | retired by that box's own pass; the new hub mints |
-| a read failed this pass | nothing retired, as for instance rows |
-
-The instance pass gains the sidecar-style guard in the other direction:
-`retirable` excludes `IsForward()` rows, and the forward phase retires
-only `IsForward()` rows. Both directions get a test (§8).
-
-### 4.7 Rows already at the host, and `apps place`
-
-- A hand row (not `Provisioned`) at the host wins. No forward row is
- written, the host is logged once per process, and nothing touches the
- hand row. railsdemo keeps serving through its hand row; removing it is
- an operator step for later, with Paul's approval.
-- A legacy placed row (`Provisioned`, `Kind instance`, `Region` the same
- fleet, same account and app as the record) is converted into a forward
- row in place. The instance-pass family minted it and the console only
- re-stamped its region, so this stays inside one authority. Its local
- process, if any, was already not the edge's (`viaTunnel`), and dropping
- its `Socket` and `DBPath` takes it out of the activator's and
- Litestream's sets.
-- Any other row at the host (a different account, app, kind or fleet):
- untouched, and the record gets no forward row. Logged.
-- `placeAppTarget` stops calling `reg.SetPlacement` on the console box's
- rows (`fleets.go:817-829`). Records are the authority in both
- directions now; the two passes converge the hub's rows from them.
- Keeping the stamp would turn a hub instance row into a fleet row that
- nothing can retire.
-
-### 4.8 Certificates and TLS
-
-TLS ends at the hub, as for hand rows today. The forward row is an exact
-route in the deployment, so the issuer's policy admits it, and the hub's
-edges file publishes it (§4.9), so a non-hub issuer admits it too. The
-first handshake orders the certificate (or the account's wildcard covers
-it, where a deployment issues those); on a multi-box deployment the hub
-serves the issuer's copy once its mirror picks it up (seconds). The box
-needs no certificate for the name. Custom domains get theirs through cert
-warm and the alias rules as any alias does (§4.10).
-
-### 4.9 Other platform boxes and DNS
-
-The hub's edges file lists every ready row, the forward row included, as
-`role: home` with its account and app (`internal/host/edgesfile.go:592`).
-A request for the host that lands on another platform box misses its own
-map and backhauls to the hub (`homemap.go`), which forwards over the
-tunnel. One hop, as for any home-boxed route. Steering, where on, points
-the host at the hub's region. No DNS record is written or changed.
-
-### 4.10 Custom domains
-
-They follow from the row with no new code: the hub's alias pass sees a
-local primary for the claim and writes the alias, the edge folds it onto
-the forward row's proxy, and the edges file publishes it once its DNS is
-stamped as pointing. The edge's tenancy check applies to the alias through
-its primary.
-
-### 4.11 Headers, cache, metering
-
-- `X-Carlos-Version`: the forward row has no `Version`, so the hub stamps
- nothing and the box's header (from the generation that served, on a
- rootfs or generations box) reaches the client once. The witness asserts
- exactly one value.
-- Response cache: forward rows bypass the hub's response cache, for the
- reason the backhaul path already gives (`edge.go`, backhaul notes: a copy
- kept where the app's `Carlos-Purge` cannot reach it can never be
- invalidated). The box's edge is the home edge. Open question 2.
-- Analytics, plan throttle, rate limit, guard, request records: counted
- once at the hub, skipped on the box (§3.9). Unchanged.
-- Usage: the hub meters what it forwards (`edge.go:1902`), which is the
- platform's egress. Whether the box's own meter also lands somewhere a
- bill reads is for the plan to establish; 1a changes neither.
-
-### 4.12 Hibernation and wake
-
-The hub never manages a forward row (`viaTunnel`, and the row has no
-`Hibernate` or `Runtime`). A sleeping native instance on the box wakes on
-the request the tunnel delivers, through the box's own activator. A rootfs
-instance is resident and does not sleep. A wake that takes longer than the
-client waits is the box's existing behaviour, not the hub's.
-
-### 4.13 Failure modes
+| record deleted | retired on the next whole pass, confirmed against the bucket |
+| app trashed, marker read, not production | retired (`removable`), confirmed with a fresh-store read |
+| app trashed but flagged production, or marker unreadable | kept; nothing minted (`declineMint` without `removable`) |
+| app placed back on the platform | retired; the instance pass mints the real row afterwards in the same pass |
+| app placed on another fleet of the same account | rewritten by `PutForward`, `FleetBox` cleared |
+| fleet's owner changes, or the fleet row goes | the edge stops serving on its next reload; the pass retires |
+| every box of the fleet detached | kept; 503 `fleet unreachable` with `Retry-After` |
+| hub stops being the hub | that box's pass retires its forward rows; the new hub mints |
+| a read failed, or the scan was partial | nothing retired |
+
+### 4.7 Rows already at the host, and `apps place` **(R1-7)**
+
+The forward phase never converts, overwrites or deletes a row that is not
+a forward row. Whatever holds the host (a hand row, a legacy placed row
+from `apps place`, another app's row) stays as it is and the host is
+reported (§4.3 step 4). railsdemo keeps serving through its hand row;
+removing it is an operator step for later, with Paul's approval, after
+which the forward row appears on the next pass. A legacy placed
+`Provisioned` instance row likewise stays, served as today and still not
+retired; the plan lists any such rows on dev and flagship (read-only) and
+their removal is approved per row.
+
+`placeAppTarget` stops calling `reg.SetPlacement` on the console box's
+rows (`fleets.go:817-829`) (Q5, fixed), so no new legacy placed row is
+made.
+
+### 4.8 Request policy: enforced once, at the hub; the gate at the fleet edge **(R1-2, R1-3)**
+
+Rate limit, plan throttle, lapse page, upgrades. Enforcement for a
+forward row happens at the hub; the fleet edge keeps exempting tunneled
+requests, unchanged. The selectors that name `instance` admit a forward
+row too, with the app's own settings:
+
+- `rateAdmit` (`ratelimit.go:124`): `Kind != "instance" && !IsForward()`;
+ the forward row carries `RateLimit`, so `up.rate` (`edge.go:1004`) is the
+ app's setting and the plan ceiling applies by account;
+- `planThrottleOf` (`planthrottle.go:53`) and `trackUpgrade`
+ (`planthrottle.go:99`) the same; `planThrottleFor`
+ (`internal/host/plans_pass.go:208`) the same;
+- `planDisabledFor` already keys on account and host, kind-free.
+
+The gate. The hub never interprets a gate on a forward row: the row's
+`Gate` is empty and the hub forwards every path to the fleet edge, which
+holds the record's gate on its own row, renders the form, checks the
+password, sets and strips the cookie (`internal/gate/gate.go`). The one
+code change is the login-POST refusal:
+
+```go
+// edge.go:1966, today: if loginPost && up.route.Gate == "" {
+if loginPost && up.route.Gate == "" && !up.route.IsForward() {
+ http.NotFound(w, r)
+ return
+}
+```
+
+The gate's same-origin check reads `Origin` against `r.Host`, which
+`fleetProxy` preserves (`edge.go:3110-3116`). The cookie is host-only and
+`Secure`; the browser holds it for the public name and the hub passes it
+through untouched.
+
+Caches, which the gate makes load-bearing: the hub cannot see the fleet
+edge's gate, so it must never answer a forward row from storage.
+
+- The response cache: `cacheable` (`edge.go:2083`) gains `&& !up.route.IsForward()`
+ (Q2, fixed: the purge stops at the box, and a gated page cached at the hub
+ would be served without the cookie).
+- The asset cache: `localAssetCatch` (`assetcatch.go:256-275`) refuses a
+ forward row, which also refuses the hop fill (`serveAssetFillForHop`,
+ `assetcatch.go:354`, goes through it). The edges file publishes no
+ `assets` block for one (§4.4), so no far edge catches for it either.
+
+The guard (hard and probe checks) and analytics run at the hub, as for
+any route, and the fleet edge skips them for tunneled requests.
+
+### 4.9 Certificates and TLS **(R1-6)**
+
+TLS ends at the hub. An eligible forward row is in the hub's map and in
+its edges file, so the hub's own policy and a separate issuer both admit
+it; the first handshake orders, or a wildcard the deployment issues covers
+it; on a multi-box deployment the hub serves the issuer's copy once its
+mirror picks it up. A refused row is in neither the map nor the file
+(§4.4), so it drives no order anywhere. Custom domains get theirs as any
+alias does.
+
+### 4.10 Other platform boxes and DNS
+
+The hub's edges file lists an eligible forward row as `role: home` with
+its account and app. A request landing on another platform box backhauls
+to the hub (`homemap.go`), one hop. No DNS record is written or changed.
+Steering is not asked for: the forward row carries no `Steering`.
+
+### 4.11 Custom domains, catch-alls and platform names **(R1-10, R1-11)**
+
+- An attached custom domain: the hub's alias pass sees a local primary
+ and writes the alias; the edge folds it onto the forward row's proxy; the
+ edges file publishes it under the §4.4 rule.
+- An instance catch-all (`<slug>.<custom-parent>`): derived from the
+ forward row's `Slug` (`aliases.go:170`), which the forward phase
+ converges. Covered by a test through both edges.
+- Platform names: none in 1a. The domains pass picks a source with a
+ socket, an address or a static channel (`firstReadyUpstream`,
+ `internal/domains/reconcile.go:823`), and a forward row has none, so it
+ mints nothing from one. Stated, tested, and left so: widening it would
+ make a domains-owned forward-shaped row, and ownership would stop being
+ disjoint (§4.3).
+
+### 4.12 Headers and metering
+
+The forward row has no `Version`, so the hub stamps nothing and the box's
+header reaches the client once. Usage: the hub meters what it forwards
+(`edge.go:1902`), the platform's egress; 1a does not change the box's
+meter.
+
+### 4.13 Hibernation and wake
+
+The hub never manages a forward row (`viaTunnel`; no `Hibernate`, no
+`Runtime`, `ActivatorManaged` false, `internal/activator/layout.go:65`). A
+sleeping native instance wakes on the box when the tunnel delivers the
+request; a rootfs instance is resident.
+
+### 4.14 Failure modes
| what fails | what a visitor sees | why |
|---|---|---|
-| fleet box down, or its tunnel down | 503, `Retry-After: 2`, after at most ~10 s of reap | `errFleetDark`; fleet channels ping every 5 s with a 5 s deadline (`tunnel.go:50-59`) |
+| fleet box or its tunnel down | 503, `Retry-After: 2`, after at most ~10 s of reap | `errFleetDark`; fleet channels ping every 5 s, 5 s deadline (`tunnel.go:58-59`) |
| tunnel drops mid-request | 502 | `fleetProxy`'s other transport errors |
| box up, its own row not minted yet | the box's unknown-host answer | the box's pass has not run |
-| instance failed on the box (held build) | whatever the box answers (its last good build, or its error) | the hub forwards |
-| hub down | the host is down | the hub is a single point for its fleets, as now |
-| fleet owner mismatch | TLS refusal, as for an unknown host | §4.4 |
-| record deleted | TLS refusal after the next whole pass | §4.6 |
-
-### 4.14 Every other reader must ignore a forward row
-
-The plan's first task is the audit: every reader of `reg.List()` and
-every selector on `Provisioned`, listed with what it does with a
-`forward` row. Known so far:
-
-- Must ignore (positive kind or column filters already do; each gets a
- guard test): root adopt (`release.Adoptable`, `SidecarAdoptable`),
- `CapabilityRoute`, named-unit config delivery and restart (no `Unit`),
- the rootfs and activator paths (no `Runtime`, no `Hibernate`,
- `ActivatorOwned` false), Litestream (`ops.FleetDBs`, no `DBPath`), seed
- passes (`seedreconcile.go:174`), layout, scheduled work, plans and caps
- counting, telemetry, the instance pass's own removal (§4.6).
-- Must include: the edge's fleet arm, the edges file, the alias pass, the
- issuer policy, analytics' app switch (by account and app).
-- Console, which shares the registry: the fleet page's placed-apps list
- (`fleets.go:1301-1307`) and the placement readers (`accountfleet.go:144`,
- `regionfacts.go:118`) already read fleet-placed rows as "placed", which
- is now correct for apps born placed. Instance health
- (`apiinstances.go:405-420`) treats a local row as local and must skip a
- forward row so a fleet instance keeps its fleet answer.
-- The domains pass (flagship, `PLATFORM_APPS_DOMAIN` set) mints platform
- addresses from a source row; with a forward row as source, `mintedRoute`
- copies its kind and region, giving a second forward-kind row owned by
- the domains pass. The plan checks the source selection and the domains
- pass's removal against that.
+| instance failed on the box | whatever the box answers | the hub forwards |
+| hub down | the host is down | the hub is a single point for its fleets, as today |
+| owner mismatch, unknown fleet, non-inert forward row | TLS refusal, as for an unknown host; no order anywhere | §4.4 |
+| record deleted or app trashed | TLS refusal after the next whole pass | §4.6 |
+| rate limit or throttle hit | 429 from the hub | §4.8 |
+
+### 4.15 Every other reader of a forward row **(R1-4, R1-9, rev 2)**
+
+The plan's first task re-runs this audit over every `reg.List()` reader
+and every `Provisioned` selector, with a table test (§8). Known:
+
+Must ignore it, and why that holds:
+
+- Root adopt, capability, fast sweep, config sync: `release.Adoptable`,
+ `SidecarAdoptable`, `CapabilityRoute` select `instance` or `sidecar`.
+- Named-unit delivery and restart (no `Unit`), rootfs and the activator
+ (no `Runtime`, `ActivatorManaged` false), Litestream (`ops.FleetDBs`, no
+ `DBPath`), seed passes (`seedreconcile.go:174`), layout, scheduled work,
+ build-state refresh (`keepsBuildState`, `internal/host/buildstate.go:367`,
+ false).
+- **Retention (rev 2).** `retentionPass` (`internal/host/retention.go:50-110`)
+ prunes releases for every app with a row on the box, protecting that
+ box's versions and the platform box reports. A forward row would have
+ brought fleet apps into the hub's retention, and fleet boxes' versions
+ are not in those reports, so the hub could have pruned the build box-1
+ runs. Its selection skips `IsForward()` rows: fleet apps keep today's
+ rule, pruned by no platform box (and never by a fleet box, spec F6).
+- The instance pass's removal (§4.3).
+
+Must treat it correctly, with a change:
+
+- **Root egress (R1-4).** `boxWhollyNested`
+ (`internal/host/egress_source.go:59-108`) refuses any kind it does not
+ know (`:85`), and root's egress source closes private egress for every
+ local instance when it does (`:255`). It gains one case ahead of that
+ refusal: a forward row that is `InertForward()` runs no local process
+ and is skipped; a forward row that is not inert is refused with its own
+ reason; every other unknown kind is still refused. The independent
+ runtime evidence (`railEvidence`) is untouched. Root code: claimed in
+ §7.
+- Request policy (§4.8), caches (§4.8), edge dispatch and publication
+ (§4.4), bindings (§4.5).
+
+Must include it, unchanged: the alias pass, analytics' switch (by account
+and app), the plans pass (limits by account), telemetry.
+
+Console, which shares the registry: the fleet page's placed-apps list
+(`fleets.go:1301-1307`) and the placement readers (`accountfleet.go:144`,
+`regionfacts.go:118`) already read fleet-placed rows as placed, which is
+now right for apps born placed. Instance health
+(`apiinstances.go:405-420`) skips a forward row so a fleet instance keeps
+its fleet answer.
## 5. Provider boundary
-Nothing here touches a cloud API. The forward pass reads the registry and
-records it already read, the edge reads the registry, and DNS is the
-deployment's. Works the same on any provider and on a deployment with no
-cloud at all.
+No cloud API. The forward phase reads records the scan already read and
+the local registry; the edge reads the registry; DNS is the deployment's.
+Works the same on any provider and with no cloud.
-## 6. Request budget
+## 6. Request budget **(R1-9)**
-Steady state, nothing changing, per box per day:
+Per box per day with nothing changing. `P` = instance passes a day on the
+hub (the 5-minute backstop, about 262, plus change-driven passes), `A` =
+fleet-placed apps that gain a forward row, `C` = their accounts not
+already represented on the hub, `N` = platform boxes, `F` = directories
+under `fleets/`, `B` = binding objects.
-| box | before | after |
+| reader | before | after |
|---|---|---|
-| hub | instance pass reads (unchanged); bindings pass `1 + F + B` per pass | same |
-| every other platform box | instance pass reads; bindings pass `1 + F + B` per pass | instance pass reads; no bindings pass |
+| instance pass, record bodies | read on every platform box | same (no new record read) |
+| instance pass, trash markers (hub) | in-scope apps | + `A` GETs per pass in the prefetch: `A x P` |
+| trash removal confirmation | on a removal only | same, for forward retirements |
+| telemetry (hub; index armed) | per hosted (account, app) | + up to 2 GETs per new pair per scope change and per 30-minute backstop: `<= 2 x 48 x A` (account key shared when the account already has rows) |
+| telemetry (index off) | 2 GETs per pair per pass | + `2 x A x` telemetry passes |
+| plans pass (plans on) | 1 limits GET per represented account per pass | + `C` per pass |
+| retention | per hosted app | unchanged: forward rows excluded (§4.15) |
+| build states, alias pass, edges-file assets | per their selectors | unchanged: forward rows excluded or read nothing |
+| bindings pass | `1 + F + B` per pass on every platform box | on the hub only: saves `(N - 1) x 262 x (1 + F + B)` |
+| edges file | written on change | one more PUT when a forward row appears or goes; readers' existing 30 s mirror |
| fleet boxes | unchanged | unchanged |
-`F` is the number of directories under `fleets/`, `B` the number of
-binding objects; the loop runs about 262 times a day (5 minutes plus up to
-a minute of jitter). So 1a saves `(N - 1) x 262 x (1 + F + B)` requests a
-day on a deployment with `N` platform boxes, and adds none: the forward
-phase uses records the scan already read and a local SQLite table; the
-edge check is local.
-
-On change: one edges-file PUT on the hub when a forward row appears or
-goes (the file is written on change only), and the readers' existing
-30-second mirror reads it; one certificate order per new host, as for any
-route. A test with a counting store asserts the instance pass makes the
-same store calls with and without fleet-placed records present.
-
-## 7. Census
-
-- Root-read census (`TestPlan14RootReadCensus`): it fails, because
- `internal/provision`, `internal/registry`, `internal/edge` and
- `internal/host` are in the root binary. Card through `make census-card`
- and `make census-propose`. Claims to make: no root read is added; root's
- passes read the registry as before and select by `Kind == "instance"`,
- `IsSidecar()`, `Unit`, `Runtime`, `Backing`, `Caps`, none of which a
- forward row carries; the edge's fleets read moves earlier in `Reload`,
- same table, same connection rule. Reviewer from the other family
- (Astra), verdict on #280.
-- Record-write census (9B8): no new bucket writer. If the forward phase
- lives in a declaration the inventory pins (`Reconcile` names record
- keys), its digest changes and is re-reviewed with the census card.
-- The console change (`placeAppTarget`) is outside the root census scope.
+So 1a is not free: each fleet app costs the hub about what a platform app
+costs its home box (`P + 96` GETs a day with the index armed, plus the
+account's limits reads where plans are on), and the bindings saving is a
+fixed offset. At S3's GET price that is about a hundredth of a cent per
+fleet app per day. No reader polls on its own timer: every one is an
+existing pass gated as it is today.
+
+The test: the production pass set (instance pass, telemetry, plans,
+retention, bindings, edges file) run over identical records and registry
+twice, once without and once with a fleet-placed app and its forward row,
+with a counting store; the difference must equal the table's `A = 1, C = 1`
+row by row.
+
+## 7. Census **(R1-13, R1-4)**
+
+Root-read census (`TestPlan14RootReadCensus`) fails: `internal/provision`,
+`internal/registry`, `internal/edge`, `internal/host`, `internal/release`
+and the root package are in the root binary. Input sources are unchanged
+(the agent-writable `registry.db`, including its console-written
+`fleets` and `fleet_boxes` tables, and the bucket through the existing
+passes). Added read sites and changed units, claimed one by one with
+`make census-card` and `make census-propose`:
+
+- `internal/registry`: `KindForward`, `Route.IsForward` (reads `Kind`),
+ `Route.InertForward` (reads the columns of §4.2), `PutForward` and
+ `DeleteForward` (new writers, conditional on `Kind`).
+- `internal/host/egress_source.go` `boxWhollyNested`: **runs as root**. A
+ new case reads `Kind` and the inert columns of an agent-written row to
+ SKIP it; every other refusal and the root evidence are unchanged. The
+ reviewer checks that an agent-written row can only skip itself, never
+ another row, and that a non-inert forward row is still refused.
+- `internal/provision/reconcile.go` `Reconcile` (forward phase, trash
+ prefetch scope, `retirable` guard) and `ReconcileConfig.FleetOwners`
+ (reads `Fleet.Name`, `Fleet.Account`).
+- `internal/host`: `boxProvisionConfig` (hub predicate, owner map),
+ `ReconcileFleetBindings` (key check; reads `FleetBox.Label`, `Status`),
+ `instancesLoop` (hub-only bindings), the edges-file writer (eligibility,
+ fleets read), `retentionPass` selection, `planThrottleFor`.
+- `internal/edge`: `Reload` (forward case, eligibility, fleets read moved
+ earlier), `FleetServeEligible`, `rateAdmit`, `planThrottleOf`,
+ `trackUpgrade`, the login-POST rule, `cacheable`, `localAssetCatch`.
+- `internal/release`: `FleetForwardFloor`, `FleetForwardFloorAllows`,
+ `FleetForwardFloorOverrideFlag`, `SystemPointer.AllowBelowFleetForwardFloor`
+ (an additive, signed field root parses and does not act on, as the two
+ floors' flags).
+- Root package: the `carlos system update` and `rollback` flag; the
+ `carlos route` and `carlos add` refusal.
+
+Root's own row readers (adopt, capability, named units, restart, stage,
+rootfs) change no code and select by `Kind == "instance"`, `IsSidecar()`,
+`Unit`, `Runtime`, `Backing`, `Caps`; the reviewer checks none admits an
+inert forward row.
+
+Record-write census (9B8): no new bucket writer. `Reconcile`'s inventory
+digest changes and is re-reviewed with the card. The console changes
+(`placeAppTarget`, the floor judge, the fleet-create barrier) are outside
+the root scope.
+
+Reviewer: Astra, verdict on #280.
## 8. Tests
-Unit (`internal/provision`, `internal/edge`, `internal/registry`):
-
-1. Desired set: owner match mints; owner mismatch, unknown fleet,
- non-hub, replica, collision with an in-scope record, existing hand row
- or other row: none, and logged once.
-2. Converge and retire: each row of §4.6's table; no retirement on a
- failed read, a partial scan, or a protected host; the snapshot
- re-check.
-3. Guards both ways: the instance pass never retires a forward row; the
- forward phase never retires an instance or sidecar row.
-4. Every selector in §4.14's "must ignore" list answers false for a
- forward row (one table test over the selectors, so a new selector that
- forgets the kind shows up there).
-5. Edge: a fleet-placed row with a mismatched account gets no map entry
- and `Allowed` false; a match is served through `fleetProxy`; a
- forwarded response carries the box's `X-Carlos-Version` exactly once;
- forward rows skip the response cache.
-6. Counting store: the request budget of §6.
-
-Production-wired witness (the gate, ahead of review rounds; memory
-`production-wired-witnesses`). In the root package, which can import both
-the console and the agent, building on `internal/edge/tunnel_e2e_test.go`'s
-real tunnel loop. No hand-built forward rows, no fabricated records:
-
-- A real console `Server` over a temp registry and a dir-backed
- deployment store creates account A's fleet `f`, adds `box-1` (keeping
- the printed token), creates app `shop` with `--place fleet/f` and its
- instance, and promotes `v1`.
-- The hub: a real `Edge` with the tunnel hub armed through
- `enableTunnelsFromEnv` (`CARLOS_TUNNEL_HOST` set), the same registry,
- and the instance pass run through the function the change-index leg
- calls, with the config the agent builds from its env.
-- The box: a second real `Edge` on its own registry, its instance pass
- run with `CARLOS_FLEET=f`, serving over `tunnelclient.Loop` with the
- token from step one, and a real process bound at the derived socket
- answering `/up` with the build.
-- Assert through the hub's TLS listener (test certificate): `GET /up` is
- 200 with one `X-Carlos-Version: v1`. Then: detach the box, 503 with
- `Retry-After`; re-add, 200; delete the record, the row goes and the hub
- refuses the name; a second account B with its own fleet places an app on
- `fleet/f` by writing the record directly (bypassing the console door):
- no row, and a hand row for it is refused by the edge.
+Unit (`internal/registry`, `internal/provision`, `internal/edge`,
+`internal/host`):
+
+1. `PutForward` over an existing non-forward row writes nothing and
+ returns `ErrHostHeld`; over a forward row carrying stray `Tunnel`,
+ `Caps`, `Unit`, `Seed`, the stored row read back has exactly §4.2's
+ columns; `FleetBox` survives an unchanged `Region` and is cleared by a
+ changed one. `DeleteForward` leaves a hand row alone.
+2. Forward phase: every decision of §4.3 step 3 and every row of §4.6,
+ including trash read and not production (retired), production
+ (kept), unreadable marker (kept, not minted), snapshot removal
+ re-confirmed against the bucket; no removal on a failed read or partial
+ scan; held host reported once per pass.
+3. Ownership both ways: the instance pass never retires a forward row; the
+ forward phase never touches an instance, sidecar, hand or `Platform`
+ row; the domains pass mints nothing from a forward source.
+4. Readers table: every §4.15 "must ignore" selector answers false for an
+ inert forward row, retention included (a forward row pins and prunes
+ nothing for its app).
+5. `FleetServeEligible`: accountless hand row eligible and logged;
+ explicit mismatch refused; invalid account refused (not `OpsAccount`'d
+ into a pass); forward row with empty account, unknown fleet, or a stray
+ column refused.
+6. Edge: an ineligible row has no map entry, `Allowed` false; a forward row
+ with a stray `Tunnel` is not served through the tunnel arm; the box's
+ `X-Carlos-Version` arrives once; forward rows are never stored in or
+ answered from the response or asset cache.
+7. Request policy, through both edges: an HTTP request and a WebSocket
+ upgrade over the limit get 429 at the hub, and the fleet edge never
+ limits a tunneled request; a throttled account's upgrade is refused and
+ an open one is closed by `CloseAccountUpgrades` at the hub.
+8. Edges file and a separate issuer: a second edge reading only the hub's
+ edges file admits an eligible forward row's name and its alias and
+ catch-all, and admits none of a refused row's.
+9. Bindings through the authenticated store door: a box of fleet A writes
+ `fleets/A/bindings/<B's host>.json` naming fleet B and a B label, and a
+ binding naming an unregistered label under its own fleet; the bindings
+ pass applies neither.
+10. Egress: a box with one nested local instance and an inert forward row
+ is wholly nested; with a non-inert forward row or an unknown kind it is
+ not.
+11. Floor: §9's refusals, override, signed flag and fleet-create barrier.
+12. Counting store: §6.
+
+Production-wired witness, the gate ahead of review rounds (memory
+`production-wired-witnesses`). In the root package, which can import the
+console and the agent, on `internal/edge/tunnel_e2e_test.go`'s real tunnel
+loop; no hand-built rows, no fabricated records:
+
+- A real console `Server` over a temp registry and a dir-backed store
+ creates account A's fleet `f`, adds `box-1` (keeping the printed token),
+ creates app `shop` with `--place fleet/f`, sets a password gate and a
+ rate limit, and promotes `v1`.
+- The hub: a real `Edge` with the hub armed through `enableTunnelsFromEnv`,
+ the same registry, the instance pass through the function the
+ change-index leg calls, with the config the agent builds from its env.
+- The box: a second real `Edge` on its own registry, its instance pass run
+ with `CARLOS_FLEET=f`, serving over `tunnelclient.Loop` with that token,
+ and a real process at the derived socket answering `/up` with its build.
+- Through the hub's TLS listener (test certificate): `GET /up` gets the
+ fleet edge's login form; `POST /.carlos/gate` with the password gets the
+ cookie; `GET /up` with it is 200 with one `X-Carlos-Version: v1`; the
+ same GET without the cookie is the form again (nothing cached at the
+ hub); requests past the limit get 429 from the hub. Then: an instance
+ catch-all under an attached custom parent serves; detach the box, 503
+ with `Retry-After`; re-add, 200; trash the app, the row goes and the hub
+ refuses the name; account B writes a record placed on `fleet/f`
+ directly to the store: no row, no edges-file entry.
Live acceptance on dev, after the roll (read-only checks):
- `curl -sI https://shop.bab.dev.oncarlos.com/up` from DOCS-T1: 200,
`X-Carlos-Version: v1`.
-- The same through leo (`--resolve shop.bab.dev.oncarlos.com:443:18.200.150.210`):
+- Through leo (`--resolve shop.bab.dev.oncarlos.com:443:18.200.150.210`):
200 by backhaul.
- `curl -sI https://railsdemo.bab.dev.oncarlos.com/up`: still 200 through
- its hand row.
+ its hand row, and the hub's journal reports the held host.
- The r10r fleet page lists `shop`.
-## 9. Rollout
-
-No switch. A forward row exists only on a hub, and only for a record whose
-fleet the hub's own table gives to the record's account; a box with no
-hub, which is every box but the console's on today's deployments, holds
-none. Stopping rule 5: what a user gets is their fleet app at its URL; who
-asks is Paul (2026-10-29); it switches on when the release carrying it
-rolls to dev, and on the flagship with its next roll.
-
-No release floor. Only the hub writes forward rows, and other boxes see
-them only through the hub's edges file, in a shape they already read. A
-rollback of the hub leaves forward rows that the older binary still serves
-(its fleet arm keys on placement) and never retires, and its root passes
-ignore (they select `instance`); the next upgrade reconciles them.
-
-Order: dev first (sophie is the dev hub), the witness check, then the
-flagship. On any other deployment with fleets (Tito, for Eleven), the
-upgrade gives fleet-placed records public rows where no hand row holds
-the host; hand rows keep winning. Say so in the release notes.
-
-No member-facing strings are added. If the plan adds a REASON for a
-withheld forward row to `instances list`, it goes to copy review.
-
-## 10. Open questions for Paul
-
-1. A new row kind (`forward`) rather than reusing `instance` or the
- domains pass's `Platform` flag. Recommend: the new kind (§4.2). The
- other two hand the row to passes that run or remove things.
-2. Forwarded responses skip the hub's response cache, because the app's
- `Carlos-Purge` stops at the box and the hub's copy could never be
- invalidated. Recommend: skip in 1a. The cost is that fleet apps get no
- response cache until the purge is carried through the tunnel.
-3. Hand rows: leave them winning, or adopt a hand row that matches a
- record? Recommend: leave them (adoption is an authority transfer), and
- convert only the `Provisioned` legacy placed rows. railsdemo's hand row
- goes later, with your approval.
-4. The edge refuses any fleet-placed row whose account is not the fleet's
- owner, hand rows included. Recommend: yes, mismatches only; a row with
- no account is served as today and logged.
-5. `apps place` stops stamping the console box's rows. Recommend: yes;
- the passes converge from records in both directions.
+## 9. Rollout and the floor **(R1-5)**
+
+No feature switch: a forward row exists only on a hub, for a record whose
+fleet the hub's table gives to the record's account. Stopping rule 5: a
+user gets their fleet app at its URL; Paul asked (2026-10-29); it switches
+on when the release carrying it rolls to dev, and on the flagship with its
+next roll.
+
+A release floor, because an older hub serves a forward row (its fleet arm
+keys on placement, `edge.go:820`) and cannot retire it (`reconcile.go:2044`),
+so after a rollback a deleted or reassigned host would keep pointing at
+the old fleet indefinitely. The RegionalDomainsFloor pattern
+(`internal/release/layoutintent.go:265`, `internal/console/regionalfloor.go`):
+
+- `release.FleetForwardFloor`, a `SemVer` set to the release that ships
+ this (numbered at the cut, pinned by `TestFleetForwardFloorIsPinned`),
+ and `release.FleetForwardFloorAllows(installed, candidate)`, the same
+ shape as `RegionalFloorAllows` (`layoutintent.go:305`): a channel below
+ the floor may move anywhere; one at or above it may not move below it or
+ to a version that does not parse.
+- Condition: while a fleet exists in the console's registry
+ (`ListFleets` non-empty, local, no bucket read). This is a superset of
+ "a fleet-placed record exists" (no fleet-placed record can be made, or
+ forwarded, without a fleet) chosen because the record form needs a walk
+ of every record and the table form is exact about what matters: no
+ fleet, no forward row.
+- Override: `--allow-below-fleet-forward-floor`
+ (`release.FleetForwardFloorOverrideFlag`) on `carlos system update` and
+ `carlos system rollback`, signed on the pointer as
+ `AllowBelowFleetForwardFloor` and part of an activation request's
+ identity, as the other two overrides; boxes do not read it. Its log line
+ and the CLI's warning say what it costs: the hub keeps serving fleet
+ apps it can no longer retire, so remove their rows first.
+- Checked where the other floors are: `systemFloorGate` /
+ `systemFloorSnapshot` (`internal/console/rootfsfloor.go`) on the update
+ door's preflight (`apisystemupdate.go:428`), `promoteHostUpdate`, and
+ `rollbackHostUpdate`, judged on the same pointer read; and again under a
+ console mutex (`fleetFloorMu`) immediately before the pointer is
+ published, as `regionalFloorPublish` does.
+- The barrier for the other order: the fleet-create doors
+ (`handleAPIFleetNew`, `fleets.go:176`, and the page form) hold
+ `fleetFloorMu` from their check to their write and refuse while any
+ system channel's current pointer names a release below the floor. So a
+ fleet cannot appear between a downgrade's judgment and its publication,
+ nor while a downgraded hub could still be running the newer binary.
+ Existing fleets are unaffected.
+
+Refusal, override and barrier strings go to copy review.
+
+Order: dev first (sophie is the dev hub), the witness, then the flagship.
+Any other deployment with fleets (Tito, for Eleven) gains public rows for
+fleet-placed records where no row holds the host; existing rows keep
+winning. The release notes say so, and name the floor.
+
+## 10. Decisions (fixed by the controller, platform-39)
+
+1. A new row kind, `forward`.
+2. Forwarded responses skip the hub's response cache (and its asset
+ cache, §4.8).
+3. Every existing row at the host wins; the forward phase never converts
+ one (extended from hand rows by the R1-7 ruling).
+4. The edge refuses a fleet-placed row whose account is not the fleet's
+ owner; a row with an empty raw account is served and logged.
+5. `apps place` stops re-stamping rows on the console box.
+6. R1 rulings: bindings hardened here (R1-1); enforcement once at the hub
+ (R1-2); the fleet edge owns the gate (R1-3); egress recognises the
+ inert forward shape (R1-4); a release floor (R1-5); one eligibility
+ predicate (R1-6); no conversion (R1-7); explicit trash decisions
+ (R1-8); Slug kept (R1-10); no platform names in 1a (R1-11).
+
+One call left for the controller: the floor's condition is "a fleet
+exists" rather than the ruling's "a fleet-placed record exists" (§9), for
+the reason given there. A deployment with an empty fleet gets a floor it
+does not strictly need, and the override covers it.
## 11. Notes against the #457 draft
-- "The console never writes route rows": it never ADDS one, but
- `apps place` re-stamps `Region` on the console box's existing rows
- (`fleets.go:817-829`). That was the original route answer for fleets,
- and it is why the hub already has a fleet arm. It never helped an app
- born placed, or any rootfs app.
+- "The console never writes route rows": it never adds one, but
+ `apps place` re-stamps `Region` on the console box's rows
+ (`fleets.go:817-829`).
- "A forwarding row only when the fleet's owner record names the same
- account": the bucket owner record is not needed. The hub holds the
- console's `fleets` table locally, the same table its tunnel auth and
- store door use. §4.4.
-- "The hub edge (the platform box the router reaches)": concretely the
- console's box. Boxes dial the console host and the fleets table exists
- only in its registry. On dev that is sophie, which is also where the
- apps domain resolves.
+ account": the hub's local `fleets` table is the owner, not the bucket
+ owner record.
+- "The hub edge": concretely the console's box (sophie on dev).
- "Pointing at the fleet and the box running the instance": the record
- names no box. The box comes from the existing bindings
- (`fleets/<f>/bindings/<host>.json`, `ReconcileFleetBindings`), with the
- first connected box as fallback, which is enough for one box (§4.5).
-- Line refs: `fleetProxy` is at `edge.go:3106` on main (3059 in the draft).
- `inScope` at `reconcile.go:487-499` is right.
-- "Custom domains and certificates follow from the row": yes, plus two
- things the draft did not name: the edge-side tenancy check (§4.4) and
- the hub cache that the app's purge cannot reach (§4.11).
+ names no box; bindings do, and they needed hardening (§4.5).
+- `fleetProxy` is at `edge.go:3106` on main, not 3059.
+- "Custom domains and certificates follow from the row": only once
+ publication obeys the same tenancy rule as serving (§4.4), the row keeps
+ its slug (§4.11), and the hub never answers it from a cache (§4.8).