plans: refresh stateless replicas Plan 4 against main (#511)
Binding rulings D1-D12 from a drift check against 5c9fc1c2: deploy IDs stay box-minted, Task 1 extends the release record, returning boxes take the record's target, region HA start gates apply, Task 4 builds on 225c41d0, smoke follow-ups ride the branch, the floor judge and root backstop placement, and 8a3d302's HA guards and drill window.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/2026-11-01-stateless-replicas-4-deploy-and-drill.md+70 −0
CI failed — run details
Intent
<paseo-system version="1" kind="agent-message" source-agent-id="09cca118-043b-44a3-94aa-a983228e744d" message-id="98c84b51-9e2b-4c71-98cb-9754691fdbe5"> From the Tito session, on Paul's instruction: please start Plan 4 for #511 (stateless replicas) now rather than waiting. Work through your listed order, starting with (1) refreshing Plan 4 against current main. Post progress on #511 as you go. Bring Paul's two decisions to him (the SR copy-deck review, and the go to merge and cut v0.35.0 after the drill) when you reach them. </paseo-system>
<task-notification> <task-id>ad176cf7d01495cce</task-id> <tool-use-id>toolu_017UdvAx2egXczMca9KA6kkg</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/ad176cf7d01495cce.output</output-file> <status>completed</status> <summary>Agent "Plan 4 drift check vs main" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>The plan still fits main on files: every file it says to modify exists at the same path, and every missing file is one it says to create. The drift is in the interfaces and in code that main has added since 2026-11-04. I only read source; I ran no build or test. The full report is at `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/stateless-replicas-4/.superpowers/sdd/2026-11-01-stateless-replicas-4-deploy-and-drill/drift-report.md`. **Biggest drift per task** - **Task 1:** - Deploy IDs are minted on the box (`FailureBook.ReplicaDeployID`, `internal/rollout/failures.go:1331`), not by a console `beginReplicaDeploy` as the plan assumes. - F8 added a `SoleFleetBox` proof to `SetRecordReplicaRelease` (`internal/provision/replicadeploy.go:14`); the planned `SetRecordReplicaDeploy` signature drops it and the expected revision. - A `/release` endpoint already exists (`internal/console/routedecls.go:422`). `ReplicaSwapActive` and `HaltRecordReplicaDeploy` already exist (`internal/provision/replicaassignment.go:268-295`). - The test pattern `TestReplica(Release.*|Deploy.*|OnlyOne.*)$` already matches about 20 passing Plan 1 tests, so "expect FAIL" can't be seen. - **Task 2:** - F10 already holds a failed or unknown release at copies=1, but its wake fallback uses this box's own good build (`internal/activator/rootfsrelease.go:1014`, `internal/activator/stateless.go:389`). With copies>1, a returning box must use the record's `ReplicaDeploy` target instead. - Two new start gates: W6 `TenantStartsClosed` (`internal/activator/group_admission.go:15`) and the §25 start fence. A permitted swap must pass them; a refused start means no ACK and the deploy halts. - **Task 3:** `carlos console` lives in `interactive_cli.go:613`, which is missing from Files. The console has no client yet for the snapshot socket `/run/carlos/.replicas/health.sock`, which is 0700 and owned by the agent's user. `doorRefusal` now has keyed fields. The edge page cache is per copy. - **Task 4:** 225c41d0 already sizes a fleet-placed app against only that fleet's active boxes (`internal/console/policysize.go:96-186`). `sizeRefusal` (`:322`, quarter rule at `:339`) has the shape `fleetSizeRefusal` needs. Placement already calls it (`internal/console/replicaplacement.go:151`). There is no "spare" box status. - **Task 5:** - The other floor judges now take `cur *release.SystemPointer` and an `allow` flag, and re-judge under `fleetFloorMu`. The copies door holds no floor mutex, so it can race a below-floor publication. - W6 runs `refusalsBeforeDrain` (`internal/host/systemapply.go:351`) before draining a fixed box out of the load balancer, so a root backstop placed after it would refuse only after the drain. - `docs/region-ha-runbook.md:68` uses v0.35.0, the reserved replicas floor, as its `ha_floor` example. **Plan edits, most important first** 1. Decide who mints deploy IDs: keep them on the box or retire `FailureBook.ReplicaDeployID`. 2. Keep the F8 proof and the expected revision in `SetRecordReplicaDeploy`, and say whether `/deploy` replaces or extends `/release`. 3. Put the `replicaFloorAllows` backstop inside `activationRule` (`internal/host/systemapply.go:1336`), modelled on `errExecSandboxFloor`. 4. Change to `replicaFloorJudge(ctx, channel, cur, target)`: call it from both branches of `systemFloorSnapshot`, re-judge under the floor mutex, and make the copies door take that mutex. 5. For an assigned set, the returning-box target comes from `ReplicaDeploy`; F10's local recovery applies only without an assignment. 6. Route `ReplicaSwap` and the cold join through `tenantStartRefusal`, and add a test where the gate is closed during a permit. 7. Build Task 4 on 225c41d0: return `fleetOnly` from `sizeBoxes` and swap the predicate at `replicaplacement.go:151`. 8. Add the missing files: `internal/console/hostactivation.go`, `apisystemupdate.go`, `fleetfloor.go`, `interactive_cli.go`, `internal/activator/stateless.go`, `statelessrelease.go`, `internal/host/replicacoordinator.go`. 9. Narrow the red test patterns. Drill scope: hard-stop a fleet box only. 10. Ask the HA owner to fix the runbook's v0.35.0 example. **Region HA reading and tests** - **§25 (held requests):** `docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md`, lines 1049-1340; §25.15 is binding where it differs. Main constraints: - Every request goes through one front-door `MoveState` check. - At most two forward attempts. - Replay only from a whole copy of 64 KiB or less. - Platform headers are stripped. - The retained start fence refuses every start. - Copies are refused for HA records, so replica hosts never move. - **§7.5 (DR-5):** same file, lines 341-384. No lease takeover without proof and expiry, and nothing makes a box serve a pool it doesn't serve. The replica coordinator must stay a record field, never an `ha` `lock.json`. The drill must not stop HA boxes. - **Grouproll:** `go test ./internal/grouproll ./internal/grouprollaws -count=1`. - Key tests: `TestSeededSimulation`, `TestSimulationMutations`, `TestRequiredMutations`, `TestDepartMutations`, `TestParityLedgerComplete`. - `TestEndToEndMinio` runs only with `CARLOS_MINIO_TEST=1` and a running MinIO. - Also: root `system_group_test.go` (`TestCLI*`), provision `TestRegionGroup*`, and `scripts/grouproll-golden/python_tests.py`. - **Region HA boundary:** `go test . -run 'TestRegionHA' -count=1` (root `region_ha_boundary_test.go`). Tests: `TestRegionHACoreImportsNoAWS`, `TestRegionHAAdaptersAreNamedForAWS`, `TestRegionHAS3ClientsUseS3Compat`, `TestRegionHAS3CheckerCatchesABareClient`. The S3 check scans activator, console, edge and host, so any new S3 client there must use `s3compat`. I created no scratch files; the only new file is the report.</result> <usage><subagent_tokens>242433</subagent_tokens><tool_uses>102</tool_uses><duration_ms>873433</duration_ms></usage> </task-notification>
Attributed to this commit: 19.3 g CO₂e (2,193,996 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on stateless-replicas-4, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/plans/2026-11-01-stateless-replicas-4-deploy-and-drill.md b/docs/superpowers/plans/2026-11-01-stateless-replicas-4-deploy-and-drill.md| index ca8ee5133..cd599e2a7 100644 |
| --- a/docs/superpowers/plans/2026-11-01-stateless-replicas-4-deploy-and-drill.md |
| +++ b/docs/superpowers/plans/2026-11-01-stateless-replicas-4-deploy-and-drill.md |
| @@ -10,6 +10,76 @@ |
| **Spec:** `docs/superpowers/specs/2026-11-01-stateless-replicas-design.md` (rev 2, approved 2026-11-01). |
| +## Refresh 2026-11-11 (binding; overrides the task text below where they differ) |
| + |
| +Plan 4 was written against main of 2026-11-01. It is refreshed here against main 5c9fc1c2. Region HA has moved since then: hadrain, harelease, hacache, §25 held requests, DR-5, the group roll verb and W6 ingress drain. So has 225c41d0 (#875). The full drift check is in the controller's `.superpowers/sdd/2026-11-01-stateless-replicas-4-deploy-and-drill/drift-report.md`. The rulings, numbered D1-D12: |
| + |
| +- **D1, deploy IDs stay box-minted.** The coordinator box selects the ID with `FailureBook.ReplicaDeployID` (`internal/rollout/failures.go:1331`), as Plan 1 built it. There is no console `beginReplicaDeploy` allocator, so there is only one ID authority. A retry stays the existing explicit deploy or instances-retry action, which clears the book's selection. |
| +- **D2, Task 1 extends the existing release record and does not add a second one.** |
| + - The new transitions are order, permit, ACK, done and halt. They go through a typed `provision.SetRecordReplicaDeploy(ctx, s, id, expectedRevision uint64, change replicas.DeployChange, now time.Time, proof ...SoleFleetBox)`. |
| + - That function keeps F8's `SoleFleetBox` re-check and the expected revision, matching `SetRecordReplicaRelease` (`internal/provision/replicadeploy.go:14`). |
| + - `ReplicaSwapActive` and `HaltRecordReplicaDeploy` (`internal/provision/replicaassignment.go:268-295`) stay the source of truth for an active step. |
| + - `POST .../release` (`internal/console/routedecls.go:422`) stays unchanged, for v0.34.x boxes at copies=1. A sibling `POST .../deploy` carries the swap transitions; only boxes at StatelessReplicasFloor call it. |
| + - Files added: `internal/console/replicacoordinator.go`, `internal/console/routedecls.go`, `internal/host/replicacoordinator.go`, `internal/activator/statelessrelease.go` and `internal/provision/replicaassignment.go`. |
| + - The worker's `Note(rec)` is fed from `RecordFactsOf`/`WithReplicaReleaseObservation` and the existing `CoordinationClient` tick. There is no new poller. |
| +- **D3, Task 1 shrinks.** Plan 1 already built these, so they are not rebuilt: |
| + - the one-copy phases (pending, releasing, released, failed, unknown) and their replay and retake rules; |
| + - closing a dead term's releasing phase as unknown (`statelessrelease.go:91-99`); |
| + - commandless releases; |
| + - a retry getting a new ID. |
| + |
| + The task is the multi-box part: order, a single outstanding permit, ACK authentication by ActiveBox, and one path for promotion, rollback and first deploy. |
| +- **D4, Task 2: a returning box's target.** For a record with `ReplicaAssignment`, a returning box takes its target from the record's `ReplicaDeploy`: the last released or done target. F10's local `committedGood` recovery (`internal/activator/rootfsrelease.go:1014`, `internal/activator/stateless.go:389`) applies only to records with no assignment. `TestReplicaReturnsAfterDeploy` covers both. |
| +- **D5, Task 2: the HA start gates still apply.** |
| + - `ReplicaSwap` and the cold join go through `tenantStartRefusal`: W6 `TenantStartsClosed` (`internal/activator/group_admission.go:15`) and the §25 start fence. A refused start sends no ACK and grants no next permit, and a test case covers it. |
| + - The old generation's stop respects outstanding admission tickets (`handover.go:167`). |
| + - In the path list, "held" means hold-swap, not §25 held requests, and F10 recovery is added to that list. |
| + - Files added: `internal/activator/stateless.go`, `statelessrelease.go` and `group_admission.go`. |
| +- **D6, Task 3.** |
| + - It also fixes F2: `carlos restart` refuses fleet instances. |
| + - `carlos console` lives in `interactive_cli.go:613`, which is added to Files. |
| + - The console reads Plan 3's snapshot socket `/run/carlos/.replicas/health.sock` (0700, agent uid). An explicit step decides that access: a group-readable mode, or a console-uid check per Plan 3's Q7. |
| + - `doorRefusal` literals are keyed, and every 503 carries `Retry-After`. |
| + - The docs say the edge page cache and purges are per copy. |
| + - The `docs/site/cli.md` edits must pass `go test ./internal/docsite`. |
| +- **D7, Task 4 builds on 225c41d0.** |
| + - `sizeBoxes` already narrows to the placed fleets (`internal/console/policysize.go:96-186`). It now also reports `fleetOnly`, and only then is `fleetSizeRefusal` (the budget `max(0, total - max(1 GiB, total/8))`) chosen over the quarter rule. |
| + - The same predicate replaces `sizeRefusal` at `internal/console/replicaplacement.go:151`. |
| + - "Spare boxes" means every active roster row of the placed fleet, assigned or not (`policysize.go:154-166`). |
| + - Fleet tiers are refused for gVisor-family units (`internal/instancectl/gen.go:86`). |
| + - The create door has no size check today, so adding one there is new work in its create handler. |
| + - Index anchor `policysize.go:262` becomes `:339`. |
| + - First-user check: a t4g.xlarge fleet box (about 15.6 GiB reported) has a budget of about 13.6 GiB, so the 12g tier fits. |
| +- **D8, follow-ups ride this branch.** They are the 11-04 smoke findings that matter for a first real user: |
| + - F11: about 4 s of 503s and a false "deploy stopped" log on the stateful-to-stateless switch; |
| + - F1b: no reason is shown for a stuck rollout; |
| + - F4: a region line appears on fleet creates; |
| + - F7: a premature "wake failed" line. |
| + |
| + Each is a small commit with a witness. They land after Task 3 and before Task 5. |
| +- **D9, Task 5 publication judge.** |
| + - The judge is `replicaFloorJudge(ctx, channel string, cur *release.SystemPointer, target string) error`. It is called from both branches of `systemFloorSnapshot` (`internal/console/rootfsfloor.go:63-82`) and re-judged under the floor mutex, as `fleetFloorPublish` is. There is no override flag. |
| + - The copies door (`internal/console/appcopies.go:84`) takes the same mutex. The lock order is fleet, then replica, then regional. |
| + - Count admission already refuses copies above 1 below the floor (`appcopies.go:31-46,251-252`). The new work is the publication side and the root backstop. |
| + - Files added: `internal/console/hostactivation.go`, `apisystemupdate.go`, `fleetfloor.go` and `regionalfloor.go`. |
| + - The group roll verb joins the publication audit, with its exclusion reason written down. |
| +- **D10, Task 5 root backstop.** `replicaFloorAllows` sits inside `activationRule` (`internal/host/systemapply.go:1336`), modelled on `errExecSandboxFloor`. W6's `refusalsBeforeDrain` (`:351`) therefore refuses before any load-balancer drain. |
| +- **D11, region HA guards (8a3d302, 2026-11-11).** |
| + - Read region HA spec §25 and §7.5 first (`docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md`, lines 1049-1340 and 341-384). §25.15 is binding where it differs. |
| + - The replica coordinator stays a record field and never becomes an HA `lock.json`. |
| + - Copies stay refused for HA records. |
| + - Any new S3 client in activator, console, edge or host uses `s3compat`. |
| + - Every task touching activator, edge or placement runs these locally, targeted, and CI runs them on the tip: |
| + - `go test ./internal/grouproll ./internal/grouprollaws -count=1` |
| + - `go test . -run 'TestRegionHA' -count=1` |
| +- **D12, the drill.** |
| + - It is a live window booked with 8a3d302 on #421, one window at a time. |
| + - It hard-stops only a drill fleet box: the pre-approved 2x t4g.small fleet (P21), never an HA group member or a fixed HA box. |
| + - The candidate build may use v0.35.0 only as an untagged dev candidate. The public v0.35.0 is cut by 8a3d302 after v0.34.46 and follows the normal dev-first roll. |
| + - 8a3d302 also fixes `docs/region-ha-runbook.md:68`, whose `ha_floor` example reads v0.35.0. |
| +- **Test patterns.** Each task's red run names only its new tests, because `TestReplica(Release.*|Deploy.*|OnlyOne.*)$` already matches about 20 passing Plan 1 tests. |
| +- **Execution.** Opus implements; Astra reviews every task, and Fable is added for root, termination and the whole branch (Paul, 2026-11-08). Review rounds are capped at three. |
| + |
| ## Global Constraints |
| - Copy: use the series copy deck, ids `SR-<plan>-C<nn>`, pending until Paul's copy review; apply edits verbatim before building strings. No em dashes; neutral shop/example.com names. |