activator: a session is held and settled like a run, beside it (rootfs plan 6)
Task 9. The entry gains a tty hold beside the cmd hold; each hold knows its role, and RunCmd picks the slot by spec.TTY (ErrTTYBusy for a second session, ErrCmdBusy for a second run), so a run and a session coexist and neither's stop, settle, release or files touch the other's. The busy, start-in-flight, settle-retry, interrupt and generations-pin paths cover both roles; the four idle and stop checks and beginStopLocked's cancel cover a session (PF-18). A release's busy check counts cmd holds only (PF-17). The lease-loss stop and kill cover the tty hold, each func counted under and killing its own role's unit (PF-3). An import's abort is refused while a session is open. Census overlay re-proposed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/notes/census-proposal-rootfs-apps-6.md+11 −3internal/activator/activator.go+28 −17internal/activator/cmd.go+166 −77internal/activator/cmd_swap_test.go+99 −1internal/activator/cmd_test.go+449 −14internal/activator/generations_file.go+4 −4internal/activator/rootfs_cmd_lease_test.go+534 −12internal/activator/rootfs_swap_release_test.go+2 −1internal/activator/rootfsrelease.go+4 −2internal/activator/rootfsrelease_test.go+2 −2internal/host/runexec_linux_test.go+1 −0internal/provision/seed.go+10 −0internal/provision/seed_test.go+65 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv+17 −9
Intent
<task-notification> <task-id>a5b8b4388fb92f260</task-id> <tool-use-id>toolu_01CBqBLEv4PfgQpKq2MMHwzJ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a5b8b4388fb92f260.output</output-file> <status>completed</status> <summary>Agent "Plan 6 Task 8: agent pty and tty start" 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>The fix for Astra's P2 is in. The tty handoff socket now stays open until the unit is settled, so the tty units' ExecStopPost=instance-exit can open its stdin again. **Status:** DONE_WITH_CONCERNS **Commit:** `b9e0eddd` (on `49c6abb9`), not pushed. **Tests:** the three new tests failed first (the socket had been unlinked after the handoff), then passed. Also passing: the other Task 8 tests, the invariant guards, the activator regression set, the provision census tests, vet, and the darwin/arm64, windows/amd64 and linux/arm64 builds. Of three mutations, two were killed: "close after handoff" and "send the fd twice". The third survived; see concern 1. **What changed:** - Exactly one fd transfer happens, to the first root peer, and the agent closes its slave right after. - Later root peers are accepted and closed at once, with nothing sent. A peer that is not root is refused as before. - The socket is unlinked only in Close, which StopAndSettle calls after the stop and the cgroup proof. - The census card changed only by the activator envelope. I re-proposed the overlay with all 43 claims carried over unchanged, and the seal stays at `b36c59a0`. No approval requested. - The real-systemd check (handoff, stop, exit hook runs and records) is added to Task 15's dev-box checklist in `progress.md` as a carried item, and noted in the report. **Concerns:** 1. The "send twice" mutation only dies when both guards are removed. With just the `spent` flag removed, it survives as an equivalent mutant. The other guard is that the slave is already closed, and `send` refuses a closed slave. Removing the slave close alone is killed by an existing test. I kept both guards on purpose. 2. A socket file now stays in `/run/carlos/logs` for the session's lifetime, which is the cost the ruling accepted. If a unit is never settled, for example the agent exits mid-session, the file stays until the next listen on that path removes it. 3. Later root peers are closed without a log line, so the post hook adds nothing to the journal. The fix report is appended to `.superpowers/sdd/2026-10-24-rootfs-apps-6-interactive/task-8-report.md`.</result> <usage><subagent_tokens>381628</subagent_tokens><tool_uses>14</tool_uses><duration_ms>313082</duration_ms></usage> </task-notification>
<task-notification> <task-id>biakbz61v</task-id> <tool-use-id>toolu_01QDzHdGngbRrb45nTWqG8U4</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/biakbz61v.output</output-file> <status>completed</status> <summary>Background command "Wait for CI on the #471 tip" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 14.7 g CO₂e (1,863,342 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 2051bff6b..7e95a150b 100644 |
| --- a/docs/superpowers/notes/census-proposal-rootfs-apps-6.md |
| +++ b/docs/superpowers/notes/census-proposal-rootfs-apps-6.md |
| @@ -4,13 +4,16 @@ Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejec |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| -| `internal/activator/activator.go` `Service.finishStop` | body | unchanged (5) | rootfs Plan 6 Task 7a fix round 1 (Astra P1): beside the worker check, under the same lock, a stop with a lease stop of its commands outstanding (e.leaseStops) is kept pending, the replica and lease held, and the sweep finishes it once they have returned; the entry is never released while a kill captured for it may still reach its unit; the same five read sites, no read added | |
| +| `internal/activator/activator.go` `Service.finishStop` | body | unchanged (5) | rootfs Plan 6 Task 7a fix round 1 (Astra P1): beside the worker check, under the same lock, a stop with a lease stop of its commands outstanding (e.leaseStops) is kept pending, the replica and lease held, and the sweep finishes it once they have returned; the entry is never released while a kill captured for it may still reach its unit; the same five read sites, no read added 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 | |
| | `internal/activator/activator.go` `Service.installProcLocked` | body | unchanged (1) | rootfs Plan 6 Task 7a (Call A1, Astra R1 P1-1): the lease watch is installed for every rootfs row (e.route.Rootfs()), not only a resident, so a hibernating rootfs row's run or session is reached at the lease's loss; the same one read of the entry's route; installs nothing else | |
| +| `internal/activator/activator.go` `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/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 cmd-unit holds and cmd-unit lease stops refuse a release command, never a 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 while one is; 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/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 | |
| @@ -24,8 +27,9 @@ Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejec |
| | `internal/instanceexec/probe.go` `productionProbeEnv` | body | unchanged (1) | rootfs Plan 6 Task 5 (PF-8): the binary probe env sets devPts=/dev/pts and openPtmx (open /dev/ptmx O_RDWR|O_NOCTTY and close at once), the fields the rootfs probe env already set; read by the new pts-private line inside the probe unit (as carlos, in the namespace); fix round 1: also reads its own environment, CARLOS_PROBE_PTS_PRIVATE (exactly "1" enforces pts-private; otherwise the line is reported unverified), which the probe unit sets; the same direct site, no new root read | |
| | `internal/layout/plan.go` `NestedPlatformNames` | body | unchanged (1) | rootfs Plan 6 Task 5: the fixed role list gains RoleTTY, so launch.tty.json is one more fixed platform name; still reads nothing | |
| | `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 | |
| +| `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/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 | |
| @@ -46,11 +50,14 @@ Recorded dispositions, which each change must still satisfy: |
| - `internal/activator/activator.go` `Service.finishStop`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with a run's settle checked before replication closes, which keeps the stop pending until the run is proven stopped; read sites unchanged, offsets moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: an HA entry (its replica is an HA one, haEntryRep) now releases through releaseHAClean (a new unit on this card) instead of e.rep.Close; when that answers errHostSliceUnproven the stop is kept pending (keepPendingLocked) with the lease held and renewing, and the sweep finishes it once proven; a non-HA entry is unchanged; the same five sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: a forgotten entry's stop is noted for its resident (noteResidentStopLocked: crash or lost lease backs off, any other stop restarts on the next tick) and its ownerDone channel is closed; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: while the host has a release command's record (a.releaseOps[e.host], running or not proven stopped), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the record's proof; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.20: while a rootfs worker may run or is a stray (rootfsWorkersLiveLocked, in-memory, read under a.mu), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the workers are proven stopped; the same five read sites, no read added; only holds a release back |
| - `internal/activator/activator.go` `Service.installProcLocked`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: the one place a process, its generation and the lease replica are installed on an entry; a resident is put under its lease watch (watchResidentLeaseLocked) at that moment; reads only the entry's route |
| +- `internal/activator/activator.go` `Service.sweepOnce`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/activator/activator.go` `type Service`: authority, task B,C,D,F,J4. Basis: rev3=PROPOSED-seed; existing activator lifecycle and due-wake state plus owned seed exclusion and incarnation-keyed diagnostics; normal refusal and preparation ordering remain authoritative; PROPOSED-plans-2-box-limits adds the idleFor hook field, which only narrows idle windows;rev3=census-ruling-plans-4c-box-throttle;basis=gains the maxRunFor hook field beside idleFor (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=gains the disabledFor hook field beside maxRunFor (plans 4d). No read added.;rev3=census-ruling-remote-instance-metrics;basis=gains tenancySeq, hostTenants and hostMixed, in-memory fields for Tenancies; no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more field, markers (markerRetry: an atomic running flag and the last log time) for retryOwedMarkers; no read added; merge of origin/main d7ae1d76: main's fields are kept as main has them (census-ruling-remote-instance-metrics: tenancySeq, hostTenants, hostMixed); this branch's change is the same as above;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: new fields for rootfs admission (rootfsArmed, rootfsSwept), the per-host gate ask and refusal memo, and residency state (lister, backoff, start ceiling, cursor, test seam); no read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: one new field, releaseOps (host to the in-memory release record, under a.mu); no read;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W: one new field, leaseNow (a clock seam for a worker start's headroom against the lease deadline, nil is the real clock); no read;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: gains the holder cache and its single-flight state; no read |
| - `internal/activator/backend_rootfs.go` `ExecBackend.StartRelease`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R, R1: new; startRootfsCmd naming release.ProcessRelease, both streams through one capped line writer (releaseOutput, runs.MaxOutputBytes) into the caller's writer; no read of its own |
| - `internal/activator/cmdunit.go` `type CmdSpec`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): declaration only; Prepare is a callback field, not a prepared statement |
| - `internal/activator/prepare.go` `ExecBackend.prepareKeyedAt`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/activator/rootfs_service.go` `Service.residentLeaseLost`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8 (C7): a resident's lost lease marks it and then kills its generations off a.mu (killResidentGens);rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.10: a resident's lost lease stops its workers (stopRootfsWorkersAtLoss, proven gone) in parallel with killResidentGens; rt is taken under the lock and passed to killResidentGens in place of e.route (the same route); site +whole:Route (that local rt); no file read |
| +- `internal/activator/rootfsrelease.go` `Service.releaseAdmitLocked`: legacy, task accepted-legacy. Basis: 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 |
| +- `internal/activator/rootfsrelease.go` `Service.runRelease`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/host/runexec.go` `runsWorker.execute`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/host/units/carlos-instance-cmd@.service` `external`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/host/units/carlos-instance-gen@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input |
| @@ -64,6 +71,7 @@ Recorded dispositions, which each change must still satisfy: |
| - `internal/instanceexec/probe.go` `productionProbeEnv`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=the binary probe's env gains boxAddrs (instancectl.BoxAddrsPath, /opt/carlos/box-addrs), which boxAddrClosed (a decision row) reads inside the probe unit, and mmapWX (realMmapWX, an anonymous mapping); the same one direct site |
| - `internal/layout/plan.go` `NestedPlatformNames`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, called only from the agent's offline sealer and source retire (IsNestedPlatformName): a fixed list of names, reads nothing |
| - `internal/provision/reconcile.go` `Reconcile`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write. |
| +- `internal/provision/seed.go` `SeedAbortBecause`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-seeded-instances;basis=the console (cmd/console serve under console.service, user carlos-console): the record transition the --from door aborts a seed with, recording its reason |
| - `internal/activator/backend_rootfs.go` `ExecBackend.startRootfsCmd`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/activator/cmd.go` `Service.RunCmd`: legacy, task accepted-legacy. Basis: 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 |
| - `internal/activator/cmdunit.go` `ExecBackend.StartCmd`: legacy, task accepted-legacy. Basis: 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 |
| @@ -90,6 +98,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - new `internal/instanceexec/tty_linux.go:receivePTY`: reads +file:Fstat; written legacy, accepted-legacy, frozen |
| - reads `internal/activator/cmdunit.go:cmdUnit.StopAndSettle`: +registry:Host, +whole:Route; keeps legacy, task accepted-legacy |
| -Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `b36c59a06b5a30cbcddce32c5843f8ba76bfca5e37e119c8562e313d1500d5f2`. |
| +Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `1dca4fb512d2fae76fd23a4a36fbf50402eaa6a9223a025ad17d91c5cbedb682`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/activator/activator.go b/internal/activator/activator.go| index 3c370c16a..36e0310a2 100644 |
| --- a/internal/activator/activator.go |
| +++ b/internal/activator/activator.go |
| @@ -497,15 +497,18 @@ type actEntry struct { |
| // awake transition, closed by finishStop as the entry is forgotten. |
| // Under a.mu. |
| ownerDone chan struct{} |
| - // leaseStops counts the lease-loss and lease-short one-shot stops |
| + // leaseStops counts, per one-shot role (instancectl.RoleCmd, |
| + // instancectl.RoleTTY), the lease-loss and lease-short one-shot stops |
| // captured for this entry (stopOneShotsAtLeaseLocked) that have not |
| // returned. While any is outstanding the entry is not released |
| - // (finishStop keeps its stop pending, the lease held) and takes no new |
| - // run or release command (cmdBusyLocked): a kill names its unit by host |
| - // and role only, so it is bound to the command it was issued for by |
| - // keeping the unit unused until it has returned (Plan 6 Task 7a, fix |
| - // round 1). Under a.mu. |
| - leaseStops int |
| + // (finishStop keeps its stop pending, the lease held), and while one of |
| + // a role is, the entry takes no new command of that role: no run or |
| + // release command for the cmd unit, no session for the tty unit |
| + // (holdBusyLocked). A kill names its unit by host and role only, so it |
| + // is bound to the command it was issued for by keeping that unit |
| + // unused until it has returned (Plan 6 Task 7a, fix round 1; Task 9). |
| + // Written through addLeaseStop. Under a.mu. |
| + leaseStops map[instancectl.Role]int |
| // ownerKilled: the tick's second-line lease check (rootfsTick) has |
| // already killed this unwatched rootfs entry's one-shot units and, a |
| // resident, its generations. Under a.mu. |
| @@ -554,9 +557,15 @@ type actEntry struct { |
| // replication closes, and a unit not proven settled keeps the stop |
| // pending with replication and the lease held (merge ruling M1). |
| cmd *cmdHold |
| - // cmdLeft holds runs released before their unit was proven settled |
| - // (cmdRun.Release): their Stop failed or never came. finishStop settles |
| - // them as it does cmd, before replication closes. Written under a.mu. |
| + // tty is the session attached to this instance (rootfs apps Plan 6 |
| + // Task 9), held exactly as cmd is, beside it: a run and a session |
| + // coexist, each in its own unit. Written under a.mu. |
| + tty *cmdHold |
| + // cmdLeft holds runs and sessions released before their unit was |
| + // proven settled (cmdRun.Release): their Stop failed or never came. |
| + // finishStop settles them as it does cmd and tty, before replication |
| + // closes. Each counts against its own role only (holdBusyLocked). |
| + // Written under a.mu. |
| cmdLeft []*cmdHold |
| sidecarUncertain bool |
| @@ -3101,8 +3110,10 @@ func (a *Service) beginStopLocked(e *actEntry, why string) { |
| } |
| e.state = actStopping |
| e.stopWhy = why |
| - if e.cmd != nil { |
| - e.cmd.cancelPrepare() // a stop interrupts a run's download |
| + for _, h := range []*cmdHold{e.cmd, e.tty} { |
| + if h != nil && h.cancelPrepare != nil { |
| + h.cancelPrepare() // a stop interrupts a run's or a session's download |
| + } |
| } |
| // A release command this entry owns is cancelled, so runRelease stops |
| // and settles its unit at once (Group R, INV-R1). The stop keeps the |
| @@ -4872,7 +4883,7 @@ func (a *Service) finishStop(e *actEntry, outcome *stopObservation) { |
| // that unit, until it has. |
| a.mu.Lock() |
| workersLive := rootfsWorkersLiveLocked(e) |
| - leaseStops := e.leaseStops |
| + leaseStops := pendingLeaseStopsLocked(e) |
| if workersLive || leaseStops > 0 { |
| a.keepPendingLocked(e, outcome) |
| } |
| @@ -5170,7 +5181,7 @@ func (a *Service) sweepOnce() { |
| // A worker a lapse turned off (plans 4d) is not restarted: it |
| // stands down, as a finished one does. Never mid-command, never a |
| // move's active probe. |
| - if e.worker && e.cmd == nil && !activeProbe(e) && a.disabled(e.route) { |
| + if e.worker && !holdsAttachedLocked(e) && !activeProbe(e) && a.disabled(e.route) { |
| log.Printf("activator: sidecar %s exited and was turned off by its plan — not restarting", e.host) |
| a.beginStopLocked(e, StopExited) |
| continue |
| @@ -5214,7 +5225,7 @@ func (a *Service) sweepOnce() { |
| // Nor while a release command of the host is open (Group R): the |
| // stop waits for the first sweep after its record goes. |
| releasing := a.releaseOps[e.host] != nil |
| - if !activeProbe(e) && e.cmd == nil && !releasing && a.disabled(e.route) { |
| + if !activeProbe(e) && !holdsAttachedLocked(e) && !releasing && a.disabled(e.route) { |
| log.Printf("activator: %s was turned off by its plan — stopping", e.host) |
| a.beginStopLocked(e, StopIdle) |
| continue |
| @@ -5244,7 +5255,7 @@ func (a *Service) sweepOnce() { |
| // An instance whose release command is open is never idle (Group R, |
| // C8): a hibernating incumbent keeps serving through an overlap |
| // migration. |
| - if hibernates && e.inflight == 0 && e.cmd == nil && !releasing && now.Sub(e.lastActive) >= idleWindow { |
| + if hibernates && e.inflight == 0 && !holdsAttachedLocked(e) && !releasing && now.Sub(e.lastActive) >= idleWindow { |
| // Don't sleep into an imminent tick. A wake/sleep pair is a full |
| // checkpoint-and-restore round trip; spending one to be absent |
| // for less time than we would have idled anyway is a straight |
| @@ -5294,7 +5305,7 @@ func (a *Service) sweepOnce() { |
| // in flight, and wakes on its next request. Never a worker, and |
| // never mid-command or mid-release: it fires on the first sweep |
| // after the release's record goes. |
| - if f := a.maxRunFor.Load(); f != nil && !e.worker && hibernates && e.cmd == nil && !releasing { |
| + if f := a.maxRunFor.Load(); f != nil && !e.worker && hibernates && !holdsAttachedLocked(e) && !releasing { |
| if d := (*f)(e.route); d > 0 && now.Sub(e.spawnedAt) >= d { |
| log.Printf("activator: %s awake %s, past its plan's ceiling of %s — stopping", e.host, now.Sub(e.spawnedAt).Truncate(time.Second), d) |
| a.beginStopLocked(e, StopIdle) |
diff --git a/internal/activator/cmd.go b/internal/activator/cmd.go| index c12b8252d..a2b8a64ca 100644 |
| --- a/internal/activator/cmd.go |
| +++ b/internal/activator/cmd.go |
| @@ -35,6 +35,12 @@ var ErrCmdClaim = errors.New("activator: claim control is armed; runs wait for t |
| // run's unit was never proven settled. |
| var ErrCmdBusy = errors.New("activator: a run is already attached to this instance") |
| +// ErrTTYBusy: a session is already attached to the instance, or an |
| +// earlier session's unit was never proven settled, or a lease stop of the |
| +// tty unit has not returned (rootfs apps Plan 6 Task 9). A run beside it |
| +// is never a reason: the session has its own unit. |
| +var ErrTTYBusy = errors.New("activator: a session is already attached to this instance") |
| + |
| // 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") |
| @@ -72,7 +78,8 @@ const cmdStopBound = 2 * time.Minute |
| // stop waiting on the start still has the settle's budget after it. |
| const cmdStartBound = 45 * time.Second |
| -// CmdHandle is a started run, as the box's run pass sees it. |
| +// CmdHandle is a started run, as the box's run pass sees it, or a started |
| +// session (CmdSpec.TTY), as the box's session pass sees it. |
| type CmdHandle interface { |
| Invocation() string |
| Poll(ctx context.Context) (instancectl.CmdStatus, error) |
| @@ -86,11 +93,21 @@ type CmdHandle interface { |
| Stop(ctx context.Context) error |
| // Release clears the run from the entry once its result is written. |
| Release() |
| + // Terminal is the started unit's terminal (CmdUnit.Terminal): a |
| + // session's pty master, nil for a run. |
| + Terminal() Terminal |
| } |
| -// cmdHold is the entry's cmd field. |
| +// cmdHold is one command of the entry: a run (the entry's cmd field), a |
| +// session (its tty field), or a release command (releaseOp.hold). |
| type cmdHold struct { |
| runID string |
| + // role is the unit the hold's command runs in: instancectl.RoleCmd for |
| + // a run or a release command, instancectl.RoleTTY for a session (rootfs |
| + // apps Plan 6 Task 9). It picks the entry's slot, the busy check that |
| + // counts the hold, and the unit a lease kill names. Set at construction |
| + // and never written again. |
| + role instancectl.Role |
| // starting is set under a.mu by RunCmd's last awake check: from then |
| // on a stop waits for the start. Before it, a stop does not wait: the |
| // check will see the entry stopping and abandon the run. |
| @@ -153,10 +170,24 @@ type cmdSettle struct { |
| err error |
| } |
| -func newCmdHold(runID string, cancelPrepare context.CancelFunc, now func() time.Time) *cmdHold { |
| - return &cmdHold{runID: runID, cancelPrepare: cancelPrepare, now: now, started: make(chan struct{})} |
| +func newCmdHold(runID string, role instancectl.Role, cancelPrepare context.CancelFunc, now func() time.Time) *cmdHold { |
| + return &cmdHold{runID: runID, role: role, cancelPrepare: cancelPrepare, now: now, started: make(chan struct{})} |
| } |
| +// holdSlot is e's attached hold of role: its tty field for a session, its |
| +// cmd field otherwise. The caller holds a.mu. |
| +func holdSlot(e *actEntry, role instancectl.Role) **cmdHold { |
| + if role == instancectl.RoleTTY { |
| + return &e.tty |
| + } |
| + return &e.cmd |
| +} |
| + |
| +// holdsAttachedLocked reports whether a run or a session is attached to e: |
| +// while one is, the idle sweep, the plans ceiling and the plans turned-off |
| +// stop leave e alone (PF-18). The caller holds a.mu. |
| +func holdsAttachedLocked(e *actEntry) bool { return e.cmd != nil || e.tty != nil } |
| + |
| // stop waits for the start to return, records reason and the time if it is |
| // the first stop asked for (the run's own Stop passes "", so an instance |
| // stop after it is not what ended the run), and stops and settles the unit. |
| @@ -279,18 +310,25 @@ func (r *cmdRun) Interrupted() (string, time.Time) { |
| return r.h.reason, r.h.askedAt |
| } |
| func (r *cmdRun) Stop(ctx context.Context) error { return r.h.stop(ctx, "") } |
| +func (r *cmdRun) Terminal() Terminal { |
| + if r.h.unit == nil { |
| + return nil |
| + } |
| + return r.h.unit.Terminal() |
| +} |
| -// Release clears the hold and stamps activity, so the instance idles a |
| -// full window after a run rather than hibernating at the next sweep. A |
| -// unit not proven settled (its Stop failed or never came) stays the |
| -// instance's: the next stop settles it before replication closes, and |
| -// keeps replication and the lease until it has (run spec §5.3, codex 1; |
| -// merge ruling M1). |
| +// Release clears the hold from its own slot (a run's or a session's) and |
| +// stamps activity, so the instance idles a full window after a run rather |
| +// than hibernating at the next sweep. A unit not proven settled (its Stop |
| +// failed or never came) stays the instance's: the next stop settles it |
| +// before replication closes, and keeps replication and the lease until it |
| +// has (run spec §5.3, codex 1; merge ruling M1). The other slot's hold is |
| +// never touched. |
| func (r *cmdRun) Release() { |
| r.once.Do(func() { |
| r.a.mu.Lock() |
| - if r.e.cmd == r.h { |
| - r.e.cmd = nil |
| + if slot := holdSlot(r.e, r.h.role); *slot == r.h { |
| + *slot = nil |
| r.e.lastActive = r.a.now() |
| if !r.h.provenSettled() { |
| r.e.cmdLeft = append(r.e.cmdLeft, r.h) |
| @@ -300,57 +338,90 @@ func (r *cmdRun) Release() { |
| }) |
| } |
| -// cmdBusyLocked reports whether e cannot take a run (or, for Group R, a |
| -// release command): one is attached, an earlier one's unit was never |
| -// proven settled, or a lease stop captured for e has not returned. It drops the released |
| -// holds that have since settled. The caller holds a.mu. |
| -func cmdBusyLocked(e *actEntry) bool { |
| +// holdBusyLocked reports whether e's role unit cannot take a new command: |
| +// for instancectl.RoleCmd a run (or, for Group R, a release command), for |
| +// instancectl.RoleTTY a session. It is busy when that role's hold is |
| +// attached, an earlier hold of that role was never proven settled, or a |
| +// lease stop of that role's unit captured for e has not returned. Only |
| +// role's holds and stops count: a session never makes the cmd unit busy, |
| +// nor a run the tty unit (rootfs apps Plan 6 Task 9, PF-17). It drops the |
| +// released holds, of either role, that have since settled. The caller |
| +// holds a.mu. |
| +func holdBusyLocked(e *actEntry, role instancectl.Role) bool { |
| left := e.cmdLeft[:0] |
| + busy := false |
| for _, h := range e.cmdLeft { |
| if !h.provenSettled() { |
| left = append(left, h) |
| + busy = busy || h.role == role |
| } |
| } |
| clear(e.cmdLeft[len(left):]) |
| e.cmdLeft = left |
| // A lease stop captured for e that has not returned may still kill |
| - // the cmd unit by its name: nothing new uses that unit until it has |
| + // role's unit by its name: nothing new uses that unit until it has |
| // (Plan 6 Task 7a fix round 1). |
| - return e.cmd != nil || len(left) > 0 || e.leaseStops > 0 |
| + return *holdSlot(e, role) != nil || busy || e.leaseStops[role] > 0 |
| } |
| -// cmdHoldsLocked is every run of e whose unit may still be running: the |
| -// released runs not proven settled, and the attached run once it is |
| -// starting. An attached run not yet starting is not one: RunCmd's last |
| -// awake check sees a stop and abandons it before any unit starts. The |
| -// caller holds a.mu. |
| -func cmdHoldsLocked(e *actEntry) []*cmdHold { |
| +// addLeaseStop counts d more lease stops of role's unit on e |
| +// (stopOneShotsAtLeaseLocked). The caller holds a.mu. |
| +func (e *actEntry) addLeaseStop(role instancectl.Role, d int) { |
| + if e.leaseStops == nil { |
| + e.leaseStops = map[instancectl.Role]int{} |
| + } |
| + e.leaseStops[role] += d |
| +} |
| + |
| +// pendingLeaseStopsLocked is every lease stop of e, of either role, that |
| +// has not returned: finishStop keeps e's stop pending while there is one. |
| +// The caller holds a.mu. |
| +func pendingLeaseStopsLocked(e *actEntry) int { |
| + n := 0 |
| + for _, c := range e.leaseStops { |
| + n += c |
| + } |
| + return n |
| +} |
| + |
| +// holdsLocked is every run and session of e whose unit may still be |
| +// running: the released ones not proven settled, of either role, and the |
| +// attached run and session once each is starting. An attached hold not |
| +// yet starting is not one: RunCmd's last awake check sees a stop and |
| +// abandons it before any unit starts. The caller holds a.mu. |
| +func holdsLocked(e *actEntry) []*cmdHold { |
| var holds []*cmdHold |
| for _, h := range e.cmdLeft { |
| if !h.provenSettled() { |
| holds = append(holds, h) |
| } |
| } |
| - if e.cmd != nil && e.cmd.starting && !e.cmd.provenSettled() { |
| - holds = append(holds, e.cmd) |
| + for _, h := range []*cmdHold{e.cmd, e.tty} { |
| + if h != nil && h.starting && !h.provenSettled() { |
| + holds = append(holds, h) |
| + } |
| } |
| return holds |
| } |
| -// cmdStartInFlightLocked reports whether e's run has passed RunCmd's last |
| -// check and its StartCmd has not returned: a unit may be starting against |
| -// e's current generation right now. An overlap swap is not admitted, and |
| -// does not switch, while one is (merge ruling M2). The caller holds a.mu. |
| +// cmdStartInFlightLocked reports whether e's run or session has passed |
| +// RunCmd's last check and its StartCmd has not returned: a unit may be |
| +// starting against e's current generation right now. An overlap swap is |
| +// not admitted, and does not switch, while one is (merge ruling M2); a |
| +// session execs its generation's build as a run does. The caller holds |
| +// a.mu. |
| func cmdStartInFlightLocked(e *actEntry) bool { |
| - if e.cmd == nil || !e.cmd.starting { |
| - return false |
| - } |
| - select { |
| - case <-e.cmd.started: |
| - return false |
| - default: |
| - return true |
| + for _, h := range []*cmdHold{e.cmd, e.tty} { |
| + if h == nil || !h.starting { |
| + continue |
| + } |
| + select { |
| + case <-h.started: |
| + default: |
| + return true |
| + } |
| } |
| + return false |
| } |
| // switchPendingLocked is a live overlap successor of e: a member spawning |
| @@ -393,15 +464,15 @@ func cmdOwnershipLocked(a *Service, e *actEntry) string { |
| // besides the successor's own done. |
| var cmdSwitchPoll = 100 * time.Millisecond |
| -// interruptCmdsLocked interrupts every run of e admitted against |
| -// generation n, which is retiring (merge ruling M2): each unit is stopped |
| -// and settled off a.mu, and the run learns why, which the member reads as |
| -// interrupted (exit 125, RUN-C75). A settle that fails leaves the run |
| -// unproven: its own Stop or the instance's next stop tries again, and the |
| -// generations file keeps naming n's build until one succeeds. The caller |
| -// holds a.mu. |
| +// interruptCmdsLocked interrupts every run and session of e admitted |
| +// against generation n, which is retiring (merge ruling M2): each unit is |
| +// stopped and settled off a.mu, and the command learns why, which the |
| +// member reads as interrupted (exit 125, RUN-C75). A settle that fails |
| +// leaves the hold unproven: its own Stop or the instance's next stop |
| +// tries again, and the generations file keeps naming n's build until one |
| +// succeeds. The caller holds a.mu. |
| func (a *Service) interruptCmdsLocked(e *actEntry, n uint64, why string) { |
| - for _, h := range cmdHoldsLocked(e) { |
| + for _, h := range holdsLocked(e) { |
| if h.gen.N != n { |
| continue |
| } |
| @@ -416,14 +487,16 @@ func (a *Service) interruptCmdsLocked(e *actEntry, n uint64, why string) { |
| } |
| // oneShotHoldsLocked reports whether a one-shot unit of e may be running: |
| -// a run's (cmdHoldsLocked). Task 9 adds a session's. The caller holds a.mu. |
| +// a run's or a session's (holdsLocked). The caller holds a.mu. |
| func oneShotHoldsLocked(e *actEntry) bool { |
| - return len(cmdHoldsLocked(e)) > 0 |
| + return len(holdsLocked(e)) > 0 |
| } |
| // stopOneShotsAtLeaseLocked is a rootfs instance's lease reaching its |
| // one-shot units (rootfs apps Plan 6 Task 7a, Call A1; C7): one func per |
| -// hold of e that may be running, for the caller to run off a.mu. With kill |
| +// hold of e that may be running, of either role (a run's cmd unit, a |
| +// session's tty unit: Task 9, PF-3), each naming its own hold's role and |
| +// no other, for the caller to run off a.mu. With kill |
| // false (residentLeaseShort, while a drain still fits) each stops its run |
| // (StopLeaseLost), bounded by cmdStopBound. With kill true (the loss |
| // itself: residentLeaseLostLocked, and the tick's fallback) root kills the |
| @@ -433,11 +506,13 @@ func oneShotHoldsLocked(e *actEntry) bool { |
| // still keeps the lease until the hold is proven (settleCmds). Nothing for |
| // a binary row, which holds no resident lease. |
| // |
| -// Each func is counted on e (e.leaseStops) from the moment it is captured |
| -// until it returns, so its kill, which names the unit by host and role |
| -// only, can never reach another command (fix round 1): while it is |
| -// outstanding e is not released (finishStop keeps the stop pending, the |
| -// lease held) and takes no new run or release command (cmdBusyLocked). |
| +// Each func is counted on e, under its hold's role (e.leaseStops), from |
| +// the moment it is captured until it returns, so its kill, which names the |
| +// unit by host and role only, can never reach another command (fix round |
| +// 1): while it is outstanding e is not released (finishStop keeps the stop |
| +// pending, the lease held) and takes no new command of that role: no run |
| +// or release command for the cmd unit, no session for the tty unit |
| +// (holdBusyLocked). |
| // finishStop is the only release of an entry that held a run, so no other |
| // entry, and no other command of the unit, can exist on this box until the |
| // kill has returned. |
| @@ -456,15 +531,15 @@ func (a *Service) stopOneShotsAtLeaseLocked(e *actEntry, rt registry.Route, kill |
| return nil |
| } |
| var out []func() |
| - for _, h := range cmdHoldsLocked(e) { |
| - e.leaseStops++ |
| + for _, h := range holdsLocked(e) { |
| + e.addLeaseStop(h.role, 1) |
| out = append(out, func() { |
| defer func() { |
| a.mu.Lock() |
| - e.leaseStops-- |
| + e.addLeaseStop(h.role, -1) |
| a.mu.Unlock() |
| }() |
| - a.stopOneShotAtLease(rt, h, instancectl.RoleCmd, kill) |
| + a.stopOneShotAtLease(rt, h, h.role, kill) |
| }) |
| } |
| return out |
| @@ -549,24 +624,28 @@ func (a *Service) oneShotHeadroom(rep Rep) error { |
| return nil |
| } |
| -// retryCmdSettlesLocked is the sweep's retry of every run of e whose stop |
| -// was asked for and is not proven (re-review 6): a run interrupted when a |
| -// swap retired its generation, a run whose own Stop failed, and a released |
| -// run left unsettled. It runs whatever state e is in, pending stop or |
| -// awake, so an instance that stays awake still gets its runs proven, their |
| -// pins dropped and later runs admitted. Each attempt runs off a.mu, one at |
| -// a time per run, actStopTimeout apart. The caller holds a.mu. |
| +// retryCmdSettlesLocked is the sweep's retry of every run and session of |
| +// e whose stop was asked for and is not proven (re-review 6): one |
| +// interrupted when a swap retired its generation, one whose own Stop |
| +// failed, and a released one left unsettled. It runs whatever state e is |
| +// in, pending stop or awake, so an instance that stays awake still gets |
| +// its commands proven, their pins dropped and later ones admitted. Each |
| +// attempt runs off a.mu, one at a time per hold, actStopTimeout apart. The |
| +// caller holds a.mu. |
| func (a *Service) retryCmdSettlesLocked(e *actEntry) { |
| for _, h := range e.cmdLeft { |
| h.retrySettle(true, actStopTimeout) |
| } |
| - if e.cmd != nil && e.cmd.starting { |
| - e.cmd.retrySettle(false, actStopTimeout) |
| + for _, h := range []*cmdHold{e.cmd, e.tty} { |
| + if h != nil && h.starting { |
| + h.retrySettle(false, actStopTimeout) |
| + } |
| } |
| } |
| -// settleCmds is a run's part of an instance's termination proof (run spec |
| -// §5.3; merge ruling M1): every run of e whose unit may still be running is |
| +// settleCmds is a run's and a session's part of an instance's termination |
| +// proof (run spec §5.3; merge ruling M1): every run and session of e whose |
| +// unit may still be running is |
| // stopped and settled, bounded by cmdStopBound, and it reports whether none |
| // may be running now. Proven means the unit stopped and its cgroup is empty |
| // (cmdUnit.StopAndSettle). A settle that fails is not given up on: the stop |
| @@ -574,7 +653,7 @@ func (a *Service) retryCmdSettlesLocked(e *actEntry) { |
| // pass calls this again (finishPendingStops). Never call it with a.mu held. |
| func (a *Service) settleCmds(e *actEntry) bool { |
| a.mu.Lock() |
| - holds, why := cmdHoldsLocked(e), e.stopWhy |
| + holds, why := holdsLocked(e), e.stopWhy |
| a.mu.Unlock() |
| if len(holds) == 0 { |
| return true |
| @@ -591,7 +670,8 @@ func (a *Service) settleCmds(e *actEntry) bool { |
| return proven |
| } |
| -// RunCmd runs one command against rt's instance (run spec §5.2 and §5.3): |
| +// RunCmd runs one command against rt's instance (run spec §5.2 and §5.3), |
| +// or opens one session (spec.TTY set, rootfs apps Plan 6 Task 9): |
| // refused with claim control armed, for anything but an instance, or on a |
| // layout other than nested; the instance woken through the ordinary wake |
| // path, waiting up to 60 s; the run attached to the awake entry; |
| @@ -602,6 +682,11 @@ func (a *Service) settleCmds(e *actEntry) bool { |
| // finishStop for the start to return and then stops the unit before |
| // replication closes. |
| // |
| +// A run takes the entry's cmd slot and a session its tty slot: each is |
| +// refused only for its own slot (ErrCmdBusy, ErrTTYBusy; holdBusyLocked), |
| +// so a run and a session of one instance coexist. A release command holds |
| +// the cmd unit, so it refuses a run and never a session (PF-17). |
| +// |
| // ctx is the run's own: its deadline and cancellation span the whole |
| // admission, the wake, Prepare, any wait for a swap's switch and the last |
| // checks (re-review 5). A run whose ctx ends before the start returns |
| @@ -647,9 +732,13 @@ func (a *Service) RunCmd(ctx context.Context, rt registry.Route, spec CmdSpec) ( |
| } |
| return refuse(&CmdWakeError{Reason: memberSafeWakeReason(err), Err: err}) |
| } |
| + role, busyErr := instancectl.RoleCmd, ErrCmdBusy |
| + if spec.TTY != nil { |
| + role, busyErr = instancectl.RoleTTY, ErrTTYBusy |
| + } |
| pctx, pcancel := context.WithCancel(ctx) |
| defer pcancel() |
| - h := newCmdHold(spec.RunID, pcancel, a.now) |
| + h := newCmdHold(spec.RunID, role, pcancel, a.now) |
| h.afterSettled = spec.AfterSettled |
| a.mu.Lock() |
| e := a.entries[rt.Host] |
| @@ -666,15 +755,15 @@ func (a *Service) RunCmd(ctx context.Context, rt registry.Route, spec CmdSpec) ( |
| a.mu.Unlock() |
| release() |
| return refuse(ErrCmdNotInstance) |
| - case cmdBusyLocked(e), a.releaseOps[rt.Host] != nil: |
| + 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 |
| - // asked, never an entry field. |
| + // asked, never an entry field. A session's tty unit is its own. |
| a.mu.Unlock() |
| release() |
| - return refuse(ErrCmdBusy) |
| + return refuse(busyErr) |
| } |
| - e.cmd = h |
| + *holdSlot(e, role) = h |
| a.mu.Unlock() |
| release() // the hold, not the in-flight count, keeps the idle timer off now |
| run := &cmdRun{a: a, e: e, h: h} |
diff --git a/internal/activator/cmd_swap_test.go b/internal/activator/cmd_swap_test.go| index 2e066f9a4..5dc2e1826 100644 |
| --- a/internal/activator/cmd_swap_test.go |
| +++ b/internal/activator/cmd_swap_test.go |
| @@ -19,6 +19,7 @@ type cmdSwapBackend struct { |
| *fakeSwapBackend |
| cmu sync.Mutex |
| unit *fakeCmdUnit |
| + ttyUnit *fakeCmdUnit // a session's (spec.TTY set) unit |
| specs []CmdSpec |
| gate chan struct{} // when set, StartCmd blocks until it closes |
| entered chan struct{} // when set, closed as StartCmd is entered |
| @@ -42,6 +43,9 @@ func (b *cmdSwapBackend) StartCmd(_ context.Context, _ registry.Route, spec CmdS |
| b.cmu.Lock() |
| defer b.cmu.Unlock() |
| b.specs = append(b.specs, spec) |
| + if spec.TTY != nil { |
| + return b.ttyUnit, nil |
| + } |
| return b.unit, nil |
| } |
| @@ -55,7 +59,7 @@ func newCmdSwapFixture(t *testing.T) (*swapFixture, *cmdSwapBackend) { |
| t.Helper() |
| var cb *cmdSwapBackend |
| f := newSwapFixtureOn(t, func(b *fakeSwapBackend) Backend { |
| - cb = &cmdSwapBackend{fakeSwapBackend: b, unit: &fakeCmdUnit{}} |
| + cb = &cmdSwapBackend{fakeSwapBackend: b, unit: &fakeCmdUnit{}, ttyUnit: &fakeCmdUnit{term: &fakeTerminal{}}} |
| return cb |
| }) |
| f.b.layoutFn = func(registry.Route) (Layout, string) { return LayoutNested, "" } |
| @@ -551,3 +555,97 @@ func TestARunWhoseBuildRecordFailsOrIsOvertakenNeverStarts(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +// Rootfs apps Plan 6 Task 9: a session on a generation a swap retires is |
| +// interrupted and settled as a run is (interruptCmdsLocked), and reads |
| +// why. Its interruption's settle fails once: the retired build stays |
| +// pinned in the generations file, a run is still admitted beside it (the |
| +// session holds the tty unit, not the cmd unit), and the sweeps alone |
| +// retry the settle while the instance stays awake, prove it and drop the |
| +// pin. The cmd unit is never touched. |
| +func TestASessionIsInterruptedWhenItsGenerationRetires(t *testing.T) { |
| + t.Parallel() |
| + f, cb := newCmdSwapFixture(t) |
| + path := release.GenerationsPath(t.TempDir()) |
| + f.a.GenerationsFile = path |
| + cb.ttyUnit.setSettleErr(errors.New("instance control: 502 mid-roll")) |
| + h, err := f.a.RunCmd(context.Background(), testRoute(f.host), sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if g := f.a.runGenOf(h); g.N != f.incumbent.N { |
| + t.Fatalf("the session was admitted against %+v, want the incumbent", g) |
| + } |
| + at := f.attempt(ModeOverlap) |
| + at.Cause = CauseRelease |
| + if res := f.a.Swap(context.Background(), at, f.newest); res.Outcome != SwapDone { |
| + t.Fatalf("Swap = %+v", res) |
| + } |
| + waitFor(t, "the interruption's failed stop", func() bool { |
| + n, _ := cb.ttyUnit.stopped() |
| + return n == 1 && h.(*cmdRun).h.settlingDone() |
| + }) |
| + if why, at := h.Interrupted(); why != StopRelease || at.IsZero() { |
| + t.Fatalf("Interrupted() = %q at %v, want %q", why, at, StopRelease) |
| + } |
| + pinned := func() bool { |
| + if err := f.a.persistGenerations(); err != nil { |
| + t.Fatal(err) |
| + } |
| + return slices.Contains(readPinPaths(t, path, f.host), f.incumbent.StagedPath) |
| + } |
| + if !pinned() { |
| + t.Fatal("the retired build lost its pin while its session was unproven") |
| + } |
| + run, err := f.a.RunCmd(context.Background(), testRoute(f.host), CmdSpec{RunID: "run_b"}) |
| + if err != nil { |
| + t.Fatalf("a run beside the unproven session: %v", err) |
| + } |
| + if err := run.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + run.Release() |
| + cb.ttyUnit.setSettleErr(nil) |
| + f.clk.advance(actStopTimeout) |
| + f.a.sweepOnce() |
| + waitFor(t, "the sweep's retry proving the session stopped", func() bool { return h.(*cmdRun).h.provenSettled() }) |
| + waitFor(t, "the pin released", func() bool { return !pinned() }) |
| + if f.a.entryCount() != 1 { |
| + t.Fatal("interrupting the session stopped the instance") |
| + } |
| + if n, _ := cb.unit.stopped(); n != 1 { |
| + t.Fatalf("the cmd unit was stopped %d times, want once (the run's own Stop)", n) |
| + } |
| + h.Release() |
| +} |
| + |
| +// A session's start in flight refuses an overlap swap's admission, as a |
| +// run's does (merge ruling M2): the session execs its generation's build. |
| +func TestASessionStartInFlightRefusesAnOverlapSwap(t *testing.T) { |
| + f, cb := newCmdSwapFixture(t) |
| + cb.gate, cb.entered = make(chan struct{}), make(chan struct{}) |
| + entered := cb.entered |
| + type ran struct { |
| + h CmdHandle |
| + err error |
| + } |
| + done := make(chan ran, 1) |
| + go func() { |
| + h, err := f.a.RunCmd(context.Background(), testRoute(f.host), sessionSpec("ses_a")) |
| + done <- ran{h, err} |
| + }() |
| + <-entered |
| + res := f.a.Swap(context.Background(), f.attempt(ModeOverlap), f.newest) |
| + if res.Outcome != SwapAbandoned || !strings.Contains(res.Reason, errSwapBusy.Error()) || res.Executed { |
| + t.Fatalf("Swap during the session's start = %+v, want abandoned as busy with nothing run", res) |
| + } |
| + close(cb.gate) |
| + r := <-done |
| + if r.err != nil { |
| + t.Fatal(r.err) |
| + } |
| + if err := r.h.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.h.Release() |
| +} |
diff --git a/internal/activator/cmd_test.go b/internal/activator/cmd_test.go| index 25711d849..83bc7f899 100644 |
| --- a/internal/activator/cmd_test.go |
| +++ b/internal/activator/cmd_test.go |
| @@ -47,6 +47,7 @@ type fakeCmdUnit struct { |
| settleErr error |
| rep func() *fakeRep |
| status instancectl.CmdStatus |
| + term Terminal // a session's unit's terminal; nil for a run's |
| } |
| func (u *fakeCmdUnit) Invocation() string { return "inv1" } |
| @@ -55,7 +56,7 @@ func (u *fakeCmdUnit) Poll(context.Context) (instancectl.CmdStatus, error) { |
| defer u.mu.Unlock() |
| return u.status, nil |
| } |
| -func (u *fakeCmdUnit) Terminal() Terminal { return nil } |
| +func (u *fakeCmdUnit) Terminal() Terminal { return u.term } |
| func (u *fakeCmdUnit) StopAndSettle(context.Context) error { |
| u.mu.Lock() |
| defer u.mu.Unlock() |
| @@ -77,11 +78,28 @@ func (u *fakeCmdUnit) stopped() (int, bool) { |
| return u.stops, u.repWasClosed |
| } |
| +// fakeTerminal is a session unit's terminal for the fakes: it is only |
| +// ever compared, never read. |
| +type fakeTerminal struct{} |
| + |
| +func (*fakeTerminal) Read([]byte) (int, error) { return 0, errors.New("fake terminal") } |
| +func (*fakeTerminal) Write(p []byte) (int, error) { return len(p), nil } |
| +func (*fakeTerminal) Resize(uint16, uint16) error { return nil } |
| +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}} |
| +} |
| + |
| // cmdFakeBackend is fakeBackend with the run capability and a nested layout. |
| +// A session's start (spec.TTY set) returns ttyUnit, a run's unit. |
| type cmdFakeBackend struct { |
| *fakeBackend |
| cmdMu sync.Mutex |
| unit *fakeCmdUnit |
| + ttyUnit *fakeCmdUnit |
| + ttyStarts int |
| startErr error |
| cmdStarts int |
| gate chan struct{} // when set, StartCmd blocks until it closes |
| @@ -106,13 +124,18 @@ func (b *cmdFakeBackend) StartCmd(ctx context.Context, rt registry.Route, spec C |
| if b.startCmd != nil { |
| return b.startCmd(ctx, rt, spec) |
| } |
| + unit := b.unit |
| + if spec.TTY != nil { |
| + b.ttyStarts++ |
| + unit = b.ttyUnit |
| + } |
| if b.startErr != nil { |
| if b.errWithUnit { |
| - return b.unit, b.startErr |
| + return unit, b.startErr |
| } |
| return nil, b.startErr |
| } |
| - return b.unit, nil |
| + return unit, nil |
| } |
| func testCmdActivator(t *testing.T, cfg Config) (*Service, *cmdFakeBackend, *fakeClock) { |
| @@ -120,6 +143,7 @@ func testCmdActivator(t *testing.T, cfg Config) (*Service, *cmdFakeBackend, *fak |
| fb := &fakeBackend{layoutFn: func(registry.Route) (Layout, string) { return LayoutNested, "" }} |
| cb := &cmdFakeBackend{fakeBackend: fb} |
| cb.unit = &fakeCmdUnit{rep: fb.lastRep} |
| + cb.ttyUnit = &fakeCmdUnit{rep: fb.lastRep, term: &fakeTerminal{}} |
| clk := &fakeClock{t: time.Unix(1_700_000_000, 0)} |
| reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db")) |
| if err != nil { |
| @@ -211,15 +235,19 @@ func TestRunCmdHoldsTheIdleTimer(t *testing.T) { |
| waitFor(t, "hibernation after the run", func() bool { return a.entryCount() == 0 }) |
| } |
| -// Every stop path stops and settles the run before replication closes, and |
| -// the run learns why (run spec §5.3, codex 1). |
| -func TestEveryStopPathSettlesTheRunBeforeReplicationCloses(t *testing.T) { |
| - t.Parallel() |
| - cases := []struct { |
| - name string |
| - why string |
| - stop func(a *Service, cb *cmdFakeBackend, host string) |
| - }{ |
| +// stopPath is one way an instance stops, and the reason a run or session |
| +// it interrupts reads. |
| +type stopPath struct { |
| + name string |
| + why string |
| + stop func(a *Service, cb *cmdFakeBackend, host string) |
| +} |
| + |
| +// everyStopPath is every stop path a run or a session must be settled on |
| +// before replication closes (run spec §5.3, codex 1; rootfs apps Plan 6 |
| +// Task 9). |
| +func everyStopPath() []stopPath { |
| + return []stopPath{ |
| {"bounce", StopRestart, func(a *Service, _ *cmdFakeBackend, h string) { a.Bounce(h) }}, |
| {"process exit", StopExited, func(a *Service, cb *cmdFakeBackend, _ string) { cb.lastProc().exit(); a.sweepOnce() }}, |
| {"lease lost", StopLeaseLost, func(a *Service, cb *cmdFakeBackend, _ string) { cb.lastRep().setErr(errors.New("lost")); a.sweepOnce() }}, |
| @@ -242,7 +270,13 @@ func TestEveryStopPathSettlesTheRunBeforeReplicationCloses(t *testing.T) { |
| a.Shutdown(ctx) |
| }}, |
| } |
| - for _, c := range cases { |
| +} |
| + |
| +// Every stop path stops and settles the run before replication closes, and |
| +// the run learns why (run spec §5.3, codex 1). |
| +func TestEveryStopPathSettlesTheRunBeforeReplicationCloses(t *testing.T) { |
| + t.Parallel() |
| + for _, c := range everyStopPath() { |
| t.Run(c.name, func(t *testing.T) { |
| a, cb, _ := testCmdActivator(t, Config{}) |
| cb.execVerFn = func() string { return "v1" } |
| @@ -375,7 +409,7 @@ func TestAnUnprovenRunStopKeepsReplicationAndTheLease(t *testing.T) { |
| } |
| } |
| a.mu.Lock() |
| - held := a.entries[rt.Host] != nil && len(cmdHoldsLocked(a.entries[rt.Host])) == 1 |
| + held := a.entries[rt.Host] != nil && len(holdsLocked(a.entries[rt.Host])) == 1 |
| a.mu.Unlock() |
| if !held { |
| t.Fatal("the entry let go of the run's handle") |
| @@ -898,3 +932,404 @@ func TestABlockingAfterSettledDoesNotBlockStop(t *testing.T) { |
| t.Fatalf("AfterSettled ran %d times, want once", n) |
| } |
| } |
| + |
| +// Rootfs apps Plan 6 Task 9: a session (spec.TTY set) joins the |
| +// instance's writer lifecycle in its own slot, beside a run's. |
| + |
| +// holdsOf is e's attached run and session holds, under a.mu. |
| +func (a *Service) holdsOf(host string) (cmd, tty *cmdHold) { |
| + a.mu.Lock() |
| + defer a.mu.Unlock() |
| + if e := a.entries[host]; e != nil { |
| + return e.cmd, e.tty |
| + } |
| + return nil, nil |
| +} |
| + |
| +// Every stop path stops and settles the session before replication |
| +// closes, as for a run, and the session learns why; a run's unit is never |
| +// touched by it. |
| +func TestEveryStopPathSettlesTheSessionBeforeReplicationCloses(t *testing.T) { |
| + t.Parallel() |
| + for _, c := range everyStopPath() { |
| + t.Run(c.name, func(t *testing.T) { |
| + a, cb, _ := testCmdActivator(t, Config{}) |
| + cb.execVerFn = func() string { return "v1" } |
| + rt := testRoute("c.example.com") |
| + h, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + c.stop(a, cb, rt.Host) |
| + waitFor(t, "the instance stopped", func() bool { return a.entryCount() == 0 }) |
| + stops, repWasClosed := cb.ttyUnit.stopped() |
| + if stops != 1 { |
| + t.Fatalf("the tty unit was stopped %d times, want 1", stops) |
| + } |
| + if repWasClosed { |
| + t.Fatal("replication closed before the session settled") |
| + } |
| + if !cb.lastRep().isClosed() { |
| + t.Fatal("replication never closed") |
| + } |
| + if got, at := h.Interrupted(); got != c.why || at.IsZero() { |
| + t.Fatalf("Interrupted() = %q at %v, want %q and when", got, at, c.why) |
| + } |
| + if n, _ := cb.unit.stopped(); n != 0 { |
| + t.Fatalf("a session's stop stopped the cmd unit %d times", n) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestRunCmdHoldsTheIdleTimerForASession(t *testing.T) { |
| + t.Parallel() |
| + a, _, clk := testCmdActivator(t, Config{}) |
| + rt := testRoute("c.example.com") |
| + h, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + clk.advance(time.Hour) |
| + a.sweepOnce() |
| + if a.entryCount() != 1 || a.stopWhyOf(rt.Host) != "" { |
| + t.Fatal("the idle timer stopped an instance with a session open") |
| + } |
| + if err := h.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + h.Release() |
| + clk.advance(time.Hour) |
| + a.sweepOnce() |
| + waitFor(t, "hibernation after the session", func() bool { return a.entryCount() == 0 }) |
| +} |
| + |
| +// A run and a session of one instance coexist, each in its own slot: a |
| +// second of either is refused with its own error, and neither's stop, |
| +// settle, release or files touch the other's. |
| +func TestASessionAndARunCoexist(t *testing.T) { |
| + t.Parallel() |
| + a, cb, _ := testCmdActivator(t, Config{}) |
| + rt := testRoute("c.example.com") |
| + var runFiles, sesFiles, refusedFiles atomic.Int32 |
| + runSpec := CmdSpec{RunID: "run_a", AfterSettled: func() { runFiles.Add(1) }} |
| + sesSpec := sessionSpec("ses_a") |
| + sesSpec.AfterSettled = func() { sesFiles.Add(1) } |
| + run, err := a.RunCmd(context.Background(), rt, runSpec) |
| + if err != nil { |
| + t.Fatalf("run: %v", err) |
| + } |
| + ses, err := a.RunCmd(context.Background(), rt, sesSpec) |
| + if err != nil { |
| + t.Fatalf("a session beside a run: %v", err) |
| + } |
| + if ses.Terminal() != cb.ttyUnit.term || ses.Terminal() == nil { |
| + t.Fatalf("the session's Terminal() = %v, want its unit's", ses.Terminal()) |
| + } |
| + if run.Terminal() != nil { |
| + t.Fatalf("a run's Terminal() = %v, want nil", run.Terminal()) |
| + } |
| + second := sessionSpec("ses_b") |
| + second.AfterSettled = func() { refusedFiles.Add(1) } |
| + if _, err := a.RunCmd(context.Background(), rt, second); !errors.Is(err, ErrTTYBusy) { |
| + t.Fatalf("a second session: err = %v, want ErrTTYBusy", err) |
| + } |
| + if _, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_b", AfterSettled: func() { refusedFiles.Add(1) }}); !errors.Is(err, ErrCmdBusy) { |
| + t.Fatalf("a second run: err = %v, want ErrCmdBusy", err) |
| + } |
| + if n := refusedFiles.Load(); n != 2 { |
| + t.Fatalf("the refused commands' AfterSettled ran %d times, want once each", n) |
| + } |
| + // The run ends: its stop, its files and its release touch nothing of |
| + // the session's. |
| + if err := run.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + waitFor(t, "the run's files after its proof", func() bool { return runFiles.Load() == 1 }) |
| + run.Release() |
| + if n, _ := cb.ttyUnit.stopped(); n != 0 || sesFiles.Load() != 0 { |
| + t.Fatalf("the run's end stopped the tty unit %d times and ran the session's AfterSettled %d times", n, sesFiles.Load()) |
| + } |
| + if why, _ := ses.Interrupted(); why != "" { |
| + t.Fatalf("the run's end interrupted the session: %q", why) |
| + } |
| + if cmd, tty := a.holdsOf(rt.Host); cmd != nil || tty != ses.(*cmdRun).h { |
| + t.Fatalf("after the run's release: cmd %v, tty %v; want no run and the session attached", cmd, tty) |
| + } |
| + // A new run while the session stays, then the session ends: neither |
| + // touches the other. |
| + run2, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_c"}) |
| + if err != nil { |
| + t.Fatalf("a run beside the session after the first run ended: %v", err) |
| + } |
| + cmdStops, _ := cb.unit.stopped() |
| + if err := ses.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + waitFor(t, "the session's files after its proof", func() bool { return sesFiles.Load() == 1 }) |
| + ses.Release() |
| + if n, _ := cb.unit.stopped(); n != cmdStops { |
| + t.Fatalf("the session's end stopped the cmd unit (%d stops, was %d)", n, cmdStops) |
| + } |
| + if why, _ := run2.Interrupted(); why != "" { |
| + t.Fatalf("the session's end interrupted the run: %q", why) |
| + } |
| + if cmd, tty := a.holdsOf(rt.Host); cmd != run2.(*cmdRun).h || tty != nil { |
| + t.Fatalf("after the session's release: cmd %v, tty %v; want the run attached and no session", cmd, tty) |
| + } |
| + if n := runFiles.Load(); n != 1 { |
| + t.Fatalf("the first run's AfterSettled ran %d times, want once", n) |
| + } |
| + if err := run2.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + run2.Release() |
| +} |
| + |
| +// A session left unsettled (its Stop failed, then its release) holds the |
| +// tty slot only: a new session is ErrTTYBusy, a run is admitted, and the |
| +// left hold is settled by the instance's next stop. |
| +func TestAnUnsettledSessionHoldsOnlyTheTTYSlot(t *testing.T) { |
| + t.Parallel() |
| + a, cb, _ := testCmdActivator(t, Config{}) |
| + rt := testRoute("c.example.com") |
| + cb.ttyUnit.setSettleErr(errors.New("processes remained")) |
| + ses, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := ses.Stop(context.Background()); err == nil { |
| + t.Fatal("the session's Stop succeeded with its settle failing") |
| + } |
| + ses.Release() |
| + if _, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_b")); !errors.Is(err, ErrTTYBusy) { |
| + t.Fatalf("a session beside an unsettled one: err = %v, want ErrTTYBusy", err) |
| + } |
| + run, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_a"}) |
| + if err != nil { |
| + t.Fatalf("a run beside an unsettled session: %v", err) |
| + } |
| + if err := run.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + run.Release() |
| + cb.ttyUnit.setSettleErr(nil) |
| + a.Bounce(rt.Host) |
| + waitFor(t, "the instance stopped", func() bool { a.sweepOnce(); return a.entryCount() == 0 }) |
| + if _, repWasClosed := cb.ttyUnit.stopped(); repWasClosed { |
| + t.Fatal("replication closed before the left session settled") |
| + } |
| +} |
| + |
| +func TestRunCmdSessionRefusesWithClaimControlArmed(t *testing.T) { |
| + a, cb, _ := testCmdActivator(t, Config{HostWrites: hostwrite.Config{Enabled: true}}) |
| + if _, err := a.RunCmd(context.Background(), testRoute("c.example.com"), sessionSpec("ses_a")); !errors.Is(err, ErrCmdClaim) { |
| + t.Fatalf("err = %v, want ErrCmdClaim", err) |
| + } |
| + if acquires, _, _ := cb.counts(); acquires != 0 || cb.ttyStarts != 0 { |
| + t.Fatal("a claim-armed refusal woke the instance or started a session") |
| + } |
| +} |
| + |
| +func TestRunCmdSessionWakesAHibernatedInstanceFirst(t *testing.T) { |
| + a, cb, _ := testCmdActivator(t, Config{}) |
| + h, err := a.RunCmd(context.Background(), testRoute("c.example.com"), sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, _, wakes := cb.counts(); wakes != 1 || cb.ttyStarts != 1 || h.Terminal() == nil { |
| + t.Fatalf("wake starts %d, tty starts %d, terminal %v", wakes, cb.ttyStarts, h.Terminal()) |
| + } |
| + if err := h.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + h.Release() |
| +} |
| + |
| +// PF-17: a release command holds the cmd unit, not the tty unit. A run is |
| +// refused beside one; a session is admitted; and a session attached is |
| +// not busy for the release's own admission. |
| +func TestASessionIsNotRefusedForARelease(t *testing.T) { |
| + t.Parallel() |
| + a, _, _ := testCmdActivator(t, Config{}) |
| + rt := testRoute("c.example.com") |
| + arrangeAwake(t, a, rt) |
| + a.mu.Lock() |
| + if a.releaseOps == nil { |
| + a.releaseOps = map[string]*releaseOp{} |
| + } |
| + a.releaseOps[rt.Host] = &releaseOp{host: rt.Host, owner: a.entries[rt.Host], cancel: func(error) {}, done: make(chan struct{})} |
| + a.mu.Unlock() |
| + if _, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_a"}); !errors.Is(err, ErrCmdBusy) { |
| + t.Fatalf("a run beside a release: err = %v, want ErrCmdBusy", err) |
| + } |
| + ses, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatalf("a session beside a release: %v", err) |
| + } |
| + a.mu.Lock() |
| + delete(a.releaseOps, rt.Host) |
| + admit := a.releaseAdmitLocked(a.entries[rt.Host]) |
| + a.mu.Unlock() |
| + if admit != nil { |
| + t.Fatalf("a release's admission beside a session: %v, want admitted", admit) |
| + } |
| + // A run attached is busy for it, as before. |
| + run, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_b"}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + a.mu.Lock() |
| + admit = a.releaseAdmitLocked(a.entries[rt.Host]) |
| + a.mu.Unlock() |
| + if !errors.Is(admit, errSwapBusy) { |
| + t.Fatalf("a release's admission beside a run: %v, want errSwapBusy", admit) |
| + } |
| + for _, h := range []CmdHandle{run, ses} { |
| + if err := h.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + h.Release() |
| + } |
| +} |
| + |
| +// PF-18: with only a session attached (e.tty), each idle and stop check |
| +// leaves the entry as it is: the idle sleep, the plans awake ceiling, the |
| +// plan-disabled stop of a route, and the no-restart of a worker a lapse |
| +// turned off. And a stop cancels the session's Prepare as it does a run's. |
| +func TestASessionHoldsEveryIdleAndStopCheck(t *testing.T) { |
| + t.Parallel() |
| + attach := func(a *Service, host string) { |
| + a.mu.Lock() |
| + a.entries[host].tty = &cmdHold{role: instancectl.RoleTTY} |
| + a.mu.Unlock() |
| + } |
| + detach := func(a *Service, host string) { |
| + a.mu.Lock() |
| + a.entries[host].tty = nil |
| + a.mu.Unlock() |
| + } |
| + t.Run("idle sleep", func(t *testing.T) { |
| + a, _, clk, _ := testActivator(t, time.Minute) |
| + wakeInstance(t, a, "one.example.com") |
| + attach(a, "one.example.com") |
| + clk.advance(time.Hour) |
| + a.sweepOnce() |
| + if !a.entryAwake("one.example.com") || a.stopWhyOf("one.example.com") != "" { |
| + t.Fatal("the idle sweep stopped an entry with a session") |
| + } |
| + detach(a, "one.example.com") |
| + a.sweepOnce() |
| + waitFor(t, "the idle stop once the session went", func() bool { return a.entryCount() == 0 }) |
| + }) |
| + t.Run("plans awake ceiling", func(t *testing.T) { |
| + a, _, clk, _ := testActivator(t, 15*time.Minute) |
| + a.SetMaxRunFor(maxRunFor(15 * time.Minute)) |
| + release, err := a.beginRequest(context.Background(), testRoute("one.example.com")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer release() |
| + attach(a, "one.example.com") |
| + clk.advance(time.Hour) |
| + a.sweepOnce() |
| + if !a.entryAwake("one.example.com") || a.stopWhyOf("one.example.com") != "" { |
| + t.Fatal("the plans ceiling stopped an entry with a session") |
| + } |
| + detach(a, "one.example.com") |
| + a.sweepOnce() |
| + waitFor(t, "the ceiling stop once the session went", func() bool { return a.entryCount() == 0 }) |
| + }) |
| + t.Run("plan-disabled route", func(t *testing.T) { |
| + a, _, clk, _ := testActivator(t, time.Hour) |
| + wakeInstance(t, a, "one.example.com") |
| + attach(a, "one.example.com") |
| + a.SetDisabledFor(disabledFor("one.example.com")) |
| + clk.advance(time.Second) |
| + a.sweepOnce() |
| + if !a.entryAwake("one.example.com") { |
| + t.Fatal("a turned-off entry was stopped mid-session") |
| + } |
| + detach(a, "one.example.com") |
| + a.sweepOnce() |
| + waitFor(t, "the turned-off stop once the session went", func() bool { return !a.Owns("one.example.com") }) |
| + }) |
| + t.Run("turned-off worker", func(t *testing.T) { |
| + a, b, _, _ := testActivator(t, time.Hour) |
| + host := "bot.x.internal" |
| + if err := a.WakeWorker(alwaysOnWorkerRoute(host)); err != nil { |
| + t.Fatalf("WakeWorker: %v", err) |
| + } |
| + attach(a, host) |
| + a.SetDisabledFor(disabledFor(host)) |
| + b.lastWorker().kill() |
| + a.sweepOnce() |
| + if why := a.stopWhyOf(host); why != "" || !a.Owns(host) { |
| + t.Fatalf("a turned-off worker with a session attached stood down (%q)", why) |
| + } |
| + detach(a, host) |
| + }) |
| + t.Run("a stop cancels the session's prepare", func(t *testing.T) { |
| + a, cb, _ := testCmdActivator(t, Config{}) |
| + rt := testRoute("c.example.com") |
| + inPrepare, unblock := make(chan struct{}), make(chan struct{}) |
| + var cancelled atomic.Bool |
| + done := make(chan error, 1) |
| + spec := sessionSpec("ses_a") |
| + spec.Prepare = func(ctx context.Context) error { |
| + close(inPrepare) |
| + <-unblock |
| + cancelled.Store(ctx.Err() != nil) |
| + return nil |
| + } |
| + go func() { |
| + _, err := a.RunCmd(context.Background(), rt, spec) |
| + done <- err |
| + }() |
| + <-inPrepare |
| + a.Bounce(rt.Host) |
| + waitFor(t, "the instance stopped while the session's Prepare ran", func() bool { return a.entryCount() == 0 }) |
| + close(unblock) |
| + var se *CmdStoppedError |
| + if err := <-done; !errors.As(err, &se) || se.Reason != StopRestart { |
| + t.Fatalf("err = %v, want CmdStoppedError{%q}", err, StopRestart) |
| + } |
| + if !cancelled.Load() { |
| + t.Error("the stop did not cancel the session's Prepare") |
| + } |
| + if cb.ttyStarts != 0 { |
| + t.Fatal("a tty unit started after the stop") |
| + } |
| + }) |
| +} |
| + |
| +// The sweep retries an attached session's failed settle once its stop was |
| +// asked for, while the instance stays awake (re-review 6), as it does a |
| +// run's; and a session nobody asked to stop is left alone. |
| +func TestTheSweepRetriesAnAttachedSessionsFailedSettle(t *testing.T) { |
| + t.Parallel() |
| + a, cb, clk := testCmdActivator(t, Config{}) |
| + rt := testRoute("c.example.com") |
| + cb.ttyUnit.setSettleErr(errors.New("processes remained")) |
| + ses, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + clk.advance(actStopTimeout) |
| + a.sweepOnce() |
| + time.Sleep(20 * time.Millisecond) |
| + if n, _ := cb.ttyUnit.stopped(); n != 0 { |
| + t.Fatalf("the sweep stopped a session nobody asked to stop (%d stops)", n) |
| + } |
| + if err := ses.Stop(context.Background()); err == nil { |
| + t.Fatal("the session's Stop succeeded with its settle failing") |
| + } |
| + cb.ttyUnit.setSettleErr(nil) |
| + clk.advance(actStopTimeout) |
| + a.sweepOnce() |
| + waitFor(t, "the sweep's retry proving the session stopped", func() bool { return ses.(*cmdRun).h.provenSettled() }) |
| + if !a.entryAwake(rt.Host) { |
| + t.Fatal("the retry stopped the instance") |
| + } |
| + ses.Release() |
| +} |
diff --git a/internal/activator/generations_file.go b/internal/activator/generations_file.go| index 5b46978e0..be091b05c 100644 |
| --- a/internal/activator/generations_file.go |
| +++ b/internal/activator/generations_file.go |
| @@ -211,10 +211,10 @@ func (a *Service) entryGenerationsLocked(e *actEntry, add func(release.StagedIde |
| for _, v := range e.attemptBuilds { |
| add(release.StagedIdentity{Version: v}) |
| } |
| - // A run's generation, until the run is proven settled (merge ruling |
| - // M2): its command execs that build, and may outlive the generation's |
| - // own process once a swap retires it. |
| - for _, h := range cmdHoldsLocked(e) { |
| + // A run's or a session's generation, until it is proven settled |
| + // (merge ruling M2): its command execs that build, and may outlive the |
| + // generation's own process once a swap retires it. |
| + for _, h := range holdsLocked(e) { |
| gen(h.gen) |
| } |
| // A rootfs worker's build, its own identity (W1.19): from its start's |
diff --git a/internal/activator/rootfs_cmd_lease_test.go b/internal/activator/rootfs_cmd_lease_test.go| index b104023ec..4b73775c8 100644 |
| --- a/internal/activator/rootfs_cmd_lease_test.go |
| +++ b/internal/activator/rootfs_cmd_lease_test.go |
| @@ -14,6 +14,7 @@ import ( |
| "errors" |
| "fmt" |
| "path/filepath" |
| + "slices" |
| "sync" |
| "sync/atomic" |
| "testing" |
| @@ -24,9 +25,12 @@ import ( |
| ) |
| // leaseCmdUnit is a run's unit whose settles are recorded among the |
| -// backend's events ("settle"), failing while settleErr is set. |
| +// backend's events ("settle", or event when set: a session's unit records |
| +// "settle:tty"), failing while settleErr is set. |
| type leaseCmdUnit struct { |
| b *fakeBackend |
| + event string |
| + term Terminal // a session's unit's; nil for a run's |
| mu sync.Mutex |
| settles int |
| settleErr error |
| @@ -38,9 +42,13 @@ func (u *leaseCmdUnit) Poll(ctx context.Context) (instancectl.CmdStatus, error) |
| <-ctx.Done() |
| return instancectl.CmdStatus{}, ctx.Err() |
| } |
| -func (u *leaseCmdUnit) Terminal() Terminal { return nil } |
| +func (u *leaseCmdUnit) Terminal() Terminal { return u.term } |
| func (u *leaseCmdUnit) StopAndSettle(context.Context) error { |
| - u.b.record("settle") |
| + if u.event != "" { |
| + u.b.record(u.event) |
| + } else { |
| + u.b.record("settle") |
| + } |
| u.mu.Lock() |
| defer u.mu.Unlock() |
| u.settles++ |
| @@ -62,14 +70,22 @@ func (u *leaseCmdUnit) settleCount() int { |
| // runLeaseBackend is killBackend (KillGen recorded "kill:<n>") with the run |
| // capability on the nested layout and the one-shot kill (oneShotKiller), |
| -// recorded "killoneshot:<role>" with its time. StartCmd blocks on |
| -// startGate when it is set, after closing startEntered. |
| +// recorded "killoneshot:<role>" with its time. A run's StartCmd blocks on |
| +// startGate when it is set, after closing startEntered; a session's |
| +// (spec.TTY set, recorded "starttty:<id>") on ttyGate after ttyEntered, |
| +// and returns ttyUnit. |
| type runLeaseBackend struct { |
| *killBackend |
| - unit *leaseCmdUnit |
| + unit *leaseCmdUnit |
| + ttyUnit *leaseCmdUnit |
| omu sync.Mutex |
| oneShots []time.Time |
| + oneShotRoles []instancectl.Role // beside oneShots |
| + onOneShotOf func(instancectl.Role) // a test's seam, as onOneShot, told the role |
| + ttyGate chan struct{} |
| + ttyEntered chan struct{} |
| + ttyStarts int |
| onOneShot func() |
| startGate chan struct{} |
| startEntered chan struct{} |
| @@ -79,6 +95,20 @@ type runLeaseBackend struct { |
| } |
| func (b *runLeaseBackend) StartCmd(_ context.Context, _ registry.Route, spec CmdSpec) (CmdUnit, error) { |
| + if spec.TTY != nil { |
| + b.omu.Lock() |
| + gate, entered := b.ttyGate, b.ttyEntered |
| + b.ttyStarts++ |
| + b.omu.Unlock() |
| + b.record("starttty:" + spec.RunID) |
| + if entered != nil { |
| + close(entered) |
| + } |
| + if gate != nil { |
| + <-gate |
| + } |
| + return b.ttyUnit, nil |
| + } |
| b.omu.Lock() |
| gate, entered := b.startGate, b.startEntered |
| b.cmdStarts++ |
| @@ -96,11 +126,15 @@ func (b *runLeaseBackend) StartCmd(_ context.Context, _ registry.Route, spec Cmd |
| func (b *runLeaseBackend) KillOneShot(_ context.Context, rt registry.Route, role instancectl.Role) error { |
| b.omu.Lock() |
| b.oneShots = append(b.oneShots, time.Now()) |
| - hook := b.onOneShot |
| + b.oneShotRoles = append(b.oneShotRoles, role) |
| + hook, hookOf := b.onOneShot, b.onOneShotOf |
| b.omu.Unlock() |
| if hook != nil { |
| hook() // a test's seam: the kill's way to root, delayed |
| } |
| + if hookOf != nil { |
| + hookOf(role) |
| + } |
| // Recorded when the kill reaches root, after any delay. |
| b.record(fmt.Sprintf("killoneshot:%s", role)) |
| if b.killVia != nil { |
| @@ -115,6 +149,25 @@ func (b *runLeaseBackend) oneShotKills() []time.Time { |
| return append([]time.Time(nil), b.oneShots...) |
| } |
| +// killsOf is when each KillOneShot of role was asked. |
| +func (b *runLeaseBackend) killsOf(role instancectl.Role) []time.Time { |
| + b.omu.Lock() |
| + defer b.omu.Unlock() |
| + var out []time.Time |
| + for i, r := range b.oneShotRoles { |
| + if r == role { |
| + out = append(out, b.oneShots[i]) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +func (b *runLeaseBackend) ttyStartCount() int { |
| + b.omu.Lock() |
| + defer b.omu.Unlock() |
| + return b.ttyStarts |
| +} |
| + |
| func (b *runLeaseBackend) starts() int { |
| b.omu.Lock() |
| defer b.omu.Unlock() |
| @@ -130,6 +183,7 @@ func runLeaseService(t *testing.T, routes ...registry.Route) (*Service, *runLeas |
| fb := &fakeBackend{layoutFn: func(registry.Route) (Layout, string) { return LayoutNested, "" }} |
| b := &runLeaseBackend{killBackend: &killBackend{fakeBackend: fb}} |
| b.unit = &leaseCmdUnit{b: fb} |
| + b.ttyUnit = &leaseCmdUnit{b: fb, event: "settle:tty", term: &fakeTerminal{}} |
| clk := &fakeClock{t: time.Unix(1_700_000_000, 0)} |
| reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db")) |
| if err != nil { |
| @@ -147,6 +201,7 @@ func runLeaseService(t *testing.T, routes ...registry.Route) (*Service, *runLeas |
| // A test that failed with a run unproven leaves a stop pending: |
| // prove it, and let the sweep finish it, before the Shutdown. |
| b.unit.setSettleErr(nil) |
| + b.ttyUnit.setSettleErr(nil) |
| for deadline := time.Now().Add(5 * time.Second); time.Now().Before(deadline) && a.stopsPending(); { |
| clk.advance(time.Minute) |
| a.sweepOnce() |
| @@ -740,14 +795,14 @@ func TestAnOutstandingLeaseStopKeepsTheUnitFree(t *testing.T) { |
| run.Release() |
| a.mu.Lock() |
| e := a.entries[host] |
| - e.leaseStops++ |
| + e.addLeaseStop(instancectl.RoleCmd, 1) |
| admit := a.releaseAdmitLocked(e) |
| a.mu.Unlock() |
| returned := false |
| t.Cleanup(func() { // a failure below must not leave the stop held pending |
| if !returned { |
| a.mu.Lock() |
| - e.leaseStops-- |
| + e.addLeaseStop(instancectl.RoleCmd, -1) |
| a.mu.Unlock() |
| } |
| }) |
| @@ -758,7 +813,7 @@ func TestAnOutstandingLeaseStopKeepsTheUnitFree(t *testing.T) { |
| t.Fatalf("RunCmd with a lease stop outstanding = %v, want ErrCmdBusy", err) |
| } |
| a.mu.Lock() |
| - e.leaseStops-- |
| + e.addLeaseStop(instancectl.RoleCmd, -1) |
| returned = true |
| a.mu.Unlock() |
| run, err = a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_c"}) |
| @@ -854,7 +909,7 @@ func TestALeaseKillIsBoundedByKillOneShotsBudgets(t *testing.T) { |
| b.omu.Lock() |
| b.onOneShot = func() { // off a.mu: the count while the kill is on its way |
| a.mu.Lock() |
| - n := e.leaseStops |
| + n := e.leaseStops[instancectl.RoleCmd] |
| a.mu.Unlock() |
| select { |
| case counted <- n: |
| @@ -875,7 +930,7 @@ func TestALeaseKillIsBoundedByKillOneShotsBudgets(t *testing.T) { |
| waitFor(t, "the count to drop once the hung kill returned", func() bool { |
| a.mu.Lock() |
| defer a.mu.Unlock() |
| - return e.leaseStops == 0 |
| + return pendingLeaseStopsLocked(e) == 0 |
| }) |
| if took := time.Since(lostAt); took < oneShotKillControlBound || took > oneShotKillControlBound+slack { |
| t.Fatalf("the count dropped %s after the loss; want KillOneShot's control budget, %s", took, oneShotKillControlBound) |
| @@ -888,3 +943,470 @@ func TestALeaseKillIsBoundedByKillOneShotsBudgets(t *testing.T) { |
| finishStopOf(t, a, clk, host) |
| }) |
| } |
| + |
| +// Rootfs apps Plan 6 Task 9 (PF-3): a session's tty unit is under the |
| +// instance's lease as a run's cmd unit is, beside it. Each hold's stop and |
| +// kill names its own role's unit and nothing of the other's. |
| + |
| +// sessionWithFiles is a session's spec whose AfterSettled counts on n. |
| +func sessionWithFiles(id string, n *atomic.Int32) CmdSpec { |
| + s := sessionSpec(id) |
| + s.AfterSettled = func() { n.Add(1) } |
| + return s |
| +} |
| + |
| +// An awake resident with a run and a session attached, its web drain |
| +// stalled: the loss asks root to kill the cmd unit and the tty unit, each |
| +// once and at once, beside the generation kill, before anything settles |
| +// either; both read as interrupted by the lost lease. Each hold is proven |
| +// on its own: the run's proof runs the run's AfterSettled and nothing of |
| +// the session's, and the lease is given back only once both are proven. |
| +func TestResidentLeaseLossKillsTheSessionBesideTheRun(t *testing.T) { |
| + host := "shop.example.com" |
| + a, b, clk := runLeaseService(t, residentRoute(host)) |
| + rep := ownedRepUntil(b, func() time.Time { return time.Now().Add(time.Hour) }) |
| + startResident(t, a, host) |
| + var runFiles, sesFiles atomic.Int32 |
| + run, err := a.RunCmd(context.Background(), residentRoute(host), CmdSpec{RunID: "run_a", AfterSettled: func() { runFiles.Add(1) }}) |
| + if err != nil { |
| + t.Fatalf("RunCmd run: %v", err) |
| + } |
| + ses, err := a.RunCmd(context.Background(), residentRoute(host), sessionWithFiles("ses_a", &sesFiles)) |
| + if err != nil { |
| + t.Fatalf("RunCmd session: %v", err) |
| + } |
| + end := stallDrain(t, b, b.lastProc()) |
| + b.kmu.Lock() |
| + b.onKill = nil // the drain stays stalled until the test ends it |
| + b.kmu.Unlock() |
| + b.unit.setSettleErr(errors.New("processes remained")) |
| + b.ttyUnit.setSettleErr(errors.New("processes remained")) |
| + lostAt := time.Now() |
| + rep.Load().lose(errors.New("renew: the lock was taken")) |
| + waitFor(t, "both kills at the loss", func() bool { |
| + return len(b.killsOf(instancectl.RoleCmd)) > 0 && len(b.killsOf(instancectl.RoleTTY)) > 0 |
| + }) |
| + for _, role := range []instancectl.Role{instancectl.RoleCmd, instancectl.RoleTTY} { |
| + if d := b.killsOf(role)[0].Sub(lostAt); d > time.Second { |
| + t.Fatalf("the %s unit was killed %s after the loss", role, d) |
| + } |
| + } |
| + waitFor(t, "the generation's kill", func() bool { return len(b.killTimes()) > 0 }) |
| + // Each lease stop kills its own unit before it settles it; the two |
| + // run at once, so one's settle may come before the other's kill. |
| + ev := b.events() |
| + for kill, settle := range map[string]string{"killoneshot:cmd": "settle", "killoneshot:tty": "settle:tty"} { |
| + if k, s := slices.Index(ev, kill), slices.Index(ev, settle); k < 0 || s >= 0 && s < k { |
| + t.Fatalf("events %v: %s did not come before %s", ev, kill, settle) |
| + } |
| + } |
| + for name, h := range map[string]CmdHandle{"run": run, "session": ses} { |
| + if why, at := h.Interrupted(); why != StopLeaseLost || !at.Equal(clk.now()) { |
| + t.Fatalf("the %s's Interrupted() = %q at %v, want %q at the loss", name, why, at, StopLeaseLost) |
| + } |
| + } |
| + end() |
| + waitFor(t, "the entry's stop to keep its unproven holds", func() bool { |
| + a.mu.Lock() |
| + defer a.mu.Unlock() |
| + e := a.entries[host] |
| + return e != nil && e.pendingStop |
| + }) |
| + if rep.Load().isClosed() || runFiles.Load() != 0 || sesFiles.Load() != 0 { |
| + t.Fatalf("while both were unproven: lease closed %v, run files %d, session files %d", rep.Load().isClosed(), runFiles.Load(), sesFiles.Load()) |
| + } |
| + // The run is proven; the session is not. The run's files go, the |
| + // session's stay, and the lease stays. |
| + b.unit.setSettleErr(nil) |
| + waitFor(t, "the run's proof", func() bool { |
| + clk.advance(time.Minute) |
| + a.sweepOnce() |
| + return runFiles.Load() == 1 |
| + }) |
| + if rep.Load().isClosed() || sesFiles.Load() != 0 || !a.hasEntry(host) { |
| + t.Fatalf("with the session unproven: lease closed %v, session files %d, entry %v", rep.Load().isClosed(), sesFiles.Load(), a.hasEntry(host)) |
| + } |
| + b.ttyUnit.setSettleErr(nil) |
| + finishStopOf(t, a, clk, host) |
| + ev = b.events() |
| + c := indexWithPrefix(ev, "close") |
| + if c < 0 || c < lastIndexOf(ev, "settle") || c < lastIndexOf(ev, "settle:tty") { |
| + t.Fatalf("events %v: the lease was given back before both holds were proven", ev) |
| + } |
| + if n, m := len(b.killsOf(instancectl.RoleCmd)), len(b.killsOf(instancectl.RoleTTY)); n != 1 || m != 1 { |
| + t.Fatalf("kills: cmd %d, tty %d; want one each", n, m) |
| + } |
| + run.Release() |
| + ses.Release() |
| + waitFor(t, "the session's files after its proof", func() bool { return sesFiles.Load() == 1 }) |
| + time.Sleep(20 * time.Millisecond) |
| + if r, s := runFiles.Load(), sesFiles.Load(); r != 1 || s != 1 { |
| + t.Fatalf("AfterSettled ran %d times for the run and %d for the session, want once each", r, s) |
| + } |
| +} |
| + |
| +// The entry is already stopping (a restart, its drain stalled) when the |
| +// lease runs short and then is lost: residentLeaseShort stops the |
| +// session, and the loss kills its tty unit. |
| +func TestResidentLeaseLossKillsTheSessionOfAnAlreadyStoppingEntry(t *testing.T) { |
| + shrinkDrainBudget(t, 400*time.Millisecond) |
| + host := "shop.example.com" |
| + a, b, clk := runLeaseService(t, residentRoute(host)) |
| + deadline := time.Now().Add(1200 * time.Millisecond) |
| + ownedRepUntil(b, func() time.Time { return deadline }) |
| + startResident(t, a, host) |
| + ses, err := a.RunCmd(context.Background(), residentRoute(host), sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatalf("RunCmd: %v", err) |
| + } |
| + stallDrain(t, b, b.lastProc()) |
| + b.ttyUnit.setSettleErr(errors.New("processes remained")) |
| + if !a.Bounce(host) { |
| + t.Fatal("Bounce found no awake entry") |
| + } |
| + waitFor(t, "the session's stop at the short lease", func() bool { return b.ttyUnit.settleCount() > 0 }) |
| + if !time.Now().Before(deadline) { |
| + t.Fatalf("the session's stop began %s after the safety deadline", time.Since(deadline)) |
| + } |
| + waitFor(t, "the session's kill at the loss", func() bool { return len(b.killsOf(instancectl.RoleTTY)) > 0 }) |
| + if k := b.killsOf(instancectl.RoleTTY)[0]; k.Before(deadline.Add(-50 * time.Millisecond)) { |
| + t.Fatalf("the kill came %s before the loss", deadline.Sub(k)) |
| + } |
| + if n := len(b.killsOf(instancectl.RoleCmd)); n != 0 { |
| + t.Fatalf("a session's lease kill asked root to kill the cmd unit %d times", n) |
| + } |
| + if why, _ := ses.Interrupted(); why != StopLeaseLost { |
| + t.Fatalf("Interrupted() = %q, want %q", why, StopLeaseLost) |
| + } |
| + b.ttyUnit.setSettleErr(nil) |
| + finishStopOf(t, a, clk, host) |
| + ses.Release() |
| +} |
| + |
| +// A session's start in flight at the loss: the tty kill is asked at once, |
| +// and again once the start returns a unit; the hold is then proven. |
| +func TestResidentLeaseLossKillsASessionWhoseStartIsInFlight(t *testing.T) { |
| + host := "shop.example.com" |
| + a, b, clk := runLeaseService(t, residentRoute(host)) |
| + rep := ownedRepUntil(b, func() time.Time { return time.Now().Add(time.Hour) }) |
| + startResident(t, a, host) |
| + b.kmu.Lock() |
| + b.onKill = func(uint64) { b.lastProc().exit() } |
| + b.kmu.Unlock() |
| + gate, entered := make(chan struct{}), make(chan struct{}) |
| + b.omu.Lock() |
| + b.ttyGate, b.ttyEntered = gate, entered |
| + b.omu.Unlock() |
| + var opened sync.Once |
| + open := func() { opened.Do(func() { close(gate) }) } |
| + t.Cleanup(open) |
| + var settled atomic.Int32 |
| + type result struct { |
| + h CmdHandle |
| + err error |
| + } |
| + ran := make(chan result, 1) |
| + go func() { |
| + h, err := a.RunCmd(context.Background(), residentRoute(host), sessionWithFiles("ses_a", &settled)) |
| + ran <- result{h, err} |
| + }() |
| + <-entered |
| + rep.Load().lose(errors.New("renew: the lock was taken")) |
| + waitFor(t, "the tty kill at the loss", func() bool { return len(b.killsOf(instancectl.RoleTTY)) == 1 }) |
| + time.Sleep(50 * time.Millisecond) |
| + if n := len(b.killsOf(instancectl.RoleTTY)); n != 1 { |
| + t.Fatalf("%d tty kills while the start is blocked, want one", n) |
| + } |
| + open() |
| + waitFor(t, "the tty kill again once the start returned its unit", func() bool { return len(b.killsOf(instancectl.RoleTTY)) == 2 }) |
| + r := <-ran |
| + if r.err != nil { |
| + t.Fatalf("RunCmd: %v", r.err) |
| + } |
| + waitFor(t, "the session's hold to be proven", func() bool { return settled.Load() == 1 }) |
| + if why, _ := r.h.Interrupted(); why != StopLeaseLost { |
| + t.Fatalf("Interrupted() = %q, want %q", why, StopLeaseLost) |
| + } |
| + if n := len(b.killsOf(instancectl.RoleCmd)); n != 0 { |
| + t.Fatalf("a session's lease kill asked root to kill the cmd unit %d times", n) |
| + } |
| + r.h.Release() |
| + finishStopOf(t, a, clk, host) |
| +} |
| + |
| +// The session's headroom: with less than oneShotStartLead left before the |
| +// lease's safety deadline, a rootfs session is refused as a lost lease and |
| +// no tty unit starts. |
| +func TestRootfsSessionRefusedWithoutLeaseHeadroom(t *testing.T) { |
| + host := "shop.example.com" |
| + a, b, _ := runLeaseService(t, residentRoute(host)) |
| + until := time.Now().Add(time.Hour) |
| + ownedRepUntil(b, func() time.Time { return until }) |
| + startResident(t, a, host) |
| + a.leaseNow = func() time.Time { return until.Add(-oneShotStartLead()).Add(time.Millisecond) } |
| + _, err := a.RunCmd(context.Background(), residentRoute(host), sessionSpec("ses_a")) |
| + var se *CmdStoppedError |
| + if !errors.As(err, &se) || se.Reason != StopLeaseLost { |
| + t.Fatalf("RunCmd = %v, want CmdStoppedError{StopLeaseLost}", err) |
| + } |
| + if n := b.ttyStartCount(); n != 0 { |
| + t.Fatalf("%d tty starts without headroom, want none", n) |
| + } |
| + a.leaseNow = func() time.Time { return until.Add(-oneShotStartLead()).Add(-time.Second) } |
| + ses, err := a.RunCmd(context.Background(), residentRoute(host), sessionSpec("ses_b")) |
| + if err != nil { |
| + t.Fatalf("RunCmd with headroom: %v", err) |
| + } |
| + if err := ses.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + ses.Release() |
| +} |
| + |
| +// Astra R1 P1-1 for a session: a hibernating rootfs row woken by a |
| +// session, with a run beside it, is under the lease watch. At the loss |
| +// root kills the tty unit and the cmd unit, both at once, and no |
| +// generation. The tick's fallback (no lease signal) reaches the session |
| +// too. An unwatched entry refuses the session before any tty start. |
| +func TestHibernatingRootfsLeaseLossKillsItsSession(t *testing.T) { |
| + t.Run("watched", func(t *testing.T) { |
| + host := "shop.example.com" |
| + a, b, clk := runLeaseService(t) |
| + rep := ownedRepUntil(b, func() time.Time { return time.Now().Add(time.Hour) }) |
| + rt := rootfsGateRoute(host) |
| + ses, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatalf("RunCmd session: %v", err) |
| + } |
| + run, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_a"}) |
| + if err != nil { |
| + t.Fatalf("RunCmd run: %v", err) |
| + } |
| + a.mu.Lock() |
| + watched := a.entries[host] != nil && a.entries[host].ownerDone != nil |
| + a.mu.Unlock() |
| + if !watched { |
| + t.Fatal("the session's wake left the hibernating rootfs entry unwatched") |
| + } |
| + lostAt := time.Now() |
| + rep.Load().lose(errors.New("renew: the lock was taken")) |
| + waitFor(t, "both kills at the loss", func() bool { |
| + return len(b.killsOf(instancectl.RoleTTY)) > 0 && len(b.killsOf(instancectl.RoleCmd)) > 0 |
| + }) |
| + for _, role := range []instancectl.Role{instancectl.RoleTTY, instancectl.RoleCmd} { |
| + if d := b.killsOf(role)[0].Sub(lostAt); d > time.Second { |
| + t.Fatalf("the %s unit was killed %s after the loss", role, d) |
| + } |
| + } |
| + time.Sleep(50 * time.Millisecond) |
| + if n := len(b.killTimes()); n != 0 { |
| + t.Fatalf("a hibernating row's generation was killed %d times at the loss", n) |
| + } |
| + for name, h := range map[string]CmdHandle{"run": run, "session": ses} { |
| + if why, _ := h.Interrupted(); why != StopLeaseLost { |
| + t.Fatalf("the %s's Interrupted() = %q, want %q", name, why, StopLeaseLost) |
| + } |
| + h.Release() |
| + } |
| + a.Bounce(host) |
| + finishStopOf(t, a, clk, host) |
| + }) |
| + t.Run("tick fallback", func(t *testing.T) { |
| + host := "shop.example.com" |
| + a, b, clk := runLeaseService(t) |
| + rt := rootfsGateRoute(host) |
| + ses, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatalf("RunCmd: %v", err) |
| + } |
| + b.lastRep().setErr(errors.New("lease renewal failed")) |
| + a.rootfsTick() |
| + waitFor(t, "the tick's tty kill", func() bool { return len(b.killsOf(instancectl.RoleTTY)) == 1 }) |
| + a.rootfsTick() |
| + time.Sleep(50 * time.Millisecond) |
| + if n := len(b.killsOf(instancectl.RoleTTY)); n != 1 { |
| + t.Fatalf("%d tty kills over two ticks, want one (latched)", n) |
| + } |
| + if n := len(b.killTimes()); n != 0 { |
| + t.Fatalf("a hibernating row's generation was killed %d times", n) |
| + } |
| + waitFor(t, "the session's stop after the kill", func() bool { return b.ttyUnit.settleCount() > 0 }) |
| + if why, _ := ses.Interrupted(); why != StopLeaseLost { |
| + t.Fatalf("Interrupted() = %q, want %q", why, StopLeaseLost) |
| + } |
| + ses.Release() |
| + a.Bounce(host) |
| + finishStopOf(t, a, clk, host) |
| + }) |
| + t.Run("unwatched", func(t *testing.T) { |
| + host := "shop.example.com" |
| + a, b, clk := runLeaseService(t) |
| + ownedRepUntil(b, func() time.Time { return time.Now().Add(time.Hour) }) |
| + rt := rootfsGateRoute(host) |
| + run, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_a"}) |
| + if err != nil { |
| + t.Fatalf("RunCmd run: %v", err) |
| + } |
| + a.mu.Lock() |
| + e := a.entries[host] |
| + close(e.ownerDone) |
| + e.ownerDone = nil |
| + a.mu.Unlock() |
| + var settled atomic.Int32 |
| + _, err = a.RunCmd(context.Background(), rt, sessionWithFiles("ses_a", &settled)) |
| + var se *CmdStoppedError |
| + if !errors.As(err, &se) || se.Reason != StopLeaseLost { |
| + t.Fatalf("RunCmd = %v, want CmdStoppedError{StopLeaseLost}", err) |
| + } |
| + if n := b.ttyStartCount(); n != 0 || settled.Load() != 1 { |
| + t.Fatalf("tty starts %d, AfterSettled %d; want none and once", n, settled.Load()) |
| + } |
| + if err := run.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + run.Release() |
| + a.Bounce(host) |
| + finishStopOf(t, a, clk, host) |
| + }) |
| +} |
| + |
| +// Each lease stop is joined to its own role's unit (Task 7a's join, per |
| +// role): while one for the tty unit is outstanding no session starts, and |
| +// a run and a release command (the cmd unit) are admitted; while one for |
| +// the cmd unit is outstanding no run and no release start, and a session |
| +// is admitted. The entry's stop waits for either. |
| +func TestAnOutstandingLeaseStopKeepsOnlyItsRolesUnitFree(t *testing.T) { |
| + for _, role := range []instancectl.Role{instancectl.RoleCmd, instancectl.RoleTTY} { |
| + t.Run(string(role), func(t *testing.T) { |
| + host := "shop.example.com" |
| + a, _, _ := runLeaseService(t) |
| + rt := rootfsGateRoute(host) |
| + first, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_a"}) |
| + if err != nil { |
| + t.Fatalf("RunCmd: %v", err) |
| + } |
| + if err := first.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + first.Release() |
| + a.mu.Lock() |
| + e := a.entries[host] |
| + e.addLeaseStop(role, 1) |
| + admit := a.releaseAdmitLocked(e) |
| + a.mu.Unlock() |
| + returned := false |
| + t.Cleanup(func() { |
| + if !returned { |
| + a.mu.Lock() |
| + e.addLeaseStop(role, -1) |
| + a.mu.Unlock() |
| + } |
| + }) |
| + run, runErr := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_b"}) |
| + ses, sesErr := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if role == instancectl.RoleCmd { |
| + if !errors.Is(admit, errSwapBusy) || !errors.Is(runErr, ErrCmdBusy) || sesErr != nil { |
| + t.Fatalf("a cmd lease stop outstanding: release %v, run %v, session %v; want busy, ErrCmdBusy, admitted", admit, runErr, sesErr) |
| + } |
| + } else { |
| + if admit != nil || runErr != nil || !errors.Is(sesErr, ErrTTYBusy) { |
| + t.Fatalf("a tty lease stop outstanding: release %v, run %v, session %v; want admitted, admitted, ErrTTYBusy", admit, runErr, sesErr) |
| + } |
| + } |
| + for _, h := range []CmdHandle{run, ses} { |
| + if h != nil { |
| + if err := h.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + h.Release() |
| + } |
| + } |
| + a.mu.Lock() |
| + e.addLeaseStop(role, -1) |
| + returned = true |
| + a.mu.Unlock() |
| + }) |
| + } |
| +} |
| + |
| +// Task 7a's join for the tty unit: a session's lease kill, held on its way |
| +// to root, is counted under the tty role only (the run's, beside it, |
| +// returns and leaves the cmd role's count at zero), so it keeps the tty |
| +// unit from a new session and not the cmd unit from a run |
| +// (TestAnOutstandingLeaseStopKeepsOnlyItsRolesUnitFree), and the entry's |
| +// stop keeps the lease while it is out. Once the kill returns the stop |
| +// finishes, after it. |
| +func TestASessionLeaseKillHoldsOnlyTheTTYUnit(t *testing.T) { |
| + host := "shop.example.com" |
| + a, b, clk := runLeaseService(t) |
| + rep := ownedRepUntil(b, func() time.Time { return time.Now().Add(time.Hour) }) |
| + rt := rootfsGateRoute(host) |
| + ses, err := a.RunCmd(context.Background(), rt, sessionSpec("ses_a")) |
| + if err != nil { |
| + t.Fatalf("RunCmd session: %v", err) |
| + } |
| + run, err := a.RunCmd(context.Background(), rt, CmdSpec{RunID: "run_a"}) |
| + if err != nil { |
| + t.Fatalf("RunCmd run: %v", err) |
| + } |
| + repA := rep.Load() |
| + held, letGo := make(chan struct{}), make(chan struct{}) |
| + var once, released sync.Once |
| + release := func() { released.Do(func() { close(letGo) }) } |
| + t.Cleanup(release) |
| + b.omu.Lock() |
| + b.onOneShotOf = func(role instancectl.Role) { |
| + if role == instancectl.RoleTTY { |
| + once.Do(func() { close(held) }) |
| + <-letGo |
| + } |
| + } |
| + b.omu.Unlock() |
| + repA.lose(errors.New("renew: the lock was taken")) |
| + select { |
| + case <-held: |
| + case <-time.After(5 * time.Second): |
| + t.Fatal("no tty kill was issued at the loss") |
| + } |
| + a.mu.Lock() |
| + e := a.entries[host] |
| + a.mu.Unlock() |
| + waitFor(t, "the run's lease stop to return", func() bool { |
| + a.mu.Lock() |
| + defer a.mu.Unlock() |
| + return e.leaseStops[instancectl.RoleCmd] == 0 |
| + }) |
| + a.mu.Lock() |
| + ttyStops := e.leaseStops[instancectl.RoleTTY] |
| + a.mu.Unlock() |
| + if ttyStops != 1 { |
| + t.Fatalf("the entry counts %d tty lease stops while the session's kill is on its way, want 1", ttyStops) |
| + } |
| + for _, h := range []CmdHandle{ses, run} { |
| + if err := h.Stop(context.Background()); err != nil { |
| + t.Fatal(err) |
| + } |
| + h.Release() |
| + } |
| + a.mu.Lock() |
| + ttyBusy, cmdBusy := holdBusyLocked(e, instancectl.RoleTTY), holdBusyLocked(e, instancectl.RoleCmd) |
| + a.mu.Unlock() |
| + if !ttyBusy || cmdBusy { |
| + t.Fatalf("with only the tty kill out: tty unit busy %v, cmd unit busy %v; want true, false", ttyBusy, cmdBusy) |
| + } |
| + a.Bounce(host) |
| + for i := 0; i < 10; i++ { |
| + clk.advance(time.Minute) |
| + a.sweepOnce() |
| + time.Sleep(20 * time.Millisecond) |
| + } |
| + if repA.isClosed() || !a.hasEntry(host) { |
| + t.Fatalf("the lease was given back (%v) or the entry let go while the tty kill was on its way", repA.isClosed()) |
| + } |
| + release() |
| + finishStopOf(t, a, clk, host) |
| + ev := b.events() |
| + if k, c := lastIndexOf(ev, "killoneshot:tty"), indexWithPrefix(ev, "close"); k < 0 || c < k { |
| + t.Fatalf("events %v: the lease was given back before the tty kill returned", ev) |
| + } |
| +} |
diff --git a/internal/activator/rootfs_swap_release_test.go b/internal/activator/rootfs_swap_release_test.go| index 57ba67812..860a80109 100644 |
| --- a/internal/activator/rootfs_swap_release_test.go |
| +++ b/internal/activator/rootfs_swap_release_test.go |
| @@ -25,6 +25,7 @@ import ( |
| "testing" |
| "time" |
| + "github.com/carlosframework/platform/internal/instancectl" |
| "github.com/carlosframework/platform/internal/lease" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| @@ -645,7 +646,7 @@ func TestOverlapAbandonsWhileARunIsOpen(t *testing.T) { |
| incumbent := f.b.lastProc() |
| f.a.mu.Lock() |
| e := f.a.entries[f.host] |
| - e.cmd = newCmdHold("run_a", func() {}, f.a.now) |
| + e.cmd = newCmdHold("run_a", instancectl.RoleCmd, func() {}, f.a.now) |
| f.a.mu.Unlock() |
| t.Cleanup(func() { |
| f.a.mu.Lock() |
diff --git a/internal/activator/rootfsrelease.go b/internal/activator/rootfsrelease.go| index 6244ca4d5..53f2c8b66 100644 |
| --- a/internal/activator/rootfsrelease.go |
| +++ b/internal/activator/rootfsrelease.go |
| @@ -420,7 +420,7 @@ func (a *Service) runRelease(ctx context.Context, e *actEntry, rt registry.Route |
| rctx, cancel := context.WithCancelCause(ctx) |
| defer cancel(nil) |
| op := &releaseOp{host: host, build: id, cancel: cancel, owner: e, state: releaseRunning, done: make(chan struct{})} |
| - op.hold = newCmdHold("release", func() { cancel(context.Canceled) }, a.now) |
| + op.hold = newCmdHold("release", instancectl.RoleCmd, func() { cancel(context.Canceled) }, a.now) |
| op.hold.starting = true |
| op.hold.onProven = func() { a.releaseProven(op) } |
| startedClosed := false |
| @@ -572,7 +572,9 @@ func (a *Service) runRelease(ctx context.Context, e *actEntry, rt registry.Route |
| // own exclusions, mirrored from Swap's (swap.go) [pf R1.10], so a release |
| // never runs for a swap the admission then refuses. The caller holds a.mu. |
| func (a *Service) releaseAdmitLocked(e *actEntry) error { |
| - if cmdBusyLocked(e) { |
| + // The cmd unit only: a session runs in its own tty unit and never |
| + // holds a release (rootfs apps Plan 6 Task 9, PF-17). |
| + if holdBusyLocked(e, instancectl.RoleCmd) { |
| return errSwapBusy |
| } |
| if e.state != actAwake { |
diff --git a/internal/activator/rootfsrelease_test.go b/internal/activator/rootfsrelease_test.go| index 0343aab26..469dfd807 100644 |
| --- a/internal/activator/rootfsrelease_test.go |
| +++ b/internal/activator/rootfsrelease_test.go |
| @@ -866,7 +866,7 @@ func TestReleaseNotDueStartsNothing(t *testing.T) { |
| func TestReleaseRefusedWhileARunHoldsTheUnit(t *testing.T) { |
| r := newReleaseRig(t) |
| r.a.mu.Lock() |
| - r.e.cmd = newCmdHold("r1", nil, r.a.now) |
| + r.e.cmd = newCmdHold("r1", instancectl.RoleCmd, nil, r.a.now) |
| r.a.mu.Unlock() |
| ex, err := r.runNow(t) |
| if ex || !errors.Is(err, errSwapBusy) || r.b.startCount() != 0 { |
| @@ -875,7 +875,7 @@ func TestReleaseRefusedWhileARunHoldsTheUnit(t *testing.T) { |
| r.noRecord(t, "beside a run") |
| // A run released but not proven settled holds the unit too. |
| r.a.mu.Lock() |
| - left := newCmdHold("r0", nil, r.a.now) |
| + left := newCmdHold("r0", instancectl.RoleCmd, nil, r.a.now) |
| r.e.cmd, r.e.cmdLeft = nil, []*cmdHold{left} |
| r.a.mu.Unlock() |
| if _, err := r.runNow(t); !errors.Is(err, errSwapBusy) || r.b.startCount() != 0 { |
diff --git a/internal/host/runexec_linux_test.go b/internal/host/runexec_linux_test.go| index a81268daf..5941b2d92 100644 |
| --- a/internal/host/runexec_linux_test.go |
| +++ b/internal/host/runexec_linux_test.go |
| @@ -62,6 +62,7 @@ func (h *fakeHandle) Poll(ctx context.Context) (instancectl.CmdStatus, error) { |
| return instancectl.CmdStatus{}, ctx.Err() |
| } |
| } |
| +func (h *fakeHandle) Terminal() activator.Terminal { return nil } |
| func (h *fakeHandle) Interrupted() (string, time.Time) { |
| h.mu.Lock() |
| defer h.mu.Unlock() |
diff --git a/internal/provision/seed.go b/internal/provision/seed.go| index e8276fb5c..67fbd29d8 100644 |
| --- a/internal/provision/seed.go |
| +++ b/internal/provision/seed.go |
| @@ -215,6 +215,13 @@ func SeedRefuse(id, reason string) func(*Record) error { |
| // specs scope that rule to the import; a --from seed's abort is its door's |
| // own failure path, and a run admitted on the reserved record must not |
| // leave it stuck reserving. |
| +// |
| +// So is an import's abort while a session is open (rec.Interactive, rootfs |
| +// apps Plan 6 Task 9): an InteractiveOpenError, so errors.Is(err, |
| +// ErrInteractiveOpen). The rollback writes the instance's database, which |
| +// the session's command may be writing; session admission already refuses |
| +// an uncommitted import (InteractiveAdmit), as run admission does. A |
| +// --from seed's abort ignores the marker, as it ignores a run. |
| func SeedAbort(id string) func(*Record) error { return SeedAbortBecause(id, "") } |
| // SeedAbortBecause is SeedAbort recording why in Reason: the sentence the |
| @@ -234,6 +241,9 @@ func SeedAbortBecause(id, reason string) func(*Record) error { |
| if rec.Seed.Import() && rec.ActiveRun.Open() { |
| return &RunOpenError{Run: *rec.ActiveRun} |
| } |
| + if rec.Seed.Import() && rec.Interactive != nil { |
| + return &InteractiveOpenError{State: *rec.Interactive} |
| + } |
| rec.Seed.State = seeds.StateAborted |
| if reason != "" { |
| rec.Seed.Reason = reason |
diff --git a/internal/provision/seed_test.go b/internal/provision/seed_test.go| index e23878af4..be759a41a 100644 |
| --- a/internal/provision/seed_test.go |
| +++ b/internal/provision/seed_test.go |
| @@ -8,6 +8,7 @@ import ( |
| "testing" |
| "time" |
| + "github.com/carlosframework/platform/internal/domains" |
| "github.com/carlosframework/platform/internal/release" |
| "github.com/carlosframework/platform/internal/seeds" |
| ) |
| @@ -391,6 +392,70 @@ func TestSeedAbortOfAnImportWaitsForAnOpenRun(t *testing.T) { |
| } |
| } |
| +// Rootfs apps Plan 6 Task 9 (carried from Task 3's review): an import's |
| +// abort, whose rollback writes the instance's database, is refused while |
| +// a session is open on the instance, as it is while a run is, although |
| +// session admission already refuses an uncommitted import. Every abort |
| +// form refuses; once the session's marker is cleared the abort goes |
| +// through. A --from seed's abort, its door's own failure path, ignores |
| +// the marker, as it ignores a run. |
| +func TestSeedAbortOfAnImportWaitsForAnOpenSession(t *testing.T) { |
| + ctx := context.Background() |
| + acct := domains.Sqid(7) |
| + marker := &InteractiveState{ID: "ses_a", Console: "boot-1", PickupBy: time.Now().Add(time.Minute).UTC()} |
| + newRec := func(t *testing.T, s release.Store, seed *SeedSource) Record { |
| + t.Helper() |
| + rec := Record{ |
| + Schema: 1, Host: "shop.example.com", Slug: "shop", App: "shop", Account: acct, |
| + Channel: "stable", CreatedAt: time.Date(2026, 10, 8, 9, 0, 0, 0, time.UTC), Seed: seed, |
| + Interactive: marker, |
| + } |
| + if err := CreateRecord(ctx, s, rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + return rec |
| + } |
| + for name, abort := range map[string]func(seed *SeedSource) func(*Record) error{ |
| + "SeedAbort": func(seed *SeedSource) func(*Record) error { return SeedAbort(seed.ID) }, |
| + "SeedAbortBecause": func(seed *SeedSource) func(*Record) error { return SeedAbortBecause(seed.ID, "the copy failed") }, |
| + "SeedAbortUploadBecause": func(seed *SeedSource) func(*Record) error { |
| + return SeedAbortUploadBecause(seed.ID, "the upload failed") |
| + }, |
| + "SeedAbortStale": func(seed *SeedSource) func(*Record) error { return SeedAbortStale(seed.ID, seed.State, seed.At) }, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + seed := testSeed(t, seeds.KindImport, seeds.StatePlaced) |
| + if name == "SeedAbortUploadBecause" { |
| + seed.State = seeds.StateAwaitingUpload |
| + } |
| + rec := newRec(t, s, seed) |
| + _, err := SetRecordSeed(ctx, s, rec.Account, rec.App, rec.Host, abort(seed)) |
| + var open *InteractiveOpenError |
| + if !errors.Is(err, ErrInteractiveOpen) || !errors.As(err, &open) || open.State.ID != "ses_a" { |
| + t.Fatalf("abort with a session open: err = %v, want an InteractiveOpenError naming ses_a", err) |
| + } |
| + if got, err := GetRecord(ctx, s, rec.Account, rec.App, rec.Host); err != nil || got.Seed.State != seed.State { |
| + t.Fatalf("after the refusal: %+v, %v; want the seed still %s", got, err, seed.State) |
| + } |
| + if _, err := SetRecordInteractive(ctx, s, rec.Account, rec.App, rec.Host, InteractiveClear("ses_a")); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, err := SetRecordSeed(ctx, s, rec.Account, rec.App, rec.Host, abort(seed)); err != nil || got.Seed.State != seeds.StateAborted { |
| + t.Fatalf("abort with the session gone: %+v, %v", got, err) |
| + } |
| + }) |
| + } |
| + t.Run("a --from seed", func(t *testing.T) { |
| + s := release.NewDirStore(t.TempDir()) |
| + seed := testSeed(t, seeds.KindReplica, seeds.StateReserving) |
| + rec := newRec(t, s, seed) |
| + if got, err := SetRecordSeed(ctx, s, rec.Account, rec.App, rec.Host, SeedAbort(seed.ID)); err != nil || got.Seed.State != seeds.StateAborted { |
| + t.Fatalf("a --from seed's abort beside a session: %+v, %v", got, err) |
| + } |
| + }) |
| +} |
| + |
| // A --from seed's abort is the door's own failure path (spec §4 step 7): a |
| // run admitted on the reserved record must not leave it stuck reserving. |
| func TestSeedAbortOfAReplicaIgnoresAnOpenRun(t *testing.T) { |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index ae92fd462..24c10f11e 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 b36c59a06b5a30cbcddce32c5843f8ba76bfca5e37e119c8562e313d1500d5f2 |
| +plan14-root-reads-rootfs-apps-6.tsv 1dca4fb512d2fae76fd23a4a36fbf50402eaa6a9223a025ad17d91c5cbedb682 |
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 9d868bd43..c7984fddc 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv |
| @@ -1,13 +1,16 @@ |
| # 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. |
| -# 20 body, 5 sites, 9 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 24 body, 5 sites, 9 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| # 1 removed: each unit's declaration, or each envelope's directory, is absent from the scanned tree, so its row goes, a frozen declaration is retired as absent, and an envelope is retired. |
| # 17 new dispositions: 1 reads re-frozen at their disposition with the claim, 16 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| -@legacy 55df17ea73134f602af4b4aa2280eb646c1a311b9d5a13aedecd59d0cdbabf95 internal/activator/activator.go Service.finishStop legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with a run's settle checked before replication closes, which keeps the stop pending until the run is proven stopped; read sites unchanged, offsets moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: an HA entry (its replica is an HA one, haEntryRep) now releases through releaseHAClean (a new unit on this card) instead of e.rep.Close; when that answers errHostSliceUnproven the stop is kept pending (keepPendingLocked) with the lease held and renewing, and the sweep finishes it once proven; a non-HA entry is unchanged; the same five sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: a forgotten entry's stop is noted for its resident (noteResidentStopLocked: crash or lost lease backs off, any other stop restarts on the next tick) and its ownerDone channel is closed; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: while the host has a release command's record (a.releaseOps[e.host], running or not proven stopped), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the record's proof; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.20: while a rootfs worker may run or is a stray (rootfsWorkersLiveLocked, in-memory, read under a.mu), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the workers are proven stopped; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1 (Astra P1): beside the worker check, under the same lock, a stop with a lease stop of its commands outstanding (e.leaseStops) is kept pending, the replica and lease held, and the sweep finishes it once they have returned; the entry is never released while a kill captured for it may still reach its unit; the same five read sites, no read added registry:Socket@4054,registry:Socket@4159,whole:Route@4004,whole:Route@4056,whole:Route@4161 c565cc2dc400f420ac39130adcd32659f04d3330d8d8551f2f48afd76a696369 |
| +@legacy 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 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 74f64f4524a22200b784d5dd4cb4506d4eef3e9b9d95376cc80c2bddeb5ca182 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 cmd-unit holds and cmd-unit lease stops refuse a release command, never a 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 while one is; no read added, read sites unchanged registry:Kind@309,whole:Route@311,whole:Route@390 34030a95c61049ed6a25bd9b3e24690d72e9532aa4d6ce58e237ff085e15dc18 |
| +@legacy 674cf44c939f32e93617eb9f0c9653554b4d22d81bc0d09454fe5df8ba61c793 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 |
| @legacy 6d257f47ef6aac75f3139d8e0ea689774fb9bd3bfca50c0f321573a483ded5e9 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 |
| @legacy ee96c9cf9e4e6b0dea8325a3eaf0053773b3a20d3940afe881a0db8aa71b2d23 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 |
| @legacy c986824bab7acb9d785c21f3a48d18f8e678d9252eaea80839ec869f52787a5e 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 |
| @@ -21,12 +24,13 @@ |
| @legacy eaf433e09f4fce09c3df3357d5811657d4db19eb29eccd96df40666f382fb49d internal/instanceexec/probe.go productionProbeEnv legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=the binary probe's env gains boxAddrs (instancectl.BoxAddrsPath, /opt/carlos/box-addrs), which boxAddrClosed (a decision row) reads inside the probe unit, and mmapWX (realMmapWX, an anonymous mapping); the same one direct site;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5 (PF-8): the binary probe env sets devPts=/dev/pts and openPtmx (open /dev/ptmx O_RDWR|O_NOCTTY and close at once), the fields the rootfs probe env already set; read by the new pts-private line inside the probe unit (as carlos, in the namespace); fix round 1: also reads its own environment, CARLOS_PROBE_PTS_PRIVATE (exactly "1" enforces pts-private; otherwise the line is reported unverified), which the probe unit sets; the same direct site, no new root read data-literal@67 9de3096aec14bb54d72ee47eceb866cc2b6b80fcda8206cf9a4d5476f0f0d177 |
| @legacy 7282b3718ce918bbd9d7e4dce31a4737bca6eddb45048749c502c8261c740cf8 internal/layout/plan.go NestedPlatformNames legacy accepted-legacy accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, called only from the agent's offline sealer and source retire (IsNestedPlatformName): a fixed list of names, reads nothing;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the fixed role list gains RoleTTY, so launch.tty.json is one more fixed platform name; still reads nothing data-literal@84 faf3813dcb08f2e153a45b53f4461899327775c298419fc7fe817e80110119d0 |
| @legacy 438a9858d01281800b89923ab2c4bf47bba5c3eab23e07fe43af9a5e3a9ae755 internal/provision/reconcile.go Reconcile legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-rootfs-apps-6;basis=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 registry:Account@36233,registry:Account@37498,registry:Account@55577,registry:Account@55623,registry:Account@56467,registry:Account@56844,registry:Account@57070,registry:Account@57137,registry:Account@57183,registry:Account@57276,registry:Account@57318,registry:Account@57966,registry:Account@58224,registry:Account@58764,registry:Account@58812,registry:Account@59185,registry:Account@59231,registry:Account@59476,registry:Account@59901,registry:Account@60389,registry:Account@61125,registry:Account@61318,registry:Account@61664,registry:Account@62229,registry:App@36206,registry:App@37471,registry:App@55597,registry:App@55635,registry:App@56479,registry:App@56856,registry:App@57082,registry:App@57157,registry:App@57195,registry:App@57296,registry:App@57978,registry:App@58236,registry:App@58776,registry:App@58824,registry:App@59205,registry:App@59243,registry:App@59488,registry:App@59913,registry:App@60401,registry:App@61137,registry:App@61330,registry:App@61676,registry:App@62241,registry:ClaimOwnership@36820,registry:DBPath@45677,registry:DBPath@45692,registry:DBPath@45938,registry:DBPath@46541,registry:DBPath@46554,registry:EgressAllow@35319,registry:Gate@42022,registry:Gate@42162,registry:Gate@42449,registry:Hibernate@40694,registry:Hibernate@40892,registry:Hibernate@40957,registry:Hibernate@41296,registry:Hibernate@41647,registry:Hibernate@41957,registry:HoldOp@60870,registry:HoldOp@60961,registry:HoldOp@61096,registry:HoldOp@61472,registry:Host@26327,registry:Host@55556,registry:Host@56443,registry:Host@56820,registry:Host@56984,registry:Host@57090,registry:Host@57986,registry:Host@58192,registry:Host@59068,registry:Host@59340,registry:Host@59455,registry:Host@59778,registry:Host@59875,registry:Host@60266,registry:Host@60363,registry:Host@60577,registry:Host@60952,registry:Host@61087,registry:Host@61291,registry:Host@61364,registry:Host@61463,registry:Host@61638,registry:Host@61713,registry:Host@61799,registry:Host@62206,registry:Kind@36962,registry:Kind@37225,registry:Kind@45595,registry:Kind@45608,registry:Kind@45718,registry:Kind@45731,registry:Kind@46452,registry:Kind@46463,registry:Kind@54680,registry:Kind@60568,registry:Kind@61078,registry:Kind@61454,registry:Kind@61629,registry:Kind@61790,registry:PolicyExpiresAt@35344,registry:Pool@54766,registry:Provisioned@36182,registry:Provisioned@37447,registry:Provisioned@54725,registry:RateLimit@42535,registry:RateLimit@42686,registry:RateLimit@42973,registry:Region@54755,registry:Replication@41381,registry:Replication@41508,registry:Runtime@28984,registry:Runtime@29162,registry:Runtime@31367,registry:Runtime@40061,registry:Runtime@40115,registry:Runtime@40319,registry:Seed@44075,registry:SeedSource@43558,registry:Size@35335,registry:Socket@45643,registry:Socket@45658,registry:Socket@45955,registry:Socket@46511,registry:Socket@46524,registry:Unit@45561,registry:Unit@45574,registry:Unit@46478,registry:Unit@46489,whole:ClaimOwnership@36823,whole:ClaimOwnership@36840,whole:Route@26309,whole:Route@26320,whole:Route@26338,whole:Route@27619,whole:Route@29479,whole:Route@29486,whole:Route@29526,whole:Route@29887,whole:Route@30225,whole:Route@30672,whole:Route@30723,whole:Route@30760,whole:Route@32432,whole:Route@32641,whole:Route@32980,whole:Route@32989,whole:Route@33035,whole:Route@35268,whole:Route@35827,whole:Route@36298,whole:Route@36308,whole:Route@36665,whole:Route@36672,whole:Route@36740,whole:Route@37063,whole:Route@38096,whole:Route@41047,whole:Route@45787,whole:Route@47373,whole:Route@47418,whole:Route@47428,whole:Route@48298,whole:Route@49325,whole:Route@54791,whole:Route@54939,whole:Route@56036,whole:Route@56395,whole:Route@56777,whole:Route@61551,whole:Route@62136,whole:Route@62186 be1b699f14a2f8d6935d959dee168bdf6fb556cd78da458f5ba8a1c0e8512a17 |
| +@legacy da695cf047ad1ddad8d36bfc6ab71bae2afe595233e3628f4e990b10d3221950 internal/provision/seed.go SeedAbortBecause legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the console (cmd/console serve under console.service, user carlos-console): the record transition the --from door aborts a seed with, recording its reason;rev3=census-ruling-rootfs-apps-6;basis=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 file:Open@432 1b3914ea6c6e599868c2736ab21601b8f112acab9220119e633fbf7fbd4c32c2 |
| @legacy 432e0850cbdf6796ff4582bada35e5617292317b50f822fb18896cd64819f35e internal/activator/backend_rootfs.go ExecBackend.KillOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a (Call A1), new: a rootfs row only (else errOneShotKillBinary) and a one-shot role only (cmd or tty): StopRootfs(host, role, 0, no worker, kill) to root's existing /stop on DeadlineControl, then waitRoleCgroupEmpty (unitEvents on the role's rootfs unit) on roleEmptyBound; nil is the proof; the registry:Host sites are log and error text and the host passed to root, which names the unit from its own validated host; fix round 2: root's kill waits on oneShotKillControlBound, a package var equal to DeadlineControl (30 s) so a test can shrink it, in place of the constant; the same budgets, the same reads registry:Host@1023,registry:Host@154,registry:Host@279,registry:Host@374,registry:Host@433,registry:Host@559,registry:Host@657,registry:Host@716,registry:Host@954,whole:Route@877 8168e9fc15e050df81837e7a66e6d20feed7df36639d119f14824c8be3bcbad5 |
| @legacy 6f89b17e52b3166bcee93563263c4d66854ff60dab0dc6fecbca8a4f08b352a5 internal/activator/backend_rootfs.go ExecBackend.startRootfsRun legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: StartCmd's rootfs arm: refuses a run with no serving image (errNoCmdExe) or a partial one (errPartialStagedIdentity), both marked, and one with no launch environment (errNoGenEnv); asks replicaKeyGate; composes rootfsCmdVars over the generation's launch environment and the row's dbPath; then startRootfsCmd with the operator's argv exactly as given; root validates the image by digest and runs the argv inside the instance's namespace; the registry:Host sites are error text; Plan 6 Task 8: also a session rootfs arm: the same serving-image, partial-identity, launch-environment and replica-key refusals first; with spec.TTY set it composes rootfsTTYVars (no run id or directory; TERM and CARLOS_SESSION_ID) and starts startRootfsCmd in the tty role with spec.Process (console) or spec.Args, else rootfsCmdVars and the cmd role as before; +whole:Route x2 are rt to rootfsTTYVars and the dbPath read once for both registry:Host@192,registry:Host@450,registry:Host@587,whole:Route@1013,whole:Route@1160,whole:Route@1240,whole:Route@773,whole:Route@872,whole:Route@930 62055615354e08d3c3ca91486ab3e0604367a1f013e263984df2962dafcf26b3 |
| @legacy c6d7609e34806d3c51e249713109f3bb9bae3c0645d4b6bf9f8190e48f9ce88b internal/activator/backend_unit.go SplitBackend.KillOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: forwards KillOneShot by pick(rt), as KillGen does; a half without it refuses (errOneShotKillBinary); reads only the route registry:Host@219,whole:Route@123,whole:Route@286 59823fbe5e35c5b54e0843a681ad59f684bd28e3a8315c1571198b3e5c43d3ee |
| @legacy d6543d9dad5ac1da40d0cbaaa7cfefb37f8c0b473c902957dc27420a61371899 internal/activator/cmd.go Service.killOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: the backend's KillOneShot (oneShotKiller) for one run, bounded by DeadlineControl plus roleEmptyBound, logged either way; the registry:Host sites are log lines registry:Host@240,registry:Host@549,registry:Host@680,whole:Route@398 3eb9bb7269c2a5fc8d4c798d884d92f7fa32eddbde588a3c9ad2d741211b869b |
| @legacy acd4a733f1d39bf9444302ee997852e46f6cdd946f2d68b1baa7c9b02400ea6b internal/activator/cmd.go Service.stopOneShotAtLease legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one run hold's lease stop, off a.mu: with kill, killOneShot at once and again once a start that was in flight returns a unit; then the hold's own stop (StopLeaseLost) bounded by cmdStopBound; the registry:Host sites are log lines registry:Host@714,registry:Host@961,whole:Route@309,whole:Route@529 46c39957f77353866dc7d8adbababfde54bd8634f5669fd61c3011a54f5e7c9a |
| -@legacy 3f9867cb5b71307489417d708ab6f5ebe66aebfdc2ff017d9b28d0fcc28fbba5 internal/activator/cmd.go Service.stopOneShotsAtLeaseLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one stopOneShotAtLease func per run hold that may be running (cmdHoldsLocked), none for a binary row (rt.Rootfs()); in memory only; fix round 1 (Astra P1): each func is counted on the entry it was captured for (e.leaseStops, under a.mu) from capture until it returns, so its kill, which names the unit by host and role only, never reaches another command: while counted the entry is not released (finishStop keeps the stop pending, the lease held) and takes no new run or release command (cmdBusyLocked); no read added whole:Route@338 fb82ec32cafeed4d228a07dfad0c12768db2804688477471597c505eb3707009 |
| +@legacy 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 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 |
| @@ -39,17 +43,20 @@ |
| @legacy 8e00efef4ecab3057d44b14e01fba5aa93e5359ba841c4fea91b57487481202f internal/instanceexec/tty_linux.go receivePTY legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7 (PF-9), new: the trampoline's tty role, run by instance-exec [--rootfs] tty %I as carlos inside the instance's namespace (never root): one recvmsg on its own stdin (the tty unit's StandardInput= socket to the agent), exactly the hello carlos-tty/1 and exactly one SCM_RIGHTS fd (received close-on-exec), else refused with every received fd closed; the one Fstat is of that received fd, which must be a character device of a Unix98 pty slave major (136-143) that answers TCGETS, else refused and closed; it opens, runs and follows no path; the fd becomes only the tenant's stdio and controlling terminal (runTTYInit through runInitChecked, which closes the init's copy after the fork); no root process reads anything new file:Fstat@1454 1099af8a1dc0732b74afbe42bc45ccce6df3db9662ff7dc41f278e2bd4a274ce |
| @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 24677dea5779d57c560884eebbeea0abdcb9389b985089aefd1bf4f44bcc7b7f internal/activator/cmd.go Service.RunCmd legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): admits one run against an awake entry under the agent's own lease, fence and swap checks; it starts nothing itself and root validates what it later names;rev3=census-ruling-edge-request-records;basis=passes nil for begin's new req parameter; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: a carlos run is refused with ErrCmdBusy while a release record of the host is open (a.releaseOps[rt.Host], in-memory), as a run already in flight refuses it; new site +registry:Host (that map lookup); adds a refusal only;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a: AfterSettled honoured on every path (called before return on each path that starts no unit, else by the settle that proves the unit gone); a rootfs run is refused as a lost lease (CmdStoppedError StopLeaseLost) when its entry is not under the lease watch (residentWatchedLocked), and, off a.mu, when the replica's in-memory SafeUntil leaves less than oneShotStartLead (oneShotHeadroom); new sites are e.route.Rootfs() and a log line; adds refusals only file:Prepare@2243,file:Prepare@2277,registry:Host@1371,registry:Host@1696,registry:Host@7249,registry:Host@8485,registry:Kind@437,whole:Route@683,whole:Route@7653,whole:Route@8117,whole:Route@8650,whole:Route@869 36a03283c6c294123e02bb1779bcc6ad0ae273f69297ab35ff37e95cf2e52d8d |
| +@legacy 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 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 |
| -internal/activator/activator.go Service.finishStop legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with a run's settle checked before replication closes, which keeps the stop pending until the run is proven stopped; read sites unchanged, offsets moved;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: an HA entry (its replica is an HA one, haEntryRep) now releases through releaseHAClean (a new unit on this card) instead of e.rep.Close; when that answers errHostSliceUnproven the stop is kept pending (keepPendingLocked) with the lease held and renewing, and the sweep finishes it once proven; a non-HA entry is unchanged; the same five sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: a forgotten entry's stop is noted for its resident (noteResidentStopLocked: crash or lost lease backs off, any other stop restarts on the next tick) and its ownerDone channel is closed; no read added;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: while the host has a release command's record (a.releaseOps[e.host], running or not proven stopped), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the record's proof; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.20: while a rootfs worker may run or is a stray (rootfsWorkersLiveLocked, in-memory, read under a.mu), replication and the lease stay and the stop is kept pending (keepPendingLocked) until the workers are proven stopped; the same five read sites, no read added; only holds a release back;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1 (Astra P1): beside the worker check, under the same lock, a stop with a lease stop of its commands outstanding (e.leaseStops) is kept pending, the replica and lease held, and the sweep finishes it once they have returned; the entry is never released while a kill captured for it may still reach its unit; the same five read sites, no read added registry:Socket@4054,registry:Socket@4159,whole:Route@4004,whole:Route@4056,whole:Route@4161 c565cc2dc400f420ac39130adcd32659f04d3330d8d8551f2f48afd76a696369 |
| +internal/activator/activator.go Service.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 |
| internal/activator/activator.go Service.installProcLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 8: the one place a process, its generation and the lease replica are installed on an entry; a resident is put under its lease watch (watchResidentLeaseLocked) at that moment; reads only the entry's route;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a (Call A1, Astra R1 P1-1): the lease watch is installed for every rootfs row (e.route.Rootfs()), not only a resident, so a hibernating rootfs row's run or session is reached at the lease's loss; the same one read of the entry's route; installs nothing else whole:Route@144 cacc399eb6e09be70d3a2ad1774800fb6a252590cebd62dd0e9f369e97275f81 |
| +internal/activator/activator.go 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/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 cmd-unit holds and cmd-unit lease stops refuse a release command, never a 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 while one is; no read added, read sites unchanged registry:Kind@309,whole:Route@311,whole:Route@390 34030a95c61049ed6a25bd9b3e24690d72e9532aa4d6ce58e237ff085e15dc18 |
| +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/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 |
| @@ -63,12 +70,13 @@ internal/instancectl/server.go type Server legacy accepted-legacy accepted-legac |
| internal/instanceexec/probe.go productionProbeEnv legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=the binary probe's env gains boxAddrs (instancectl.BoxAddrsPath, /opt/carlos/box-addrs), which boxAddrClosed (a decision row) reads inside the probe unit, and mmapWX (realMmapWX, an anonymous mapping); the same one direct site;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5 (PF-8): the binary probe env sets devPts=/dev/pts and openPtmx (open /dev/ptmx O_RDWR|O_NOCTTY and close at once), the fields the rootfs probe env already set; read by the new pts-private line inside the probe unit (as carlos, in the namespace); fix round 1: also reads its own environment, CARLOS_PROBE_PTS_PRIVATE (exactly "1" enforces pts-private; otherwise the line is reported unverified), which the probe unit sets; the same direct site, no new root read data-literal@67 9de3096aec14bb54d72ee47eceb866cc2b6b80fcda8206cf9a4d5476f0f0d177 |
| internal/layout/plan.go NestedPlatformNames legacy accepted-legacy accepted-legacy;rev3=census-ruling-moves-offline;basis=root-input (J4, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, called only from the agent's offline sealer and source retire (IsNestedPlatformName): a fixed list of names, reads nothing;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: the fixed role list gains RoleTTY, so launch.tty.json is one more fixed platform name; still reads nothing data-literal@84 faf3813dcb08f2e153a45b53f4461899327775c298419fc7fe817e80110119d0 |
| internal/provision/reconcile.go Reconcile legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-rootfs-apps-6;basis=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 registry:Account@36233,registry:Account@37498,registry:Account@55577,registry:Account@55623,registry:Account@56467,registry:Account@56844,registry:Account@57070,registry:Account@57137,registry:Account@57183,registry:Account@57276,registry:Account@57318,registry:Account@57966,registry:Account@58224,registry:Account@58764,registry:Account@58812,registry:Account@59185,registry:Account@59231,registry:Account@59476,registry:Account@59901,registry:Account@60389,registry:Account@61125,registry:Account@61318,registry:Account@61664,registry:Account@62229,registry:App@36206,registry:App@37471,registry:App@55597,registry:App@55635,registry:App@56479,registry:App@56856,registry:App@57082,registry:App@57157,registry:App@57195,registry:App@57296,registry:App@57978,registry:App@58236,registry:App@58776,registry:App@58824,registry:App@59205,registry:App@59243,registry:App@59488,registry:App@59913,registry:App@60401,registry:App@61137,registry:App@61330,registry:App@61676,registry:App@62241,registry:ClaimOwnership@36820,registry:DBPath@45677,registry:DBPath@45692,registry:DBPath@45938,registry:DBPath@46541,registry:DBPath@46554,registry:EgressAllow@35319,registry:Gate@42022,registry:Gate@42162,registry:Gate@42449,registry:Hibernate@40694,registry:Hibernate@40892,registry:Hibernate@40957,registry:Hibernate@41296,registry:Hibernate@41647,registry:Hibernate@41957,registry:HoldOp@60870,registry:HoldOp@60961,registry:HoldOp@61096,registry:HoldOp@61472,registry:Host@26327,registry:Host@55556,registry:Host@56443,registry:Host@56820,registry:Host@56984,registry:Host@57090,registry:Host@57986,registry:Host@58192,registry:Host@59068,registry:Host@59340,registry:Host@59455,registry:Host@59778,registry:Host@59875,registry:Host@60266,registry:Host@60363,registry:Host@60577,registry:Host@60952,registry:Host@61087,registry:Host@61291,registry:Host@61364,registry:Host@61463,registry:Host@61638,registry:Host@61713,registry:Host@61799,registry:Host@62206,registry:Kind@36962,registry:Kind@37225,registry:Kind@45595,registry:Kind@45608,registry:Kind@45718,registry:Kind@45731,registry:Kind@46452,registry:Kind@46463,registry:Kind@54680,registry:Kind@60568,registry:Kind@61078,registry:Kind@61454,registry:Kind@61629,registry:Kind@61790,registry:PolicyExpiresAt@35344,registry:Pool@54766,registry:Provisioned@36182,registry:Provisioned@37447,registry:Provisioned@54725,registry:RateLimit@42535,registry:RateLimit@42686,registry:RateLimit@42973,registry:Region@54755,registry:Replication@41381,registry:Replication@41508,registry:Runtime@28984,registry:Runtime@29162,registry:Runtime@31367,registry:Runtime@40061,registry:Runtime@40115,registry:Runtime@40319,registry:Seed@44075,registry:SeedSource@43558,registry:Size@35335,registry:Socket@45643,registry:Socket@45658,registry:Socket@45955,registry:Socket@46511,registry:Socket@46524,registry:Unit@45561,registry:Unit@45574,registry:Unit@46478,registry:Unit@46489,whole:ClaimOwnership@36823,whole:ClaimOwnership@36840,whole:Route@26309,whole:Route@26320,whole:Route@26338,whole:Route@27619,whole:Route@29479,whole:Route@29486,whole:Route@29526,whole:Route@29887,whole:Route@30225,whole:Route@30672,whole:Route@30723,whole:Route@30760,whole:Route@32432,whole:Route@32641,whole:Route@32980,whole:Route@32989,whole:Route@33035,whole:Route@35268,whole:Route@35827,whole:Route@36298,whole:Route@36308,whole:Route@36665,whole:Route@36672,whole:Route@36740,whole:Route@37063,whole:Route@38096,whole:Route@41047,whole:Route@45787,whole:Route@47373,whole:Route@47418,whole:Route@47428,whole:Route@48298,whole:Route@49325,whole:Route@54791,whole:Route@54939,whole:Route@56036,whole:Route@56395,whole:Route@56777,whole:Route@61551,whole:Route@62136,whole:Route@62186 be1b699f14a2f8d6935d959dee168bdf6fb556cd78da458f5ba8a1c0e8512a17 |
| +internal/provision/seed.go SeedAbortBecause legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the console (cmd/console serve under console.service, user carlos-console): the record transition the --from door aborts a seed with, recording its reason;rev3=census-ruling-rootfs-apps-6;basis=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 file:Open@432 1b3914ea6c6e599868c2736ab21601b8f112acab9220119e633fbf7fbd4c32c2 |
| internal/activator/backend_rootfs.go ExecBackend.KillOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a (Call A1), new: a rootfs row only (else errOneShotKillBinary) and a one-shot role only (cmd or tty): StopRootfs(host, role, 0, no worker, kill) to root's existing /stop on DeadlineControl, then waitRoleCgroupEmpty (unitEvents on the role's rootfs unit) on roleEmptyBound; nil is the proof; the registry:Host sites are log and error text and the host passed to root, which names the unit from its own validated host; fix round 2: root's kill waits on oneShotKillControlBound, a package var equal to DeadlineControl (30 s) so a test can shrink it, in place of the constant; the same budgets, the same reads registry:Host@1023,registry:Host@154,registry:Host@279,registry:Host@374,registry:Host@433,registry:Host@559,registry:Host@657,registry:Host@716,registry:Host@954,whole:Route@877 8168e9fc15e050df81837e7a66e6d20feed7df36639d119f14824c8be3bcbad5 |
| internal/activator/backend_rootfs.go ExecBackend.startRootfsRun legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: StartCmd's rootfs arm: refuses a run with no serving image (errNoCmdExe) or a partial one (errPartialStagedIdentity), both marked, and one with no launch environment (errNoGenEnv); asks replicaKeyGate; composes rootfsCmdVars over the generation's launch environment and the row's dbPath; then startRootfsCmd with the operator's argv exactly as given; root validates the image by digest and runs the argv inside the instance's namespace; the registry:Host sites are error text; Plan 6 Task 8: also a session rootfs arm: the same serving-image, partial-identity, launch-environment and replica-key refusals first; with spec.TTY set it composes rootfsTTYVars (no run id or directory; TERM and CARLOS_SESSION_ID) and starts startRootfsCmd in the tty role with spec.Process (console) or spec.Args, else rootfsCmdVars and the cmd role as before; +whole:Route x2 are rt to rootfsTTYVars and the dbPath read once for both registry:Host@192,registry:Host@450,registry:Host@587,whole:Route@1013,whole:Route@1160,whole:Route@1240,whole:Route@773,whole:Route@872,whole:Route@930 62055615354e08d3c3ca91486ab3e0604367a1f013e263984df2962dafcf26b3 |
| internal/activator/backend_unit.go SplitBackend.KillOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: forwards KillOneShot by pick(rt), as KillGen does; a half without it refuses (errOneShotKillBinary); reads only the route registry:Host@219,whole:Route@123,whole:Route@286 59823fbe5e35c5b54e0843a681ad59f684bd28e3a8315c1571198b3e5c43d3ee |
| internal/activator/cmd.go Service.killOneShot legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: the backend's KillOneShot (oneShotKiller) for one run, bounded by DeadlineControl plus roleEmptyBound, logged either way; the registry:Host sites are log lines registry:Host@240,registry:Host@549,registry:Host@680,whole:Route@398 3eb9bb7269c2a5fc8d4c798d884d92f7fa32eddbde588a3c9ad2d741211b869b |
| internal/activator/cmd.go Service.stopOneShotAtLease legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one run hold's lease stop, off a.mu: with kill, killOneShot at once and again once a start that was in flight returns a unit; then the hold's own stop (StopLeaseLost) bounded by cmdStopBound; the registry:Host sites are log lines registry:Host@714,registry:Host@961,whole:Route@309,whole:Route@529 46c39957f77353866dc7d8adbababfde54bd8634f5669fd61c3011a54f5e7c9a |
| -internal/activator/cmd.go Service.stopOneShotsAtLeaseLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a, new: one stopOneShotAtLease func per run hold that may be running (cmdHoldsLocked), none for a binary row (rt.Rootfs()); in memory only; fix round 1 (Astra P1): each func is counted on the entry it was captured for (e.leaseStops, under a.mu) from capture until it returns, so its kill, which names the unit by host and role only, never reaches another command: while counted the entry is not released (finishStop keeps the stop pending, the lease held) and takes no new run or release command (cmdBusyLocked); no read added whole:Route@338 fb82ec32cafeed4d228a07dfad0c12768db2804688477471597c505eb3707009 |
| +internal/activator/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/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 |
| @@ -81,18 +89,18 @@ internal/instancectl/cmd.go Server.oneShotStatus legacy accepted-legacy accepted |
| internal/instanceexec/tty_linux.go receivePTY legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7 (PF-9), new: the trampoline's tty role, run by instance-exec [--rootfs] tty %I as carlos inside the instance's namespace (never root): one recvmsg on its own stdin (the tty unit's StandardInput= socket to the agent), exactly the hello carlos-tty/1 and exactly one SCM_RIGHTS fd (received close-on-exec), else refused with every received fd closed; the one Fstat is of that received fd, which must be a character device of a Unix98 pty slave major (136-143) that answers TCGETS, else refused and closed; it opens, runs and follows no path; the fd becomes only the tenant's stdio and controlling terminal (runTTYInit through runInitChecked, which closes the init's copy after the fork); no root process reads anything new file:Fstat@1454 1099af8a1dc0732b74afbe42bc45ccce6df3db9662ff7dc41f278e2bd4a274ce |
| 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 file:Prepare@2243,file:Prepare@2277,registry:Host@1371,registry:Host@1696,registry:Host@7249,registry:Host@8485,registry:Kind@437,whole:Route@683,whole:Route@7653,whole:Route@8117,whole:Route@8650,whole:Route@869 36a03283c6c294123e02bb1779bcc6ad0ae273f69297ab35ff37e95cf2e52d8d |
| +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/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 a101487c05860ca19b284f2ca0b014d69d8dc0f9217cf93108166634a81ae0a3 |
| +@coverage internal/activator b050e60f27b14ee5a75d64603bcbce3a0b23e5af4c9d562c64992477f0bae345 |
| @coverage internal/appconfig cac8d8ef7538a456d034801c95ce6508a4983e5516b3bbbd302bec0fbafdd479 |
| @coverage internal/host 69c09eff5b3b87756182f001086b391c02b867e82e8d21ea40722c992fec43a7 |
| @coverage internal/host/units c3cc4f3b917fdb938f20d406b1704ec54e24553851c298e312056d397d10b0e1 |
| @coverage internal/instancectl 096e845eb71478e8b68726160cff450f8ba850869dae65582dabd25f445527e9 |
| @coverage internal/instanceexec 65f6db1c6bf469f1d19615ec989f54c20de3b73c3c03ae2d677cffbcc60470fd |
| @coverage internal/layout 1527c3b31d87743798002b1ebefcd2cb0dc422a8642f72a3ff8dbefbd2c84d9b |
| -@coverage internal/provision e1ecfdc3d169773ac6dd9dc09a6d0feea768ceb1b80195199c5ef74b2f0e6f5c |
| +@coverage internal/provision b987b9c81cae353279ac80747047e3b29783643bfe39c67167a535f3fd529254 |