| index 8783442ad..2a9af0627 100644 |
| --- a/docs/superpowers/plans/2026-10-30-fleet-public-routes.md |
| +++ b/docs/superpowers/plans/2026-10-30-fleet-public-routes.md |
| @@ -8,7 +8,7 @@ |
| |
| **Tech Stack:** Go; registry SQLite (`internal/registry`); the edge and its tunnel hub (`internal/edge`); the agent passes (`internal/host`, `internal/provision`, `internal/domains`); the console (`internal/console`); signed system pointers (`internal/release`). |
| |
| -**Status:** rev 2, for Astra plan review round 2 of 3. Round 1 (`docs/superpowers/reviews/CODEX-FINDINGS-fleet-public-routes-plan-R1.md`, NOT READY, 3 P1 and 6 P2) and its dispositions are below. |
| +**Status:** rev 3, for Astra plan review round 3 of 3 (the last). Round 1 (`CODEX-FINDINGS-fleet-public-routes-plan-R1.md`, NOT READY, 3 P1 and 6 P2) and round 2 (`-R2.md`, NOT READY, 3 P1 and 2 P2) and their dispositions are below, with a migration and fixture sweep over every task. |
| |
| **Spec:** `docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md`, rev 4, APPROVED by Paul 2026-10-30 (recorded on amadan #457). Read §4.2 (the shape and the writer rule), §4.3 (the forward phase), §4.4 (the predicate) and §9 (the floor) before any task. Every section number below is the spec's. |
| |
| @@ -57,6 +57,26 @@ Every finding taken, with the controller's rulings (platform-39). |
| | P2-8 spec witnesses | Table-driven over the forbidden class for sanitisation (Task 2), serving (Task 4), publication (Task 6) and egress (Task 7); a live forward source mints no platform name (Task 7); multipart through the real fleet gate (Task 4) | Tasks 2, 4, 6, 7 | |
| | P2-9 rollout deliverables | Task 14 adds a read-only inventory of fleet-placed non-forward rows on dev and the flagship; Task 15 adds the release-notes paragraph through the release's Luna pass; any removal is per row with Paul's approval | Tasks 14, 15 | |
| |
| +## Review dispositions (Astra plan R2) |
| + |
| +| finding | disposition | where | |
| +|---|---|---| |
| +| P1-1 `TestReconcileFleetBindingsSkipsCorruptJSON` | Its fixture gains fleet `pi` and active box `amber-gliding`; every positive binding fixture is now named with the membership it needs | Task 1 Step 1 | |
| +| P1-2 floor callers | Task 8 migrates every caller of `systemFloorGate`, `systemFloorSnapshot` and `rollbackHostUpdate` (listed by file:line), each passing `false` for the new override with its assertions kept | Task 8 Step 1 | |
| +| P1-3 TLS refusal in the witness | Task 13 serves the hub from an unstarted `httptest` server whose `tls.Config.GetCertificate` refuses an SNI name `hub.Allowed` rejects (production's admission path, `issuerHostPolicy` -> `deploymentHost`, `certsync.go:197`, `edge.go:1363`, is unexported inside `edge.Run`'s TLS chain, `edge.go:3859-3938`; with one hub and no other box's edges file, `deploymentHost` and `Allowed` give the same answer); refusal assertions use fresh connections; the mutation is shown against it | Task 13 | |
| +| P2-4 `carryAliasesTx` | Reached through `SetInstancePaths` (`registry.go:2189`) and through `Upsert` (`registry.go:1486`); the positive arm asserts the alias's socket changed | Task 3 Step 1 | |
| +| P2-5 nondeterministic mutation | Inside the publication callback, a synchronous `s.fleetFloorMu.TryLock()` must fail; the channel-coordinated outcomes stay | Task 9 Step 1 | |
| + |
| +### Sweep for the same family (rev 3) |
| + |
| +Every function whose signature or contract a task changes, with every caller (tests included) and every fixture the change touches; every refusal test checked for a fixture that can produce the refusal. Found and fixed in rev 3, beyond the five findings: |
| + |
| +- Task 4: the tenancy predicate applies to existing fleet-placed rows. The existing edge tests' rows carry no account (`fleet_route_test.go:96-257`, `fleet_e2e_test.go:335`, `fleetapi_e2e_test.go:398`, `edgeerrors_test.go:399`), so they take the accountless path and keep passing; `TestSidecarRouteIsNeverServable` (`edge_test.go:2283`, account `bdm` on fleet `eleven` of `amadan`) is refused on kind first and keeps passing. Named in Task 4 so the implementer does not "fix" them. |
| +- Task 6: the hub flag reaches the edges-file writer by reading `hubArmed(os.Getenv)` inside the write, not as a parameter: `edgesFileWriteClaims` has 90 call sites, none changed. |
| +- Task 8: the activation identity (`hostactivation.go:124`) and the signed pointer gain the override with `omitempty`, so every existing activation id and pointer is byte-identical when the override is false. |
| +- Task 11: dropping `SetPlacement` breaks three existing tests that pin the old stamping: `TestPlaceStampsRoutesAndInstances` (`fleets_test.go:406`), the `assertPlacement` helper (`fleets_test.go:1219`, 12 callers) and `TestAccountFleetActiveFlipsWithPlacement` (`accountfleet_test.go:177`). Task 11 migrates them. |
| +- Refusal fixtures: Task 1's forged-binding test gains a positive control (a correctly keyed binding from `away`'s own box applies); Task 5 sets `CARLOS_RATE_LIMIT=enforce` before `edge.New` (the mode is read once, `edge.go:475`); Task 7's retention test gains a positive control (a non-forward `blog` row with the same retention record is pruned); Task 9's barrier tests seed a fresh heartbeat following `stable` (`seedHeartbeat`-shaped `status.Box` with `Metrics.SystemChannel`, as `hostactivation_test.go:94`), without which `regionalChannelRefusal`'s channel set is empty and nothing would be refused; Task 10's production arm uses `release.SetProduction` before the trash marker, as `reconcile_test.go:1659` does. |
| + |
| ## Plan rulings (choices the spec leaves open, with cost if wrong) |
| |
| - P-1. The floor's version: `v0.32.0`, the next minor after v0.31.0 (live on dev). Task 13's release step re-pins it if the cut is numbered otherwise. Cost if wrong: one constant and its pinning test. |
| @@ -137,11 +157,11 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| - Test seam, package-private and nil in production: `var bindingsAfterChecks func(host string)` in `fleetbind.go`, called between the pre-checks and `SetFleetBoxIf`. |
| - Retired contracts, each with the test that pinned it: clearing by `SetFleetBox(host, "")` (`TestSetFleetBoxRoundTrips`'s second half, `TestUpsertPreservesFleetBox`'s last block): no production caller ever cleared; a forward row's `FleetBox` is cleared by `PutForward` on a `Region` change (Task 2), and a hand row's is never cleared by a pass, as today. The unknown-host error (`TestSetFleetBoxUnknownHostErrors`): `SetFleetBoxIf` answers `false, nil`, because a binding whose row is gone simply no longer applies (spec §4.5). |
| |
| -- [ ] **Step 1: Migrate the existing tests**, so the package compiles once `SetFleetBox` is gone: `TestSetFleetBoxRoundTrips` becomes `TestSetFleetBoxIfRoundTrips` (fleet `home` with active `box-1`, row placed `fleet/home`; stamp; no clear); `TestSetFleetBoxUnknownHostErrors` becomes `TestSetFleetBoxIfUnknownHostIsNoChange` (`false, nil`); `TestUpsertPreservesFleetBox` stamps with `SetFleetBoxIf` and drops its clearing block; `TestFingerprintChangesOnFleetBoxRestamp` registers `box-a` and `box-b` active on fleet `pi` and restamps with `SetFleetBoxIf`; `fleetbind_test.go`'s positive cases (`TestReconcileFleetBindingsStampsMatchingRoute`, `...AppliesMatchingFleetPlacement`, `...Idempotent`) add `UpsertFleet` and an active `AddFleetBox` for the binding's label. `internal/edge`'s door e2e (`fleetapi_e2e_test.go:131`) and `fleet_e2e_test.go` already register their boxes active. |
| +- [ ] **Step 1: Migrate the existing tests**, so the package compiles once `SetFleetBox` is gone: `TestSetFleetBoxRoundTrips` becomes `TestSetFleetBoxIfRoundTrips` (fleet `home` with active `box-1`, row placed `fleet/home`; stamp; no clear); `TestSetFleetBoxUnknownHostErrors` becomes `TestSetFleetBoxIfUnknownHostIsNoChange` (`false, nil`); `TestUpsertPreservesFleetBox` stamps with `SetFleetBoxIf` and drops its clearing block; `TestFingerprintChangesOnFleetBoxRestamp` registers `box-a` and `box-b` active on fleet `pi` and restamps with `SetFleetBoxIf`; `fleetbind_test.go`'s positive cases add `UpsertFleet` and an active `AddFleetBox` for the binding's label: `TestReconcileFleetBindingsStampsMatchingRoute` (`:251`, fleet `pi`, box `amber-gliding`), `...AppliesMatchingFleetPlacement` (`:340`, `pi`, `pi-box`), `...SkipsCorruptJSON` (`:369`, `pi`, `amber-gliding`, for its valid sibling `good.example.com`), `...Idempotent` (`:411`, `pi`, `amber-gliding`). The negative cases (`:281`, `:308`, `:677`) need no membership. `internal/edge`'s door e2e (`fleetapi_e2e_test.go:131`) and `fleet_e2e_test.go` already register their boxes active. |
| - [ ] **Step 2: Write failing tests.** |
| - `internal/registry`: `TestSetFleetBoxIfBindsPlacementKindAndMembership`: fleets `home` (`box-1` active, `box-2` detached) and `away` (`box-1` active), a row `shop.example.com` placed `fleet/home`: `(host, "home", "box-1")` true and the row reads `box-1`; `(host, "away", "box-1")`, `(host, "home", "box-2")`, `(host, "home", "box-9")` false; a sidecar row placed `fleet/home` false; unknown host `false, nil`. `TestSetFleetBoxIfOverRemote`: the first two cases through the remote fixture. |
| - `internal/host`: `TestHubArmed`: (`"tunnel.example.com"`, `""`) true; (`"tunnel.example.com"`, `"home"`) false; (`""`, `""`) false; (`" "`, `""`) false. |
| - - `internal/host/fleetbind_door_test.go`, on a door fixture built as `newFSKWorld` builds one (`edge.New`, `EnableStatic`, `EnableTunnels`, a box store from `fleetapi.New(srvURL, "<fleet>/box-1", token)`): `TestForgedBindingsChangeNothing` (account `bab` owns `home`, `k3x` owns `away`; `away`'s `box-1` PUTs through its door `fleets/away/bindings/<home's host>.json` naming fleet `home` and box `box-1`, and `fleets/away/bindings/<away's host>.json` naming box `box-7`; after `ReconcileFleetBindings` both rows' `FleetBox` is empty). `TestStaleBindingCannotStampTheNewPlacement`: `bab` owns `home` and `away`, both with an active `box-1`; `home`'s `box-1` PUTs a correct binding through the door; `bindingsAfterChecks` moves the row to `fleet/away` with `SetPlacement` and sets `FleetBox` empty by raw SQL; after the pass the row's `FleetBox` is empty. |
| + - `internal/host/fleetbind_door_test.go`, on a door fixture built as `newFSKWorld` builds one (`edge.New`, `EnableStatic`, `EnableTunnels`, a box store from `fleetapi.New(srvURL, "<fleet>/box-1", token)`): `TestForgedBindingsChangeNothing` (account `bab` owns `home`, `k3x` owns `away`; `away`'s `box-1` PUTs through its door `fleets/away/bindings/<home's host>.json` naming fleet `home` and box `box-1`, and `fleets/away/bindings/<away's host>.json` naming box `box-7`; after `ReconcileFleetBindings` both rows' `FleetBox` is empty; positive control in the same test: `away`'s `box-1` writes a correctly keyed binding for `away`'s host naming `box-1`, and that row's `FleetBox` becomes `box-1`). `TestStaleBindingCannotStampTheNewPlacement`: `bab` owns `home` and `away`, both with an active `box-1`; `home`'s `box-1` PUTs a correct binding through the door; `bindingsAfterChecks` moves the row to `fleet/away` with `SetPlacement` and sets `FleetBox` empty by raw SQL; after the pass the row's `FleetBox` is empty. |
| - Mutations to show: compare the body's fleet instead of the key (the forged test fails); the old hostname-only `UPDATE` (the stale test fails). |
| - [ ] **Step 3: Run** `TMPDIR=/tmp/g nice -n 19 go test ./internal/registry/ ./internal/host/ -run 'TestSetFleetBoxIf|TestHubArmed|TestForgedBindings|TestStaleBinding|TestReconcileFleetBindings|TestUpsertPreservesFleetBox|TestFingerprintChangesOnFleetBox' -count=1`. Expected: FAIL on the new tests only (undefined `SetFleetBoxIf`, `hubArmed`). |
| - [ ] **Step 4: Implement** as the Interfaces block says. |
| @@ -194,7 +214,7 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| - Test helper (package `registry`, test file): `func dumpDB(t *testing.T, r *Registry) map[string][]string`: every table named in `sqlite_master`, each row rendered as its column values joined, sorted. |
| |
| - [ ] **Step 1: Write failing tests.** |
| - - `TestEveryRouteWriterRefusesAForwardRow`: one table, one entry per writer of the inventory, each entry carrying its own fixture builder (the state its writer needs to act at all: a held route for the hold helpers, a journaled import for `CommitImport`/`CloseImportGate`/`RestoreImportRoute`, claim rows and a cold handover for `RestoreClaimRows`/`RebindClaimRows`/`RetireClaimRows`, an alias for `carryAliasesTx` through `RepointPlatformSocket`, a lifetime pair for `InstallLifetimeIf`) and its call with arguments that would change a non-forward row. Per entry: run it once against a non-forward row and assert the row changed (so the fixture is live); then against the same fixture with the host a forward row: `dumpDB` before equals `dumpDB` after, and the writer returned `ErrForwardRow` or no change. `RetireClaimRows` gets an `archive` spy that fails the test if called. Separately, `SetDNSStatus` and `SetCertExpiresAt` stamp a forward row. |
| + - `TestEveryRouteWriterRefusesAForwardRow`: one table, one entry per writer of the inventory, each entry carrying its own fixture builder (the state its writer needs to act at all: a held route for the hold helpers, a journaled import for `CommitImport`/`CloseImportGate`/`RestoreImportRoute`, claim rows and a cold handover for `RestoreClaimRows`/`RebindClaimRows`/`RetireClaimRows`, an alias pointing at the route's socket for `carryAliasesTx`, reached through `SetInstancePaths` (`registry.go:2189`) and through `Upsert` (`registry.go:1486`), whose positive arm asserts the alias's socket changed to the new one (`RepointPlatformSocket` has its own UPDATE, `aliassocket.go:129`, and its own entry), a lifetime pair for `InstallLifetimeIf`) and its call with arguments that would change a non-forward row. Per entry: run it once against a non-forward row and assert the row changed (so the fixture is live); then against the same fixture with the host a forward row: `dumpDB` before equals `dumpDB` after, and the writer returned `ErrForwardRow` or no change. `RetireClaimRows` gets an `archive` spy that fails the test if called. Separately, `SetDNSStatus` and `SetCertExpiresAt` stamp a forward row. |
| - `TestRestoreWritersRefuseForwardInputsAtAbsentHosts`: `RestoreClaimRows`, `RebindClaimRows`, `RestoreImportRoute` (and `insertRouteTx` through its caller) given an input row of kind forward for a host with no row: `ErrForwardRow`; `dumpDB` unchanged; no row at the host. |
| - `TestRouteWriterInventoryIsComplete` (`forward_inventory_test.go`): load `internal/registry` (non-test files) with `go/parser` and `go/types` (`importer.ForCompiler(fset, "source", nil)`); visit every call whose method is `Exec`, `ExecContext`, `Query`, `QueryContext`, `QueryRow`, `QueryRowContext`, `Prepare` or `PrepareContext`; take the SQL argument's `types.Info.Types[expr].Value` (a constant, so `"UPDATE " + "routes SET x = ?"` resolves); a resolved string matching `(?i)\b(insert(\s+or\s+\w+)?\s+into|replace\s+into|update|delete\s+from)\s+routes\b` names its enclosing function, which must be a writer of the first test's table or one of the five exceptions. An argument with no constant value must be a key of `unresolvedRouteSQL map[string]string` (`"<file>:<func>"` to its classification, e.g. `"claimrows.go:RetireClaimRows": "DELETE FROM routes|timers, guarded by the forward check before archive"`); an unclassified one fails, as does a stale key. |
| - `TestForwardHostRefusedByTheCLI` (root package, `carlosTestEnv`, scratch `cmd.Dir`): `carlos add`, `carlos route -host <h> -channel x`, `carlos remove <h>` against a registry holding a forward row print FPR-C01 and exit 1; the row is unchanged. |
| @@ -220,6 +240,8 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| - `localAssetCatch` returns false for `up.route.IsForward()`. |
| - Test fixture (package `edge`, `fleetforward_test.go`), reused by Task 5: `func forwardHubAndBox(t *testing.T, hubRows, boxRows []registry.Route, boxHandler http.Handler) (hubURL string, hub, box *Edge)`: a hub `Edge` on its own registry with fleet `home` of `bab` and box `box-1` (`UpsertFleet`, `AddFleetBox`), forward rows seeded with `PutForward` (not `Upsert`, which refuses them after Task 3), tunnels enabled as `fleetTestEdge` does (`fleet_route_test.go:39`); a box `Edge` on a second registry holding `boxRows`, dialed in as `home/box-1` by `startFakeRemoteHost` (`tunnel_e2e_test.go:190`, the real `tunnelclient` loop) serving the box `Edge` itself, or `boxHandler` when non-nil. `fleetTestEdge`'s `acme`/`amadan` names are not reused. And `func corruptRow(t *testing.T, regPath, host, column string, value any)`: opens the registry file with `database/sql` (driver `"sqlite"`, as the registry does), `UPDATE routes SET <column> = ? WHERE host = ?`, asserts one row affected, then reads the row back through `registry.Open(...).Get` to prove the value persisted. |
| |
| +- Existing tests the predicate touches, unchanged: the fleet-placed rows in `fleet_route_test.go:96-257`, `fleet_e2e_test.go:335`, `fleetapi_e2e_test.go:398` and `edgeerrors_test.go:399` carry no account and take the accountless path; `TestSidecarRouteIsNeverServable` (`edge_test.go:2283`) is refused on kind before the predicate. Do not add accounts to them. |
| + |
| - [ ] **Step 1: Write failing tests** (`fleetforward_test.go`, on `forwardHubAndBox`): |
| - `TestFleetServeEligible`: table. Forward rows: hub off -> false; owner match -> true; owner mismatch, unknown fleet, empty raw account, one stray forbidden field -> false. Hand rows (`Kind` instance, placed `fleet/home`): empty raw account -> true; `Account "k3x"` with owner `bab` -> false; `Account "!!"` (invalid, `RouteAccount` gives `OpsAccount`) -> false. |
| - `TestReloadServesOnlyEligibleForwardRows`: owners `home`->`bab`; forward rows `a.example.com` (`bab`) and `b.example.com` (`k3x`) via `PutForward`; `c.example.com` (`bab`) via `PutForward`, then `corruptRow(..., "tunnel", "t1")`; then `Reload`: `Allowed(a)` true, `Allowed(b)` and `Allowed(c)` false; a request to `c` never reaches a static tunnel client `t1` registered in the test (it records nothing). |
| @@ -246,7 +268,7 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| **Interfaces:** |
| - Produces: `rateAdmit`, `planThrottleOf`, `trackUpgrade` and `planThrottleFor` take `up.route.Kind != "instance" && !up.route.IsForward()` (resp. `rt`) as their refusal. The `fromTunnel` exemptions stay. |
| |
| -- [ ] **Step 1: Write failing tests** (on Task 4's `forwardHubAndBox`, the box a real `Edge` whose own row carries the same `RateLimit`, so a second enforcement would show): |
| +- [ ] **Step 1: Write failing tests** (on Task 4's `forwardHubAndBox`, with `t.Setenv("CARLOS_RATE_LIMIT", "enforce")` before either `edge.New`, since the mode is read once at construction, `edge.go:475`; the box a real `Edge` whose own row carries the same `RateLimit`, so a second enforcement would show): |
| - `TestForwardRateLimitAtTheHubOnly`: forward row with `RateLimit` of 2 requests per window for the test client, `RateEnforce`; three GETs: the third is 429 from the hub (the box never sees it); the box's own limiter, configured the same, never refuses a tunneled request. |
| - `TestForwardUpgradeIsLimitedAtTheHub`: the same with WebSocket upgrades: the third handshake 429. |
| - `TestForwardPlanThrottleAndUpgradeClose`: `SetPlanThrottleFor` returns an awake throttle for `bab`: an upgrade is refused 429; with plans governing `bab`, an open upgrade is closed by `CloseAccountUpgrades("bab")`. |
| @@ -260,12 +282,12 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| ### Task 6: The edges file publishes what the edge serves |
| |
| **Files:** |
| -- Modify: `internal/host/edgesfile.go:543-598` (`edgesFileWriteClaims`), its loop's arming (`edgesfile.go:1030`) for the hub flag |
| +- Modify: `internal/host/edgesfile.go:543-598` (`edgesFileWriteClaims`) |
| - Test: `internal/host/edgesfile_forward_test.go`, `internal/edge/issuer_forward_test.go`, `internal/edge/testdata/edges-forward-hub.json` |
| |
| **Interfaces:** |
| - Consumes: Task 4's `edge.FleetServeEligible`; Task 1's `hubArmed`. |
| -- Produces: the writer reads `reg.ListFleets()` once per write into `owners`, takes `hub` from `hubArmed(os.Getenv)` at loop arm, and leaves out every row with `!edge.FleetServeEligible(...)` that would take the fleet arm, every forward row when `!hub`, every alias, instance catch-all and wildcard entry whose primary is left out, and any `assets` block for a forward row. |
| +- Produces: the writer reads `reg.ListFleets()` once per write into `owners` and `hubArmed(os.Getenv)` inside the write (no parameter: `edgesFileWriteClaims` has 90 call sites, none changes; tests set the variables with `t.Setenv`), and leaves out every row with `!edge.FleetServeEligible(...)` that would take the fleet arm, every forward row when `!hub`, every alias, instance catch-all and wildcard entry whose primary is left out, and any `assets` block for a forward row. |
| |
| - [ ] **Step 1: Write failing tests.** |
| - `TestEdgesFilePublishesOnlyEligibleForwardRows`: hub on; owners `home`->`bab`; forward rows for `bab` (eligible) and `k3x` (refused), each with an alias and an instance catch-all; the written file names the eligible row, its alias and catch-all with `account`/`app`, and nothing of the refused row's; no `assets` key on the eligible entry. |
| @@ -294,7 +316,7 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| - [ ] **Step 1: Write failing tests.** |
| - `TestEgressNestedWithAnInertForwardRow`: one nested managed local instance and an inert forward row: `boxWhollyNested` true. A row of kind `"frobnicate"`: false (today's refusal kept). Mutation: skip every forward row regardless of shape; the next test fails. |
| - `TestEgressRefusesEachNonInertForwardRow`: for each `registry.ForwardForbidden` entry, the same box with the forward row's column corrupted by raw SQL (persisted, read back): `boxWhollyNested` false, the reason naming the host. |
| - - `TestRetentionIgnoresForwardRows`: a forward row of app `shop` with a retention record of keep 1 and three versions in the store: `retentionPass` deletes nothing for `shop` (counting store: zero `GetRetention` reads for `shop`). |
| + - `TestRetentionIgnoresForwardRows`: a forward row of app `shop` with a retention record of keep 1 and three versions in the store: `retentionPass` deletes nothing for `shop` (counting store: zero `GetRetention` reads for `shop`); positive control in the same pass: an instance row of app `blog` with the same record and versions has its two oldest pruned. |
| - `TestExpiredCanariesIgnoreForwardRows`: a forward row on `canary/x`: the count is 0 and the store sees no channel read. |
| - `TestDomainsTrashLoopKeepsForwardRows` (`internal/domains`): trashed `shop` with a forward row and trashed `blog` with an instance row: after `Reconcile`, `blog`'s row gone, `shop`'s forward row present. |
| - `TestDomainsMintsNoPlatformNameFromALiveForwardRow` (`internal/domains`): apps domain `example.com`, account `bab` materialized, a live (not trashed) forward row for `shop` and its canary channel pointer present: after `Reconcile`, no `Platform` row for `shop` exists and the registry's route count is unchanged (spec §4.11, `firstReadyUpstream` at `internal/domains/reconcile.go:823`). |
| @@ -325,15 +347,16 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| - `promoteHostUpdate`, `rollbackHostUpdate` (both arms) and the activation identity (`hostactivation.go:124`, `:252`) carry `AllowBelowFleetForwardFloor`; the update and rollback request bodies gain `allow_below_fleet_forward_floor`; `errFleetFloorPromotion` joins the two existing `errors.Is` sites (`apisystemupdate.go:428`, `:956`) with the same status. |
| - `system.go`: the flag on `runSystemUpdate` and `runSystemRollback`, sent as `allow_below_fleet_forward_floor`. |
| |
| -- [ ] **Step 1: Write failing tests.** |
| +- [ ] **Step 1: Migrate the callers** of the three console functions whose signatures gain `allowFleet bool` (as the last parameter), each passing `false` and keeping its assertions: `systemFloorGate` at `regionalfloor_test.go:86,92`, `rootfsfloor_test.go:54,60`; `systemFloorSnapshot` at `rootfsfloor.go:53`, `hostactivation.go:208`; `rollbackHostUpdate` at `apisystemupdate.go:953` (production: passes `in.AllowBelowFleetForwardFloor`), `apiplacements_put_test.go:884`, `hostactivation_test.go:162,173,177`, `plan9_b_test.go:200,238`, `regionalfloor_test.go:73,76,125,168,235,260,285,295,336,379,413,491`, `rootfsfloor_test.go:46,96,192,216`; and `apisystemupdate.go:428` (production: passes the request's field). `promoteHostUpdate`, `release.PromoteSystem`, `RollbackSystem` and both `Prepare*` keep their signatures (the override rides `SystemPromoteOptions`), so their other callers (`internal/host`, `internal/hostactors`, `internal/release` tests) are unchanged. The activation identity (`hostactivation.go:124`) and `SystemPointer` take the field with `omitempty`, so existing ids and pointers are byte-identical when it is false. |
| +- [ ] **Step 2: Write failing tests.** |
| - `internal/release`: `TestFleetForwardFloorIsPinned` (`v0.32.0`); `TestFleetForwardFloorAllows` (installed `v0.31.0` -> anything true; installed `v0.32.0` -> `v0.31.9` false, `v0.32.1` true, `"junk"` false); `TestPrepareCarriesTheFleetFloorOverride` (both `Prepare*` sign it; a pointer without the field still verifies). |
| - `internal/console` (through the HTTP fixture and `promoteHostUpdate`/`rollbackHostUpdate` directly where the other floors' tests do): `TestFleetFloorRefusesACrossingWhileAFleetExists` (pointer `v0.32.0`, fleet `home`, target `v0.31.0`: 409 with C02; no fleet: allowed; override: allowed and C04 logged); `TestFleetFloorJudgesAFirstPublication` (no pointer, fleet `home`, target `v0.31.0`: refused with C03 by `systemFloorGate` and, with the gate bypassed by a hook, by `fleetFloorPublish`; target `v0.32.0`: allowed); `TestFleetFloorRollback` (history below the floor: refused, held-activation retry with a different override refused); `TestFleetFloorListErrorRefuses`. |
| - Root package: `TestSystemUpdateSendsTheFleetFloorOverride` (the request body carries `allow_below_fleet_forward_floor: true` with the flag), and `TestFleetRoutesCopyBuiltIsApplied` covers C05's text against `FleetForwardFloorOverrideUsage` with `%s` replaced by `"v"+release.FleetForwardFloor.String()`. |
| -- [ ] **Step 2: Run** `nice -n 19 go test ./internal/release/ ./internal/console/ . -run 'FleetForwardFloor|TestPrepareCarriesTheFleetFloor|TestFleetFloor|TestSystemUpdateSendsTheFleetFloor|TestFleetRoutesCopy|RegionalFloor|RootfsFloor' -count=1`. Expected: FAIL on the new tests. |
| -- [ ] **Step 3: Implement.** |
| -- [ ] **Step 4: Run** Step 2. Expected: PASS, the rootfs and regional floor tests unchanged. |
| -- [ ] **Step 5: Census** (`SystemPointer`, `SystemPromoteOptions`, `PrepareSystemPromotion`, `PrepareSystemRollback`, the new release declarations, `runSystemUpdate`, `runSystemRollback`; the console files are outside the scope). |
| -- [ ] **Step 6: Commit.** |
| +- [ ] **Step 3: Run** `nice -n 19 go test ./internal/release/ ./internal/console/ . -run 'FleetForwardFloor|TestPrepareCarriesTheFleetFloor|TestFleetFloor|TestSystemUpdateSendsTheFleetFloor|TestFleetRoutesCopy|RegionalFloor|RootfsFloor|HostActivation|Rollback|Plan9B' -count=1`. Expected: FAIL on the new tests only (the migrated ones compile and pass). |
| +- [ ] **Step 4: Implement.** |
| +- [ ] **Step 5: Run** Step 3. Expected: PASS. |
| +- [ ] **Step 6: Census** (`SystemPointer`, `SystemPromoteOptions`, `PrepareSystemPromotion`, `PrepareSystemRollback`, the new release declarations, `runSystemUpdate`, `runSystemRollback`; the console files are outside the scope). |
| +- [ ] **Step 7: Commit.** |
| |
| ### Task 9: The fleet-create barrier and the three interleavings |
| |
| @@ -349,10 +372,11 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| - Test hooks `fleetFloorHooks struct{ beforeLock, locked, createBeforeLock func() }` on `Server`, as `regionalFloorHooks`: `beforeLock` and `locked` in `fleetFloorPublish`, `createBeforeLock` in the create doors just before they take `fleetFloorMu`. |
| |
| - [ ] **Step 1: Write failing tests.** |
| - - `TestFleetCreateRefusedWhileAChannelIsBelowTheFloor`: pointer `stable` at `v0.31.0` followed by a fresh box: `carlos fleets create` answers 409 with C06 and no fleet row exists; pointer at `v0.32.0`: created; no pointer: created; pointer unreadable: 503 C07. |
| + - Every barrier test seeds one fresh box heartbeat following `stable` (a `status.Box` with `Metrics.SystemChannel: "stable"`, as `hostactivation_test.go:94` writes one); with none, `regionalChannelRefusal`'s channel set is empty and the barrier checks nothing. |
| + - `TestFleetCreateRefusedWhileAChannelIsBelowTheFloor`: pointer `stable` at `v0.31.0` followed by the fresh box: `carlos fleets create` answers 409 with C06 and no fleet row exists; pointer at `v0.32.0`: created; no pointer: created; pointer unreadable: 503 C07. |
| - `TestFleetFloorInterleavings`: (a) no pointer; an update to `v0.31.0` passes `systemFloorGate` with no fleet; `beforeLock` creates fleet `home` through the door (passes: no pointer); the publication then judges under `fleetFloorMu`, refuses with C03, and `GetSystemPointer` still returns not-found. (b) no pointer, no fleet; the publication of `v0.31.0` holds `fleetFloorMu` (`locked` hook) while a fleet create starts in a goroutine; after it publishes, the create returns 409 C06 and no fleet row exists. |
| - - (c), the mutual exclusion through the write: no pointer, no fleet; the publication of `v0.31.0` judges (passes) and the `locked` hook, which runs after the judgment and before `publish`, starts a fleet create in a goroutine, waits until the create's own `beforeLock` hook reports it is about to take `fleetFloorMu`, then waits 200 ms and asserts the create has not returned and no fleet row exists; the hook returns, the pointer is published, and the create then returns 409 C06 with no fleet row. |
| - - Case (a) is the re-judgment witness and stays. The early-unlock mutation (release `fleetFloorMu` after the judgment, before `publish`) is shown against (c): the create returns 201 inside the hook's wait, and the test fails. |
| + - (c), the mutual exclusion through the write: no pointer, no fleet; the publication of `v0.31.0` judges (passes) and the `locked` hook, which runs after the judgment and before `publish`, starts a fleet create in a goroutine, waits until the create's own `beforeLock` hook reports it is about to take `fleetFloorMu`, then waits 200 ms and asserts the create has not returned and no fleet row exists; the hook returns, the pointer is published, and the create then returns 409 C06 with no fleet row. Inside the `publish` callback the test asserts synchronously that `s.fleetFloorMu.TryLock()` returns false (the publication still holds the mutex as it writes). |
| + - Case (a) is the re-judgment witness and stays. The early-unlock mutation (release `fleetFloorMu` after the judgment, before `publish`) is shown against (c): the `TryLock` assertion fails deterministically, whatever the scheduler does with the create goroutine. |
| - [ ] **Step 2: Run** `nice -n 19 go test ./internal/console/ -run 'TestFleetCreateRefused|TestFleetFloorInterleavings|TestFleetFloor|TestAPIFleet' -count=1`. Expected: FAIL on the new tests. |
| - [ ] **Step 3: Implement.** |
| - [ ] **Step 4: Run** Step 2. Expected: PASS. |
| @@ -374,7 +398,7 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| - [ ] **Step 1: Write failing tests** (fixtures as `reconcile_test.go`'s, a `DirStore`, a real registry, records written with `CreateRecord`): |
| - `TestForwardPhaseMintsForTheFleetOwnerOnly`: owners `home`->`bab`, `away`->`k3x`; records `shop` of `bab` on `fleet/home` (minted, shape = `forwardRowFor`), `shop2` of `bab` on `fleet/away` (none), `x` on `fleet/nowhere` (none), a `role: replica` record and a record with `Pool "p1"` on `fleet/home` (none, logged). |
| - `TestForwardPhaseIsInertWithoutOwners`: `FleetOwners` nil: no forward row minted; an existing one retired on a whole pass. |
| - - `TestForwardPhaseTrashDecisions`: trashed, production clear: retired; trashed, flagged production: kept; marker unreadable (a store failing that key): kept, nothing minted for a new record. |
| + - `TestForwardPhaseTrashDecisions`: trashed, production clear: retired; trashed, flagged production (`release.SetProduction` before the marker, as `reconcile_test.go:1659`): kept; marker unreadable (a store failing that key): kept, nothing minted for a new record. |
| - `TestForwardPhaseRetiresOnlyOnAWholePass`: a record gone with one other record unreadable: kept; on the next whole pass: retired; over a snapshot missing the record but the bucket holding it: kept. |
| - `TestForwardPhaseLeavesAHeldHostAndReportsIt`: a hand row and a provisioned instance row at fleet-placed hosts: both unchanged after two passes; the report logged once per pass per host. |
| - `TestForwardPhaseMovesBetweenFleetsAndBack`: `fleet/home` -> `fleet/away` (same account): row rewritten, `FleetBox` cleared; -> platform region in scope: forward row gone and an instance row minted in the same pass. |
| @@ -395,8 +419,9 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| **Interfaces:** |
| - Produces: `placeAppTarget` no longer calls `reg.SetPlacement`; the health loop treats a local forward row as not local; `func forwardHeldReason(rows map[string]registry.Route, rec provision.Record) string` returns C08 (with the fleet) when the record is fleet-placed and the local row at its host is not a forward row, else `""`; it fills `Reason` only when nothing else has. |
| |
| +- [ ] **Step 0: Migrate** the tests that pin the old stamping: `TestPlaceStampsRoutesAndInstances` (`fleets_test.go:406`) becomes `TestPlaceStampsInstancesNotRoutes` (records stamped, routes' `Region` unchanged, another app's route untouched); `assertPlacement` (`fleets_test.go:1219`, 12 callers) drops its route loop and keeps the store and record checks, its comment saying the passes converge rows from records; `TestAccountFleetActiveFlipsWithPlacement` (`accountfleet_test.go:177`) seeds its row `Provisioned` with a matching record and, after the place, runs one instance pass on the console's registry (`provision.Reconcile` with `FleetOwners` naming `acme` for the fixture's account) before its unchanged assertion. |
| - [ ] **Step 1: Write failing tests** (instance fixture, `shop` placed on `home`): `TestPlaceNoLongerStampsRows` (a local instance row of `shop` keeps its `Region` after `apps place --target fleet/home`, the record moves); `TestFleetInstanceHealthIgnoresTheForwardRow` (a forward row at the host: the instance's health is the fleet answer, not the local row's); `TestInstanceListNamesTheHeldHost` (a hand row at the host: `instances list` REASON is C08 naming `home`; a forward row: no such REASON). |
| -- [ ] **Step 2: Run** `nice -n 19 go test ./internal/console/ . -run 'TestPlaceNoLongerStamps|TestFleetInstanceHealthIgnores|TestInstanceListNamesTheHeldHost|TestFleetRoutesCopy|TestAPIPlace' -count=1`. Expected: FAIL on the new tests. |
| +- [ ] **Step 2: Run** `nice -n 19 go test ./internal/console/ . -run 'TestPlace|TestAppPlace|TestFleetPagePlace|TestAccountFleet|TestFleetInstanceHealthIgnores|TestInstanceListNamesTheHeldHost|TestFleetRoutesCopy|Rootfs' -count=1`. Expected: FAIL on the new tests only. |
| - [ ] **Step 3: Implement.** |
| - [ ] **Step 4: Run** Step 2. Expected: PASS. |
| - [ ] **Step 5: Commit** (console only). |
| @@ -431,7 +456,7 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| - Create: `fleet_public_routes_e2e_test.go` (root package) |
| |
| **Interfaces:** |
| -- Consumes, all exported and used in production, nothing exported for the test alone: `console.NewServer` over a temp registry and a `release.DirStore` (as `deploy_region_e2e_test.go` runs the console); the `carlos` CLI built by `buildCarlos` (`auth_e2e_test.go:34`) for every member action; the hub `Edge` from `edge.New`, armed with `EnableStatic` and `EnableTunnels(edge.NewTunnelHub(host, nil))` (the calls `enableTunnelsFromEnv` makes) on the console's registry file, served by `httptest.NewTLSServer`; the hub's pass as `provision.Reconcile(ctx, store, reg, host.BoxProvisionConfig(reg, hubEnv, nil, nil))` with `hubEnv` naming `CARLOS_TUNNEL_HOST`; the box: a second `Edge` on its own registry, its pass `provision.Reconcile(ctx, boxStore, boxReg, host.BoxProvisionConfig(boxReg, boxEnv, nil, nil))` with `CARLOS_FLEET=home`, `CARLOS_REGION=fleet/home` over a `fleetapi.New` store (the door), its release staged and stamped by `release.Pass(ctx, boxReg, boxStore, pub, optDir, nil)` (the root adopt pass) into a temp `optDir`, the staged binary (the tiny server the console tests ship) started by the test at the row's socket as its unit would start it, and the box dialed in with `tunnelclient.Loop` using the token `fleets add-box` printed. |
| +- Consumes, all exported and used in production, nothing exported for the test alone: `console.NewServer` over a temp registry and a `release.DirStore` (as `deploy_region_e2e_test.go` runs the console); the `carlos` CLI built by `buildCarlos` (`auth_e2e_test.go:34`) for every member action; the hub `Edge` from `edge.New`, armed with `EnableStatic` and `EnableTunnels(edge.NewTunnelHub(host, nil))` (the calls `enableTunnelsFromEnv` makes) on the console's registry file, served by `srv := httptest.NewUnstartedServer(hub)` with `srv.TLS = &tls.Config{GetCertificate: func(h *tls.ClientHelloInfo) (*tls.Certificate, error) { if !hub.Allowed(h.ServerName) { return nil, errNotAdmitted }; return nil, nil }}` then `srv.StartTLS()` (a `nil, nil` answer falls back to the test certificate `StartTLS` installs; production's admission path, `issuerHostPolicy` -> `deploymentHost`, is unexported inside `edge.Run`'s TLS chain, and with one hub and no other edges file it gives `Allowed`'s answer); clients send the host as SNI with `InsecureSkipVerify` (the assertion is admission, not the test CA), and every refusal assertion uses a fresh `http.Transport{DisableKeepAlives: true}`; the hub's pass as `provision.Reconcile(ctx, store, reg, host.BoxProvisionConfig(reg, hubEnv, nil, nil))` with `hubEnv` naming `CARLOS_TUNNEL_HOST`; the box: a second `Edge` on its own registry, its pass `provision.Reconcile(ctx, boxStore, boxReg, host.BoxProvisionConfig(boxReg, boxEnv, nil, nil))` with `CARLOS_FLEET=home`, `CARLOS_REGION=fleet/home` over a `fleetapi.New` store (the door), its release staged and stamped by `release.Pass(ctx, boxReg, boxStore, pub, optDir, nil)` (the root adopt pass) into a temp `optDir`, the staged binary (the tiny server the console tests ship) started by the test at the row's socket as its unit would start it, and the box dialed in with `tunnelclient.Loop` using the token `fleets add-box` printed. |
| - Why in-process: an unprivileged `carlos agent` cannot stage (the agent relays a blocked stage to root, `internal/host/stagerelay.go`) or run an instance unit, so a subprocess harness of the agents would have to fake root; the one export it costs, `BoxProvisionConfig`, is the production loops' own function (Task 12). |
| |
| - [ ] **Step 1: Write** `TestFleetAppServesThroughTheHub`, no hand rows, no fabricated records, every member step through the CLI: |
| @@ -440,9 +465,9 @@ Forward rows exist only once the hub's pass is given `FleetOwners` (Task 12). Un |
| 3. Requests over the limit: 429 from the hub. |
| 4. Attach a custom parent with an instance catch-all: `<slug>.<parent>` serves 200. |
| 5. `fleets detach-box`: 503 with `Retry-After`; `fleets add-box` again and redial with the new token: 200. |
| - 6. Trash `shop` (not production): after the hub's pass the forward row is gone and the hub's TLS handshake for the name fails. |
| + 6. Trash `shop` (not production): after the hub's pass and `Reload`, the forward row is gone, and a fresh connection's TLS handshake with SNI `shop.bab.example.com` fails. |
| 7. Account `k3x` writes a record placed on `fleet/home` directly to the store: after a pass, no row at its host and no entry in the hub's edges file. |
| -- [ ] **Step 2: Run** `TMPDIR=/tmp/g nice -n 19 go test . -run 'TestFleetAppServesThroughTheHub' -count=1 -v` (sandbox off). Expected: PASS. Show it can fail: give the hub `hubEnv` without `CARLOS_TUNNEL_HOST`; step 2 fails with a TLS refusal. |
| +- [ ] **Step 2: Run** `TMPDIR=/tmp/g nice -n 19 go test . -run 'TestFleetAppServesThroughTheHub' -count=1 -v` (sandbox off). Expected: PASS. Show it can fail, twice: give the hub `hubEnv` without `CARLOS_TUNNEL_HOST` (no forward row, `Allowed` false: step 2's handshake is refused); and make `GetCertificate` admit every name (step 6's handshake succeeds and the test fails). |
| - [ ] **Step 3: Census** (none expected: a test file; confirm the card is unchanged). |
| - [ ] **Step 4: Commit.** |
| |