carlos / platform Public

agent: a session launches only on its authorized lifetime; hangup keeps the handoff; ends wait for the proof; sessions join at shutdown (rootfs plan 6 task 12 fix round 1)

Astra task 12 review: P1 and six P2s.
- CmdSpec.Incarnation: RunCmd refuses a session (ErrCmdIncarnation) at
  admission and at its last check unless the awake entry's row is the
  lifetime the grant authorized; 0 is refused. The worker re-reads its row
  and names the record's lifetime.
- ptyTerminal.Hangup closes the master alone; the handoff listener stays
  until the settle, for the tty unit's ExecStopPost.
- Each Stop has its own budget from the moment it is asked; the End, the
  start-failure verdict and Release wait for the proof (AfterSettled).
- The worker's shutdown cancels and joins every session; runAgent calls it
  after svc.Shutdown. The Open wait ends on cancellation.
- The reader is released on every exit of a session.
- Sessions keep the pass's context values (the lifetime judge, PF-19).
- The request budget is asserted at the wire (NewDeploymentS3Store over a
  counting fake S3): 2 GETs per session, none otherwise.
- A signal is exit 128+n, as carlos run reports one.
Census overlay rootfs-apps-6 re-proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 3ec25d3703c654373abd21bdd254b257af1fbd3f parent 690b226
12 files changed, +782 −113
  • docs/superpowers/notes/census-proposal-rootfs-apps-6.md +7 −6
  • internal/activator/activator_test.go +4 −1
  • internal/activator/cmd.go +24 −0
  • internal/activator/cmd_test.go +70 −1
  • internal/activator/cmdunit.go +9 −1
  • internal/activator/pty_linux.go +16 −5
  • internal/activator/pty_linux_test.go +32 −0
  • internal/host/agent.go +5 −0
  • internal/host/interactive.go +176 −35
  • internal/host/interactive_test.go +420 −47
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv +18 −16

Intent

Human

