carlos / platform Public

activator: a lease-loss kill is joined to its entry; a proving stop returns after AfterSettled (rootfs plan 6 task 7a fix round 1)

Astra R1 P1: a kill at a lease's loss names the rootfs cmd unit by host
and role only, so a late one could reach the next run of a reused unit.
Each lease stop is now counted on the entry it was captured for
(e.leaseStops) until it returns; meanwhile finishStop keeps the stop
pending with the lease held, so the entry is not released and no later
entry or command of that unit can exist, and cmdBusyLocked refuses a new
run or release on the entry. A controlled regression holds the old kill
across settle, stop and a new run's wake: the new run starts only after
the kill returned.

P2: a settle that proves the unit gone runs onProven and AfterSettled
before it ends the attempt, so a proving Stop returns with them done.
P3: startRootfsRun's errNoGenEnv and replica-key refusals are tested
(nothing laid out, nothing asked of root).

The lease watch reads the drain budget New copied (Service.drainBudget),
so a test's change of the package var never races a watch goroutine
under -race. Census overlay rootfs-apps-6 re-proposed (seal 92667fa6).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev e026fdc162441edcdc75f3f1199b0cbb330f61e8 parent a76ab51
9 files changed, +281 −20
  • docs/superpowers/notes/census-proposal-rootfs-apps-6.md +5 −1
  • internal/activator/activator.go +28 −2
  • internal/activator/cmd.go +31 −6
  • internal/activator/cmd_test.go +23 −0
  • internal/activator/rootfs_cmd_lease_test.go +140 −3
  • internal/activator/rootfs_service.go +4 −3
  • internal/activator/rootfs_test.go +42 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv +7 −4

Intent

Human

<task-notification> <task-id>b1z7co9zo</task-id> <tool-use-id>toolu_01XazMbKARkdrfH3N4RtcvoG</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/b1z7co9zo.output</output-file> <status>completed</status> <summary>Background command "Run Astra review of Plan 6 Task 7a" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a183e06b7000fc3f7</task-id> <tool-use-id>toolu_013LedgKKeqL7u9Vx437Fmdw</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a183e06b7000fc3f7.output</output-file> <status>completed</status> <summary>Agent "#471 Task 7: load, restart, reloads" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status:** DONE_WITH_CONCERNS **Commits:** f0f699d7 on design-tunnel-websockets-471, not pushed. Git printed its usual packed-refs.lock error, but the commit landed. **Tests:** all five witnesses pass at `-short`, and again under `-race` with no data races. The production-values load test passes in 1.6 s wall with 261 MiB peak RSS. All 10 recorded mutations make the tests fail as intended (3 load-test window mutations, 1 stream-slot, 2 restart, 1 shutdown, 3 Reload). **Concerns:** 1. **The spec's push-back bound does not hold on Linux.** The brief's check, accepted bytes ≤ StreamWindow + 4 MiB, failed as written (6.6 MiB against 4.16 MiB at `-short`). Linux grows the client's send buffer up to 4 MiB and the hub's receive buffer up to 6 MiB. I measured nearly 10 MiB per socket in those kernel queues on loopback. - The test now measures those queues on each connection and subtracts them, then holds the rest to StreamWindow + 4 MiB. The rest was about 300 KiB at `-short` and 1.3 MiB at production values. - That still catches a box that buffers too much: the no-push-back and 8 MiB stream-buffer mutations both fail it. - At 128 sockets the kernel held about 950 MB in queues. That is kernel memory, not process memory. - Spec §4.8 (c) and case 13 need a ruling. I did not edit the spec. 2. **The production-values run happened twice, not once.** The first run failed after 81 s on a kernel-limit check I had added, not one from the brief; I removed it. The 81 s was slow cleanup, which is now fixed. 3. **The "ConnWindow 1 MiB: the POST times out" proof ran at `-short` scale only.** There I set the connection window to one stream window, which is what 1 MiB is at production scale, and the POST timed out after 10 s. A literal 1 MiB can't fail at `-short` scale, and I didn't spend a third production run on it. 4. **The load test uses a new row, `load.example.com`, with `busy_at` raised.** With default rate settings, the hub sheds 100 held GETs from one client with 429. So the test measures stream slots rather than the rate limit. 5. **Naming:** `wsScene` is already the scene's type, so the constructor became `newWSScene(t, fx, wsOpts{...})`. Task 6's two callers are migrated in the same commit. 6. **Scratch:** the sandbox and the normal shell use different `$TMPDIR`s, so my scratch directory landed in one that already held another session's files (`mut6.py`, `verify2.*`). I deleted only my own files and left theirs. The census card is unchanged from Task 6 (seal 1379d066…5e7). Only test files changed, so spec §7 is untouched. The full report is in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-tunnel-websockets-471/.superpowers/sdd/2026-10-30-tunnel-websockets/task-7-report.md`.</result> <usage><subagent_tokens>262645</subagent_tokens><tool_uses>71</tool_uses><duration_ms>1565699</duration_ms></usage> </task-notification>

