carlos / platform Public

plans: fleet box restart wake (fenced refusal, live record on index miss)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4bc8451578a62351df27372f0e14947fec18022a parent fe854a4
1 file changed, +46 −0
  • docs/superpowers/plans/2026-11-21-fleet-restart-wake.md +46 −0

Intent

Attributed to this commit: 20.7 g CO₂e (2,520,376 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on fleet-restart-wake, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/superpowers/plans/2026-11-21-fleet-restart-wake.md b/docs/superpowers/plans/2026-11-21-fleet-restart-wake.md
new file mode 100644
index 000000000..2e5542510
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-21-fleet-restart-wake.md
@@ -0,0 +1,46 @@
+# Fleet box restart: wake a single-copy instance without the index wait and the false backoff
+
+Source: the 2026-11-21 Tito production v0.40.2 roll. A single-copy rootfs instance on a fleet box was down for 33 s across its box's agent restart, against about 5 to 11 s that the instance-control probe needs. Paul said go on 2026-11-21, relayed by Tito's session, for fixes (1) and (2) below. No spec change: this is a latency fix under existing rules. The investigation was read from code at v0.40.2; check every citation against this branch (main fe854a4e) before relying on it.
+
+Binding rules the fix must keep:
+- the lease;
+- the R1 stale-wake fence: the fresh record read at the exec gate (stateless.go statelessFinalRecord, cfg.Record);
+- R2 restore-required;
+- the maintenance fence and the instance-control readiness gate (no nested or rootfs start on an unproven box);
+- the moves hold view rule (moves spec §9.4);
+- region HA rules (spec §25 and §7.5; CI runs the grouproll tests and the region_ha boundary test).
+
+Review round limit: three; AGENTS.md stopping rules apply.
+
+## What happened (code at v0.40.2)
+
+1. The wake took the stateless launch path (activator.go doStatelessWake → prepareStateless → statelessObservation, stateless.go about line 316), because the build or its staged manifest declares stateless mode.
+2. An ordinary wake carries no replica-observation carrier, so it falls back to `a.cfg.ReplicaRecord(rt)` (stateless.go about 324). In the agent that is `replicaRecordFacts(boxLifetimes)` (internal/host/agent.go about 515 and 4351-4358), which returns bare `replicas.ErrFenced` on an index miss. `boxLifetimes` lives in memory, and only the reconcile pass's record scan fills it (reconcile.go about 1493-1498). After a restart it is empty until the first pass's scan, which starts only after the moves hold and offline keep views are built (fastboot.go).
+3. The always-on starter counts bare `replicas.ErrFenced` as a build failure (rootfs_service.go residentFailure / verdictOf about 486-501, 1155-1156; swap.go about 274-299), so it backs off 1, 2, 4, 8, 16 s with jitter (about 393-407). Request wakes meanwhile get a quiet 503 resident-backoff.
+
+## Global constraints
+
+- No new store reads on a timer. A live record read on an index miss is one read per wake attempt that would otherwise have failed; it must not run when the index answers.
+- A refusal never counts as a build failure. A build failure still backs off as today.
+- Targeted tests only (`-run`), never a full suite locally. Socket-binding packages need `TMPDIR=/tmp/g` with the sandbox off.
+- No tenant names in code, tests or comments.
+
+## Task 1: a fenced refusal is retried on the next tick, not backed off
+
+1. Find where the always-on (resident) starter and any other wake classifier decide refusal against failure (residentFailure, verdictOf, and the request path that answers resident-backoff). Make `replicas.ErrFenced`, bare or wrapped, a refusal everywhere the activator's own `ErrFenced` already is. List every classifier you checked in the report.
+2. A refusal sets the next attempt to the next resident tick (`residentPoll`, 2 s) and logs as a refusal (only when its text changes, as the other refusals do), never as "wake failed".
+3. Tests, deterministic with a fake clock or the existing seams: a resident instance whose launch returns bare `replicas.ErrFenced` three times, then succeeds, starts on the tick after the refusal stops, with no backoff growth; a genuine build failure still backs off as before.
+
+## Task 2: an index miss reads the record live
+
+1. In the agent's `ReplicaRecord` wiring (replicaRecordFacts), on a lifetime-index miss read the record from the store with the existing record-facts reader (haRecordFacts or whatever this branch has) instead of returning `replicas.ErrFenced`. An index hit stays as it is, with no read. A failed or absent live read keeps today's refusal.
+2. Do not populate or overwrite the shared index from this read: the index stays the reconcile scan's observation (lifetimeindex.go). Say in the report why that is safe.
+3. Show the R1 fence still decides: the exec gate's fresh record read still runs after this and still refuses a stale wake (a record whose box or incarnation changed between the live read and the gate). Name the test that proves it, existing or new.
+4. Tests, deterministic: a restarted agent (empty index) whose instance-control gate is ready starts an always-on single-copy instance without waiting for the first reconcile scan (block the scan on a barrier; the start must still happen); an absent record keeps the refusal; a record moved to another box is refused at the gate.
+5. Census: `make census-card`, CLAIMS file, `make census-propose NAME=fleet-restart-wake`; the controller gets it approved.
+
+## Out of scope
+
+- The instance-control probe's timing (a safety gate).
+- Fewer record walks per pass (#964, branch fleet-shared-walk).
+- Why the app's build declares stateless mode (Tito's to check).