spec: revision 2 for #1139 after review round 1
Accepts all six round-1 findings (dispositions §8): flat placement made safe (per-instance temp names and purge, layout-aware rollback), a rolledback door operation and defined failure semantics (retryable stays ready; terminal goes failed -> aborted -> rollback), readiness evidence in the fleet heartbeat plus a new seeds protocol and floor advance, the file kind taught to SeedReady/Unfinished/retirement checks, and docs/parity/UX.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+206
−26
docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md+145 −26docs/superpowers/specs/CODEX-FINDINGS-fleet-seeded-create-R1.md+61 −0
CI cancelled — superseded by a newer push — run details
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 129602813..3f7fac2fa 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 |
| @@ -1,6 +1,6 @@ |
| # Seeded instances on a customer fleet (#1139) |
| -Status: rulings given (Paul, 2026-11-20: yes to all five in §2); in review. Builds on the seeded-instances design |
| +Status: rulings given (Paul, 2026-11-20: yes to all five in §2). Revision 2, after review round 1 (findings: `CODEX-FINDINGS-fleet-seeded-create-R1.md`; dispositions §8). Builds on the seeded-instances design |
| (`2026-10-08-seeded-instances-design.md`, "the seeds spec" below) and the |
| fleet designs (`2026-10-29-fleet-public-routes-design.md`, |
| `2026-11-14-fleet-record-labels-design.md`). |
| @@ -84,6 +84,20 @@ stored, as every door does (§3.1's ordering, codex R3-2). The upload checks |
| length, sha256 and `lease.CheckDBContext` (integrity, at least one table), |
| writes the snapshot, and moves the seed to `ready` by CAS. |
| +**Every consumer of a seed kind learns `file`** (R1-5). Each gets a |
| +table-driven test row beside the existing kinds: |
| + |
| +- `provision.SeedReady` accepts `file` from `reserving` (today it is |
| + replica-only, `seed.go:166`). |
| +- `SeedSource.Unfinished` treats a `placed` file seed as finished, as it |
| + does a `placed` replica (`seed.go:72`). |
| +- The kind-specific retirement and purge checks that today name |
| + `KindReplica` (`provision/reconcile.go:1963`, |
| + `provision/seedreconcile.go:240`) name `KindFile` too. |
| +- A new `provision.SeedFail(id, reason)` moves a `file` seed from `ready` |
| + to `aborted`, setting `Reason` (§3.6). It never applies to an import, |
| + whose `SeedRefuse` is unchanged. |
| + |
| ### 3.3 Where it is stored |
| | App placement | Snapshot key | Bucket | |
| @@ -101,44 +115,118 @@ learn the second key. The sweep's three cases (§3.1) apply unchanged: a |
| Before writing any seed state, the console checks, for the app's placement: |
| - **a region:** the existing `seedRegionReady`; |
| -- **a customer fleet:** every active box of the fleet reports the seeds |
| - floor armed and `carlos.prev` seed-capable, read from the fleet's own |
| - evidence. **Open question:** whether a fleet box's edges file (or its |
| - heartbeat under `fleets/<fleet>/`) already carries those fields, or |
| - needs them added. The store door must also grant fleet boxes a read of |
| - `control/seeds-protocol.json`, so they can arm the floor at all. |
| +- **a customer fleet:** every active box registered to the fleet reports, |
| + in a fresh heartbeat, the seeds floor armed at the file-seed protocol or |
| + above, and `carlos.prev` either excluded or at that protocol or above. |
| + |
| +Fleet boxes skip the edges file (`host/edgesfile.go:1263`), and their |
| +heartbeat (`status/snapshot.go:651`) carries release information but not |
| +the floor (R1-4). So: |
| + |
| +- **The heartbeat gains three additive fields**, filled by the same code |
| + that fills the edges file's floor fields today |
| + (`host/edgesfile.go:478`): the armed floor's protocol, whether |
| + `carlos.prev` is excluded, and `carlos.prev`'s protocol. Absent fields |
| + read as "not ready". |
| +- **The console reads them** through the fleet-prefixed store it already |
| + uses for fleet heartbeats (`console/teamfloor.go:82`). Any active |
| + registered box with a missing, stale or short heartbeat makes the door |
| + answer 503 (unconfirmed) or 409 (below the floor), naming the boxes, as |
| + `seedRegionReady` does. |
| +- **The store door grants a fleet box a read of |
| + `control/seeds-protocol.json`**, so it can arm the floor at all. It is a |
| + deployment-wide control object with no account data in it. |
| +- **A new seeds protocol.** File seeds read a different key and report |
| + through a different door, so a binary that only knows the replica and |
| + import protocols must never place one. `seeds.RequiredProtocol` for a |
| + file seed is one above today's, and the door requires it. Rollout |
| + advances existing floors to it (§6). |
| The one-box rule of the seeds spec applies: the record must be ownable by a |
| single box (a `FleetBox` label, or the fleet's sole active box). |
| ### 3.5 The box |
| -The fleet box handles a `file` seed exactly as a region box handles a |
| -`--from` seed (§3.4's plain path), with two seams swapped: |
| +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: |
| + - **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** |
| + (`.seed-<base>-` prefix, any seed id, so an earlier aborted seed's |
| + leftover still goes). Today it removes every `.seed-sd_*.tmp*` in the |
| + directory (`activator/seedplace.go:395`), which on a flat box would |
| + 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. |
| 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 |
| of §3.3 through the store door (`fleetapi.Open`). The checks of §3.4 |
| step 2 are unchanged. |
| -2. **Recording progress.** On a fleet box, `placed` and `refused` go to a |
| - new console door instead of a store write: |
| +2. **Recording progress.** On a fleet box, the seed transitions the box |
| + makes go to a new console door instead of a store write: |
| - `POST /api/fleet/seeds/{account}/{app}/{host}/{placed|refused}` with |
| - the seed `id` (and, for `refused`, the reason). |
| + `POST /api/fleet/seeds/{account}/{app}/{host}/{placed|failed|rolledback}` |
| + with the seed `id`, and for `failed` the reason (§3.6). |
| It is authenticated like `replicaFleetRecord` |
| (`internal/console/replicacoordinator.go:22`): the tunnel name and |
| token must belong to the fleet the record is placed on, and the calling |
| - box must own the record. The console applies the existing |
| - `provision.Seed*` transition by CAS and, for `placed`, deletes the |
| - snapshot. A stale or repeated call is a no-op on the seed `id`. |
| + box must own the record: the record's `FleetBox` label names it, or |
| + the record has no label and the caller is the fleet's sole active box |
| + (`provision.SoleFleetBox`, which `replicaFleetRecord` already |
| + resolves). The console applies the transition by CAS: |
| + - `placed`: `SeedPlaced`, then deletes the snapshot; |
| + - `failed`: `SeedFail` (§3.6); |
| + - `rolledback`: `SeedRolledBack`, then deletes the snapshot if any, |
| + then finishes the record as `seedfinish.go` does today. |
| + |
| + A call naming another seed `id`, or a state the CAS does not accept, |
| + changes nothing and answers 409. A repeated call is a no-op. |
| The hub routes the path to the console as it does `/api/fleet/replicas` |
| (`edge.go:2412`). |
| Deleting the snapshot moves to the console on fleets because the store |
| door does not let a fleet box delete under `apps/<sqid>/`. |
| -### 3.6 What does not change |
| +### 3.6 Failure and abandonment on a fleet (R1-2, R1-3) |
| + |
| +**Retryable failures stay in `ready`.** A store-door read that fails, a |
| +disk or I/O error, a wake that dies: the wake fails and logs, as §3.4 of |
| +the seeds spec says, and the next wake retries from the snapshot. Nothing |
| +is reported. |
| + |
| +**Terminal failures go to `aborted`.** The snapshot's length or sha256 |
| +does not match the record, or `lease.CheckDBContext` rejects it. Retrying |
| +cannot fix either. The box reports `failed` with the reason; the console |
| +moves the seed `ready` → `aborted` with `Reason` set (`SeedFail`). The |
| +member sees the reason in `instances list`, as for a refused import. |
| + |
| +**Abandonment reaches `rolled-back` through the door.** A seed is |
| +`aborted` by `SeedFail`, by the console's deadline sweep (a `file` seed in |
| +`reserving` for more than an hour, as `--from`), or by the member |
| +(`instances delete` before placement). For an `aborted` file seed on a |
| +fleet, the owning box's reconcile runs the existing local rollback |
| +(purge the marker, temp files and any local database, §3.5 item 0), and |
| +only then reports `rolledback`. The console then deletes the snapshot and |
| +finishes the record, freeing the hostname. Local cleanup always |
| +completes before the hostname is released. |
| + |
| +**No box owns it.** If the fleet has no active box (or several and no |
| +label), nothing places or rolls back. The sweep's existing one-hour and |
| +seven-day bounds still abort the seed; the console then finishes an |
| +`aborted` file seed that no box has placed itself, since no box holds |
| +anything for it (the record never left `ready` on any box). |
| + |
| +### 3.7 What does not change |
| - Import, `--replaces`, the swap, the gate and commit, everywhere. |
| - `--from`, everywhere (it keeps refusing on fleets). |
| @@ -172,19 +260,50 @@ door does not let a fleet box delete under `apps/<sqid>/`. |
| - Box: a fleet box reads the snapshot through a fake store door, places |
| it, and reports `placed` to a fake console door; a failed check reports |
| `refused` and never starts an empty database. |
| +- Flat: two seeds placing at once in one shared directory both succeed; |
| + an earlier seed's leftover temp file is purged. |
| +- Failure: a corrupted snapshot reports `failed`, the seed goes to |
| + `aborted`, the box rolls back and reports `rolledback`, the record is |
| + finished, the hostname is free. |
| +- Abandonment: an upload that never finishes is aborted by the sweep and |
| + finished; a member's delete before placement does the same. |
| +- Readiness: a fleet with one box missing the new heartbeat fields, or |
| + below the protocol, refuses with the box named. |
| +- Lifecycle: table rows for `file` in `SeedReady`, `Unfinished`, |
| + `SeedFail` and the retirement checks. |
| - End to end on dev: a fleet-placed app, `create --seed-file`, first wake, |
| the replica in the fleet's bucket, the snapshot gone. |
| ## 6. Rollout |
| -1. Box release first; then publish the seeds floor where it is not yet |
| - published; then the console. Dev before flagship (README, rollout). |
| +1. Box release first. Then publish or advance the seeds floor to the |
| + file-seed protocol on every deployment, once every box (rollback |
| + binaries included) runs that release. Then the console. Dev before |
| + flagship (README, rollout). |
| 2. Eleven's fleet arms the floor, then Eleven seeds its four services. |
| -## 7. Open questions |
| - |
| -1. Does a fleet box already report the seeds floor fields the console's |
| - readiness check needs (§3.4)? |
| -2. Should `--seed-file` also be offered for region apps in this change, or |
| - kept fleet-only at first? This draft allows both, since the region path |
| - is the import door's storage with `--from`'s states. |
| +## 7. Docs, parity and copy (R1-6) |
| + |
| +- `docs/site/cli.md`: `--seed-file` under the existing `instances create` |
| + heading, with the fleet and region cases. |
| +- `parity/parity.tsv`: rows for `POST /api/fleet/seeds/...` (box-only, no |
| + CLI) and for the create flag; `make parity-doc`. |
| +- New CLI output (the waiting line, the refusal sentences) goes through a |
| + UX pass in the mockup kit, then copy review, before implementation |
| + (AGENTS.md:378-419). Strings are pinned in `approved_*_copy_test.go`. |
| +- Region apps get `--seed-file` too: the region path is the import door's |
| + storage with `--from`'s states, and keeping one command for both |
| + placements is simpler to explain. |
| + |
| +## 8. Round 1 dispositions |
| + |
| +Findings: `CODEX-FINDINGS-fleet-seeded-create-R1.md`. |
| + |
| +| Finding | Disposition | |
| +|---|---| |
| +| R1-1 P1 flat placement and purge | Accepted: §3.5 item 0 (layout gates, per-instance temp names and purge, rollback path, concurrent test) | |
| +| R1-2 P1 no route to `rolled-back` | Accepted: `rolledback` door operation, §3.6 | |
| +| R1-3 P1 `refused` undefined for `file` | Accepted: `failed` → `SeedFail` → `aborted` → rollback, retryable vs terminal defined, §3.6 | |
| +| R1-4 P2 readiness evidence, protocol | Accepted: heartbeat fields, fleet readiness, store-door read of the floor, new protocol, floor advance, §3.4 and §6 | |
| +| R1-5 P2 lifecycle consumers | Accepted: §3.2 list and table tests | |
| +| R1-6 P2 docs, parity, UX | Accepted: §7 | |
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-fleet-seeded-create-R1.md b/docs/superpowers/specs/CODEX-FINDINGS-fleet-seeded-create-R1.md| new file mode 100644 |
| index 000000000..a6561f2cf |
| --- /dev/null |
| +++ b/docs/superpowers/specs/CODEX-FINDINGS-fleet-seeded-create-R1.md |
| @@ -0,0 +1,61 @@ |
| +1. **P1 — §3.5–3.6: unchanged placement and purge rules do not support flat fleets.** |
| + |
| + **Evidence:** `internal/provision/seedreconcile.go:151` refuses a ready seed’s mint unless nested; `internal/activator/seedplace.go:160` independently refuses flat placement. Beyond those gates, `internal/activator/paths.go:41` keeps flat instances in the shared data directory, while `internal/activator/seedplace.go:395` deletes **every** `.seed-sd_*.tmp*` entry in that directory. |
| + |
| + **Failure scenario:** With the proposed two seam changes alone, a flat fleet never places the seed. Merely relaxing the layout gates introduces another failure: concurrent first wakes of instances A and B let B’s purge unlink A’s in-progress snapshot, causing A’s placement to fail. |
| + |
| + **Concrete fix:** Explicitly adapt both layout gates for customer fleets while retaining claim/foreign-layout refusals. Scope temporary files and their cleanup to the destination instance, including leftovers from earlier seed IDs. Test overlapping placements on one flat box. Also adapt rollback’s hard-coded `NestedDBPath` (`internal/provision/seedreconcile.go:291`). |
| + |
| + **Fault family:** Instance-local placement and cleanup must remain isolated when instances share a directory. |
| + |
| +2. **P1 — §3.2–3.5: abandoned fleet seeds have no permitted route to `rolled-back`.** |
| + |
| + **Evidence:** The new door exposes only `placed|refused` (design:126). Existing abandonment deletes from `cfg.Seeds.Data` and directly calls `SetRecordSeed(...SeedRolledBack...)` (`internal/provision/seedreconcile.go:246` and `:252`). Fleet record writes remain forbidden by `internal/edge/storedoor.go:807` and `:840`. Console finishing requires `rolled-back` (`internal/console/seedfinish.go:84`). |
| + |
| + **Failure scenario:** A client begins an upload and disappears. After an hour the sweep aborts its reservation, but the fleet box cannot record rollback through the store door. The record indefinitely holds the hostname, preventing a fresh create. Teaching the console finish the new snapshot key does not repair this missing transition. |
| + |
| + **Concrete fix:** Define an authenticated, owner-checked rollback-completion operation, with local cleanup completed before its CAS; let the console delete the snapshot and finish afterward. Cover abandoned reservations and interrupted placement. Include `file` in the existing replica-kind-specific retirement and purge checks (`internal/provision/reconcile.go:1963`, `internal/provision/seedreconcile.go:240`). |
| + |
| + **Fault family:** Abandonment must complete cleanup before releasing the hostname. |
| + |
| +3. **P1 — §3.5 and §5: the proposed `refused` operation cannot apply the existing transition to a `file` seed.** |
| + |
| + **Evidence:** `provision.SeedRefuse` accepts only `KindImport` in `ready` (`internal/provision/seed.go:208`). Plain placement failures return errors without recording refusal (`internal/activator/seedplace.go:101`). Once a seed becomes `refused`, reconcile skips it (`internal/provision/seedreconcile.go:131`); the sweep only expires replica reservations and imports awaiting upload/stop (`internal/console/seedsweep.go:104`). |
| + |
| + **Failure scenario:** The promised failed-check test cannot pass using the existing transition: a `file` refusal conflicts. Simply widening that transition instead leaves the seed permanently skipped, with no specified retry or abandonment path. |
| + |
| + **Concrete fix:** Define file-placement failure semantics explicitly: which failures remain retryable in `ready`, which become terminal, and how terminal failures reach cleanup. Implement the corresponding typed transition and reporting hook without changing import semantics. |
| + |
| + **Fault family:** Every reachable seed state needs a defined recovery or terminal-cleanup path. |
| + |
| +4. **P2 — §3.4, §6 and §7: resolve the readiness evidence and require the release implementing this feature.** |
| + |
| + **Evidence:** Fleet boxes skip edges-file publication (`internal/host/edgesfile.go:1263`). Their heartbeat exposes release/previous-release information but not the seeds-floor fields (`internal/status/snapshot.go:651`); those fields currently live in `edgesFile` (`internal/host/edgesfile.go:478`). The console already reads fleet heartbeats through a fleet-prefixed store (`internal/console/teamfloor.go:82`). Existing seeds protocols predate file seeds (`internal/seeds/floor.go:18`), and the old reader uses the regional snapshot key (`internal/host/seedwiring.go:35`). |
| + |
| + **Failure scenario:** The readiness check cannot obtain its promised evidence today. Moreover, publishing only where no floor exists leaves an existing floor capable of admitting a rollback binary that cannot read fleet snapshots. |
| + |
| + **Concrete fix:** Specify additive heartbeat fields and their producer, freshness/completeness checks against every active registered box, and rejection of missing evidence. Require a feature-specific protocol/release minimum for the running and recovery binaries; advance existing floors during rollout too. |
| + |
| + **Fault family:** Admission evidence must prove support for the exact persistent protocol being introduced. |
| + |
| +5. **P2 — §3.2: enumerate the new kind’s lifecycle consumers.** |
| + |
| + **Evidence:** `SeedReady` is replica-kind-specific (`internal/provision/seed.go:166`), and `Unfinished` recognizes only placed replicas or committed imports/demo claims as finished (`internal/provision/seed.go:72`). |
| + |
| + **Failure scenario:** Reusing `SeedReady` rejects a file upload’s publication; leaving `Unfinished` unchanged makes even a successfully placed file seed permanently unfinished. |
| + |
| + **Concrete fix:** Specify the file-kind transition and terminal-state predicate changes, with table-driven coverage alongside existing kinds. |
| + |
| + **Fault family:** All consumers of a persistent seed kind must agree on its lifecycle. |
| + |
| +6. **P2 — §5–6: include the required interface documentation and UX work.** |
| + |
| + **Evidence:** The design adds console routes and human-facing CLI behavior but omits parity/documentation and UX/copy steps. `AGENTS.md:554` requires parity rows for new console route declarations; `AGENTS.md:389` requires a UX pass for CLI output. |
| + |
| + **Failure scenario:** Implementation reaches review without required route coverage or reviewed user-facing behavior. |
| + |
| + **Concrete fix:** Add parity rows for the new doors, document `--seed-file` under the existing create command in `docs/site/cli.md`, regenerate parity documentation, and schedule UX/copy review before implementation. |
| + |
| + **Fault family:** Public interfaces must ship with their documentation and review requirements. |
| + |
| +NOT READY |
| \ No newline at end of file |