Attributed to this commit: 11.7 g CO₂e (1,372,269 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on rootfs-apps-6-interactive, 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/notes/census-proposal-rootfs-apps-6.md b/docs/superpowers/notes/census-proposal-rootfs-apps-6.md
index 0c91d8950..37ae9c1b5 100644
--- a/docs/superpowers/notes/census-proposal-rootfs-apps-6.md
+++ b/docs/superpowers/notes/census-proposal-rootfs-apps-6.md
@@ -4,7 +4,9 @@ Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejec
| unit | change | read sites | what changed |
|---|---|---|---|
+| `internal/activator/activator.go` `Service.finishStop` | body | unchanged (5) | rootfs Plan 6 Task 7a fix round 1 (Astra P1): beside the worker check, under the same lock, a stop with a lease stop of its commands outstanding (e.leaseStops) is kept pending, the replica and lease held, and the sweep finishes it once they have returned; the entry is never released while a kill captured for it may still reach its unit; the same five read sites, no read added |
| `internal/activator/activator.go` `Service.installProcLocked` | body | unchanged (1) | rootfs Plan 6 Task 7a (Call A1, Astra R1 P1-1): the lease watch is installed for every rootfs row (e.route.Rootfs()), not only a resident, so a hibernating rootfs row's run or session is reached at the lease's loss; the same one read of the entry's route; installs nothing else |
+| `internal/activator/activator.go` `type Service` | body | unchanged (0) | rootfs Plan 6 Task 7a fix round 1: one field, drainBudget (time.Duration), which New copies from residentDrainBudget and a rootfs entry's lease watch reads in its place, so a test's change of the package var never races a watch goroutine; declaration only, reads nothing |
| `internal/activator/backend_rootfs.go` `ExecBackend.StartRelease` | body | unchanged (2) | rootfs Plan 6 Task 7a: passes rootfsCmdLaunch{Process: release.ProcessRelease} to startRootfsCmd in place of the bare process name; its /cmd request and launch.cmd.json are byte-identical to before (TestStartReleaseIsUnchanged, goldens written from 3fd3c3a4); no read added |
| `internal/activator/cmdunit.go` `type CmdSpec` | body | unchanged (1) | rootfs Plan 6 Task 7a: declaration only: gains AfterSettled, a callback field the caller sets (the box's run pass removes the run's directory in it), called once when no unit of the run can be running; reads nothing |
| `internal/activator/rootfs_service.go` `Service.residentLeaseLost` | body | unchanged (2) | rootfs Plan 6 Task 7a (Call A1): residentLeaseLostLocked also returns one kill func per one-shot unit that may run; each runs off a.mu in the same WaitGroup as stopRootfsWorkersAtLoss and killResidentGens, which still run only for a resident (gens non-nil); the kills go to root's existing /stop through KillOneShot; no read added |
@@ -40,7 +42,9 @@ A removed unit's recorded disposition and basis are in its table above. For a re
Recorded dispositions, which each change must still satisfy:
+- `internal/activator/activator.go` `Service.finishStop`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with a run's settle checked before replication closes, which keeps the stop pending until the run is proven stopped; read sites unchanged, offsets moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: an HA entry (its replica is an HA one, haEntryRep) now releases through releaseHAClean (a new unit on this card) instead of e.rep.Close; when that answers errHostSliceUnproven the stop is kept pending (keepPendingLocked) with the lease held and renewing, and the sweep finishes it once proven; a non-HA entry is unchanged; the same five sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: a forgotten entry's stop is noted for its resident (noteResidentStopLocked: crash or lost lease backs off, any other stop restarts on the next tick) and its ownerDone channel is closed; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: while the host has a release command's record (a.releaseOps[e.host], running or not proven stopped), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the record's proof; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.20: while a rootfs worker may run or is a stray (rootfsWorkersLiveLocked, in-memory, read under a.mu), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the workers are proven stopped; the same five read sites, no read added; only holds a release back
- `internal/activator/activator.go` `Service.installProcLocked`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: the one place a process, its generation and the lease replica are installed on an entry; a resident is put under its lease watch (watchResidentLeaseLocked) at that moment; reads only the entry's route
+- `internal/activator/activator.go` `type Service`: authority, task B,C,D,F,J4. Basis: rev3=PROPOSED-seed; existing activator lifecycle and due-wake state plus owned seed exclusion and incarnation-keyed diagnostics; normal refusal and preparation ordering remain authoritative; PROPOSED-plans-2-box-limits adds the idleFor hook field, which only narrows idle windows;rev3=census-ruling-plans-4c-box-throttle;basis=gains the maxRunFor hook field beside idleFor (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=gains the disabledFor hook field beside maxRunFor (plans 4d). No read added.;rev3=census-ruling-remote-instance-metrics;basis=gains tenancySeq, hostTenants and hostMixed, in-memory fields for Tenancies; no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more field, markers (markerRetry: an atomic running flag and the last log time) for retryOwedMarkers; no read added; merge of origin/main d7ae1d76: main's fields are kept as main has them (census-ruling-remote-instance-metrics: tenancySeq, hostTenants, hostMixed); this branch's change is the same as above;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: new fields for rootfs admission (rootfsArmed, rootfsSwept), the per-host gate ask and refusal memo, and residency state (lister, backoff, start ceiling, cursor, test seam); no read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: one new field, releaseOps (host to the in-memory release record, under a.mu); no read;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W: one new field, leaseNow (a clock seam for a worker start's headroom against the lease deadline, nil is the real clock); no read;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: gains the holder cache and its single-flight state; no read
- `internal/activator/backend_rootfs.go` `ExecBackend.StartRelease`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1: new; startRootfsCmd naming release.ProcessRelease, both streams through one capped line writer (releaseOutput, runs.MaxOutputBytes) into the caller's writer; no read of its own
- `internal/activator/cmdunit.go` `type CmdSpec`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): declaration only; Prepare is a callback field, not a prepared statement
- `internal/activator/rootfs_service.go` `Service.residentLeaseLost`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8 (C7): a resident's lost lease marks it and then kills its generations off a.mu (killResidentGens);rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.10: a resident's lost lease stops its workers (stopRootfsWorkersAtLoss, proven gone) in parallel with killResidentGens; rt is taken under the lock and passed to killResidentGens in place of e.route (the same route); site +whole:Route (that local rt); no file read
@@ -77,6 +81,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/instancectl/cmd.go:Server.oneShotStatus`: reads +file:Query ×3; written legacy, accepted-legacy, frozen
- new `internal/instanceexec/tty_linux.go:receivePTY`: reads +file:Fstat; written legacy, accepted-legacy, frozen
-Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `a423737430ea5ec92dd0f268aaa519463cd43c0f790cb730542121aca5b58d29`.
+Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `92667fa6f8aabb3261f962c8105f08abef20ba8590eae9c7fb889ce6d3eae8d5`.
Overlay: `internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/activator/activator.go b/internal/activator/activator.go
index 101919460..3c370c16a 100644
--- a/internal/activator/activator.go
+++ b/internal/activator/activator.go
@@ -497,6 +497,15 @@ type actEntry struct {
// awake transition, closed by finishStop as the entry is forgotten.
// Under a.mu.
ownerDone chan struct{}
+ // leaseStops counts the lease-loss and lease-short one-shot stops
+ // captured for this entry (stopOneShotsAtLeaseLocked) that have not
+ // returned. While any is outstanding the entry is not released
+ // (finishStop keeps its stop pending, the lease held) and takes no new
+ // run or release command (cmdBusyLocked): a kill names its unit by host
+ // and role only, so it is bound to the command it was issued for by
+ // keeping the unit unused until it has returned (Plan 6 Task 7a, fix
+ // round 1). Under a.mu.
+ leaseStops int
// ownerKilled: the tick's second-line lease check (rootfsTick) has
// already killed this unwatched rootfs entry's one-shot units and, a
// resident, its generations. Under a.mu.
@@ -1250,6 +1259,13 @@ type Service struct {
// as the lease runs. A seam for the unit tests, set before any start.
leaseNow func() time.Time
+ // drainBudget is residentDrainBudget as New read it: a rootfs entry's
+ // lease watch reads this field, never the package var, which only a
+ // test changes, before it builds its Service (fix round 1: a watch
+ // goroutine of an earlier Service then never races a later test's
+ // change). Set at construction and never written again.
+ drainBudget time.Duration
+
// Routes, when non-nil, is read by doWake before Acquire (design §6.8)
// to refresh the route against the registry's committed row rather than
// spawning against the copy the edge cached at request time. Nil (every
@@ -1579,6 +1595,7 @@ func New(cfg Config, backend Backend, due DueStore) *Service {
if u, ok := backend.(entryFilesUser); ok {
u.useEntryFiles(a.entryFilesFor)
}
+ a.drainBudget = residentDrainBudget
return a
}
@@ -4848,10 +4865,15 @@ func (a *Service) finishStop(e *actEntry, outcome *stopObservation) {
return
}
// And a rootfs worker (Group W, W1.20): one that may run, or a stray,
- // keeps replication and the lease, here as well as in releasable.
+ // keeps replication and the lease, here as well as in releasable. So
+ // does a lease stop of a one-shot unit that has not returned (Plan 6
+ // Task 7a fix round 1): its kill names the unit by host and role, so
+ // the entry is not released, and no later entry can start a command of
+ // that unit, until it has.
a.mu.Lock()
workersLive := rootfsWorkersLiveLocked(e)
- if workersLive {
+ leaseStops := e.leaseStops
+ if workersLive || leaseStops > 0 {
a.keepPendingLocked(e, outcome)
}
a.mu.Unlock()
@@ -4859,6 +4881,10 @@ func (a *Service) finishStop(e *actEntry, outcome *stopObservation) {
log.Printf("activator: stop %s: a worker is not proven stopped; keeping replication and the lease until it is", e.host)
return
}
+ if leaseStops > 0 {
+ log.Printf("activator: stop %s: %d lease stop(s) of its commands have not returned; keeping replication and the lease until they have", e.host, leaseStops)
+ return
+ }
// Close = final sync + lease release. After a lost lease the release part
// fails harmlessly (someone else owns the lock); the sync still preserves
// a local checkpoint.
diff --git a/internal/activator/cmd.go b/internal/activator/cmd.go
index 9e9038663..06bda4c7e 100644
--- a/internal/activator/cmd.go
+++ b/internal/activator/cmd.go
@@ -205,13 +205,17 @@ func (h *cmdHold) settle(at *cmdSettle) {
}
h.settling, h.lastTry = nil, h.now()
h.mu.Unlock()
- close(at.done)
+ // A settle that proves the unit gone runs onProven and AfterSettled
+ // before it ends the attempt, so a stop that returns nil returns with
+ // both done (Plan 6 Task 7a fix round 1: the callback's completion is
+ // part of the stop's contract).
if err == nil {
if h.onProven != nil {
h.onProven()
}
h.settled()
}
+ close(at.done)
}
// retrySettle starts one settle attempt in the background, for the sweep
@@ -297,8 +301,9 @@ func (r *cmdRun) Release() {
})
}
-// cmdBusyLocked reports whether e cannot take a run: one is attached, or
-// an earlier one's unit was never proven settled. It drops the released
+// cmdBusyLocked reports whether e cannot take a run (or, for Group R, a
+// release command): one is attached, an earlier one's unit was never
+// proven settled, or a lease stop captured for e has not returned. It drops the released
// holds that have since settled. The caller holds a.mu.
func cmdBusyLocked(e *actEntry) bool {
left := e.cmdLeft[:0]
@@ -309,7 +314,10 @@ func cmdBusyLocked(e *actEntry) bool {
}
clear(e.cmdLeft[len(left):])
e.cmdLeft = left
- return e.cmd != nil || len(left) > 0
+ // A lease stop captured for e that has not returned may still kill
+ // the cmd unit by its name: nothing new uses that unit until it has
+ // (Plan 6 Task 7a fix round 1).
+ return e.cmd != nil || len(left) > 0 || e.leaseStops > 0
}
// cmdHoldsLocked is every run of e whose unit may still be running: the
@@ -424,14 +432,31 @@ func oneShotHoldsLocked(e *actEntry) bool {
// returns a unit, and then the run's stop settles its streams and records
// the reason. A kill or settle that fails is logged: the entry's stop path
// still keeps the lease until the hold is proven (settleCmds). Nothing for
-// a binary row, which holds no resident lease. The caller holds a.mu.
+// a binary row, which holds no resident lease.
+//
+// Each func is counted on e (e.leaseStops) from the moment it is captured
+// until it returns, so its kill, which names the unit by host and role
+// only, can never reach another command (fix round 1): while it is
+// outstanding e is not released (finishStop keeps the stop pending, the
+// lease held) and takes no new run or release command (cmdBusyLocked).
+// finishStop is the only release of an entry that held a run, so no other
+// entry, and no other command of the unit, can exist on this box until the
+// kill has returned. The caller holds a.mu.
func (a *Service) stopOneShotsAtLeaseLocked(e *actEntry, rt registry.Route, kill bool) []func() {
if !rt.Rootfs() {
return nil
}
var out []func()
for _, h := range cmdHoldsLocked(e) {
- out = append(out, func() { a.stopOneShotAtLease(rt, h, instancectl.RoleCmd, kill) })
+ e.leaseStops++
+ out = append(out, func() {
+ defer func() {
+ a.mu.Lock()
+ e.leaseStops--
+ a.mu.Unlock()
+ }()
+ a.stopOneShotAtLease(rt, h, instancectl.RoleCmd, kill)
+ })
}
return out
}
diff --git a/internal/activator/cmd_test.go b/internal/activator/cmd_test.go
index cba3dd191..d4e42caab 100644
--- a/internal/activator/cmd_test.go
+++ b/internal/activator/cmd_test.go
@@ -849,3 +849,26 @@ func TestRunCmdAfterSettledRunsOnceOnEveryPath(t *testing.T) {
})
}
}
+
+// Fix round 1 (Astra P2): AfterSettled's completion is part of the proving
+// stop's contract: a Stop that proves the unit gone returns only once the
+// callback has returned, so the caller's files are gone by then.
+func TestAProvingStopReturnsAfterAfterSettled(t *testing.T) {
+ t.Parallel()
+ a, _, _ := testCmdActivator(t, Config{})
+ var done atomic.Bool
+ h, err := a.RunCmd(context.Background(), testRoute("c.example.com"), CmdSpec{RunID: "run_a", AfterSettled: func() {
+ time.Sleep(100 * time.Millisecond)
+ done.Store(true)
+ }})
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer h.Release()
+ if err := h.Stop(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ if !done.Load() {
+ t.Fatal("Stop returned before AfterSettled had")
+ }
+}
diff --git a/internal/activator/rootfs_cmd_lease_test.go b/internal/activator/rootfs_cmd_lease_test.go
index 4267af036..d6ab2b2bc 100644
--- a/internal/activator/rootfs_cmd_lease_test.go
+++ b/internal/activator/rootfs_cmd_lease_test.go
@@ -75,11 +75,12 @@ type runLeaseBackend struct {
cmdStarts int
}
-func (b *runLeaseBackend) StartCmd(context.Context, registry.Route, CmdSpec) (CmdUnit, error) {
+func (b *runLeaseBackend) StartCmd(_ context.Context, _ registry.Route, spec CmdSpec) (CmdUnit, error) {
b.omu.Lock()
gate, entered := b.startGate, b.startEntered
b.cmdStarts++
b.omu.Unlock()
+ b.record("startcmd:" + spec.RunID)
if entered != nil {
close(entered)
}
@@ -94,10 +95,11 @@ func (b *runLeaseBackend) KillOneShot(_ context.Context, rt registry.Route, role
b.oneShots = append(b.oneShots, time.Now())
hook := b.onOneShot
b.omu.Unlock()
- b.record(fmt.Sprintf("killoneshot:%s", role))
if hook != nil {
- hook()
+ hook() // a test's seam: the kill's way to root, delayed
}
+ // Recorded when the kill reaches root, after any delay.
+ b.record(fmt.Sprintf("killoneshot:%s", role))
return nil
}
@@ -625,3 +627,138 @@ func TestResidentLeaseWatchUnchangedForResidents(t *testing.T) {
}
})
}
+
+// Astra R1 P1 (fix round 1): a kill issued at a lease's loss only ever hits
+// the command it was issued for. The old kill is held on its way to root
+// (the seam) while the run it was issued for is proven gone by its own
+// Stop, the entry is stopped, and a new run on the host is asked for under
+// a new lease. The entry is not released, and the new run does not start,
+// until the old kill has returned: the new run starts after it, and
+// survives.
+func TestALateLeaseKillNeverReachesTheNextRun(t *testing.T) {
+ host := "shop.example.com"
+ a, b, clk := runLeaseService(t)
+ rep := ownedRepUntil(b, func() time.Time { return time.Now().Add(time.Hour) })
+ rt := rootfsGateRoute(host)
+ runA, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_a"})
+ if err != nil {
+ t.Fatalf("RunCmd A: %v", err)
+ }
+ repA := rep.Load()
+ held, letGo := make(chan struct{}), make(chan struct{})
+ var once, released sync.Once
+ release := func() { released.Do(func() { close(letGo) }) }
+ t.Cleanup(release)
+ b.omu.Lock()
+ b.onOneShot = func() { once.Do(func() { close(held) }); <-letGo }
+ b.omu.Unlock()
+ repA.lose(errors.New("renew: the lock was taken"))
+ select {
+ case <-held:
+ case <-time.After(5 * time.Second):
+ t.Fatal("no kill was issued at the loss")
+ }
+ // A's own Stop proves it gone while the kill is held; the entry stops.
+ if err := runA.Stop(context.Background()); err != nil {
+ t.Fatalf("A's Stop: %v", err)
+ }
+ runA.Release()
+ a.Bounce(host)
+ type result struct {
+ run CmdHandle
+ err error
+ }
+ ranB := make(chan result, 1)
+ go func() {
+ run, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_b"})
+ ranB <- result{run, err}
+ }()
+ // Sweeps while the old kill is held: the stop stays pending, the lease
+ // held, and B does not start.
+ for i := 0; i < 10; i++ {
+ clk.advance(time.Minute)
+ a.sweepOnce()
+ time.Sleep(20 * time.Millisecond)
+ }
+ if indexWithPrefix(b.events(), "startcmd:run_b") >= 0 {
+ t.Fatalf("events %v: the next run started while the old kill was still on its way", b.events())
+ }
+ if repA.isClosed() {
+ t.Fatal("the old lease was given back while its kill was still on its way")
+ }
+ release()
+ var rB result
+ waitFor(t, "the next run to start once the old kill returned", func() bool {
+ clk.advance(time.Minute)
+ a.sweepOnce()
+ select {
+ case rB = <-ranB:
+ return true
+ default:
+ return false
+ }
+ })
+ if rB.err != nil {
+ t.Fatalf("RunCmd B: %v", rB.err)
+ }
+ ev := b.events()
+ if k, s := lastIndexOf(ev, "killoneshot:cmd"), indexWithPrefix(ev, "startcmd:run_b"); k < 0 || s < k {
+ t.Fatalf("events %v: the old kill reached root after the next run started", ev)
+ }
+ time.Sleep(50 * time.Millisecond)
+ if ev2 := b.events(); lastIndexOf(ev2, "killoneshot:cmd") != lastIndexOf(ev, "killoneshot:cmd") {
+ t.Fatalf("events %v: a kill reached root after the next run started", ev2)
+ }
+ if err := rB.run.Stop(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ rB.run.Release()
+}
+
+// While a lease stop captured for an entry is outstanding, that entry
+// takes no new run (ErrCmdBusy) and admits no release command: nothing new
+// may use the unit the stop names.
+func TestAnOutstandingLeaseStopKeepsTheUnitFree(t *testing.T) {
+ host := "shop.example.com"
+ a, _, _ := runLeaseService(t)
+ rt := rootfsGateRoute(host)
+ run, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_a"})
+ if err != nil {
+ t.Fatalf("RunCmd: %v", err)
+ }
+ if err := run.Stop(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ run.Release()
+ a.mu.Lock()
+ e := a.entries[host]
+ e.leaseStops++
+ admit := a.releaseAdmitLocked(e)
+ a.mu.Unlock()
+ returned := false
+ t.Cleanup(func() { // a failure below must not leave the stop held pending
+ if !returned {
+ a.mu.Lock()
+ e.leaseStops--
+ a.mu.Unlock()
+ }
+ })
+ if !errors.Is(admit, errSwapBusy) {
+ t.Fatalf("a release admitted with a lease stop outstanding: %v", admit)
+ }
+ if _, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_b"}); !errors.Is(err, ErrCmdBusy) {
+ t.Fatalf("RunCmd with a lease stop outstanding = %v, want ErrCmdBusy", err)
+ }
+ a.mu.Lock()
+ e.leaseStops--
+ returned = true
+ a.mu.Unlock()
+ run, err = a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_c"})
+ if err != nil {
+ t.Fatalf("RunCmd once the lease stop returned: %v", err)
+ }
+ if err := run.Stop(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ run.Release()
+}
diff --git a/internal/activator/rootfs_service.go b/internal/activator/rootfs_service.go
index 5e289c67a..720ecd7f9 100644
--- a/internal/activator/rootfs_service.go
+++ b/internal/activator/rootfs_service.go
@@ -841,7 +841,8 @@ var _ residentOwnership = (*lease.Replicator)(nil)
// residentDrainBudget is the safe time a graceful stop needs: the next-due
// probe (5 s), the SIGTERM drain (actStopTimeout, 20 s) and the proof. With
// less than this left before the safety deadline the resident is stopped at
-// once; a var so tests can shrink it.
+// once; a var so tests can shrink it, before they build their Service
+// (New copies it to Service.drainBudget, which the watch reads).
var residentDrainBudget = 30 * time.Second
// watchResidentLeaseLocked starts e's lease watch. Only installProcLocked
@@ -883,11 +884,11 @@ func (a *Service) watchResidentLease(e *actEntry, sig residentOwnership, done <-
var due <-chan time.Time
if !draining {
left := time.Until(until)
- if left <= residentDrainBudget {
+ if left <= a.drainBudget {
draining = true
a.residentLeaseShort(e, left)
} else {
- t = time.NewTimer(left - residentDrainBudget)
+ t = time.NewTimer(left - a.drainBudget)
due = t.C
}
}
diff --git a/internal/activator/rootfs_test.go b/internal/activator/rootfs_test.go
index bfce1e284..eb3f0bef8 100644
--- a/internal/activator/rootfs_test.go
+++ b/internal/activator/rootfs_test.go
@@ -1186,3 +1186,45 @@ func TestUnitNameForAGenerationIsTheRunRolesOnly(t *testing.T) {
t.Errorf("cmd = %q", got)
}
}
+
+// Fix round 1 (Astra P3): startRootfsRun's two refusals after the image
+// check, a run whose generation kept no launch environment (errNoGenEnv)
+// and a replica's run without its home's key (ErrReplicaKey), refuse
+// before anything is laid out or asked of root: no launch file, no stream
+// listener, no control request.
+func TestRootfsRunRefusesWithoutEnvOrReplicaKey(t *testing.T) {
+ t.Parallel()
+ for _, c := range []struct {
+ name string
+ replica bool
+ env map[string]string
+ want error
+ }{
+ {"no launch environment", false, nil, errNoGenEnv},
+ {"a replica without its home's key", true, map[string]string{"SHOP_MODE": "live"}, ErrReplicaKey},
+ } {
+ t.Run(c.name, func(t *testing.T) {
+ b, ctl := newRootfsBackend(t)
+ rt := rootfsRoute(b)
+ rt.Replica = c.replica
+ id := stagedRootfsIdentity(t, b, "v2")
+ dir := filepath.Join(provision.InstanceDir(b.DataDir, rt.Host), CmdRunDirName, "r1")
+ u, err := b.StartCmd(context.Background(), rt, CmdSpec{RunID: "r1", RunDir: dir, Args: []string{"true"},
+ serving: stagedExeOf(id), genEnv: c.env})
+ if !errors.Is(err, c.want) || u != nil {
+ t.Fatalf("StartCmd = %v, %v; want %v and no unit", u, err, c.want)
+ }
+ if calls := ctl.callList(); len(calls) != 0 {
+ t.Fatalf("root was asked: %v", calls)
+ }
+ if _, err := os.Stat(filepath.Join(provision.InstanceDir(b.DataDir, rt.Host), instancectl.LaunchFileName(instancectl.RoleCmd))); !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("launch.cmd.json: %v, want none written", err)
+ }
+ for _, name := range []string{string(instancectl.RoleCmd), cmdErrSocket} {
+ if _, err := os.Stat(b.logSocketNamed(rt.Host, name)); !errors.Is(err, os.ErrNotExist) {
+ t.Errorf("the %s listener's socket: %v, want none", name, err)
+ }
+ }
+ })
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index c618ba15b..944eb77b4 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -43,4 +43,4 @@ plan14-root-reads-region-ha-dead-holder-backoff.tsv 8f6a1865b0abcea9d4fb68232cc2
plan14-root-reads-managed-fleets-1c-451.tsv af326671321edda76c7e6217a47892605a9e3b886fa880ad6d049c2f28f63873
plan14-root-reads-fleet-public-routes.tsv bca6ef741a96b72767b1747789cd01b3111d61b68548cbe368258c31f3d53a2e
plan14-root-reads-fleet-routes-followups.tsv 1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7
-plan14-root-reads-rootfs-apps-6.tsv a423737430ea5ec92dd0f268aaa519463cd43c0f790cb730542121aca5b58d29
+plan14-root-reads-rootfs-apps-6.tsv 92667fa6f8aabb3261f962c8105f08abef20ba8590eae9c7fb889ce6d3eae8d5
diff --git a/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv b/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv
index 736b96d6b..0fdd06e65 100644
--- a/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv
+++ b/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv
@@ -1,7 +1,8 @@
# Census overlay rootfs-apps-6, written by census-propose (#369). census-ruling-rootfs-apps-6, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-rootfs-apps-6.md.
-# 17 body, 4 sites, 9 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 19 body, 4 sites, 9 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
# 1 removed: each unit's declaration, or each envelope's directory, is absent from the scanned tree, so its row goes, a frozen declaration is retired as absent, and an envelope is retired.
# 12 new dispositions: 0 reads re-frozen at their disposition with the claim, 12 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 55df17ea73134f602af4b4aa2280eb646c1a311b9d5a13aedecd59d0cdbabf95 internal/activator/activator.go Service.finishStop legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with a run's settle checked before replication closes, which keeps the stop pending until the run is proven stopped; read sites unchanged, offsets moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: an HA entry (its replica is an HA one, haEntryRep) now releases through releaseHAClean (a new unit on this card) instead of e.rep.Close; when that answers errHostSliceUnproven the stop is kept pending (keepPendingLocked) with the lease held and renewing, and the sweep finishes it once proven; a non-HA entry is unchanged; the same five sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: a forgotten entry's stop is noted for its resident (noteResidentStopLocked: crash or lost lease backs off, any other stop restarts on the next tick) and its ownerDone channel is closed; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: while the host has a release command's record (a.releaseOps[e.host], running or not proven stopped), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the record's proof; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.20: while a rootfs worker may run or is a stray (rootfsWorkersLiveLocked, in-memory, read under a.mu), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the workers are proven stopped; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1 (Astra P1): beside the worker check, under the same lock, a stop with a lease stop of its commands outstanding (e.leaseStops) is kept pending, the replica and lease held, and the sweep finishes it once they have returned; the entry is never released while a kill captured for it may still reach its unit; the same five read sites, no read added registry:Socket@4054,registry:Socket@4159,whole:Route@4004,whole:Route@4056,whole:Route@4161 c565cc2dc400f420ac39130adcd32659f04d3330d8d8551f2f48afd76a696369
@legacy 1f6bcc9cf0f66285a303c9d14a8ac511b721f7941c0fe45c18eeaf5ec7c42662 internal/activator/activator.go Service.installProcLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: the one place a process, its generation and the lease replica are installed on an entry; a resident is put under its lease watch (watchResidentLeaseLocked) at that moment; reads only the entry's route;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a (Call A1, Astra R1 P1-1): the lease watch is installed for every rootfs row (e.route.Rootfs()), not only a resident, so a hibernating rootfs row's run or session is reached at the lease's loss; the same one read of the entry's route; installs nothing else whole:Route@144 cacc399eb6e09be70d3a2ad1774800fb6a252590cebd62dd0e9f369e97275f81
@legacy a3fb62ce1d8e3c0003ac3404e257da6a6069b7761f4327cb559844ae0ac4fcbc internal/activator/backend_rootfs.go ExecBackend.StartRelease legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1: new; startRootfsCmd naming release.ProcessRelease, both streams through one capped line writer (releaseOutput, runs.MaxOutputBytes) into the caller's writer; no read of its own;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: passes rootfsCmdLaunch{Process: release.ProcessRelease} to startRootfsCmd in place of the bare process name; its /cmd request and launch.cmd.json are byte-identical to before (TestStartReleaseIsUnchanged, goldens written from 3fd3c3a4); no read added registry:Host@182,whole:Route@247 9dd1cb5cf2b170f59e5e46a121a665bd0ca4d6c9698aab63804880848b5ee9ee
@legacy a743ccbd44c9d21980323e3e2ccdaf87d2b602a5408bca7d5a882c1d5d453fe3 internal/activator/cmdunit.go type CmdSpec legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): declaration only; Prepare is a callback field, not a prepared statement;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: declaration only: gains AfterSettled, a callback field the caller sets (the box's run pass removes the run's directory in it), called once when no unit of the run can be running; reads nothing file:Prepare@487 f3c596b537f466e707f4974aa06065fb08bebb4a89749c8d6138810c9aa0a5b2
@@ -24,7 +25,7 @@
@legacy c6d7609e34806d3c51e249713109f3bb9bae3c0645d4b6bf9f8190e48f9ce88b internal/activator/backend_unit.go SplitBackend.KillOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: forwards KillOneShot by pick(rt), as KillGen does; a half without it refuses (errOneShotKillBinary); reads only the route registry:Host@219,whole:Route@123,whole:Route@286 59823fbe5e35c5b54e0843a681ad59f684bd28e3a8315c1571198b3e5c43d3ee
@legacy d6543d9dad5ac1da40d0cbaaa7cfefb37f8c0b473c902957dc27420a61371899 internal/activator/cmd.go Service.killOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: the backend's KillOneShot (oneShotKiller) for one run, bounded by DeadlineControl plus roleEmptyBound, logged either way; the registry:Host sites are log lines registry:Host@240,registry:Host@549,registry:Host@680,whole:Route@398 3eb9bb7269c2a5fc8d4c798d884d92f7fa32eddbde588a3c9ad2d741211b869b
@legacy acd4a733f1d39bf9444302ee997852e46f6cdd946f2d68b1baa7c9b02400ea6b internal/activator/cmd.go Service.stopOneShotAtLease legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one run hold's lease stop, off a.mu: with kill, killOneShot at once and again once a start that was in flight returns a unit; then the hold's own stop (StopLeaseLost) bounded by cmdStopBound; the registry:Host sites are log lines registry:Host@714,registry:Host@961,whole:Route@309,whole:Route@529 46c39957f77353866dc7d8adbababfde54bd8634f5669fd61c3011a54f5e7c9a
-@legacy 58054c1bdae99b3fcd68352771c4e1f1d34650d1d17a9e87379ddb2284425a06 internal/activator/cmd.go Service.stopOneShotsAtLeaseLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one stopOneShotAtLease func per run hold that may be running (cmdHoldsLocked), none for a binary row (rt.Rootfs()); in memory only whole:Route@240 985fd564c12bf8f0339915e776d38d3139eb28b7c44c047bd91bbfd9fad3792d
+@legacy 3f9867cb5b71307489417d708ab6f5ebe66aebfdc2ff017d9b28d0fcc28fbba5 internal/activator/cmd.go Service.stopOneShotsAtLeaseLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one stopOneShotAtLease func per run hold that may be running (cmdHoldsLocked), none for a binary row (rt.Rootfs()); in memory only; fix round 1 (Astra P1): each func is counted on the entry it was captured for (e.leaseStops, under a.mu) from capture until it returns, so its kill, which names the unit by host and role only, never reaches another command: while counted the entry is not released (finishStop keeps the stop pending, the lease held) and takes no new run or release command (cmdBusyLocked); no read added whole:Route@338 fb82ec32cafeed4d228a07dfad0c12768db2804688477471597c505eb3707009
@legacy 6d3fbdea661079d19e104dae75e1fe1943ee5fbaf40435e501b5afd8d4bd2c98 internal/activator/rootfs_service.go Service.residentLeaseLostLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: a census unit now (two whole:Route sites, e.route to stopOneShotsAtLeaseLocked and e.route.Resident()): also returns the one-shot kill funcs of any rootfs entry that is the host's, whatever its state; a hibernating entry gets no stop and no generation kills; in memory only whole:Route@198,whole:Route@218 6266ff6af94cc58e1226f3921da636cc6fa7d365340ecce216f0493d2d7e97a7
@legacy 44b446f87f5f55a32ba63c481687b01c59c7a8c20d2b41ff82b9a37709081399 internal/activator/rootfs_service.go Service.residentLeaseShort legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: a census unit now (two whole:Route sites, e.route to stopOneShotsAtLeaseLocked and e.route.Resident()): stops every one-shot unit that may run, whatever the entry's state, off a.mu; begins a resident's graceful stop only while it is awake, as before; in memory only whole:Route@188,whole:Route@377 c39a0d4aeb53d0608e3c3e95ea3742ef6dab8ea3419a061a3415ffe5c491ecfe
@legacy 14cec7be2873b15f373f40e319f5c6c61d441f521121499f2a04b331bd3453f3 internal/host/units/carlos-instance-rootfs-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the rootfs tty template, carlos-instance-rootfs-cmd@.service outside named lines held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit --rootfs tty %I, StandardInput=file:/run/carlos/logs/%I.tty.sock with StandardOutput/StandardError=journal, and RootImage plus the two BindReadOnlyPaths sources under /run/carlos-control/exe/%I/rootfs/tty/ (root-only exe layout) instead of rootfs/cmd/. The rootfs namespace block byte for byte (TestRootfsTemplatesShareOneNamespace), runs as carlos, binds only the instance own and root paths (TestRootfsTemplatesBindOnlyTheInstancesOwnAndRoots). Task 6: POST /tty runtime=rootfs (startRootfsCmd with RoleTTY) starts it through Plan 2's rootfs one-shot path (preflight, validateStagedImage, ensureRootfsExe under rootfs/tty/, jit drop-in and owed reload, post-start MemoryDenyWriteExecute check); its files go only through removeRootfsUnitFiles (stopRootfs and cleanCmdExe with RoleTTY, the sweep) file:external@0 d57f6d6fbe553e5ba5a5762ab2bd72586835ce1db748b67044edd1bf90af6953
@@ -35,7 +36,9 @@
@legacy 24677dea5779d57c560884eebbeea0abdcb9389b985089aefd1bf4f44bcc7b7f internal/activator/cmd.go Service.RunCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): admits one run against an awake entry under the agent's own lease, fence and swap checks; it starts nothing itself and root validates what it later names;rev3=census-ruling-edge-request-records;basis=passes nil for begin's new req parameter; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: a carlos run is refused with ErrCmdBusy while a release record of the host is open (a.releaseOps[rt.Host], in-memory), as a run already in flight refuses it; new site +registry:Host (that map lookup); adds a refusal only;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: AfterSettled honoured on every path (called before return on each path that starts no unit, else by the settle that proves the unit gone); a rootfs run is refused as a lost lease (CmdStoppedError StopLeaseLost) when its entry is not under the lease watch (residentWatchedLocked), and, off a.mu, when the replica's in-memory SafeUntil leaves less than oneShotStartLead (oneShotHeadroom); new sites are e.route.Rootfs() and a log line; adds refusals only file:Prepare@2243,file:Prepare@2277,registry:Host@1371,registry:Host@1696,registry:Host@7249,registry:Host@8485,registry:Kind@437,whole:Route@683,whole:Route@7653,whole:Route@8117,whole:Route@8650,whole:Route@869 36a03283c6c294123e02bb1779bcc6ad0ae273f69297ab35ff37e95cf2e52d8d
@legacy 170b90032d9379a8456afec905fc67a0ef82176b56fa2a8d841f39a9a010b7f8 internal/activator/cmdunit.go ExecBackend.StartCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): writes launch.cmd.json in the instance's own directory and asks instance control to start the cmd unit; root validates the staged executable it names (refuseStagedExe) and decides the start;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: after the layout and run-directory checks, a rootfs row returns startRootfsRun (backend_rootfs.go) before nestedGate; the binary path is byte-identical (TestBinaryStartCmdLaunchGolden); new site +whole:Route is rt.Rootfs() registry:Host@1576,registry:Host@1700,registry:Host@1764,registry:Host@1887,registry:Host@2034,registry:Host@218,registry:Host@2188,registry:Host@2316,registry:Host@2404,registry:Host@2808,registry:Host@2877,registry:Host@2928,registry:Host@343,registry:Host@624,registry:Host@706,registry:Host@810,whole:Route@130,whole:Route@1360,whole:Route@1467,whole:Route@2086,whole:Route@2332,whole:Route@2420,whole:Route@2740,whole:Route@2744,whole:Route@275,whole:Route@2973,whole:Route@2977,whole:Route@409,whole:Route@446 d509ae582cfb0b76ee8fced8fcb50f3c4c43f04124c67711bae473866d9cdef7
@legacy 9cf38b9e2187459c195b34026f96a71b7bf7883f4d7219e66562c9f446fbbdc3 internal/activator/rootfs_service.go Service.rootfsTick legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: per activator tick, lists residents (Registry.ResidentInstances through the DueStore), and for each rootfs entry kills generations whose replica reports a lost lease with no watch installed, stops an exited rootfs process (StopExited), and supervises; then drops forgotten residents and reserves proactive starts (residentJob) for resident-shaped, unheld rows within the start ceiling after the locked admission;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.10: when the tick kills a lost-lease resident's generations it also starts stopRootfsWorkersAtLoss(e) beside them; superviseRootfsLocked (a no-op in Group A) is now the worker supervision; the same 15 read sites, no read added; stops more, starts nothing new on its own;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: the no-signal fallback also covers a hibernating rootfs entry with a one-shot unit that may run (oneShotHoldsLocked); it latches ownerKilled and runs each one-shot kill func (KillOneShot to root's existing /stop) with go off a.mu, beside a resident's killResidentGens and stopRootfsWorkersAtLoss as before; new site +whole:Route is e.route.Rootfs(); stops more, starts nothing registry:Host@1842,registry:Host@2071,registry:Host@2427,whole:Route@113,whole:Route@1200,whole:Route@1795,whole:Route@1824,whole:Route@1993,whole:Route@2024,whole:Route@2106,whole:Route@2271,whole:Route@2320,whole:Route@2465,whole:Route@397,whole:Route@803,whole:Route@824 de44f5578a049a224f06a302863752c3a4ff53767478a54d08e373db018efe82
+internal/activator/activator.go Service.finishStop legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with a run's settle checked before replication closes, which keeps the stop pending until the run is proven stopped; read sites unchanged, offsets moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: an HA entry (its replica is an HA one, haEntryRep) now releases through releaseHAClean (a new unit on this card) instead of e.rep.Close; when that answers errHostSliceUnproven the stop is kept pending (keepPendingLocked) with the lease held and renewing, and the sweep finishes it once proven; a non-HA entry is unchanged; the same five sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: a forgotten entry's stop is noted for its resident (noteResidentStopLocked: crash or lost lease backs off, any other stop restarts on the next tick) and its ownerDone channel is closed; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: while the host has a release command's record (a.releaseOps[e.host], running or not proven stopped), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the record's proof; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.20: while a rootfs worker may run or is a stray (rootfsWorkersLiveLocked, in-memory, read under a.mu), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the workers are proven stopped; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1 (Astra P1): beside the worker check, under the same lock, a stop with a lease stop of its commands outstanding (e.leaseStops) is kept pending, the replica and lease held, and the sweep finishes it once they have returned; the entry is never released while a kill captured for it may still reach its unit; the same five read sites, no read added registry:Socket@4054,registry:Socket@4159,whole:Route@4004,whole:Route@4056,whole:Route@4161 c565cc2dc400f420ac39130adcd32659f04d3330d8d8551f2f48afd76a696369
internal/activator/activator.go Service.installProcLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: the one place a process, its generation and the lease replica are installed on an entry; a resident is put under its lease watch (watchResidentLeaseLocked) at that moment; reads only the entry's route;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a (Call A1, Astra R1 P1-1): the lease watch is installed for every rootfs row (e.route.Rootfs()), not only a resident, so a hibernating rootfs row's run or session is reached at the lease's loss; the same one read of the entry's route; installs nothing else whole:Route@144 cacc399eb6e09be70d3a2ad1774800fb6a252590cebd62dd0e9f369e97275f81
+internal/activator/activator.go type Service authority B,C,D,F,J4 rev3=PROPOSED-seed; existing activator lifecycle and due-wake state plus owned seed exclusion and incarnation-keyed diagnostics; normal refusal and preparation ordering remain authoritative; PROPOSED-plans-2-box-limits adds the idleFor hook field, which only narrows idle windows;rev3=census-ruling-plans-4c-box-throttle;basis=gains the maxRunFor hook field beside idleFor (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=gains the disabledFor hook field beside maxRunFor (plans 4d). No read added.;rev3=census-ruling-remote-instance-metrics;basis=gains tenancySeq, hostTenants and hostMixed, in-memory fields for Tenancies; no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more field, markers (markerRetry: an atomic running flag and the last log time) for retryOwedMarkers; no read added; merge of origin/main d7ae1d76: main's fields are kept as main has them (census-ruling-remote-instance-metrics: tenancySeq, hostTenants, hostMixed); this branch's change is the same as above;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: new fields for rootfs admission (rootfsArmed, rootfsSwept), the per-host gate ask and refusal memo, and residency state (lister, backoff, start ceiling, cursor, test seam); no read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: one new field, releaseOps (host to the in-memory release record, under a.mu); no read;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W: one new field, leaseNow (a clock seam for a worker start's headroom against the lease deadline, nil is the real clock); no read;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: gains the holder cache and its single-flight state; no read;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1: one field, drainBudget (time.Duration), which New copies from residentDrainBudget and a rootfs entry's lease watch reads in its place, so a test's change of the package var never races a watch goroutine; declaration only, reads nothing c8b46a426344dcd145128985398b1540c760a7001b86f7ce0e93d465d0d026f3
internal/activator/backend_rootfs.go ExecBackend.StartRelease legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1: new; startRootfsCmd naming release.ProcessRelease, both streams through one capped line writer (releaseOutput, runs.MaxOutputBytes) into the caller's writer; no read of its own;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: passes rootfsCmdLaunch{Process: release.ProcessRelease} to startRootfsCmd in place of the bare process name; its /cmd request and launch.cmd.json are byte-identical to before (TestStartReleaseIsUnchanged, goldens written from 3fd3c3a4); no read added registry:Host@182,whole:Route@247 9dd1cb5cf2b170f59e5e46a121a665bd0ca4d6c9698aab63804880848b5ee9ee
internal/activator/cmdunit.go type CmdSpec legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): declaration only; Prepare is a callback field, not a prepared statement;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: declaration only: gains AfterSettled, a callback field the caller sets (the box's run pass removes the run's directory in it), called once when no unit of the run can be running; reads nothing file:Prepare@487 f3c596b537f466e707f4974aa06065fb08bebb4a89749c8d6138810c9aa0a5b2
internal/activator/rootfs_service.go Service.residentLeaseLost legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8 (C7): a resident's lost lease marks it and then kills its generations off a.mu (killResidentGens);rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.10: a resident's lost lease stops its workers (stopRootfsWorkersAtLoss, proven gone) in parallel with killResidentGens; rt is taken under the lock and passed to killResidentGens in place of e.route (the same route); site +whole:Route (that local rt); no file read;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a (Call A1): residentLeaseLostLocked also returns one kill func per one-shot unit that may run; each runs off a.mu in the same WaitGroup as stopRootfsWorkersAtLoss and killResidentGens, which still run only for a resident (gens non-nil); the kills go to root's existing /stop through KillOneShot; no read added whole:Route@137,whole:Route@394 64ce2f74e65941ea2a731518c773cb9b27456f2db298c69ed4e02de375b1777f
@@ -57,7 +60,7 @@ internal/activator/backend_rootfs.go ExecBackend.startRootfsRun legacy accepted-
internal/activator/backend_unit.go SplitBackend.KillOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: forwards KillOneShot by pick(rt), as KillGen does; a half without it refuses (errOneShotKillBinary); reads only the route registry:Host@219,whole:Route@123,whole:Route@286 59823fbe5e35c5b54e0843a681ad59f684bd28e3a8315c1571198b3e5c43d3ee
internal/activator/cmd.go Service.killOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: the backend's KillOneShot (oneShotKiller) for one run, bounded by DeadlineControl plus roleEmptyBound, logged either way; the registry:Host sites are log lines registry:Host@240,registry:Host@549,registry:Host@680,whole:Route@398 3eb9bb7269c2a5fc8d4c798d884d92f7fa32eddbde588a3c9ad2d741211b869b
internal/activator/cmd.go Service.stopOneShotAtLease legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one run hold's lease stop, off a.mu: with kill, killOneShot at once and again once a start that was in flight returns a unit; then the hold's own stop (StopLeaseLost) bounded by cmdStopBound; the registry:Host sites are log lines registry:Host@714,registry:Host@961,whole:Route@309,whole:Route@529 46c39957f77353866dc7d8adbababfde54bd8634f5669fd61c3011a54f5e7c9a
-internal/activator/cmd.go Service.stopOneShotsAtLeaseLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one stopOneShotAtLease func per run hold that may be running (cmdHoldsLocked), none for a binary row (rt.Rootfs()); in memory only whole:Route@240 985fd564c12bf8f0339915e776d38d3139eb28b7c44c047bd91bbfd9fad3792d
+internal/activator/cmd.go Service.stopOneShotsAtLeaseLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one stopOneShotAtLease func per run hold that may be running (cmdHoldsLocked), none for a binary row (rt.Rootfs()); in memory only; fix round 1 (Astra P1): each func is counted on the entry it was captured for (e.leaseStops, under a.mu) from capture until it returns, so its kill, which names the unit by host and role only, never reaches another command: while counted the entry is not released (finishStop keeps the stop pending, the lease held) and takes no new run or release command (cmdBusyLocked); no read added whole:Route@338 fb82ec32cafeed4d228a07dfad0c12768db2804688477471597c505eb3707009
internal/activator/rootfs_service.go Service.residentLeaseLostLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: a census unit now (two whole:Route sites, e.route to stopOneShotsAtLeaseLocked and e.route.Resident()): also returns the one-shot kill funcs of any rootfs entry that is the host's, whatever its state; a hibernating entry gets no stop and no generation kills; in memory only whole:Route@198,whole:Route@218 6266ff6af94cc58e1226f3921da636cc6fa7d365340ecce216f0493d2d7e97a7
internal/activator/rootfs_service.go Service.residentLeaseShort legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: a census unit now (two whole:Route sites, e.route to stopOneShotsAtLeaseLocked and e.route.Resident()): stops every one-shot unit that may run, whatever the entry's state, off a.mu; begins a resident's graceful stop only while it is awake, as before; in memory only whole:Route@188,whole:Route@377 c39a0d4aeb53d0608e3c3e95ea3742ef6dab8ea3419a061a3415ffe5c491ecfe
internal/host/units/carlos-instance-rootfs-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the rootfs tty template, carlos-instance-rootfs-cmd@.service outside named lines held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit --rootfs tty %I, StandardInput=file:/run/carlos/logs/%I.tty.sock with StandardOutput/StandardError=journal, and RootImage plus the two BindReadOnlyPaths sources under /run/carlos-control/exe/%I/rootfs/tty/ (root-only exe layout) instead of rootfs/cmd/. The rootfs namespace block byte for byte (TestRootfsTemplatesShareOneNamespace), runs as carlos, binds only the instance own and root paths (TestRootfsTemplatesBindOnlyTheInstancesOwnAndRoots). Task 6: POST /tty runtime=rootfs (startRootfsCmd with RoleTTY) starts it through Plan 2's rootfs one-shot path (preflight, validateStagedImage, ensureRootfsExe under rootfs/tty/, jit drop-in and owed reload, post-start MemoryDenyWriteExecute check); its files go only through removeRootfsUnitFiles (stopRootfs and cleanCmdExe with RoleTTY, the sweep) file:external@0 d57f6d6fbe553e5ba5a5762ab2bd72586835ce1db748b67044edd1bf90af6953
@@ -71,7 +74,7 @@ internal/activator/rootfs_service.go Service.rootfsTick legacy accepted-legacy a
@remove internal/instancectl/cmd.go Server.handleCmdStatus
@removed internal/instancectl/cmd.go Server.handleCmdStatus H3 census-ruling-rootfs-apps-6;absent;basis=rootfs Plan 6 Task 6: moved whole to Server.oneShotStatus (role-aware; see its claim), not deleted: no check, refusal or validation is lost
@coverage . fbc28f10f89cd03cac31bae0d798ae7f707eb7671284a6115abd8c1c214369b6
-@coverage internal/activator 8413e57c046e67da3e953ab1207c8a75da33a88dddab6b41b30684f16c808f14
+@coverage internal/activator cea21bcaeb98df2ea11cf94759d80cb0ee635f002d6cec6d19723d63e4684af4
@coverage internal/appconfig cac8d8ef7538a456d034801c95ce6508a4983e5516b3bbbd302bec0fbafdd479
@coverage internal/host 69c09eff5b3b87756182f001086b391c02b867e82e8d21ea40722c992fec43a7
@coverage internal/host/units c3cc4f3b917fdb938f20d406b1704ec54e24553851c298e312056d397d10b0e1