| 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). |