docs: fleet record labels rev 2, owner-authorized labelling
Rewrites the spec around the release manager's option B after Astra's round 1 review of f484c4c2. An account owner ties an unlabelled fleet instance to a box with carlos instances label; the console proposes a box from the binding and hub stamp in a dry run, but never treats them as authority. A new typed writer checks every write-time condition under the fleet lock. Creates on multi-box fleets label or refuse, the worker's first-labelling path is turned off, and growth stays refused. Removes the box door, awake trigger, report mode and marker rule. Adds the trust assumption, cost, copy drafts, rollout and witnesses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+437
−554
docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md+437 −554
CI passed — 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 374109a29..eda897704 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,559 +1,442 @@ |
| -# Fleet record labels: tie every fleet instance to the box serving it |
| - |
| -Rev 1, 2026-11-14. Draft for review, round 0 of 3 (stopping rule 1). |
| -Discussion: #1008 on amadan carlos/platform. Builds on managed fleets 1b |
| -(`2026-10-28-managed-fleets-design.md` §4, "1b addendum", rules 1-11) and |
| -stateless replicas (`2026-11-01-stateless-replicas-design.md`, Plan 4 and |
| -the sole-box rule F8). Depends on the up-front guard on branch |
| -`stateless-unlabelled-guard` (read at `d0ff269a`, not merged); the plan |
| -waits for that merge (stopping rule 4). |
| - |
| -All file:line references are to `main` at `d6c6f3f2`. **Verified** means |
| -read in the code at that line. **Inferred** means reasoned from the code but |
| -not exercised by a test or on a box; the plan must confirm each one. |
| +# 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. |
| + |
| +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. |
| ## 1. The problem |
| -An instance record placed on a fleet (Region `fleet/<name>`) that has no |
| -`fleet_box` and no `replica_assignment` is "unlabelled". On a fleet with |
| -two or more active boxes such a record cannot run a stateless build, and |
| -the platform has no way to make it labelled without guessing. |
| - |
| -- Every box carries it. `ownsRecord` answers true for an unlabelled |
| - record on any fleet box (`internal/provision/reconcile.go:549-557`), and |
| - the record scan skips only records labelled for another box |
| - (`reconcile.go:1403-1411`). Verified. |
| -- For a stateful build the per-host Litestream lease picks the one box |
| - that runs it. A stateless build has no Litestream lease (stateless spec |
| - §6.2: "the start rule ... does not apply to stateless rows"), so |
| - "every box carries it" would mean every box runs it. Inferred. |
| -- The coordinator door refuses it. `replicaFleetRecord` accepts an |
| - unlabelled record only when the fleet has exactly one active box |
| - (`internal/console/replicacoordinator.go:45-50`, `soleActiveFleetBox` |
| - `:58-74`); every box of a larger fleet gets 404, which the box reads as |
| - fenced. Verified. This is the 16-minute staging outage in #1008. |
| -- The guard on `stateless-unlabelled-guard` refuses stateless |
| - publication, copies above 1 and fleet growth for such records |
| - (`unlabelledFleetRecordRefusal`, `fleetGrowthRefusal`, |
| - `statelessPublicationRefusal` in `internal/console/appcopies.go` on that |
| - branch). It keeps the app up. It does not label anything, so an app |
| - that wants to go stateless stays refused until something does. |
| - |
| -This design labels those records with the box that is serving them, so no |
| -live app changes box, and stops new unlabelled records being created on |
| -multi-box fleets. |
| - |
| -## 2. What exists today |
| - |
| -### 2.1 How records get labels |
| - |
| -- **At create.** The create door labels a record with |
| - `chooseDestination`'s box only when the fleet view's activation gate is |
| - open (`internal/console/apiinstances.go:2158-2176`, `:2511-2530`). It |
| - continues unlabelled when the view cannot be read, when the gate is |
| - closed, when no box qualifies (`:2528`), when `MarkFleetBoxLabelled` |
| - fails (`:2521-2523`), for a record `movable` rejects, and for every |
| - seeded or imported create (`:2476-2492`). Verified. |
| -- **The gate.** `labelActive` is `Active && !HasSidecars && |
| - DeploymentCurrent && !Unmovable` (`internal/console/fleetbox.go:139-141`). |
| - `Active` needs two or more active boxes and every read whole |
| - (`:388`). `Unmovable` is fleet-wide: one record that `movable` rejects |
| - (an `Addr`, HA, a demo, a binary that never hibernates; |
| - `fleetbox.go:178-190`) closes the gate for every record on the fleet |
| - (`:382-384`). `DeploymentCurrent` needs every box of the deployment, and |
| - the console, at `FleetBoxLabelFloor` v0.33.0 |
| - (`fleetbox.go:346-355`, `internal/release/layoutintent.go:277`). |
| +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. |
| + |
| +## 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 |
| + |
| +``` |
| +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`); |
| +- `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 relabel worker's first labelling.** Every five minutes |
| - (`internal/console/fleetrelabel.go:60`), when the gate is open, each |
| - unlabelled record whose binding object was written for it (same fleet |
| - and host, `BoundAt` after `CreatedAt`) and names a valid destination is |
| - labelled to that box (`planFirstLabelling`, `:194-217`). A record with no |
| - such binding stays unlabelled: "the console never picks a box for an |
| - existing record" (`:38-41`; 1b rule 6, plan review R3). Verified. |
| -- **The writer.** `provision.SetRecordFleetBox` |
| - (`internal/provision/fleetbox.go:51-79`) writes only while Region, label |
| - and `CreatedAt` equal what the caller read, refuses while the seed blocks |
| - a move, and sets `FleetBoxMoved` only on a relabel between two non-empty |
| - labels. It goes through `updateRecord` and `WriteRecord`, whose |
| - `replicaFieldsFixed` check (`internal/provision/record_sequence.go:143`, |
| - `replicacoordinator.go:74-105`) refuses any change to the replica fields |
| - outside their typed writers. A label write changes none of them. |
| - Verified. |
| - |
| -Why the staging record stayed unlabelled is not known. Any one of these |
| -would do it: some record on that fleet that `movable` rejects, a sidecar, |
| -one box of the deployment below v0.33.0 or missing a heartbeat, or no |
| -binding written after the record's creation. Inferred. |
| - |
| -### 2.2 Who serves a record: three sources |
| - |
| -1. **The lease.** `lock.json` at the instance's prefix in the fleet's own |
| - data bucket. It is the arbiter of who may run the instance |
| - (`internal/lease/lease.go:1-12`). Its owner string names the box: |
| - `box/v1;ref=<ref>;...` (`internal/hafresh/owner.go:40-54`), where a |
| - fleet box's ref is its fleet label (`internal/host/haself.go:29`, |
| - `metrics_loop.go:886-887`). The console never reads a fleet's data |
| - bucket: its only `lease.LockState` call reads the platform's |
| - hibernation bucket (`internal/console/seedfinish.go:285`), and |
| - `registry.Fleet.Bucket` is "customer data bucket name" |
| - (`internal/registry/fleets.go:41`). Verified. That the console holds |
| - no credential for a bring-your-own fleet bucket is inferred. |
| -2. **The binding object.** `fleets/<f>/bindings/<host>.json` in the |
| - deployment bucket (`internal/host/fleetbind.go:68-70`). Two writers: |
| - the wake hook, with takeover, right after a wake won the lease |
| - (`fleetBindingHook`, `:390-406`, wired at `internal/host/agent.go:775`); |
| - and the agent's startup pass, without takeover, for every resident |
| - route (`publishResidentFleetBindings`, `:428-449`, `agent.go:995`). |
| - The startup write is "a bare 'this route is resident here' observation |
| - with no lease behind it" (`:411-412`), and on an unlabelled fleet every |
| - box has every route resident. It may create a binding where none |
| - exists (`bindingBlocked`, `:102-113`). The wake hook writes nothing for |
| - a stateless wake (`:392-395`), and a failed write is only logged |
| - (`:403-405`). The object carries no field saying which writer wrote |
| - it (`:33-47`). Verified. |
| -3. **The hub's stamp.** The hub copies bindings into its forward row's |
| - `FleetBox` with `SetFleetBoxIf` (`ReconcileFleetBindings`, |
| - `fleetbind.go:269-357`) on its instances loop, every 5 to 6 minutes |
| - (`agent.go:4475`, `:4495-4499`). For an unlabelled row the forward |
| - phase leaves that stamp alone (`internal/provision/forward.go:55-69`). |
| - The edge treats it as a hint: an unlabelled row falls back to any |
| - connected box of the fleet (`internal/edge/edge.go:4364-4394`). |
| - Verified. The stamp is a lagging copy of source 2, never independent |
| - evidence. Inferred, from the single writer. |
| - |
| -### 2.3 What labelling does to the boxes |
| - |
| -- **The serving box.** Its row's `Assigned` converges to the record's |
| - `FleetBoxAt` (`reconcile.go:1081`, `registry.SetFleetAssignment`). Only a |
| - wake reads it: `leaseRouteChanged` refuses a wake that was in flight |
| - across the change (`internal/activator/wakeidentity.go:104-125`). Nothing |
| - stops a live process when `Assigned` changes. Inferred: no other reader |
| - of `Assigned` acts on a live entry (`grep` of `\.Assigned` in |
| - `internal/activator`). At the next wake the start rule finds no marker |
| - beside the local copy, sets the copy aside under |
| - `<DataDir>/.superseded/<host>/` and restores from the fleet bucket |
| - (`internal/activator/startrule.go:175-222`). Set-aside copies are never |
| - deleted (`:21-23`). This is 1b rule 6's intended cost ("that box's copy |
| - is set aside once and the same data restored", spec line 201ff). |
| - Verified. |
| -- **Every other box.** `ownsRecord` turns false, so the scan skips the |
| - record (`reconcile.go:1409`) and the removal phase retires the row |
| - (`:2549-2576`, `:2662`). If that box had a live entry for it, removal |
| - while awake goes through `RetireExcept`: a final checkpoint and a lease |
| - release, the ordinary stop (`internal/activator/activator.go:6167-6177`). |
| - Verified. A box that does not hold the lease has no live entry, so |
| - nothing stops there; a wake already waiting for the lease is refused |
| - when its row goes. Inferred. |
| -- **The hub.** The forward row becomes labelled (`FleetLabel` and |
| - `FleetBox` from the record, `forward.go:29-47`), and the edge then |
| - dials only that box, with no fallback (`edge.go:4389-4394`). Verified. |
| - So labelling also replaces a stale stamp. |
| - |
| -## 3. Decisions |
| - |
| -### D1. The lease holder is the source of truth, and it says so itself |
| - |
| -The box that holds an instance's lease is the box serving it. That is the |
| -only source that cannot be stale: a binding can be a startup observation, |
| -a missed write or an old wake, and the hub's stamp is a delayed copy of |
| -the binding. The console cannot read the lease on a bring-your-own fleet, |
| -so it does not try. **The box that holds the lease asks the console to |
| -label the record to itself**, and the console checks everything else. |
| - |
| -- **Corroboration: the binding.** Before asking, the box writes a |
| - takeover binding naming itself (the wake hook already has; a box asking |
| - outside a wake writes one first, which its held lease entitles it to). |
| - The request carries that binding's `BoundAt`. The console reads the |
| - binding and labels only when it still names the asking box with that |
| - `BoundAt`. A different box or a different `BoundAt` means another wake |
| - overwrote it since: the console refuses and reports both. It does not |
| - pick between them. |
| -- **The hub's stamp is reported, never decisive.** When the stamp names |
| - another box the console labels anyway and logs the disagreement. The |
| - staging case (stamp box-2, box-1 holding the lease and serving) is |
| - exactly the case this must label to box-1: skipping it would leave the |
| - stale stamp and the refusal in place. Once labelled, the hub's forward |
| - phase rewrites the row from the label (§2.3). |
| -- **Why not a console pass over bindings.** The worker in §2.1 already |
| - does that where the gate is open, and it can label from a startup |
| - binding naming a box that never held the lease (§2.2). Labelling to the |
| - wrong box is not data loss (the holder stops with a checkpoint and the |
| - labelled box restores), but it moves a live app, which this design |
| - must not do. |
| -- **Why not "label on adopting stateless".** At the publication door the |
| - console does not know which box holds the lease. The guard refuses |
| - there instead, and its message changes to say the app is not tied to a |
| - box yet and will be after its next request (copy review). |
| - |
| -### D2. Where it runs, how often, what it costs |
| - |
| -Three parts, each event-driven. No part polls per box or per record. |
| - |
| -1. **The label door** (console, D3), called by the lease holder. |
| -2. **Box triggers** (D4): once after a wake of an unlabelled fleet row, |
| - and from the box's own reconcile pass for an unlabelled row it holds |
| - awake (a local check, no bucket read). After a refusal the box waits |
| - for its next wake or one hour, whichever is later. |
| -3. **Growth labelling** (D7): the add-box door labels a one-box fleet's |
| - records to its sole box before a second box joins. |
| - |
| -A read-only report (D9) shows what is unlabelled and why. |
| - |
| -Cost per record: one binding read and write by the box, one door call, |
| -and on the console one record read, one binding read and one record |
| -write. It happens once per record; once labelled, the box never asks |
| -again. The door's fleet view (heartbeat listings and inventory) is shared |
| -across calls and at most 60 seconds old, so a burst of wakes after a box |
| -restart costs one view per fleet per minute. A one-box fleet is refused |
| -from the registry alone, before any bucket read. This stays inside the |
| -budget rule: no new per-box polling. |
| - |
| -### D3. The label door |
| - |
| -`POST /api/fleet/labels/{account}/{app}/{host}` on the console, beside |
| -the replica doors (`internal/console/routedecls.go:439-441`). The path |
| -avoids the literal `instances`, which would make the handler a key-site |
| -census unit (`plan9_b8_census_test.go:57`). |
| - |
| -**Authentication** is `replicaFleetRecord`'s first half: valid path |
| -shapes, `Carlos-Tunnel-Name` `<fleet>/<box>`, and the box's bearer token |
| -through `fleetIdentityOK` (`replicacoordinator.go:23-36`). The record must |
| -be live and placed on that fleet. A failure is 404, as on the replica |
| -doors. |
| - |
| -**Body:** `{"bound_at": <ms>}`, decoded strictly (`replicaPayload`). |
| - |
| -**Checks, in order.** Cheap ones first. Each refusal names its reason in |
| -the answer and in one console log line. |
| - |
| -1. The fleet has two or more active registry boxes; otherwise 409 |
| - `one_box`, with a 24-hour retry hint. The asking box is active and not |
| - draining (`draining`). |
| -2. The record is unlabelled, with no replica assignment. Already labelled |
| - to the asking box: 200, nothing written. Labelled elsewhere or |
| - assigned: 409 `labelled`. |
| -3. Per-record eligibility: `fleetLabelsRecord` and `movable` |
| - (`fleetbox.go:167-190`); no `Move` in flight (`move`); the seed does |
| - not block a move (`import`, also enforced by `SetRecordFleetBox`). |
| -4. The binding names the asking box with the given `bound_at`, and was |
| - written after the record's `CreatedAt` (`binding`). A binding that |
| - cannot be read is 503. |
| -5. The fleet view: no sidecars on the fleet (1b rule 10), the deployment |
| - and console at the label floor (rule 8), and the asking box fresh and |
| - at the floor (`validDestination`, `fleetrelabel.go:296-303`). Rule 11 |
| - is applied per record (check 3), not to the whole fleet (Q1). |
| -6. The console is not a host-claim console. The relabel worker is off |
| - there because no claim operation gates its record writes |
| - (`fleetrelabel.go:70-74`); the door follows it (`host_claim`). |
| - |
| -**Write.** Under `lockFleet(fleet)` (the lock creates and the relabel |
| -worker take, `fleetbox.go:217-222`): `MarkFleetBoxLabelled`, then |
| -`SetRecordFleetBox` with `FleetBoxExpect{Region, Label: "", CreatedAt}` |
| -as read, then a serial bump so boxes converge in seconds. `ErrFleetBoxMoved` |
| -is 409 `changed`; `ErrFleetBoxImportInFlight` is 409 `import`. Success is |
| -200 `{"fleet_box": <box>, "assigned_at": <FleetBoxAt>}`. The CAS makes the |
| -door idempotent and safe against the relabel worker, a create and a |
| -second box asking at once: whoever writes first wins, and the rest see a |
| -label that is not `""`. |
| - |
| -**Dry run.** `CONSOLE_FLEET_LABELS=off|report|on`. In `report` the door |
| -runs every check, writes nothing, logs `would label <host> to <box>` and |
| -answers 200 `{"applied": false}`. In `off` it answers 404, so boxes back |
| -off as they do on an older console. |
| - |
| -### D4. The box side |
| - |
| -- **Wake trigger.** In `fleetBindingHook`, after a successful takeover |
| - binding write for a route that is unlabelled (`Assigned == ""`, |
| - `FleetBoxes == ""`, not stateless, not a sidecar), call the door with |
| - that `BoundAt`. Runs in the hook's goroutine, off the wake path, like |
| - the binding write (`fleetbind.go:365-368`). |
| -- **Awake trigger.** In the box's reconcile pass, for each unlabelled |
| - fleet row the activator `HoldsAwake` (`activator.go:3639-3643`: awake, |
| - lease held, not fenced) and the box has not asked about since its last |
| - wake or within the hour: write a takeover binding, then call the door. |
| - This covers an instance that has been awake since before this release |
| - and may not sleep for days. |
| -- **Back-off.** 404 (old or `off` console), a 409 or a 5xx: no retry |
| - until the next wake or one hour, kept in memory per host. 409 `one_box` |
| - waits 24 hours. An agent restart forgets it, which costs at most one |
| - call per unlabelled host per restart. |
| -- **The marker rule (one place, in the activator).** When a box converges |
| - its row's `Assigned` from `""` to a value while it holds that instance |
| - awake under its lease, it writes `<db>.assigned` with that value |
| - (`establishAssignment`, `startrule.go:378-390`) under the entry's lock. |
| - The running database is the authoritative copy: it is what the lease |
| - holder replicates, and only a relabel can give another box the record, |
| - which changes `Assigned` again. So the next wake keeps the warm copy |
| - instead of setting it aside and restoring. It covers labels from the |
| - door, from growth and from the relabel worker alike. If the instance is |
| - not awake at that moment, nothing is written and §2.3's set-aside and |
| - restore happen once, as today. Cutting this rule (Q5) only costs one |
| - restore and one set-aside copy per labelled live record. |
| - |
| -### D5. Records left unlabelled, and why |
| - |
| -| Record | Outcome | |
| -|---|---| |
| -| Never woken, or asleep since this release | Unlabelled until its next wake, which asks. The console never picks a box for it (1b rule 6, R3). | |
| -| Asleep, with a binding | Same. The binding may be a startup observation (§2.2). See Q3. | |
| -| Static | Never labelled; every box serves it from the bucket (`fleetbox.go:162-169`). | |
| -| `Addr`/`Addrs`, HA, demo, binary that never hibernates | Never labelled (`movable`). The guard covers stateless for them. | |
| -| `Move` in flight, or seed blocking a move | Refused now; asked again at the next wake after the move or import ends. | |
| -| Box draining, lost or detached | A draining or lost box is refused; a detached box cannot authenticate. A fleet with unlabelled records cannot start a drain anyway (`drainBox` strands them, `fleetrelabel.go:482-487`). | |
| -| Fleet with sidecars, or deployment below v0.33.0 | Refused (1b rules 10 and 8). Stateless needs v0.34.0 or later (`layoutintent.go:403`), so these fleets cannot hit #1008. | |
| - |
| -### D6. No new unlabelled creates on multi-box fleets |
| - |
| -On a fleet with two or more active boxes, a create of a record that |
| -`fleetLabelsRecord` admits and `movable` accepts gets a label or is |
| -refused: |
| - |
| -- **Transient reasons are refused with a retry.** The view could not be |
| - read whole, no box is a destination right now, or |
| - `MarkFleetBoxLabelled` failed. Today these create unlabelled |
| - (`apiinstances.go:2171`, `:2521-2523`, `:2528`). Instead: 503 with |
| - `Retry-After: 30`, nothing written. Labelling deterministically to a box |
| - that is not fresh would start the instance on a box that may be down. |
| -- **The gate's fleet-wide `Unmovable` stops closing it for creates.** A |
| - movable record is labelled even when another record on the fleet is |
| - not (per-record rule 11, Q1). |
| -- **Below the label floor, or with sidecars:** created unlabelled as |
| - today. Labels would be ignored by old boxes, and stateless cannot run |
| - there (D5). |
| -- **Seeded and imported creates** stay unlabelled at create. The seed |
| - lands on whichever box places it, and that box's first wake after the |
| - import commits asks the door. The guard refuses stateless for them |
| - until then. |
| -- **An always-on stateless create.** `movable(rec)` without a manifest |
| - rejects a binary that never hibernates (`fleetbox.go:185-189`), so such |
| - a create on a multi-box fleet stays unlabelled today. The create door |
| - passes the channel head's verified manifest when the head is |
| - stateless. Inferred gap; the plan confirms it with a test first. |
| - |
| -### D7. A one-box fleet that grows labels first |
| - |
| -A one-box fleet stays unlabelled while it has one box. F8 rejected |
| -labelling one-box fleets (labels are authoritative with no fallback), and |
| -the sole-box rule covers them. The moment that stops holding is the |
| -add-box door, so that is where they get labelled. |
| - |
| -When `handleAPIFleetAddBox` (`internal/console/fleets.go:390`) would take |
| -a fleet from one active box to two, then before `AddFleetBox`, under |
| -`lockFleet`: read the fleet's inventory whole (`fleetInventoryFor`, |
| -`fleetbox.go:433-468`), and label each unlabelled, movable, non-static |
| -record with no move or demo to the sole active box, through the same |
| -`MarkFleetBoxLabelled` and `SetRecordFleetBox` calls as the door. Only |
| -when the sole box is fresh and the deployment is at the label floor. |
| - |
| -This picks no box. The sole active box is the only one with a fleet |
| -channel, so it is the box serving every awake record and the box that |
| -will wake every sleeping one. A detached box that is still running gets |
| -no traffic: its token no longer authenticates (`fleetIdentityOK`). A |
| -record that cannot be labelled (an import in flight) stays unlabelled. |
| -If it runs a stateless build, the guard's `fleetGrowthRefusal` still |
| -refuses the growth and names it. |
| - |
| -### D8. Stateless replicas after labelling |
| - |
| -Once labelled, the record goes through the paths that already handle |
| -labelled records. Each is verified to accept a label equal to the |
| -asking box: |
| - |
| -- **Coordinator door:** `rec.FleetBox == box` passes without proof |
| - (`replicacoordinator.go:52-54`). `SetRecordCoordinator` fences only an |
| - unlabelled fleet record without proof, or a label naming another box |
| - (`internal/provision/replicacoordinator.go:59`). |
| - `SetRecordReplicaRelease` applies the same test |
| - (`internal/provision/replicadeploy.go:43`). |
| -- **Placement:** `replicaNext` starts from `Boxes: [FleetBox]` |
| +- **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 serving box. `SetRecordReplicaAssignment` refuses a set that |
| - drops the labelled box without retiring it |
| - (`internal/provision/replicaassignment.go:122`). |
| - `ClearRecordReplicaAssignment` returns to a label (`:252-273`). |
| -- **The hub:** a replica assignment projects `FleetBoxes` and clears |
| - `FleetBox`/`FleetLabel` on the row (`replicaassignment.go:216-231`); the |
| - forward row converts the same way (`forward.go:44`). Unchanged. |
| -- **The guard** stops refusing: `anyUnlabelledFleetRecord` is false for |
| - a labelled record (guard branch). No change to it beyond its message. |
| - |
| -A stale `Coordinator` naming another box on a newly labelled record makes |
| -the coordinator door answer `CoordinatorHeldError` until it expires, then |
| -the labelled box takes it. Inferred. It arises only if a one-box fleet |
| -coordinated the record before it grew, which D7 and the guard prevent. |
| - |
| -### D9. The report |
| - |
| -`carlos fleets show <fleet>` gains a section, for the fleet's owner and |
| -for operators: how many instances are not tied to a box, and for each its |
| -reason (D5's rows), what its binding and the hub's stamp say, and the |
| -door's last answer for it. It reads the inventory, one binding per |
| -unlabelled record and the hub's registry, on demand. It is one-off, per |
| -invocation. With the console in `report` mode, it also lists the labels |
| -the door would have written. Changed CLI output gets a UX pass, then the |
| -copy review; `fleets-show` stays `partial` in `parity/parity.tsv:144`. |
| - |
| -## 4. Rollout |
| - |
| -Dev first, then flagship, then self-hosted operators (memory: roll order |
| -dev first). Nothing here touches production without the release |
| -manager's go. |
| - |
| -0. **Read-only inventory.** On dev and flagship: `carlos fleets ls`, then |
| - `fleets show` per fleet (after the release, the D9 report). Not |
| - checked for this spec. From session notes, dev has fleet r10r (account |
| - bab, one box, box-1) and residue rows drill-sr to drill-sr5 whose |
| - boxes are gone. If those rows still count active boxes, D3 check 1 |
| - and D6 treat them as multi-box fleets. They hold no records, but the |
| - inventory says whether to close them first. |
| -1. **Release N** carries the console door (default `report`), D6, D7, D9, |
| - the box triggers and the marker rule. Boxes that meet an older console |
| - get 404 and back off (D4), so the order of box and console rolls does |
| - not matter. |
| -2. **Dev, report mode.** Roll, wait a day, read the D9 report and the |
| - `would label` lines. Each one is checked against the lease owner in |
| - `lock.json`, read on the box (dev only; platform debugging). |
| -3. **Dev drill**, in a live window booked on #421 through the release |
| - manager. Adding a box to r10r needs the hostname-history window (the |
| - 1b drill cost about 58 s of dev console downtime) and a temporary |
| - second EC2 box, which needs Paul's scoped approval (account, region, |
| - instance type, duration, teardown). Outline: |
| - 1. On r10r (one box), ship a stateful, hibernating build of a sample |
| - app (shop) and create a second instance. Both unlabelled. |
| - 2. Console `on`. Add box-2. Witness: both records `fleet_box=box-1`, |
| - a GET loop shows no 5xx, `X-Carlos-Version` unchanged, box-2 never |
| - wakes them, and box-1's next wake keeps its copy (marker, no |
| - set-aside line). |
| - 3. Make an unlabelled multi-box record with a `--from` seeded create. |
| - Wake it. Witness: the waking box asks, the label matches the lease |
| - owner, and the other box drops its row without a wake. |
| - 4. Disagreement: with an instance awake on box-1, write a binding |
| - naming box-2 into the dev deployment bucket. Witness: box-1's awake |
| - trigger rewrites the binding, the door labels box-1, and the hub |
| - stamp disagreement is logged. |
| - 5. D6: stop box-2's agent until its heartbeat is stale and create an |
| - instance. Witness: 503 with `Retry-After`, nothing written. Restart |
| - it. |
| - 6. Ship shop `--stateless`, then `--copies 2`. Witness: accepted, |
| - placement keeps box-1 and adds box-2, the GET loop stays clean. |
| - 7. Teardown: `--copies 1`, `fleets drain r10r box-2`, |
| - `detach-box --terminated`, terminate the instance. Records back on |
| - box-1. |
| -4. **Dev `on`** after the drill passes. This is the switch-on (stopping |
| - rule 5): release N+1 defaults to `on`. |
| -5. **Flagship:** the release manager's roll, `report` for a day, read |
| - the report, then `on`. |
| -6. **Self-hosted operators:** their console and boxes on N+1 (default |
| - `on`), or N with `report` first. The staging record behind #1008 is |
| - awake on one box today. Its box asks within a reconcile pass of the |
| - roll, and the guard then lets its stateless trial proceed. |
| - |
| -**Witness tests** (production-wired: real reconcile, activator and door |
| -wiring, two boxes in one process as `TestTwoBoxFleetEndToEnd` does): |
| - |
| -- door: labels the asking box; refuses a binding naming another box or |
| - another `BoundAt`; one box; draining; `Move`; import; sidecars; below |
| - the floor; host-claim; `report` writes nothing; a second caller after a |
| - label is a no-op or `labelled`; |
| -- box: the wake trigger asks once; the awake trigger asks only for a row |
| - `HoldsAwake`; back-off honours 404, 409 and `one_box`; |
| -- marker: written only while the entry is awake under its lease at the |
| - moment `Assigned` first converges; never after the lease is lost; |
| -- serving box: an `Assigned` change on an awake entry neither stops nor |
| - cycles it (pins the inference in §2.3); |
| -- other boxes: drop the row; a live entry there stops through |
| - `RetireExcept` with its checkpoint; |
| -- create (D6): each transient reason is a 503 with nothing written; a |
| - movable record is labelled on a fleet holding an unmovable one; |
| -- growth (D7): labels to the sole box before the add; refuses as the |
| - guard does when a stateless record cannot be labelled; |
| -- replicas (D8): a newly labelled record passes the coordinator door and |
| - raises to two copies keeping its box. |
| - |
| -## 5. Census |
| - |
| -**Record-write census (9B8, `internal/provision/plan9_b8_census_test.go`).** |
| -Every top-level declaration naming `SetRecordFleetBox` is a unit |
| -(`plan9_b8_census_test.go:56`). New units: the door handler and the |
| -growth helper (`record-writer`, `key:SetRecordFleetBox`). Changed digest: |
| -`Server.handleAPIInstanceCreate` (pinned in overlays such as |
| -`plans3a_census_test.go:16` and `region_labels_census_test.go:32`), and |
| -`Server.handleAPIFleetAddBox` if the growth labelling is inline rather than |
| -a helper. `Server.writeRelabels` (`managed_fleets_1b_census_test.go:75`) |
| -is unchanged unless Q4 changes the worker. One new overlay, |
| -`fleet_record_labels_census_test.go`, carries them. |
| - |
| -**Root-read census (`TestPlan14RootReadCensus`, AGENTS.md "The census").** |
| -The console packages are out of scope. In scope, and needing a card |
| -(`make census-card`, a CLAIMS file, `make census-propose`) and an |
| -independent reviewer's verdict: |
| - |
| -- `internal/host`: the wake and awake triggers and the door client (the |
| - fleet binding hook, the reconcile pass, a client beside |
| - `replicaCoordinatorAPI.post`, `internal/host/replicacoordinator.go:98-110`); |
| -- `internal/activator`: the marker rule (D4); |
| -- the root package's `fleets.go`: the `fleets show` section. |
| - |
| -Claims for the card: no new root read. The marker rule adds an |
| -agent-written file that root does not read. The marker sits beside the |
| -database in tenant-writable ground, as 1b's marker already does |
| -(`startrule.go:47-51`); the reviewer checks that the new write path takes |
| -no tenant-named input beyond the host the row already names. |
| - |
| -Parity: the `box-doors` row (`parity/parity.tsv:255`) gains the door. No |
| -new `carlos` verb, so `docs/site/cli.md` gains no heading. |
| - |
| -## 6. Out of scope |
| - |
| -The other findings in #1008: a stateful fallback when a stateless wake is |
| -refused, logging coordinator refusals on both sides with a distinct status |
| -for "not your record", and why the hub stamp went stale. This design |
| -removes the stale stamp's effect for every labelled record (§2.3) but does |
| -not explain it. |
| - |
| -## 7. Open questions for the reviewer |
| - |
| -1. **Rule 11 per record.** 1b rule 11 closes labelling for a whole fleet |
| - when any record on it is unmovable (`fleetbox.go:382-384`). This design |
| - applies it per record for the door and for creates. Ownership is |
| - already per record (`ownsRecord`), and a drain already strands |
| - unlabelled records per record. Is the fleet-wide rule still needed for |
| - anything? If it must stay, fleets holding one always-on record are |
| - never labelled, and the guard keeps refusing stateless on them. |
| -2. **Labelling at growth versus F8.** F8 rejected labelling one-box |
| - fleets. D7 labels only at the moment a fleet stops being one-box. Is |
| - that the narrow version F8 allows, or should growth stay refused while |
| - unlabelled records exist (the guard's behaviour, extended to all |
| - movable records)? |
| -3. **Sleeping records.** Records asleep since the release stay unlabelled |
| - until they wake (1b rule 6, R3). Should a wake binding (if bindings |
| - gain a field naming their writer) be enough to label a sleeping |
| - record? Its data is in the bucket, so the risk is a wrong warm-cache |
| - box, not data. |
| -4. **The relabel worker's binding path.** It can label from a startup |
| - binding (§2.2). Keep it as approved, restrict it to fleets the door |
| - cannot reach, or retire it once the door is on? |
| -5. **The marker rule.** Keep it (root-scope change, census card), or cut |
| - it and accept one restore and one never-deleted set-aside copy per |
| - labelled live record? |
| -6. **Hub stamp disagreement.** This design labels and logs (D1). The |
| - release manager's direction was "skip and report". Skipping would leave |
| - the staging case unlabelled for as long as the stamp is stale. Is |
| - proceed-and-log acceptable, given the stamp is derived from the |
| - binding? |
| -7. **Create refusals.** D6 turns today's silent unlabelled creates into a |
| - 503 with retry when no box qualifies. Is a refused create better than |
| - an unlabelled one for every caller, including the seed doors' callers |
| - and automated creates? |
| -8. **Switch-on.** Default `report` in release N and `on` in N+1 after the |
| - dev drill. Does the release manager want a date instead? |
| -9. **The stale stamp.** Must #1008's item 3 be explained before |
| - self-hosted operators switch to `on`, or is the lease-holder rule |
| - enough? |
| -10. **Host-claim consoles.** The door is off there, like the relabel |
| - worker. Is any live console a host-claim console with multi-box |
| - fleets? |
| -11. **Always-on stateless creates (D6).** Confirm the gap with a test |
| - before the plan sizes the fix. |
| + 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 | |
| +|---|---:|---:| |
| +| 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 | |
| + |
| +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`. |
| + |
| +## 9. 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 |
| + 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. |
| + |
| +| 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` | |
| +| 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. |