carlos / platform Public

spec: seeded instances on a customer fleet (#1139)

Human

Prompt

build #1139 (instances import for apps on a customer fleet) in this session.

From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.

Summary

draft design — a fresh  on fleets, snapshot in the
deployment bucket under apps/<sqid>/, a console door for the fleet box's seed
transitions, flat allowed on single-tenant fleets. Rulings asked of Paul in §2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c6a969abb7a1ca614043859aeda62e64dbdec9ef parent cdf9818
1 file changed, +190 −0
  • docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md +190 −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
new file mode 100644
index 000000000..e5345740c
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-20-fleet-seeded-create-design.md
@@ -0,0 +1,190 @@
+# Seeded instances on a customer fleet (#1139)
+
+Status: draft for review. 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`).
+
+## 1. The problem
+
+An account that brings its own fleet usually brings existing data with it.
+Today it cannot start an instance on its fleet from that data:
+
+- `carlos instances import` refuses any app placed on a fleet or in a pool
+ (`internal/console/apiinstanceimport.go:114`, `apiinstanceseed.go:118`).
+- Even without that refusal, import is the wrong shape. It takes over a
+ route that already points at an address on one platform box
+ (`--replaces host:port`, the swap and the verify gate of the seeds spec
+ §5.4). A fleet app has no such route. What the account wants is a new
+ instance that starts from a database file.
+
+The first user is Eleven (account `bdr`, fleet `eleven`). Its 17 chat
+spaces are already on its fleet: they were hibernating, so their replicas
+were already in the fleet's bucket and a fleet box restored them. What is
+left is four shared services (a push relay, an OAuth broker, a passkey
+backup server and a provisioner). Each has a small SQLite database (tens of
+MB at most) on a machine the platform never ran.
+
+## 2. Rulings asked of Paul
+
+1. **A fresh seeded create, not import.** `carlos instances create --app A
+ --host H --seed-file <db>` creates a new instance whose database starts
+ as the file. It follows `--from`'s state path, not import's: no
+ `--replaces`, no swap, no gate, no commit.
+2. **Where the snapshot lives on a fleet.** The seeds spec keeps snapshots
+ in the home region's data bucket (§3.1). A fleet has no home region, and
+ its own bucket is one the console cannot write. So for a fleet app the
+ console writes the snapshot to the deployment bucket at
+ `apps/<sqid>/<app>/seeds/<host>/<id>/snapshot.db`. The fleet box can
+ already read anything under `apps/<sqid>/` through the store door
+ (`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.
+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
+ there today. A fleet box reports them to a new console door instead
+ (§3.5).
+5. **`create --from <sibling>` on a fleet stays out of scope.** It needs a
+ box to copy a replica inside the fleet's own bucket, which is a
+ different piece of work. It keeps refusing, with its current message.
+
+## 3. Design
+
+### 3.1 The command
+
+```sh
+carlos instances create --app push --host push.bdr.example.com --seed-file push.db [--environment push]
+```
+
+- `--seed-file` is mutually exclusive with `--from`, and accepted only
+ with the instance kind.
+- The CLI reads the file, hashes it, and uses the import door's two calls:
+ begin, then a streamed upload. Begin carries the seed's sha256 and
+ length. Nothing in the request names a bucket or a key (the seeds spec,
+ ruling 2).
+- It waits for `ready`, then prints the instance as `create` does. It does
+ not wait for `placed`: placement happens on first wake, as for `--from`.
+- Every other check of `create` runs first (manifest, domain, quota,
+ environment rules of the seeds spec ruling 4).
+
+### 3.2 The record
+
+`SeedSource.Kind` gains `"file"`. Its path is `reserving` → `ready` →
+`placed`, with `aborted` → `rolled-back` for an abandoned seed, exactly as
+`--from` (the seeds spec §3.2). `Replaces` and `VerifyHash` stay empty.
+
+The begin door writes the record as `reserving` before any snapshot byte is
+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.
+
+### 3.3 Where it is stored
+
+| App placement | Snapshot key | Bucket |
+|---|---|---|
+| a region | `seeds/<host>/<id>/snapshot.db` | the region's data bucket, as today |
+| a customer fleet | `apps/<sqid>/<app>/seeds/<host>/<id>/snapshot.db` | the deployment bucket |
+
+The console's finish (`seedfinish.go`) and deadline sweep (`seedsweep.go`)
+learn the second key. The sweep's three cases (§3.1) apply unchanged: a
+`file` seed stuck in `reserving` for more than an hour is aborted, as
+`--from` is.
+
+### 3.4 Readiness and the floor
+
+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.
+
+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:
+
+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:
+
+ `POST /api/fleet/seeds/{account}/{app}/{host}/{placed|refused}` with
+ the seed `id` (and, for `refused`, the reason).
+
+ 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`.
+ 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
+
+- Import, `--replaces`, the swap, the gate and commit, everywhere.
+- `--from`, everywhere (it keeps refusing on fleets).
+- Region placement of `file` seeds uses today's keys and checks.
+- Placement itself (§3.4 steps 1 to 4), the marker, the purge rules and
+ failure handling.
+
+## 4. Security
+
+- Bytes pass through the console only; nothing a request supplies picks a
+ bucket or key (the seeds spec ruling 2).
+- The deployment bucket holds the account's database for the time between
+ upload and placement. The snapshot is deleted on `placed`, and the sweep
+ bounds an abandoned one. This matches what import already does for
+ region apps.
+- The new door trusts only an authenticated fleet identity for the fleet
+ the record is placed on, and acts only on the seed `id` the record
+ names.
+- Flat layout on a customer fleet: one tenant per box (ruling 3).
+- Root: the box changes touch the seed path the agent runs. Each changed
+ unit gets a census claim (AGENTS.md, the census).
+
+## 5. Testing
+
+- Console: begin and upload for a fleet app write the record and the
+ snapshot under §3.3's key; a region app is unchanged; `--from` on a
+ fleet still refuses; readiness refuses a fleet with a box below the
+ floor.
+- Door: a call from another fleet, another box, or with a stale seed id
+ changes nothing; `placed` deletes the snapshot once.
+- 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.
+- 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).
+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.