<task-notification> <task-id>a30b99354e9ae2d3c</task-id> <tool-use-id>toolu_012XDASFmjGCS7cWnjGmTGkF</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a30b99354e9ae2d3c.output</output-file> <status>completed</status> <summary>Agent "Plan 6 Task 12: box session worker" 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 **Commit:** 690b2265 `agent: the box's interactive session worker (rootfs plan 6)`, on rootfs-apps-6-interactive. Not pushed. The report is at `.superpowers/sdd/2026-10-24-rootfs-apps-6-interactive/task-12-report.md`. That directory is git-ignored, so the report is not in the commit, the same as the earlier task reports. **Tests:** the brief's 14 tests plus 21 more pass, three times under `-race`, including the linux end-to-end test with a real `console.Server`, a real pty and `/bin/cat`, and the restarted-worker test against a real console. The runs, box-judge, copy-gate and census tests also pass, and the darwin/arm64, windows/amd64 and linux/arm64 builds are clean. Of 40 mutations, 39 are killed. The one survivor (M12) drops an explicit pickup-time check, which changes nothing because `VerifyGrant` already refuses the same expired grant. **Request counts:** - **One session on the owning box:** 2 GETs (the grant, then `config.json`) and no writes, lists or record reads. A test asserts this. - **Idle pass, a record already seen, or a box that doesn't own the row (or, for an HA host, doesn't hold it awake):** 0 requests. - **A forged or mismatched grant:** 1 GET, once. **Census:** I re-proposed the rootfs-apps-6 overlay; the seal moved from f02fd204 to 75b5bf97. All 47 earlier claims are carried over unchanged, including the removed `handleCmdStatus` claim, and there are 12 new ones. The changes are: - `runAgent` gains one call, `armInteractivePass`. - Five new units in `interactive.go`. - `internal/interactive` enters the root binary's scope unchanged, because the agent now imports it. **Concerns:** 1. **Copy gap:** a session ended as `replaced` has no approved reason sentence. Its `carlos logs` line shows the bare code ("…ended after 3s: replaced"), the same fallback `runRefusedWords` uses for unknown codes. It needs a row in the batched copy review. 2. **Signal exits:** a command killed by a signal is reported as exited with code 128+n, because the End frame has no signal field. 3. **HA limit (PF-15, dev only):** a sleeping HA host that no box holds awake is never dialed, so its session expires with RFS-6-C18. 4. **Pre-existing cross-vet failures:** `GOOS=darwin|windows go vet` already fails in `internal/host` at `hawake_wiring_test.go`, which uses helpers from a linux-only test file, and in `internal/activator` at `activator_test.go:4930` (`unix.Mkfifo`). My test files compile on darwin. 5. **Slow replacement:** if a newer session replaces one that is still waiting for its Open frame, the old one notices only when that read returns, up to 10 s later. It then ends as replaced without starting anything.</result> <usage><subagent_tokens>399494</subagent_tokens><tool_uses>150</tool_uses><duration_ms>3545909</duration_ms></usage> </task-notification>

Human

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

Human

> WebSockets for fleet apps (#471) are merged and on dev (v0.32.1). The one check left waits for bab's usage limit to reset at midnight UTC. Why are we waiting for a usage limit on a platform we own/control?

Attributed to this commit: 143 g CO₂e (13,276,933 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 db2c868a2..68288ff7c 100644
--- a/docs/superpowers/notes/census-proposal-rootfs-apps-6.md
+++ b/docs/superpowers/notes/census-proposal-rootfs-apps-6.md
@@ -1,6 +1,6 @@
# Census approval: rootfs-apps-6
-Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejects every change below, 28 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejects every change below, 29 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
| unit | change | read sites | what changed |
|---|---|---|---|
@@ -9,12 +9,12 @@ Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejec
| `internal/activator/activator.go` `Service.sweepOnce` | body | unchanged (39) | rootfs Plan 6 Task 9 (PF-18): the four checks that left an entry with a run attached alone (e.cmd == nil) now read holdsAttachedLocked(e), a run or a session attached, so a session holds the idle sleep, the plans awake ceiling, the plans turned-off stop and the turned-off worker's stand-down as a run does; in-memory under a.mu; only keeps an entry awake longer; no read added, read sites unchanged |
| `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; Plan 6 Task 8: passes instancectl.RoleCmd and oneShotSinks{Stdout, Stderr} (the same two release writers) to startRootfsCmd, which now takes the role; its /cmd request and launch.cmd.json stay byte-identical (TestStartReleaseIsUnchanged); 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; fix round 2: comment only: AfterSettled is called once, after the proof, never while a lock is held, in the settle's goroutine without the stop waiting for it, and must not call Stop or Shutdown; Plan 6 Task 8: declaration only: gains Process (a declared process name, "" or console; StartCmd refuses it except for a session on a rootfs row) and TTY (*TTYSpec: Term, Cols, Rows; set, the command is a session in the tty unit), fields the box sets; reads nothing |
+| `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; fix round 2: comment only: AfterSettled is called once, after the proof, never while a lock is held, in the settle's goroutine without the stop waiting for it, and must not call Stop or Shutdown; Plan 6 Task 8: declaration only: gains Process (a declared process name, "" or console; StartCmd refuses it except for a session on a rootfs row) and TTY (*TTYSpec: Term, Cols, Rows; set, the command is a session in the tty unit), fields the box sets; reads nothing Task 12 fix round 1: declaration only: gains Incarnation (uint64), the session's authorized lifetime, which the box sets from the instance record and RunCmd compares with the entry's row; reads nothing |
| `internal/activator/prepare.go` `ExecBackend.prepareKeyedAt` | body | unchanged (13) | rootfs Plan 6 Task 8: the cmd role three exceptions (no env read, the replica gate left to StartCmd, no app-log listener) now cover every one-shot role, instancectl.OneShot(role): cmd and tty; before, the tty role fell to the sidecar env-file read and an app-log listener on its handoff socket path; no read added, one removed for tty |
| `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 |
| `internal/activator/rootfsrelease.go` `Service.releaseAdmitLocked` | body | unchanged (3) | rootfs Plan 6 Task 9 (PF-17): the busy check is holdBusyLocked(e, RoleCmd) where it was cmdBusyLocked(e): only established cmd-unit holds and cmd-unit lease stops refuse a release command, never a started session, whose tty unit is its own; cmdStartInFlightLocked now also counts a session's start in flight (merge ruling M2), so a release is refused during either role's start window, short and bounded, as swap admission is (fix round 2 ruling: a refusal at admission is not executed and takes the ordinary retry); no read added, read sites unchanged |
| `internal/activator/rootfsrelease.go` `Service.runRelease` | body | unchanged (12) | rootfs Plan 6 Task 9: newCmdHold takes the hold's role; a release command's hold is instancectl.RoleCmd, the unit it runs in; nothing else changed, no read added |
-| `internal/host/agent.go` `runAgent` | body | unchanged (6) | rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites |
+| `internal/host/agent.go` `runAgent` | body | unchanged (6) | rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites |
| `internal/host/runexec.go` `runsWorker.execute` | body | unchanged (2) | rootfs Plan 6 Task 7a (INV-2): sets CmdSpec.AfterSettled to remove the run's directory (runs.RemoveRunDir under the instance's own directory, as cleanUp did) once the activator has proven no unit of the run runs; finish and cleanUp take removeDir, true only on the incarnation refusal before RunCmd; the directory goes later or at the same point, never earlier; no read added |
| `internal/host/units/carlos-instance-cmd@.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else |
| `internal/host/units/carlos-instance-gen@.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else |
@@ -30,7 +30,7 @@ Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejec
| `internal/provision/reconcile.go` `Reconcile` | body | unchanged (178) | rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call |
| `internal/provision/seed.go` `SeedAbortBecause` | body | unchanged (1) | rootfs Plan 6 Task 9 (carried from Task 3's review): after the open-run refusal, an import's abort is also refused while the record carries a session marker (rec.Interactive), with an InteractiveOpenError; a --from seed's abort is unchanged; it only refuses more, no read added |
| `internal/activator/backend_rootfs.go` `ExecBackend.startRootfsCmd` | sites | +registry:Host, -whole:Route | rootfs Plan 6 Task 7a: takes a rootfsCmdLaunch, a declared process or an operator's argv, exactly one or refused before anything is laid out; the launch file names the process or cmd, never an argv; CmdRootfs names the image with the process or with the argv in the request body, which root validates against the staged image itself (instancectl, unchanged); new site +registry:Host is that refusal's message; Plan 6 Task 8 (PF-1): takes the role, cmd or tty, and oneShotSinks; refused before anything is laid out unless the role is a one-shot whose I/O matches (a terminal for tty alone), and for tty unless the control channel has the session verbs (TTYControl, else ErrNoTTY); prepare(rt, role); for tty the session pty and its handoff socket on the agent own logs path (openTTY, TTYSocketName) take the place of the two stream listeners; the launch file is the role one (launch.tty.json for tty: schema 2, process console or cmd, never an argv, env alone through rootfsLaunchEnv); a tty starts through TTYControl.TTYRootfs (POST /tty runtime=rootfs; root Task 6 handler validates the staged image and the process or argv itself), a cmd through CmdRootfs as before; the same refusal and may-have-begun handling; -whole:Route is b.tier(rt) read once |
-| `internal/activator/cmd.go` `Service.RunCmd` | sites | +registry:Host, +whole:Route ×2 | 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 Task 9 (PF-17): a session (spec.TTY) takes the entry's tty slot and a run its cmd slot (holdSlot), the hold carrying its role (newCmdHold); each is refused only for its own role (holdBusyLocked: ErrCmdBusy or ErrTTYBusy), so a run and a session coexist; a release command (a.releaseOps) refuses a run only, since the session's tty unit is its own; no read added, read sites unchanged |
+| `internal/activator/cmd.go` `Service.RunCmd` | sites | +registry:Host, +whole:Route ×2 | 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 Task 9 (PF-17): a session (spec.TTY) takes the entry's tty slot and a run its cmd slot (holdSlot), the hold carrying its role (newCmdHold); each is refused only for its own role (holdBusyLocked: ErrCmdBusy or ErrTTYBusy), so a run and a session coexist; a release command (a.releaseOps) refuses a run only, since the session's tty unit is its own; no read added, read sites unchanged Task 12 fix round 1 (Astra P1, incarnation binding): a session (spec.TTY) is refused with ErrCmdIncarnation, under a.mu, at admission (before the hold is attached, so nothing of it runs) and again at the last check before the start, unless the awake entry's row lifetime (e.route.Incarnation) equals spec.Incarnation, the lifetime the box's grant authorized; 0 (unknown) is refused; a run is not checked; refuses more, starts nothing new, no read added beyond the in-memory e.route field (sessionIncarnationLocked) |
| `internal/activator/cmdunit.go` `ExecBackend.StartCmd` | sites | +registry:Host, +whole:Route ×2 | 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(); Plan 6 Task 8: a session (spec.TTY): checkCmdLaunch refuses before anything is listened on or written a launch shape (errCmdLaunchShape: process and argv both or neither, a process other than console, a run naming a process, a session with a run directory or streams, an id that is not one path element) and a process on a binary row (errBinaryProcess); then the session verbs (TTYControl) or ErrNoTTY; on a binary row the same nested gate, live link or staged build, launch environment and replica gate as a run; prepare(rt, RoleTTY); the pty and its handoff socket (openTTY) in place of the two streams; launch.tty.json with argv [live link, args...] and childEnv(ttyVars); then TTYControl.TTY, or TTYExe naming the staged build (POST /tty; root Task 6 handler validates it); the run path is unchanged (TestBinaryStartCmdLaunchGolden); new sites are rt to checkCmdLaunch and rt.Host in its error |
| `internal/activator/cmdunit.go` `cmdUnit.Poll` | sites | +registry:Host ×4, +registry:Runtime, +whole:Route ×5 | rootfs Plan 6 Task 8 (PF-7): role-aware: a cmd unit polls as before (CmdStatusRootfs on a rootfs row, CmdStatus on a binary one); a tty unit polls through TTYControl, TTYStatusRootfs on a rootfs row and TTYStatus on a binary one, or ErrNoTTY without the session verbs; any other role is refused; all status reads over the control socket, no decision; the new sites are the error text (rt.Host), the tty arm runtime check (rt.Runtime) and the route passed |
| `internal/activator/rootfs_service.go` `Service.rootfsTick` | sites | +whole:Route | 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 |
@@ -88,6 +88,7 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/activator/cmd.go:Service.killOneShot`: reads +registry:Host ×3, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/cmd.go:Service.stopOneShotAtLease`: reads +registry:Host ×2, +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/activator/cmd.go:Service.stopOneShotsAtLeaseLocked`: reads +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/activator/cmd.go:sessionIncarnationLocked`: reads +registry:Incarnation, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/cmdunit.go:ExecBackend.ttyVars`: reads +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/activator/pty_linux.go:openPTY`: reads +file:Open, +file:Syscall; written legacy, accepted-legacy, frozen
- new `internal/activator/pty_linux.go:ptyTerminal.Read`: reads +file:Read ×2; written legacy, accepted-legacy, frozen
@@ -98,7 +99,7 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/host/interactive.go:interactiveWorker.owned`: reads +registry:Account, +registry:App, +registry:Provisioned, +whole:Route ×3; written legacy, accepted-legacy, frozen
- new `internal/host/interactive.go:sessionRun.bridge`: reads +file:Read; written legacy, accepted-legacy, frozen
- new `internal/host/interactive.go:sessionRun.receiveOpen`: reads +file:Open ×6; written legacy, accepted-legacy, frozen
-- new `internal/host/interactive.go:sessionRun.serve`: reads +file:Open, +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/host/interactive.go:sessionRun.serve`: reads +file:Open, +registry:Incarnation, +whole:Route; written legacy, accepted-legacy, frozen
- new `internal/host/units/carlos-instance-rootfs-tty@.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
- new `internal/host/units/carlos-instance-tty@.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
- new `internal/instancectl/cmd.go:Server.oneShotStatus`: reads +file:Query ×3; written legacy, accepted-legacy, frozen
@@ -111,6 +112,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/interactive/interactive.go:type Open`: reads +file:Open; written legacy, accepted-legacy, frozen
- reads `internal/activator/cmdunit.go:cmdUnit.StopAndSettle`: +registry:Host, +whole:Route; keeps legacy, task accepted-legacy
-Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `75b5bf971620474d35c8cd06aab78f0c4edfc24d925729daa3567bcf369ca644`.
+Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `87f29ffd175e44b45b2de6a8f9623b9384dd36be3ef8a057bbcfd723c9118b5e`.
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_test.go b/internal/activator/activator_test.go
index ac26b0cf5..d678dea3c 100644
--- a/internal/activator/activator_test.go
+++ b/internal/activator/activator_test.go
@@ -902,8 +902,11 @@ func testRoute(host string) registry.Route {
// Hibernate is set because these routes model activator-managed hosts —
// the per-host gate (the due sweep's flag filter, ServeHTTP's gate) only
// acts on flagged instances.
+ // Incarnation is the row's lifetime, as every row minted since the
+ // lifetime pair has one: a session names it (CmdSpec.Incarnation,
+ // sessionSpec).
return registry.Route{Host: host, Kind: "instance", Socket: "/tmp/nope.sock",
- DBPath: filepath.Join("/tmp", host+".db"), Hibernate: true}
+ DBPath: filepath.Join("/tmp", host+".db"), Hibernate: true, Incarnation: 1}
}
// testWorkerRoute is a standalone sidecar's row: no socket (nothing can dial
diff --git a/internal/activator/cmd.go b/internal/activator/cmd.go
index 842f06b8e..a3aaf27ce 100644
--- a/internal/activator/cmd.go
+++ b/internal/activator/cmd.go
@@ -41,6 +41,18 @@ var ErrCmdBusy = errors.New("activator: a run is already attached to this instan
// is never a reason: the session has its own unit.
var ErrTTYBusy = errors.New("activator: a session is already attached to this instance")
+// ErrCmdIncarnation: a session's authorization names another lifetime of
+// the instance than the awake entry's row, or none (CmdSpec.Incarnation).
+// Nothing starts.
+var ErrCmdIncarnation = errors.New("activator: the session was authorized for another lifetime of the instance")
+
+// sessionIncarnationLocked reports whether spec, a session, is refused
+// against e for its lifetime: unknown, or not the entry's row's. A run is
+// never refused here. The caller holds a.mu.
+func sessionIncarnationLocked(e *actEntry, spec CmdSpec) bool {
+ return spec.TTY != nil && (spec.Incarnation == 0 || e.route.Incarnation != spec.Incarnation)
+}
+
// ErrCmdNotInstance: runs are for instances; the route is a worker or
// another kind.
var ErrCmdNotInstance = errors.New("activator: runs are only for instances, and this route is not one")
@@ -760,6 +772,12 @@ func (a *Service) RunCmd(ctx context.Context, rt registry.Route, spec CmdSpec) (
a.mu.Unlock()
release()
return refuse(ErrCmdNotInstance)
+ case sessionIncarnationLocked(e, spec):
+ // The awake entry is another lifetime of the host than the one the
+ // session was authorized for (Task 12 fix round 1, P1).
+ a.mu.Unlock()
+ release()
+ return refuse(ErrCmdIncarnation)
case holdBusyLocked(e, role), role == instancectl.RoleCmd && a.releaseOps[rt.Host] != nil:
// A release command of the host, running or not proven stopped,
// holds its cmd unit as a run does (Group R, INV-R1): the record is
@@ -811,6 +829,12 @@ func (a *Service) RunCmd(ctx context.Context, rt registry.Route, spec CmdSpec) (
a.mu.Unlock()
return abandon(&CmdStoppedError{Reason: why})
}
+ // The entry's row may have moved meanwhile: a session still names
+ // its lifetime, or starts nothing.
+ if sessionIncarnationLocked(e, spec) {
+ a.mu.Unlock()
+ return abandon(ErrCmdIncarnation)
+ }
// An overlap successor is on its way: the current generation may
// retire before the unit is even up, so nothing starts against it.
// The run waits for the switch (and then runs the successor's
diff --git a/internal/activator/cmd_test.go b/internal/activator/cmd_test.go
index 17e26ab4f..38bea1395 100644
--- a/internal/activator/cmd_test.go
+++ b/internal/activator/cmd_test.go
@@ -89,7 +89,8 @@ func (*fakeTerminal) Hangup() error { return nil }
// sessionSpec is a session's launch (spec.TTY set, rootfs apps Plan 6).
func sessionSpec(id string) CmdSpec {
- return CmdSpec{RunID: id, Args: []string{"sh"}, TTY: &TTYSpec{Term: "xterm-256color", Cols: 80, Rows: 24}}
+ // Incarnation is testRoute's lifetime: the session was authorized for it.
+ return CmdSpec{RunID: id, Args: []string{"sh"}, TTY: &TTYSpec{Term: "xterm-256color", Cols: 80, Rows: 24}, Incarnation: 1}
}
// cmdFakeBackend is fakeBackend with the run capability and a nested layout.
@@ -1456,3 +1457,71 @@ func TestHoldsAwake(t *testing.T) {
a.entries[rt.Host] = e
a.mu.Unlock()
}
+
+// A session launches only against the lifetime it was authorized for (Task
+// 12 fix round 1, P1): an awake entry of another lifetime of the host, an
+// unknown lifetime, or an entry whose row moves before the start, is
+// ErrCmdIncarnation, and no unit starts. A run is not checked.
+func TestRunCmdBindsASessionToItsIncarnation(t *testing.T) {
+ session := func(inc uint64) CmdSpec { s := sessionSpec("tty_a"); s.Incarnation = inc; return s }
+ old, successor := testRoute("c.example.com"), testRoute("c.example.com")
+ old.Incarnation, successor.Incarnation = 1, 2
+
+ t.Run("a successor is awake", func(t *testing.T) {
+ a, cb, _ := testCmdActivator(t, Config{})
+ run, err := a.RunCmd(context.Background(), successor, CmdSpec{RunID: "run_a"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer run.Release()
+ prepared := 0
+ stale := session(1)
+ stale.Prepare = func(context.Context) error { prepared++; return nil }
+ if _, err := a.RunCmd(context.Background(), old, stale); !errors.Is(err, ErrCmdIncarnation) {
+ t.Fatalf("err = %v, want ErrCmdIncarnation", err)
+ }
+ if cb.ttyStarts != 0 || prepared != 0 {
+ t.Fatalf("a session of the old lifetime: %d tty starts, Prepare ran %d times; want it refused at admission", cb.ttyStarts, prepared)
+ }
+ if tty := a.entries[successor.Host].tty; tty != nil {
+ t.Fatal("a refused session holds the tty slot")
+ }
+ // The control: the successor's own session starts.
+ h, err := a.RunCmd(context.Background(), successor, session(2))
+ if err != nil || cb.ttyStarts != 1 {
+ t.Fatalf("the successor's session: %v, %d starts", err, cb.ttyStarts)
+ }
+ h.Release()
+ })
+ t.Run("unknown", func(t *testing.T) {
+ // A row and a session with no lifetime: unknown is refused, even
+ // though the two agree.
+ a, cb, _ := testCmdActivator(t, Config{})
+ legacy := testRoute("c.example.com")
+ legacy.Incarnation = 0
+ if _, err := a.RunCmd(context.Background(), legacy, session(0)); !errors.Is(err, ErrCmdIncarnation) || cb.ttyStarts != 0 {
+ t.Fatalf("err = %v, %d starts; want ErrCmdIncarnation and none", err, cb.ttyStarts)
+ }
+ })
+ t.Run("the row moves before the start", func(t *testing.T) {
+ a, cb, _ := testCmdActivator(t, Config{})
+ spec := session(1)
+ spec.Prepare = func(context.Context) error {
+ a.mu.Lock()
+ a.entries[old.Host].route.Incarnation = 2
+ a.mu.Unlock()
+ return nil
+ }
+ if _, err := a.RunCmd(context.Background(), old, spec); !errors.Is(err, ErrCmdIncarnation) || cb.ttyStarts != 0 {
+ t.Fatalf("err = %v, %d starts; want ErrCmdIncarnation and none", err, cb.ttyStarts)
+ }
+ })
+ t.Run("a run is not checked", func(t *testing.T) {
+ a, cb, _ := testCmdActivator(t, Config{})
+ h, err := a.RunCmd(context.Background(), old, CmdSpec{RunID: "run_a"})
+ if err != nil || cb.cmdStarts != 1 {
+ t.Fatalf("a run: %v, %d starts", err, cb.cmdStarts)
+ }
+ h.Release()
+ })
+}
diff --git a/internal/activator/cmdunit.go b/internal/activator/cmdunit.go
index c1a1bae02..cae3410c9 100644
--- a/internal/activator/cmdunit.go
+++ b/internal/activator/cmdunit.go
@@ -56,6 +56,14 @@ type CmdSpec struct {
// unit on a pty whose master the unit hands back (CmdUnit.Terminal).
// RunDir is unused and Stdout and Stderr must be nil.
TTY *TTYSpec
+ // Incarnation is the instance lifetime a session's authorization names
+ // (the record's Incarnation, which the row's lifetime pair carries;
+ // rootfs apps Plan 6 Task 12 fix round 1). RunCmd refuses a session
+ // with ErrCmdIncarnation, under a.mu at admission and again at its last
+ // check, unless the awake entry's row has exactly this lifetime; 0, a
+ // lifetime unknown, is refused. A run does not set it and is not
+ // checked: its pass reads the record again under the hold (Prepare).
+ Incarnation uint64
// RunDir is CARLOS_RUN_DIR: <instance dir>/.carlos-run/<RunID>, made and
// filled by the caller.
RunDir string
@@ -137,7 +145,7 @@ type Terminal interface {
io.Reader // the pty master; reads EIO once the tenant's side has closed
io.Writer
Resize(cols, rows uint16) error // TIOCSWINSZ on the master: the kernel sends SIGWINCH to the foreground group
- Hangup() error // closes the master: SIGHUP to the tenant's session
+ Hangup() error // closes the master alone: SIGHUP to the tenant's session; the handoff stays until the settle
}
// TTYStartFailed reports whether a session's unit, whose poll answered st,
diff --git a/internal/activator/pty_linux.go b/internal/activator/pty_linux.go
index a5b4784ba..fe0e597a4 100644
--- a/internal/activator/pty_linux.go
+++ b/internal/activator/pty_linux.go
@@ -243,6 +243,9 @@ type ptyTerminal struct {
closeOnce sync.Once
closeErr error
+ // masterOnce closes the master once, for Hangup and close alike.
+ masterOnce sync.Once
+ masterErr error
}
// openTTY opens a session's pty at cols x rows and listens at path to hand
@@ -280,10 +283,18 @@ func (t *ptyTerminal) Resize(cols, rows uint16) error {
return ioctlErr
}
-// Hangup closes the handoff and the master: the kernel hangs up the
-// tenant's session (SIGHUP to its session leader). Safe to call more than
-// once, and after the settle has closed them.
-func (t *ptyTerminal) Hangup() error { return t.close() }
+// Hangup closes the master alone: the kernel hangs up the tenant's session
+// (SIGHUP to its session leader). The handoff listener stays until the
+// settle closes it (close, from StopAndSettle), because the unit's
+// ExecStopPost opens the same StandardInput= socket (Task 8's ruling; Task
+// 12 fix round 1, P2). Safe to call more than once, and after the settle.
+func (t *ptyTerminal) Hangup() error { return t.closeMaster() }
+
+// closeMaster closes the master, once.
+func (t *ptyTerminal) closeMaster() error {
+ t.masterOnce.Do(func() { t.masterErr = t.master.Close() })
+ return t.masterErr
+}
// handed reports whether the slave reached the tty unit.
func (t *ptyTerminal) handed() bool { return t.h.Handed() }
@@ -291,7 +302,7 @@ func (t *ptyTerminal) handed() bool { return t.h.Handed() }
// close closes the handoff and the master, once.
func (t *ptyTerminal) close() error {
t.closeOnce.Do(func() {
- t.closeErr = errors.Join(t.h.Close(), t.master.Close())
+ t.closeErr = errors.Join(t.h.Close(), t.closeMaster())
})
return t.closeErr
}
diff --git a/internal/activator/pty_linux_test.go b/internal/activator/pty_linux_test.go
index 0e0bfd7af..f470b023c 100644
--- a/internal/activator/pty_linux_test.go
+++ b/internal/activator/pty_linux_test.go
@@ -896,3 +896,35 @@ func TestTTYHandoffSocketLastsUntilTheSettle(t *testing.T) {
t.Errorf("the handoff socket after the settle: %v, want it gone", err)
}
}
+
+// A session's hangup closes the master alone (Task 12 fix round 1, P2): the
+// box's worker hangs up before it stops the unit, and the handoff socket
+// must still answer the tty unit's ExecStopPost= until the settle.
+func TestTTYHangupKeepsTheHandoffUntilTheSettle(t *testing.T) {
+ skipAsRoot(t, "the test's own connection would be root's")
+ b, rt, _, _, u := startBinaryTTY(t)
+ sock := b.logSocketNamed(rt.Host, TTYSocketName)
+ setTTYPeerOK(t, peerIsMe)
+ if _, fds, err := receiveTTY(t, sock); err != nil || len(fds) != 1 {
+ t.Fatalf("handoff: %d fds, %v", len(fds), err)
+ }
+ term := u.Terminal()
+ if err := term.Hangup(); err != nil {
+ t.Fatalf("Hangup: %v", err)
+ }
+ if _, err := term.Read(make([]byte, 8)); err == nil {
+ t.Fatal("the master still reads after the hangup")
+ }
+ if payload, fds, err := receiveTTY(t, sock); payload != "" || len(fds) != 0 || !errors.Is(err, io.EOF) {
+ t.Fatalf("after the hangup the post hook's connect got %q and %d fds (%v), want EOF and nothing", payload, len(fds), err)
+ }
+ if _, err := os.Lstat(sock); err != nil {
+ t.Fatalf("the handoff socket after the hangup: %v, want it kept until the settle", err)
+ }
+ if err := u.StopAndSettle(context.Background()); err != nil {
+ t.Fatalf("StopAndSettle: %v", err)
+ }
+ if _, err := os.Lstat(sock); !errors.Is(err, os.ErrNotExist) {
+ t.Errorf("the handoff socket after the settle: %v, want it gone", err)
+ }
+}
diff --git a/internal/host/agent.go b/internal/host/agent.go
index d343144b3..0463c466e 100644
--- a/internal/host/agent.go
+++ b/internal/host/agent.go
@@ -1107,6 +1107,11 @@ func runAgent(args []string, buildClaims ClaimFactory) {
if svc != nil {
ctx := shutdownCtx
svc.Shutdown(ctx)
+ // Then the interactive sessions' worker (rootfs apps Plan 6 Task
+ // 12): every session, whatever its stage, ends and is joined under
+ // the same budget. Shutdown has settled their units, so each sends
+ // its End and logs its line before this process exits.
+ shutdownInteractive(ctx)
// Then the scheduler, under the same budget (spec §8.6, Task 11): an
// attempt whose swap Shutdown just cancelled finishes its done(), its
// outcome and the end of its intent on disk, and so does a wake event
diff --git a/internal/host/interactive.go b/internal/host/interactive.go
index caab53a2e..2a694c0ae 100644
--- a/internal/host/interactive.go
+++ b/internal/host/interactive.go
@@ -67,8 +67,11 @@ const (
)
// errSessionReplaced is the cause a newer session for the same host ends
-// an older one with.
-var errSessionReplaced = errors.New("host: a newer session replaced this one")
+// an older one with; errWorkerShutdown is the agent's shutdown's.
+var (
+ errSessionReplaced = errors.New("host: a newer session replaced this one")
+ errWorkerShutdown = errors.New("host: the agent is shutting down")
+)
// interactiveWorker is the box's half of interactive sessions.
type interactiveWorker struct {
@@ -93,6 +96,10 @@ type interactiveWorker struct {
idle, max, grace time.Duration
alive, lost, openWait time.Duration
drain time.Duration
+ // stopBound is one Stop's budget, from the moment it is asked for
+ // (runStopBound); a Stop that ends without the proof is asked again
+ // each bound until the proof comes.
+ stopBound time.Duration
// holds is svc.HoldsAwake, consulted only for an HA route (PF-15).
holds func(host string) bool
// judge is the box's lifetime judge (newBoxJudge): every pass runs
@@ -105,16 +112,27 @@ type interactiveWorker struct {
startFailed func(activator.Terminal, instancectl.CmdStatus) bool
// start runs a session on its own goroutine.
start func(func())
+ // afterOpen, when set, is called with the session once its Open has
+ // arrived and its reader runs, before it serves. A test seam.
+ afterOpen func(s *sessionRun)
+
+ // life ends at shutdown (cancelled by shut): every session's context
+ // ends with it. sessions joins them.
+ life context.Context
+ shut context.CancelFunc
+ sessions sync.WaitGroup
mu sync.Mutex
noted map[string]provision.Record // host -> the record reconcile read
seen map[string]time.Time // session id -> when it may be forgotten
logged map[string]bool // ids whose grant read failed, logged once
active map[string]*sessionRun // host -> the session this worker runs
+ closed bool // shutdown has begun: no new session
}
func newInteractiveWorker(store release.Store, routes func(string) (*registry.Route, error), launch runLauncher, pub ed25519.PublicKey, box string) *interactiveWorker {
- return &interactiveWorker{store: store, routes: routes, launch: launch, pub: pub, box: box,
+ life, shut := context.WithCancel(context.Background())
+ return &interactiveWorker{store: store, routes: routes, launch: launch, pub: pub, box: box, life: life, shut: shut,
fleet: func() (string, string, bool) { return "", "", false },
allowed: func(ctx context.Context, acct, app string) (bool, error) {
// The default bundle's setting (carried from Task 4).
@@ -124,7 +142,7 @@ func newInteractiveWorker(store release.Store, routes func(string) (*registry.Ro
now: time.Now,
idle: interactive.IdleTimeout, max: interactive.MaxDuration, grace: interactive.HangupGrace,
alive: interactive.KeepaliveEvery, lost: interactive.KeepaliveLost, openWait: interactive.OpenWait,
- drain: sessionDrain, startFailed: activator.TTYStartFailed,
+ drain: sessionDrain, stopBound: runStopBound, startFailed: activator.TTYStartFailed,
start: func(f func()) { go f() },
noted: map[string]provision.Record{}, seen: map[string]time.Time{}, logged: map[string]bool{},
active: map[string]*sessionRun{}}
@@ -168,6 +186,27 @@ func (w *interactiveWorker) pass(ctx context.Context) {
}
}
+// shutdown ends every session this worker runs, whatever its stage (a dial
+// or an Open pending, a start, an attached session), and waits for each to
+// finish, within ctx. No session starts after it. An attached session is
+// hung up and stopped at once; its End says the box's agent stopped.
+func (w *interactiveWorker) shutdown(ctx context.Context) {
+ w.mu.Lock()
+ w.closed = true
+ w.mu.Unlock()
+ w.shut()
+ done := make(chan struct{})
+ go func() {
+ w.sessions.Wait()
+ close(done)
+ }()
+ select {
+ case <-done:
+ case <-ctx.Done():
+ log.Printf("agent: interactive: shutdown: sessions still ending: %v", ctx.Err())
+ }
+}
+
// seenFor is how long an id stays seen after its pickup: past it, a grant
// would be refused as expired anyway (VerifyGrant allows MaxGrantSkew).
const seenFor = 2 * interactive.MaxGrantSkew
@@ -218,6 +257,13 @@ func (w *interactiveWorker) consider(ctx context.Context, rec provision.Record)
if m == nil {
return
}
+ w.mu.Lock()
+ closed := w.closed
+ w.mu.Unlock()
+ if closed {
+ // Shutting down: nothing is read and nothing starts.
+ return
+ }
rt, ok := w.owned(rec)
if !ok {
return
@@ -267,13 +313,26 @@ func (w *interactiveWorker) consider(ctx context.Context, rec provision.Record)
w.markSeen(id, g.PickupBy)
s := &sessionRun{w: w, rec: rec, rt: rt, g: g, done: make(chan struct{}),
activity: make(chan struct{}, 1), in: make(chan sessionInput, sessionInputQueue),
- readDone: make(chan struct{}), over: make(chan struct{})}
- s.ctx, s.cancel = context.WithCancelCause(context.Background())
+ readDone: make(chan struct{}), over: make(chan struct{}), settled: make(chan struct{})}
+ // The session's context keeps the pass's values, the lifetime judge
+ // among them (PF-19), and none of its deadline: it ends when a newer
+ // session replaces it or the worker shuts down.
+ s.ctx, s.cancel = context.WithCancelCause(context.WithoutCancel(ctx))
w.mu.Lock()
+ if w.closed {
+ w.mu.Unlock()
+ s.cancel(errWorkerShutdown)
+ return
+ }
old := w.active[rec.Host]
w.active[rec.Host] = s
+ w.sessions.Add(1)
w.mu.Unlock()
- w.start(func() { s.run(old) })
+ s.unwatch = context.AfterFunc(w.life, func() { s.cancel(errWorkerShutdown) })
+ w.start(func() {
+ defer w.sessions.Done()
+ s.run(old)
+ })
}
// forget drops s from the active set, unless a newer session took its host.
@@ -307,18 +366,24 @@ type sessionRun struct {
rt registry.Route
g interactive.Grant
// ctx is cancelled, with errSessionReplaced, by a newer session for
- // the host.
- ctx context.Context
- cancel context.CancelCauseFunc
- done chan struct{}
+ // the host, or with errWorkerShutdown by the worker's shutdown
+ // (unwatch stops that).
+ ctx context.Context
+ cancel context.CancelCauseFunc
+ unwatch func() bool
+ done chan struct{}
+ // settled closes when the activator has proven the unit gone
+ // (CmdSpec.AfterSettled), however late after a Stop.
+ settled chan struct{}
+ settledOnce sync.Once
ws *websocket.Conn
sendMu sync.Mutex
// The reader's outputs. activity is a keystroke (idle reset); in is
// the terminal's input; readDone closes when the reader stops, with
- // peerEnd set first if the console sent an End. over closes when the
- // session is ending, so a reader waiting on in gives up.
+ // peerEnd set first if the console sent an End. over closes on every
+ // exit of run once the reader runs, so a reader waiting on in gives up.
activity chan struct{}
in chan sessionInput
readDone chan struct{}
@@ -332,6 +397,8 @@ func (s *sessionRun) run(old *sessionRun) {
w := s.w
defer close(s.done)
defer w.forget(s)
+ defer s.cancel(nil)
+ defer s.unwatch()
if old != nil {
old.cancel(errSessionReplaced)
<-old.done
@@ -352,11 +419,17 @@ func (s *sessionRun) run(old *sessionRun) {
return
}
go s.read()
- end, started := interactive.End{Reason: interactive.EndReplaced}, false
+ if w.afterOpen != nil {
+ w.afterOpen(s)
+ }
+ end, started := s.peerGone(), false
if s.ctx.Err() == nil {
- // Not replaced while it waited for the Open.
+ // Not replaced, nor shut down, while it waited for the Open.
end, started = s.serve(open)
}
+ // From here nothing takes the reader's frames: one waiting on a full
+ // queue gives up, on every path.
+ close(s.over)
end.Box = w.box
if end.Ended.IsZero() {
end.Ended = w.now().UTC()
@@ -398,6 +471,9 @@ func (s *sessionRun) dial() (*websocket.Conn, error) {
// session's Open, normalized and checked.
func (s *sessionRun) receiveOpen() (interactive.Open, error) {
_ = s.ws.SetReadDeadline(time.Now().Add(s.w.openWait))
+ // A replacement or the shutdown ends the wait at once.
+ stop := context.AfterFunc(s.ctx, func() { _ = s.ws.SetReadDeadline(time.Unix(1, 0)) })
+ defer stop()
kind, payload, err := interactive.Receive(s.ws)
if err != nil {
return interactive.Open{}, err
@@ -503,8 +579,11 @@ func (s *sessionRun) keepalive(stop <-chan struct{}, done chan<- struct{}) {
// console's own End if it sent one, else lost. A newer session's
// replacement comes first.
func (s *sessionRun) peerGone() interactive.End {
- if errors.Is(context.Cause(s.ctx), errSessionReplaced) {
+ switch cause := context.Cause(s.ctx); {
+ case errors.Is(cause, errSessionReplaced):
return interactive.End{Reason: interactive.EndReplaced}
+ case errors.Is(cause, errWorkerShutdown):
+ return interactive.End{Reason: interactive.EndInterrupted, Detail: activator.StopShutdown}
}
select {
case <-s.readDone:
@@ -548,7 +627,6 @@ func launchEnd(err error) interactive.End {
// follows the last output.
func (s *sessionRun) serve(open interactive.Open) (interactive.End, bool) {
w := s.w
- defer close(s.over)
stopAlive, aliveDone := make(chan struct{}), make(chan struct{})
go s.keepalive(stopAlive, aliveDone)
defer func() {
@@ -590,9 +668,21 @@ func (s *sessionRun) serve(open interactive.Open) (interactive.End, bool) {
case <-launched:
}
}()
+ // The launch is bound to the lifetime the grant authorized (fix round
+ // 1, P1): the row is read again (the agent's own registry), and the
+ // activator refuses an awake entry of any other lifetime.
+ rt, ok := w.owned(s.rec)
+ if !ok || rt.Incarnation != s.rec.Incarnation {
+ close(launched)
+ lcancel()
+ log.Printf("agent: interactive: %s %s: the row is not the authorized lifetime %d any more", s.rec.Host, s.g.ID, s.rec.Incarnation)
+ return interactive.End{Reason: interactive.EndInterrupted, Detail: runs.InterruptedStartFailed}, false
+ }
spec := activator.CmdSpec{RunID: s.g.ID, Process: open.Process, Args: open.Argv,
- TTY: &activator.TTYSpec{Term: open.Term, Cols: uint16(open.Cols), Rows: uint16(open.Rows)}}
- handle, err := w.launch.RunCmd(lctx, s.rt, spec)
+ TTY: &activator.TTYSpec{Term: open.Term, Cols: uint16(open.Cols), Rows: uint16(open.Rows)},
+ Incarnation: s.rec.Incarnation,
+ AfterSettled: func() { s.settledOnce.Do(func() { close(s.settled) }) }}
+ handle, err := w.launch.RunCmd(lctx, rt, spec)
close(launched)
ended := lctx.Err() != nil
lcancel()
@@ -690,30 +780,66 @@ func (s *sessionRun) bridge(handle activator.CmdHandle) interactive.End {
}
}()
- sctx, cancel := context.WithTimeout(context.Background(), runStopBound)
- defer cancel()
- stopped := false
- stop := func() {
- if stopped {
+ // proven: the activator has proven the unit gone: a Stop answered nil,
+ // or the settle that proved it called AfterSettled (s.settled).
+ proven := false
+ // stopOnce asks for one stop, with its own budget from now (fix round
+ // 1, P2): a session may run for hours before it stops.
+ stopOnce := func() {
+ sctx, cancel := context.WithTimeout(context.Background(), w.stopBound)
+ defer cancel()
+ if err := handle.Stop(sctx); err != nil {
+ log.Printf("agent: interactive: %s %s: stop, not proven yet: %v", s.rec.Host, s.g.ID, err)
return
}
- stopped = true
- if err := handle.Stop(sctx); err != nil {
- log.Printf("agent: interactive: %s %s: stop: %v", s.rec.Host, s.g.ID, err)
+ proven = true
+ }
+ stopAsked := false
+ stop := func() {
+ if !stopAsked {
+ stopAsked = true
+ stopOnce()
}
}
- // finish stops the unit, closes the terminal and joins the pump and the
- // feed, so no frame follows the End and the handoff is settled.
- finish := func() {
+ // settle waits for the proof: a Stop that ended without it keeps the
+ // session's settlement pending, as a run's is, and the stop is asked
+ // again each bound. Only the worker's shutdown gives up on it, false.
+ settle := func() bool {
stop()
+ for !proven {
+ retry := time.NewTimer(w.stopBound)
+ select {
+ case <-s.settled:
+ proven = true
+ case <-w.life.Done():
+ retry.Stop()
+ return false
+ case <-retry.C:
+ stopOnce()
+ }
+ retry.Stop()
+ }
+ return true
+ }
+ // finish stops the unit and waits for the proof, then closes the master
+ // and joins the pump and the feed, so no frame follows the End. The
+ // handoff listener is the settle's to close (Task 8), never the
+ // worker's: Hangup closes the master alone.
+ finish := func() bool {
+ ok := settle()
if term != nil {
_ = term.Hangup()
}
close(stopFeed)
<-pumpDone
<-feedDone
+ return ok
}
+ // Release, after the proof (or the shutdown) and the End's verdict.
defer handle.Release()
+ // unsettled is the End of a session whose unit was not proven gone
+ // before the agent shut down: the activator's own shutdown settles it.
+ unsettled := interactive.End{Reason: interactive.EndInterrupted, Detail: activator.StopShutdown}
idle := time.NewTimer(w.idle)
defer idle.Stop()
@@ -779,9 +905,13 @@ wait:
case <-statuses:
case <-grace.C:
stop()
+ case <-w.life.Done():
+ // Shutting down: no grace.
}
grace.Stop()
- finish()
+ if !finish() {
+ return unsettled
+ }
return *hangup
}
@@ -795,9 +925,11 @@ wait:
}
drain.Stop()
}
- finish()
- // The settle has joined the handoff (Stop closes it), so whether the
- // unit ever took its terminal is final.
+ if !finish() {
+ return unsettled
+ }
+ // The settle is proven and has joined the handoff, so whether the unit
+ // ever took its terminal is final.
reason, askedAt := handle.Interrupted()
if reason != "" && done != nil && done.st.State == instancectl.CmdDone && askedAt.After(done.at) {
// Asked for after the command had finished: the exit stands.
@@ -815,7 +947,8 @@ wait:
}
exit, signal := exitOf(done.st)
if signal != "" {
- // A command ended by a signal exits as a shell reports it.
+ // A command ended by a signal exits 128+n, as carlos run reports a
+ // run's (run.go, runExit).
var n int
fmt.Sscanf(signal, "%d", &n)
exit = 128 + n
@@ -920,6 +1053,14 @@ func withInteractiveHook(cfg provision.ReconcileConfig) provision.ReconcileConfi
return cfg
}
+// shutdownInteractive ends and joins the armed worker's sessions, within
+// ctx (the agent's shutdown).
+func shutdownInteractive(ctx context.Context) {
+ if w := armedInteractive.Load(); w != nil {
+ w.shutdown(ctx)
+ }
+}
+
// runInteractivePass acts on what the last reconcile pass noted.
func runInteractivePass(ctx context.Context) {
if w := armedInteractive.Load(); w != nil {
diff --git a/internal/host/interactive_test.go b/internal/host/interactive_test.go
index ee4c845b0..c268905aa 100644
--- a/internal/host/interactive_test.go
+++ b/internal/host/interactive_test.go
@@ -41,6 +41,7 @@ import (
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/runs"
+ "github.com/carlosframework/platform/internal/s3fake"
"github.com/carlosframework/platform/internal/seeds"
)
@@ -147,7 +148,9 @@ func (s *ixStore) reset() {
}
// ixTerm is a session's terminal: out is what the tenant's command prints
-// (the test writes it), in is what reaches the command.
+// (the test writes it), in is what reaches the command. It models the
+// activator's ptyTerminal: Hangup closes the master alone, and the handoff
+// listener stays until the settle (settleClose, the handle's proven Stop).
type ixTerm struct {
outR *io.PipeReader
outW *io.PipeWriter
@@ -156,11 +159,27 @@ type ixTerm struct {
resizes [][2]uint16
hangups int
closed bool
+ // listening is the handoff listener, open until the settle.
+ listening bool
}
func newIxTerm() *ixTerm {
r, w := io.Pipe()
- return &ixTerm{outR: r, outW: w}
+ return &ixTerm{outR: r, outW: w, listening: true}
+}
+
+// settleClose is the settle's close: the listener, then the master.
+func (t *ixTerm) settleClose() {
+ t.mu.Lock()
+ t.listening = false
+ t.mu.Unlock()
+ t.close()
+}
+
+func (t *ixTerm) listenerOpen() bool {
+ t.mu.Lock()
+ defer t.mu.Unlock()
+ return t.listening
}
func (t *ixTerm) Read(p []byte) (int, error) { return t.outR.Read(p) }
@@ -214,6 +233,13 @@ type ixHandle struct {
askedAt time.Time
stops []time.Time
releases int
+ // afterSettled is the session's CmdSpec.AfterSettled. slowStop makes a
+ // Stop wait for its context and return without the proof; prove then
+ // settles the unit. budgets are each Stop's context budget at the call.
+ afterSettled func()
+ slowStop bool
+ budgets []time.Duration
+ listenAtStop []bool
// events is the order of Stop and Release against the session's other
// calls, for the tests that check it.
events []string
@@ -257,16 +283,42 @@ func (h *ixHandle) interrupt(reason string, at time.Time) {
h.reason, h.askedAt = reason, at
h.mu.Unlock()
}
-func (h *ixHandle) Stop(context.Context) error {
+func (h *ixHandle) Stop(ctx context.Context) error {
h.mu.Lock()
h.stops = append(h.stops, time.Now())
h.events = append(h.events, "stop")
+ if dl, ok := ctx.Deadline(); ok {
+ h.budgets = append(h.budgets, time.Until(dl))
+ }
+ if t, ok := h.term.(*ixTerm); ok {
+ h.listenAtStop = append(h.listenAtStop, t.listenerOpen())
+ }
+ slow := h.slowStop
h.mu.Unlock()
+ if slow {
+ // The settle outlives this caller's budget: no proof yet.
+ <-ctx.Done()
+ return ctx.Err()
+ }
+ h.prove()
+ return nil
+}
+
+// prove is the settle's proof: the terminal closed, the unit done, then
+// AfterSettled, as the activator calls it.
+func (h *ixHandle) prove() {
if t, ok := h.term.(*ixTerm); ok {
- t.close()
+ t.settleClose()
}
h.finish(instancectl.CmdStatus{State: instancectl.CmdDone, Code: "killed", Status: "15"})
- return nil
+ h.mu.Lock()
+ h.events = append(h.events, "proven")
+ cb := h.afterSettled
+ h.afterSettled = nil
+ h.mu.Unlock()
+ if cb != nil {
+ cb()
+ }
}
func (h *ixHandle) Release() {
h.mu.Lock()
@@ -307,6 +359,9 @@ func (l *ixLaunch) RunCmd(ctx context.Context, rt registry.Route, spec activator
if err != nil {
return nil, err
}
+ h.mu.Lock()
+ h.afterSettled = spec.AfterSettled
+ h.mu.Unlock()
return h, nil
}
@@ -325,9 +380,11 @@ type ixDoor struct {
mu sync.Mutex
headers []http.Header
refuse int // when set, the door answers this status before the upgrade
- open interactive.Open
- script func(ws *websocket.Conn)
- frames chan ixFrame
+ // hold, when set, keeps the Open back until it closes.
+ hold chan struct{}
+ open interactive.Open
+ script func(ws *websocket.Conn)
+ frames chan ixFrame
}
type ixFrame struct {
@@ -339,6 +396,12 @@ func newIxDoor(t *testing.T, open interactive.Open) *ixDoor {
t.Helper()
d := &ixDoor{t: t, open: open, frames: make(chan ixFrame, 256)}
srv := interactive.NewServer(func(ws *websocket.Conn) {
+ d.mu.Lock()
+ hold := d.hold
+ d.mu.Unlock()
+ if hold != nil {
+ <-hold
+ }
if err := interactive.SendJSON(ws, interactive.KindOpen, d.open); err != nil {
return
}
@@ -774,6 +837,7 @@ func TestInteractiveWorkerReportsAFailedStart(t *testing.T) {
}{
{errors.New("control: connection refused"), runs.InterruptedStartFailed},
{&activator.CmdStoppedError{Reason: activator.StopRestart}, activator.StopRestart},
+ {fmt.Errorf("activator: %w", activator.ErrCmdIncarnation), runs.InterruptedStartFailed},
} {
wd := newIxWorld(t)
wd.launch.err = c.err
@@ -1100,6 +1164,12 @@ func TestInteractiveWorkerHangsUpThenStops(t *testing.T) {
if term.hungUp() == 0 || len(stops) == 0 || releases != 1 {
t.Fatalf("hangups %d, stops %d, releases %d", term.hungUp(), len(stops), releases)
}
+ h.mu.Lock()
+ listened := h.listenAtStop
+ h.mu.Unlock()
+ if len(listened) == 0 || !listened[0] {
+ t.Fatal("the handoff listener was closed before the stop: the tty unit's ExecStopPost could not open its stdin")
+ }
after := stops[0].Sub(time.Unix(0, hungAt.Load()))
if !exits && after < 150*time.Millisecond {
t.Fatalf("stopped %s after the hangup, before the grace", after)
@@ -1228,8 +1298,8 @@ func TestInteractiveWorkerReportsAStartThatNeverTookItsTerminal(t *testing.T) {
h.mu.Lock()
order := strings.Join(h.events, ",")
h.mu.Unlock()
- if !strings.HasPrefix(order, "stop,startFailed") || !strings.HasSuffix(order, "release") {
- t.Fatalf("order %s: the start's verdict must follow the stop", order)
+ if !strings.HasPrefix(order, "stop,proven,startFailed") || !strings.HasSuffix(order, "release") {
+ t.Fatalf("order %s: the start's verdict must follow the stop's proof", order)
}
}
@@ -1254,42 +1324,6 @@ func TestInteractiveWorkerWritesNothingToTheBucket(t *testing.T) {
}
}
-// The request budget (plan Task 10, "Owning box"): one grant GET and one
-// config.json GET per session, nothing else; an idle pass and a pass on a
-// box that does not own the row make none.
-func TestInteractiveWorkerRequestBudget(t *testing.T) {
- wd := newIxWorld(t)
- wd.w.pass(context.Background())
- if gets, writes, lists := wd.store.counts(); gets+writes+lists != 0 {
- t.Fatalf("an idle pass: %d GETs, %d writes, %d lists", gets, writes, lists)
- }
- rec, _ := wd.session()
- wd.door.wantStatus(t, interactive.StateStarting)
- wd.door.wantStatus(t, interactive.StateStarted)
- wd.launch.handle.finish(instancectl.CmdStatus{State: instancectl.CmdDone, Code: "exited", Status: "0"})
- wd.launch.handle.term.(*ixTerm).outW.Close()
- wd.door.wantEnd(t)
- wd.wait()
- gets, writes, lists := wd.store.counts()
- want := []string{interactive.GrantKey(ixAcct, "shop", rec.Interactive.ID), appconfig.Key(ixAcct, "shop")}
- if gets != 2 || writes != 0 || lists != 0 || fmt.Sprint(wd.store.keys) != fmt.Sprint(want) {
- t.Fatalf("one session: %d GETs %q, %d writes, %d lists; want %q", gets, wd.store.keys, writes, lists, want)
- }
- // The same record again (a later reconcile pass) reads nothing.
- wd.store.reset()
- wd.w.note(rec)
- wd.w.pass(context.Background())
- if gets, _, _ := wd.store.counts(); gets != 0 {
- t.Fatalf("a seen session read %d objects", gets)
- }
- other := newIxWorld(t)
- other.w.routes = noRoutes
- other.session()
- if gets, writes, lists := other.store.counts(); gets+writes+lists != 0 {
- t.Fatalf("a box that does not own the row: %d GETs, %d writes, %d lists", gets, writes, lists)
- }
-}
-
// A newer session for the instance ends the one this worker still runs
// first, as replaced, and then starts.
func TestInteractiveWorkerReplacesAnOlderSession(t *testing.T) {
@@ -1684,7 +1718,10 @@ func TestARestartedWorkerCannotRelaunchAnEndedSession(t *testing.T) {
// worker, hooks its note into reconcile or runs its pass does the same for
// the session worker.
func TestInteractiveWorkerIsWiredBesideTheRunsWorker(t *testing.T) {
- pairs := map[string]string{"armRunsPass": "armInteractivePass", "withRunsHook": "withInteractiveHook", "runRunsPass": "runInteractivePass"}
+ // The function that arms the session worker also joins it at shutdown
+ // (fix round 1, P2).
+ pairs := map[string]string{"armRunsPass": "armInteractivePass", "withRunsHook": "withInteractiveHook", "runRunsPass": "runInteractivePass",
+ "armInteractivePass": "shutdownInteractive"}
found := map[string]int{}
for _, name := range []string{"agent.go", "changeindex.go"} {
f, err := parser.ParseFile(token.NewFileSet(), name, nil, 0)
@@ -1721,3 +1758,339 @@ func TestInteractiveWorkerIsWiredBesideTheRunsWorker(t *testing.T) {
}
}
}
+
+// The launch is bound to the lifetime the grant authorized (fix round 1,
+// P1): a row that is another lifetime by the launch starts nothing and ends
+// the session as a start failure, within the same two GETs; the launch
+// names the authorized lifetime to the activator, which refuses an awake
+// entry of any other (TestRunCmdBindsASessionToItsIncarnation).
+func TestInteractiveWorkerBindsTheLaunchToTheAuthorizedIncarnation(t *testing.T) {
+ t.Run("replaced between pickup and launch", func(t *testing.T) {
+ wd := newIxWorld(t)
+ var reads atomic.Int32
+ wd.w.routes = func(h string) (*registry.Route, error) {
+ rt := ixRoute(ixHost)
+ rt.Incarnation = 1
+ if reads.Add(1) > 1 {
+ rt.Incarnation = 2 // deleted and created again since the pickup
+ }
+ return rt, nil
+ }
+ rec := ixRecord(ixID(t), time.Now().Add(time.Minute))
+ rec.Incarnation = 1
+ wd.grant(rec, nil, nil)
+ wd.store.reset()
+ wd.w.note(rec)
+ wd.w.pass(context.Background())
+ wd.door.wantStatus(t, interactive.StateStarting)
+ e := wd.door.wantEnd(t)
+ if e.Reason != interactive.EndInterrupted || e.Detail != runs.InterruptedStartFailed {
+ t.Fatalf("end %+v, want a start failure", e)
+ }
+ wd.wait()
+ if n := len(wd.launch.calls()); n != 0 {
+ t.Fatalf("%d launches against another lifetime", n)
+ }
+ if gets, writes, lists := wd.store.counts(); gets != 2 || writes != 0 || lists != 0 {
+ t.Fatalf("requests: %d GETs, %d writes, %d lists; want the same two GETs", gets, writes, lists)
+ }
+ })
+ t.Run("the activator is told the lifetime", func(t *testing.T) {
+ wd := newIxWorld(t)
+ rt := ixRoute(ixHost)
+ rt.Incarnation = 4
+ wd.w.routes = ixRoutes(rt)
+ rec := ixRecord(ixID(t), time.Now().Add(time.Minute))
+ rec.Incarnation = 4
+ wd.grant(rec, nil, nil)
+ wd.w.note(rec)
+ wd.w.pass(context.Background())
+ wd.door.wantStatus(t, interactive.StateStarting)
+ wd.door.wantStatus(t, interactive.StateStarted)
+ if calls := wd.launch.calls(); len(calls) != 1 || calls[0].Incarnation != 4 || wd.launch.routes[0].Incarnation != 4 {
+ t.Fatalf("launch %+v on %+v, want lifetime 4", calls, wd.launch.routes)
+ }
+ wd.launch.handle.finish(instancectl.CmdStatus{State: instancectl.CmdDone, Code: "exited", Status: "0"})
+ wd.launch.handle.term.(*ixTerm).outW.Close()
+ wd.door.wantEnd(t)
+ wd.wait()
+ })
+}
+
+// The End, the start-failure verdict and Release wait for the activator's
+// proof that the unit is gone (fix round 1, P2). A Stop that runs out of its
+// budget without the proof keeps the settlement pending, and each Stop's
+// budget starts when it is asked for, not when the session started.
+func TestInteractiveWorkerEndWaitsForTheSettlement(t *testing.T) {
+ wd := newIxWorld(t)
+ wd.w.stopBound = 120 * time.Millisecond
+ wd.w.drain = 20 * time.Millisecond
+ h := wd.launch.handle
+ h.slowStop = true
+ var verdicts atomic.Int32
+ wd.w.startFailed = func(activator.Terminal, instancectl.CmdStatus) bool { verdicts.Add(1); return false }
+ wd.session()
+ wd.door.wantStatus(t, interactive.StateStarting)
+ wd.door.wantStatus(t, interactive.StateStarted)
+ time.Sleep(300 * time.Millisecond) // longer than one stop budget
+ h.finish(instancectl.CmdStatus{State: instancectl.CmdDone, Code: "exited", Status: "0"})
+ waitFor(t, "two stops without proof", func() bool { stops, _ := h.stopped(); return len(stops) >= 2 })
+ select {
+ case f := <-wd.door.frames:
+ if f.kind != interactive.KindAlive {
+ t.Fatalf("frame %q before the proof", f.kind)
+ }
+ default:
+ }
+ if _, releases := h.stopped(); releases != 0 || verdicts.Load() != 0 {
+ t.Fatalf("before the proof: %d releases, %d verdicts", releases, verdicts.Load())
+ }
+ h.mu.Lock()
+ budgets := append([]time.Duration(nil), h.budgets...)
+ h.slowStop = false
+ h.mu.Unlock()
+ for _, b := range budgets {
+ if b < 100*time.Millisecond {
+ t.Fatalf("a stop was asked with %s of budget left: the budget must start at the stop", b)
+ }
+ }
+ h.prove()
+ if e := wd.door.wantEnd(t); e.Reason != interactive.EndExited {
+ t.Fatalf("end %+v", e)
+ }
+ wd.wait()
+ if _, releases := h.stopped(); releases != 1 || verdicts.Load() != 1 {
+ t.Fatalf("after the proof: %d releases, %d verdicts", releases, verdicts.Load())
+ }
+}
+
+// The worker's shutdown ends and joins every session, whatever its stage,
+// and starts none after it (fix round 1, P2).
+func TestInteractiveWorkerShutdownJoinsEverySession(t *testing.T) {
+ shutdown := func(t *testing.T, wd *ixWorld) {
+ t.Helper()
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ start := time.Now()
+ wd.w.shutdown(ctx)
+ if took := time.Since(start); took > 3*time.Second {
+ t.Fatalf("shutdown took %s", took)
+ }
+ wd.w.mu.Lock()
+ n := len(wd.w.active)
+ wd.w.mu.Unlock()
+ if n != 0 {
+ t.Fatalf("%d sessions still active after the shutdown", n)
+ }
+ }
+ t.Run("an Open pending", func(t *testing.T) {
+ wd := newIxWorld(t)
+ hold := make(chan struct{})
+ defer close(hold)
+ wd.door.hold = hold
+ wd.session()
+ waitFor(t, "the dial", func() bool { return len(wd.door.dials()) == 1 })
+ shutdown(t, wd)
+ if len(wd.launch.calls()) != 0 {
+ t.Fatal("a session pending its Open launched")
+ }
+ })
+ t.Run("starting", func(t *testing.T) {
+ wd := newIxWorld(t)
+ wd.launch.block = true
+ wd.session()
+ wd.door.wantStatus(t, interactive.StateStarting)
+ waitFor(t, "the launch", func() bool { return len(wd.launch.calls()) == 1 })
+ shutdown(t, wd)
+ if e := wd.door.wantEnd(t); e.Reason != interactive.EndInterrupted || e.Detail != activator.StopShutdown {
+ t.Fatalf("end %+v", e)
+ }
+ })
+ t.Run("attached", func(t *testing.T) {
+ wd := newIxWorld(t)
+ wd.session()
+ wd.door.wantStatus(t, interactive.StateStarting)
+ wd.door.wantStatus(t, interactive.StateStarted)
+ shutdown(t, wd)
+ if e := wd.door.wantEnd(t); e.Reason != interactive.EndInterrupted || e.Detail != activator.StopShutdown {
+ t.Fatalf("end %+v", e)
+ }
+ if stops, releases := wd.launch.handle.stopped(); len(stops) == 0 || releases != 1 {
+ t.Fatalf("%d stops, %d releases", len(stops), releases)
+ }
+ // None starts after it, and nothing is read for it.
+ wd.session()
+ if gets, _, _ := wd.store.counts(); wd.dialed.Load() != 1 || gets != 0 {
+ t.Fatalf("after the shutdown: %d dials, %d GETs; want no new dial and no read", wd.dialed.Load(), gets)
+ }
+ })
+}
+
+// A replacement while the reader waits on a full queue of keystrokes (the
+// Open arrived, then the session was replaced before it served) does not
+// strand the reader: the old session ends and the new one starts (fix round
+// 1, P2).
+func TestInteractiveWorkerReaderGivesUpWhenReplacedDuringOpen(t *testing.T) {
+ wd := newIxWorld(t)
+ wd.w.grace = 20 * time.Millisecond
+ first := true
+ wd.door.script = func(ws *websocket.Conn) {
+ for range 3 * sessionInputQueue {
+ if interactive.Send(ws, interactive.KindData, []byte("x")) != nil {
+ return
+ }
+ }
+ wd.door.collect(ws)
+ }
+ rec2 := ixRecord(ixID(t), time.Now().Add(time.Minute))
+ wd.w.afterOpen = func(s *sessionRun) {
+ if !first {
+ return
+ }
+ first = false
+ waitFor(t, "the reader's queue to fill", func() bool { return len(s.in) == cap(s.in) })
+ wd.grant(rec2, nil, nil)
+ wd.w.note(rec2)
+ go wd.w.pass(context.Background())
+ waitFor(t, "the replacement", func() bool { return s.ctx.Err() != nil })
+ }
+ wd.session()
+ if e := wd.door.wantEnd(t); e.Reason != interactive.EndReplaced {
+ t.Fatalf("the old session's end %+v, want replaced", e)
+ }
+ waitFor(t, "the new session to start", func() bool { return len(wd.launch.calls()) == 1 })
+ if calls := wd.launch.calls(); calls[0].RunID != rec2.Interactive.ID {
+ t.Fatalf("launched %+v", calls[0])
+ }
+ wd.launch.handle.finish(instancectl.CmdStatus{State: instancectl.CmdDone, Code: "exited", Status: "0"})
+ wd.launch.handle.term.(*ixTerm).outW.Close()
+ wd.wait()
+}
+
+// PF-19: a session's reads carry the pass's lifetime judge.
+func TestInteractiveWorkerSessionReadsCarryTheJudge(t *testing.T) {
+ wd := newIxWorld(t)
+ judge := provision.NewLifetimeJudge()
+ wd.w.judge = judge
+ got := make(chan *provision.LifetimeJudge, 1)
+ wd.w.allowed = func(ctx context.Context, acct, app string) (bool, error) {
+ got <- provision.JudgeFrom(ctx)
+ return false, nil
+ }
+ rec := ixRecord(ixID(t), time.Now().Add(time.Minute))
+ wd.grant(rec, nil, nil)
+ ixRefusal(t, wd, rec, interactive.RefusedOff)
+ if j := <-got; j != judge {
+ t.Fatalf("the setting read's context carries judge %p, want the pass's %p", j, judge)
+ }
+}
+
+// A command ended by a signal is reported as carlos run reports a run's:
+// exit 128+n (run.go, runExit).
+func TestInteractiveWorkerReportsASignalAs128PlusN(t *testing.T) {
+ wd := newIxWorld(t)
+ rec, _ := wd.session()
+ wd.door.wantStatus(t, interactive.StateStarting)
+ wd.door.wantStatus(t, interactive.StateStarted)
+ wd.launch.handle.finish(instancectl.CmdStatus{State: instancectl.CmdDone, Code: "killed", Status: "9"})
+ wd.launch.handle.term.(*ixTerm).outW.Close()
+ if e := wd.door.wantEnd(t); e.Reason != interactive.EndExited || e.Exit != 137 {
+ t.Fatalf("end %+v, want exited 137", e)
+ }
+ wd.wait()
+ if msgs := wd.eventMsgs(); len(msgs) != 2 || !strings.HasPrefix(msgs[1], "interactive session "+rec.Interactive.ID+" ended with exit 137 after ") {
+ t.Fatalf("events %q", msgs)
+ }
+}
+
+// ixS3 is the requests the production deployment store made of a fake S3.
+type ixS3 struct {
+ mu sync.Mutex
+ reqs []string
+}
+
+func (c *ixS3) add(r *http.Request) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ kind := r.Method
+ if r.URL.Query().Has("list-type") || r.URL.Query().Has("delimiter") {
+ kind = "LIST"
+ }
+ c.reqs = append(c.reqs, kind+" "+r.URL.Path)
+}
+
+func (c *ixS3) take() []string {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ out := c.reqs
+ c.reqs = nil
+ return out
+}
+
+// The request budget at the wire (plan Task 10, "Owning box"): the worker
+// over the production deployment store (NewDeploymentS3Store) and a counting
+// fake S3. One session: two GETs, the grant then config.json. An idle pass,
+// the same record again, and a box that does not own the row: none. No
+// writes and no LISTs.
+func TestInteractiveWorkerRequestBudget(t *testing.T) {
+ dir := release.NewDirStore(t.TempDir())
+ count := &ixS3{}
+ fake := s3fake.New(dir)
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ count.add(r)
+ fake.ServeHTTP(w, r)
+ }))
+ t.Cleanup(srv.Close)
+ t.Setenv("CARLOS_S3_ENDPOINT", srv.URL)
+ t.Setenv("AWS_ACCESS_KEY_ID", "fixture")
+ t.Setenv("AWS_SECRET_ACCESS_KEY", "fixture")
+ t.Setenv("AWS_REGION", "us-east-1")
+ t.Setenv("AWS_EC2_METADATA_DISABLED", "true")
+ s3, err := release.NewDeploymentS3Store(context.Background(), "carlos-fixture")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ wd := newIxWorld(t)
+ if _, err := appconfig.SetInteractive(context.Background(), dir, ixAcct, "shop", true); err != nil {
+ t.Fatal(err)
+ }
+ wd.store = &ixStore{Store: dir} // where the test writes the grant
+ w := newInteractiveWorker(s3, ixRoutes(ixRoute(ixHost)), wd.launch, wd.pub, "box-a")
+ wd.w = w
+ count.take()
+
+ w.pass(context.Background())
+ if got := count.take(); len(got) != 0 {
+ t.Fatalf("an idle pass: %q", got)
+ }
+ rec := ixRecord(ixID(t), time.Now().Add(time.Minute))
+ wd.grant(rec, nil, nil)
+ count.take()
+ w.note(rec)
+ w.pass(context.Background())
+ wd.door.wantStatus(t, interactive.StateStarting)
+ wd.door.wantStatus(t, interactive.StateStarted)
+ wd.launch.handle.finish(instancectl.CmdStatus{State: instancectl.CmdDone, Code: "exited", Status: "0"})
+ wd.launch.handle.term.(*ixTerm).outW.Close()
+ wd.door.wantEnd(t)
+ wd.wait()
+ want := []string{"GET /carlos-fixture/" + interactive.GrantKey(ixAcct, "shop", rec.Interactive.ID), "GET /carlos-fixture/" + appconfig.Key(ixAcct, "shop")}
+ if got := count.take(); fmt.Sprint(got) != fmt.Sprint(want) {
+ t.Fatalf("one session: %q, want %q", got, want)
+ }
+ w.note(rec)
+ w.pass(context.Background())
+ if got := count.take(); len(got) != 0 {
+ t.Fatalf("a seen session: %q", got)
+ }
+ other := newInteractiveWorker(s3, noRoutes, wd.launch, wd.pub, "box-b")
+ rec2 := ixRecord(ixID(t), time.Now().Add(time.Minute))
+ wd.grant(rec2, nil, nil)
+ count.take()
+ other.note(rec2)
+ other.pass(context.Background())
+ if got := count.take(); len(got) != 0 {
+ t.Fatalf("a box that does not own the row: %q", got)
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 75c6e60b9..a0312b29e 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 75b5bf971620474d35c8cd06aab78f0c4edfc24d925729daa3567bcf369ca644
+plan14-root-reads-rootfs-apps-6.tsv 87f29ffd175e44b45b2de6a8f9623b9384dd36be3ef8a057bbcfd723c9118b5e
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 1e02a976a..b74590a1a 100644
--- a/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv
+++ b/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv
@@ -1,12 +1,12 @@
# 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.
# 25 body, 5 sites, 10 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.
-# 28 new dispositions: 1 reads re-frozen at their disposition with the claim, 27 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+# 29 new dispositions: 1 reads re-frozen at their disposition with the claim, 28 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
@legacy c41d9a1319e7f19435f88127ae64ec2739a24900da6942fe69e710eb6d47e36c 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 Task 9 (PF-3): the count is pendingLeaseStopsLocked(e), the sum of e.leaseStops over both one-shot roles (now a map per role, cmd and tty), so a session's lease stop of the tty unit keeps the stop pending, the replica and lease held, as a run's does; the same five read sites, no read added registry:Socket@4068,registry:Socket@4173,whole:Route@4018,whole:Route@4070,whole:Route@4175 9748565e756038b7da9a06daefeb758fae4705ecb8ce400a1d4ea3e5231a7271
@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 2401ee86a2ee7e9138b032f65973c8049d9452d18d2e0c04d21edeea4dcca3d6 internal/activator/activator.go Service.sweepOnce legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; registry remains legacy; PROPOSED-plans-2-box-limits: the sweep also narrows an entry's idle window to its account's plan idle through the SetIdleFor hook (never lengthens it; always-on workers and held probe entries are untouched; the hibernate, inflight and held-for-tick guards are unchanged).;rev3=census-ruling-plans-4c-box-throttle;basis=after the worker max_run branch, stops a non-worker entry past the plans continuous-awake ceiling (maxRunFor, passed the row), busy or not, never mid-command (plans 4c). One more whole-row read: the row handed to the hook, as idleFor already is. This bypasses the inflight and held-for-tick protections the idle stop keeps, on purpose: escalated by Astra and ACCEPTED by Paul (census owner), 2026-10-25.;rev3=census-ruling-plans-4d-lapse;basis=stops a live entry the turned-off hook names (never mid-command, never a move's active probe), stands down an exited worker it names instead of restarting it (Astra finding 4), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Four more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips.;rev3=census-ruling-remote-instance-metrics;basis=its two entries-map insertions go through putEntryLocked (which also notes the route's tenant in memory for the metrics sampler); no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more call at the top, a.retryOwedMarkers() (harelease.go), which starts at most one background lease.RetryPending pass over owed region HA release markers, off a.mu; the due query, idle, max-run and lapse logic are unchanged; the same 38 sites, no read added; merge of origin/main d7ae1d76: main's change is kept as main has it (census-ruling-remote-instance-metrics: its two entries-map insertions go through putEntryLocked); this branch's change is the same as above; read sites the same 38, offsets moved;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: a resident (Route.Resident) is never stopped for idleness or by the continuous-awake ceiling; the due-wake check is left on Hibernate (comment); stops less, not more;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: an entry whose host has a release record open (the in-memory a.releaseOps[e.host]) is not stopped by its plan's turn-off, by idleness or by the continuous-awake ceiling until the record goes; one more sweep pass, reapReleaseOpsLocked, retries an unproven release's stop (through finishPendingStops); the same 39 read sites, no read added; stops less, not more;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 9 (PF-18): the four checks that left an entry with a run attached alone (e.cmd == nil) now read holdsAttachedLocked(e), a run or a session attached, so a session holds the idle sleep, the plans awake ceiling, the plans turned-off stop and the turned-off worker's stand-down as a run does; in-memory under a.mu; only keeps an entry awake longer; no read added, read sites unchanged registry:Hibernate@10801,registry:Hibernate@14559,registry:Hibernate@23817,registry:Hibernate@5676,registry:Hibernate@7875,registry:Host@23886,registry:Host@23944,registry:Host@24411,registry:Host@24504,registry:Host@25239,registry:Host@25328,registry:Host@26392,registry:Host@26679,registry:Host@26735,registry:NextDue@25194,registry:Status@23833,whole:Route@10803,whole:Route@11662,whole:Route@14561,whole:Route@16494,whole:Route@18204,whole:Route@18394,whole:Route@18687,whole:Route@18859,whole:Route@19006,whole:Route@23217,whole:Route@23993,whole:Route@24908,whole:Route@25248,whole:Route@25255,whole:Route@26207,whole:Route@26508,whole:Route@26712,whole:Route@5487,whole:Route@5678,whole:Route@7708,whole:Route@7877,whole:Route@8070,whole:Route@8533 ddf9a21dc0ae724138b1b0963155d8f555f2ce6982f7e61b9dc05f2bdd80bbe6
@legacy 2a089187c24f754778cd73dad684598279a5a54535915e261158751a750ebe9d 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; Plan 6 Task 8: passes instancectl.RoleCmd and oneShotSinks{Stdout, Stderr} (the same two release writers) to startRootfsCmd, which now takes the role; its /cmd request and launch.cmd.json stay byte-identical (TestStartReleaseIsUnchanged); no read added registry:Host@182,whole:Route@247 980b99f9faa5e8c182f89a821118175a750de42ebbe1947884e29e4901611d95
-@legacy cc1eabf2c1d89a0a96b8bfcfaa1f76b2b0beb39474d5e53fe526de11733da8fa 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; fix round 2: comment only: AfterSettled is called once, after the proof, never while a lock is held, in the settle's goroutine without the stop waiting for it, and must not call Stop or Shutdown; Plan 6 Task 8: declaration only: gains Process (a declared process name, "" or console; StartCmd refuses it except for a session on a rootfs row) and TTY (*TTYSpec: Term, Cols, Rows; set, the command is a session in the tty unit), fields the box sets; reads nothing file:Prepare@1305 f71a97113e7d5583d7b38bdf4883b1bb379ad7111a2550be0bc4e7bcbcc2fac6
+@legacy d20e3fff7ffc3885ab6f68a92e9b535620955717e2f5c77ce1ede028deb2ccaa 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; fix round 2: comment only: AfterSettled is called once, after the proof, never while a lock is held, in the settle's goroutine without the stop waiting for it, and must not call Stop or Shutdown; Plan 6 Task 8: declaration only: gains Process (a declared process name, "" or console; StartCmd refuses it except for a session on a rootfs row) and TTY (*TTYSpec: Term, Cols, Rows; set, the command is a session in the tty unit), fields the box sets; reads nothing Task 12 fix round 1: declaration only: gains Incarnation (uint64), the session's authorized lifetime, which the box sets from the instance record and RunCmd compares with the entry's row; reads nothing file:Prepare@1822 5fef13425a1ab96487b3de980e66761e920f6e0342470f1f18920e3f944143a3
@legacy 81be2be248ab3838d49b6a9502dfcbc905bc97da48487aba00fe094d53077c83 internal/activator/prepare.go ExecBackend.prepareKeyedAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling zddr4, with no further change from this branch beyond carrying main's new early return into the six-value signature. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): body of the frozen prepareAt, which is now its wrapper; it also returns the instance key's layer and reads no env for the cmd role; same reads, same nested launch paths;rev3=census-ruling-wake-latency-2;basis=takes an optional timer and marks its steps with time.Now() (dirs, admin token, instance key, env, control socket, key gate, logs); no read added or moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, run and seed roles only, under a 30 s context (haSecretsBudget): the token producer is ensureAdminTokenFor(hctx, rt, p) (on this nested path the same beneath producer, EnsureAdminTokenBeneath's, plus the HA mint decision inside it); ensureInstanceKeyFor now gets hctx instead of context.Background(), so the key's bucket read is bounded by 30 s as well as configReadTimeout; the env is launchEnvLayer(hctx, rt) (instanceEnvLayer for a non-HA host; for an HA host one capture, published and acknowledged); a test seam (haLaunchHooks.afterGate, nil in production) is called before the producers. The separate haMintGate and haSecretsReady calls are gone (final fix F2). Sites against main: -registry:Host (the rt.Host+".env" argument EnsureAdminTokenBeneath took) and +whole:Route (rt to launchEnvLayer); the cmd role and a non-HA host are unchanged;rev3=census-ruling-rootfs-fleet-followups;basis=names the process for the role log listener: release.ProcessWeb when rt.Rootfs() and the role is run, else none, passed to logEmitter; reads rt.Runtime through Rootfs(); no file, path or env read added or moved;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8: the cmd role three exceptions (no env read, the replica gate left to StartCmd, no app-log listener) now cover every one-shot role, instancectl.OneShot(role): cmd and tty; before, the tty role fell to the sidecar env-file read and an app-log listener on its handoff socket path; no read added, one removed for tty file:ReadDir@2965,registry:Host@1783,registry:Host@1995,registry:Host@5886,registry:Host@6084,registry:Host@612,whole:Route@1674,whole:Route@1885,whole:Route@2116,whole:Route@320,whole:Route@4678,whole:Route@5227,whole:Route@5920 0fce84024e1c33a8f8db76231106e7b962627f294dd6429038b479d25274a5b2
@legacy 2d9c727dee13d2655dcd898f0f5aecaa20902fa217ea6cf20a3ecce21e657388 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
@legacy a55981c78ecf7e6cc533e2ca1f8732773fc68d8382a17bc34d7c7fc81297aadb internal/activator/rootfsrelease.go Service.releaseAdmitLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1 [pf R1.10]: new; the owner's half of a release's admission under a.mu: refuses while a run holds the cmd unit, and for an awake owner mirrors Swap's exclusions (worker or non-instance kind, a layout other than flat or nested through the existing swapLayout, members, a raised parent, a resize, a cmd start in flight); in-memory only; refusals only;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 9 (PF-17): the busy check is holdBusyLocked(e, RoleCmd) where it was cmdBusyLocked(e): only established cmd-unit holds and cmd-unit lease stops refuse a release command, never a started session, whose tty unit is its own; cmdStartInFlightLocked now also counts a session's start in flight (merge ruling M2), so a release is refused during either role's start window, short and bounded, as swap admission is (fix round 2 ruling: a refusal at admission is not executed and takes the ordinary retry); no read added, read sites unchanged registry:Kind@309,whole:Route@311,whole:Route@390 d1f6ba85b88b217e9d82caa7f033f20f61429bc319f48099e60e3aea37234916
@@ -31,17 +31,18 @@
@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 df3f3b61ff8b8728750f677f5f67b0b499f761681593619c55713a7603ae1d82 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 Task 9 (PF-3): covers every run and session hold that may be running (holdsLocked: e.cmd, e.tty and the released holds of either role); each func is counted under its hold's role (addLeaseStop(h.role)) and stops and kills that role's unit only (stopOneShotAtLease(rt, h, h.role, kill)), so a session's lease kill names the tty unit and a run's the cmd unit, never the other's; while a role's count is up no new command of that role starts (holdBusyLocked); no read added whole:Route@358 3be2f4759579fea82f4afe35babbd400ab33a18a87340706f2b3f525a067d21d
+@legacy 6188930a4fe995d9f5c3f8756e5488df29a414c55c94353e478fec72104ca1bb internal/activator/cmd.go sessionIncarnationLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12 fix round 1, new: RunCmd's session lifetime check, in memory under a.mu: a session (spec.TTY) whose spec.Incarnation is 0 or differs from the entry's row lifetime (e.route.Incarnation) is refused; a run never is; reads only those two fields, nothing from disk or a path registry:Incarnation@117,whole:Route@119 6694885322e347b0ece1510427ef6e22c040dc08243380763d223d9e1cdca53d
@legacy abb459549436cbe93fde533f5b1ab964758f1f94b1ea165bf95201e6df775026 internal/activator/cmdunit.go ExecBackend.ttyVars legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8, new: a session environment: cmdVars over the generation launch environment without CARLOS_RUN_ID and CARLOS_RUN_DIR, with TERM and CARLOS_SESSION_ID set over the file; map composition only, the route host through cmdVars whole:Route@156 127be6d996c0492af254a0a6b6fa9f292c8b5e8b0656ac02319aa61f77186a00
@legacy 6ac5faaf8631164738d53b1d4af6ebd609543f8d454457edb4eb5d3b33564858 internal/activator/pty_linux.go openPTY legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8, new: the agent (user carlos, never root) opens the fixed path /dev/ptmx O_RDWR|O_NOCTTY|O_CLOEXEC, unlocks it (TIOCSPTLCK), takes the slave from the master with TIOCGPTPEER (never opening /dev/pts/N by path, so no path a tenant can name is opened), sets TIOCEXCL on the slave and the window size on the master; the slave goes only to a SO_PEERCRED uid 0 peer of the agent owner-only handoff socket (ttyPeerOK), the tty unit stdin file:Open@143,file:Syscall@517 42d48a34ebb89715fd152471c827408c0439009525d37c5dd7c68a9ca035a1d6
@legacy 0842489ea1caf0137eec6eb816259e02fb7638e90aaac2453713a4180629cbcf internal/activator/pty_linux.go ptyTerminal.Read legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8, new: reads the session pty master the agent itself opened (openPTY), as the agent (user carlos); the bytes go to the session caller only file:Read@22,file:Read@60 55a2d9ae0563470e24cd622805eb71c6463b6b001d69ae495500d789b68ea23d
@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 9d3d5ea17a224dd06eaa558ec8862ef403fe00dbfb483c40f52ff27864872eb9 internal/activator/rootfsenv.go ExecBackend.rootfsTTYVars legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8, new: a rootfs session environment: ttyVars over the generation launch environment, then rootfsVars with the row canonical socket and dbPath set after the file environment, as rootfsCmdVars does; map composition only registry:Socket@202,whole:Route@163 6f561ab8a1e4a8063afeb0be152cee2f5fbb30d78e3008a2b515bc4aeba9735b
-@legacy 3daeabb64386c5c369bf464104882f1c19a66112e29fcd90c29997bbebdc66e0 internal/host/interactive.go interactiveWorker.consider legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: the box's session worker decides one reconcile-noted record (InteractiveSeen): its row from the agent's own registry (owned), for an HA row (rt.HA) only when the activator holds the host awake (HoldsAwake), then the signed grant GET from the deployment store at interactive.GrantKey of the record's own account, app and a session id that passed interactive.ValidID, verified under CARLOS_RELEASE_PUBKEY (VerifyGrant) and matched to the record; it runs as the agent (user carlos), writes nothing, and nothing it reads reaches root registry:HA@181,whole:Route@1751,whole:Route@1755 37cc833b3ca261c129eb1c0e1f966140e57550936a1ae50b42c31a0b01803e8c
+@legacy cf5c950a495a9934d7036ef3bef524cc46a0704990ac8181f91735f4c6d7a1fc internal/host/interactive.go interactiveWorker.consider legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: the box's session worker decides one reconcile-noted record (InteractiveSeen): nothing once the worker is shutting down; its row from the agent's own registry (owned), for an HA row (rt.HA) only when the activator holds the host awake (HoldsAwake), then the signed grant GET from the deployment store at interactive.GrantKey of the record's own account, app and a session id that passed interactive.ValidID, verified under CARLOS_RELEASE_PUBKEY (VerifyGrant) and matched to the record; the session's context keeps the pass's values (the lifetime judge, PF-19) and ends at a replacement or the worker's shutdown, which joins it; it runs as the agent (user carlos), writes nothing, and nothing it reads reaches root registry:HA@310,whole:Route@1880,whole:Route@1884 cec32b03db08ae55a8238f27533ae8c134dd47bf34a7bcfa5f9f0033a7d6d64b
@legacy c6851e192e7ecbbcaf506a5a5a7aff21b89bc3d340affe2eaacf62e54a7f315d internal/host/interactive.go interactiveWorker.owned legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: runsWorker.owned's rule for the session worker: the agent's registry row for the record's host, provisioned for the record's account and app and activator-managed; in-memory reads of the row, agent only, nothing reaches root registry:Account@162,registry:App@191,registry:Provisioned@144,whole:Route@130,whole:Route@241,whole:Route@292 6efa21c1510d9f42538d47c49c2111895d3d5cc0226da21161786103a21aa79e
-@legacy 69546dd142d35b47f31a59448ef868dd1fd45676c84a5fad4bb665456ec38756 internal/host/interactive.go sessionRun.bridge legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: relays a started session between the console's box door and the session's pty master the agent itself holds (CmdHandle.Terminal, the activator's ptyTerminal): file:Read is a read of that master, at most 32 KiB per frame; writes keystrokes and resizes to it, polls, hangs up, stops and releases through the activator's CmdHandle; agent only, nothing reaches root file:Read@391 06bd6e3b26b7f3e73b42c6c237fe506ce5984524f1616aa9e8df0f91aa438d5a
-@legacy d2b0185be4f88ddd8749aa5f06ddc47327e0bea1e5a7f5a91f6404e8a0c39983 internal/host/interactive.go sessionRun.receiveOpen legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: reads the console's first frame on the box door's WebSocket within OpenWait and decodes interactive.Open, normalized and checked (Open.Check); the file:Open sites are the type name interactive.Open and its methods, not a file open; agent only, nothing reaches root file:Open@194,file:Open@265,file:Open@343,file:Open@36,file:Open@422,file:Open@513 71508261339c1285dff476b2bb095e7b821ac586bfd198ef86b1e0c8f7d63557
-@legacy ced2bf6b5c16e765e2b613e649a20c07136b5d1c25a839ac42e1e04bfb08eb61 internal/host/interactive.go sessionRun.serve legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: refuses over the connection (incarnation from the grant against the record, the app's setting from config.json of the default bundle via appconfig.GetInteractive, an uncommitted import), then RunCmd with spec.TTY {Term, Cols, Rows}, Process and Args exactly as the checked Open names them, on the owned row; root's tty start validates the process or argv itself (Tasks 6 to 8, unchanged); the file:Open site is the interactive.Open parameter type; adds no root input file:Open@32,whole:Route@1551 0dc848ec6db6196485b3f561463dd1c4895acdf4a3df7bdecf6923a83f74b3d0
+@legacy 3b3f7e7259fee7faca8397e93a379f29cc03f7040b919fd5b5e755d606d75cb6 internal/host/interactive.go sessionRun.bridge legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: relays a started session between the console's box door and the session's pty master the agent itself holds (CmdHandle.Terminal, the activator's ptyTerminal): file:Read is a read of that master, at most 32 KiB per frame; writes keystrokes and resizes to it; fix round 1 (Astra P2): a hangup closes the master alone (the handoff listener stays for the unit's ExecStopPost until the activator's settle), each Stop gets its own budget from the moment it is asked, and the End, the start-failure verdict and Release wait for the activator's proof (a nil Stop or AfterSettled), asking the stop again each bound, giving up only at the agent's shutdown; agent only, nothing reaches root file:Read@391 61b9e4165f4c005f84c241dc1323c43b033d9d7934e9a24f6b431447dd2e9d7b
+@legacy 53addbe851402e8591dff617a24917802ad766b8af69d909a886a1022c10ec4e internal/host/interactive.go sessionRun.receiveOpen legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: reads the console's first frame on the box door's WebSocket within OpenWait and decodes interactive.Open, normalized and checked (Open.Check); fix round 1: a replacement or the agent's shutdown ends the wait at once (the read deadline set to the past); the file:Open sites are the type name interactive.Open and its methods, not a file open; agent only, nothing reaches root file:Open@353,file:Open@36,file:Open@424,file:Open@502,file:Open@581,file:Open@672 eb126ee8e50fecef51b41830852c6702ab237e69075c82f25759001a3b222721
+@legacy e1c96b8b8ab126da5c0a054d9c85abfc0b8cb9d589f0da576689c0b1155598fa internal/host/interactive.go sessionRun.serve legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: refuses over the connection (incarnation from the grant against the record, the app's setting from config.json of the default bundle via appconfig.GetInteractive under the session's context with the lifetime judge, an uncommitted import), then RunCmd with spec.TTY {Term, Cols, Rows}, Process and Args exactly as the checked Open names them; fix round 1 (Astra P1): the row is read again from the agent's registry and must still be the record's lifetime (+registry:Incarnation), and spec.Incarnation names that lifetime so the activator refuses an entry of any other; root's tty start validates the process or argv itself (Tasks 6 to 8, unchanged); the file:Open site is the interactive.Open parameter type; adds no root input file:Open@32,registry:Incarnation@1553,whole:Route@2194 1823a1cfa00784827e17a95ce36a8991a1d0702c20db6f17d155031266f1b551
@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
@legacy b18625dfcfcaa6d4e0ae128e2b77ad7fb53d0a4206458b43ef4125d248e6ef58 internal/host/units/carlos-instance-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the binary tty template, carlos-instance-cmd@.service outside six named lines held by TestTTYTemplateEqualsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit tty %I (the same root binary as every template), StandardInput=file:/run/carlos/logs/%I.tty.sock replacing the cmd StandardOutput socket (PID 1 opens it as root on the nosymfollow logs mount, as the cmd streams), StandardOutput=journal, StandardError=journal, and BindReadOnlyPaths sources tty-app/tty-live under /run/carlos-control/exe/%I (root-only exe layout, as cmd-app/cmd-live). Same namespace block byte for byte, runs as carlos. Task 6: POST /tty (handleOneShot(RoleTTY), claimAwareLegacy) starts it, after the role lock, the loaded-state refusal and refuseStagedExe; the tty-app/tty-live sources are laid out by ensureCmdExeAt(RoleTTY) and removed by removeCmdExe(RoleTTY) at /stop role=tty and /sweep file:external@0 060295d0956afad52db77dba1988c508cf4289f9b5a18242a206a315145b8e0d
@legacy 9491fe16a762f2bfb2e6b288428f67b157b813d01c226917ec4c3366ebffb305 internal/instancectl/cmd.go Server.oneShotStatus legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: handleCmdStatus's body moved whole and made role-aware (it serves GET /cmd/{host} and GET /tty/{host} through handleOneShotStatus(role), both claimAwareLegacy): the same three file:Query sites (the URL query read for the invocation, for parseQuery and for the role check); the role check now refuses any role field but the route's own (role=tty on /cmd and role=cmd on /tty are 400, before any show); the unit shown is UnitName(role, host) or RootfsUnitName(role, host) for runtime=rootfs, a name root builds from a validated host and a route constant; read-only systemctl show, starts and stops nothing; no file read added file:Query@1090,file:Query@384,file:Query@759 9ea847d9a1e6b0e0929f27b27a9ade5c783c0de1ba0d997523c939be8293e701
@@ -54,7 +55,7 @@
@legacy 7fa09e38ea17338b467b1cc6ca5e557d2ed77bb0f6477083d17e33484393f8b4 internal/interactive/interactive.go type Open legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: enters scope unchanged with package interactive (Task 2); the Open frame's declaration; file:Open is the type's name; reads nothing file:Open@5 ad72d02e636f55e4c1d4b62129780432b5b949672042ec59d4cb7dbfbc027a3b
@legacy 42df81763fd67911e0e9dc84bca80d45f90fdc374fda09040eff0e07627f8bc0 internal/activator/cmdunit.go cmdUnit.StopAndSettle legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): asks instance control to stop the unit, then waits; the agent keeps the lease until this is proven; no root decision;rev3=census-ruling-rootfs-apps-2;basis=the stop goes through stopRole with the row instead of Control.Stop with its host, so one Host site goes; for a rootfs row that is the rootfs stop verb's request (StopRootfs) over the same control socket; the proof (stop, cgroup empty, streams drained) is unchanged; no file read added;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8 (PF-7): stops and proves the unit own role (stopRole and waitRoleCgroupEmpty with u.role, cmd or tty), never a hard-coded cmd; a unit of no one-shot role is refused; after the proof it drains the two streams, or closes the session handoff and master; new sites are the refusal text (rt.Host) and the route registry:Host@216,whole:Route@218,whole:Route@365,whole:Route@517 68abc85a8850ee4e740e177636b40026b5cea4fb3545d2995ccbab6ff05bd0dc
@legacy 80d2897553e3f5a31e55ecabdf1da017c7a6f5fbe2adde5a643c0c1a1887a8e1 internal/activator/backend_rootfs.go ExecBackend.startRootfsCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1 [pf R0.1, R1.4]: new; the agent's first caller of root's existing CmdRootfs (POST /cmd to root's control socket, unchanged). In order: rootfsGates; refuses a partial staged identity (version, path, digest); rootfsControl; prepare(rt, RoleCmd) (the instance's own directories); two stream listeners on the agent's own log sockets (logSocketNamed); the schema-2 launch file for RoleCmd with env alone (writeRootfsLaunchFor, the same writer and the same root reader as the web start's RoleRun file, rootfsLaunchEnv: never the agent's own environment); the caller's exec gate (runExecGate); then CmdRootfs(host, the row's tier memory.max, StagedImage{staged path, version, digest, process}), process being a declared process name root checks against the staged manifest. ErrStagedImage and ErrStartRefused are refusals with no unit; any other error returns a unit to stop and settle. Root validates the staged image and the process itself (instancectl, unchanged); registry:Host sites are log lines, socket and unit names;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: takes a rootfsCmdLaunch, a declared process or an operator's argv, exactly one or refused before anything is laid out; the launch file names the process or cmd, never an argv; CmdRootfs names the image with the process or with the argv in the request body, which root validates against the staged image itself (instancectl, unchanged); new site +registry:Host is that refusal's message; Plan 6 Task 8 (PF-1): takes the role, cmd or tty, and oneShotSinks; refused before anything is laid out unless the role is a one-shot whose I/O matches (a terminal for tty alone), and for tty unless the control channel has the session verbs (TTYControl, else ErrNoTTY); prepare(rt, role); for tty the session pty and its handoff socket on the agent own logs path (openTTY, TTYSocketName) take the place of the two stream listeners; the launch file is the role one (launch.tty.json for tty: schema 2, process console or cmd, never an argv, env alone through rootfsLaunchEnv); a tty starts through TTYControl.TTYRootfs (POST /tty runtime=rootfs; root Task 6 handler validates the staged image and the process or argv itself), a cmd through CmdRootfs as before; the same refusal and may-have-begun handling; -whole:Route is b.tier(rt) read once registry:Host@1135,registry:Host@1299,registry:Host@1428,registry:Host@1645,registry:Host@2062,registry:Host@2211,registry:Host@2274,registry:Host@2542,registry:Host@2870,registry:Host@2996,registry:Host@3094,registry:Host@320,registry:Host@490,registry:Host@685,registry:Host@963,whole:Route@1351,whole:Route@2089,whole:Route@2935,whole:Route@2939,whole:Route@3161,whole:Route@3165,whole:Route@780 9a8131053dfff1c24d5a222612df56c09d2c105234b9a471773243ba88aabfec
-@legacy a26d326b74fee7875e7b7b462cbb9cef5c275cb7291b6e8634874122fba2fa9e 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 Task 9 (PF-17): a session (spec.TTY) takes the entry's tty slot and a run its cmd slot (holdSlot), the hold carrying its role (newCmdHold); each is refused only for its own role (holdBusyLocked: ErrCmdBusy or ErrTTYBusy), so a run and a session coexist; a release command (a.releaseOps) refuses a run only, since the session's tty unit is its own; no read added, read sites unchanged file:Prepare@2455,file:Prepare@2489,registry:Host@1502,registry:Host@1865,registry:Host@7461,registry:Host@8697,registry:Kind@437,whole:Route@683,whole:Route@7865,whole:Route@8329,whole:Route@869,whole:Route@8862 8a2e42ff8bb02e61ddbe1ac30e3d9ee68d5fa90c8e537e31646c24d894552663
+@legacy bcbb2ab3880cdb8dd08adc67e18b28162861e95cc4689f49a2bbaaa77709003a 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 Task 9 (PF-17): a session (spec.TTY) takes the entry's tty slot and a run its cmd slot (holdSlot), the hold carrying its role (newCmdHold); each is refused only for its own role (holdBusyLocked: ErrCmdBusy or ErrTTYBusy), so a run and a session coexist; a release command (a.releaseOps) refuses a run only, since the session's tty unit is its own; no read added, read sites unchanged Task 12 fix round 1 (Astra P1, incarnation binding): a session (spec.TTY) is refused with ErrCmdIncarnation, under a.mu, at admission (before the hold is attached, so nothing of it runs) and again at the last check before the start, unless the awake entry's row lifetime (e.route.Incarnation) equals spec.Incarnation, the lifetime the box's grant authorized; 0 (unknown) is refused; a run is not checked; refuses more, starts nothing new, no read added beyond the in-memory e.route field (sessionIncarnationLocked) file:Prepare@2688,file:Prepare@2722,registry:Host@1502,registry:Host@2098,registry:Host@7900,registry:Host@9136,registry:Kind@437,whole:Route@683,whole:Route@8304,whole:Route@869,whole:Route@8768,whole:Route@9301 9881ba68b16772b93517153df1501af9314de89d7f0fca24788793ef1b29cf76
@legacy 5c73de37a228f96b04da6efbce918888c7278380fb41acc6f337b28129c1c65f 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(); Plan 6 Task 8: a session (spec.TTY): checkCmdLaunch refuses before anything is listened on or written a launch shape (errCmdLaunchShape: process and argv both or neither, a process other than console, a run naming a process, a session with a run directory or streams, an id that is not one path element) and a process on a binary row (errBinaryProcess); then the session verbs (TTYControl) or ErrNoTTY; on a binary row the same nested gate, live link or staged build, launch environment and replica gate as a run; prepare(rt, RoleTTY); the pty and its handoff socket (openTTY) in place of the two streams; launch.tty.json with argv [live link, args...] and childEnv(ttyVars); then TTYControl.TTY, or TTYExe naming the staged build (POST /tty; root Task 6 handler validates it); the run path is unchanged (TestBinaryStartCmdLaunchGolden); new sites are rt to checkCmdLaunch and rt.Host in its error registry:Host@1092,registry:Host@1201,registry:Host@1972,registry:Host@2176,registry:Host@218,registry:Host@2404,registry:Host@2597,registry:Host@2671,registry:Host@2745,registry:Host@2819,registry:Host@3203,registry:Host@3336,registry:Host@3372,registry:Host@367,registry:Host@473,registry:Host@685,registry:Host@983,whole:Route@130,whole:Route@1788,whole:Route@1895,whole:Route@2220,whole:Route@2313,whole:Route@2489,whole:Route@298,whole:Route@3137,whole:Route@3141,whole:Route@3423,whole:Route@3427,whole:Route@414,whole:Route@755,whole:Route@792 c6e6aff9afe40d2bed118208c3efc69ee1dc2b2ca9566919f76d3ad13a03fb58
@legacy 1c353f4e60f0651b29fc9f3f265ebe5269ce639109112a63b5e8f2ff63989b16 internal/activator/cmdunit.go cmdUnit.Poll legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): a status read over the control socket; no decision;rev3=census-ruling-rootfs-apps-2;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=a rootfs row's (Runtime) command is polled through RootfsControl.CmdStatusRootfs, a binary row's through CmdStatus as before; both are status reads over the control socket; the new kind is registry:Runtime, one site; no decision;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8 (PF-7): role-aware: a cmd unit polls as before (CmdStatusRootfs on a rootfs row, CmdStatus on a binary one); a tty unit polls through TTYControl, TTYStatusRootfs on a rootfs row and TTYStatus on a binary one, or ErrNoTTY without the session verbs; any other role is refused; all status reads over the control socket, no decision; the new sites are the error text (rt.Host), the tty arm runtime check (rt.Runtime) and the route passed registry:Host@279,registry:Host@334,registry:Host@392,registry:Host@541,registry:Host@643,registry:Host@692,registry:Host@792,registry:Runtime@126,registry:Runtime@566,whole:Route@128,whole:Route@281,whole:Route@336,whole:Route@394,whole:Route@543,whole:Route@568,whole:Route@645,whole:Route@694,whole:Route@794 ccbe6c0392bb15a847b1d00cf20b3ae146e96c41a5389e188659a464aa3c2877
@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
@@ -63,12 +64,12 @@ internal/activator/activator.go Service.installProcLocked legacy accepted-legacy
internal/activator/activator.go Service.sweepOnce legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; registry remains legacy; PROPOSED-plans-2-box-limits: the sweep also narrows an entry's idle window to its account's plan idle through the SetIdleFor hook (never lengthens it; always-on workers and held probe entries are untouched; the hibernate, inflight and held-for-tick guards are unchanged).;rev3=census-ruling-plans-4c-box-throttle;basis=after the worker max_run branch, stops a non-worker entry past the plans continuous-awake ceiling (maxRunFor, passed the row), busy or not, never mid-command (plans 4c). One more whole-row read: the row handed to the hook, as idleFor already is. This bypasses the inflight and held-for-tick protections the idle stop keeps, on purpose: escalated by Astra and ACCEPTED by Paul (census owner), 2026-10-25.;rev3=census-ruling-plans-4d-lapse;basis=stops a live entry the turned-off hook names (never mid-command, never a move's active probe), stands down an exited worker it names instead of restarting it (Astra finding 4), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Four more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips.;rev3=census-ruling-remote-instance-metrics;basis=its two entries-map insertions go through putEntryLocked (which also notes the route's tenant in memory for the metrics sampler); no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more call at the top, a.retryOwedMarkers() (harelease.go), which starts at most one background lease.RetryPending pass over owed region HA release markers, off a.mu; the due query, idle, max-run and lapse logic are unchanged; the same 38 sites, no read added; merge of origin/main d7ae1d76: main's change is kept as main has it (census-ruling-remote-instance-metrics: its two entries-map insertions go through putEntryLocked); this branch's change is the same as above; read sites the same 38, offsets moved;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: a resident (Route.Resident) is never stopped for idleness or by the continuous-awake ceiling; the due-wake check is left on Hibernate (comment); stops less, not more;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: an entry whose host has a release record open (the in-memory a.releaseOps[e.host]) is not stopped by its plan's turn-off, by idleness or by the continuous-awake ceiling until the record goes; one more sweep pass, reapReleaseOpsLocked, retries an unproven release's stop (through finishPendingStops); the same 39 read sites, no read added; stops less, not more;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 9 (PF-18): the four checks that left an entry with a run attached alone (e.cmd == nil) now read holdsAttachedLocked(e), a run or a session attached, so a session holds the idle sleep, the plans awake ceiling, the plans turned-off stop and the turned-off worker's stand-down as a run does; in-memory under a.mu; only keeps an entry awake longer; no read added, read sites unchanged registry:Hibernate@10801,registry:Hibernate@14559,registry:Hibernate@23817,registry:Hibernate@5676,registry:Hibernate@7875,registry:Host@23886,registry:Host@23944,registry:Host@24411,registry:Host@24504,registry:Host@25239,registry:Host@25328,registry:Host@26392,registry:Host@26679,registry:Host@26735,registry:NextDue@25194,registry:Status@23833,whole:Route@10803,whole:Route@11662,whole:Route@14561,whole:Route@16494,whole:Route@18204,whole:Route@18394,whole:Route@18687,whole:Route@18859,whole:Route@19006,whole:Route@23217,whole:Route@23993,whole:Route@24908,whole:Route@25248,whole:Route@25255,whole:Route@26207,whole:Route@26508,whole:Route@26712,whole:Route@5487,whole:Route@5678,whole:Route@7708,whole:Route@7877,whole:Route@8070,whole:Route@8533 ddf9a21dc0ae724138b1b0963155d8f555f2ce6982f7e61b9dc05f2bdd80bbe6
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; Plan 6 Task 8: passes instancectl.RoleCmd and oneShotSinks{Stdout, Stderr} (the same two release writers) to startRootfsCmd, which now takes the role; its /cmd request and launch.cmd.json stay byte-identical (TestStartReleaseIsUnchanged); no read added registry:Host@182,whole:Route@247 980b99f9faa5e8c182f89a821118175a750de42ebbe1947884e29e4901611d95
-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; fix round 2: comment only: AfterSettled is called once, after the proof, never while a lock is held, in the settle's goroutine without the stop waiting for it, and must not call Stop or Shutdown; Plan 6 Task 8: declaration only: gains Process (a declared process name, "" or console; StartCmd refuses it except for a session on a rootfs row) and TTY (*TTYSpec: Term, Cols, Rows; set, the command is a session in the tty unit), fields the box sets; reads nothing file:Prepare@1305 f71a97113e7d5583d7b38bdf4883b1bb379ad7111a2550be0bc4e7bcbcc2fac6
+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; fix round 2: comment only: AfterSettled is called once, after the proof, never while a lock is held, in the settle's goroutine without the stop waiting for it, and must not call Stop or Shutdown; Plan 6 Task 8: declaration only: gains Process (a declared process name, "" or console; StartCmd refuses it except for a session on a rootfs row) and TTY (*TTYSpec: Term, Cols, Rows; set, the command is a session in the tty unit), fields the box sets; reads nothing Task 12 fix round 1: declaration only: gains Incarnation (uint64), the session's authorized lifetime, which the box sets from the instance record and RunCmd compares with the entry's row; reads nothing file:Prepare@1822 5fef13425a1ab96487b3de980e66761e920f6e0342470f1f18920e3f944143a3
internal/activator/prepare.go ExecBackend.prepareKeyedAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling zddr4, with no further change from this branch beyond carrying main's new early return into the six-value signature. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): body of the frozen prepareAt, which is now its wrapper; it also returns the instance key's layer and reads no env for the cmd role; same reads, same nested launch paths;rev3=census-ruling-wake-latency-2;basis=takes an optional timer and marks its steps with time.Now() (dirs, admin token, instance key, env, control socket, key gate, logs); no read added or moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, run and seed roles only, under a 30 s context (haSecretsBudget): the token producer is ensureAdminTokenFor(hctx, rt, p) (on this nested path the same beneath producer, EnsureAdminTokenBeneath's, plus the HA mint decision inside it); ensureInstanceKeyFor now gets hctx instead of context.Background(), so the key's bucket read is bounded by 30 s as well as configReadTimeout; the env is launchEnvLayer(hctx, rt) (instanceEnvLayer for a non-HA host; for an HA host one capture, published and acknowledged); a test seam (haLaunchHooks.afterGate, nil in production) is called before the producers. The separate haMintGate and haSecretsReady calls are gone (final fix F2). Sites against main: -registry:Host (the rt.Host+".env" argument EnsureAdminTokenBeneath took) and +whole:Route (rt to launchEnvLayer); the cmd role and a non-HA host are unchanged;rev3=census-ruling-rootfs-fleet-followups;basis=names the process for the role log listener: release.ProcessWeb when rt.Rootfs() and the role is run, else none, passed to logEmitter; reads rt.Runtime through Rootfs(); no file, path or env read added or moved;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8: the cmd role three exceptions (no env read, the replica gate left to StartCmd, no app-log listener) now cover every one-shot role, instancectl.OneShot(role): cmd and tty; before, the tty role fell to the sidecar env-file read and an app-log listener on its handoff socket path; no read added, one removed for tty file:ReadDir@2965,registry:Host@1783,registry:Host@1995,registry:Host@5886,registry:Host@6084,registry:Host@612,whole:Route@1674,whole:Route@1885,whole:Route@2116,whole:Route@320,whole:Route@4678,whole:Route@5227,whole:Route@5920 0fce84024e1c33a8f8db76231106e7b962627f294dd6429038b479d25274a5b2
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
internal/activator/rootfsrelease.go Service.releaseAdmitLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1 [pf R1.10]: new; the owner's half of a release's admission under a.mu: refuses while a run holds the cmd unit, and for an awake owner mirrors Swap's exclusions (worker or non-instance kind, a layout other than flat or nested through the existing swapLayout, members, a raised parent, a resize, a cmd start in flight); in-memory only; refusals only;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 9 (PF-17): the busy check is holdBusyLocked(e, RoleCmd) where it was cmdBusyLocked(e): only established cmd-unit holds and cmd-unit lease stops refuse a release command, never a started session, whose tty unit is its own; cmdStartInFlightLocked now also counts a session's start in flight (merge ruling M2), so a release is refused during either role's start window, short and bounded, as swap admission is (fix round 2 ruling: a refusal at admission is not executed and takes the ordinary retry); no read added, read sites unchanged registry:Kind@309,whole:Route@311,whole:Route@390 d1f6ba85b88b217e9d82caa7f033f20f61429bc319f48099e60e3aea37234916
internal/activator/rootfsrelease.go Service.runRelease legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1: new; the one place a release command runs. Refuses while any record of the host is open; skips the row's good build (releaseRan); reads the declared processes (declaredProcesses: the existing staged-manifest read) and refuses on a read error, never treating it as no release; runs only when releaseDue; needs a lease watch and a ReleaseBackend; its gate is the caller's plus the lease's Err and its safety deadline more than releaseStopLead (cmdStopBound, 2 min) away; creates the record under a.mu after releaseAdmitLocked; publishes the generations file and the build state (recordBuild) before anything runs; times out at the manifest's timeout_sec (default, capped at runs.MaxTimeout); ReleaseEnv; a supervisor stops the unit ahead of the lease's safety deadline; StartRelease under the exec gate; polls the unit (root's existing cmd status); stops and settles it (the existing cmd hold's stop, cmdStopBound); only a non-zero exit, a signal or the timeout with the unit proven gone is the build's failure (*ReleaseError); registry:Host sites are the record key and log lines;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 9: newCmdHold takes the hold's role; a release command's hold is instancectl.RoleCmd, the unit it runs in; nothing else changed, no read added registry:Host@184,whole:Route@2955,whole:Route@3184,whole:Route@3672,whole:Route@3701,whole:Route@5749,whole:Route@589,whole:Route@6217,whole:Route@6494,whole:Route@6924,whole:Route@817,whole:Route@902 442d93ec958dea41fe2eb1c49b1600e77450fc54c79a236c9cdd7c613d48f972
-internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites file:Exec@17043,file:Open@1150,file:Statfs@42963,registry:App@11199,whole:Route@11191,whole:Route@27218 aff93cec62fdc1c04c35ec0f51d6f5e8b14bbd21936c038f7ade2f38eb611dcd
+internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites file:Exec@17043,file:Open@1150,file:Statfs@42963,registry:App@11199,whole:Route@11191,whole:Route@27218 496139e3c25360fb785647a381d7133c5b4d32a36dd5f7c9d419e82f0f7d8ee0
internal/host/runexec.go runsWorker.execute legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): runs one picked run to its result in the bucket; every root action goes through instance control;rev3=PROPOSED-325;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=emits the run's start and end as member log events through the agent's EventSink; reads unchanged;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a (INV-2): sets CmdSpec.AfterSettled to remove the run's directory (runs.RemoveRunDir under the instance's own directory, as cleanUp did) once the activator has proven no unit of the run runs; finish and cleanUp take removeDir, true only on the incarnation refusal before RunCmd; the directory goes later or at the same point, never earlier; no read added file:Prepare@1905,whole:Route@2916 43bd160066b4d3e7aef00e3891001bc5ffa9a40f597cb6e5cc7215eae2814df9
internal/host/units/carlos-instance-cmd@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the cmd unit template (applied by PID 1 as root; its process runs as carlos): extends the J4 seed pattern to the run role. The template equals the seed template outside named lines, and the template-equality test pins that. Root lays out a staged executable validated by the same refuseStagedExe the seed and generation paths use, then starts this unit, which runs as carlos with the instance's own reach. No new trust of registry, /data or agent-asserted content beyond the seed path;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 925113f4c51c091f0da65c2c67c5902aa35ab37abbe6491ca935820517e8149d
internal/host/units/carlos-instance-gen@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the same one namespace-block line, TemporaryFileSystem=/dev/pts:ro, as carlos-instance@.service; nothing else file:external@0 0bd25fefd9306449d55e235e9bd8986466bc4cd68ad56b5614d32596ce39c262
@@ -89,17 +90,18 @@ internal/activator/backend_unit.go SplitBackend.KillOneShot legacy accepted-lega
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; 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 Task 9 (PF-3): covers every run and session hold that may be running (holdsLocked: e.cmd, e.tty and the released holds of either role); each func is counted under its hold's role (addLeaseStop(h.role)) and stops and kills that role's unit only (stopOneShotAtLease(rt, h, h.role, kill)), so a session's lease kill names the tty unit and a run's the cmd unit, never the other's; while a role's count is up no new command of that role starts (holdBusyLocked); no read added whole:Route@358 3be2f4759579fea82f4afe35babbd400ab33a18a87340706f2b3f525a067d21d
+internal/activator/cmd.go sessionIncarnationLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12 fix round 1, new: RunCmd's session lifetime check, in memory under a.mu: a session (spec.TTY) whose spec.Incarnation is 0 or differs from the entry's row lifetime (e.route.Incarnation) is refused; a run never is; reads only those two fields, nothing from disk or a path registry:Incarnation@117,whole:Route@119 6694885322e347b0ece1510427ef6e22c040dc08243380763d223d9e1cdca53d
internal/activator/cmdunit.go ExecBackend.ttyVars legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8, new: a session environment: cmdVars over the generation launch environment without CARLOS_RUN_ID and CARLOS_RUN_DIR, with TERM and CARLOS_SESSION_ID set over the file; map composition only, the route host through cmdVars whole:Route@156 127be6d996c0492af254a0a6b6fa9f292c8b5e8b0656ac02319aa61f77186a00
internal/activator/pty_linux.go openPTY legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8, new: the agent (user carlos, never root) opens the fixed path /dev/ptmx O_RDWR|O_NOCTTY|O_CLOEXEC, unlocks it (TIOCSPTLCK), takes the slave from the master with TIOCGPTPEER (never opening /dev/pts/N by path, so no path a tenant can name is opened), sets TIOCEXCL on the slave and the window size on the master; the slave goes only to a SO_PEERCRED uid 0 peer of the agent owner-only handoff socket (ttyPeerOK), the tty unit stdin file:Open@143,file:Syscall@517 42d48a34ebb89715fd152471c827408c0439009525d37c5dd7c68a9ca035a1d6
internal/activator/pty_linux.go ptyTerminal.Read legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8, new: reads the session pty master the agent itself opened (openPTY), as the agent (user carlos); the bytes go to the session caller only file:Read@22,file:Read@60 55a2d9ae0563470e24cd622805eb71c6463b6b001d69ae495500d789b68ea23d
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/activator/rootfsenv.go ExecBackend.rootfsTTYVars legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8, new: a rootfs session environment: ttyVars over the generation launch environment, then rootfsVars with the row canonical socket and dbPath set after the file environment, as rootfsCmdVars does; map composition only registry:Socket@202,whole:Route@163 6f561ab8a1e4a8063afeb0be152cee2f5fbb30d78e3008a2b515bc4aeba9735b
-internal/host/interactive.go interactiveWorker.consider legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: the box's session worker decides one reconcile-noted record (InteractiveSeen): its row from the agent's own registry (owned), for an HA row (rt.HA) only when the activator holds the host awake (HoldsAwake), then the signed grant GET from the deployment store at interactive.GrantKey of the record's own account, app and a session id that passed interactive.ValidID, verified under CARLOS_RELEASE_PUBKEY (VerifyGrant) and matched to the record; it runs as the agent (user carlos), writes nothing, and nothing it reads reaches root registry:HA@181,whole:Route@1751,whole:Route@1755 37cc833b3ca261c129eb1c0e1f966140e57550936a1ae50b42c31a0b01803e8c
+internal/host/interactive.go interactiveWorker.consider legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: the box's session worker decides one reconcile-noted record (InteractiveSeen): nothing once the worker is shutting down; its row from the agent's own registry (owned), for an HA row (rt.HA) only when the activator holds the host awake (HoldsAwake), then the signed grant GET from the deployment store at interactive.GrantKey of the record's own account, app and a session id that passed interactive.ValidID, verified under CARLOS_RELEASE_PUBKEY (VerifyGrant) and matched to the record; the session's context keeps the pass's values (the lifetime judge, PF-19) and ends at a replacement or the worker's shutdown, which joins it; it runs as the agent (user carlos), writes nothing, and nothing it reads reaches root registry:HA@310,whole:Route@1880,whole:Route@1884 cec32b03db08ae55a8238f27533ae8c134dd47bf34a7bcfa5f9f0033a7d6d64b
internal/host/interactive.go interactiveWorker.owned legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: runsWorker.owned's rule for the session worker: the agent's registry row for the record's host, provisioned for the record's account and app and activator-managed; in-memory reads of the row, agent only, nothing reaches root registry:Account@162,registry:App@191,registry:Provisioned@144,whole:Route@130,whole:Route@241,whole:Route@292 6efa21c1510d9f42538d47c49c2111895d3d5cc0226da21161786103a21aa79e
-internal/host/interactive.go sessionRun.bridge legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: relays a started session between the console's box door and the session's pty master the agent itself holds (CmdHandle.Terminal, the activator's ptyTerminal): file:Read is a read of that master, at most 32 KiB per frame; writes keystrokes and resizes to it, polls, hangs up, stops and releases through the activator's CmdHandle; agent only, nothing reaches root file:Read@391 06bd6e3b26b7f3e73b42c6c237fe506ce5984524f1616aa9e8df0f91aa438d5a
-internal/host/interactive.go sessionRun.receiveOpen legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: reads the console's first frame on the box door's WebSocket within OpenWait and decodes interactive.Open, normalized and checked (Open.Check); the file:Open sites are the type name interactive.Open and its methods, not a file open; agent only, nothing reaches root file:Open@194,file:Open@265,file:Open@343,file:Open@36,file:Open@422,file:Open@513 71508261339c1285dff476b2bb095e7b821ac586bfd198ef86b1e0c8f7d63557
-internal/host/interactive.go sessionRun.serve legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: refuses over the connection (incarnation from the grant against the record, the app's setting from config.json of the default bundle via appconfig.GetInteractive, an uncommitted import), then RunCmd with spec.TTY {Term, Cols, Rows}, Process and Args exactly as the checked Open names them, on the owned row; root's tty start validates the process or argv itself (Tasks 6 to 8, unchanged); the file:Open site is the interactive.Open parameter type; adds no root input file:Open@32,whole:Route@1551 0dc848ec6db6196485b3f561463dd1c4895acdf4a3df7bdecf6923a83f74b3d0
+internal/host/interactive.go sessionRun.bridge legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: relays a started session between the console's box door and the session's pty master the agent itself holds (CmdHandle.Terminal, the activator's ptyTerminal): file:Read is a read of that master, at most 32 KiB per frame; writes keystrokes and resizes to it; fix round 1 (Astra P2): a hangup closes the master alone (the handoff listener stays for the unit's ExecStopPost until the activator's settle), each Stop gets its own budget from the moment it is asked, and the End, the start-failure verdict and Release wait for the activator's proof (a nil Stop or AfterSettled), asking the stop again each bound, giving up only at the agent's shutdown; agent only, nothing reaches root file:Read@391 61b9e4165f4c005f84c241dc1323c43b033d9d7934e9a24f6b431447dd2e9d7b
+internal/host/interactive.go sessionRun.receiveOpen legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: reads the console's first frame on the box door's WebSocket within OpenWait and decodes interactive.Open, normalized and checked (Open.Check); fix round 1: a replacement or the agent's shutdown ends the wait at once (the read deadline set to the past); the file:Open sites are the type name interactive.Open and its methods, not a file open; agent only, nothing reaches root file:Open@353,file:Open@36,file:Open@424,file:Open@502,file:Open@581,file:Open@672 eb126ee8e50fecef51b41830852c6702ab237e69075c82f25759001a3b222721
+internal/host/interactive.go sessionRun.serve legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12, new: refuses over the connection (incarnation from the grant against the record, the app's setting from config.json of the default bundle via appconfig.GetInteractive under the session's context with the lifetime judge, an uncommitted import), then RunCmd with spec.TTY {Term, Cols, Rows}, Process and Args exactly as the checked Open names them; fix round 1 (Astra P1): the row is read again from the agent's registry and must still be the record's lifetime (+registry:Incarnation), and spec.Incarnation names that lifetime so the activator refuses an entry of any other; root's tty start validates the process or argv itself (Tasks 6 to 8, unchanged); the file:Open site is the interactive.Open parameter type; adds no root input file:Open@32,registry:Incarnation@1553,whole:Route@2194 1823a1cfa00784827e17a95ce36a8991a1d0702c20db6f17d155031266f1b551
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
internal/host/units/carlos-instance-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the binary tty template, carlos-instance-cmd@.service outside six named lines held by TestTTYTemplateEqualsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit tty %I (the same root binary as every template), StandardInput=file:/run/carlos/logs/%I.tty.sock replacing the cmd StandardOutput socket (PID 1 opens it as root on the nosymfollow logs mount, as the cmd streams), StandardOutput=journal, StandardError=journal, and BindReadOnlyPaths sources tty-app/tty-live under /run/carlos-control/exe/%I (root-only exe layout, as cmd-app/cmd-live). Same namespace block byte for byte, runs as carlos. Task 6: POST /tty (handleOneShot(RoleTTY), claimAwareLegacy) starts it, after the role lock, the loaded-state refusal and refuseStagedExe; the tty-app/tty-live sources are laid out by ensureCmdExeAt(RoleTTY) and removed by removeCmdExe(RoleTTY) at /stop role=tty and /sweep file:external@0 060295d0956afad52db77dba1988c508cf4289f9b5a18242a206a315145b8e0d
internal/instancectl/cmd.go Server.oneShotStatus legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: handleCmdStatus's body moved whole and made role-aware (it serves GET /cmd/{host} and GET /tty/{host} through handleOneShotStatus(role), both claimAwareLegacy): the same three file:Query sites (the URL query read for the invocation, for parseQuery and for the role check); the role check now refuses any role field but the route's own (role=tty on /cmd and role=cmd on /tty are 400, before any show); the unit shown is UnitName(role, host) or RootfsUnitName(role, host) for runtime=rootfs, a name root builds from a validated host and a route constant; read-only systemctl show, starts and stops nothing; no file read added file:Query@1090,file:Query@384,file:Query@759 9ea847d9a1e6b0e0929f27b27a9ade5c783c0de1ba0d997523c939be8293e701
@@ -112,16 +114,16 @@ internal/interactive/interactive.go Open.Normalized legacy accepted-legacy accep
internal/interactive/interactive.go type Open legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: enters scope unchanged with package interactive (Task 2); the Open frame's declaration; file:Open is the type's name; reads nothing file:Open@5 ad72d02e636f55e4c1d4b62129780432b5b949672042ec59d4cb7dbfbc027a3b
internal/activator/cmdunit.go cmdUnit.StopAndSettle legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): asks instance control to stop the unit, then waits; the agent keeps the lease until this is proven; no root decision;rev3=census-ruling-rootfs-apps-2;basis=the stop goes through stopRole with the row instead of Control.Stop with its host, so one Host site goes; for a rootfs row that is the rootfs stop verb's request (StopRootfs) over the same control socket; the proof (stop, cgroup empty, streams drained) is unchanged; no file read added;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8 (PF-7): stops and proves the unit own role (stopRole and waitRoleCgroupEmpty with u.role, cmd or tty), never a hard-coded cmd; a unit of no one-shot role is refused; after the proof it drains the two streams, or closes the session handoff and master; new sites are the refusal text (rt.Host) and the route registry:Host@216,whole:Route@218,whole:Route@365,whole:Route@517 68abc85a8850ee4e740e177636b40026b5cea4fb3545d2995ccbab6ff05bd0dc
internal/activator/backend_rootfs.go ExecBackend.startRootfsCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1 [pf R0.1, R1.4]: new; the agent's first caller of root's existing CmdRootfs (POST /cmd to root's control socket, unchanged). In order: rootfsGates; refuses a partial staged identity (version, path, digest); rootfsControl; prepare(rt, RoleCmd) (the instance's own directories); two stream listeners on the agent's own log sockets (logSocketNamed); the schema-2 launch file for RoleCmd with env alone (writeRootfsLaunchFor, the same writer and the same root reader as the web start's RoleRun file, rootfsLaunchEnv: never the agent's own environment); the caller's exec gate (runExecGate); then CmdRootfs(host, the row's tier memory.max, StagedImage{staged path, version, digest, process}), process being a declared process name root checks against the staged manifest. ErrStagedImage and ErrStartRefused are refusals with no unit; any other error returns a unit to stop and settle. Root validates the staged image and the process itself (instancectl, unchanged); registry:Host sites are log lines, socket and unit names;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: takes a rootfsCmdLaunch, a declared process or an operator's argv, exactly one or refused before anything is laid out; the launch file names the process or cmd, never an argv; CmdRootfs names the image with the process or with the argv in the request body, which root validates against the staged image itself (instancectl, unchanged); new site +registry:Host is that refusal's message; Plan 6 Task 8 (PF-1): takes the role, cmd or tty, and oneShotSinks; refused before anything is laid out unless the role is a one-shot whose I/O matches (a terminal for tty alone), and for tty unless the control channel has the session verbs (TTYControl, else ErrNoTTY); prepare(rt, role); for tty the session pty and its handoff socket on the agent own logs path (openTTY, TTYSocketName) take the place of the two stream listeners; the launch file is the role one (launch.tty.json for tty: schema 2, process console or cmd, never an argv, env alone through rootfsLaunchEnv); a tty starts through TTYControl.TTYRootfs (POST /tty runtime=rootfs; root Task 6 handler validates the staged image and the process or argv itself), a cmd through CmdRootfs as before; the same refusal and may-have-begun handling; -whole:Route is b.tier(rt) read once registry:Host@1135,registry:Host@1299,registry:Host@1428,registry:Host@1645,registry:Host@2062,registry:Host@2211,registry:Host@2274,registry:Host@2542,registry:Host@2870,registry:Host@2996,registry:Host@3094,registry:Host@320,registry:Host@490,registry:Host@685,registry:Host@963,whole:Route@1351,whole:Route@2089,whole:Route@2935,whole:Route@2939,whole:Route@3161,whole:Route@3165,whole:Route@780 9a8131053dfff1c24d5a222612df56c09d2c105234b9a471773243ba88aabfec
-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 Task 9 (PF-17): a session (spec.TTY) takes the entry's tty slot and a run its cmd slot (holdSlot), the hold carrying its role (newCmdHold); each is refused only for its own role (holdBusyLocked: ErrCmdBusy or ErrTTYBusy), so a run and a session coexist; a release command (a.releaseOps) refuses a run only, since the session's tty unit is its own; no read added, read sites unchanged file:Prepare@2455,file:Prepare@2489,registry:Host@1502,registry:Host@1865,registry:Host@7461,registry:Host@8697,registry:Kind@437,whole:Route@683,whole:Route@7865,whole:Route@8329,whole:Route@869,whole:Route@8862 8a2e42ff8bb02e61ddbe1ac30e3d9ee68d5fa90c8e537e31646c24d894552663
+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 Task 9 (PF-17): a session (spec.TTY) takes the entry's tty slot and a run its cmd slot (holdSlot), the hold carrying its role (newCmdHold); each is refused only for its own role (holdBusyLocked: ErrCmdBusy or ErrTTYBusy), so a run and a session coexist; a release command (a.releaseOps) refuses a run only, since the session's tty unit is its own; no read added, read sites unchanged Task 12 fix round 1 (Astra P1, incarnation binding): a session (spec.TTY) is refused with ErrCmdIncarnation, under a.mu, at admission (before the hold is attached, so nothing of it runs) and again at the last check before the start, unless the awake entry's row lifetime (e.route.Incarnation) equals spec.Incarnation, the lifetime the box's grant authorized; 0 (unknown) is refused; a run is not checked; refuses more, starts nothing new, no read added beyond the in-memory e.route field (sessionIncarnationLocked) file:Prepare@2688,file:Prepare@2722,registry:Host@1502,registry:Host@2098,registry:Host@7900,registry:Host@9136,registry:Kind@437,whole:Route@683,whole:Route@8304,whole:Route@869,whole:Route@8768,whole:Route@9301 9881ba68b16772b93517153df1501af9314de89d7f0fca24788793ef1b29cf76
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(); Plan 6 Task 8: a session (spec.TTY): checkCmdLaunch refuses before anything is listened on or written a launch shape (errCmdLaunchShape: process and argv both or neither, a process other than console, a run naming a process, a session with a run directory or streams, an id that is not one path element) and a process on a binary row (errBinaryProcess); then the session verbs (TTYControl) or ErrNoTTY; on a binary row the same nested gate, live link or staged build, launch environment and replica gate as a run; prepare(rt, RoleTTY); the pty and its handoff socket (openTTY) in place of the two streams; launch.tty.json with argv [live link, args...] and childEnv(ttyVars); then TTYControl.TTY, or TTYExe naming the staged build (POST /tty; root Task 6 handler validates it); the run path is unchanged (TestBinaryStartCmdLaunchGolden); new sites are rt to checkCmdLaunch and rt.Host in its error registry:Host@1092,registry:Host@1201,registry:Host@1972,registry:Host@2176,registry:Host@218,registry:Host@2404,registry:Host@2597,registry:Host@2671,registry:Host@2745,registry:Host@2819,registry:Host@3203,registry:Host@3336,registry:Host@3372,registry:Host@367,registry:Host@473,registry:Host@685,registry:Host@983,whole:Route@130,whole:Route@1788,whole:Route@1895,whole:Route@2220,whole:Route@2313,whole:Route@2489,whole:Route@298,whole:Route@3137,whole:Route@3141,whole:Route@3423,whole:Route@3427,whole:Route@414,whole:Route@755,whole:Route@792 c6e6aff9afe40d2bed118208c3efc69ee1dc2b2ca9566919f76d3ad13a03fb58
internal/activator/cmdunit.go cmdUnit.Poll legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): a status read over the control socket; no decision;rev3=census-ruling-rootfs-apps-2;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=a rootfs row's (Runtime) command is polled through RootfsControl.CmdStatusRootfs, a binary row's through CmdStatus as before; both are status reads over the control socket; the new kind is registry:Runtime, one site; no decision;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 8 (PF-7): role-aware: a cmd unit polls as before (CmdStatusRootfs on a rootfs row, CmdStatus on a binary one); a tty unit polls through TTYControl, TTYStatusRootfs on a rootfs row and TTYStatus on a binary one, or ErrNoTTY without the session verbs; any other role is refused; all status reads over the control socket, no decision; the new sites are the error text (rt.Host), the tty arm runtime check (rt.Runtime) and the route passed registry:Host@279,registry:Host@334,registry:Host@392,registry:Host@541,registry:Host@643,registry:Host@692,registry:Host@792,registry:Runtime@126,registry:Runtime@566,whole:Route@128,whole:Route@281,whole:Route@336,whole:Route@394,whole:Route@543,whole:Route@568,whole:Route@645,whole:Route@694,whole:Route@794 ccbe6c0392bb15a847b1d00cf20b3ae146e96c41a5389e188659a464aa3c2877
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
@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 089879d2d79f4193310e975248cdd2ac6c6114162d9caa6ba38db48f6487a658
+@coverage internal/activator ca11a10e8d8d494376ebf3fd0a4d7aa2ea471ec696732849c8cb2afb6bbe3ac0
@coverage internal/appconfig cac8d8ef7538a456d034801c95ce6508a4983e5516b3bbbd302bec0fbafdd479
-@coverage internal/host d7bb9b20bcf4f304042025e5373c6aefa6d4df179a2d7b7b46a5760cc7a408ca
+@coverage internal/host 8225c70eaa0fb38c90fde16a9cd471ae5583183a84389b01db606ebbcb42f6e7
@coverage internal/host/units c3cc4f3b917fdb938f20d406b1704ec54e24553851c298e312056d397d10b0e1
@coverage internal/instancectl 096e845eb71478e8b68726160cff450f8ba850869dae65582dabd25f445527e9
@coverage internal/instanceexec 65f6db1c6bf469f1d19615ec989f54c20de3b73c3c03ae2d677cffbcc60470fd