carlos / platform Public

docs: fleet record labels implementation plan

Plan for spec rev 3 (5f67588c): T1 stale unlabelled wake fence, T2 proven
checkpoint and restore-required first labels, T3 stateless drain and
failover, T4 first-label writer and owner door, T5 the CLI verb, T6
create changes and the worker's first labelling off, T7 copy and docs,
T8 census cards, T9 the r10r dev drill. Lands as two merges so release A
is the rollback floor. Each task names deterministic witnesses, its
targeted test runs and its review gate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4301463ff14ae5b1348ee5821b621dde1097e967 parent 5f67588
1 file changed, +443 −0
  • docs/superpowers/plans/2026-11-14-fleet-record-labels.md +443 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/plans/2026-11-14-fleet-record-labels.md b/docs/superpowers/plans/2026-11-14-fleet-record-labels.md
new file mode 100644
index 000000000..a0d1a4685
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-14-fleet-record-labels.md
@@ -0,0 +1,443 @@
+# Fleet Record Labels Implementation Plan
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Let an account owner tie an unlabelled fleet instance record to the box serving it (`carlos instances label`). First make every box safe against the stale wakes and empty starts that a wrong label could cause.
+
+**Architecture:** The box-side safety work comes first: one stale-wake fence in `currentWakeRoute`, a proven final checkpoint before a fleet stop releases its lease, and verified stateless eligibility in relabel and drain. Then the console's typed first-label writer and its owner-only door, the CLI, the create changes and turning off the worker's first labelling. It lands as two merges, so the first release (A) is the rollback floor.
+
+**Tech Stack:** Go. The console in `internal/console`, records in `internal/provision`, the activator and start rule in `internal/activator`, the lease in `internal/lease`, the CLI in the root package.
+
+**Spec:** `docs/superpowers/specs/2026-11-14-fleet-record-labels-design.md` (rev 3, final). Read it with this plan. R1-R4, §4 (v1 scope), §5 (door) and D1-D4 are the requirements. The copy keys are C01-C44.
+
+**Prerequisite:** branch `stateless-unlabelled-guard` is merged to `main` before T4 starts (stopping rule 4). This plan relies only on its merged contract.
+
+## Global Constraints
+
+- v1 labels only to the serving box. Binding and hub stamp must agree, and the named box must be active, fresh, not draining and eligible (spec §4).
+- Owner only: `apiOwnerAccountFor`. Route `Allow: svcrole.Set{}`. Host-claim consoles: door and D1 off.
+- The new writer writes `FleetBox`, `FleetBoxAt` (write time, RFC 3339 nanoseconds UTC) and `FleetBoxMoved = true` (R2).
+- `FleetRecordLabelFloor` (new, `internal/release/layoutintent.go`) = release A's tag. The door requires it of every active box of the fleet and of the console (R4).
+- The door requires `v.Complete` from `loadFleetViewRequiredAt(ctx, fleet, now, true)`.
+- Fleet-placed rows only for the R2 checkpoint change. Platform-region stops are unchanged.
+- Copy: CLI strings lower case, no final full stop, no em dashes. Strings land marked `// draft for copy review (Cnn)` and go to Paul's shared copy review before release B.
+- Tests: targeted `-run` only, for example `go test ./internal/activator -run 'TestX|TestY' -count=1`. CI runs the full suite. Leave `GOCACHE` at its default.
+- Every witness is deterministic: barriers (channels, test seams, hooks), never sleeps.
+- Wire shapes are additive. No record field changes meaning.
+
+## Review Focus
+
+- **A stateful instance that never wrote a database**, once labelled (Moved = true, no replica, no local copy): it refuses to start with C43. It must not start empty. T2 pins it with `TestLabelledInstanceWithNoDatabaseAnywhereRefuses`.
+- **An agent restarted between the label and its reconcile**, with a request arriving before the first pass: the unlabelled row's wake is fenced (R1). T1 pins it with `TestFenceHoldsAfterAgentRestartBeforeReconcile`.
+- **Clock skew between a box's `BoundAt` (box clock) and the record's `CreatedAt` (console clock)**: a binding dated before creation is no evidence, so the door refuses `no_evidence`. It never accepts it. T4 pins it with `TestBindingDatedBeforeCreateIsNoEvidence`.
+- **The hub has no forward row yet** (the hub pass has not run since placement): the door refuses `no_evidence` with C10's second form. T4 pins it with `TestMissingHubRowIsNoEvidence`.
+- **A host typed with capitals or spaces**: the CLI lowercases and trims, as `instances retry` does. T5 pins it with `TestInstancesLabelNormalisesTheHost`.
+
+## Landing
+
+- **M1:** T1, T2, T3 and T6 Part B (the worker's first labelling off). Release A. This is the rollback floor (spec D2). The release manager records it in the roll recipe.
+- **M2:** T4, T5, T6 Part A, T7 and T8. Release B, the switch-on. The release manager records the owner and target release on #1008 before T1 starts.
+- **T9** (the dev drill) runs after release B is on dev.
+- **Reviews:** Astra per task (the gate named in each task), and Fable as well on T1 and T2 (termination and storage). Whole-branch review before each merge: Astra plus Fable. Round budget per stopping rule 1.
+
+## File Structure
+
+| File | Responsibility | Task |
+|---|---|---|
+| `internal/activator/wakeidentity.go` | the R1 fence in `currentWakeRoute` | T1 |
+| `internal/host/agent.go` | `FleetWakeIdentityUnknown` gets a record reader | T1 |
+| `internal/lease/lease.go` | `Replicator.CloseProven` | T2 |
+| `internal/lease/leasetest/` | a fault hook that fails replica PUTs | T2 |
+| `internal/activator/activator.go` | fleet stops use `CloseProven` and stay pending | T2 |
+| `internal/console/fleetrelabel.go` | verified manifest in relabel and drain; first labelling removed | T3, T6 |
+| `internal/console/fleetbox.go` | `movableVerified` helper | T3 |
+| `internal/provision/fleetbox.go` | `SetRecordFirstFleetBox` and its errors | T4 |
+| `internal/release/layoutintent.go` | `FleetRecordLabelFloor` | T4 |
+| `internal/console/instancelabel.go` (new) | the door: evidence, decision, write | T4 |
+| `internal/console/routedecls.go`, `parity/parity.tsv` | route and parity row | T4, T5 |
+| `instances_cli.go` (verb and `instanceLabel` beside `instanceRetry`), `commands.go` | the CLI verb | T5 |
+| `internal/console/apiinstances.go` | create on multi-box fleets | T6 |
+| `docs/site/cli.md`, `docs/drafts/fleet-record-labels/` | docs and copy deck | T7 |
+| `internal/provision/fleet_record_labels_census_test.go`, `testdata/plan14-root-reads-fleet-record-labels-*.tsv` | census | T8 |
+
+---
+
+### Task 1: The stale unlabelled wake fence (R1)
+
+**Files:**
+- Modify: `internal/activator/wakeidentity.go:206-268` (`currentWakeRoute`), `:175-185` (`FleetWakeIdentityUnknown` takes a record reader)
+- Modify: `internal/host/agent.go` (where `FleetWakeIdentityUnknown` is built) to pass `FleetRecordFrom(store)`
+- Test: `internal/activator/pendingwake_linux_test.go` (its two-box `Service` harness: `sharedLock`, `fleetBucket`, `fleetBox`, `asFleetBox`)
+
+**Interfaces:**
+- Produces: `FleetWakeIdentityUnknown(fleet string, err error, record func(context.Context, registry.Route) (*provision.Record, error)) FleetWake`, and a new sentinel, `errUnlabelledRecordLabelled = errors.New("the record is tied to a box, but this route has not caught up")`, wrapped with `errRouteChangedUnderLease`.
+
+**Behaviour:** In `currentWakeRoute`, an unlabelled row (`Assigned == "" && FleetBoxes == ""`) whose `Region` is a fleet placement, on a box in `FleetWakeCheck` or `FleetWakeUnknown` mode, reads the record once through `a.Fleet.Record`. It refuses, so the caller gives the lease back and nothing restores or starts, when:
+
+- the record has any `FleetBox`;
+- the record has a `ReplicaAssignment`;
+- the record is retired, nil, or unreadable (`errRecordUnreadUnderLease`).
+
+Otherwise it returns as today. In `FleetWakeNone` mode, or for a row off a fleet, it reads nothing.
+
+- [ ] **Step 1: Write the failing tests** in `pendingwake_linux_test.go`:
+ - `TestUnlabelledStaleWakeRefusedWhenRecordNamesAnotherBox`: box A holds an older local DB (`writeUsableDB` with sequence 1) on an unlabelled row. The bucket holds sequence 2. The record names `pi-2`. A's `Service` wake must:
+ - return an error wrapping `errRouteChangedUnderLease`;
+ - leave `lock.heldBy() == ""` after;
+ - not call the restore (a counter on `swapRestoreReplica` stays 0);
+ - spawn no process;
+ - leave A's local DB unchanged at sequence 1.
+ - `TestUnlabelledWakeRefusedWhenRecordLabelledToThisBox`: the record names `pi-1` and the row has not converged. Refused, as above.
+ - `TestUnlabelledWakeRefusedWhenRecordHasAssignment`.
+ - `TestUnlabelledWakeRefusedWhenRecordUnreadable`: the record reader returns an error. The wake fails with `errRecordUnreadUnderLease`.
+ - `TestUnlabelledWakeFencedWhenLabelledWhileWaitingForTheLease`: a barrier inside `sharedLock.take` holds A's acquire. The test writes the label to `pi-2`, then releases the barrier. Refused.
+ - `TestFenceHoldsAfterAgentRestartBeforeReconcile`: a fresh `Service` on A with A's stale registry row (no reconcile run) and the record labelled `pi-2`. Refused.
+ - `TestUnlabelledWakeOnUnlabelledRecordWakesAsToday`: wakes, and the record reader is called exactly once.
+ - `TestUnlabelledWakeOffFleetReadsNothing`: `FleetWakeNone`, so the record reader is called 0 times.
+ - `TestUnlabelledWakeOnIdentityUnknownBoxIsFenced`: `FleetWakeUnknown` with the reader, and a labelled record. Refused.
+ - `TestStatelessUnlabelledWakeFenced` (the `stateless.go:341` path) and `TestWorkerUnlabelledWakeFenced` (the `rootfsworkers.go:478` path).
+- [ ] **Step 2: Run them and confirm they fail.** Run `go test ./internal/activator -run 'TestUnlabelled|TestFenceHolds|TestStatelessUnlabelled|TestWorkerUnlabelled' -count=1`. Expected: the refusal tests FAIL (the wake succeeds), and the two pass-through tests PASS.
+- [ ] **Step 3: Implement the fence** in `currentWakeRoute`, and the reader on `FleetWakeIdentityUnknown` and its agent wiring.
+- [ ] **Step 4: Run them, plus the existing fence tests, and confirm all pass.** Run `go test ./internal/activator -run 'TestUnlabelled|TestFenceHolds|TestStatelessUnlabelled|TestWorkerUnlabelled|TestPendingWake|TestRetirementFences|TestLaggingReconcile|TestLabelledWakeReadsTheRecordOnce|TestUnreadableRecord|TestWakeRouteChanged' -count=1`, then `go test ./internal/host -run 'TestAgent.*Fleet' -count=1`. Expected: PASS.
+- [ ] **Step 5: Commit.** `activator: fence stale unlabelled fleet wakes under the lease (R1)`.
+
+**Review gate:** Astra and Fable. A root-binary file changed, so T8 carries the card.
+
+### Task 2: Restore-required and a proven final checkpoint (R2)
+
+**Files:**
+- Modify: `internal/lease/lease.go:646-676`. Add `CloseProven`; `Close` is unchanged.
+- Modify: `internal/lease/leasetest/` (add `FailReplicaPuts(prefix string) (heal func())` if no equivalent hook exists)
+- Modify: `internal/activator/activator.go` (`finishStop` around `:5415-5431`, `retryPendingStop`, the `Shutdown` path)
+- Test: `internal/lease/release_test.go`, `internal/activator/pendingwake_linux_test.go`, `internal/activator/startrule_test.go`
+
+**Interfaces:**
+- Produces:
+ - `func (r *Replicator) CloseProven(ctx context.Context) error`. It runs `SyncAndWait`. On error it returns `ErrCheckpointUnproven` (wrapping the cause) and leaves replication running and the lease held. On success it does exactly what `Close` does.
+ - `var ErrCheckpointUnproven = errors.New("lease: final checkpoint not confirmed")`.
+- Consumes: T4's writer sets `FleetBoxMoved = true`. The start rule's existing `rt.Moved` refusal (`startrule.go:333-376`) is the restore-required semantics. No new marker.
+
+**Behaviour:**
+- A stop of a fleet-placed row (`registry.FleetPlacement(rt.Region)`) whose `e.rep` is non-HA calls `CloseProven` after the process has exited. On `ErrCheckpointUnproven` the stop stays pending, as the HA path's `keepPendingLocked` does. The box logs C44, and `retryPendingStop` retries on the sweep.
+- At `Shutdown`, a fleet stop still unproven calls `Abandon`: no release, the lease runs to its TTL, and an ERROR names the host.
+- Non-fleet rows call `Close` as today.
+
+- [ ] **Step 1: Write the failing tests.**
+ - `internal/lease`: `TestCloseProvenKeepsTheLeaseWhenTheFinalSyncFails`. With `FailReplicaPuts` on, `CloseProven` returns `ErrCheckpointUnproven` and `lock.json` is still present. After `heal()`, a second `CloseProven` returns nil, `lock.json` is gone, and a restore yields the last write.
+ - `internal/activator`: `TestFleetStopWithFailedCheckpointStaysPending`. Use real `Service` and `ExecBackend` against `leasetest`, a write after wake, and a fault before the stop. Assert:
+ - the process is gone;
+ - the entry is pending;
+ - the lease is still held;
+ - the C44 line is in the log.
+
+ Then heal, call `sweepOnce()`, and assert the lease is released and a restore on box B yields the write.
+ - `TestShutdownWithUnprovenCheckpointLeavesLeaseToTTL`.
+ - `TestPlatformRegionStopUnchanged`: a non-fleet row whose final sync fails still releases, as today.
+ - Start rule pins (green on main; they guard the R2 contract):
+ - `TestMovedInstanceOnACleanBoxRefusesWithoutReplica` exists already;
+ - add `TestFirstLabelOnServingBoxWithoutReplicaRefuses`: an unmarked local copy, `Moved` true, and no replica. The copy is set aside and the start is refused with `ErrNothingToRestore`;
+ - add `TestLabelledInstanceWithNoDatabaseAnywhereRefuses`: no local copy, no set-aside copy, no replica, and `Moved` true. Refused, with the C43 text.
+- [ ] **Step 2: Run them and confirm the first four fail.** Run `go test ./internal/lease -run TestCloseProven -count=1` and `go test ./internal/activator -run 'TestFleetStopWithFailedCheckpoint|TestShutdownWithUnproven|TestPlatformRegionStopUnchanged|TestFirstLabelOnServingBox|TestLabelledInstanceWithNoDatabase|TestMovedInstanceOnACleanBox' -count=1`. Expected: `CloseProven` is undefined, then the stop tests fail. The start rule pins pass.
+- [ ] **Step 3: Implement `CloseProven`, the leasetest hook, and the activator's fleet-stop branch.** Reuse `keepPendingLocked` and `retryPendingStop` rather than a second pending mechanism.
+- [ ] **Step 4: Run Step 2's commands, plus `-run 'TestPendingWake|TestRetirementFences|TestEveryFreshBootPathConsultsTheRule|TestRelease'`.** Expected: PASS.
+- [ ] **Step 5: Commit.** `lease, activator: a fleet stop releases only after a proven checkpoint (R2)`.
+
+**Review gate:** Astra and Fable (termination, production storage). Census card in T8.
+
+### Task 3: Stateless drain and failover (R3)
+
+**Files:**
+- Modify: `internal/console/fleetbox.go`. Add `movableVerified`.
+- Modify: `internal/console/fleetrelabel.go:175`, `:485`
+- Test: `internal/console/fleetrelabel_test.go`, `internal/activator/stateless_test.go`
+
+**Interfaces:**
+- Produces: `func (s *Server) movableVerified(ctx context.Context, rec provision.Record) (bool, error)`.
+ - For `Runtime == "" && Hibernate != nil && !*Hibernate` it calls `s.replicaSelected(ctx, rec)` and `movable(rec, m)`.
+ - Otherwise it calls `movable(rec)`.
+ - A manifest error returns `(false, err)`, so the caller logs it and leaves the record.
+
+**Behaviour:** `relabelFleet` and `drainBox` call `movableVerified` instead of `movable`. A labelled one-copy always-on stateless record, with no assignment, moves off a lost or draining box like any other. An unverifiable manifest leaves it where it is, logged, and drain refuses it, naming the app.
+
+- [ ] **Step 1: Write the failing tests:**
+ - `TestLostBoxMovesAnAlwaysOnStatelessRecord`: a labelled `pi-1`, a stateless verified manifest, `pi-1` lost, and `RunFleetRelabelPass` at an explicit time. The record names `pi-2`, and `FleetBoxMoved` is true.
+ - `TestDrainMovesAnAlwaysOnStatelessRecord`.
+ - `TestOneCopyStatelessFailsOverWithoutAssignment`: n == 1 and no `ReplicaAssignment`. `replicaAction` does nothing, and the relabel moves it.
+ - `TestUnverifiableManifestLeavesTheRecord`: the record is unchanged and the log names the host.
+ - In the activator, `TestLabelledStatelessRowStartsOnTheNewBox`: a row with `Assigned` set, `Moved` true and a stateless generation starts without a database restore. Expected to be a pin; if it is red, fix it in this task.
+- [ ] **Step 2: Run them and confirm they fail.** Run `go test ./internal/console -run 'TestLostBoxMovesAnAlwaysOn|TestDrainMovesAnAlwaysOn|TestOneCopyStateless|TestUnverifiableManifest' -count=1`.
+- [ ] **Step 3: Implement `movableVerified`** and switch both call sites to it.
+- [ ] **Step 4: Run Step 2's command, plus `-run 'TestLostBoxMovesToTheSurvivor|TestDrain'` and `go test ./internal/activator -run TestLabelledStatelessRowStartsOnTheNewBox -count=1`.** Expected: PASS.
+- [ ] **Step 5: Commit.** `console: relabel and drain verify always-on stateless records (R3)`.
+
+**Review gate:** Astra.
+
+### Task 4: The first-label writer and the owner's door
+
+**Files:**
+- Modify: `internal/provision/fleetbox.go`. Add `SetRecordFirstFleetBox` and its errors.
+- Modify: `internal/release/layoutintent.go`. Add `FleetRecordLabelFloor`, set to release A's tag.
+- Create: `internal/console/instancelabel.go`, `internal/console/instancelabel_test.go`
+- Create: `internal/provision/fleetbox_first_test.go`
+- Modify: `internal/console/routedecls.go` (route), `parity/parity.tsv` (row `instances-label`)
+
+**Interfaces:**
+- Produces, in `provision`:
+ ```go
+ var (
+ ErrFleetBoxNotFirst = errors.New("provision: the record is already tied to a box")
+ ErrFleetBoxAssigned = errors.New("provision: the record has a replica assignment")
+ ErrFleetBoxMoveInFlight = errors.New("provision: the record has a move in flight")
+ ErrFleetBoxCoordinated = errors.New("provision: another box coordinates the record")
+ )
+ func SetRecordFirstFleetBox(ctx context.Context, s release.Store, acct, app, host string,
+ want FleetBoxExpect, label string, at time.Time) (*Record, error)
+ ```
+ It also returns the existing `ErrFleetBoxMoved` (expectation, retired) and `ErrFleetBoxImportInFlight`. All checks run inside the `updateRecord` mutation. A test seam, `firstLabelBeforeWrite func(host string)`, nil in production, runs after the read and before the CAS.
+- Produces, in `console`:
+ ```go
+ type instanceLabelAnswer struct {
+ Host, Fleet, Label string
+ Binding *labelBinding `json:"binding"` // {Box string; BoundAt int64; AfterCreate bool}
+ HubBox string `json:"hub_box"`
+ Agree bool `json:"agree"`
+ ServingBox string `json:"serving_box"`
+ Box string `json:"box"`
+ Eligible bool `json:"eligible"`
+ WhyNot string `json:"why_not"`
+ Applied bool `json:"applied"`
+ }
+ func (s *Server) handleAPIInstanceLabel(w http.ResponseWriter, r *http.Request)
+ ```
+ `WhyNot` codes, each mapped to a copy key in T7: `not_fleet`, `labelled`, `assigned`, `move`, `import`, `coordinated`, `not_active`, `draining`, `stale`, `runtime`, `floor`, `not_serving`, `disagree`, `no_evidence`, `unmovable:<static|addr|always_on|unit|ha|demo>`, `sidecars`, `incomplete`, `changed`, `mark_failed`.
+- Route: `{Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/label", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIInstanceLabel}`.
+
+**Behaviour:** As in spec §5. The steps, in order:
+
+1. Owner gate, then the app checks, a judged record read and fleet ownership. A host-claim console answers C33.
+2. Under `lockFleet`: a fresh `findFleetBox`, then the complete view (R4 and `v.Complete`).
+3. The binding read and the hub row (`reg.Get(host)` forward row `FleetBox`).
+4. The §4 serving-box rule, then per-record `movableVerified`.
+5. Unless `dry_run`: `MarkFleetBoxLabelled`, then `SetRecordFirstFleetBox(..., time.Now())`, then `bumpSerial`.
+
+A `MarkFleetBoxLabelled` failure is `mark_failed`. A writer error maps to its code. A competing first label that won is `labelled` with `Label` set to the winner (C34).
+
+- [ ] **Step 1: Write the failing writer tests** in `fleetbox_first_test.go`:
+ - `TestFirstLabelWritesMovedAndAt`: `FleetBox`, `FleetBoxAt` equal to `at` (RFC 3339 nanoseconds UTC), and `FleetBoxMoved` true.
+ - `TestFirstLabelRefusesALabelledRecord`.
+ - `TestFirstLabelRefusesAnAssignment`.
+ - `TestFirstLabelRefusesAMove`.
+ - `TestFirstLabelRefusesABlockingSeed`.
+ - `TestFirstLabelRefusesALiveCoordinatorElsewhere`. An expired one is allowed: `TestFirstLabelAllowsAnExpiredCoordinator`.
+ - `TestFirstLabelRefusesARetiredRecord`.
+ - `TestFirstLabelRefusesABadLabel`.
+ - CAS-retry barriers using `firstLabelBeforeWrite`. Each injects a change, plus a store conflict on the first PUT, and asserts the refusal on the retry: `TestFirstLabelRetryRefusesRetirement`, `...RetryRefusesSeedBlock`, `...RetryRefusesAssignment`, `...RetryRefusesCoordinator`, `...RetryRefusesCompetingLabel`.
+- [ ] **Step 2: Write the failing door tests** in `instancelabel_test.go`:
+ - Authorization:
+ - `TestLabelDoorOwnerOnly`: a member gets 403 with C18.
+ - `TestLabelDoorNonMemberIs404`: byte-identical to an unknown app.
+ - `TestLabelDoorRefusesServiceRoles`: admin and app credentials.
+ - `TestLabelDoorRefusesAFleetBoxToken`: a real fleet box bearer, with tunnel headers.
+ - `TestLabelDoorWrongAccountRecordIs404`.
+ - `TestLabelDoorWrongFleetBox`: a box of another fleet gives `not_active`.
+ - Records:
+ - `TestLabelDoorRetiredRecordIs404`.
+ - `TestLabelDoorRefusesMoveAndAssignment`.
+ - Boxes:
+ - `TestLabelDoorDetachedBox`.
+ - `TestLabelDoorDrainingBox`.
+ - `TestLabelDoorStaleBox`.
+ - `TestLabelDoorFloor`: one fleet box below `FleetRecordLabelFloor` gives `floor`.
+ - `TestLabelDoorIncompleteView`: the view returns `Complete == false` with a nil error, giving `incomplete`.
+ - Evidence:
+ - `TestLabelDoorLabelsTheServingBox`: binding and hub agree on `pi-1`, and `--box pi-1` gives `applied` true, the record labelled, and a serial bump.
+ - `TestLabelDoorRefusesAnotherBox`: `not_serving`, with the record unchanged.
+ - `TestLabelDoorRefusesDisagreement`.
+ - `TestBindingDatedBeforeCreateIsNoEvidence`.
+ - `TestMissingHubRowIsNoEvidence`.
+ - The rest:
+ - `TestLabelDoorDryRunWritesNothing`: no record PUT, no serial write, no `MarkFleetBoxLabelled`.
+ - `TestLabelDoorOneBoxFleet`: agreeing evidence labels the sole box.
+ - `TestLabelDoorUnmovable`: each reason.
+ - `TestLabelDoorSidecars`.
+ - `TestLabelDoorHostClaimConsole`: C33.
+ - `TestLabelDoorDetachedBetweenCheckAndWrite`: a barrier detaches after the registry read and before the mark. The mark refuses, giving `mark_failed`, with the record unchanged.
+ - `TestLabelDoorMarkSurvivesFailedWrite`: the writer fails after the mark, `LabelledAt` is set, and the answer is not applied. This pins the spec's stated non-atomicity.
+ - `TestLabelDoorConcurrentLabels`: two requests with a barrier, one `applied`, one `labelled`.
+- [ ] **Step 3: Run them and confirm they fail.** Run `go test ./internal/provision -run TestFirstLabel -count=1` and `go test ./internal/console -run 'TestLabelDoor|TestBindingDatedBeforeCreate|TestMissingHubRow' -count=1`. Expected: undefined, then FAIL.
+- [ ] **Step 4: Implement the writer, the floor constant, the door, the route and the parity row.** Then run `make parity-doc`.
+- [ ] **Step 5: Run Step 3's commands, plus `go test ./internal/console -run 'TestParity|TestRouteDecl' -count=1` and `go test . -run 'TestParity' -count=1`.** Expected: PASS.
+- [ ] **Step 6: Commit.** `console: owner ties an unlabelled fleet record to its serving box`.
+
+**Review gate:** Astra (security gate, record writer). Census: record-write units in T8.
+
+### Task 5: `carlos instances label`
+
+**Files:**
+- Modify: `instances_cli.go`: `runInstancesLabel`, modelled on `runInstancesRetry` at `:1216-1250`. Add a usage line to `instancesRecordsUsage` (`:221-233`).
+- Modify: the API session file holding `instanceRetry`. Add `instanceLabel`.
+- Modify: `commands.go` (the clireg node `label` under `instances`)
+- Test: `instances_cli_label_test.go` (new). It goes through `carlosTestEnv` with `cmd.Dir` set to scratch (AGENTS.md).
+
+**Interfaces:**
+- Consumes: T4's answer and route.
+- Produces: `func (s *apiSession) instanceLabel(ctx context.Context, acct apiAcct, app, host, box string, dryRun bool) (*instanceLabelAnswer, error)`. A client-side mirror of T4's struct.
+
+**Behaviour:**
+- Positional host, lowercased and trimmed.
+- `--box` and `--dry-run` flags with C03 and C04 help.
+- No `--box` means `dry_run` true.
+- It prints C06-C17 from the answer, and prints "tied" (C17) only when `applied` is true.
+- A `why_not` prints its copy and exits non-zero.
+- A timeout or connection loss after sending a write prints C38 and exits non-zero.
+
+- [ ] **Step 1: Write the failing tests** against an `httptest` console stub:
+ - `TestInstancesLabelDryRunByDefault`: the request has `dry_run` true and the output has C13 and C16.
+ - `TestInstancesLabelAppliedPrintsTied`.
+ - `TestInstancesLabelUnappliedIsNotTied`: 200 with `applied` false never prints C17.
+ - `TestInstancesLabelRefusalExitsNonZero`, for each code.
+ - `TestInstancesLabelUnknownOutcome`: the stub hangs past the deadline, through a channel barrier. C38.
+ - `TestInstancesLabelNormalisesTheHost`.
+ - `TestInstancesLabelArgErrors`: none or two hosts give C05.
+- [ ] **Step 2: Run them and confirm they fail.** Run `go test . -run TestInstancesLabel -count=1`.
+- [ ] **Step 3: Implement** the verb, the session method and the clireg node. Then run `make parity-doc`.
+- [ ] **Step 4: Run `go test . -run 'TestInstancesLabel|TestParityCLIPaths|TestParityCLIAudience|TestParityPageIsCurrent' -count=1`.** Expected: PASS.
+- [ ] **Step 5: Commit.** `cli: carlos instances label`.
+
+**Review gate:** Astra. The UX pass on the human output happens in T7, before the copy review.
+
+### Task 6: Create on multi-box fleets, and the worker's first labelling off
+
+Part B lands in M1 (release A). Part A lands in M2.
+
+**Files:**
+- Modify: `internal/console/apiinstances.go:2158-2176`, `:2511-2530`
+- Modify: `internal/console/fleetrelabel.go:157-166`. Remove the call and `planFirstLabelling` (`:191-217`).
+- Modify: `internal/console/fleetbox.go:139-141`. `labelActive` drops `!v.Unmovable` for creates; drain keeps its per-record refusal.
+- Test: `internal/console/apiinstances_test.go`, `internal/console/fleetrelabel_test.go`, `internal/host/fleettwobox_e2e_test.go`
+
+**Behaviour, Part A (spec D1):**
+- On a fleet with two or more active boxes, a create of a platform-run process record is labelled with `chooseDestination` and the verified manifest, or refused with 503, `Retry-After: 30` and C39. Refusals are for an incomplete view, no destination, below the label floor, sidecars, or a failed mark. All of these happen before any record, environment or claim write.
+- A platform-run process that `movableVerified` rejects (always-on stateful, unit-backed, HA) is refused with C42.
+- Static and `Addr` records, seeds and imports (`seedPlacementRefusal`), demos, and host-claim consoles are unchanged.
+
+**Behaviour, Part B (spec D2):** The worker never writes a first label. Its lost, draining and detached handling stays.
+
+- [ ] **Step 1: Write the failing tests (Part B).**
+ - `TestFirstLabellingIsOff` replaces `TestFirstLabellingFollowsBindings`. An unlabelled record with a valid binding stays unlabelled across three passes at explicit times.
+ - Keep `TestLostBoxMovesToTheSurvivor` green.
+ - Rewrite `TestTwoBoxFleetEndToEnd_RealFirstLabelling` as `TestTwoBoxFleetEndToEnd_RealNoAutomaticFirstLabel`: the pass leaves both fixtures unlabelled.
+- [ ] **Step 2: Run them and confirm `TestFirstLabellingIsOff` fails.** Run `go test ./internal/console -run 'TestFirstLabelling|TestLostBox' -count=1` and `go test ./internal/host -run TestTwoBoxFleetEndToEnd_RealNoAutomaticFirstLabel -count=1`.
+- [ ] **Step 3: Remove the first-labelling path.** Commit: `console: the relabel worker no longer writes first labels (D2)`.
+- [ ] **Step 4: Write the failing tests (Part A).**
+ - `TestCreateRefusesWhenNoDestination`: assert zero record, environment and claim writes through a counting store.
+ - `TestCreateRefusesBelowLabelFloor`.
+ - `TestCreateRefusesWithSidecars`.
+ - `TestCreateRefusesOnIncompleteView`.
+ - `TestCreateRefusesWhenMarkFails`.
+ - `TestCreateLabelsAFreshSurvivor`: one box stale, one fresh, so it is labelled to the fresh one.
+ - `TestCreateLabelsMovableBesideAnUnmovable`.
+ - `TestCreateRefusesAlwaysOnStatefulOnMultiBox`.
+ - `TestCreateLabelsAlwaysOnStateless`: the spec's Q11 gap.
+ - `TestCreateSeedOnFleetStillRefused`.
+ - `TestCreateOnHostClaimConsoleUnchanged`.
+ - `TestCreateOnOneBoxFleetUnchanged`.
+- [ ] **Step 5: Run them and confirm they fail.** Run `go test ./internal/console -run 'TestCreate(Refuses|Labels|Seed|OnHostClaim|OnOneBox)' -count=1`.
+- [ ] **Step 6: Implement Part A.**
+- [ ] **Step 7: Run Step 5's command, plus `-run 'TestAPIInstanceCreate|TestRootfsCreate'`.** Expected: PASS.
+- [ ] **Step 8: Commit.** `console: no unlabelled process creates on multi-box fleets (D1)`.
+
+**Review gate:** Astra (Part B before M1, Part A before M2).
+
+### Task 7: Copy deck and docs
+
+**Files:**
+- Modify: the files holding the C-strings (from T2, T4, T5 and T6), and the guard's `copiesUnlabelled` and `copiesUnlabelledGrowth` (C41, C40)
+- Create: `docs/drafts/fleet-record-labels/` (the copy-review deck, with `serve.sh` per the copy-review skill)
+- Modify: `docs/site/cli.md`. Add the heading `### carlos instances label`, with a dry-run example using neutral names (shop, example.com).
+
+**Behaviour:**
+- Every string from spec §9 is in the code, marked `// draft for copy review (Cnn)`.
+- First a UX pass on the CLI output (AGENTS.md "Every UI change gets a UX pass"): state first, little reading.
+- Then the deck goes to Paul's shared copy review. Approved text is applied verbatim before release B.
+
+- [ ] **Step 1: Do the UX pass** on a captured dry-run and a refusal. Record the changes in the deck notes.
+- [ ] **Step 2: Build the deck** with every key C01-C44 and serve it.
+- [ ] **Step 3: Write `TestInstancesLabelCopyKeysPresent`.** It fails when any C-key named in the spec has no draft marker in the tree. Run `go test . -run TestInstancesLabelCopyKeysPresent -count=1`, expecting FAIL before the strings are marked, then PASS.
+- [ ] **Step 4: Update the docs.** Run `go test ./internal/docsite -count=1`. Expected: PASS.
+- [ ] **Step 5: Commit.** `docs: carlos instances label, copy deck for review`.
+- [ ] **Step 6: After Paul's review, apply the approved copy.** Rerun Steps 3 and 4. Commit `copy: apply approved fleet record label strings`.
+
+**Review gate:** Astra (light); the copy review is Paul's.
+
+### Task 8: Census cards
+
+**Files:**
+- Create: `internal/provision/fleet_record_labels_census_test.go` (the record-write overlay)
+- Modify: `internal/provision/plan9_b8_census_test.go:56`. Add `"setrecordfirstfleetbox": true` to `censusKeyExact`.
+- Create, via `make census-propose`: `testdata/plan14-root-reads-fleet-record-labels-m1.tsv`, `-m2.tsv`, and the `docs/superpowers/notes/census-proposal-*.md` cards
+
+**Behaviour:**
+- Record-write units:
+ - `SetRecordFirstFleetBox` (record-writer, `key:SetRecordFirstFleetBox,key:updateRecord`);
+ - `Server.handleAPIInstanceLabel` (record-writer);
+ - the changed digests of `Server.handleAPIInstanceCreate`, `Server.relabelFleet` and `Server.drainBox`, and the removal of `planFirstLabelling`, wherever they are pinned.
+- Root-read cards for M1 (activator, lease, host) and M2 (provision, release, root package `instances_cli.go`). Claim: no new root read.
+- Each card's verdict comes from Astra, recorded on #280 with the reviewer and the tip.
+
+- [ ] **Step 1: Before each merge, run `make census-card`** and write CLAIMS: one line per changed unit, saying what changed and that no read was added.
+- [ ] **Step 2: Run `make census-propose NAME=fleet-record-labels-m1 CLAIMS=<file>`** (then `-m2`). Expected: it writes the overlay and the card, and the census is clean.
+- [ ] **Step 3: Run `go test ./internal/provision -run 'TestPlan14RootReadCensus|TestPlan9B8|TestCensusScopeIsTheRootBinary' -count=1`.** Expected: PASS.
+- [ ] **Step 4: Commit.** `census: fleet record labels <m1|m2>`. Brief Astra from `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`, and record the verdict on #280.
+
+**Review gate:** Astra's census verdict.
+
+### Task 9: Dev drill
+
+**Prerequisites:**
+- Release B is on dev.
+- A live window is booked on #421 through the release manager.
+- Paul's scoped approval covers a temporary box-2 on fleet r10r (dev account): instance type, duration and teardown.
+- The hostname-history window is planned (the 1b drill cost about 58 s of dev console downtime).
+
+Evidence goes to `~/.cache/fleet-record-labels-drill/`, outside the repo, and is removed by exact path after the report is posted on #1008.
+
+- [ ] **Step 1: Make the fixtures.** While r10r has one box, create two stateful hibernating instances of a sample app (shop). Each writes an advancing sequence row, with one write per request. Add box-2. Confirm both are still unlabelled. The worker is off since release A; re-check before every later step.
+- [ ] **Step 2: Dry run each** with `carlos instances label --app shop <host>`. Record the binding, the hub box and `serving_box`. On each box, read `lock.json` and the lease owner, and compare.
+- [ ] **Step 3: No-handover case.** Tie instance 1 to `serving_box`. Witness:
+ - the same process and generation;
+ - the lease owner unchanged;
+ - the sequence keeps advancing;
+ - the other box drops its row;
+ - the next wake restores once.
+- [ ] **Step 4: Handover case through wrong evidence.** On instance 2, with box-1 serving, write a binding naming box-2 into the dev deployment bucket, and wait for the hub stamp to copy it (confirm by reading the hub row). Tie it to box-2. Witness under a steady GET and POST loop:
+ - box-1 stops once with a proven checkpoint (no C44);
+ - the lease owner changes once;
+ - box-2 restores the last committed sequence value, and writes continue from it;
+ - failures are limited to requests in flight at the stop and during the one wake.
+
+ Record the measured outage.
+- [ ] **Step 5: Fence case (R1).** Pause box-1's agent reconcile, using the drill's documented hook or a stopped agent with the edge up. Wake instance 2 through box-1. It is refused with the R1 message, and box-1's older copy is not served.
+- [ ] **Step 6: Refusals.** A draining box, a stale box, a non-owner member, a box below the floor (if available), disagreeing evidence, and `--box` naming the non-serving box.
+- [ ] **Step 7: Go stateless.** Ship shop `--stateless --copies 2`. It is accepted, each instance keeps its labelled box, and the loop stays clean.
+- [ ] **Step 8: Teardown.**
+ 1. `--copies 1`.
+ 2. `carlos fleets drain r10r box-2`, and wait until it is empty.
+ 3. Terminate the machine.
+ 4. Only then, `carlos fleets detach-box --terminated r10r box-2`.
+ 5. Confirm both records are on box-1.
+- [ ] **Step 9: Post the report on #1008**, with the measured outage, the lease owner timeline and the sequence values. Tell the release manager, whose go starts the flagship roll.
+
+**Review gate:** the release manager reads the report before flagship.
+
+---
+
+## Self-review notes
+
+- Spec coverage:
+ - R1 is T1, R2 is T2 (T4 sets Moved), R3 is T3, and R4 is T4 (floor and view).
+ - §4 and §5 are T4 and T5.
+ - D1 is T6 Part A, D2 is T6 Part B in M1, D3 needs no code (guard copy in T7), and D4 is already verified.
+ - Copy is T7, census T8, rollout T9.
+- Types: `SetRecordFirstFleetBox`, `instanceLabelAnswer`, `movableVerified`, `CloseProven`, `ErrCheckpointUnproven` and `FleetRecordLabelFloor` are each defined once, in the task named, and used by name after that.
+- Execution: subagent-driven is recommended. The tasks touch termination, storage and a security gate, so each wants its own Astra gate before the next starts.