docs: fleet record labels design (#1008)
Spec for labelling unlabelled fleet instance records with the box that serves them. The lease holder asks the console to label the record to itself through a new box door, corroborated by its own takeover binding; the hub stamp is logged, never decisive. Also covers refusing unlabelled creates on multi-box fleets, labelling a one-box fleet at growth, the stateless replica paths after labelling, rollout with a report mode and a dev drill, census impact and open questions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+559
−0
docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md+559 −0
CI failed — 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| new file mode 100644 |
| index 000000000..374109a29 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md |
| @@ -0,0 +1,559 @@ |
| +# 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. |
| + |
| +## 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`). |
| + 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]` |
| + (`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. |