plans: Plan 4 refresh round 2 from Astra's plan review (#511)
R1-R8: one attempt per build across coordinators with a durable retry; the swap permit apart from the release phase; LastGood across repeated failures; copies door checks published pointers; the replica floor at every activation step; large sizes floor-gated at copies=1; the worker fed by ReplicaObserved; per-generation admission tickets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/2026-11-01-stateless-replicas-4-deploy-and-drill.md+41 −0
CI passed — run details
Intent
<task-notification> <task-id>b6fmhdx3h</task-id> <tool-use-id>toolu_015YUL2tMi1seeRtbLcwa8T5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/b6fmhdx3h.output</output-file> <status>completed</status> <summary>Background command "Run Astra review of the Plan 4 refresh" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 12.4 g CO₂e (1,395,965 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 cd599e2a7..3c22450e8 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 |
| @@ -77,6 +77,47 @@ Plan 4 was written against main of 2026-11-01. It is refreshed here against main |
| - 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. |
| +### Refresh round 2: Astra plan review, round 1 (R1-R8; these amend D1-D12) |
| + |
| +- **R1 (D1), one attempt per instance and build, across coordinators.** |
| + - `ReplicaDeployID` runs only after the box holds the coordinator term. Today it runs before acquisition (`internal/activator/stateless.go:405`, `statelessrelease.go:63`); that call moves. |
| + - It reconciles against the record before using its local book. If the record holds an attempt for the same incarnation and target that is not terminal, the box adopts that ID and overwrites its local selection. A local selection never wins over a durable attempt (today the local entry wins: `internal/rollout/failures.go:1341`). |
| + - An explicit retry becomes durable, console-side: the retry action writes `RetryOf: <failed ID>` on the record. The coordinator consumes it exactly once by writing a new pending attempt that carries `RetryOf`. A successor that sees `RetryOf` already consumed mints nothing. |
| + - Tests: two boxes with populated books; a coordinator change mid-attempt; a lost reply to the retry. |
| +- **R2 (D2), the permit lives apart from the release phase.** |
| + - `ReplicaDeploy` gains a `Swap` sub-object: `Order`, `Completed`, `ActiveBox` and a permit revision. A permit stays unresolved from grant until a matching ACK, or until a halt that has proof the old generation stopped. A terminal release phase does not resolve it. |
| + - `ReplicaSwapActive` is redefined as "an unresolved permit exists", which now covers the halted case. `HaltRecordReplicaDeploy` keeps the permit unresolved. |
| + - Both writers (`/release` through `SetRecordReplicaRelease`, and `/deploy`) refuse a new ID while an unresolved permit exists. |
| + - `done` is terminal and allows a new attempt: `replicadeploy.go:51` gains `done`. |
| + - Tests: halt, then a new request, then the old box returns; two completed deploys in a row. |
| +- **R3 (D4), last good survives repeated failures.** |
| + - The record keeps `LastGood`, the target of the last attempt whose release passed. It is written at the released transition and carried forward on every begin. Failed and unknown never clear it. |
| + - The adapters at `internal/console/replicacoordinator.go:188` and `internal/host/replicacoordinator.go:54` copy `LastGood` on a new ID. Today they drop `Previous` on a new ID. |
| + - A returning assigned box takes the attempt's target only when that release passed and the box is in `Completed`, or the deploy is `done`. Otherwise it takes `LastGood`. It never reruns a release, and never guesses from its own local state. |
| + - A halted swap after a passed release is a different state from an unknown release result: the release phase stays released and the swap is halted. |
| + - Tests: success, then failure, then failure, with stale local good state; a rollout halted partway. |
| +- **R4 (D9), the copies door checks published pointers.** Under the floor mutex, the copies door checks the published system pointers, as the fleet-create barrier does (`internal/console/fleetfloor.go:139,179`), not only the console build and box heartbeats (`appcopies.go:243`). An unreadable pointer refuses. Tests: both serialized orders, with the heartbeats unchanged. |
| +- **R5 (D10), the predicate runs at every activation step.** |
| + - `replicaFloorAllows` is checked early in `activationRule`, before any drain. |
| + - It is checked again at the commit step in `activationGuard` (`internal/host/systemapply.go:1231`), under its exclusion, and in forward recovery (`:2333`), whether or not a moves floor is armed. |
| + - The evidence it reads is this box's records with copies or retiring assignments. That evidence is read inside the same exclusion. |
| + - Tests: evidence changes after the early check; journal recovery. |
| +- **R6 (D7, D9, D10), large sizes are floor-gated at copies=1 too.** |
| + - A fleet tier, or the relaxed budget, needs StatelessReplicasFloor on every possible destination whatever the copy count. The n==1 branch at `internal/console/replicaplacement.go:147` adds that floor when the size is a fleet tier. |
| + - The publication judge also refuses a below-floor target while any record, or any app's default size, uses a fleet tier. |
| + - Size-policy admission takes the same floor mutex. |
| + - The root backstop also refuses a candidate that does not know a size used on this box, because `SizedLimit` would silently fall back (`internal/activator/size.go:21`). |
| + - Tests: a single 12g copy; a default size set before any instance exists; scale-down from two copies. |
| +- **R7 (D2), how committed transitions reach the worker.** |
| + - `Note(rec)` is fed by fanning out `ReconcileConfig.ReplicaObserved` (`internal/host/agent.go:3994`), keeping the placement worker's own observation, and by the existing fast tick (`:3234`). |
| + - `WithReplicaReleaseObservation` is per attempt only. |
| + - Test, through production wiring: a permit arrives while no launch attempt is running. |
| +- **R8 (D5), admission tickets across an overlap.** |
| + - A ticket is tagged with the generation it selected at backend selection. |
| + - Retiring the old generation waits only for tickets that selected the old one. Successor traffic is never awaited, and there is no HA `BeginMove` barrier for replicas. |
| + - The retirement stop still goes through `swap.go:834`. The ACK follows the stop proof. |
| + - Test: one request is paused between admission and selection while successor requests keep arriving; retirement stays bounded, and the ACK comes only after the stop proof. |
| + |
| - **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. |