carlos / platform Public

Managed fleets 1b: ledger note and whole-branch review brief R1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev d52fa9a16b45b481e7099398a944035b74f51c0d parent bbbcee2
2 files changed, +98 −0
  • docs/superpowers/notes/managed-fleets-1b-ledger.md +49 −0
  • docs/superpowers/plans/CODEX-REVIEW-BRIEF-MANAGED-FLEETS-1B-BRANCH.md +49 −0

CI failed — run details

diff --git a/docs/superpowers/notes/managed-fleets-1b-ledger.md b/docs/superpowers/notes/managed-fleets-1b-ledger.md
new file mode 100644
index 000000000..7d28286c7
--- /dev/null
+++ b/docs/superpowers/notes/managed-fleets-1b-ledger.md
@@ -0,0 +1,49 @@
+# Managed fleets 1b: build rulings and deferred minors (from the SDD ledger)
+
+| T1 self | test "SetRecordRegion ... keep FleetBoxMoved as is" reads muddled | Ruling: SetRecordRegion clears FleetBox and FleetBoxAt and leaves FleetBoxMoved unchanged (a placement change between fleets is cut after hostname-history activation anyway) — cost if wrong: one field |
+| T6 self | spans box side (heartbeat fields, durable failed-final-sync record in activator/host/status) and console side (worker, drain, detach, CLI, docs, registry columns) | Ruling: split into T6a (box side) and T6b (console side, consumes T6a's heartbeat fields) — two review surfaces, same plan text — cost if wrong: one extra dispatch |
+Task 1: Ruling: TestPlan14RootReadCensus envelope drift (internal/provision) is left for Task 8 Step 1 (one census-propose for the whole branch) — every later task moves the envelope again — cost if wrong: CI red on intermediate pushes only
+Task 1: minor (deferred): add a conflict-injection test where an expected field changes between the read and the write of SetRecordFleetBox (correct by inspection)
+Task 2: Ruling: existing private wire types fleetView/fleetBoxView renamed fleetWire/fleetBoxWire so the plan's names hold — no behaviour change — cost if wrong: a rename
+Task 2: Ruling: fleetView.Unmovable added (labelActive needs it) — the brief's struct lacked room — cost if wrong: none
+Task 2: Ruling: a static record with Hibernate unset counts as movable — static content is served from the bucket by whichever box holds the route — cost if wrong: a static app gets a label it does not need
+Task 2: Ruling: gate (c) counts every listed heartbeat, stale or detached included (an old report keeps the gate closed until it leaves the 24 h listing) — conservative, fails closed — cost if wrong: labelling starts up to a day later after a box is retired
+Task 2: Ruling: seeded and imported creates release the fleet lock and stay unlabelled; Task 6 labels them from their bindings — keeps the seed path unchanged — cost if wrong: those instances run unlabelled until their first wake binds them
+Task 2: Ruling (supersedes the static ruling above): static records are never labelled and do not close the gate; they stay unlabelled so every box mints and serves them as today — they have no process to stop or start, and serving static content from every box is harmless — cost if wrong: static apps keep today's routing on labelled fleets
+Task 2: minor (deferred): rootfs and sidecar tests sit in fleetbox_test.go instead of rootfs_test.go / apisidecars_test.go
+Task 6 (pre-ruling, from Task 2 fix round 1): Ruling: labelActive() gates only NEW labelling (create-time labels and first labelling); moving already-labelled records off a lost or draining box needs only a complete inventory, a valid destination, and no below-floor box in the fleet (the pause) — a lost box has no fresh heartbeat by definition, so the activation gate would block the very move it exists for — cost if wrong: moves of a fleet with a long-dead box proceed without fresh version evidence of that dead box (it cannot mint anything while dead)
+Task 3: Ruling: keep the extra guard (FleetBox set only when CARLOS_FLEET's placement equals CARLOS_REGION) — a misconfigured box fails closed — cost if wrong: a box with a mismatched env mints only unlabelled records
+Task 3: Ruling: a fleet box whose identity is unknown removes its rows of labelled records (instances stop; nothing in the bucket is deleted) — fails closed for data; the lease and start rule protect storage either way, and an identity misconfig is visible in its log and heartbeat — cost if wrong: an outage on that box until its env is fixed
+Task 3: Ruling: the import journal (journalPass) is left label-blind; a relabel mid-import behaves like today's region flip — imports onto multi-box fleets are rare and the journal rolls back safely — cost if wrong: one rolled-back import
+Task 3: Ruling (supersedes the journalPass ruling above): journal recovery must respect ownership — for a journal host whose record is labelled for another box, recovery takes the same rollback a region flip takes today and the removal exemption no longer protects it, so the former owner retires the row — Astra R1 showed the exemption would keep another boxs row forever — cost if wrong: an in-flight import onto a relabelled host is rolled back
+Task 3: minor (deferred): close registries opened in fleetassigned_test.go:15 and reconcile_test.go:3876 with t.Cleanup
+Task 3: Ruling (supersedes the journal-rollback ruling): option A — SetRecordFleetBox refuses to relabel while the record has an import in flight, exactly as SetRecordRegion refuses a region move (seedMoveRefusal/MoveBlock); committed imports already reach normal removal on the next pass — the rollback premise did not match the code (region flips have no rollback; a rollback would restore an operator row; cleanup stalls) — cost if wrong: a relabel waits until the import commits
+Task 4: Ruling (corrects my dispatch ruling "marker only after the start succeeded"): the marker records that the local copy belongs to the current assignment, so it is written when the copy is established — after a successful restore, when a kept copy matches, or when startAllowed permits an empty start (before the spawn) — not on start success; the plan text says the same ("after a successful restore, a kept matching copy, or a fresh boot") — otherwise a new instance whose first start fails refuses forever — cost if wrong: none for data (the copy is this assignment's either way)
+Task 4: Ruling: a tenant able to write the marker in the nested layout can only keep its own stale copy; accepted (the .superseded root is in the agent's DataDir) — cost if wrong: a tenant harms only its own data
+Task 4: Ruling: on first labelling the box's copy is set aside and the replica restored; an unreplicated tail survives in the set-aside copy, not in service — keeping the copy instead would trust a binding whose publication can fail (#470) — cost if wrong: seconds of unreplicated writes need operator recovery from .superseded
+Task 4: Ruling: labelled rows refuse to start on darwin and windows builds — fleet boxes run Linux only (rootfs and the agent layout require it) — cost if wrong: a developer laptop cannot run a labelled fleet row
+Task 4: Ruling (plan-mandated conflict raised by Astra R1 item 3): my establishment-time marker ruling stands; plan text updated to match (Task 4 Interfaces) — the plan line would make a new instance whose first start fails refuse forever — cost if wrong: none for data
+Task 4: minor (deferred): seed markers have the same missing directory fsync (pre-existing, outside 1b)
+Task 5: Ruling: Fingerprint also hashes fleet_label — without it a label matching an existing binding would not reload the edge — cost if wrong: one extra edge reload per labelling
+Task 5: Ruling: a label naming a detached box still wins (503 until relabel) — the drain rule makes detach of a labelled box wait anyway — cost if wrong: brief 503s after an operator bypass
+Task 5: minor (deferred): forward_test.go:971 write-count helper should check rows.Err()
+Task 6a: Ruling: build crash coverage now — a durable per-instance "unsynced" record written at wake (before the instance can write) and cleared after a successful final sync; ReplicationFailures counts records for instances this process does not currently hold — the drain rule must not finish while an unreplicated tail sits on disk after an agent crash — cost: two local durable writes per wake/sleep cycle, no bucket requests
+Task 6a: Ruling: leases whose renewal outlives a failed drop count as held, so a drain waits for an agent restart — fails safe — cost if wrong: a slow drain
+Task 6a: Ruling: accepted fail-safe edges — a wake that fails after the awake record keeps counting until a good sync or fresh restore (a drain may need an operator); a box with data-dir I/O errors refuses wakes; a box with no absolute data dir never reads as drained — each errs toward keeping data — cost if wrong: slower or operator-assisted drains
+Task 6a: Ruling (refuse up front, after Astra R1 findings 1, 2, 5 on HA paths): HA hosts are out of 1b's move machinery — 6a's awake and failure records skip HA routes entirely (and any HA record already written is ignored by the count), and Task 6b makes movable() false for an HA record so a fleet holding one is never labelled and a drain refuses it — HA has its own replication rules (markers, file publication) that the drain rule does not model — cost if wrong: HA instances on fleets cannot be drained or moved by 1b
+Task 6a: minor (deferred): report noise — one TestReleaseLeaseLossUnprovenLeavesTheHold timing flake (#460 family) and the packed-refs.lock warning
+Task 6a: Ruling: HA-skip implemented as skip-for-HA within the shared maintenance/opset calls (legacy hosts keep their records), not a removal — equivalent effect — cost if wrong: none
+Task 6a: minor (deferred): records left by a host before it became HA are not removed (no longer counted)
+Task 6a: Ruling (refines the HA ruling after re-review R1): with no activator the box cannot classify HA hosts and counts every durable record, including a record left by a host that later became HA — over-counting only delays a drain, never completes one early, and the no-activator box is a misconfiguration — cost if wrong: such a box never reads as drained until its stale record is cleared
+Task 6b: Ruling: accept the extra fleet_boxes.labelled_at column (lets the detach doors tell "holds or held labelled records") — without it a silent box whose records moved looks empty — cost if wrong: one column
+Task 6b: Ruling: one draining_since column, no separate draining flag — "draining" means it is set — Task 8's census text to be updated — cost if wrong: none
+Task 6b: Ruling: accept drainDone's extra conditions (newest heartbeat from a release at or above the floor; static routes ignored) — an older box always reports zero leases; static routes are served by every box — cost if wrong: none
+Task 6b: Ruling: accept that a fleet with any unlabelled instance refuses drains (every box runs it, so no box can report empty); the operator wakes or relabels it first — fails safe — cost if wrong: a drain waits on a sleeping unbound instance
+Task 6b: Ruling: drainDone requires the heartbeat to be composed at least 2 minutes after draining_since (clock-skew margin; boxes run NTP) — a box clock running ahead could otherwise pass a pre-drain heartbeat — cost: drains take 2 minutes longer
+Task 6b: minor (deferred): fleets_cli_test.go:584 should assert both rows are present before checking columns
+Task 7: Ruling: a record moved before its first wake refuses to start on the new box (start rule c: moved, no replica, no local copy) — the box cannot tell "never had data" from "data only on the lost box's disk"; refusing keeps data safe — cost: such an instance needs an operator; follow-up filed for an explicit start-empty override
+Task 7: Ruling: RunFleetRelabelPass(ctx, now) added by Task 7 (6b had not exported it) — the plan names it — cost if wrong: none
+Task 7: minor (deferred): lost-box test should assert acquisition happens only after the recorded expiry
+Task 7: minor (deferred): restore runs emit Litestream diagnostics in test output
+Task 7: minor (deferred): GOOS=darwin vet of internal/host fails on hawake_wiring_test.go:34 claimsOnEnv (reported pre-existing)
+Task 8: Ruling: Luna D4 drops "after 20 minutes" (the lost-box threshold) — accepted verbatim per the copy precedent; the vaguer sentence is still true — cost if wrong: the docs omit a timing detail
diff --git a/docs/superpowers/plans/CODEX-REVIEW-BRIEF-MANAGED-FLEETS-1B-BRANCH.md b/docs/superpowers/plans/CODEX-REVIEW-BRIEF-MANAGED-FLEETS-1B-BRANCH.md
new file mode 100644
index 000000000..dd10fe3bd
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-REVIEW-BRIEF-MANAGED-FLEETS-1B-BRANCH.md
@@ -0,0 +1,49 @@
+# Review brief: managed fleets 1b branch, round 1 of 3
+
+Repo carlos/platform, branch `managed-fleets-1b`, tip: the commit that adds this brief.
+Under review: the diff `c24e7a04b1..HEAD` (merge base with origin/main), code and tests; docs/superpowers files are context.
+Authorities (approved by Paul): spec `docs/superpowers/specs/2026-10-28-managed-fleets-design.md` §4 "1b addendum" rules 1-11; plan `docs/superpowers/plans/2026-10-30-managed-fleets-1b-box-per-instance.md` rev 4 (after three plan-review rounds; Paul ruled to skip a fourth). Build rulings and deferred minors: `docs/superpowers/notes/managed-fleets-1b-ledger.md`. Per-task Astra reviews passed for Tasks 1-7 (and 6a/6b).
+
+You are an independent reviewer. Read the diff, then the code it reaches, and check every claim against that code.
+
+## Fixed: do not re-argue
+
+- Paul's rulings in the spec: assignment time + marker (rule 6), gate and alert (rule 8: the accepted risk is a below-floor box added after labelling serving its own stale copy until an operator acts), two-step drain with drainDone as the only detach gate (rule 5), the start rule (rule 6), sidecars and HA and unmanaged processes out of the move machinery (rules 10, 11 and the build ruling on HA).
+- Build rulings in the ledger note. Raise one only with a concrete failure scenario.
+
+## What to check
+
+1. The two central invariants, end to end across tasks: (a) a fleet instance never boots stale or empty data it should not (startAllowed, set-aside, marker, moved flag); (b) a box is never detached before drainDone holds (heartbeat composed 2 minutes after draining_since, no routes, LeasesHeld 0, ReplicationFailures 0, at-floor release), with both doors under the fleet lock.
+2. One writer: labels, ownsRecord in every reconcile path, authoritative forward rows with no edge fallback, the relabel worker's conditional writes (FleetBoxExpect, ErrFleetBoxImportInFlight before ErrMoveConflict).
+3. Mixed versions and the gate: loadDeploymentBoxesComplete, missing heartbeats, incomplete listings, LABELS PAUSED/unknown.
+4. Request budget: the inventory cache and lifetime slot reads; no new per-box bucket polling.
+5. The merge of origin/main c24e7a04 into the branch (commit c822ac47): forward-row behaviour of 1a's follow-ups and the branch's label rule both hold.
+6. Plan Review Focus (verbatim below).
+7. Census approval: the card `docs/superpowers/notes/census-proposal-managed-fleets-1b.md`. Give a verdict per unit and per re-pinned envelope using the card's own review question. The record-write census entries for Task 6b's console units too.
+8. Triage the deferred minors in the ledger note: say which, if any, must be fixed before merge.
+
+## Review Focus
+
+1. **A box partitioned from the console but still renewing its lease** while its records move. Expect: the destination waits out the lease; the source drops the rows when it next reads the record; no writes are lost (the source's copy is set aside on any later return). Task 7.
+2. **First labelling of a running fleet.** Expect: every record is labelled to the box already serving it; nothing moves; each box sets its copy aside once and restores the same data. Tasks 4, 6, 7.
+3. **A rollback of one box below the floor after labelling.** Expect: relabelling pauses with an alert; nothing else changes. Task 6.
+4. **Drain with one record that has nowhere to go.** Expect: the drain refuses up front, naming the app, and relabels nothing. Task 6.
+5. **A placement change racing a relabel.** Expect: the relabel loses (`ErrFleetBoxMoved`) and the record stays unlabelled in its new fleet. Tasks 1 and 6.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work. Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The census, and review of any newly changed security, root, termination or production-storage behaviour, still check the fix; see AGENTS.md, "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the file, the problem, the evidence (file:line, verified), the failure scenario, a concrete fix and the invariant or trust boundary it breaks (its fault family). Then census verdicts, one line per unit and envelope. Then the minors triage. End with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another round.
+- **NOT READY**: one or more P1s, listed.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of your own. Do not run the full test suites; targeted `go test -run` is fine if your sandbox allows it.