carlos / platform Public

plan: #1139 plan round 2 fixes (stopping rule 2: one place + guard tests)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev b4bb604765ac85858f09621e3e426de3e759e18d parent a8856cf
2 files changed, +43 −3
  • docs/superpowers/plans/2026-11-20-fleet-seeded-create.md +8 −3
  • docs/superpowers/plans/CODEX-FINDINGS-fleet-seeded-create-plan-R2.md +35 −0
diff --git a/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md b/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md
index 0f95086c7..74cf972c4 100644
--- a/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md
+++ b/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md
@@ -18,6 +18,8 @@
Plan round 1 (`CODEX-FINDINGS-fleet-seeded-create-plan-R1.md`): NOT READY, 3 P1 and 2 P2, all fixed in this revision. R1-1 app purge bypassed the hold (Task 16 "Every other retirement entrance"); R1-2 `finishSeed` under the record lock deadlocked with lifetimes on (Task 15); R1-3 region file uploads hit the import's one-box rule (Task 5); R1-4 the fleet sweep skipped trashed apps (Task 16); R1-5 delete answers for every aborted reason (Task 16).
+Plan round 2 (`CODEX-FINDINGS-fleet-seeded-create-plan-R2.md`): NOT READY, 2 P1, each in a family round 1 also hit, so stopping rule 2 applied. Paul chose (2026-11-20) "state the invariant, enforce it in one place, guard test" for both. R2-1: the rollback proves both local locations empty under the fence (Task 10 step 7.4, D5, `TestFleetFileSeedRollbackLayoutChangedHolds`). R2-2: `seedStorageRefusal` is the one storage prerequisite, shared by begin and upload (Task 16, `TestSeedStoragePrereqBeginMatchesUpload`).
+
Earlier: no plan review before round 1. The design's round history carries into every brief written from this plan (stopping rule 1). Three design rounds: R1 (6 findings), R2 (abandonment family, cut (a)), R3 (R3-1 exhaustive listing, R3-2 staging, R3-3 sweep). The plan review starts at round 1 and has the usual three-round budget.
## Global Constraints
@@ -393,11 +395,13 @@ The rules, each a numbered test below:
1. `cfg.ownsRecord(rec)` holds, `rollbackArmed(h)` holds, and `h.Fleet != nil`. Otherwise log and return.
2. `NextFenceGen`, then `FenceForRollback(host, gen)`, with `defer LiftFence`. If it does not proceed, return.
3. Under the fence, the host still has no row (`reg.Get`). If a row appeared, return.
- 4. Purge at the path this box would mint: `NestedDBPath` when `layoutNested()` answers true, `DefaultDBPath` when it answers false, and return when it errors (Decision D5). Unlike the region rule, the purge does not depend on the marker (design step 2). It goes through `h.RemoveLocal` (`PurgeSeedLocal`, which also removes the instance's own temps).
+ 4. Purge **both** supported local locations, `NestedDBPath` and `DefaultDBPath`, whatever the layout reader says now (Decision D5, plan R2-1). The layout intent can change between retirement and rollback, and layout migration only moves rows that still exist (`internal/layout/pass.go:323`), so the current layout is not evidence of where the seed's data is. Each goes through `h.RemoveLocal` (`PurgeSeedLocal`, which also removes that location's own temps). Then, still under the fence, stat both locations: the database, `-wal`, `-shm`, the marker and any `.seed-<base>-` temp. Any error, or anything still there, means not proven: log and return. Unlike the region rule, the purge does not depend on the marker (design step 2). This is the single local half of the proof; nothing else on the box decides local cleanup for a fleet file seed.
5. Still under the fence, `ListPrefix(HibernatePrefix(ReplicaPrefix, host)+"/")` and `ListPrefix(activator.MovesPrefix(host))`. Any error: log and return. Any key in either: report `failed` with `copy-in-storage` (Decision D6), log, and return.
- 6. Both empty and step 4 done: `Report(rolledback)`. An error is logged, and the next pass tries again.
+ 6. Both locations proven empty in step 4 and both prefixes empty in step 5: `Report(rolledback)`. An error is logged, and the next pass tries again.
8. **Row retirement.** The dispatch at `reconcile.go:1963` already covers `KindFile` from Task 4. On a fleet box the row goes first, then a later pass with no row rolls back, the same order as `--from`.
+- **Guard test for the local proof (plan R2-1):** `TestFleetFileSeedRollbackLayoutChangedHolds`, deterministic and table-driven: seed data left in the flat location with the layout reader now answering nested, and the reverse; a purge that fails in either location; a stat that errors. In every row no `rolledback` is reported while either location holds seed data, and it is reported once both are empty. It lives with Task 11's rollback tests.
+
- [ ] **Step 1: Failing tests** (activator, with the existing seed fixtures; a fake `SeedObjects`, a fake `Mirror`, `hasOwnReplica` and `OnSeedFailed`):
- `TestFleetFileSeedPlacesThroughStoreDoorAndReportsPlaced`: `Open` is called with the account and app, and `OnSeedPlaced` is called once.
- `TestFleetFileSeedCheckFailureReportsFailed`: a corrupt snapshot reports `not-a-database` once and fails the wake. No database is at the path, and the manifest's seed command never runs.
@@ -606,6 +610,7 @@ Under `withRecordLock`, `fleetSeedRecord` runs again, and then:
func (s *Server) seedFleetReady(ctx context.Context, fleet string) *doorRefusal
```
- **Begin.** A fleet-placed record (`registry.FleetPlacement(c.placed)`) skips the region and data-bucket checks and calls `seedFleetReady`. The rest is as Task 5. A pool is still FS-20.
+- **Storage prerequisites in one place (plan R2-2).** Add `seedStorageRefusal(kind, placement) *doorRefusal`, the single answer to "can this console store this seed's snapshot": an import or a region `file` seed needs `SeedData != nil && HibernateBucket != ""` (today's `seedNoDataRefusal`); a fleet `file` seed needs `s.cfg.Releases` and nothing regional. Begin and upload both call it, and nothing else checks storage: the unconditional check at `apiinstanceimport.go:410` is replaced by the call, so imports keep their exact refusal. Guard test `TestSeedStoragePrereqBeginMatchesUpload`, table-driven over (import, region file, fleet file) × (with and without `SeedData`/`HibernateBucket`, with and without `Releases`): begin and upload agree in every row, and a fleet file seed goes begin through PUT to `ready` with `SeedData=nil` and `HibernateBucket=""`. The existing import refusal tests still pass.
- **Upload.** For a fleet record, the put goes to `s.cfg.Releases` at `seeds.FleetSnapshotKey`, create-only (`release.PutObjectFrom` with `""`, as `putSnapshot` does). The upload's readiness re-check calls `seedFleetReady`.
- **Sweep.** `StartSeedsPass` no longer returns when `SeedData` is nil. Only the region half needs it. A second listing, for each fleet-placed app **including trashed apps** (plan R1-4: `fleetPlacedApps` passes `includeTrash=false`, `fleetsecretskey.go:361` → `store.go:2077`, so add an `includeTrash` variant; the region half already covers trashed apps, `seedsweep.go:285`), over every account with a fleet, runs `ListMod(seeds.FleetSnapshotsPrefix(sqid, app))` on `s.cfg.Releases`. It must be a `release.ModLister`, or the fleet half deletes nothing and logs. `ParseFleetSnapshotKey` and the same `snapshotDecision` decide, so an aborted fleet file seed's snapshot is deleted while its record stays aborted (R3-3). Step 6 (finish `rolled-back`) is unchanged. It only ever meets a fleet file seed that the door moved to `rolled-back`, which is after proof. The sweep never moves a fleet file seed to `rolled-back`.
- **Finish.** `finishSeedOnce`: a fleet-placed record deletes its snapshot from `s.cfg.Releases` at the fleet key and does not need `SeedData`. The replica delete (`:124`) is skipped for a fleet record. `deleteSeedReplica` already refuses one (`:270`), and that is now explicit.
@@ -735,7 +740,7 @@ Order (AGENTS.md "rollout order"; design §6): boxes, then the floor, then the c
- **D2. The begin rides the `import` object with `kind: "file"`.** It is the import door's begin, literally. Create bodies are decoded leniently (`authcli.go:656`), so a new top-level field sent to an old console would be dropped, and an empty ordinary instance created. An old console instead refuses the `import` body before writing anything: on a fleet with `seedPlacementRefusal`, on a region with `importShapeRefusal`'s `replaces` sentence. That sentence is confusing, but nothing is written.
- **D3. The heartbeat carries seven fields, not three** (Task 11). The fleet check is the region check's rule (`seedfloor.go:79-89`), which reads the floor's `min_release` match, carlos.prev's verdict, and the root and moves floor states.
- **D4. The box sends a reason code, not text.** The console maps each code to an approved sentence, so a box never writes text that a member reads.
-- **D5. The fleet rollback purges at the path the box would mint** (nested or flat, by its layout reader). The design says "the row's own database path", but the rollback runs only on a pass with no row (Gap G4).
+- **D5. The fleet rollback purges and proves both local locations** (nested and flat), never just the one the layout reader names today (plan R2-1). The design says "the row's own database path", but the rollback runs only on a pass with no row (Gap G4).
- **D6. `SeedFail` also sets `Reason` on an already-aborted file seed** (code `copy-in-storage`, FS-30). This is how `instances list` can show design §3.6's sentence (Gap G5).
- **D7. A staging listing error on admission fails the wake and reports nothing.** It is retried. Objects under staging report `failed`. Both readings are fail-closed (Gap G6).
- **D8. A fleet file seed needs a fleet with exactly one active box.** This is the design's one-box rule, given that the seed door runs before labelling (Gap G1).
diff --git a/docs/superpowers/plans/CODEX-FINDINGS-fleet-seeded-create-plan-R2.md b/docs/superpowers/plans/CODEX-FINDINGS-fleet-seeded-create-plan-R2.md
new file mode 100644
index 000000000..622b91f12
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-FINDINGS-fleet-seeded-create-plan-R2.md
@@ -0,0 +1,35 @@
+Round-1 dispositions:
+
+- **R1-1, P1 — resolved:** Task 16 now requires fail-closed guards at every record-retirement and app-purge entrance.
+- **R1-2, P1 — resolved:** Task 15 releases the record lock before `finishSeed`, with a lifetimes-enabled handler test.
+- **R1-3, P1 — resolved:** Task 5 explicitly dispatches upload readiness by seed kind and tests a two-box region.
+- **R1-4, P2 — resolved:** Task 16 includes trashed fleet apps in snapshot sweeping.
+- **R1-5, P2 — resolved:** Task 16 refuses deletion of every aborted fleet file seed, regardless of reason.
+
+Reviewed the requested plan revision. Checkout HEAD differs from the requested commit only by the round-2 brief. No files changed or tests run.
+
+1. **P1 — Task 10 / D5 / G4: the current mint layout cannot prove cleanup of the retired row’s database.**
+
+ **Evidence:** [Plan:396](/Users/paulcampbell/github.com/carlosframework/platform-fleet-seeded-create/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md:396) chooses exactly one purge path from the current layout reader, after retirement has discarded the row. That reader consults the latest layout intent, not the retired row’s location ([layoutleg.go:840](/Users/paulcampbell/github.com/carlosframework/platform-fleet-seeded-create/internal/host/layoutleg.go:840)). Layout migration enumerates existing registry rows ([pass.go:323](/Users/paulcampbell/github.com/carlosframework/platform-fleet-seeded-create/internal/layout/pass.go:323)); it cannot migrate a row already removed. Purging an absent directory succeeds ([seedplace.go:343](/Users/paulcampbell/github.com/carlosframework/platform-fleet-seeded-create/internal/activator/seedplace.go:343)).
+
+ **Failure scenario:** A fleet seed leaves local data in the flat layout and is aborted before replication. Its row is retired. Before the next rollback pass, the layout intent changes to nested. Rollback successfully “purges” the absent nested directory, finds both remote prefixes empty, and reports `rolledback`. The hostname is released while the flat database remains. The reverse layout change has the same problem.
+
+ **Concrete fix:** Keep the proof in `rollbackFleetFileSeed`, but make it cover both supported local locations under the fence, refusing completion on any unresolved data or cleanup error. Alternatively, durably preserve the actual cleanup location before retiring the row and account for layout migration. Add a deterministic test changing layout between retirement and rollback, asserting that no report occurs while either location retains seed data.
+
+ **Fault family:** Abandonment — hostname release requires proof that no local or remotely restorable seed data remains.
+
+2. **P1 — Task 16: fleet upload still encounters the region-data-bucket prerequisite.**
+
+ **Evidence:** [Plan:608](/Users/paulcampbell/github.com/carlosframework/platform-fleet-seeded-create/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md:608) explicitly skips region/data-bucket checks at **begin**. Its upload instructions change readiness and the destination store, but do not change the unconditional prerequisite in [apiinstanceimport.go:410](/Users/paulcampbell/github.com/carlosframework/platform-fleet-seeded-create/internal/console/apiinstanceimport.go:410): PUT refuses when `SeedData == nil` **or** `HibernateBucket == ""`, before reaching readiness dispatch.
+
+ **Failure scenario:** A console with deployment storage and a ready customer fleet, but no regional hibernation storage, accepts begin and reserves the hostname. Every upload then refuses despite the fleet snapshot belonging in the deployment bucket. Task 16 explicitly supports operation without `SeedData` for sweep and finish, but the create-through-upload flow remains broken.
+
+ **Concrete fix:** Explicitly scope this prerequisite to imports and region file seeds. Fleet file uploads must validate their deployment-store requirements instead. Add begin-through-PUT coverage with `SeedData=nil` and `HibernateBucket=""`, alongside regression coverage preserving the existing region/import refusal.
+
+ **Fault family:** Admission consistency — a placement accepted at begin must remain uploadable under the same storage prerequisites.
+
+No additional P2 or P3 findings.
+
+Both fault families also appeared in round 1. Under stopping rule 2, these should not enter another incremental fix cycle without the prescribed decision. I recommend enforcing each invariant in one place, with the deterministic guard tests above; this does not require reopening the closed design.
+
+**NOT READY**
\ No newline at end of file