activator, provision: fleet file seeds need a nested box (Task 10 R3)
Round 3 of the Task 10 review (Codex) found two more P1s in the cleanup-identity family: a failed purge forgets the original storage, and recursive removal stats a child and then opens it separately. With round 2's, all three need a writer with the data's uid during cleanup. A flat box has one by design: every app shares one data directory and one uid. Paul chose (2026-11-20) to refuse flat boxes for fleet file seeds instead of chasing each interleaving. Box. seedAction (seedMintRefusal) and seededRestore refuse a flat box for a fleet file seed exactly as for every other seed. Nothing is minted (the pass logs "this box does not mint nested") and a wake fails with the existing sentence "... this box does not run instances nested." Neither is reported to the door, so the seed stays ready; the console refuses such a fleet up front (Task 16, FS-26). Kept: the per-instance temp names, instancefs.PurgeProven, the both-locations proof and the round 1 and 2 tests, as defence in depth and for a box whose layout changed. TestFlatFleetTwoSeedsPlace- Concurrently is replaced by TestFlatFleetBoxRefusesFileSeed and a flat row in TestFleetFileSeedMintLayout. Threat model, on rollbackFleetFileSeed and in design §3.6: the cleanup proof assumes no other writer to the nested instance directory during cleanup. The instance is stopped under the fence, its directory is owned by its own uid, and root and the box agent are trusted. Design: §2 ruling 3, §3.5 item 0, §3.6, new §11 (Task 10 review dispositions). Plan: review log, Review Focus 4, Task 9, Task 10 rule 1 and tests, Task 16's readiness rule, Decision D13, and FS-26 redrafted, pending Paul.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+208
−153
docs/superpowers/plans/2026-11-20-fleet-seeded-create.md+15 −9docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md+70 −12internal/activator/backend_exec.go+2 −1internal/activator/seedfleet_linux_test.go+61 −45internal/activator/seedplace.go+6 −3internal/activator/seedplace_linux_test.go+0 −62internal/provision/seedfleet.go+32 −10internal/provision/seedfleet_linux_test.go+22 −11
CI failed — run details
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 f37d03cf3..e7d943bb3 100644 |
| --- a/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md |
| +++ b/docs/superpowers/plans/2026-11-20-fleet-seeded-create.md |
| @@ -22,6 +22,8 @@ Plan round 2 (`CODEX-FINDINGS-fleet-seeded-create-plan-R2.md`): NOT READY, 2 P1, |
| Plan round 3 (`CODEX-FINDINGS-fleet-seeded-create-plan-R3.md`): NOT READY, 1 P1 and 1 P2, both fixed here. R3-1: `seedFleetReady` refuses a claim-enabled console first (Task 16, `TestFileSeedFleetClaimConsoleRefuses`); the reviewer named this a refuse-up-front case matching the plan's declared scope. R3-2 (P2): `seedsFloorFields` takes the box identity and moves context (Task 11, two tests). A fourth round needs Paul's go. |
| +Task 10's own review (Codex, three rounds; design §11): round 1 fixed a transient check failure reported as terminal and a path-based cleanup scan; round 2 put purge and proof in one function that holds its directories (`instancefs.PurgeProven`); round 3 found two more in the same family, all needing a same-uid writer during cleanup. Paul chose (2026-11-20) to **refuse flat boxes for fleet file seeds** (Decision D13). This revision changes Review Focus 4, Task 9's flat test, Task 10 rule 1 and its tests, Task 16's readiness rule and FS-26. A short round 4 confirms it. |
| + |
| 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 |
| @@ -45,7 +47,7 @@ Earlier: no plan review before round 1. The design's round history carries into |
| 1. **The interrupted placement (R2-2, deterministic).** The replica uploads, the `placed` report fails, and the member deletes. The rollback purges local data, finds the replica, reports nothing, and the hostname stays held. Empty the fake fleet bucket's prefix and the next pass reports `rolledback`. A second seed at that hostname places its own snapshot (Task 11, `TestFleetFileSeedInterruptedPlacementHoldsHostname`). |
| 2. **An orphaned generation (R3-1).** `head.json` is gone but generation objects remain, so `lease.HasReplica` says false. The rollback must still report nothing (Task 11, `TestFleetFileSeedRollbackOrphanedGenerationHolds`). |
| 3. **Staging under a matching marker (R3-2).** A retry with this seed's marker and objects under `moves/<host>/` reports `failed`. It never promotes or restores them (Task 10, `TestFleetFileSeedRetryRefusesStaging`, `TestFleetFileSeedRestoreOwnNeverPromotesStaging`). |
| -4. **Two seeds placing at once in one flat directory.** Neither purge touches the other's temp file (Task 9, `TestFlatFleetTwoSeedsPlaceConcurrently`). |
| +4. **A flat fleet box takes no file seed** (Decision D13). Nothing is minted, fetched, listed or reported there (Task 10, `TestFlatFleetBoxRefusesFileSeed`, `TestFleetFileSeedMintLayout`). A purge still touches only its own instance's temp files (Task 9, `TestPurgeSeedTargetRemovesOnlyOwnInstanceTemps`). |
| 5. **A box that is not the owner.** Its `placed` from another fleet, another box, or naming another seed id changes nothing and answers 409 or the byte-identical 404 (Task 15, `TestFleetSeedDoorRefusals`). |
| 6. **A fleet with one box below the floor, or missing the new heartbeat block.** The door refuses and names the box (Task 14, `TestSeedFleetReadyNamesBoxes`). |
| @@ -124,7 +126,7 @@ instances create: fleet main has more than one active box. A seeded instance nee |
| instances create: could not confirm every box in fleet main. Try again in a minute. |
| instances create: the platform on box-2 in fleet main is below the seeds floor. Update it, then try again. |
| instances create: claim control is on for box-2 in fleet main. Seeded instances are not supported there yet. |
| -instances create: the layout of box-2 in fleet main is neither nested nor flat. Seed files need one of those. |
| +instances create: box-2 in fleet main keeps all its instances in one shared directory. A seed file needs a box that keeps each instance in its own. |
| instances create: This deployment’s seeds floor does not allow seed files yet. An operator publishes it again with carlos system seeds-floor publish. |
| instances create: This console runs with claim control on. Seeded instances are not supported here yet. |
| @@ -434,8 +436,8 @@ func ParseFleetSnapshotKey(key string) (sqid, app, host, id string, ok bool) |
| - [ ] **Step 1: Failing tests** |
| - `TestPurgeSeedTargetRemovesOnlyOwnInstanceTemps`: a flat directory with `.seed-a.example.com.db-sd_x.tmp`, `.seed-b.example.com.db-sd_y.tmp` and a legacy `.seed-sd_z.tmp`. Purging `a.example.com.db` removes only the first. With the nested flag the legacy name goes too. |
| - `TestPurgeSeedTargetRemovesEarlierSeedsLeftover`: an earlier aborted seed id's temp for the same base is removed. |
| - - `TestFlatFleetTwoSeedsPlaceConcurrently`: two `placeSeed` calls on one directory for two hosts, with a fake `SeedObjects` that blocks each fetch until both have started. Both place, and neither temp is removed by the other. |
| -- [ ] **Step 2:** `go test ./internal/activator -run 'TestPurgeSeedTarget|TestFlatFleetTwoSeeds' -count=1`. Expect FAIL. |
| + - ~~`TestFlatFleetTwoSeedsPlaceConcurrently`~~: removed by Decision D13 (a flat fleet box places no file seed). Its replacement is Task 10's `TestFlatFleetBoxRefusesFileSeed`. |
| +- [ ] **Step 2:** `go test ./internal/activator -run 'TestPurgeSeedTarget' -count=1`. Expect FAIL. |
| - [ ] **Step 3:** Implement. Then run step 2 and `go test ./internal/activator -run 'TestSeed|TestPlaceSeed|TestReconcileSeedMarker' -count=1`: PASS. |
| - [ ] **Step 4:** Commit: `activator: seed temp files carry their instance's database name`. |
| @@ -486,7 +488,8 @@ func rollbackFleetFileSeed(ctx context.Context, reg *registry.Registry, cfg Reco |
| The rules, each a numbered test below: |
| -1. **Layout** (design §3.5 item 0). `seedAction` (`seedreconcile.go:151`) mints a `ready` file seed on a box whose `cfg.Region` is a fleet placement (`registry.FleetPlacement`) when the box is flat. `seededRestore` (`seedplace.go:160`) admits `LayoutFlat` when `b.CustomerFleet`. Claim control still refuses, and `LayoutForeign` still refuses. |
| +1. **Layout** (design §3.5 item 0, Decision D13). Nested only. `seedAction` (`seedreconcile.go:151`) and `seededRestore` (`seedplace.go:160`) refuse a flat box for a fleet file seed exactly as for every other seed: no row is minted (the pass logs "this box does not mint nested") and a wake fails with the existing sentence "… this box does not run instances nested." Neither is reported to the door, so the seed stays `ready`. A fleet box also mints a file seed only when it has the fleet hooks. Claim control still refuses, and `LayoutForeign` still refuses. |
| + **Threat model** (design §3.6, and the comment on `rollbackFleetFileSeed`): the cleanup proof assumes no other writer to the nested instance directory during cleanup. The instance is stopped under the fence, its directory is owned by its own uid, and root and the box agent are trusted for this invariant. |
| 2. **Reading.** `fetchSeed` calls `b.Seeds.Open(ctx, rt.Account, rt.App, host, id)`. |
| 3. **Staging (R3-2).** For an unplaced fleet file seed (the kind is `file`, the state is not `placed`, and the box is on a customer fleet), `seededRestore` first lists `MovesPrefix(host)` through `b.Mirror`. If anything is there, it reports `copy-exists` through `OnSeedFailed` and fails the wake with FS-40. A listing error fails the wake and reports nothing (Decision D7). This runs before step 1's replica question. |
| 4. **Admission (R2-2).** When `hasOwnReplica` is true for such a seed, `ReadSeedMarker(dbPath)` must name `src.ID`. If it does not, or it cannot be read, report `copy-exists`, fail the wake, and restore nothing. If it does, `restoreOwn` runs through `restorePlain` with staging promotion off. |
| @@ -513,7 +516,8 @@ The rules, each a numbered test below: |
| - `TestFleetFileSeedRetryRefusesStaging`: a matching marker and objects under `moves/<host>/`. It reports `copy-exists`, and `promoteStagedReplica` and the restore are never called. |
| - `TestFleetFileSeedRestoreOwnNeverPromotesStaging`: a matching marker, an empty staging listing that then changes under the restore. `restorePlain` runs with staging off, and the mirror's `List` is called only by admission. |
| - `TestFleetFileSeedStagingListErrorReportsNothing`. |
| - - `TestFlatFleetBoxAdmitsFileSeed` and `TestFlatNonFleetBoxStillRefuses`. |
| + - `TestFlatFleetBoxRefusesFileSeed` (a flat fleet box: the flat refusal, nothing fetched, listed or reported; a nested one places) and `TestFlatNonFleetBoxStillRefuses`. In provision, `TestFleetFileSeedMintLayout`: a flat fleet box mints nothing and leaves the record `ready`. |
| + - Review rounds 1 and 2: `TestFleetFileSeedCheckCouldNotRunReportsNothing`; `TestFleetFileSeedRollbackSwappedDirectoryHolds` and `TestFleetFileSeedRollbackHoldsItsDirectories` (provision), `TestPurgeProvenRefusesASymlinkedComponent` and `TestPurgeProvenHoldsItsDirectories` (instancefs). The swap tests stay as defence in depth. |
| - [ ] **Step 2: Failing tests** (provision, with fake hooks and a temp registry): |
| - `TestFleetFileSeedRollbackReportsRolledBackWhenEmpty`: fence, purge, two listings, then one `rolledback` report. No record write and no snapshot delete. |
| - `TestFleetFileSeedRollbackListingErrorReportsNothing`: an error on the replica prefix, then the same on staging. Each reports nothing. |
| @@ -710,7 +714,7 @@ Under `withRecordLock`, `fleetSeedRecord` runs again, and then: |
| // floor.Min); MinRelease == floor.MinRelease; PrevRelease "none" or |
| // PrevAllowedFor == floor.MinRelease; the root rule of seedfloor.go:86 |
| // (else FS-23, 409, boxes named); no HostClaimEnabled (FS-24); Layout.Mode |
| -// nested or flat (FS-26). Ownership: the record must be ownable by one box |
| +// nested (FS-26; a flat box is refused, Decision D13). Ownership: the record must be ownable by one box |
| // (design §3.4). The seed door runs before fleet labelling |
| // (apiinstances.go:2545 vs :2569), so a file seed's record is created |
| // unlabelled, and the fleet must have exactly one active box (FS-21; |
| @@ -741,7 +745,7 @@ func (s *Server) seedFleetReady(ctx context.Context, fleet string) *doorRefusal |
| - [ ] **Step 1: Failing tests:** |
| - `TestFileSeedBeginFleetWritesDeploymentKey`: begin and upload. The record is `ready`, and the snapshot is at `apps/<sqid>/<app>/seeds/<host>/<id>/snapshot.db` in the deployment bucket. Nothing is in the data bucket. A region app is unchanged (Task 5's test still passes). |
| - `TestFileSeedFleetClaimConsoleRefuses` (plan R3-1): a claim-enabled console and an otherwise-ready, claims-disabled one-box fleet. Begin and PUT both refuse with the claim sentence, and no record or snapshot is written. |
| - - `TestSeedFleetReadyNamesBoxes`: one box missing `seeds_floor`, then one at protocol 3. Each is refused with the box named. `TestSeedFleetReadyStaleHeartbeat` is a 503. `TestSeedFleetReadyRefusesTwoActiveBoxes`, `TestSeedFleetReadyRefusesClaimControl`, `TestSeedFleetReadyAdmitsFlat`. |
| + - `TestSeedFleetReadyNamesBoxes`: one box missing `seeds_floor`, then one at protocol 3. Each is refused with the box named. A box whose `Layout.Mode` is flat, or anything but nested, is refused with FS-26 and named (Decision D13). `TestSeedFleetReadyStaleHeartbeat` is a 503. `TestSeedFleetReadyRefusesTwoActiveBoxes`, `TestSeedFleetReadyRefusesClaimControl`, `TestSeedFleetReadyAdmitsFlat`. |
| - `TestFromOnFleetStillRefuses` (kept). |
| - `TestSeedsPassDeletesAbortedFleetFileSnapshotKeepsRecord` (R3-3), `TestSeedsPassDeletesAbortedFleetFileSnapshotInTrashedApp` (plan R1-4), `TestSeedsPassAbortsStuckFleetFileReservation`, `TestSeedsPassDeletesOrphanFleetSnapshotAfterAnHour`, `TestSeedsPassFleetHalfRunsWithoutSeedData`. |
| - `TestFleetFileSeedNoOwnerNeverFinished`: an aborted fleet file seed whose fleet has no active box. Sweeps and finishes leave the record alone, and the hostname stays held. |
| @@ -839,7 +843,7 @@ House rules applied: no em dashes; curly apostrophes; placeholders in their orde |
| | FS-23 | the platform on %s in fleet %s is below the seeds floor. Update it, then try again. | %s in fleet %s are below the seeds floor. Update the platform on those boxes, then try again. | approved (Paul, 2026-11-20) | |
| | FS-24 | claim control is on for %s in fleet %s. Seeded instances are not supported there yet. | %s in fleet %s run with claim control on. Seeded instances are not supported there yet. | approved (Paul, 2026-11-20) | |
| | FS-25 | This deployment’s seeds floor does not allow seed files yet. An operator publishes it again with carlos system seeds-floor publish. | This deployment’s seeds floor predates seed files. An operator publishes it again with carlos system seeds-floor publish. | approved (Paul, 2026-11-20) (capital T, as SD-N3) | |
| -| FS-26 | the layout of %s in fleet %s is neither nested nor flat. Seed files need one of those. | %s in fleet %s run instances in a layout seeds do not support. | approved (Paul, 2026-11-20) | |
| +| FS-26 | %s in fleet %s keeps all its instances in one shared directory. A seed file needs a box that keeps each instance in its own. | the layout of %s in fleet %s is neither nested nor flat. Seed files need one of those. | **pending (Paul)**: redrafted for Decision D13 (nested only). The earlier text was approved 2026-11-20 and is now wrong. Shown for any box whose layout is not nested | |
| | FS-27 | the seed file on the box did not match the upload | the file on the box did not match its upload, so it was not used | approved (Paul, 2026-11-20) (Seed.Reason) | |
| | FS-28 | the seed file on the box failed its integrity check | the file is not a database that passes an integrity check, so it was not used | approved (Paul, 2026-11-20) (Seed.Reason) | |
| | FS-29 | a copy of data already exists for this hostname | same | approved (Paul, 2026-11-20) (Seed.Reason; design §3.6's words) | |
| @@ -890,6 +894,8 @@ House rules applied: no em dashes; curly apostrophes; placeholders in their orde |
| - **The bucket is not named.** The console knows the bucket the fleet was created against (`registry.Fleet.Bucket`, `internal/registry/fleets.go:41`, from `carlos fleets create --bucket`). But the box writes to its own `CARLOS_HIBERNATE_BUCKET` (`internal/host/agent.go:885`, `seedDataOpener(cfg.Bucket, …)`), and nothing checks the two match. The sentence says "the fleet’s storage", which is true either way. |
| - Reporting the prefix itself through the heartbeat was the alternative. It would be box-supplied text a member reads, which D4 rules out. |
| +- **D13. Fleet file seeds need a nested box** (Paul, 2026-11-20, after Task 10 review round 3; it replaces design ruling 3 as first accepted). Three review rounds found cleanup-identity failures that all need a same-uid writer during cleanup, which a flat box has by design. On a nested box the instance directory belongs to the instance's own uid and that instance is stopped under the fence. So the box never mints or places a fleet file seed flat, and the console refuses a fleet with a box that is not nested (Task 16, FS-26). The per-instance temp names (Task 9), `instancefs.PurgeProven` and the both-locations proof (D5) stay: harmless, and they guard a layout change. Eleven's fleet `eleven` must run nested before slice 4. |
| + |
| ## Design gaps found while planning |
| - **G1. Fleet seed records are created unlabelled.** The create door hands every seed over before fleet labelling: `unlockFleet` and the handover at `internal/console/apiinstances.go:2545-2557` come before `fleetCreateLabel` at `:2569`. A box treats an unlabelled fleet record as its own (`internal/provision/reconcile.go:553`). On a fleet with two or more active boxes, every box would mint and place the seed, and no box would own it at the door. The plan refuses those fleets (D8). The alternative is to label at begin, which takes the fleet lock during begin; begin is quick for a file seed, because the upload is a separate call. Paul's call. Eleven's fleet must have one active box, or wait for that ruling. |
diff --git a/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md b/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md| index 6ea48dfee..6218a6c4d 100644 |
| --- a/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md |
| +++ b/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md |
| @@ -40,11 +40,18 @@ MB at most) on a machine the platform never ran. |
| (`internal/edge/storedoor.go:688`, `aclRead`). The platform holds a |
| copy of the account's database until placement, then deletes it. It |
| already holds one for every import upload; this only moves where. |
| -3. **Flat layout is allowed on a customer fleet.** The seeds spec rules |
| - flat boxes out because a seeded instance there "would be one uid among |
| - every tenant" (§6.3). Every box of a customer fleet runs only the fleet |
| - owner's apps, so there is one tenant. Boxes with claim control armed are |
| - still refused, as in §3.4. |
| +3. **Flat layout is refused for fleet file seeds** (Paul, 2026-11-20, |
| + after Task 10 review round 3; this replaces the ruling first accepted, |
| + "flat layout is allowed on a customer fleet"). A fleet file seed is |
| + created, minted and placed only on a box that runs its instances |
| + nested. The first ruling reasoned that a customer fleet has one tenant, |
| + so the seeds spec's objection to flat boxes ("one uid among every |
| + tenant", §6.3) did not apply. That holds for confidentiality. It does |
| + not hold for the cleanup proof of §3.6: on a flat box every app writes |
| + to one shared data directory as one uid, so another of the fleet |
| + owner's apps can replace what a cleanup is working on, and the proof |
| + cannot be made (§11). Boxes with claim control armed are still refused, |
| + as in §3.4. |
| 4. **A fleet box records seed progress through the console.** The store |
| door refuses a fleet box's writes to `apps/<sqid>/<app>/instances/*` |
| (`storedoor.go:807-832`), and the box's seed transitions write exactly |
| @@ -154,12 +161,20 @@ single box (a `FleetBox` label, or the fleet's sole active box). |
| The fleet box handles a `file` seed as a region box handles a `--from` |
| seed (§3.4's plain path), with these changes. |
| -0. **Layout (ruling 3, R1-1).** The two flat refusals |
| - (`provision/seedreconcile.go:151`, `activator/seedplace.go:160`) admit a |
| - flat box when it is a customer-fleet box (`CARLOS_FLEET` set). Claim |
| - control and any layout other than flat or nested still refuse. On a |
| - flat box instances share one data directory (`activator/paths.go:41`), |
| - so: |
| +0. **Layout (ruling 3 as changed, R1-1, §11).** The two flat refusals |
| + (`provision/seedreconcile.go:151`, `activator/seedplace.go:160`) stay as |
| + they are for a fleet file seed: nested only, as for every other seed. |
| + A flat fleet box mints no row for one (the pass logs "this box does not |
| + mint nested") and a wake of one fails with the seeds spec's sentence |
| + ("… this box does not run instances nested."). Neither is reported to |
| + the console: the seed stays `ready`, and the console refuses a fleet |
| + with a flat box before it creates anything (§3.4). Claim control and |
| + any layout other than nested still refuse. |
| + |
| + The rest of this item was written for the flat admission and is kept. |
| + It is harmless on a nested box, and it guards a box whose layout |
| + changed between placement and rollback. On a flat box instances share |
| + one data directory (`activator/paths.go:41`), so: |
| - **Seed temp files carry their instance's database name**: |
| `.seed-<base>-<id>.tmp…`, where `<base>` is the database's file name. |
| - **`purgeSeedTarget` removes only its own instance's temp files** |
| @@ -169,7 +184,8 @@ seed (§3.4's plain path), with these changes. |
| delete another instance's placement in progress. |
| - **Rollback uses the row's own database path**, not `NestedDBPath` |
| (`provision/seedreconcile.go:291`). |
| - - A test places two seeds at once on one flat directory. |
| + - ~~A test places two seeds at once on one flat directory.~~ Replaced: |
| + a test that a flat fleet box refuses a file seed and mints nothing. |
| 1. **Reading the snapshot.** `SeedObjects.Open` takes the account and app |
| as well as host and id, and a fleet box's implementation streams the key |
| @@ -223,6 +239,23 @@ the proof can be made. It is enforced in one place, the box's rollback of |
| an aborted file seed, and the door's `rolledback` operation is the only |
| way it is reported. |
| +**What the proof assumes (threat model; Paul, 2026-11-20, after Task 10 |
| +review round 3).** The local half of the proof assumes that nothing else |
| +writes to the instance's nested directory while the cleanup runs: |
| + |
| +- a fleet file seed is placed only on a nested row (§2 ruling 3), and a |
| + nested instance directory is owned by that instance's own uid, so no |
| + other app on the box can write in it or replace it; |
| +- that instance is stopped under the fence for the whole cleanup; |
| +- root and the box agent are trusted for this invariant. They are the |
| + ones proving it. |
| + |
| +A flat data directory breaks the first point, which is why flat boxes are |
| +refused. The rollback still purges and proves both local locations, and |
| +its purge holds its directories open and checks their identity |
| +(`instancefs.PurgeProven`). Those are defence in depth and guard a layout |
| +change; the invariant does not rest on them. |
| + |
| **Abandonment.** A seed is `aborted` by `SeedFail`, by the console's |
| deadline sweep (a `file` seed in `reserving` past `seedFileReserveTTL`, |
| §3.3), or by the member (`instances delete` before placement). For an |
| @@ -419,3 +452,28 @@ review (stopping rule 3), and its brief names R3-1 and R3-2. |
| | R3-1 P1 `HasReplica` is not an emptiness proof | Fixed: exhaustive paginated listing of both restore-capable prefixes, fail closed, §3.6 step 3; orphaned-generation test, §5 | |
| | R3-2 P1 staging can restore unrelated data | Fixed: staging refused and promotion off for an unplaced fleet file seed; staging in the rollback listing, §3.6; staging tests, §5 | |
| | R3-3 P2 snapshot retention vs the sweep | Fixed by matching the sweep: the snapshot goes on abandonment, the record holds the hostname, §4; sweep test, §5 | |
| + |
| +## 11. Task 10 review dispositions |
| + |
| +Task 10 (placement and rollback on a fleet box) had its own review, by |
| +Codex, as §10 required. Three rounds, each NOT READY. |
| + |
| +| Round | Finding | Disposition | |
| +|---|---|---| |
| +| 1 | P1 a transient integrity-check failure aborts a valid seed | Fixed: `not-a-database` is reported only for a verdict on the contents (`lease.CheckSaysDamaged`); a check that could not run is retried | |
| +| 1 | P1 the cleanup proof follows symlinked directory components | Fixed: the scan opens with no symlink followed, from descriptors | |
| +| 2 | P1 the cleanup does not keep directory identity across list, remove and proof | Stopping rule 2 (same family twice). Paul chose "state the invariant, enforce it in one place, guard test": one function owns each location and holds its directories (`instancefs.PurgeProven`) | |
| +| 3 | P1 a failed purge forgets the original storage, so the next pass proves an empty replacement | Not fixed in code. See below | |
| +| 3 | P1 recursive removal stats a child and then opens it separately, so a swapped child is removed in place of the original | Not fixed in code. See below | |
| + |
| +Round 3's two findings and round 2's share one cause: a writer with the |
| +same uid as the data, active during the cleanup. On a flat box that |
| +writer exists by design, since every app shares one data directory and |
| +one uid. **Paul chose (2026-11-20) to refuse flat boxes** for fleet file |
| +seeds (§2 ruling 3, §3.5 item 0) instead of chasing each interleaving. On |
| +a nested box the instance directory belongs to the instance's own uid and |
| +that instance is stopped under the fence, so the writer does not exist |
| +(§3.6, "What the proof assumes"). A short fourth round confirms this. |
| + |
| +The work rounds 1 and 2 added stays: the per-instance temp names, the |
| +descriptor-holding purge and the both-locations proof. |
diff --git a/internal/activator/backend_exec.go b/internal/activator/backend_exec.go| index b35f239e6..c19e7cc3b 100644 |
| --- a/internal/activator/backend_exec.go |
| +++ b/internal/activator/backend_exec.go |
| @@ -327,7 +327,8 @@ type ExecBackend struct { |
| // placed, then the snapshot's delete. Nil: not recorded here. |
| OnSeedPlaced func(ctx context.Context, account, app, host, id string) error |
| // CustomerFleet is a box of a customer fleet (CARLOS_FLEET resolves). |
| - // It runs flat, and places a file seed by the fleet rules (seedfleet.go). |
| + // It places a file seed by the fleet rules (seedfleet.go), on a nested |
| + // row only, like every seed. |
| CustomerFleet bool |
| // OnSeedFailed reports a fleet file seed's terminal failure (fleet |
| // seeded create design §3.6) with a reason code: "mismatch", |
diff --git a/internal/activator/seedfleet_linux_test.go b/internal/activator/seedfleet_linux_test.go| index dfe193ab1..210620fc1 100644 |
| --- a/internal/activator/seedfleet_linux_test.go |
| +++ b/internal/activator/seedfleet_linux_test.go |
| @@ -51,8 +51,8 @@ type fleetSeedRig struct { |
| restored int // restoreReplica's calls |
| } |
| -// fleetFileSeedRig builds the rig: flat (the customer-fleet layout) or |
| -// nested, a ready file seed whose snapshot is a small database, an empty |
| +// fleetFileSeedRig builds the rig: nested, where a fleet file seed is |
| +// placed, or flat, where it is refused; a ready file seed whose snapshot is a small database, an empty |
| // bucket, and no replica of the host's own unless a test says so. |
| func fleetFileSeedRig(t *testing.T, flat bool) *fleetSeedRig { |
| t.Helper() |
| @@ -119,7 +119,7 @@ func (r *fleetSeedRig) keys(prefix string) []string { |
| return out |
| } |
| -const copyExistsSentence = "shop.example.com could not start from its seed: a copy of data already exists for this hostname." |
| +const copyExistsSentence = "h.example.com could not start from its seed: a copy of data already exists for this hostname." |
| func requireRefusal(t *testing.T, fresh bool, err error, want string) { |
| t.Helper() |
| @@ -130,7 +130,7 @@ func requireRefusal(t *testing.T, fresh bool, err error, want string) { |
| } |
| func TestFleetFileSeedPlacesThroughStoreDoorAndReportsPlaced(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| fresh, err := r.b.Restore(context.Background(), r.rt) |
| if err != nil || fresh { |
| t.Fatalf("Restore = fresh %v, %v", fresh, err) |
| @@ -156,7 +156,7 @@ func TestFleetFileSeedPlacesThroughStoreDoorAndReportsPlaced(t *testing.T) { |
| } |
| func TestFleetFileSeedCheckFailureReportsFailed(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| body := []byte("not sqlite at all, but the right length and hash") |
| sum := sha256.Sum256(body) |
| r.rt.SeedSource = seeds.RowSeed{ID: r.id, Kind: seeds.KindFile, SHA256: hex.EncodeToString(sum[:]), Bytes: int64(len(body)), State: seeds.StateReady}.Encode() |
| @@ -172,7 +172,7 @@ func TestFleetFileSeedCheckFailureReportsFailed(t *testing.T) { |
| } |
| func TestFleetFileSeedMismatchReportsFailed(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| r.objs.body[r.id] = r.objs.body[r.id][:100] |
| fresh, err := r.b.Restore(context.Background(), r.rt) |
| requireRefusal(t, fresh, err, "length or sha256") |
| @@ -205,7 +205,7 @@ func TestFleetFileSeedCheckCouldNotRunReportsNothing(t *testing.T) { |
| "cancelled": fmt.Errorf("integrity_check: %w", context.DeadlineExceeded), |
| } { |
| t.Run(name, func(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| checks := 0 |
| setKnob(t, &checkSeedDB, func(ctx context.Context, path string) error { |
| if checks++; checks == 1 { |
| @@ -241,7 +241,7 @@ func TestFleetFileSeedCheckCouldNotRunReportsNothing(t *testing.T) { |
| "unmarked, same words": {errors.New("file is not a database"), nil}, |
| } { |
| t.Run(name, func(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| setKnob(t, &checkSeedDB, func(context.Context, string) error { return c.err }) |
| fresh, err := r.b.Restore(context.Background(), r.rt) |
| requireRefusal(t, fresh, err, "integrity check") |
| @@ -255,7 +255,7 @@ func TestFleetFileSeedCheckCouldNotRunReportsNothing(t *testing.T) { |
| // A read that fails, a disk that fails: the wake fails, nothing is |
| // reported, and the next wake places the seed. |
| func TestFleetFileSeedUnreadReportsNothing(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| r.objs.err = errors.New("store door down") |
| fresh, err := r.b.Restore(context.Background(), r.rt) |
| requireRefusal(t, fresh, err, "could not be read") |
| @@ -293,14 +293,14 @@ func TestFleetFileSeedReplicaWithoutMarkerReportsFailed(t *testing.T) { |
| } |
| }, |
| } { |
| - for _, flat := range []bool{true, false} { |
| - t.Run(fmt.Sprintf("%s, flat %v", name, flat), func(t *testing.T) { |
| - r := fleetFileSeedRig(t, flat) |
| + { |
| + t.Run(name, func(t *testing.T) { |
| + r := fleetFileSeedRig(t, false) |
| r.ownReplica(t, true) |
| leave(t, r) |
| fresh, err := r.b.Restore(context.Background(), r.rt) |
| requireRefusal(t, fresh, err, "a copy of data already exists") |
| - if flat && err.Error() != copyExistsSentence { |
| + if err.Error() != copyExistsSentence { |
| t.Fatalf("sentence = %q, want FS-40 %q", err.Error(), copyExistsSentence) |
| } |
| if !reflect.DeepEqual(r.failed, []string{provision.SeedCodeCopyExists}) { |
| @@ -318,7 +318,7 @@ func TestFleetFileSeedReplicaWithoutMarkerReportsFailed(t *testing.T) { |
| } |
| func TestFleetFileSeedReplicaWithMarkerRestoresAndReportsPlaced(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| r.ownReplica(t, true) |
| r.writeMarker(t, r.id) |
| fresh, err := r.b.Restore(context.Background(), r.rt) |
| @@ -340,8 +340,8 @@ func TestFleetFileSeedReplicaWithMarkerRestoresAndReportsPlaced(t *testing.T) { |
| // anything is staged, so a retry with staged objects is refused before the |
| // replica question is even asked. Nothing is promoted, nothing restored. |
| func TestFleetFileSeedRetryRefusesStaging(t *testing.T) { |
| - for _, flat := range []bool{true, false} { |
| - r := fleetFileSeedRig(t, flat) |
| + { |
| + r := fleetFileSeedRig(t, false) |
| asked := r.ownReplica(t, true) |
| r.writeMarker(t, r.id) |
| staged := MovesPrefix(r.rt.Host) + "generations/a/snapshot" |
| @@ -359,7 +359,7 @@ func TestFleetFileSeedRetryRefusesStaging(t *testing.T) { |
| } |
| // With no replica either, the fresh fetch is refused the same way: |
| // once placed, an ordinary wake would promote the staged copy over it. |
| - r2 := fleetFileSeedRig(t, flat) |
| + r2 := fleetFileSeedRig(t, false) |
| r2.mirror.put(r2.b.Cfg.Bucket, staged, "e1") |
| fresh, err = r2.b.Restore(context.Background(), r2.rt) |
| requireRefusal(t, fresh, err, "a copy of data already exists") |
| @@ -374,7 +374,7 @@ func TestFleetFileSeedRetryRefusesStaging(t *testing.T) { |
| // the bucket is listed once, by admission, and the staged object is neither |
| // promoted nor dropped. |
| func TestFleetFileSeedRestoreOwnNeverPromotesStaging(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| r.writeMarker(t, r.id) |
| staged := MovesPrefix(r.rt.Host) + "generations/a/snapshot" |
| setKnob(t, &hasOwnReplica, func(context.Context, string, string, string) (bool, error) { |
| @@ -404,7 +404,7 @@ func TestFleetFileSeedStagingListErrorReportsNothing(t *testing.T) { |
| "no bucket reader on the box": func(r *fleetSeedRig) { r.b.Mirror = nil }, |
| } { |
| t.Run(name, func(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| asked := r.ownReplica(t, true) |
| r.writeMarker(t, r.id) |
| breakIt(r) |
| @@ -422,8 +422,9 @@ func TestFleetFileSeedStagingListErrorReportsNothing(t *testing.T) { |
| // Design §3.6's last sentence: once placed, a fleet file seed's wakes are |
| // ordinary restores and staging behaves as it does today. |
| func TestFleetFileSeedOncePlacedPromotesStagingAsToday(t *testing.T) { |
| - r := fleetFileSeedRig(t, true) |
| + r := fleetFileSeedRig(t, false) |
| r.rt = withSeedState(t, r.rt, seeds.StatePlaced) |
| + os.MkdirAll(filepath.Dir(r.rt.DBPath), 0o700) // lease.Restore's own MkdirAll |
| r.mirror.put(r.b.Cfg.Bucket, MovesPrefix(r.rt.Host)+"generations/a/snapshot", "e1") |
| fresh, err := r.b.Restore(context.Background(), r.rt) |
| if err != nil || fresh || r.restored != 1 || len(r.failed) != 0 { |
| @@ -434,35 +435,49 @@ func TestFleetFileSeedOncePlacedPromotesStagingAsToday(t *testing.T) { |
| } |
| } |
| -func TestFlatFleetBoxAdmitsFileSeed(t *testing.T) { |
| +// Paul's ruling after Task 10's review round 3: a fleet file seed needs a |
| +// nested box. A flat customer-fleet box refuses it as every box refuses |
| +// every seed flat: the same sentence, nothing fetched, nothing listed, |
| +// nothing reported, nothing at the row's path. The seed stays ready. |
| +func TestFlatFleetBoxRefusesFileSeed(t *testing.T) { |
| r := fleetFileSeedRig(t, true) |
| if l, _ := r.b.Layout(r.rt); l != LayoutFlat { |
| t.Fatalf("the rig's row classifies as %v, want flat", l) |
| } |
| - if fresh, err := r.b.Restore(context.Background(), r.rt); err != nil || fresh { |
| - t.Fatalf("Restore = fresh %v, %v; want the seed placed flat", fresh, err) |
| + for _, own := range []bool{false, true} { // with a replica of its own, too |
| + r.ownReplica(t, own) |
| + r.writeMarker(t, r.id) |
| + fresh, err := r.b.Restore(context.Background(), r.rt) |
| + requireRefusal(t, fresh, err, "this box does not run instances nested.") |
| + if r.objs.opens != 0 || r.restored != 0 || len(r.failed) != 0 || len(r.placed) != 0 || len(r.mirror.lists) != 0 { |
| + t.Fatalf("fetched %d, restored %d, reported %q, placed %q, listed %q; want none", r.objs.opens, r.restored, r.failed, r.placed, r.mirror.lists) |
| + } |
| + if _, err := os.Lstat(r.rt.DBPath); !os.IsNotExist(err) { |
| + t.Fatalf("a database is at the flat path: %v", err) |
| + } |
| + } |
| + // A nested fleet box places it. |
| + n := fleetFileSeedRig(t, false) |
| + if l, _ := n.b.Layout(n.rt); l != LayoutNested { |
| + t.Fatalf("the nested rig's row classifies as %v", l) |
| } |
| - if m, _ := os.ReadFile(r.rt.DBPath + SeedMarkerSuffix); strings.TrimSpace(string(m)) != r.id { |
| - t.Fatalf("marker = %q, want %s", m, r.id) |
| + if fresh, err := n.b.Restore(context.Background(), n.rt); err != nil || fresh { |
| + t.Fatalf("nested: Restore = fresh %v, %v; want the seed placed", fresh, err) |
| } |
| - // Claim control refuses on a fleet as anywhere. |
| - c := fleetFileSeedRig(t, true) |
| + if m, _ := os.ReadFile(n.rt.DBPath + SeedMarkerSuffix); strings.TrimSpace(string(m)) != n.id { |
| + t.Fatalf("marker = %q, want %s", m, n.id) |
| + } |
| + // Claim control refuses on a fleet as anywhere, and so does a row that |
| + // is neither flat nor nested. |
| + c := fleetFileSeedRig(t, false) |
| c.b.ClaimArmed = true |
| fresh, err := c.b.Restore(context.Background(), c.rt) |
| requireRefusal(t, fresh, err, "claim control") |
| - // So does a row that is neither flat nor nested. |
| - f := fleetFileSeedRig(t, true) |
| + f := fleetFileSeedRig(t, false) |
| f.rt.Socket = filepath.Join(t.TempDir(), "x.sock") |
| fresh, err = f.b.Restore(context.Background(), f.rt) |
| requireRefusal(t, fresh, err, "nested") |
| - // And a --from seed keeps today's flat refusal on a fleet box. |
| - p := fleetFileSeedRig(t, true) |
| - src, _ := seeds.ParseRowSeed(p.rt.SeedSource) |
| - src.Kind = seeds.KindReplica |
| - p.rt.SeedSource = src.Encode() |
| - fresh, err = p.b.Restore(context.Background(), p.rt) |
| - requireRefusal(t, fresh, err, "nested") |
| - for _, x := range []*fleetSeedRig{c, f, p} { |
| + for _, x := range []*fleetSeedRig{c, f} { |
| if x.objs.opens != 0 || len(x.failed) != 0 { |
| t.Fatalf("a refused wake fetched %d and reported %q", x.objs.opens, x.failed) |
| } |
| @@ -628,7 +643,8 @@ func TestFleetFileSeedInterruptedPlacementHoldsHostname(t *testing.T) { |
| }, |
| }, |
| } |
| - cfg := provision.ReconcileConfig{Region: "fleet/pi", FleetBox: "pi-1", DataDir: b.DataDir, Seeds: hooks} |
| + cfg := provision.ReconcileConfig{Region: "fleet/pi", FleetBox: "pi-1", DataDir: b.DataDir, Seeds: hooks, |
| + Layout: func(context.Context, release.Store) (string, error) { return release.LayoutModeNested, nil }} |
| pass := func() { |
| t.Helper() |
| if err := provision.Reconcile(ctx, store, reg, cfg); err != nil { |
| @@ -655,19 +671,19 @@ func TestFleetFileSeedInterruptedPlacementHoldsHostname(t *testing.T) { |
| } |
| return *rt |
| } |
| - flat := provision.DefaultDBPath(b.DataDir, host) |
| + dbAt := provision.NestedDBPath(b.DataDir, host) // the row's database: nested, the only layout a fleet file seed takes |
| - // The first seed is minted flat, placed, and its replica uploads. |
| + // The first seed is minted nested, placed, and its replica uploads. |
| first, firstBody := seedRecord("first", time.Now().UTC().Add(-time.Hour)) |
| pass() |
| rt := row() |
| - if rt.DBPath != flat { |
| - t.Fatalf("minted at %s, want the flat path %s", rt.DBPath, flat) |
| + if rt.DBPath != dbAt { |
| + t.Fatalf("minted at %s, want the nested path %s", rt.DBPath, dbAt) |
| } |
| if fresh, err := b.Restore(ctx, rt); err != nil || fresh { |
| t.Fatalf("placing the first seed: fresh %v, %v", fresh, err) |
| } |
| - if got, _ := os.ReadFile(flat); !bytes.Equal(got, firstBody) { |
| + if got, _ := os.ReadFile(dbAt); !bytes.Equal(got, firstBody) { |
| t.Fatal("the first seed's snapshot is not at the row's path") |
| } |
| bucket.put(b.Cfg.Bucket, replicaPrefix+"generations/g1/0000000000000001.ltx", "e1") |
| @@ -685,7 +701,7 @@ func TestFleetFileSeedInterruptedPlacementHoldsHostname(t *testing.T) { |
| if got, _ := reg.Get(host); got != nil { |
| t.Fatalf("the aborted seed's row is still up: %+v", got) |
| } |
| - if _, err := os.Lstat(flat); err != nil { |
| + if _, err := os.Lstat(dbAt); err != nil { |
| t.Fatalf("the database went with the row: %v", err) |
| } |
| if len(reports) != 0 { |
| @@ -693,7 +709,7 @@ func TestFleetFileSeedInterruptedPlacementHoldsHostname(t *testing.T) { |
| } |
| pass() // purge, find the replica, hold |
| - for _, p := range []string{flat, flat + SeedMarkerSuffix} { |
| + for _, p := range []string{dbAt, dbAt + SeedMarkerSuffix} { |
| if _, err := os.Lstat(p); !os.IsNotExist(err) { |
| t.Fatalf("%s survived the purge: %v", p, err) |
| } |
diff --git a/internal/activator/seedplace.go b/internal/activator/seedplace.go| index af821f2be..433b6c5a2 100644 |
| --- a/internal/activator/seedplace.go |
| +++ b/internal/activator/seedplace.go |
| @@ -182,9 +182,12 @@ func (b *ExecBackend) seededRestore(ctx context.Context, rt registry.Route, src |
| return fail(seedRefusedClaim(host)) |
| } |
| paths := b.pathsFor(rt) |
| - // A customer-fleet box runs flat, and takes a file seed flat (design |
| - // §3.5 item 0). Every other seed, and every other box, is nested only. |
| - if paths.layout != LayoutNested && !(fleet && paths.layout == LayoutFlat) { |
| + // Nested only, for every seed on every box, a customer fleet's |
| + // included (design §2 ruling 3 as changed after Task 10's review round |
| + // 3): in a flat directory any other app of the same uid can replace |
| + // what a cleanup is working on, and the fleet rollback's proof assumes |
| + // no such writer (provision.rollbackFleetFileSeed). |
| + if paths.layout != LayoutNested { |
| return fail(seedRefusedFlat(host)) |
| } |
| dir, base := filepath.Dir(paths.dbPath), filepath.Base(paths.dbPath) |
diff --git a/internal/activator/seedplace_linux_test.go b/internal/activator/seedplace_linux_test.go| index abf0ee9e0..a7847e6df 100644 |
| --- a/internal/activator/seedplace_linux_test.go |
| +++ b/internal/activator/seedplace_linux_test.go |
| @@ -1084,65 +1084,3 @@ func TestPurgeSeedTargetRemovesEarlierSeedsLeftover(t *testing.T) { |
| } |
| } |
| } |
| - |
| -// holdingSeedObjects serves each id's snapshot but parks every read after its |
| -// first byte until release is closed, so two placements overlap with their |
| -// temp files on disk. |
| -type holdingSeedObjects struct { |
| - body map[string][]byte |
| - started chan struct{} |
| - release chan struct{} |
| -} |
| - |
| -func (h *holdingSeedObjects) Open(_ context.Context, _, _, _, id string) (io.ReadCloser, error) { |
| - b := h.body[id] |
| - return io.NopCloser(io.MultiReader(bytes.NewReader(b[:1]), |
| - readerFunc(func() { h.started <- struct{}{}; <-h.release }), bytes.NewReader(b[1:]))), nil |
| -} |
| - |
| -// readerFunc runs f once, on its first read, and is then at EOF. |
| -type readerFunc func() |
| - |
| -func (f readerFunc) Read([]byte) (int, error) { f(); return 0, io.EOF } |
| - |
| -func TestFlatFleetTwoSeedsPlaceConcurrently(t *testing.T) { |
| - b, _ := nestedBackend(t, &fakeControl{}, &fakeUnit{}) |
| - dir := t.TempDir() |
| - snap := filepath.Join(t.TempDir(), "snap.db") |
| - if err := writeMinimalSQLite(snap); err != nil { |
| - t.Fatal(err) |
| - } |
| - body, _ := os.ReadFile(snap) |
| - sum := sha256.Sum256(body) |
| - objs := &holdingSeedObjects{body: map[string][]byte{}, started: make(chan struct{}, 2), release: make(chan struct{})} |
| - b.Seeds = objs |
| - hosts := []string{"a.example.com", "b.example.com"} |
| - srcs := map[string]*seeds.RowSeed{} |
| - for _, h := range hosts { |
| - id, _ := seeds.NewID() |
| - objs.body[id] = body |
| - srcs[h] = &seeds.RowSeed{ID: id, Kind: seeds.KindFile, SHA256: hex.EncodeToString(sum[:]), Bytes: int64(len(body)), State: seeds.StateReady} |
| - } |
| - errs := make(chan error, 2) |
| - for _, h := range hosts { |
| - go func() { errs <- b.placeSeed(context.Background(), registry.Route{Host: h}, srcs[h], dir, h+".db") }() |
| - } |
| - <-objs.started |
| - <-objs.started |
| - // Both temp files exist. A third instance in the directory wakes and |
| - // purges its own leftovers; neither placement's temp may go with them. |
| - if err := purgeSeedTarget(dir, "c.example.com.db", false); err != nil { |
| - t.Fatal(err) |
| - } |
| - close(objs.release) |
| - for range hosts { |
| - if err := <-errs; err != nil { |
| - t.Fatalf("a placement failed: %v", err) |
| - } |
| - } |
| - for _, h := range hosts { |
| - if m, err := os.ReadFile(filepath.Join(dir, h+".db"+SeedMarkerSuffix)); err != nil || strings.TrimSpace(string(m)) != srcs[h].ID { |
| - t.Errorf("%s: marker %q, %v", h, m, err) |
| - } |
| - } |
| -} |
diff --git a/internal/provision/seedfleet.go b/internal/provision/seedfleet.go| index eb443731c..16c748e32 100644 |
| --- a/internal/provision/seedfleet.go |
| +++ b/internal/provision/seedfleet.go |
| @@ -67,22 +67,21 @@ func fleetFileSeed(cfg ReconcileConfig, rec Record) bool { |
| } |
| // seedMintRefusal is seedAction's layout question for a ready seed with no |
| -// row: "" to mint, or why not. Every seed mints nested. A file seed on a |
| -// customer-fleet box also mints flat (design §3.5 item 0), and only when |
| -// the box can report it: without the fleet hooks nothing could ever record |
| -// it placed or roll it back. A layout that cannot be read mints nothing. |
| +// row: "" to mint, or why not. Every seed mints nested and never flat, on a |
| +// customer fleet as anywhere (design §2 ruling 3, as changed after Task |
| +// 10's review round 3: see rollbackFleetFileSeed's threat model). A layout |
| +// that cannot be read mints nothing. A file seed on a customer-fleet box |
| +// also needs the box to be able to report it: without the fleet hooks |
| +// nothing could ever record it placed or roll it back. |
| func seedMintRefusal(rec Record, cfg ReconcileConfig, nested func() (bool, error)) string { |
| ok, err := nested() |
| if err != nil { |
| return fmt.Sprintf("this box's layout could not be read (%v)", err) |
| } |
| - if !fleetFileSeed(cfg, rec) { |
| - if !ok { |
| - return "this box does not mint nested" |
| - } |
| - return "" |
| + if !ok { |
| + return "this box does not mint nested" |
| } |
| - if !fleetRollbackArmed(cfg.Seeds) { |
| + if fleetFileSeed(cfg, rec) && !fleetRollbackArmed(cfg.Seeds) { |
| return "this fleet box cannot report a seed file's progress" |
| } |
| return "" |
| @@ -164,6 +163,29 @@ func fleetSeedPurgeProven(dataDir, dbPath string, nested bool) error { |
| // a head or root-layout files, and misses a generation left behind |
| // once its head is gone (R3-1). |
| // |
| +// The threat model (Paul, 2026-11-20, after review round 3). The local |
| +// half of the proof assumes that nothing else writes to the instance's |
| +// nested directory while the cleanup runs. That holds because: |
| +// |
| +// - a fleet file seed is minted and placed only on a nested row |
| +// (seedMintRefusal, the activator's seededRestore), and a nested |
| +// instance directory is owned by that instance's own uid, so no other |
| +// app on the box can write in it or replace it; |
| +// - that instance is stopped under the fence for the whole of the |
| +// cleanup, so its own uid runs nothing; |
| +// - root and the box agent are trusted for this invariant. They are the |
| +// ones proving it. |
| +// |
| +// A flat data directory breaks the first point: every app on the box |
| +// writes there as one uid, and one of them could move the data aside |
| +// during the purge, or swap a child directory between the purge's stat of |
| +// it and its open, and so have an untouched copy counted as gone. No |
| +// amount of care in the purge closes that, which is why flat boxes take no |
| +// file seed. The flat location is still purged and proved here, and |
| +// PurgeProven still holds its descriptors and checks identity: both are |
| +// defence in depth, and they guard a box whose layout changed, but neither |
| +// is what the invariant rests on. |
| +// |
| // Anything else is "not proven": a hook missing, a fence that does not |
| // proceed, a row that appeared, a purge or a stat that fails, a listing |
| // error. It logs and returns, the record stays aborted and holds the |
diff --git a/internal/provision/seedfleet_linux_test.go b/internal/provision/seedfleet_linux_test.go| index 554953e6c..6ebc8c5aa 100644 |
| --- a/internal/provision/seedfleet_linux_test.go |
| +++ b/internal/provision/seedfleet_linux_test.go |
| @@ -736,14 +736,14 @@ func TestFleetFileSeedRowRetiredBeforeRollback(t *testing.T) { |
| s, sqid := setup(t) |
| rec := fleetFileSeedRecord(t, s, sqid, seeds.StateReady, "") |
| box := newFleetSeedBox(t, rec.Host) |
| - cfg := fleetSeedCfg(t, box, layoutFlat) |
| + cfg := fleetSeedCfg(t, box, layoutNested) |
| reg := regWith(t) |
| if err := Reconcile(ctx, s, reg, cfg); err != nil { |
| t.Fatal(err) |
| } |
| row := mustGet(t, reg, rec.Host) |
| - if row.DBPath != DefaultDBPath(cfg.DataDir, rec.Host) || row.Seed != "" || row.SeedSource != SeedColumn(rec) { |
| - t.Fatalf("flat fleet mint = db %q seed %q col %q", row.DBPath, row.Seed, row.SeedSource) |
| + if row.DBPath != NestedDBPath(cfg.DataDir, rec.Host) || row.Seed != "" || row.SeedSource != SeedColumn(rec) { |
| + t.Fatalf("nested fleet mint = db %q seed %q col %q", row.DBPath, row.Seed, row.SeedSource) |
| } |
| placeFleetSeedData(t, row.DBPath, rec.Seed.ID) |
| if _, err := SetRecordSeed(ctx, s, rec.Account, rec.App, rec.Host, SeedAbort(rec.Seed.ID)); err != nil { |
| @@ -767,8 +767,10 @@ func TestFleetFileSeedRowRetiredBeforeRollback(t *testing.T) { |
| requireSeedState(t, s, rec, seeds.StateAborted) |
| } |
| -// Rule 1: a flat customer-fleet box mints a ready file seed, flat. Every |
| -// other flat mint, and claim control, still refuse. |
| +// Rule 1, as Paul ruled after review round 3: a fleet file seed needs a |
| +// nested box. A flat customer-fleet box mints nothing for it, as no box |
| +// mints any seed flat; the record is left ready and untouched. Claim |
| +// control and a box that cannot report still refuse. |
| func TestFleetFileSeedMintLayout(t *testing.T) { |
| for _, c := range []struct { |
| name string |
| @@ -777,12 +779,12 @@ func TestFleetFileSeedMintLayout(t *testing.T) { |
| tweak func(*ReconcileConfig) |
| mints bool |
| }{ |
| - {name: "flat fleet box, file seed", kind: seeds.KindFile, layout: layoutFlat, mints: true}, |
| + {name: "flat fleet box, file seed", kind: seeds.KindFile, layout: layoutFlat}, |
| + {name: "fleet box with no layout intent, file seed", kind: seeds.KindFile, layout: release.LayoutModeNone}, |
| {name: "nested fleet box, file seed", kind: seeds.KindFile, layout: layoutNested, mints: true}, |
| {name: "flat fleet box, --from seed", kind: seeds.KindReplica, layout: layoutFlat}, |
| {name: "layout unreadable", kind: seeds.KindFile, layout: "!"}, |
| - {name: "claim control", kind: seeds.KindFile, layout: layoutFlat, tweak: func(c *ReconcileConfig) { c.ClaimEnabled = true }}, |
| - {name: "no fleet hooks", kind: seeds.KindFile, layout: layoutFlat, tweak: func(c *ReconcileConfig) { c.Seeds.Fleet = nil }}, |
| + {name: "claim control", kind: seeds.KindFile, layout: layoutNested, tweak: func(c *ReconcileConfig) { c.ClaimEnabled = true }}, |
| {name: "no fleet hooks, nested", kind: seeds.KindFile, layout: layoutNested, tweak: func(c *ReconcileConfig) { c.Seeds.Fleet = nil }}, |
| } { |
| t.Run(c.name, func(t *testing.T) { |
| @@ -794,7 +796,8 @@ func TestFleetFileSeedMintLayout(t *testing.T) { |
| if err := CreateRecord(ctx, s, rec); err != nil { |
| t.Fatal(err) |
| } |
| - cfg := fleetSeedCfg(t, newFleetSeedBox(t, rec.Host), c.layout) |
| + box := newFleetSeedBox(t, rec.Host) |
| + cfg := fleetSeedCfg(t, box, c.layout) |
| if c.tweak != nil { |
| c.tweak(&cfg) |
| } |
| @@ -806,8 +809,16 @@ func TestFleetFileSeedMintLayout(t *testing.T) { |
| if (rt != nil) != c.mints { |
| t.Fatalf("row = %+v; want minted %v", rt, c.mints) |
| } |
| - if rt != nil && rt.Seed != "" { |
| - t.Fatalf("a seeded row carries the seed command %q", rt.Seed) |
| + if rt != nil && (rt.Seed != "" || rt.DBPath != NestedDBPath(cfg.DataDir, rec.Host)) { |
| + t.Fatalf("the seeded row = seed command %q, db %q; want none, nested", rt.Seed, rt.DBPath) |
| + } |
| + if !c.mints { |
| + // Refused, and left exactly as it was: nothing reported, |
| + // nothing purged, the record still ready. |
| + if len(box.steps) != 0 { |
| + t.Fatalf("a refused mint did %q", box.steps) |
| + } |
| + requireSeedState(t, s, rec, seeds.StateReady) |
| } |
| }) |
| } |