carlos / platform Public

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>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 7ed79d3e614390fd97fe592da7657fd5af435cec parent 5c9fc1c
1 file changed, +70 −0
  • docs/superpowers/plans/2026-11-01-stateless-replicas-4-deploy-and-drill.md +70 −0
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.