docs: fleet record labels rev 3 (final), release manager rulings
Carries the release manager's rulings on Astra's round 2 review of 6a920bd5. Adds binding requirements R1-R4: the stale unlabelled wake fence at currentWakeRoute, restore-required first labels and a proven final checkpoint before lease release on fleet rows, verified stateless eligibility through relabel and drain, and a box floor for labels. Scopes v1 to labelling only the box the binding and hub stamp agree is serving. Corrects the seed, demo, host-claim and create exceptions, states the rollback floor and non-atomic steps, and revises the copy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+388
−413
docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md+388 −413
CI cancelled — superseded by a newer push — run details
diff --git a/docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md b/docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md| index eda897704..24c7b84b6 100644 |
| --- a/docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md |
| +++ b/docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md |
| @@ -1,442 +1,417 @@ |
| -# Fleet record labels: the owner ties a fleet instance to a box |
| - |
| -Rev 2, 2026-11-14, for review round 2 of 3 (stopping rule 1). Rev 1 |
| -(`f484c4c2`) had the lease holder label itself through a box door. Astra's |
| -round 1 found four P1s in that design: stale ownership, a forgeable |
| -binding, the old worker labelling behind it, and growth guessing the box. |
| -The release manager chose option B: owner-authorized labelling, CLI first. |
| +# Fleet record labels: the owner ties a fleet instance to its serving box |
| + |
| +Rev 3 (final), 2026-11-14. The review is closed after round 2 (stopping |
| +rule 1). Rev 1 (`f484c4c2`) had the lease holder label itself, and Astra's |
| +round 1 found four P1s. Rev 2 (`6a920bd5`) moved to owner-authorized |
| +labelling (option B). Astra's round 2 found two data-safety P1s and a list |
| +of corrections. The release manager ruled on them, and this revision |
| +carries those rulings: binding requirements R1-R4, and a v1 scope that |
| +labels only to the serving box. The stale-wake invariant appeared in both |
| +rounds, so it is enforced at one start gate with a deterministic witness |
| +(R1). No further round. |
| Discussion #1008. Builds on managed fleets 1b |
| (`2026-10-28-managed-fleets-design.md` §4) and stateless replicas (F8). |
| The guard on branch `stateless-unlabelled-guard` (read at `d0ff269a`, not |
| -merged) is a prerequisite; the plan waits for it (stopping rule 4). |
| -References are to `main` at `d6c6f3f2`. **Verified**: read at that line. |
| -**Inferred**: reasoned from the code, not yet exercised; the plan pins each |
| -with a test. |
| +merged) is a prerequisite, held to its merged contract only (stopping |
| +rule 4). References are to `main` at `d6c6f3f2`. **Verified**: read at |
| +that line. **Inferred**: reasoned from the code, not yet exercised; the |
| +plan pins each one with a test. |
| ## 1. The problem |
| -An "unlabelled" record is on a fleet (Region `fleet/<name>`) with no |
| -`fleet_box` and no `replica_assignment`. Every box of the fleet carries it |
| -(`ownsRecord`, `internal/provision/reconcile.go:549-557`), and the |
| -coordinator door accepts it only on a one-box fleet |
| -(`internal/console/replicacoordinator.go:45-50`), so on a larger fleet a |
| -stateless build of it never wakes. Verified. That was #1008's 16-minute |
| -staging outage. The guard refuses stateless, copies above 1 and growth for |
| -such records (`appcopies.go`, guard branch); nothing labels them, so they |
| -stay refused. |
| - |
| -Today a record gets its first label at create, only when the fleet-wide |
| -gate is open (`internal/console/apiinstances.go:2158-2176`, `:2511-2530`; |
| -seeds and imports never, `:2476-2492`), or from the relabel worker, which |
| -labels to whatever box the binding names (`internal/console/fleetrelabel.go:157-166`, |
| -`:194-217`). Both write through `SetRecordFleetBox` |
| -(`internal/provision/fleetbox.go:51-79`). Verified. |
| +An "unlabelled" record is placed on a fleet (Region `fleet/<name>`) and |
| +has no `fleet_box` and no `replica_assignment`. |
| + |
| +- Every box of the fleet carries it (`ownsRecord`, |
| + `internal/provision/reconcile.go:549-557`). |
| +- The coordinator door accepts it only on a one-box fleet |
| + (`internal/console/replicacoordinator.go:45-50`), so on a larger fleet a |
| + stateless build of it never wakes. That was #1008's 16-minute staging |
| + outage. |
| +- The guard refuses stateless, more than one copy and growth for these |
| + records, and nothing labels them, so they stay refused. |
| + |
| +Verified. First labels come only from create, when the fleet-wide gate is |
| +open (`internal/console/apiinstances.go:2158-2176`, `:2511-2530`), and from |
| +the relabel worker, which labels to whatever box a binding names |
| +(`internal/console/fleetrelabel.go:157-166`, `:194-217`). |
| ## 2. Trust assumption |
| -**The owner decides placement**, as owners already place apps on fleets |
| -(`internal/console/fleets.go:1148`, owner only) and add, drain and detach |
| -boxes. |
| - |
| -**The console does not prove which box holds the serving lease.** The |
| -lease lives in the fleet's own data bucket (`internal/lease/lease.go:1-12`, |
| -`lockstate.go:47`). The console never reads that bucket: its only lease |
| -read is the platform's hibernation bucket |
| -(`internal/console/seedfinish.go:285`). Verified. That it has no |
| -credential for a bring-your-own fleet bucket is inferred. |
| - |
| -**A wrong choice costs one handover, never two writers.** If the owner |
| -names a box that is not serving the instance, the serving box drops its |
| -row and stops the instance with a final checkpoint and lease release |
| -(`RetireExcept`, `internal/activator/activator.go:6167-6177`). The named |
| -box wakes it on the next request and restores from the fleet bucket (start |
| -rule, `internal/activator/startrule.go:175-222`). The lease still excludes |
| -concurrent writers throughout. Verified for each step; the end-to-end |
| -sequence is inferred and is the main witness (§10). |
| - |
| -**Bindings and hub stamps are evidence for the proposal, never |
| -authority.** A fleet box can write any binding under its fleet's prefix |
| -(`internal/edge/storedoor.go:807`), including one naming itself for an |
| -instance it does not serve. The agent's startup pass writes bindings with |
| -no lease behind them (`internal/host/fleetbind.go:408-449`). The hub's |
| -stamp is copied from bindings (`ReconcileFleetBindings`, `:269-357`). |
| -Verified. Records and bindings are not a tenancy boundary (#1007). The |
| -dry run reads them to propose a box. Nothing writes a label from them. |
| - |
| -## 3. The command |
| +- **The owner decides placement**, as owners already place apps on fleets |
| + (`internal/console/fleets.go:1148`, owner only). |
| +- **The console does not prove which box holds the serving lease.** The |
| + lease is in the fleet's own data bucket (`internal/lease/lockstate.go:47`). |
| + The console's only lease read is the platform's hibernation bucket |
| + (`internal/console/seedfinish.go:285`). Verified. That the console has no |
| + credential for a bring-your-own fleet bucket is inferred. |
| +- **Bindings and hub stamps are evidence, not proof.** A fleet box can |
| + write any binding under its fleet (`internal/edge/storedoor.go:807`), and |
| + the startup pass writes bindings with no lease behind them |
| + (`internal/host/fleetbind.go:408-449`). The hub's stamp is copied from |
| + bindings (`:269-357`). Records and bindings are not a tenancy boundary |
| + (#1007). |
| +- **If the evidence is wrong, the label is in effect a move.** R1 and R2 |
| + make a move safe. The lease still excludes a second writer. R1 keeps a |
| + stale box from waking on an old copy. R2 keeps the destination from |
| + starting empty and keeps a failed checkpoint from passing as clean. The |
| + cost is at most one handover: the old box stops with a checkpoint and the |
| + named box restores. |
| + |
| +## 3. Binding requirements |
| + |
| +**R1. Stale unlabelled wakes are fenced at one start gate.** Today |
| +`currentWakeRoute` returns early for a row with no `Assigned` and no |
| +`FleetBoxes` (`internal/activator/wakeidentity.go:221-223`). `restorePlain` |
| +then keeps any local database as a warm cache |
| +(`internal/activator/backend_exec.go:1034-1042`). So a box whose row has |
| +not yet converged can wake an older copy after the record names another |
| +box. Verified. |
| + |
| +The fix: on a fleet box (`a.Fleet.Mode == FleetWakeCheck`), an unlabelled |
| +fleet-placed row's wake reads the record (one GET, |
| +`FleetRecordFrom`, `:278-286`) inside `currentWakeRoute`. The wake is |
| +refused with `errRouteChangedUnderLease` when the record: |
| + |
| +- carries any `FleetBox`, even this box's, since the row has not |
| + converged and must wake on the labelled path; |
| +- carries a `ReplicaAssignment`; |
| +- is retired, or cannot be read. |
| + |
| +`currentWakeRoute` already runs under the acquired lease and before |
| +restore or start (`activator.go:3002`, restore at `:3030`). Its other |
| +callers, the stateless and worker paths (`stateless.go:341`, |
| +`rootfsworkers.go:478`), get the same check. One gate, no second copy. |
| + |
| +**R2. A first label never starts empty, and a failed checkpoint is not |
| +clean.** |
| + |
| +- The new writer (§5) sets `FleetBoxAt` to the write time and |
| + `FleetBoxMoved = true`. The start rule already honours `Moved`: with no |
| + kept copy and no replica, it refuses an empty start |
| + (`internal/activator/startrule.go:333-376`; the refusal wraps |
| + `ErrNothingToRestore`). A label to the box that was serving sets that |
| + box's unmarked copy aside at its next wake and restores |
| + (`startrule.go:175-222`). Any destination with no local copy, no |
| + set-aside copy and no replica refuses to start. Recovery is an |
| + operator's (the refusal names the set-aside path); a start-empty override |
| + stays follow-up #481. |
| +- `Replicator.Close` releases the lease even when its final sync fails |
| + (`internal/lease/lease.go:646-676`), so acquiring a released lease does |
| + not prove the predecessor's last writes reached the bucket. Verified. |
| + For fleet-placed rows, a stop's final checkpoint must succeed before the |
| + lease is released. On failure, the stop stays pending, with the process |
| + already stopped and the lease renewing. The sweep retries it, as HA stops |
| + already do (`activator.go:5415-5424`, `keepPendingLocked`). At shutdown an |
| + unproven checkpoint leaves the lease to its TTL instead of releasing it, |
| + and logs an ERROR naming the host. This does not certify the bucket |
| + holds the newest state if the box then dies. It stops the platform from |
| + treating a failed checkpoint as a clean handover. |
| + |
| +**R3. Stateless eligibility is carried everywhere a label is acted on.** |
| +`movable` admits an always-on stateless binary only with its verified |
| +manifest (`internal/console/fleetbox.go:178-190`). The relabel worker |
| +(`fleetrelabel.go:175`) and `drainBox` (`:485`) call `movable(rec)` |
| +without one, so a labelled always-on stateless record is stranded on a |
| +lost or draining box. Replica placement does nothing for one copy with no |
| +assignment (`internal/console/replicaplacement.go:246-249`). Verified. |
| + |
| +Both call sites pass the verified selected manifest (`replicaSelected`, |
| +`replicaplacement.go:566-583`) for always-on records. A labelled |
| +one-copy stateless record then moves like any other. A manifest that |
| +cannot be verified leaves the record where it is, logged, as an unmovable |
| +record is today. |
| + |
| +**R4. Box floors.** R1-R3 are box behaviour, so a label is written only |
| +when every active box of the record's fleet, and the console, report at |
| +least `FleetRecordLabelFloor`. That is a new constant in |
| +`internal/release/layoutintent.go`, set to the release that carries R1-R3. |
| +It is above the stateless runtime floor v0.34.0 (`layoutintent.go:403`) and |
| +the label floor v0.33.0 (`:277`). Heartbeats come from a complete view |
| +(§5). |
| + |
| +## 4. v1 scope: label only to the serving box |
| + |
| +The owner may tie an unlabelled record only to the box the evidence names |
| +as serving now. Both of these must name the same box, which must be |
| +active, fresh, not draining and eligible: |
| + |
| +- the binding `fleets/<f>/bindings/<host>.json`, written for this fleet |
| + and host after the record's `CreatedAt` (the worker's test, |
| + `fleetrelabel.go:208`); |
| +- the hub's forward-row stamp (`internal/provision/forward.go:29-69`). |
| + |
| +A `--box` naming any other box is refused, because moving an instance |
| +comes later. When the binding and stamp disagree, or either is missing, |
| +the label is refused: wait for the instance to settle (the hub copies |
| +bindings every 5 to 6 minutes, `internal/host/agent.go:4475`), or wake it |
| +once and try again. The evidence is not proof. If it is wrong, R1 and R2 |
| +make the label a safe move (§2). |
| + |
| +## 5. The command and the door |
| ``` |
| carlos instances label --app <a> <host> [--box <b>] [--dry-run] |
| ``` |
| -This follows the newer instance verbs, which take the host as a |
| -positional argument after `--app` (`instances retry`, |
| -`instances_cli.go:1216-1239`; usage block `:221-233`). It has the usual |
| -`--console`, `--account` and `--account-id` flags. |
| - |
| -Without `--box` it only proposes. With `--box --dry-run` it also says what |
| -tying to that box would do. Neither writes. With `--box` alone it answers |
| -the same, then writes. |
| - |
| -**API.** `POST /api/cli/apps/{account}/{app}/instances/{host}/label`, |
| -body `{"box": "...", "dry_run": true|false}`, declared in |
| -`internal/console/routedecls.go` with `Kind: kindCLI` and |
| -`Allow: svcrole.Set{}`. People only, no service credential, as the fleet |
| -doors (`routedecls.go:915-920`). Verified pattern. Every answer, dry run or |
| -write, has one shape: `host`, `fleet`, `label` (empty while unlabelled), |
| -`binding` (`box`, `bound_at`, `after_create`, or null), `hub_box`, |
| -`agree`, `proposed`, the named `box` with `eligible` and `why_not`, |
| -`handover` (`none`, `yes` or `unknown`) and `applied`. `applied` is true |
| -only after the record write commits; a client must not read a 200 as |
| -applied. |
| - |
| -## 4. Authorization |
| - |
| -1. **Owner gate.** `apiOwnerAccountFor` (`internal/console/apiservices.go:127-138`): |
| - the caller is an owner of the account in the path, else 403. An unknown |
| - account, app or host, a record of another account, and a retired |
| - record all answer the same 404 (`apiAccountAppBy`'s rule). Verified |
| - helper. Owner only matches the placement door. The drain door admits |
| - any human member (`fleets.go:643` through `apiFleet`, `:89-99`), so see |
| - Q1. |
| -2. **The record's fleet.** The record's Region must be `fleet/<f>` and |
| - fleet `f` must belong to the same account (`registry.Fleet.Account`). |
| - A box of any other fleet is refused as "not an active box of fleet f". |
| -3. **Host-claim consoles are off.** The relabel worker is off there |
| - because no claim operation gates its record writes |
| - (`fleetrelabel.go:70-74`). This door, the create change and the worker |
| - change all follow it. |
| - |
| -## 5. The dry run: proposal from evidence |
| - |
| -The console reads three things: |
| - |
| -- **the binding**, `fleets/<f>/bindings/<host>.json` (one GET, |
| - `readFleetBinding`, `fleetrelabel.go:354-370`). It counts only when it |
| - names this fleet and host and was written after the record's |
| - `CreatedAt` (the worker's test, `:208`); |
| -- **the hub's forward row** for the host in the console's registry, its |
| - `FleetBox` stamp (no bucket request; `internal/provision/forward.go:29-69`); |
| -- **the fleet view**, for the named box's eligibility (D2 below). |
| - |
| -`agree` is true when the binding and the stamp name the same box. |
| -`proposed` is the binding's box when it is eligible, else the stamp's box |
| -when eligible, else empty. `handover` compares the named box with the |
| -binding's box. It is `none` when they match, `yes` when they differ, and |
| -`unknown` when there is no usable binding. |
| - |
| -Every answer says this is a proposal from what the boxes last reported, |
| -not proof of which box runs the instance now (C13). An owner of a |
| -bring-your-own fleet can check `lock.json` in their own bucket. The |
| -command never requires it (AGENTS.md, "Operate via API and CLI"). |
| - |
| -## 6. The write |
| - |
| -### D1. One typed transition, checked at write time |
| - |
| -A new provision writer, `SetRecordFirstFleetBox(ctx, s, acct, app, host, |
| -want FleetBoxExpect, label string, at time.Time)`, beside |
| -`SetRecordFleetBox` and sharing its `updateRecord` scaffold |
| -(`internal/provision/provision.go:1156-1207`). Inside every attempt, |
| -including a CAS retry, it refuses unless: |
| - |
| -- Region and `CreatedAt` equal `want` (the existing expectation, |
| - `fleetbox.go:53`); |
| +This follows the positional-host instance verbs (`instances retry`, |
| +`instances_cli.go:1216-1239`; usage block `:221-233`), with `--console`, |
| +`--account` and `--account-id`. |
| + |
| +- Without `--box`: a dry run that shows the evidence and the box it |
| + would accept. |
| +- With `--box --dry-run`: the same, plus whether that box would be |
| + accepted. |
| +- With `--box`: the write, when `--box` equals the evidence box. |
| + |
| +**Door.** `POST /api/cli/apps/{account}/{app}/instances/{host}/label`, |
| +body `{"box", "dry_run"}`, `Kind: kindCLI`, `Allow: svcrole.Set{}` (as the |
| +fleet doors, `routedecls.go:915-920`). Every answer has one shape: |
| + |
| +- `host`, `fleet`, `label`; |
| +- `binding` (`box`, `bound_at`, `after_create`) and `hub_box`; |
| +- `agree` and `serving_box` (set only when the two agree); |
| +- the named `box` with `eligible` and `why_not`; |
| +- `applied`. |
| + |
| +`applied` is true only after the record write commits. A 200 is not |
| +"applied". |
| + |
| +**Authorization.** `apiOwnerAccountFor` (`internal/console/apiservices.go:127-138`): |
| + |
| +- a non-owner member gets 403; |
| +- a non-member gets the resolver's indistinguishable 404; |
| +- every service role is refused by the empty `Allow`; |
| +- a fleet box token is not a CLI principal (`CLIPrincipal` resolves |
| + `cli_tokens` only, `internal/console/svcprincipal.go:105`). |
| + |
| +The owner gate checks the account, not the app or the record, so the door |
| +keeps the app's existence and linked-app checks, a judged record read, and |
| +the record's fleet belonging to the account (`registry.Fleet.Account`). An |
| +unknown or retired record is the same 404. Host-claim consoles answer |
| +"not available", as the relabel worker is off there |
| +(`fleetrelabel.go:70-74`). |
| + |
| +**Under `lockFleet(f)`** (`internal/console/fleetbox.go:217-222`): |
| + |
| +1. Read the box's registry row fresh: active and not draining. |
| +2. Load `loadFleetViewRequiredAt(ctx, f, now, true)` and **require |
| + `v.Complete`**. The call can return an incomplete view with a nil |
| + error. Then: |
| + - the box passes `destinationFor` (`fleetbox.go:128-133`); |
| + - the fleet holds no sidecars (rule 10); |
| + - `DeploymentCurrent` holds; |
| + - every active box of the fleet, and the console, are at |
| + `FleetRecordLabelFloor` (R4). |
| +3. Read the binding and the hub row, and apply §4. |
| +4. Check the record itself: `fleetLabelsRecord` and `movable` with the |
| + verified manifest (`fleetbox.go:167-190`). Rule 11 is applied per |
| + record. This amends 1b rule 11 (managed fleets spec line 246). Drain |
| + still refuses unmovable records one by one (`fleetrelabel.go:482-487`). |
| +5. To write: |
| + - `MarkFleetBoxLabelled`; |
| + - then `SetRecordFirstFleetBox`; |
| + - then `bumpSerial` (`internal/console/serialbump.go:32`). |
| + |
| +**`SetRecordFirstFleetBox`** is a new typed writer in |
| +`internal/provision/fleetbox.go`, sharing `updateRecord` |
| +(`internal/provision/provision.go:1156-1207`), which keeps the |
| +protected-field checks. On every attempt, CAS retries included, it refuses |
| +unless: |
| + |
| +- Region and `CreatedAt` equal what the door read; |
| - `FleetBox == ""` and `ReplicaAssignment == nil`; |
| -- `Move == nil` (`SetRecordFleetBox` does not check it; console moves |
| - refuse fleet records today, `internal/console/apiinstancemove.go:95-97`); |
| -- not `Retired` (a tombstone also clears Region and `CreatedAt`); |
| -- the seed does not block a move (`Seed.MoveBlock`, as `fleetbox.go:67-69`); |
| -- no unexpired `Coordinator` names another box |
| - (`internal/replicas/types.go:21-26`). |
| - |
| -`replicaFieldsFixed` (`internal/provision/record_sequence.go:143`) still |
| -guards the replica fields; the writer checks the assignment itself. |
| - |
| -### D2. Under the fleet lock, with fresh registry state |
| - |
| -The door holds `lockFleet(f)` (`internal/console/fleetbox.go:217-222`, |
| -the lock create, the worker and drain take). Under it, the door: |
| - |
| -1. reads the box's registry row fresh (`findFleetBox`), not from any |
| - cache. It must be active and not draining; |
| -2. loads the fleet view uncached (`loadFleetViewRequiredAt(..., |
| - requireComplete=true)`, `fleetbox.go:294`). The named box must be a |
| - destination (`destinationFor`, `:128-133`: fresh, not draining, at the |
| - label floor, and rootfs-ready for a rootfs record). The deployment must |
| - be at the label floor (rule 8, `DeploymentCurrent`), and the fleet must |
| - hold no sidecars (rule 10); |
| -3. checks the record per record (Q1 of round 1): `fleetLabelsRecord` and |
| - `movable` with the channel head's verified manifest when the head is |
| - stateless (`fleetbox.go:167-190`); |
| -4. for a write: `MarkFleetBoxLabelled` (so detach needs termination, |
| - `fleetrelabel.go:380-382`), then `SetRecordFirstFleetBox`, then |
| - `bumpSerial` (`internal/console/serialbump.go:32`) so boxes converge in |
| - seconds. |
| - |
| -The fleet lock is per console process; the registry row read and the |
| -record CAS cover anything outside it. |
| - |
| -### D3. What happens on the boxes |
| - |
| -- **Named box serves now (`handover: none`).** Its row's `Assigned` |
| - converges (`reconcile.go:1081`); only a wake reads it |
| - (`internal/activator/wakeidentity.go:104-125`), so the live process keeps |
| - running (inferred). At its next wake the start rule sets the local copy |
| - aside and restores once (`startrule.go:175-222`). With the marker rule |
| - cut (round 1, Q5) that costs one restore and one set-aside copy, never |
| - deleted (`startrule.go:21-23`). |
| -- **Named box does not serve now (`handover: yes`).** The serving box's |
| - scan skips the record and its removal phase retires the row |
| - (`reconcile.go:1409`, `:2662`). `RetireExcept` stops the live entry |
| - with a checkpoint and a lease release. Requests in flight on it are cut, |
| - as on a deploy restart (`activator.go:6167-6177` doc). The hub's forward |
| - row becomes labelled, so the edge dials only the named box |
| - (`internal/edge/edge.go:4389-4394`). The named box wakes it, waiting for |
| - the lease if the old box has not released it yet, and restores. One |
| - lease handover. Inferred end to end. |
| -- **Every other box** drops its row; only the lease holder has a live entry. |
| -- **A stale unlabelled wake.** Until the old box converges, it may still |
| - wake the instance unlabelled, because that path skips the record check |
| - under the lease (`wakeidentity.go:221-223`). That costs one extra stop, |
| - never two writers. The witness measures it (§10). Fencing it is Q4. |
| - |
| -## 7. The rest of the slice |
| - |
| -### D4. No unlabelled creates on multi-box fleets |
| - |
| -On a fleet with two or more active boxes, a create of a process record |
| -either gets a label at create or is refused with a retry. Nothing is |
| -written on a refusal. |
| - |
| -- **Labelled when a box qualifies.** `chooseDestination` picks a fresh |
| - survivor even when another box is stale (`fleetbox.go:143-160`). The gate |
| - stops closing for the whole fleet when one record on it is unmovable: |
| - rule 11 becomes per record (round 1, Q1). This amends 1b rule 11 |
| - (managed fleets spec, line 246). Drain keeps refusing unmovable records |
| - per record (`fleetrelabel.go:482-487`). |
| -- **Refused with a retry (503, `Retry-After: 30`)** when the view cannot |
| - be read whole, no box is a destination, the deployment is below the |
| - label floor, the fleet holds sidecars (rule 10), or |
| - `MarkFleetBoxLabelled` fails. Today each of these |
| - creates the record unlabelled (`apiinstances.go:2171`, `:2521-2528`). |
| - Verified. |
| -- **The always-on stateless gap (round 1, Q11).** Create calls |
| - `movable(rec)` without the verified manifest (`apiinstances.go:2511`), |
| - so an always-on stateless binary is created unlabelled. Verified by |
| - Astra. Create passes the channel head's manifest. A witness pins it. |
| -- **Exceptions, created unlabelled as today:** |
| - - static records, which every box serves from the bucket |
| - (`fleetbox.go:162-169`); |
| - - records `movable` rejects even with a manifest: `Addr`/`Addrs`, HA, |
| - demo, or a stateful binary that never hibernates. No process the |
| - platform moves (Q2); |
| - - seeded (`--from`) and imported creates. The seed lands on the box that |
| - places it. The record stays unlabelled until the import commits, and |
| - then the owner ties it with `carlos instances label`. The create answer |
| - says so (copy C30). The guard refuses stateless for it throughout. |
| - |
| -### D5. The worker's first labelling is turned off |
| - |
| -`relabelFleet` stops calling `planFirstLabelling` |
| -(`fleetrelabel.go:157-166`, the function `:194-217` goes). Its other half |
| -stays: a labelled record whose box is draining, lost or detached still |
| -moves (`:167-187`), and drain is unchanged. After this, the only ways a |
| -record gets its first label are a create on a qualifying fleet and the |
| -owner's command (round 1, Q4). |
| - |
| -### D6. Growth stays refused for affected records |
| - |
| -No growth labelling in this slice. The guard's `fleetGrowthRefusal` |
| -refuses a second box while a stateless unlabelled record runs on the |
| -fleet; the owner ties that record to the sole box first, then adds the |
| -box. The command accepts a one-box fleet: an owner decision, not the |
| -automatic labelling F8 rejected. Only the guard's merged behaviour is |
| -assumed. |
| - |
| -### D7. After labelling, stateless replicas accept the record |
| - |
| -- The coordinator door passes `rec.FleetBox == box` with no proof |
| - (`replicacoordinator.go:52-54`). `SetRecordCoordinator` and |
| - `SetRecordReplicaRelease` fence only an unlabelled fleet record or a |
| - label naming another box (`internal/provision/replicacoordinator.go:59`, |
| - `replicadeploy.go:43`). Verified. |
| -- Placement starts from `Boxes: [FleetBox]` |
| - (`internal/console/replicaplacement.go:109-110`), so raising copies |
| - keeps the labelled box. `SetRecordReplicaAssignment` refuses a set that |
| - drops it without retiring it (`replicaassignment.go:122`). Verified. |
| -- The guard's `anyUnlabelledFleetRecord` is false for a labelled record, |
| - so `--stateless` and `--copies` are accepted (guard branch). |
| - |
| -## 8. Cost |
| - |
| -Per command, on the console, with no new loop and no polling: |
| - |
| -| Step | Bucket GETs | PUTs | |
| +- `Move == nil` and the record is not `Retired`; |
| +- the seed does not block a move; |
| +- no unexpired `Coordinator` names another box; |
| +- `label` is a valid box label. |
| + |
| +It writes `FleetBox`, `FleetBoxAt` and `FleetBoxMoved = true` (R2). |
| + |
| +**What is not atomic** (say so in the plan and the copy): |
| + |
| +- **Registry membership and the record write.** They are not one |
| + transaction. The fresh row read and the fleet lock make them safe under |
| + the repository's assumption of one console process per deployment. |
| + `MarkFleetBoxLabelled` refuses a detached box but does not check |
| + draining. |
| +- **The mark outlives a failed write.** A label whose record write fails |
| + can still leave the box's `LabelledAt` set, which means its detach then |
| + asks for `--terminated` (`fleetrelabel.go:380-382`). "Nothing changed" |
| + in the copy means the record did not change. |
| +- **A failed serial bump** is only logged |
| + (`internal/console/serialbump.go:32`). Boxes then converge on the hourly |
| + pass. "Within seconds" is the healthy path, not a promise. |
| + |
| +## 6. The rest of the slice |
| + |
| +**D1. Create on multi-box fleets.** On a fleet with two or more active |
| +boxes, a create of a platform-run process record is labelled at create or |
| +refused with a 503 retry, before any record, environment or claim write. |
| +Refusals are for: |
| + |
| +- a view that is not complete; |
| +- no destination; |
| +- a deployment below the label floor; |
| +- sidecars on the fleet; |
| +- a failed mark. |
| + |
| +Today each of these creates the record unlabelled (`apiinstances.go:2171`, |
| +`:2521-2528`). A platform-run process the platform cannot place or move |
| +(a stateful binary that never hibernates, unit-backed, or HA) is refused |
| +on multi-box fleets (round 2, Q2). Existing records are unchanged. |
| + |
| +Create passes the channel head's verified manifest to `movable`, closing |
| +the always-on stateless gap at `apiinstances.go:2511`. These are |
| +unchanged: |
| + |
| +- static and `Addr`/`Addrs` records stay unlabelled (no process the |
| + platform runs); |
| +- seeded and imported creates are already refused on fleets |
| + (`seedPlacementRefusal`, `internal/console/apiinstanceseed.go:114-122`); |
| +- demos keep their own labelled path |
| + (`internal/console/demo_publish.go:193`); |
| +- host-claim consoles keep their create protocol, with D1 off there. |
| + |
| +**D2. The worker's first labelling is off.** `relabelFleet` stops calling |
| +`planFirstLabelling` (`fleetrelabel.go:157-166`), and that function goes. |
| +Its handling of lost, draining and detached boxes stays, with R3's |
| +manifest. **Rollback:** a console without D2 would resume ownerless |
| +labelling. So D2 ships in the first release of this slice, before the |
| +door. That release becomes this slice's rollback floor, recorded in the |
| +release notes and the release manager's roll recipe. A rollback goes no |
| +lower. |
| + |
| +**D3. Growth stays refused** for affected records. The owner ties the |
| +record to the sole box first (§4 accepts one-box fleets when the evidence |
| +agrees), then adds the box. The guard's growth refusal points at the new |
| +command (copy C40). |
| + |
| +**D4. After labelling, replicas accept the record.** |
| + |
| +- The coordinator door passes `rec.FleetBox == box` |
| + (`replicacoordinator.go:52-54`), and so do the provision writers |
| + (`internal/provision/replicacoordinator.go:59`, `replicadeploy.go:43`). |
| +- Placement starts from `[FleetBox]` (`replicaplacement.go:109-110`). |
| +- The guard passes a labelled record. |
| + |
| +Verified. |
| + |
| +## 7. Cost |
| + |
| +Per command, on the console. There is no loop and no polling. |
| + |
| +| Step | GETs | PUTs | |
| |---|---:|---:| |
| -| Record read for the answer (judged read) | 1 | 0 | |
| -| Binding read (dry run and write) | 1 | 0 | |
| -| Fleet heartbeats and deployment listing (fleet view) | one listing per heartbeat prefix and its GETs, as a multi-box create does today | 0 | |
| -| Write: `SetRecordFirstFleetBox` (read and CAS) | 1 | 1 | |
| -| Write: serial bump (`release.BumpSerial`, `serial.go:51`) | 1 | 1 | |
| +| Judged record read | 1 | 0 | |
| +| Binding read | 1 | 0 | |
| +| Fleet view (fleet and deployment heartbeat listings), as a multi-box create does today | per prefix | 0 | |
| +| Write: record read and CAS | 1 | 1 | |
| +| Write: serial bump (`internal/release/serial.go:51`) | 1 | 1 | |
| -The hub row is a registry read. A dry run costs the first three rows; a |
| -CAS retry adds a GET and a PUT; a handover adds the old box's stop |
| -checkpoint and one restore. Record and binding rows follow Astra's count; |
| -the fleet-view row is inferred from `fleetbox.go:294-390`. |
| +The hub row is a registry read. A dry run costs the first three rows. R1 |
| +adds one record GET per wake of an unlabelled row on a fleet box. That is |
| +per wake, not periodic. |
| -## 9. Rollout |
| +## 8. Rollout |
| Dev first, then flagship, then self-hosted operators. Nothing touches |
| production without the release manager's go. |
| -0. **Inventory, read only** (not done for this spec): `carlos fleets ls` |
| - and `fleets show` on dev and flagship; unlabelled records on multi-box |
| - fleets; host-claim consoles. Session notes say dev has r10r (one box) |
| - and leftover drill fleet rows whose boxes are gone. |
| -1. **Release** with the command, door, writer, D4 and D5. No runtime |
| - switch: the release is the switch-on (stopping rule 5), and the command |
| - acts only when an owner runs it. Rollback is the previous release; |
| - written labels stay and every box since v0.33.0 honours them. |
| -2. **Dev drill**, in a window booked on #421 through the release manager, |
| - with a temporary second box on r10r (Paul's scoped approval: account, |
| - instance type, duration, teardown; plus the hostname-history window). |
| - 1. While r10r has one box, create two stateful instances of a sample |
| - app (shop), unlabelled, each with a durable data sentinel row. Add |
| - box-2 (the guard allows it: the builds are stateful). Wake both. |
| - 2. Dry run each (`carlos instances label --app shop <host>`, then with |
| - `--box` and `--dry-run`). Check `agree` and `handover` against |
| - `lock.json` read on the box. |
| - 3. **No handover:** tie instance 1 to its lease holder. Witness: same |
| - process and generation, lease owner unchanged, sentinel present, the |
| - other box drops its row. |
| - 4. **Handover:** tie instance 2 to the other box under a steady GET |
| - loop. Witness: the lease owner changes once, the old box logs one |
| - stop with checkpoint, the sentinel survives, and failures are limited |
| - to requests in flight at the stop and during the one wake. |
| - 5. Refusals: a draining box, a stale box, a non-owner member, a seeded |
| - record before its import commits. Then ship `--stateless --copies 2`: |
| - accepted, each instance keeps its labelled box. |
| - 6. Teardown: `--copies 1`, drain box-2 and wait for it to finish, |
| - terminate the machine, then `detach-box --terminated`. |
| -3. **Flagship:** the release manager's roll, then the inventory again. No |
| +0. **Read-only inventory**, not done for this spec: |
| + - `carlos fleets ls` and `fleets show` on dev and flagship; |
| + - unlabelled records on multi-box fleets; |
| + - host-claim consoles. |
| + |
| + Session notes say dev has r10r (one box) and leftover drill rows. |
| +1. **Release A:** D2, R1, R2, R3 and the floor constant. This is the |
| + rollback floor. |
| +2. **Release B:** the writer, the door, the CLI and D1. The release is the |
| + switch-on (stopping rule 5). |
| + - **Owner:** the release manager. |
| + - **Target release and date:** recorded on #1008 before T1 starts. |
| +3. **Dev drill** (plan T9), in a window booked on #421 through the release |
| + manager. It needs a temporary box-2 on r10r, with Paul's scoped |
| + approval. It uses an advancing durable write sequence, not a fixed |
| + sentinel, and confirms each fixture is unlabelled before every step. |
| +4. **Flagship:** the release manager's roll, then the inventory again. No |
| labelling without the owning account's say. |
| -4. **Self-hosted operators.** First real use: an operator ties its one |
| - known unlabelled record on its staging fleet. Dry run, check |
| - `lock.json` in its own bucket, label, then its stateless trial. |
| - |
| -## 10. Witnesses |
| - |
| -- **Real two-box e2e**, with real activator orchestration around the real |
| - lease and backend (extending `internal/host/fleettwobox_e2e_test.go`). |
| - Tying to the non-serving box hands over once: one stop with checkpoint, |
| - one restore, the lease owner changes once, the data sentinel survives, |
| - and no request is lost beyond a single wake. Tying to the serving box |
| - stops nothing. It also counts extra stops from a stale unlabelled wake |
| - (§6 D3). |
| -- **Adversarial door tests:** wrong account (byte-identical 404), wrong |
| - fleet's box, a member who is not an owner (403), a service credential |
| - (refused by the route's `Allow`), a detached box, a draining box, a |
| - retired record, a record with a `Move`, with a `ReplicaAssignment`, with |
| - a blocking seed, or with another box's live coordinator. Also a box |
| - detached between the check and the write (fresh registry under the |
| - lock), two concurrent labels (one wins, the other is `changed`), and a |
| - drain racing a label. |
| -- **Dry run** writes nothing (no record PUT, no serial bump, no |
| - `MarkFleetBoxLabelled`). It reports a binding and stamp that disagree, |
| - and a binding older than the record. |
| -- **Create (D4):** each refusal writes nothing; a stale box with a fresh |
| - survivor labels to the survivor; a movable record is labelled on a |
| - fleet that holds an unmovable one; an always-on stateless create is |
| - labelled. |
| -- **Worker (D5):** an unlabelled record with a binding stays unlabelled |
| - across passes; a labelled record on a lost or draining box still moves. |
| - |
| -## 11. Census |
| - |
| -- **Record-write census** (`internal/provision/plan9_b8_census_test.go`). |
| - New units: `SetRecordFirstFleetBox` (record-writer, `key:updateRecord`) |
| - and the console door handler (record-writer). Add |
| - `setrecordfirstfleetbox` to `censusKeyExact` (`:56`) so callers are |
| - found by name. Changed digests: `Server.handleAPIInstanceCreate` |
| - (`plans3a_census_test.go:16`, `region_labels_census_test.go:32`) and |
| - `Server.relabelFleet` or `planFirstLabelling` if pinned. One overlay |
| - carries them: `fleet_record_labels_census_test.go`. |
| -- **Root-read census** (`TestPlan14RootReadCensus`). `instances_cli.go` |
| - and `internal/provision` are in the root binary: a card |
| - (`make census-card`, CLAIMS, `make census-propose`) and the other model |
| - family's verdict. Claim: no new root read. Console packages are out of |
| - scope; rev 1's box and activator changes are gone. |
| -- **Parity and docs:** a `parity/parity.tsv` row `instances-label` |
| - (`instances`, `gap`, no console page yet) and a `### carlos instances |
| - label` heading in `docs/site/cli.md`. The CLI's human output gets a UX |
| - pass, then copy review (§12). |
| - |
| -## 12. Copy (drafts for Paul's copy review) |
| - |
| -CLI strings are lower case with no final full stop, as the refusals in |
| -`internal/console/appcopies.go`. `%s` is a host, box, fleet or release. |
| +5. **Self-hosted operators.** The first real use is an operator tying its |
| + one known unlabelled record on its staging fleet: |
| + - dry run, then check `lock.json` in its own bucket; |
| + - label; |
| + - its stateless trial. |
| + |
| +## 9. Copy (drafts for Paul's copy review) |
| + |
| +CLI strings are lower case with no final full stop, as in |
| +`internal/console/appcopies.go`. Authentication failures reuse the standard |
| +CLI refusals unchanged. |
| | key | draft | |
| |---|---| |
| | C01 usage | `carlos instances label --app <a> <host> [--box <b>] [--dry-run]` | |
| -| C02 help | `label ties an instance on a fleet to one box. without --box it only proposes a box. it never changes anything with --dry-run` | |
| -| C03 | `%s is not tied to a box of fleet %s` | |
| -| C04 | `%s is tied to %s. nothing to do` | |
| -| C05 | `last reported serving box: %s (%s ago)` | |
| -| C06 | `no box has reported serving it since it was created` | |
| -| C07 | `the hub sends its requests to: %s` / C08 `the hub has no box for it yet` | |
| -| C09 | `these agree` / C10 `these disagree` | |
| -| C11 | `proposed box: %s` | |
| -| C12 | `no box to propose. name one with --box` | |
| -| C13 | `this is a proposal from what the boxes last reported, not proof of which box runs it now` | |
| -| C14 | `tying it to %s keeps it where it runs` | |
| -| C15 | `tying it to %s moves it once. it stops on %s and starts on %s, like a box restart` | |
| -| C16 | `tying it to %s may move it once. no box has reported serving it` | |
| -| C17 | `dry run. nothing changed` | |
| -| C18 | `tied %s to %s. the other boxes stop carrying it within seconds` | |
| -| C19 | `only an account owner can tie an instance to a box` | |
| -| C20 | `%s is not on a fleet` | |
| -| C21 | `%s is already tied to %s. to move it, drain that box with carlos fleets drain` | |
| -| C22 | `%s runs as copies, so placement chooses its boxes` | |
| -| C23 | `%s has a move in progress. finish it before tying it to a box` | |
| -| C24 | `%s has an import in progress. finish it before tying it to a box` | |
| +| C02 help | `label ties an instance on a fleet to the box serving it now. without --box, or with --dry-run, it only shows what it found and changes nothing` | |
| +| C03 flag --box | `the box to tie it to. it must be the box serving it now` | |
| +| C04 flag --dry-run | `show what would happen and change nothing` | |
| +| C05 arg error | `name one instance host` | |
| +| C06 | `%s is not tied to a box of fleet %s` | |
| +| C07 | `%s is already tied to %s. nothing to do` | |
| +| C08 | `last binding reported: %s (%s ago)` | |
| +| C09 | `no box has reported a binding for it since it was created` | |
| +| C10 | `the hub sends its requests to %s` / `the hub has no box for it yet` | |
| +| C11 | `these agree: %s looks like the box serving it` | |
| +| C12 | `these disagree. wait for it to settle, or open it once, then try again in about 10 minutes` | |
| +| C13 | `this is what the boxes reported, not proof of which box runs it now` | |
| +| C14 | `%s can take it. tie it with carlos instances label --app %s %s --box %s` | |
| +| C15 | `if the report is wrong, tying it moves it: it stops on the box that runs it and starts on %s from its last saved copy` | |
| +| C16 | `dry run. nothing changed` | |
| +| C17 | `tied %s to %s. the other boxes stop carrying it once they update, usually within seconds` | |
| +| C18 | `only an account owner can tie an instance to a box` | |
| +| C19 | `%s is not on a fleet` | |
| +| C20 | `%s is already tied to %s. to move it, drain that box with carlos fleets drain` | |
| +| C21 | `%s runs as copies, so placement chooses its boxes` | |
| +| C22 | `%s has a move in progress. finish it before tying it to a box` | |
| +| C23 | `%s has an import in progress. finish it before tying it to a box` | |
| +| C24 | `%s is coordinated by %s right now. try again in a few minutes` | |
| | C25 | `%s is not an active box of fleet %s` | |
| -| C26 | `%s is draining. choose another box` | |
| -| C27 | `%s has not reported in recently. choose a box that is up` | |
| -| C28 | `%s cannot run this app's runtime yet. choose another box` | |
| -| C29 | `%s cannot be tied to one box: %s`, with C29a `every box serves a static site`, C29b `it is served from an address the platform does not manage`, C29c `it never sleeps and keeps a local database` | |
| -| C30 | `%s is not tied to a box yet. once its import finishes, tie it with carlos instances label` | |
| -| C31 | `fleet %s has sidecars, so its instances cannot be tied to boxes yet` | |
| -| C32 | `tying instances to boxes is not available on this console` | |
| -| C33 | `%s changed while it was being tied. nothing changed. try again` | |
| -| C34 | `could not check the instance and its fleet, so nothing changed. try again` | |
| -| C35 | `no box of fleet %s can take a new instance right now. try again in a minute` | |
| -| C36 | `box placement on %s is paused. %s runs %s, older than %s. update it, then try again` (existing `msgLabelsPaused`, `fleetrelabel.go:601-604`, reused) | |
| -| C37 | guard's `copiesUnlabelled`, revised: `%s is not tied to one box of fleet %s, and that fleet has more than one box. tie it first with carlos instances label, then try again` | |
| - |
| -## 13. Out of scope |
| - |
| -A console action (the instance page), after the CLI's first use. Any |
| -automatic first labelling: rev 1's box door, awake trigger and report mode |
| -are removed, and so is the worker's binding path (D5). Growth labelling |
| -(D6), the box-side marker rule, fencing stale unlabelled wakes (Q4), and |
| -#1008's other items (wake fallback, refusal logging, the stale stamp's |
| -cause). |
| - |
| -## 14. Open questions for the reviewer |
| - |
| -1. **Owner only?** It matches the placement door; drain and add-box admit |
| - any human member. Should those members label too? |
| -2. **Records `movable` rejects** (a stateful binary that never hibernates, |
| - `Addr`) are still created unlabelled on multi-box fleets (D4). Refuse |
| - them, breaking creates that work today? |
| -3. **D4 refuses creates** below v0.33.0 or on a fleet with sidecars. |
| - Acceptable, or leave those unlabelled? |
| -4. **Stale unlabelled wakes** may add one stop after a handover |
| - (`wakeidentity.go:221`). Fence now, or only if the e2e shows it? |
| -5. **A handover label** prints a warning. Require a flag (`--move`) too? |
| -6. **Seeded and imported records** wait for the owner. Label them to the |
| - placing box at import commit in a later slice? |
| -7. **Switch-on:** the release manager names the owner and target date. |
| +| C26 | `%s is draining. it cannot take an instance` | |
| +| C27 | `%s has not reported in recently` | |
| +| C28 | `%s cannot run this app's runtime yet` | |
| +| C29 | `%s runs %s. every box of fleet %s needs %s or later before instances can be tied to boxes` | |
| +| C30 | `%s is not the box serving it now. only that box can be named for now` | |
| +| C31 | `%s cannot be tied to one box: %s`. Reasons: `every box serves a static site`, `it is served from an address the platform does not manage`, `it never sleeps and keeps a local database`, `it runs as a system unit`, `it is a high availability instance`, `it is a demo` | |
| +| C32 | `fleet %s has sidecars, so its instances cannot be tied to boxes yet` | |
| +| C33 | `tying instances to boxes is not available on this console` | |
| +| C34 | `another change tied %s to %s first. nothing more changed` | |
| +| C35 | `%s changed while it was being tied, so it was not tied. try again` | |
| +| C36 | `could not mark %s for this instance, so it was not tied. try again` | |
| +| C37 | `could not read the instance and its fleet, so it was not tied. try again` | |
| +| C38 | `the result is unknown: the console did not answer in time. run carlos instances label --app %s %s to see whether it is tied` | |
| +| C39 | `no box of fleet %s can take a new instance right now. try again in a minute` | |
| +| C40 | guard growth refusal, revised: `%s is not tied to a box of fleet %s, so a second box would stop it. tie it first with carlos instances label, then add the box` | |
| +| C41 | guard `copiesUnlabelled`, revised: `%s is not tied to one box of fleet %s, and that fleet has more than one box. tie it first with carlos instances label, then try again` | |
| +| C42 | create refusal: `%s cannot run on a fleet with more than one box: %s` (reasons from C31) | |
| +| C43 | box log (R2): `refusing to start %s empty: it was tied to this box and there is no saved copy to restore. set-aside copies: %s` | |
| +| C44 | box log (R2): `final checkpoint for %s failed. keeping its lease until the checkpoint succeeds` | |
| + |
| +## 10. Out of scope |
| + |
| +- A console action for labelling. |
| +- Labelling to a box other than the serving one, which is the move case. |
| +- Any automatic first labelling and any growth labelling. |
| +- The box-side marker rule. |
| +- Labelling at import commit, because fleet imports are refused. |
| +- #1008's other items: a wake fallback, refusal logging, and the cause of |
| + the stale stamp. |
| + |
| +## 11. Rulings on round 2's questions |
| + |
| +1. Owner only. |
| +2. Refuse unplaceable platform-run creates on multi-box fleets (D1). |
| +3. Refuse creates below the label floor or with sidecars. |
| +4. Fence stale wakes now (R1). |
| +5. No `--move` flag; it is moot with §4. |
| +6. Import labelling is deferred. |
| +7. Release-based switch-on, with the owner and target recorded (§8). |