carlos / platform Public

Plan 1b: marker written when the copy is established (build ruling)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 8820081ae7271b6750a055b62d741c5dc2104041 parent 1c1f7c2
1 file changed, +1 −1
  • docs/superpowers/plans/2026-10-30-managed-fleets-1b-box-per-instance.md +1 −1
diff --git a/docs/superpowers/plans/2026-10-30-managed-fleets-1b-box-per-instance.md b/docs/superpowers/plans/2026-10-30-managed-fleets-1b-box-per-instance.md
index 1d2a6d17d..0b0adbf00 100644
--- a/docs/superpowers/plans/2026-10-30-managed-fleets-1b-box-per-instance.md
+++ b/docs/superpowers/plans/2026-10-30-managed-fleets-1b-box-per-instance.md
@@ -93,7 +93,7 @@
**Interfaces (produces):**
- `func (b *ExecBackend) reconcileAssignment(rt registry.Route, dbPath string) error`: when `rt.Assigned` is set and the marker `dbPath + ".assigned"` is missing or differs, move the database and its litestream sidecar state (the files `reconcileSeedMarker` would remove) into `<data dir>/.superseded/<host>/<unix nanos>.partial/`, then rename that directory to drop `.partial`. An interrupted move leaves a `.partial` directory, which counts as set aside.
- `func (b *ExecBackend) startAllowed(rt registry.Route, haveLocal, restored bool) error`: the one rule. Returns nil for a kept copy under the current marker or a successful restore; for neither, nil only when `!rt.Moved` and no `.superseded/<host>/` entry exists; otherwise `ErrNothingToRestore`, whose message names the set-aside path (or says the instance has moved and no replica was found). Every start path on a fleet box that would boot without a restored or kept copy calls it.
-- The marker is written atomically (temp file and rename) only after `startAllowed` returned nil and the start succeeded.
+- The marker records that the local copy belongs to the current assignment. It is written atomically and durably (temp file, fsync, rename, fsync of the directory) when the copy is established: after a successful restore, when a kept copy matches, or when `startAllowed` permits an empty start, before the spawn (controller ruling during the build; a new instance whose first start fails must not refuse forever).
- [ ] **Step 1: Write the failing tests** (fault injection where named). `TestAssignmentChangeSetsTheCopyAside` (files moved, nothing deleted, restore runs, marker updated); `TestSameAssignmentKeepsTheWarmCopy`; `TestUnassignedRouteIgnoresTheRule` (today's behaviour); `TestMissingMarkerSetsAside`; `TestNothingToRestoreRefusesEveryTime` (set aside, no replica: the first wake, a second wake, and a wake through a fresh `ExecBackend` over the same data dir (agent restart) all refuse; no fresh boot); `TestInterruptedSetAsideRefuses` (a `.partial` directory left by a crash: refused); `TestMovedInstanceOnACleanBoxRefusesWithoutReplica`; `TestNewInstanceBootsFresh` (never moved, nothing set aside, no replica: fresh boot, marker written); `TestFailedRestoreLeavesNoMarker`; `TestUnreplicatedTailSurvives`; `TestEveryFreshBootPathConsultsTheRule` (a guard test over the fresh-boot call sites: each one on a fleet box goes through `startAllowed`).
- [ ] **Step 2: Run them to see them fail.** `R=$(mktemp -d /tmp/k.XXXX) && TMPDIR=$R go test ./internal/activator/ -run 'AssignmentChange|SameAssignment|UnassignedRoute|MissingMarker|NothingToRestore|InterruptedSetAside|MovedInstance|NewInstanceBootsFresh|FailedRestoreLeaves|UnreplicatedTail|EveryFreshBootPath'; rm -r $R` → FAIL.