carlos / platform Public

rootfs apps plan 3: startup sweep failure closes rootfs admission until restart (controller ruling)

After a failed startup sweep rootfs admission stays closed for the
Service's life, as seedSweptAtStart does; no retry, no rootfs-only
sweep, so internal/instancectl stays at client.go only (pre-flight 4.2).
The replaced-Service test now also asserts admission stays closed for
the Service's life.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 53b40c6ca6d38c36b815a64e52435378dc225b5f parent cfde03c
1 file changed, +21 −24
  • docs/superpowers/plans/2026-10-24-rootfs-apps-3-lifecycle.md +21 −24
diff --git a/docs/superpowers/plans/2026-10-24-rootfs-apps-3-lifecycle.md b/docs/superpowers/plans/2026-10-24-rootfs-apps-3-lifecycle.md
index 75e3bce4d..b40fb433b 100644
--- a/docs/superpowers/plans/2026-10-24-rootfs-apps-3-lifecycle.md
+++ b/docs/superpowers/plans/2026-10-24-rootfs-apps-3-lifecycle.md
@@ -6,7 +6,7 @@
**Architecture:** One immutable column, `routes.runtime` (Plan 2 Task 2), decides everything on the box. `registry.Route.ActivatorOwned()` replaces every `Kind == "instance" && Hibernate` test, so a non-hibernating rootfs row is the activator's, nested, lease-held and activator-replicated. Every start of a rootfs row, the overlap successor, the hold pin and the planned wake included, goes through Plan 2's rootfs start (Task N1), and every refusal comes before the lease (Task 7). A 2-second rootfs tick inside the activator's sweeper goroutine starts resident rows (four at a time, per-host backoff) and notices crashes. The `release` process (Group R, after A) is one service-owned operation in the rootfs cmd unit from the new image: before an overlap swap is admitted, under the incumbent's lease, the swap then running only on a proven pass; and inside a wake (planned, hold, or onto a build the row has not served), under the wake's lease. A failure is the build's failure, so the incumbent keeps serving; losing the lease stops it and proves it gone before the lease's safety deadline, and is never the build's failure. Until Group R lands, an app migrates in its own web command (`db:prepare` before the server, as Rails 8's Docker entrypoint does). Workers (Group W, after A) are `RoleWorker` units started after `web` is healthy and stopped first.
-**Tech Stack:** Go 1.26; `internal/registry`, `internal/provision`, `internal/activator` (state machine, `ExecBackend`, cmd unit), `internal/rollout`, `internal/edge`, `internal/ops`, `internal/layout`, `internal/host`, `internal/console`, `internal/runs`, `internal/rolloutwords`, `internal/status`, `internal/release`; systemd through `instancectl` (Plan 3 changes only `client.go` there, and `server.go`'s sweep, for a rootfs-only variant).
+**Tech Stack:** Go 1.26; `internal/registry`, `internal/provision`, `internal/activator` (state machine, `ExecBackend`, cmd unit), `internal/rollout`, `internal/edge`, `internal/ops`, `internal/layout`, `internal/host`, `internal/console`, `internal/runs`, `internal/rolloutwords`, `internal/status`, `internal/release`; systemd through `instancectl` (Plan 3 changes only `internal/instancectl/client.go` there).
**Spec:** `docs/superpowers/specs/2026-10-24-rootfs-apps-design.md` rev 5: §5.0 (record half), §5.2 (environment and deploy half), §5.2.1, §5.4, §5.5, §5.6, §7 C5, C7, C8. Index and shared contract: `docs/superpowers/plans/2026-10-24-rootfs-apps-0-index.md`. Prior design used for residency semantics only: `implementation/always-awake-exec.md`. Run design for the cmd unit: `docs/superpowers/specs/2026-10-08-carlos-run-design.md`.
@@ -118,7 +118,7 @@ Each is a name this plan consumes, checked against main at the amendment (a912a3
- Diagnostics (log lines, `ValidateShape` errors, test messages) are not copy and are not in the table.
- CI cross-compiles darwin and windows: linux-only code needs `//go:build linux` and a `!linux` stub. Nothing in this plan adds a syscall.
- Tests: locally only the touched packages, `go test ./internal/<pkg>/ -run 'TestX|TestY' -count=1`; CI runs the full suite. Leave `GOCACHE` at its default. Socket tests need a short `TMPDIR` (the repo's recipe: a short directory the runner creates and removes by name). Race-bearing tests are named in their task and run once with `-race` before the task's commit. New `internal/host` tests call `t.Parallel()` unless they set env, cwd, umask, log output or package vars.
-- No census task: main's census runs at merge (Paul, 2026-10-25) [pf 4.1]. The two invariants the census stood in for are tests: root reads SQLite only through the service-user child (Task 15), and Plan 3's diff touches no `internal/instancectl` file except `client.go` and `server.go`'s rootfs-only sweep (gate A) [pf 4.2; Astra R3 3].
+- No census task: main's census runs at merge (Paul, 2026-10-25) [pf 4.1]. The two invariants the census stood in for are tests: root reads SQLite only through the service-user child (Task 15), and Plan 3's diff touches no `internal/instancectl` file except `client.go` (gate A) [pf 4.2].
- Claims: host lifecycle claims are shelved. Plan 3 adds no reader of `Config.HostWrites` [pf 3.1]. While the switch exists, Plan 2's `rootfsGates` still refuses under it (`rootfs.go:155`), and Task 7's early gate inherits that, so nothing goes unrefused.
- Commits end with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.
@@ -146,7 +146,7 @@ Each is a name this plan consumes, checked against main at the amendment (a912a3
| `internal/activator/binary_golden_test.go`, `testdata/binary_golden/` (new) | INV-6's binary goldens | 1 |
| `plan3_groups_test.go` (new, root package) | per-group copy sets, the started and landed lists, the release and worker machinery inventory | 1, gates |
| `internal/host/retention.go` | resident records need a box report before retention deletes | 5 |
-| `internal/host/agent.go`, `rootfs_sweep.go` (new), `rootfsplacement.go` | `MarkRootfsSwept` after a clean startup sweep; the rootfs-only retry; ctx-bounded gate I/O | 7 |
+| `internal/host/agent.go`, `rootfsplacement.go` | `MarkRootfsSwept` after a clean startup sweep (never otherwise); ctx-bounded gate I/O | 7 |
| `internal/registry/runtime.go` (new) | `Route.Rootfs`, `ActivatorOwned`, `Resident`, `ErrRuntimeFixed` (Plan 2 owns `RuntimeRootfsV1`, `ValidRuntime` and the column) | 2 |
| `internal/registry/registry.go`, `remote.go`, `remote_dispatch.go` | `Upsert`'s hibernate and replication arms, `normalizeRoute`, `SetHibernate`'s refusal, `ResidentInstances`; `ErrRuntimeFixed` over the remote registry | 2 |
| `cli.go` | `carlos add` refuses an existing rootfs host (a diagnostic) | 2 |
@@ -157,7 +157,7 @@ Each is a name this plan consumes, checked against main at the amendment (a912a3
| `internal/release/pins.go` | `BuildStateKept` on `ActivatorOwned` | 5 |
| `internal/activator/rootfsenv.go` (new) | `rootfsCmdVars` (Task 6), `rootfsWorkerVars` (W1), on Plan 2's `rootfsVars` | 6, W1 |
| `internal/activator/genbackend.go`, `swap.go`, `wakeplan.go`, `backend_exec.go` | `StartStaged`'s rootfs arm; `KillHost`/`EmptyHost` refuse rootfs; the health bound in `genHealthy` and the verdict floor; `HasSidecar` false for rootfs | N1 |
-| `internal/instancectl/client.go`, `server.go` | `CmdRootfs` types root's pre-start refusals (N1); `SweepRootfs` and `handleSweep`'s `runtime=rootfs` filter (7); the only `instancectl` files Plan 3 changes | N1, 7 |
+| `internal/instancectl/client.go` | `CmdRootfs` types root's pre-start refusals (the only `instancectl` file Plan 3 changes) | N1 |
| `internal/activator/rootfs_service.go` (new; Plan 2 owns `rootfs.go`) | `healthBoundFor` (N1); start gates, `ArmRootfs`, first-wake budget (7); residency state and `rootfsTick` (8); the wake ceiling (R3) | N1, 7, 8, R3 |
| `internal/activator/rootfsdb.go` (new) | `ExecBackend.PlaceRootfsDB`, the empty SQLite database of D7 | 7 |
| `internal/activator/backend_rootfs.go` (new) | `Processes` (D); `stagedImageOf` (12); `StartRelease`, `ReleaseEnv` (R1); `LaunchRootfsWorker`, `RootfsWorkerGone` (W1) | D, 12, R1, W1 |
@@ -636,7 +636,7 @@ git commit -m "activator: StartStaged starts rootfs generations; the rootfs heal
- Modify: `internal/activator/wakeplan.go:381` and `awaitWake` (`activator.go:1606`, its deadline at `:1621`): `firstWakeBudgetFor(rt)`
- Modify: `internal/host/rollout.go:406`: `svc.ArmRootfs()` once the manager has armed (not in `refuseManaged`, `:210`)
- Modify: `internal/activator/rootfs.go` (Plan 2's `rootfsGates` and `rootfsGateCheck`, `:128-162`, take a `ctx`) and the two `ExecBackend` hooks they call, `RootfsOK` and `RootfsPlacement` (`backend_exec.go:218-219`, wired at `host/rootfsplacement.go:360-361`), which become `func(context.Context) error` and `func(context.Context, registry.Route) error`; `internal/host/rootfsplacement.go`: the readiness ask (`ready`, `:345-353`) and the fleet owner read (`read`, `:228-231`) derive their deadlines from that `ctx` instead of `context.Background()` [Astra R3 1]
-- Modify (the startup proof, Astra R3 3): `internal/host/agent.go` (the `Sweep` wrapper, `:660-668`); new `internal/host/rootfs_sweep.go` (`retryRootfsSweep`); `internal/instancectl/server.go` (`handleSweep`, `:934`, a `runtime=rootfs` query that lists only the four rootfs unit patterns, `:939`, and keeps only rootfs units from the job list); `internal/instancectl/client.go` (`SweepRootfs`)
+- Modify (the startup proof, Astra R3 3; controller ruling): `internal/host/agent.go` (the `Sweep` wrapper, `:660-668`, calls `svc.MarkRootfsSwept()` on a clean sweep and never otherwise). No `instancectl` file changes for it [pf 4.2]
**Interfaces:**
- Consumes: `a.gens`, `runs.MaxTimeout`, `firstWakeKillReserve` (`wakeplan.go:232`), N1's `healthBoundFor`, Plan 2's `rootfsGates` (`rootfs.go:128`) and `refuseRootfs`.
@@ -652,12 +652,9 @@ git commit -m "activator: StartStaged starts rootfs generations; the rootfs heal
func (a *Service) rootfsRefusalLocked(rt registry.Route) error // cheap, under a.mu: nil for a binary row with a valid
// runtime; !registry.ValidRuntime(rt.Runtime) -> errRuntimeUnknown; !a.gens || !a.rootfsArmed.Load() -> errRootfsUnarmed;
// !a.rootfsSwept.Load() -> errRootfsUnswept (the startup proof below)
- func (a *Service) MarkRootfsSwept() // a.rootfsSwept.Store(true); only internal/host calls it, once a sweep proved every
- // rootfs unit a previous agent left is gone; never cleared for the Service's life
- var errRootfsUnswept = errors.New("activator: rootfs instances wait for the startup sweep to prove every leftover rootfs unit gone")
- // internal/instancectl: func (c *Client) SweepRootfs(ctx context.Context) (SweepResponse, error) // POST /sweep?runtime=rootfs
- // internal/host: func retryRootfsSweep(ctx context.Context, sweep func(context.Context) (instancectl.SweepResponse, error),
- // mark func()) // 5 s doubling to 60 s, until a sweep answers with no error and no failed unit; then mark()
+ func (a *Service) MarkRootfsSwept() // a.rootfsSwept.Store(true); only internal/host calls it, once, when the startup sweep
+ // answered with no error; never cleared, and never set later in the Service's life
+ var errRootfsUnswept = errors.New("activator: rootfs instances stay off until the agent restarts: the startup sweep did not prove every leftover unit gone")
func (a *Service) rootfsStartRefusal(ctx context.Context, rt registry.Route) error // never with a.mu held: the locked half
// (taking a.mu briefly), then the backend's rootfsStartable(rt), shared per host (a singleflight, so a request storm on a
// cold host asks the gates once). Every non-nil answer of either half is marked with refuseRootfs (errRootfsRefused).
@@ -673,14 +670,14 @@ git commit -m "activator: StartStaged starts rootfs generations; the rootfs heal
// sql.Open("sqlite", path), "PRAGMA busy_timeout=5000", "PRAGMA journal_mode=WAL" (writes page 1), Close, read, remove
```
-`rootfsCtlHarness` (`rootfs_ctl_harness_test.go`, created here; Task 12 and Group R reuse it) is the real control handler behind an `ExecBackend` (Astra R1 finding 1): a real `instancectl.Server` (`Handler()`, `internal/instancectl/server.go:380`) on a unix socket under the short `TMPDIR`, with `PeerOK` returning nil; `Systemctl` a fake keyed by unit name (each unit's `show` answer, and `start`/`stop` recorded in order and changing that unit's state); `CgroupRoot` a fixture tree whose `cgroup.events` per unit the test sets; `OptDir` with build B staged at `release.VersionPath` and its root-written staged manifest (Plan 2's rootfs server fixture shape); `HostApp` answering the row's account and app; `ExeRoot` and `DropInDir` under `t.TempDir()`; a switch that makes the handler answer `/cmd` with a chosen pre-start status. The `ExecBackend` is `nestedBackend` with `Control: instancectl.NewClient(sock)` and `CgroupEvents` reading the same fixture tree. The binary `carlos-instance-cmd@<host>.service` exists in no answer: `show` reports it with no invocation and inactive, and its cgroup is absent, so a test passes only if every poll, stop and proof names the rootfs unit. It also answers `/sweep` (plain and `runtime=rootfs`) from the same systemctl fake, with a switch for a unit that will not stop.
+`rootfsCtlHarness` (`rootfs_ctl_harness_test.go`, created here; Task 12 and Group R reuse it) is the real control handler behind an `ExecBackend` (Astra R1 finding 1): a real `instancectl.Server` (`Handler()`, `internal/instancectl/server.go:380`) on a unix socket under the short `TMPDIR`, with `PeerOK` returning nil; `Systemctl` a fake keyed by unit name (each unit's `show` answer, and `start`/`stop` recorded in order and changing that unit's state); `CgroupRoot` a fixture tree whose `cgroup.events` per unit the test sets; `OptDir` with build B staged at `release.VersionPath` and its root-written staged manifest (Plan 2's rootfs server fixture shape); `HostApp` answering the row's account and app; `ExeRoot` and `DropInDir` under `t.TempDir()`; a switch that makes the handler answer `/cmd` with a chosen pre-start status. The `ExecBackend` is `nestedBackend` with `Control: instancectl.NewClient(sock)` and `CgroupEvents` reading the same fixture tree. The binary `carlos-instance-cmd@<host>.service` exists in no answer: `show` reports it with no invocation and inactive, and its cgroup is absent, so a test passes only if every poll, stop and proof names the rootfs unit. It also answers `/sweep` from the same systemctl fake, with a switch for a unit that will not stop.
The method is `rootfsStartRefusal`, not `rootfsRefusal`, because Plan 2's `rootfsRefusal` is the wrapper type `refuseRootfs` builds (`rootfs.go:58`). The first draft's `errRootfsClaim` and its claim reason are struck: Plan 3 reads no claim switch, and Plan 2's gates still refuse under it (`rootfs.go:155`), which this gate inherits [pf 3.1].
Rules:
- **Refuse before the lease (INV-3)** [pf 2.1]: `doWake` and `begin` refuse a rootfs row before `Acquire`, `Restore`, `LiveIdentity`, `recordBuild` or any entry state: `acquires == restores == materialized == 0`. Where each half runs [Astra R1 8]: `begin` asks `rootfsRefusalLocked` under its lock; on the path that would make a new entry (no live entry for the host) it drops `a.mu`, asks `rootfsStartRefusal`, retakes `a.mu` and re-checks from the top of its loop (an entry made meanwhile is coalesced on, as today), so an awake instance's requests never pay the gates and a cold one's pay them once per wake attempt; `doWake` asks `rootfsStartRefusal` off `a.mu` before step 0.5, for wakes that did not come through `begin` (due wakes, planned wakes, the tick); Task 8's tick asks it off `a.mu` for each candidate before it takes the lock to start one. Plan 2's `rootfsGates` still runs inside `Backend.Start`, after `Acquire`, `Restore` and `LiveIdentity` (which materializes the live link); asking it here first means a refused row pays none of that. The wake's member event is `RFS-3-C12` with the fragment `RFS-3-C14` for unarmed. An unknown runtime and a backend gate refusal log only (no member can cause the first; the second carries Plan 2's reason in the log). `serveWakeError` answers these 503 "instance failed to wake" (today's text). Task 8 asks the same gate in `rootfsTick`.
- `errRuntimeUnknown` is also returned for a binary-looking row whose `Runtime` is not valid, so no future value degrades to a binary launch.
-- **The startup proof** [Astra R3 3]. After an agent restart the old Service's obligations (a run's hold, Group R's release record, a worker's stray) are gone from memory, and `BindsTo` asks systemd to stop the old units but supplies no proof. On main `startActivator` (`internal/host/layoutleg.go:354`) calls `start()` whether or not the startup sweep succeeded, root keeps a unit's files when it cannot prove termination (`instancectl/server.go:986-995`), and `ReadyRootfs` (`instancectl/rootfs.go:1303`) reports only the probes, not that result. So rootfs admission is closed until a sweep has proven every leftover rootfs unit gone: `rootfsRefusalLocked` answers `errRootfsUnswept` until `MarkRootfsSwept`. The `Sweep` wrapper (`agent.go:660`) calls `svc.MarkRootfsSwept()` when the startup sweep answers with no error (`instancectl.Client.Sweep` already joins "some instance units would not stop" on a 502, `client.go:339-345`); otherwise it starts `retryRootfsSweep` with the agent's context. The retry must not re-run the full sweep, which stops every instance unit (`handleSweep`'s patterns, `server.go:937-939`) and would stop this agent's own binary units started after `Start`. It asks `SweepRootfs`, which stops only rootfs units: while admission has never opened on this Service, no rootfs unit is this agent's, so every one it finds is a leftover. Binary rows are unaffected (INV-6). This is the refuse-up-front shape main already uses for seeds, which trust an unproven stop only after a successful startup sweep (`seedSweptAtStart`, `agent.go:636-640`). It covers Group A's runs and residents and Groups R and W alike, since every rootfs start passes `rootfsRefusalLocked`.
+- **The startup proof** [Astra R3 3]. After an agent restart the old Service's obligations (a run's hold, Group R's release record, a worker's stray) are gone from memory, and `BindsTo` asks systemd to stop the old units but supplies no proof. On main `startActivator` (`internal/host/layoutleg.go:354`) calls `start()` whether or not the startup sweep succeeded, root keeps a unit's files when it cannot prove termination (`instancectl/server.go:986-995`), and `ReadyRootfs` (`instancectl/rootfs.go:1303`) reports only the probes, not that result. So rootfs admission opens only on a proven startup sweep: `rootfsRefusalLocked` answers `errRootfsUnswept` until `MarkRootfsSwept`, which the `Sweep` wrapper (`agent.go:660`) calls when the startup sweep answers with no error (`instancectl.Client.Sweep` already joins "some instance units would not stop" on a 502, `client.go:339-345`). After a failed sweep, a transport error included, rootfs admission stays closed for the Service's life, with one log line naming the reason, and opens only when the agent restarts and its next startup sweep is clean (controller ruling, 2026-10-26). There is no retry: a second full sweep after `Start` would stop this agent's own units (`handleSweep` stops every instance unit, `server.go:937-939`), and a rootfs-only sweep would change `instancectl` beyond `client.go` [pf 4.2]. Binary rows are unaffected (INV-6). This is the shape main already uses for seeds, which trust an unproven stop only after a successful startup sweep, for the agent's life (`seedSweptAtStart`, `agent.go:636-640`). It covers Group A's runs and residents and Groups R and W alike, since every rootfs start passes `rootfsRefusalLocked`.
- **Request budget** [pf 2.1]: the early gate's placement read is Plan 2's coalesced owner cache (at most 12 GET an hour per account with a record, 120 without). Residency adds no S3 read beyond a cache miss, and D7 adds one sync per first boot. A refused resident costs no lease cycle.
- The first-wake budget: a planned first wake of a rootfs build gets the rootfs health bound plus the kill reserve, so a 120 s Rails boot is judged on its own bound, not the binary 55 s. N1 already sizes the verdict floor to the same bound.
- Served never boots empty (Review Focus 4): after `Restore` reports `fresh` for a rootfs row whose `GoodVersion != ""`, the wake refuses with `errRootfsReplicaMissing` (member event `RFS-3-C15`), gives the lease back and starts nothing, and no placeholder is written. A first boot (`GoodVersion == ""`) proceeds. This check runs before the placeholder below and is not changed by it: the placeholder is only ever written for a row that has never served.
@@ -697,11 +694,11 @@ func TestRootfsRefusalPrecedesTheLease(t *testing.T) // INV-3. table over eve
// begin: acquires == restores == materialized == 0, no recordBuild, no entry left; ServeHTTP 503. Task 8 adds rootfsTick rows.
func TestRootfsAdmissionWaitsForTheStartupProof(t *testing.T) // [Astra R3 3] a replaced Service over a rootfsCtlHarness whose sweep
// answers Failed for a leftover rootfs cmd unit (its cgroup populated): the readiness probes pass, yet a request, the tick and a
- // RunCmd cause no Acquire, no Restore and no launch (errRootfsUnswept); the rootfs-only retry sweep keeps failing while the unit
- // lives and never stops a binary unit (the harness's systemctl log); once the cgroup empties the retry succeeds,
- // MarkRootfsSwept runs, and the next request wakes the instance
-func TestRootfsSweepIsRootfsOnly(t *testing.T) // internal/activator, through the harness: POST /sweep?runtime=rootfs lists and
- // stops only carlos-instance-rootfs*@ units; a plain /sweep is unchanged
+ // RunCmd cause no Acquire, no Restore and no launch (errRootfsUnswept); and admission stays closed for the Service's life: after
+ // the leftover's cgroup empties, an hour of fake time and many ticks later, still no Acquire and no second sweep; a new Service
+ // whose startup sweep is clean (MarkRootfsSwept) wakes the instance on the next request
+func TestStartupSweepMarksOnlyWhenClean(t *testing.T) // internal/host: the Sweep wrapper calls MarkRootfsSwept on a nil answer and not
+ // on a 502 (some units would not stop) or a transport error; it never sweeps twice
func TestRootfsGatesRunOffTheLock(t *testing.T) // [Astra R1 8] rootfsStartable blocks on a channel for host A: a request to
// binary host B and to awake host C completes meanwhile, and Shutdown is not held up by A beyond its ctx; awake host C's
// requests never call rootfsStartable; 20 concurrent cold requests to A call it once
@@ -734,14 +731,14 @@ func TestRootfsAppWithoutSQLiteRestarts(t *testing.T) // Review Focus 8. A web
INV-4's table gains `errRootfsUnarmed` and `errRuntimeUnknown`, each marked by `refuseRootfs`.
-- [ ] **Step 2:** Run `go test ./internal/activator/ -run 'TestRootfsRefusalPrecedesTheLease|TestRootfsAdmissionWaitsForTheStartupProof|TestRootfsSweepIsRootfsOnly|TestRootfsGatesRunOffTheLock|TestRootfsGatesThroughTheProductionBackend|TestProductionBackendImplementsRootfsSeams|TestRootfsWakeRefused|TestBinaryWakeNotGated|TestUnknownRuntimeNeverWakes|TestServedRootfsNeverBootsEmpty|TestFirstRootfsWakeMayBootFresh|TestServedRootfsPlacesNoPlaceholder|TestBinaryFreshWakePlacesNothing|TestRootfsPlaceholderFailureStartsNothing|TestPlaceRootfsDB|TestRootfsAppWithoutSQLiteRestarts' -count=1` (the production-wired ones need the short `TMPDIR` of the Global Constraints). Expected: FAIL.
+- [ ] **Step 2:** Run `go test ./internal/activator/ -run 'TestRootfsRefusalPrecedesTheLease|TestRootfsAdmissionWaitsForTheStartupProof|TestRootfsGatesRunOffTheLock|TestRootfsGatesThroughTheProductionBackend|TestProductionBackendImplementsRootfsSeams|TestRootfsWakeRefused|TestBinaryWakeNotGated|TestUnknownRuntimeNeverWakes|TestServedRootfsNeverBootsEmpty|TestFirstRootfsWakeMayBootFresh|TestServedRootfsPlacesNoPlaceholder|TestBinaryFreshWakePlacesNothing|TestRootfsPlaceholderFailureStartsNothing|TestPlaceRootfsDB|TestRootfsAppWithoutSQLiteRestarts' -count=1` (the production-wired ones need the short `TMPDIR` of the Global Constraints). Expected: FAIL.
- [ ] **Step 3:** Implement; write `RFS-3-C12`, `C14` and `C15` from the deck and add their ids to the built list.
-- [ ] **Step 4:** Run Step 2's command, Task 1's guards, the restore and seed families the new step sits beside (`go test ./internal/activator/ -run 'Restore|Seed|Fresh' -count=1`), `go test ./internal/host/ -run 'TestRollout|TestRetryRootfsSweep|Placement|Sweep' -count=1` (with `TestRetryRootfsSweep` there: backoff, no full sweep, mark only on a clean answer, stops on ctx), and `go test ./internal/instancectl/ -run 'Sweep' -count=1`. Expected: PASS.
+- [ ] **Step 4:** Run Step 2's command, Task 1's guards, the restore and seed families the new step sits beside (`go test ./internal/activator/ -run 'Restore|Seed|Fresh' -count=1`), and `go test ./internal/host/ -run 'TestRollout|TestStartupSweepMarksOnlyWhenClean|Placement|Sweep' -count=1`. Expected: PASS.
- [ ] **Step 5: Commit**
```bash
-git add internal/activator internal/host internal/instancectl/server.go internal/instancectl/client.go approved_rootfs_copy_test.go
-git commit -m "activator: rootfs rows refused before the lease, and until the startup sweep proves no rootfs leftover runs; unless overlap swaps are armed and the box's rootfs gates pass; first boot places an empty database; never boot empty after serving"
+git add internal/activator internal/host approved_rootfs_copy_test.go
+git commit -m "activator: rootfs rows refused before the lease, and, for the agent's life, after a startup sweep that did not prove every leftover gone; unless overlap swaps are armed and the box's rootfs gates pass; first boot places an empty database; never boot empty after serving"
```
---
@@ -1096,7 +1093,7 @@ git commit -m "system apply: a box with rootfs instances refuses a platform rele
- [ ] **Step 2:** `GOOS=darwin go build ./... && GOOS=windows go build ./... && GOOS=linux GOARCH=arm64 go build ./...`. Expected: clean.
- [ ] **Step 3:** Every touched package once, without `-run`: `go test ./internal/registry/ ./internal/provision/ ./internal/rollout/ ./internal/ops/ ./internal/layout/ ./internal/runs/ ./internal/rolloutwords/ ./internal/release/ -count=1`, then `go test ./internal/activator/ ./internal/edge/ ./internal/host/ ./internal/console/ -count=1` under `nice`, one package at a time, then the root package's `TestRun|TestRootfsCopy|TestRootfsBuilt|TestDocsite|TestAddRefuses` group. Expected: PASS.
- [ ] **Step 4:** `go test -race ./internal/activator/ -run 'TestResidentRequestAndTickRaceOneWake|TestResidentCrashDuringStopIsOneStop' -count=1`. Expected: PASS.
-- [ ] **Step 5:** The invariants hold: `go test ./internal/activator/ -run 'TestRootfsFilesNameNoBinaryVerb|TestRootfsRemovalOwnersUnchanged|TestRootfsRefusalsAreNotBuildFailures|TestRootfsLaunchFilesCarryOnlyComposedEnv|TestEveryRootfsProofNamesTheRootfsUnit|TestRootfsRefusalPrecedesTheLease|TestResidentFailureClassification|TestProductionBackendImplementsRootfsSeams|TestRootfsHealthWindowIsTheRootfsBound|TestBinary.*Golden|TestGenHealthyBoundBinary' -count=1` and `go test ./internal/ops/ -run 'TestFleetDBsStillExcludesHibernatingSidecars' -count=1` (PASS). Plan 3's diff touches no `internal/instancectl` file but `client.go` (N1's typed refusal, Task 7's `SweepRootfs`) and `server.go` (Task 7's rootfs-only sweep) [pf 4.2, Astra R3 3]: `git diff --name-only origin/main...HEAD -- internal/instancectl | grep -vx -e internal/instancectl/client.go -e internal/instancectl/server.go` prints nothing (an empty diff passes too).
+- [ ] **Step 5:** The invariants hold: `go test ./internal/activator/ -run 'TestRootfsFilesNameNoBinaryVerb|TestRootfsRemovalOwnersUnchanged|TestRootfsRefusalsAreNotBuildFailures|TestRootfsLaunchFilesCarryOnlyComposedEnv|TestEveryRootfsProofNamesTheRootfsUnit|TestRootfsRefusalPrecedesTheLease|TestResidentFailureClassification|TestProductionBackendImplementsRootfsSeams|TestRootfsHealthWindowIsTheRootfsBound|TestBinary.*Golden|TestGenHealthyBoundBinary' -count=1` and `go test ./internal/ops/ -run 'TestFleetDBsStillExcludesHibernatingSidecars' -count=1` (PASS). Plan 3's diff touches no `internal/instancectl` file but `client.go` (N1's typed refusal) [pf 4.2]: `git diff --name-only origin/main...HEAD -- internal/instancectl | grep -vx internal/instancectl/client.go` prints nothing (an empty diff passes too).
- [ ] **Step 6:** Add `"A"` to `plan3GroupsLanded` (Task 1's `plan3_groups_test.go`). Then `go test . -run 'TestPlan3|TestRootfsCopy|TestRootfsBuilt' -count=1`: Group A's copy set is built, Group R's and W's sets are not, and Task 1's inventory finds no release or worker machinery in `internal/activator` beyond main's baseline and A's allowed shared seams [Astra R3 6]. Expected: PASS. The controller pushes the branch to amadan; CI runs the full suite; main's census runs at merge [pf 4.1].
---
@@ -1818,5 +1815,5 @@ None open. The one this plan raised, `carlos run` on fleet boxes (D4), Paul answ
- Task 2: `Upsert` keeps a rootfs row's hibernation unless re-tenanted, the replication arm keys on the effective runtime, `carlos add` refuses an existing rootfs host, `ErrRuntimeFixed` crosses the remote registry. Task 5: `BuildStateKept`, `socket_advice.go:121` and `restartscope.go:496` added, `movesphase1.go` dropped. Task 7: `RenameBetweenNoReplace`. Task 10: `Processes` checks the image's digest, root's refusals are refusals, launch env `rootfsLaunchEnv`, the sized tier. Task 12: the same, plus `runCopySuperseded` for RUN-C47. Task 13: the provision transitions are the control, a test enumerates the `seedMoveRefusal` sites, the Phase 1 citations dropped. Every agent-side egress slot struck (#328 checks on root's side).
- **Round 2 (Astra plan review R1 of b3a40781, 7 P1 and 4 P2; map in amend-report.md "Round 2"):** Task 5 widens only (`ActivatorLeased` keeps hibernating binary sidecars where today's no-kind sites have them); N1's staged arm launches without a health wait and every rootfs `Gen` carries its full identity (`stagedIdentityOf`), with the manifest read's (nil, nil) and `BoxArtifact` cases refused; every new interface goes through `SplitBackend` with a production-composition test; one `releaseRun` record owns a release from admission to proof (INV-7), outliving a failed wake with its lease, pin and latch, read by every consumer; a final worker exec gate (`workerGate`) and `LaunchRootfsWorker` (the pre-flight's `StartWorker` collides with the binary worker start); gates, `BuildIdentity` and pins off `a.mu` and published before exec; the rollback floor is a release floor (`RootfsLifecycleFloor`), not the unit set; INV tests cover the shared dispatch files, the agent-held obligations, a real health response between the bounds and resident accounting (`residentFailure`).
- **Round 3 (Astra plan review R2 of bbac6804: 8 of 11 fixed, N1 to N6 new; Paul's decision of 2026-10-26; map in amend-report.md "Round 3"):** `release` leaves Group A for its own Group R (R1 the operation, R2 before an overlap swap, R3 inside a wake, R gate), with INV-R1 to INV-R5. N1: retries keyed on the operation's state, not the entry's. N2: the reaper in `finishPendingStops` and the records in Shutdown's drain and exit report. N3: the instance awake ceiling and the plan-disabled stop in the consumer table. N4: the open-release check at every swap admission and wake, before the due decision. N6: one classification for every release result. N5 (Group W): `workerWakeGate` takes the wake's generation and replica. New Task D in Group A holds the declared-processes read both later groups share and logs what the box does not run yet; Task 12 holds the shared `startCmdUnit`, `stagedImageOf` and the control harness. Plan 4 depends on A and W, not R: its sample migrates with `db:prepare` before Puma.
- - **Round 4 (Astra plan review R3 of 39dfc0dc; map in amend-report.md "Round 4"):** Task 8's tick only reserves, and each resident's gate I/O and start run in a job off the sweeper, cancelled with the Service; Plan 2's gate hooks take a `ctx`. Task 5 makes retention require a box report for resident records. Task 7 keeps rootfs admission closed until a startup sweep proves no rootfs leftover runs, with a rootfs-only retry sweep (`server.go`'s `handleSweep` filter, now an allowed `instancectl` file), inherited by W's gates. Group R's hold outcomes never answer `SwapDown` except for a failed release, tested through the real scheduler, and release admission refuses beside an unfinished generation operation. The gates use pinned per-group copy sets and a declared-name inventory (`plan3_groups_test.go`) in place of the grep, and the later `instancectl` checks pass on an empty diff.
+ - **Round 4 (Astra plan review R3 of 39dfc0dc; map in amend-report.md "Round 4"):** Task 8's tick only reserves, and each resident's gate I/O and start run in a job off the sweeper, cancelled with the Service; Plan 2's gate hooks take a `ctx`. Task 5 makes retention require a box report for resident records. Task 7 opens rootfs admission only on a clean startup sweep; after a failed one it stays closed until the agent restarts (controller ruling: no retry, `instancectl` stays at `client.go`), inherited by W's gates. Group R's hold outcomes never answer `SwapDown` except for a failed release, tested through the real scheduler, and release admission refuses beside an unfinished generation operation. The gates use pinned per-group copy sets and a declared-name inventory (`plan3_groups_test.go`) in place of the grep, and the later `instancectl` checks pass on an empty diff.
- Every file:line refreshed against main a912a342, spec rev 5; the RFS-3 file cells set to bare paths in the deck and here (texts unchanged); each task's header says whether it gets a cross-model review. `Service.rootfsRefusal` is now `rootfsStartRefusal`, because Plan 2's `rootfsRefusal` is a type in the same package.