carlos / platform Public

Fleet public routes design rev 4: Astra round 3 P2s applied

Round 3 was READY AFTER FIXES with no P1. Rev 4 lists every routes writer
in internal/registry (transactional, claim, import, hold, lifetime and
platform-socket writers, run-time built deletes included) under one rule:
refuse forward inputs before transactional side effects, guard the route
writes (R3-1); budgets the instance catch-all listing and duplicate-label
observations and adds alias reconciliation to the counting test (R3-2);
names the writer units in the census list (R3-3). Status: awaiting Paul's
approval.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 06b4d79ea2f3c6782772e66b8e7855e48e75395f parent 76bec27
2 files changed, +128 −32
  • docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R3.md +36 −0
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +92 −32

CI passed — run details

diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R3.md b/docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R3.md
new file mode 100644
index 000000000..dcea12717
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-R3.md
@@ -0,0 +1,36 @@
+- R1-1 (P1): **resolved** — canonical binding keys and the conditional write bind placement and active membership.
+- R1-2 (P1): **resolved** — forward rows enter the hub’s rate-limit and throttle selectors.
+- R1-3 (P1): **resolved** — forward hosts bypass login parsing, re-resolution, gate handling and caches.
+- R1-4 (P1): **resolved** — egress skips only inert forward rows and retains independent runtime checks.
+- R1-5 (P1): **resolved** — the floor judges first publication and serializes publication against fleet creation.
+- R1-6 (P1): **resolved** — serving and publication share eligibility, including derived names.
+- R1-7 (P1): **resolved** — conversion is cut; existing non-forward rows retain ownership.
+- R1-8 (P1): **resolved** — uncertainty preserves rows; retirement requires confirmation and production guards.
+- R1-9 (P2): **partly** — instance catch-all reads remain unbudgeted; finding 2.
+- R1-10 (P2): **resolved** — `Slug` is retained and converged.
+- R1-11 (P2): **resolved** — platform-name minting and both domains removal grounds have disjoint ownership.
+- R1-12 (P2): **resolved** — the accountless exception checks the raw account first.
+- R1-13 (P2): **partly** — the census inventory still omits required writer changes; finding 3.
+- R2-1 (P1): **resolved** — excluding forward rows from `loginPost` preserves the body through both existing readers.
+- R2-2 (P1): **resolved** — nil-current publication is judged under `fleetFloorMu`; both interleavings are covered.
+- R2-3 (P1): **resolved** — `SetFleetBoxIf` checks placement, kind and membership in one statement.
+- R2-4 (P2): **resolved** — canary reads are excluded and forward trash prefetch is marker-only.
+- R2-5 (P2): **resolved** — domains’ trash loop explicitly preserves forward rows.
+- R2-6 (P2): **partly** — the 65-field persisted shape is exhaustive, but its writer inventory is incomplete; finding 1.
+- R2-7 (P2): **partly** — release-publication units are added, but other required changed units remain absent; finding 3.
+
+No P1 findings.
+
+1. **P2 — §4.2: the claimed exhaustive writer list omits transactional writers.**
+ The blanket requirement to guard every writer is sound, but the enumeration at [spec:278](./docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md#L278) is incomplete. Missing examples include `InstallLifetimeIf`, whose zero-pair condition can match an inert forward row ([registry.go:1885](./internal/registry/registry.go#L1885)); `AdoptClaimRoute`, which can add forbidden ownership fields ([claimrows.go:82](./internal/registry/claimrows.go#L82)); and the import replacement transaction ([importjournal.go:324](./internal/registry/importjournal.go#L324)). Also omitted are hold/lifetime helpers, import commit/restore operations, claim retirement/recovery, and platform-socket writers.
+ **Failure scenario:** implementing or testing only the enumerated inventory leaves mutation paths outside the promised shape protection. **Fix:** explicitly inventory these operations and their transaction helpers, including dynamically constructed route deletes; refuse forward inputs before transactional side effects and guard the route writes. **Fault family:** R2-6 — every registry mutation must preserve forward-row shape and ownership.
+
+2. **P2 — §6: instance catch-alls introduce an omitted bucket listing.**
+ The budget declares the alias pass unchanged at [spec:732](./docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md#L732), and the comparative pass set omits alias reconciliation. However, a qualifying forward row makes `deriveInstanceAliases` call `labelHosts` ([aliases.go:179](./internal/domains/aliases.go#L179)). Production supplies `InstanceLabelCountsJudged` ([aliases.go:722](./internal/domains/aliases.go#L722)), which lists the app’s instance prefix ([claims.go:322](./internal/domains/claims.go#L322)); duplicate labels can additionally require lifetime observations ([claims.go:406](./internal/domains/claims.go#L406)).
+ **Failure scenario:** attaching an instance catch-all to a newly represented fleet app adds hub reads on alias passes despite the table’s zero increment. **Fix:** budget these reads and include production alias reconciliation, with catch-all and duplicate-label cases, in the comparative counting test. **Fault family:** R1-9 — request accounting must include every affected production reader.
+
+3. **P2 — §7: the census inventory still excludes units that the writer rule requires changing.**
+ The registry inventory at [spec:779](./docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md#L779) covers `registry.go` and remote dispatch, but omits writer units in other files. For example, guarding `Registry.SwapForImport` changes a declaration containing registry reads ([importjournal.go:291](./internal/registry/importjournal.go#L291)); guarding `Registry.AdoptClaimRoute` does likewise ([claimrows.go:59](./internal/registry/claimrows.go#L59)). Both are already census units. The scanner fingerprints each declaration with read sites independently ([plan14_root_reads_test.go:387](./internal/provision/plan14_root_reads_test.go#L387)); the registry envelope alone does not cover their unit dispositions.
+ **Failure scenario:** applying §4.2’s full protection produces census changes absent from §7’s promised inventory. **Fix:** add the omitted per-file writer units, including import and claim transactions, and reconcile them against the implementation’s census card. **Fault family:** R1-13 — census claims must describe every changed unit in scope.
+
+READY AFTER FIXES
\ 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 fd03dae9b..fa9571a50 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,6 +1,6 @@
# Fleet public routes: an app on a fleet serves at its URL with no hand row
-Status: DRAFT rev 3, 2026-10-30. Discussion: amadan carlos/platform #457
+Status: DRAFT rev 4, 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.
@@ -26,6 +26,17 @@ Revisions:
writers and checked by `InertForward` (R2-6); the census list per unit,
release publication included (R2-7). Rounds 1 and 2 are spent; this is
the text for round 3, the last.
+- Rev 4: Astra round 3 (`CODEX-FINDINGS-fleet-public-routes-R3.md`, READY
+ AFTER FIXES, no P1, every earlier P1 resolved, the blanket writer guard
+ judged sound). Its three P2s applied with no further round, marked
+ **(R3-n)**: the full writer inventory and the rule for transactional
+ writers (R3-1, §4.2); the instance catch-all reads budgeted (R3-2, §6);
+ the writer units in the census list (R3-3, §7).
+
+## 0. Status
+
+Rev 4. Astra R1 NOT READY, R2 NOT READY, R3 READY AFTER FIXES (P2s
+applied); awaiting Paul's approval.
## 1. Intent
@@ -275,27 +286,44 @@ cannot get there in the first place (R1-7, R2-6):
- `DeleteForward(host)`: deletes the row only if it is still a forward
row, in the same statement.
- `SetFleetBoxIf(host, fleet, label)` (§4.5).
-- Every other writer of the `routes` table in `internal/registry` carries
- `kind <> 'forward'` in its statement (an `INSERT` or `Upsert` over a
- forward host returns `ErrForwardRow`, an `UPDATE` or `DELETE` matches
- nothing), except
- `SetDNSStatus` and `SetCertExpiresAt`. Today those writers are `Upsert`,
- `UpsertUnlessRootfs`, `Delete`, `DeleteIfUnchanged` and the setters
- `SetSeedSource`, `SetHold`, `SetHoldIf`, `SetHoldIfSeq`, `SetClaimHold`,
- `SetAccount`, `SetChannel`, `SetStatus`, `SetCaps`, `SetDBPath`,
- `SetInstancePaths`, `SetBacking`, `SetUnit`, `SetReplication`,
- `SetUpstreams`, `SetSteering`, `SetAssets`, `SetUpdateSettings`,
- `SetPolicy`, `SetBuildState`, `SetReplicas`, `SetReplica`, `SetHA`,
- `SetGate`, `SetRateLimit`, `SetChannels`, `SetEnvironment`, `SetTunnel`,
- `SetPlacement`, `SetEnvironments`, `SetChannelsAndEnvironments`,
- `SetVersions`, `SetGoodBuild`, `SetServingVersion`, `SetHibernate`,
- `SetNextDue`, `SetSeed`, `SetArgs`, `SetWorkerLimits`,
- `SetProvisioned`, `SetStatusNamed`. `SetFleetBox` is removed: its only
- caller moves to `SetFleetBoxIf`. The registry's remote mode
- (`internal/registry/remote_dispatch.go`) carries the three new calls in
- place of `SetFleetBox`. The plan re-derives this list from the
- `routes` statements in the package, and a test runs each exported writer
- against a forward row (§8 test 1).
+- Every other writer of the `routes` table **(R3-1)**. The rule:
+ **refuse forward inputs before transactional side effects, guard the
+ route writes.** A writer that takes a `Route` (or a claim row) with
+ `Kind == forward` returns `ErrForwardRow` before it writes anything,
+ journal, archive or other table included. A writer inside a
+ transaction that would touch the `routes` row of a forward host checks
+ that row first, in the same transaction, and returns `ErrForwardRow`
+ before its first write. And every `routes` statement it then runs
+ carries `kind <> 'forward'` (an `INSERT` or upsert over a forward host
+ is refused, an `UPDATE` or `DELETE` matches nothing). The only
+ exceptions are `PutForward`, `DeleteForward`, `SetFleetBoxIf`,
+ `SetDNSStatus` and `SetCertExpiresAt`.
+
+ The inventory, from every `INSERT`, `UPDATE` and `DELETE` on `routes` in
+ `internal/registry` on `1fa2a99b`, statements built at run time
+ included (rev 4 grep; the plan re-derives it, and §8 test 1 runs each
+ against a forward row):
+
+ | file | writers |
+ |---|---|
+ | `registry.go` | `upsertRoute` (the statement under `Upsert` and `UpsertUnlessRootfs`), `Delete`, `InstallLifetimeIf` (its zero-pair condition would otherwise match a forward row, `:1885`), the hold helpers `SetHold`, `SetHoldIf`, `SetHoldIfSeq`, `HandHold`, `ReleaseHold`, `ReleaseHoldSeq`, `DeleteIfHold`, `DeleteIfHoldWithTimers`, `ClearNextDueIf`, and the setters `SetSeedSource`, `SetAccount`, `SetChannel`, `SetStatus`, `SetCaps`, `SetDBPath`, `SetInstancePaths`, `SetBacking`, `SetUnit`, `SetReplication`, `SetUpstreams`, `SetSteering`, `SetAssets`, `SetUpdateSettings`, `SetPolicy`, `SetBuildState`, `SetReplicas`, `SetReplica`, `SetHA`, `SetGate`, `SetRateLimit`, `SetChannels`, `SetEnvironment`, `SetTunnel`, `SetPlacement`, `SetEnvironments`, `SetChannelsAndEnvironments`, `SetVersions`, `SetGoodBuild`, `SetServingVersion`, `SetHibernate` (two statements), `SetNextDue`, `SetSeed`, `SetArgs`, `SetWorkerLimits`, `SetProvisioned`, `SetStatusNamed`; `SetFleetBox` is removed |
+ | `routecas.go` | `DeleteIfUnchanged` |
+ | `claimhold.go` | `SetClaimHold` |
+ | `claimrows.go` | `AdoptClaimRoute` (would add claim ownership, forbidden, `:82`), `RetireClaimRows` (its `DELETE FROM `+table built at run time, `:192`; refuses before writing `claim_row_retirements`) |
+ | `coldhandover.go` | `RestoreClaimRows` |
+ | `recoveryhandover.go` | `RebindClaimRows` |
+ | `importjournal.go` | `SwapForImport` (`:291-324`; refuses before the journal row is written), `insertRouteTx`, `CloseImportGate`, `CommitImport`, `RestoreImportRoute` |
+ | `aliassocket.go` | `RepointPlatformSocket`, `carryAliasesTx` (the platform-socket writers) |
+
+ `migrateClaimOwnership` (`claimrows.go:40`) only adds columns and is
+ not a writer of rows. Callers outside the package
+ (`internal/provision/reconcile.go`, `sidecar_reconcile.go`,
+ `internal/domains/reconcile.go`, `internal/hostbox/reconcile_adapter.go`,
+ `internal/host/rootinventory.go`, the root package's `cli.go`, and
+ `remote_dispatch.go`) change no code: they receive `ErrForwardRow` or a
+ no-row result and log it, as they do any refused write today. The
+ registry's remote mode (`internal/registry/remote_dispatch.go`) carries
+ the three new calls in place of `SetFleetBox`.
So `carlos route`, `carlos add` and `carlos remove` on a forward host fail
in the registry; the CLI names the record and says to change that
@@ -724,6 +752,7 @@ under `fleets/`, `B` = binding objects.
| instance pass, trash markers (hub) | in-scope apps: marker, then manifest | + `A` marker GETs per pass in the trash-only prefetch, no manifest, seed or policy read (R2-4): `A x P` |
| trash removal confirmation, production flag | on a removal only | same, for forward retirements |
| canary status, `countExpiredCanaries` (every 5-minute status tick) | 1 pointer GET per canary (account, app, channel) on the box | unchanged: forward rows skipped (R2-4); a canary forward row would have cost 288 GETs a day |
+| alias pass, instance catch-alls (R3-2; every alias pass: the 5-minute loop, `agent.go:3891`, and each change-index pass, `changeindex.go:333`) | per catch-all claim whose app has a provisioned row on the box | + per instance catch-all claim of a forward app: one `List` of the app's instance records per pass (`deriveInstanceAliases` -> `labelHosts` -> `InstanceLabelCountsJudged`, `internal/domains/aliases.go:179`, `:722`; `claims.go:322`), and, for each host in a label group of two or more, one lifetime observation per pass (`claims.go:406`; `LifetimeJudge.Observe`: the record and its incarnation slot, at least 2 GETs, more on a retried round). So `K x Pa` LISTs and about `2 x D x Pa` GETs, `K` the forward apps' catch-all claims, `D` their hosts in duplicate-label groups, `Pa` alias passes a day (at least 262). Zero for an app with no instance catch-all, which is every fleet app today |
| domains pass (housekeeper, apps domain set) | per its own selectors | unchanged: trash loop skips forward rows (R2-5), sources never pick one (R1-11); DNS and TLS stamps read no bucket |
| 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 |
@@ -744,12 +773,17 @@ existing pass gated as it is today.
The test: the production pass set (instance pass, telemetry, plans,
retention, build states, bindings, edges file, the status tick's
-`countExpiredCanaries`, and the domains pass) run over identical records
-and registry twice, once without and once with a fleet-placed app on a
-`canary/*` channel and its forward row, with a counting store keyed by
-object prefix; the difference must equal the table's `A = 1, C = 1` row by
-row, with zero manifest, policy, seed and channel-pointer reads for the
-forward app.
+`countExpiredCanaries`, the domains pass, and production alias
+reconciliation, `aliasPassReporting` with the box's judge in the context)
+run over identical records and registry twice, once without and once
+with a fleet-placed app on a `canary/*` channel and its forward row, with
+a counting store keyed by object prefix; the difference must equal the
+table's `A = 1, C = 1` row by row, with zero manifest, policy, seed and
+channel-pointer reads for the forward app. Two more cases **(R3-2)**: the
+forward app with an instance catch-all claim attached (the difference
+gains exactly one instance-prefix `List` per alias pass, `K = 1`), and
+the same with two of its instances sharing a label (it gains the two
+hosts' lifetime observations per pass, `D = 2`).
## 7. Census **(R1-13, R1-4, R2-7)**
@@ -766,9 +800,10 @@ envelope whether or not a unit changed.
Input sources are unchanged: the agent-writable `registry.db` (its
console-written `fleets` and `fleet_boxes` tables included) and the bucket
through the existing passes. What is added is read sites, listed here.
-This is the list the card should show for rev 3; the builder runs
-`make census-card` after each task and reconciles any difference here
-before `make census-propose`.
+This is the list the card should show for rev 4. The builder runs
+`make census-card` after every task, reconciles each unit it shows
+against this list, and records any difference in this section (with the
+reason) before `make census-propose`.
Envelopes re-pinned (seven): the root package `.`, `internal/registry`,
`internal/provision`, `internal/host`, `internal/edge`, `internal/release`,
@@ -785,6 +820,24 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
the §4.2 setter list whose bodies select a `Route` field. A setter whose
body has no read site changes only the envelope. `KindForward` (a
constant) is envelope-only.
+- The writer guard's other files **(R3-3)**, each declaration below
+ changed: `internal/registry/registry.go` also `upsertRoute`, `Delete`,
+ `InstallLifetimeIf`, `SetHold`, `SetHoldIf`, `SetHoldIfSeq`, `HandHold`,
+ `ReleaseHold`, `ReleaseHoldSeq`, `DeleteIfHold`,
+ `DeleteIfHoldWithTimers`, `ClearNextDueIf` and the §4.2 setters;
+ `internal/registry/routecas.go` `DeleteIfUnchanged`;
+ `internal/registry/claimhold.go` `SetClaimHold`;
+ `internal/registry/claimrows.go` `AdoptClaimRoute` (an existing unit,
+ `claimrows.go:59`), `RetireClaimRows`;
+ `internal/registry/coldhandover.go` `RestoreClaimRows`;
+ `internal/registry/recoveryhandover.go` `RebindClaimRows`;
+ `internal/registry/importjournal.go` `SwapForImport` (an existing unit,
+ `importjournal.go:291`), `insertRouteTx`, `CloseImportGate`,
+ `CommitImport`, `RestoreImportRoute`;
+ `internal/registry/aliassocket.go` `RepointPlatformSocket`,
+ `carryAliasesTx`. Those with read sites appear on the card as `body` or
+ `sites`; the rest move only the `internal/registry` envelope. Callers in
+ other packages are unchanged (§4.2).
- `internal/registry/remote_dispatch.go`: `Registry.dispatchRemote` (the
three new cases, `SetFleetBox` gone).
- `internal/provision/reconcile.go`: `Reconcile` (forward phase, trash-only
@@ -858,7 +911,14 @@ Unit (`internal/registry`, `internal/provision`, `internal/edge`,
Every other exported `routes` writer, run against a forward row,
changes nothing (an `UPDATE` matches no row; `Upsert` and
`UpsertUnlessRootfs` return `ErrForwardRow`); `SetDNSStatus` and
- `SetCertExpiresAt` stamp it. `DeleteForward` leaves a hand row alone.
+ `SetCertExpiresAt` stamp it. Every transactional writer of §4.2's
+ inventory (`SwapForImport`, `CommitImport`, `RestoreImportRoute`,
+ `CloseImportGate`, `AdoptClaimRoute`, `RetireClaimRows`,
+ `RestoreClaimRows`, `RebindClaimRows`, `RepointPlatformSocket`,
+ `InstallLifetimeIf`, the hold helpers) given a forward host returns
+ `ErrForwardRow` and leaves every table it touches, journals and
+ archives included, as it was (R3-1). `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