carlos / platform Public

instance-control: POST /tty and GET /tty/{host} (rootfs plan 6)

The control service's tty routes: POST /tty and GET /tty/{host} are
/cmd's handlers parametrised by role (handleOneShot, handleOneShotStatus,
both claimAwareLegacy), on the tty role's unit, exe sources (tty-app,
tty-live) and lock. The binary and rootfs branches both serve RoleTTY;
the rootfs one is Plan 2's startRootfsCmd with the role, so the jit
drop-in, its owed reload and the effective MemoryDenyWriteExecute check
are shared (R11).

Role-aware throughout (PF-7): start locks keyed by (role, host);
cleanCmdExe, removeCmdExe, ensureCmdExeAt and startRootfsCmd keep their
names and take the role (rev 2 P1-3, removal guard lists unchanged);
rootfsUnitOf, stopRootfs and removeRootfsFiles learn RoleTTY;
resolveRootfsLaunch gives RoleTTY the cmd rule, a declared process keeping
its own env and working_dir (P1-2). /stop and /reset take RoleTTY
(PF-27); /sweep lists both tty prefixes and removes their files.

Client: TTY, TTYExe, TTYStatus, TTYRootfs, TTYStatusRootfs (PF-6).

Census: overlay rootfs-apps-6 re-proposed (PF-14), Astra approves on #280.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 08554c12335659f4e56e5d5c45519eebb7c9f4b5 parent d598601
11 files changed, +1,178 −224
  • docs/superpowers/notes/census-proposal-rootfs-apps-6.md +17 −2
  • internal/instancectl/client.go +56 −10
  • internal/instancectl/cmd.go +93 −52
  • internal/instancectl/cmd_stagedexe_linux_test.go +77 −0
  • internal/instancectl/cmd_test.go +341 −0
  • internal/instancectl/rootfs.go +55 −43
  • internal/instancectl/rootfs_test.go +459 −71
  • internal/instancectl/server.go +27 −22
  • internal/instancectl/stagedexe.go +34 −16
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv +18 −7

Intent

Human

<task-notification> <task-id>a34ee56d494f61538</task-id> <tool-use-id>toolu_01LjkA1Kdxc4iHFRwonHEBSY</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/a34ee56d494f61538.output</output-file> <status>completed</status> <summary>Agent "Plan 6 Task 5: tty role, templates" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status:** DONE. Fix round 1/5 is in. The binary probe now enforces `pts-private` only when its installed unit says it hides `/dev/pts`, so a roll can no longer drop nested readiness in the gap between the new binary and the new units. **Commits:** d5986010 (fix round 1, base 24d2bb23) on top of 24d2bb23 (Task 5). Neither is pushed. **Tests:** Each new test failed before the change and passes after it. The instancectl, instanceexec and layout packages pass in full, the host template, unit and probe tests pass, and so do the provision census tests. Build, vet, gofmt and the three cross-builds are clean. Four mutations were tried and all were caught, including dropping the gate (the old-unit case then fails with `ready=false pts-private=fail`). **What changed:** - **Probe unit:** `carlos-instance-probe.service` now sets `Environment=CARLOS_PROBE_PTS_PRIVATE=1`. The line sits outside the shared namespace block, so the block stays byte-identical with the tenant templates. - **Shared name:** the variable name is a constant, `instancectl.ProbePtsPrivateEnv`, used by both the probe and the unit test. - **Probe:** `productionProbeEnv` reads the variable, and only exactly `1` turns the check on. - **Rootfs probe:** it never reads the variable and always checks. **How a skip is reported:** there is still exactly one `pts-private` line. Under an old unit its verdict is `unverified`, and the detail says the unit doesn't set `CARLOS_PROBE_PTS_PRIVATE=1`. `unverified` is the probe's existing verdict for checks it can't run, and it doesn't block readiness. In that case the probe doesn't touch `/dev/pts` or `/dev/ptmx` at all. **Census:** I re-proposed the `rootfs-apps-6` overlay with every earlier claim carried over word for word. Only two rows changed, the probe unit and `productionProbeEnv`, plus three envelope pins. New seal `83f9adb6…`. **Concerns:** - Those two re-frozen units need Astra's re-approval on #280. Her approval of Task 5's other units still holds. - The comment "the five rootfs units" in the rootfs block is still stale. She rated it minor and to fix later. The fix report is appended to `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-apps-6/.superpowers/sdd/2026-10-24-rootfs-apps-6-interactive/task-5-report.md`.</result> <usage><subagent_tokens>232603</subagent_tokens><tool_uses>16</tool_uses><duration_ms>370643</duration_ms></usage> </task-notification>

Human

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

Human

<task-notification> <task-id>afebcf3315033b41a</task-id> <tool-use-id>toolu_0186V8oE6KcYtP5qr1vDiKh7</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ba9fa944-a429-4788-9b3c-f2b2f42617f3/tasks/afebcf3315033b41a.output</output-file> <status>completed</status> <summary>Agent "#471 Task 4: reload mutex, sweep" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Status: DONE.** I fixed Astra's P1 test-first in one commit, not pushed. **Commit:** `3baa50b5` "edge: a registration racing a revocation is not published (#471 Task 4 fix round 1)", on top of `f7754746`. The message says the fault was there before this branch. **Fix (`internal/edge/tunnel.go`):** - **Re-check:** registration now checks a fleet box's token again under `TunnelHub.mu`, just before it publishes the connection. `SetDynamicAuth` replaces the token set under the same lock, so the two can't overlap. - **Refusal:** a refused connection is closed after the lock is released. - **Shared lookup:** `VerifyDynamic`'s lookup moved into `verifyDynamicLocked`, which both paths now use. `storedoor.go`, the other caller, behaves the same. - **Test seam:** `TunnelHub.afterAuth`, nil in production. **Test:** `TestRegistrationRacingARevocationIsNotPublished` pauses `away/box-2`'s registration at the seam, applies the change, runs `Reload` to completion, then resumes. It has three cases: - **`unchanged`** (control): the channel is published and the forward host answers from box-2. - **`detached`:** the channel is not published or selectable, and the box's connection closes within 2 s. - **`rotated`** (the old token is replaced while the registration is in flight): the same result as `detached`. **Test results:** - **RED:** the control passed; `detached` and `rotated` failed with "connection is still open". - **GREEN:** the new test passes ten times under `-race`. `TestTunnel*`, `TestReload*`, `TestWatch*`, `TestRotate*`, `TestStoreDoor*` and all of Task 4's tests pass under `-race`. The fleetapi and host fleet/door tests pass. Build, vet, gofmt and the darwin, windows and linux/arm64 cross-builds are clean. - **Mutation:** with the re-check disabled, `detached` and `rotated` fail. **Census:** the card is unchanged and no unit changed. I still added one bullet to spec §7's Task 4 paragraph naming these no-row changes, so that paragraph stays complete. **Concerns:** - The test fixes the order: the replacement completes before the publish. It can't detect a re-check moved outside the lock, so that relies on the code's shape and its comment. - When a box re-registers, the hub still closes the old connection while holding the lock. That predates this branch and I left it alone. - My session's working directory switched to `rootfs-apps-6` partway through. All edits and commits went to the `design-tunnel-websockets-471` worktree by absolute path. The fix report is appended to `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-tunnel-websockets-471/.superpowers/sdd/2026-10-30-tunnel-websockets/task-4-report.md`.</result> <usage><subagent_tokens>244097</subagent_tokens><tool_uses>18</tool_uses><duration_ms>384367</duration_ms></usage> </task-notification>

Attributed to this commit: 9.94 g CO₂e (1,045,651 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 40769356e..b7fbb186c 100644
--- a/docs/superpowers/notes/census-proposal-rootfs-apps-6.md
+++ b/docs/superpowers/notes/census-proposal-rootfs-apps-6.md
@@ -1,6 +1,6 @@
# Census approval: rootfs-apps-6
-Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejects every change below, 2 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejects every change below, 3 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
| unit | change | read sites | what changed |
|---|---|---|---|
@@ -10,14 +10,25 @@ Ruling `census-ruling-rootfs-apps-6`. The independent reviewer approves or rejec
| `internal/host/units/carlos-instance-seed@.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-sidecar@.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@.service` `external` | body | unchanged (1) | rootfs Plan 6 Task 5: one namespace-block line added after TemporaryFileSystem=/dev/mqueue:ro, TemporaryFileSystem=/dev/pts:ro (with its comment): PID 1 mounts an empty read-only tmpfs over the private /dev/pts, hiding the host devpts PrivateDevices= binds in; no bind source, Exec line, user or path read by root added; the block stays byte-identical across the binary templates (TestInstanceTemplatesShareOneNamespace) |
+| `internal/instancectl/rootfs.go` `Server.ensureRootfsExe` | body | unchanged (2) | rootfs Plan 6 Task 6: the role check admits both one-shot roles (OneShot: cmd and tty), so a rootfs session's layout is <exe root>/<iid>/rootfs/tty/ beside the cmd one, under the same root-only /run/carlos-control/exe tree, with the same Mkdir/Lstat walk, image link to the path validateStagedImage checked, root's launch.json and the resolver copy; the same two read sites, no read added |
+| `internal/instancectl/rootfs.go` `resolveRootfsLaunch` | body | unchanged (3) | rootfs Plan 6 Task 6 (PF-7): RoleTTY takes RoleCmd's rule in the same arm: a declared process other than web, with that process's own argv, env and working_dir from the root-staged manifest (console for carlos console), or an argv body that runs with web's env and working_dir (launch Process "cmd"); both or neither refused, web refused, an undeclared process refused (RFS-2-C08); refusal texts name the role; it still reads no file, the same three sites |
+| `internal/instancectl/server.go` `type Server` | body | unchanged (1) | rootfs Plan 6 Task 6: comments only: the one-shot pacing fields cover /cmd and /tty, and cmdLocks is now keyed by (role, host) (oneShotKey, PF-7) so a session's start never waits behind a command's; field declarations unchanged; the same one site, no read added |
| `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 |
Envelopes re-pinned: `.`, `internal/appconfig`, `internal/host/units`, `internal/instancectl`, `internal/instanceexec`, `internal/layout`, `internal/provision`.
+Removed units: the scan finds neither the declaration nor any of its sites.
+
+| unit | recorded disposition | basis | what changed |
+|---|---|---|---|
+| `internal/instancectl/cmd.go` `Server.handleCmdStatus` | legacy, task accepted-legacy | accepted-legacy;rev3=census-ruling-carlos-run;basis=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root): extends the J4 seed pattern to the run role. Read-only systemctl state: it answers GET /cmd/{host} with the cmd unit's state from systemctl show, and starts and stops nothing. The one flagged site is the URL's Query, not a file read. No new trust of registry, /data or agent-asserted content beyond the seed path;rev3=census-ruling-rootfs-apps-2;basis=parses the request's URL query again (parseQuery: runtime=rootfs alone picks the rootfs cmd unit, an image field is a 400, role=worker or worker= without runtime=rootfs is a 400), then refuses any role field but cmd on either runtime (task 11 fix F2), so runtime=rootfs&role=worker is a 400, never a poll; two more file:Query sites (the URL query read for parseQuery and again for the role check), beside the invocation's; the same systemctl show of a unit root names from a validated host; no file read added | rootfs Plan 6 Task 6: moved whole to Server.oneShotStatus (role-aware; see its claim), not deleted: no check, refusal or validation is lost |
+
Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+A removed unit's recorded disposition and basis are in its table above. For a removed unit or a retired envelope, confirm from the diff that the code is deleted and not moved: a read that moved shows on this card as a change to the unit that took it, and a unit moved whole shows as a new unit, a decision. Reject if a check, refusal or validation that root relies on goes with the deleted code and its callers' changes on this card do not account for that.
+
Recorded dispositions, which each change must still satisfy:
- `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
@@ -26,6 +37,9 @@ Recorded dispositions, which each change must still satisfy:
- `internal/host/units/carlos-instance-seed@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
- `internal/host/units/carlos-instance-sidecar@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
- `internal/host/units/carlos-instance@.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
+- `internal/instancectl/rootfs.go` `Server.ensureRootfsExe`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root);basis=root-input (J2,J4, as ensureExeAs): new (rootfs Plan 2 Task 5): lays out <exe root>/<key>/rootfs/<role>/ under /run/carlos-control/exe, only root's: Mkdir then Lstat of each level (refusing a non-directory), the image link (replaceLink) to the path validateStagedImage checked, launch.json (root's resolved launch) and a copy of the resolver file; the ReadFile is of resolverFile (/run/systemd/resolve/resolv.conf when present, else /etc/resolv.conf), the box's own, as allowResolvers reads it; key is an instance ID, GenKey or WorkerKey root built from a validated host, refused with a slash, a NUL, . or ..; no tenant file is read
+- `internal/instancectl/rootfs.go` `resolveRootfsLaunch`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root);basis=root-input (J2,J4, as parseRequest): new (rootfs Plan 2 Task 5): the command half of validateStagedImage, over the manifest root read itself (release.ReadStagedManifest beside the validated image): the scanner matches the word Command, here release.Process's argv field, not os/exec; it reads no file; the agent names only the process (web, a worker, a declared cmd process) or, for carlos run, an argv that runs inside the tenant's own namespace where web runs; the argv, env and working dir of a declared process are the manifest's, jit is the manifest's alone; an undeclared process is refused (RFS-2-C08)
+- `internal/instancectl/server.go` `type Server`: 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 292, with no further change from this branch. Census ruling 292 reclassified this declaration accepted-legacy (J2,J4) for root's per-host ordering of legacy run starts against stops; this ruling kept the row as main classed it. Its own addition is the cmd start's poll and wait bounds and its per-host lock map: field declarations only;rev3=census-ruling-rootfs-apps-2;basis=new fields: HostRuntime, ProbeImage, ProbeImageFile, RootfsProbeOut, DenyEvery, the deny's lastDeny and denyMu, the rootfs probe's report and lock, the jit reload counters and imageDigests; genStarting counts binary generation starts per unit; rootfsLocksMu and rootfsLocks, one lock entry per rootfs unit name being started or removed right now, held by a start from its layout through systemctl start and its own cleanup and by a removal from its proof through the raw removal, a removal refusing while it is taken, a waiting start giving up when its request ends, an entry dropped with its last holder or waiter (fixes E6, L2, L3); rootfsProvenHook, a test hook run between the proof and the raw removal; field declarations only; no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 and #329 plan 3 Task 5: the declaration gains sliceLocks (one mutex per host slice, taken by /size and /parent) and Egress (the asserter every start path calls), and its comment names the egress allow (plan 3's ControlDropInDir field was deleted in ef38e13b, the P1 EROFS fix); the same one site, the Statfs field, offset moved; no read added.
- `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.
@@ -34,7 +48,8 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/host/units/carlos-instance-rootfs-tty@.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
- new `internal/host/units/carlos-instance-tty@.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
+- new `internal/instancectl/cmd.go:Server.oneShotStatus`: reads +file:Query ×3; written legacy, accepted-legacy, frozen
-Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `83f9adb63fe0eae7ad2cd5175000678f05f6a5c646828e05e663b0a03d67f106`.
+Seal: `1379d066c8dd2335d95d5f6e9c7bce65ff57f00b2b287a308d9b3f47911ae5e7` → `b611b6ff7f86bc5b046a41d3d89ababf673ebd13e6e4c2593d7d2de4112729e1`.
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/instancectl/client.go b/internal/instancectl/client.go
index c93afb67b..2e2f1a70c 100644
--- a/internal/instancectl/client.go
+++ b/internal/instancectl/client.go
@@ -208,7 +208,7 @@ func (c *Client) Stop(ctx context.Context, host string, role Role) error {
// Cmd starts host's cmd unit and returns its invocation (run spec §5.4).
func (c *Client) Cmd(ctx context.Context, host string, memoryMax int64) (string, error) {
- return c.cmdQuery(ctx, host, memoryMax, nil)
+ return c.cmdQuery(ctx, "/cmd", host, memoryMax, nil)
}
// CmdExe is Cmd with the executable named: the serving generation's staged
@@ -216,10 +216,23 @@ func (c *Client) Cmd(ctx context.Context, host string, memoryMax int64) (string,
// the legacy sidecar (zero-downtime spec §7.5). A 403 is root's refusal,
// reported as ErrStagedExe.
func (c *Client) CmdExe(ctx context.Context, host string, memoryMax int64, x StagedExe) (string, error) {
- return c.cmdQuery(ctx, host, memoryMax, &x)
+ return c.cmdQuery(ctx, "/cmd", host, memoryMax, &x)
}
-func (c *Client) cmdQuery(ctx context.Context, host string, memoryMax int64, x *StagedExe) (string, error) {
+// TTY starts host's tty unit, one interactive session (rootfs apps design
+// §5.10), and returns its invocation. It is Cmd on the tty role's unit.
+func (c *Client) TTY(ctx context.Context, host string, memoryMax int64) (string, error) {
+ return c.cmdQuery(ctx, "/tty", host, memoryMax, nil)
+}
+
+// TTYExe is CmdExe for a session: the staged build is laid out at the tty
+// role's own sources (TTYExeApp, TTYExeLive). A 403 is ErrStagedExe.
+func (c *Client) TTYExe(ctx context.Context, host string, memoryMax int64, x StagedExe) (string, error) {
+ return c.cmdQuery(ctx, "/tty", host, memoryMax, &x)
+}
+
+// cmdQuery is the binary start of a one-shot role: path is /cmd or /tty.
+func (c *Client) cmdQuery(ctx context.Context, path, host string, memoryMax int64, x *StagedExe) (string, error) {
q := hostRole(host, "")
q.Set("memory_max", strconv.FormatInt(memoryMax, 10))
if x != nil {
@@ -228,7 +241,7 @@ func (c *Client) cmdQuery(ctx context.Context, host string, memoryMax int64, x *
q.Set("digest", x.Digest)
}
var out StartResponse
- status, _, err := c.do(ctx, DeadlineControl, http.MethodPost, "/cmd", q, &out)
+ status, _, err := c.do(ctx, DeadlineControl, http.MethodPost, path, q, &out)
if err != nil {
if status == http.StatusForbidden && x != nil {
return "", fmt.Errorf("%w: %v", ErrStagedExe, err)
@@ -240,8 +253,23 @@ func (c *Client) cmdQuery(ctx context.Context, host string, memoryMax int64, x *
// CmdStatus long-polls the named invocation of host's cmd unit.
func (c *Client) CmdStatus(ctx context.Context, host, invocation string) (CmdStatus, error) {
+ return c.oneShotStatus(ctx, "/cmd/", host, invocation, false)
+}
+
+// TTYStatus long-polls the named invocation of host's tty unit.
+func (c *Client) TTYStatus(ctx context.Context, host, invocation string) (CmdStatus, error) {
+ return c.oneShotStatus(ctx, "/tty/", host, invocation, false)
+}
+
+// oneShotStatus is the long-poll of a one-shot role's unit: prefix is
+// /cmd/ or /tty/, and rootfs picks the role's rootfs unit.
+func (c *Client) oneShotStatus(ctx context.Context, prefix, host, invocation string, rootfs bool) (CmdStatus, error) {
+ q := url.Values{"invocation": {invocation}}
+ if rootfs {
+ q.Set("runtime", runtimeRootfs)
+ }
var out CmdStatus
- _, _, err := c.do(ctx, DeadlineCmdPoll, http.MethodGet, "/cmd/"+url.PathEscape(host), url.Values{"invocation": {invocation}}, &out)
+ _, _, err := c.do(ctx, DeadlineCmdPoll, http.MethodGet, prefix+url.PathEscape(host), q, &out)
return out, err
}
@@ -509,7 +537,7 @@ func (c *Client) startRootfsQuery(ctx context.Context, q url.Values, memoryMax i
}
// StopRootfs stops one rootfs unit of host: the run unit (gen 0), a
-// generation, the named worker, or the cmd unit. kill (a generation only)
+// generation, the named worker, or the cmd or tty unit. kill (a generation only)
// kills the generation outright, as StopGen's does. A generation or worker
// whose stop root could not prove (its cgroup still populated) keeps its
// files and answers ErrGenUnproven.
@@ -530,6 +558,20 @@ func (c *Client) StopRootfs(ctx context.Context, host string, role Role, gen uin
// Anything else, a 502 and a transport failure included, may follow a
// start and stays plain.
func (c *Client) CmdRootfs(ctx context.Context, host string, memoryMax int64, img StagedImage) (string, error) {
+ return c.oneShotRootfs(ctx, "/cmd", host, memoryMax, img)
+}
+
+// TTYRootfs starts host's rootfs tty unit, one interactive session, with
+// /cmd's rootfs fields (D3): img.Process names a declared process (console
+// for carlos console) or img.Argv is the command of carlos run -it, never
+// both. Its errors are typed as CmdRootfs's.
+func (c *Client) TTYRootfs(ctx context.Context, host string, memoryMax int64, img StagedImage) (string, error) {
+ return c.oneShotRootfs(ctx, "/tty", host, memoryMax, img)
+}
+
+// oneShotRootfs is the rootfs start of a one-shot role: path is /cmd or
+// /tty.
+func (c *Client) oneShotRootfs(ctx context.Context, path, host string, memoryMax int64, img StagedImage) (string, error) {
q := hostRole(host, "")
q.Set("memory_max", strconv.FormatInt(memoryMax, 10))
setStagedImage(q, img)
@@ -543,7 +585,7 @@ func (c *Client) CmdRootfs(ctx context.Context, host string, memoryMax int64, im
}
}
var out StartResponse
- status, _, err := c.doBody(ctx, DeadlineControl, http.MethodPost, "/cmd", q, body, &out)
+ status, _, err := c.doBody(ctx, DeadlineControl, http.MethodPost, path, q, body, &out)
if err != nil {
switch {
case status == http.StatusForbidden:
@@ -558,7 +600,11 @@ func (c *Client) CmdRootfs(ctx context.Context, host string, memoryMax int64, im
// CmdStatusRootfs is CmdStatus for the rootfs cmd unit.
func (c *Client) CmdStatusRootfs(ctx context.Context, host, invocation string) (CmdStatus, error) {
- var out CmdStatus
- _, _, err := c.do(ctx, DeadlineCmdPoll, http.MethodGet, "/cmd/"+url.PathEscape(host), url.Values{"invocation": {invocation}, "runtime": {runtimeRootfs}}, &out)
- return out, err
+ return c.oneShotStatus(ctx, "/cmd/", host, invocation, true)
+}
+
+// TTYStatusRootfs is TTYStatus for the rootfs tty unit, as CmdStatusRootfs
+// is for the rootfs cmd unit.
+func (c *Client) TTYStatusRootfs(ctx context.Context, host, invocation string) (CmdStatus, error) {
+ return c.oneShotStatus(ctx, "/tty/", host, invocation, true)
}
diff --git a/internal/instancectl/cmd.go b/internal/instancectl/cmd.go
index c23c49a50..26b50ca80 100644
--- a/internal/instancectl/cmd.go
+++ b/internal/instancectl/cmd.go
@@ -32,33 +32,46 @@ func (s *Server) cmdStartWait() time.Duration {
return 10 * time.Second
}
-// handleCmd starts host's cmd unit and answers at once with the new
-// invocation (run spec §5.4); /seed blocks, this never does. The agent
-// stops a cmd unit after every run, so a unit still loaded (active,
-// activating, deactivating) belongs to a run this request must not end: it
-// is refused, never restarted. A failed one is reset first, or start would
-// keep its old result.
-func (s *Server) handleCmd(w http.ResponseWriter, r *http.Request) {
+// handleOneShot is POST /cmd and POST /tty: it starts host's unit of the
+// one-shot role (cmd, or tty for an interactive session) and answers at
+// once with the new invocation (run spec §5.4); /seed blocks, this never
+// does. The agent stops a one-shot unit after every run, so a unit still
+// loaded (active, activating, deactivating) belongs to a run this request
+// must not end: it is refused, never restarted. A failed one is reset
+// first, or start would keep its old result. Each role has its own unit,
+// exe sources and lock, so a session and a command run side by side.
+func (s *Server) handleOneShot(role Role) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ s.startOneShot(w, r, role)
+ }
+}
+
+func (s *Server) startOneShot(w http.ResponseWriter, r *http.Request, role Role) {
+ if !OneShot(role) {
+ http.Error(w, "role "+string(role)+" is not a one-shot role", http.StatusInternalServerError)
+ return
+ }
req, err := parseRequest(r, verbShape{tier: true, exe: true, cmd: true, rootfs: true})
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if req.rootfs() {
- s.startRootfsCmd(w, r, req)
+ s.startRootfsCmd(w, r, req, role)
return
}
- // One start per host at a time: a second request waits here, then reads
- // the unit loaded and is refused, instead of racing the first one's
- // invocation check and stopping its command.
- lock, _ := s.cmdLocks.LoadOrStore(req.host, new(sync.Mutex))
- lock.(*sync.Mutex).Lock()
- defer lock.(*sync.Mutex).Unlock()
+ // One start per role and host at a time: a second request waits here,
+ // then reads the unit loaded and is refused, instead of racing the
+ // first one's invocation check and stopping its command. Another role's
+ // start on the same host never waits on it (PF-7).
+ lock := s.oneShotLock(role, req.host)
+ lock.Lock()
+ defer lock.Unlock()
ctx := r.Context()
- unit := UnitName(RoleCmd, req.host)
+ unit := UnitName(role, req.host)
switch state := s.showValue(ctx, "ActiveState", unit); state {
case "active", "activating", "deactivating", "reloading", "refreshing":
- http.Error(w, "cmd: "+unit+" is "+state, http.StatusConflict)
+ http.Error(w, string(role)+": "+unit+" is "+state, http.StatusConflict)
return
case "failed":
if out, err := s.Systemctl(ctx, "reset-failed", unit); err != nil {
@@ -73,10 +86,11 @@ func (s *Server) handleCmd(w http.ResponseWriter, r *http.Request) {
if s.refuseStagedExe(w, req, unit) {
return
}
- // The command's executable is laid out at its own source (merge ruling
- // M4), never at the host's app, which an instance or sidecar start may
- // be rewriting for a different build at this moment.
- if s.refuseStart(w, req.host, unit, func() error { return s.ensureCmdExeAt(req.host, req.exe) }) {
+ // The command's executable is laid out at its role's own source (merge
+ // ruling M4), never at the host's app, which an instance or sidecar
+ // start may be rewriting for a different build at this moment, nor at
+ // the other one-shot role's.
+ if s.refuseStart(w, req.host, unit, func() error { return s.ensureCmdExeAt(role, req.host, req.exe) }) {
return
}
// A command runs beside an awake instance, whose own start set the
@@ -114,16 +128,39 @@ func (s *Server) handleCmd(w http.ResponseWriter, r *http.Request) {
dctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
s.stopUnit(dctx, unit)
cancel()
- http.Error(w, "cmd: "+unit+" showed no new invocation", http.StatusBadGateway)
+ http.Error(w, string(role)+": "+unit+" showed no new invocation", http.StatusBadGateway)
return
}
time.Sleep(s.cmdPoll())
}
}
-// handleCmdStatus is the bounded long-poll: it answers as soon as the named
-// invocation is done or gone, and running at the bound.
-func (s *Server) handleCmdStatus(w http.ResponseWriter, r *http.Request) {
+// oneShotKey keys the one-shot start locks: a role and a host (PF-7).
+type oneShotKey struct {
+ role Role
+ host string
+}
+
+// oneShotLock is the lock of role's starts and cleanups on host.
+func (s *Server) oneShotLock(role Role, host string) *sync.Mutex {
+ lock, _ := s.cmdLocks.LoadOrStore(oneShotKey{role, host}, new(sync.Mutex))
+ return lock.(*sync.Mutex)
+}
+
+// handleOneShotStatus is GET /cmd/{host} and GET /tty/{host}, the bounded
+// long-poll of the role's unit: it answers as soon as the named invocation
+// is done or gone, and running at the bound.
+func (s *Server) handleOneShotStatus(role Role) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ s.oneShotStatus(w, r, role)
+ }
+}
+
+func (s *Server) oneShotStatus(w http.ResponseWriter, r *http.Request, role Role) {
+ if !OneShot(role) {
+ http.Error(w, "role "+string(role)+" is not a one-shot role", http.StatusInternalServerError)
+ return
+ }
host := r.PathValue("host")
if !provision.ValidHostShape(host) {
http.Error(w, fmt.Sprintf("host %q is not a host", host), http.StatusBadRequest)
@@ -135,24 +172,24 @@ func (s *Server) handleCmdStatus(w http.ResponseWriter, r *http.Request) {
return
}
// The poll follows the termination verbs' rule (Astra R1 finding 6):
- // runtime=rootfs alone picks the rootfs cmd unit, an image field is a
- // 400, and role=worker or worker= without it is refused as everywhere.
+ // runtime=rootfs alone picks the role's rootfs unit, an image field is
+ // a 400, and role=worker or worker= without it is refused as everywhere.
req, err := parseQuery(host, r.URL.Query(), verbShape{rootfsStop: true})
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
- // The poll is the cmd role's alone (task 11 fix F2): a role field naming
- // any other role is a 400 on either runtime, so no request is read as a
- // poll of a unit it does not name.
- if q := r.URL.Query(); q.Has("role") && q.Get("role") != string(RoleCmd) {
- http.Error(w, fmt.Sprintf("role %q is not cmd: the cmd poll is the cmd role's", q.Get("role")), http.StatusBadRequest)
+ // Each poll is its route's role's alone (task 11 fix F2, PF-7): a role
+ // field naming any other role is a 400 on either runtime, so no request
+ // is read as a poll of a unit it does not name.
+ if q := r.URL.Query(); q.Has("role") && q.Get("role") != string(role) {
+ http.Error(w, fmt.Sprintf("role %q is not %s: the %s poll is the %s role's", q.Get("role"), role, role, role), http.StatusBadRequest)
return
}
ctx := r.Context()
- unit := UnitName(RoleCmd, host)
+ unit := UnitName(role, host)
if req.rootfs() {
- unit = RootfsUnitName(RoleCmd, host)
+ unit = RootfsUnitName(role, host)
}
deadline := time.Now().Add(s.cmdWait())
for {
@@ -189,30 +226,34 @@ func cmdStatusOf(m map[string]string, want string) CmdStatus {
return st
}
-// cleanCmdExe removes host's cmd executable sources after its cmd unit has
-// stopped: the binary cmd unit's two links, or with rootfs the rootfs cmd
-// unit's layout (<iid>/rootfs/cmd) and its jit drop-in. It holds the host's
-// cmd lock, so a start cannot be laying them out meanwhile. The binary
-// links stay for a unit that is not inactive or failed (a start that has
-// since begun). The rootfs layout goes only through removeRootfsUnitFiles's
-// proof (task 11 fixes E2 and E2c), whose refusal, a failed state query
-// included, is returned.
-func (s *Server) cleanCmdExe(ctx context.Context, host string, rootfs bool) error {
- lock, _ := s.cmdLocks.LoadOrStore(host, new(sync.Mutex))
- lock.(*sync.Mutex).Lock()
- defer lock.(*sync.Mutex).Unlock()
- unit := UnitName(RoleCmd, host)
+// cleanCmdExe removes host's executable sources of one one-shot role (cmd
+// or tty) after that role's unit has stopped: the binary unit's two links
+// (removeCmdExe), or with rootfs the role's rootfs unit's layout
+// (<iid>/rootfs/<role>) and its jit drop-in. It holds the role's lock on
+// the host, so a start of that role cannot be laying them out meanwhile.
+// The binary links stay for a unit that is not inactive or failed (a start
+// that has since begun). The rootfs layout goes only through
+// removeRootfsUnitFiles's proof (task 11 fixes E2 and E2c), whose refusal,
+// a failed state query included, is returned.
+func (s *Server) cleanCmdExe(ctx context.Context, role Role, host string, rootfs bool) error {
+ if !OneShot(role) {
+ return fmt.Errorf("role %s is not a one-shot role", role)
+ }
+ lock := s.oneShotLock(role, host)
+ lock.Lock()
+ defer lock.Unlock()
+ unit := UnitName(role, host)
if rootfs {
- unit = RootfsUnitName(RoleCmd, host)
+ unit = RootfsUnitName(role, host)
}
if rootfs {
// The rootfs layout goes only through the proof, which keeps a
// failed state query or a state other than inactive or failed as
// an error (task 11 fix E2c), and only under the unit's lock (fix
- // E6). A cmd start takes that lock after its preflight and holds
- // it through its layout, systemctl start and its own cleanup, all
- // under this same cmd lock, so here the unit's lock is free unless
- // a sweep has it: stopRootfs answers 502, files kept.
+ // E6). A one-shot start takes that lock after its preflight and
+ // holds it through its layout, systemctl start and its own cleanup,
+ // all under this same role lock, so here the unit's lock is free
+ // unless a sweep has it: stopRootfs answers 502, files kept.
hold, ok := s.tryHoldRootfsUnit(unit)
if !ok {
return errRootfsUnitInFlight(unit)
@@ -222,7 +263,7 @@ func (s *Server) cleanCmdExe(ctx context.Context, host string, rootfs bool) erro
}
switch s.showValue(ctx, "ActiveState", unit) {
case "inactive", "failed":
- s.removeCmdExe(provision.InstanceID(host))
+ s.removeCmdExe(role, provision.InstanceID(host))
}
return nil
}
diff --git a/internal/instancectl/cmd_stagedexe_linux_test.go b/internal/instancectl/cmd_stagedexe_linux_test.go
index ff8ccc935..e8f9b4749 100644
--- a/internal/instancectl/cmd_stagedexe_linux_test.go
+++ b/internal/instancectl/cmd_stagedexe_linux_test.go
@@ -212,3 +212,80 @@ func TestConcurrentCmdAndSidecarStartsBindTheirOwnBuilds(t *testing.T) {
t.Errorf("the command's stop touched the host's app: %q (%v)", got, err)
}
}
+
+// A session binds sources of its own, tty-app and tty-live, as a command
+// binds cmd-app and cmd-live: a command and a session on different builds
+// never repoint each other's, and a session's stop takes only its own.
+func TestTTYExeUsesItsOwnSources(t *testing.T) {
+ const host = "shop.example.com"
+ opt, exeRoot := t.TempDir(), t.TempDir()
+ stage := func(v string) StagedExe {
+ path := release.VersionPath(opt, release.OpsAccount, v, "blog")
+ return StagedExe{Path: path, Version: v, Digest: writeStaged(t, path, "build "+v)}
+ }
+ cmdBuild, ttyBuild := stage("v2"), stage("v3")
+ ctl := &fakeCtl{}
+ newUnitModel(ctl)
+ _, sock := serveOnSocket(t, ctl, fastCmd, func(s *Server) {
+ s.ExeRoot, s.OptDir = exeRoot, opt
+ s.HostApp = func(string) (string, string, error) { return release.OpsAccount, "blog", nil }
+ })
+ c := NewClient(sock)
+ ctx := context.Background()
+ dir := filepath.Join(exeRoot, provision.InstanceID(host))
+ if _, err := c.CmdExe(ctx, host, cgroup.TierDefault.MemoryMax, cmdBuild); err != nil {
+ t.Fatalf("CmdExe: %v", err)
+ }
+ // A refused build lays nothing out and starts nothing.
+ ctl.reset()
+ bad := StagedExe{Path: ttyBuild.Path, Version: "v3", Digest: strings.Repeat("0", 64)}
+ if _, err := c.TTYExe(ctx, host, cgroup.TierDefault.MemoryMax, bad); !errors.Is(err, ErrStagedExe) {
+ t.Errorf("TTYExe with a bad digest: %v, want ErrStagedExe", err)
+ }
+ if ctlCalled(ctl, "start") {
+ t.Errorf("a refused session reached systemd:\n%s", ctl.joined())
+ }
+ if _, err := os.Lstat(filepath.Join(dir, TTYExeApp)); !os.IsNotExist(err) {
+ t.Errorf("a refused session laid out tty-app (%v)", err)
+ }
+ if _, err := c.TTYExe(ctx, host, cgroup.TierDefault.MemoryMax, ttyBuild); err != nil {
+ t.Fatalf("TTYExe: %v", err)
+ }
+ if !ctlCalled(ctl, "start --no-block "+UnitName(RoleTTY, host)) {
+ t.Fatalf("TTYExe did not start the tty unit:\n%s", ctl.joined())
+ }
+ if got, err := os.Readlink(filepath.Join(dir, TTYExeApp)); err != nil || got != ttyBuild.Path {
+ t.Fatalf("tty-app = %q (%v), want the session's build %q", got, err, ttyBuild.Path)
+ }
+ if got, err := os.Readlink(filepath.Join(dir, TTYExeLive, host)); err != nil || got != "../app" {
+ t.Fatalf("tty-live/%s = %q (%v)", host, got, err)
+ }
+ if got, err := os.Readlink(filepath.Join(dir, CmdExeApp)); err != nil || got != cmdBuild.Path {
+ t.Fatalf("the session's start moved cmd-app to %q (%v)", got, err)
+ }
+ // The session's stop takes its own two sources and leaves the command's.
+ if err := c.Stop(ctx, host, RoleTTY); err != nil {
+ t.Fatal(err)
+ }
+ for _, name := range []string{TTYExeApp, TTYExeLive} {
+ if _, err := os.Lstat(filepath.Join(dir, name)); !os.IsNotExist(err) {
+ t.Errorf("%s survived the session's stop (%v)", name, err)
+ }
+ }
+ if got, err := os.Readlink(filepath.Join(dir, CmdExeApp)); err != nil || got != cmdBuild.Path {
+ t.Errorf("the session's stop touched cmd-app: %q (%v)", got, err)
+ }
+ // And the command's stop leaves a session's sources alone.
+ if _, err := c.TTYExe(ctx, host, cgroup.TierDefault.MemoryMax, ttyBuild); err != nil {
+ t.Fatalf("TTYExe again: %v", err)
+ }
+ if err := c.Stop(ctx, host, RoleCmd); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := os.Lstat(filepath.Join(dir, CmdExeApp)); !os.IsNotExist(err) {
+ t.Errorf("cmd-app survived the command's stop (%v)", err)
+ }
+ if got, err := os.Readlink(filepath.Join(dir, TTYExeApp)); err != nil || got != ttyBuild.Path {
+ t.Errorf("the command's stop touched tty-app: %q (%v)", got, err)
+ }
+}
diff --git a/internal/instancectl/cmd_test.go b/internal/instancectl/cmd_test.go
index 347c515d6..c87e90dda 100644
--- a/internal/instancectl/cmd_test.go
+++ b/internal/instancectl/cmd_test.go
@@ -5,6 +5,8 @@ import (
"encoding/json"
"net/http"
"net/http/httptest"
+ "os"
+ "path/filepath"
"strings"
"sync"
"testing"
@@ -245,3 +247,342 @@ func TestClientCmdAndCmdStatus(t *testing.T) {
t.Fatalf("CmdStatus = %+v, %v", st, err)
}
}
+
+// unitModel is a small systemd for the binary one-shot tests, keyed by
+// unit: a start gives the unit a new invocation and makes it active, a
+// stop makes it inactive. Explicit fakeCtl answers still win.
+type unitModel struct {
+ ctl *fakeCtl
+ mu sync.Mutex
+ seq int
+ inv map[string]string
+ active map[string]bool
+}
+
+func newUnitModel(ctl *fakeCtl) *unitModel {
+ m := &unitModel{ctl: ctl, inv: map[string]string{}, active: map[string]bool{}}
+ ctl.mu.Lock()
+ if ctl.answers == nil {
+ ctl.answers = map[string]string{}
+ }
+ ctl.dynamic = m.run
+ ctl.mu.Unlock()
+ return m
+}
+
+func (m *unitModel) run(args []string) (string, bool) {
+ line := strings.Join(args, " ")
+ if m.ctl.hasAnswer(line) {
+ return "", false
+ }
+ unit := args[len(args)-1]
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ switch {
+ case args[0] == "start":
+ m.seq++
+ m.inv[unit] = "inv" + strings.Repeat("x", m.seq)
+ m.active[unit] = true
+ return "", true
+ case args[0] == "stop":
+ m.active[unit] = false
+ return "", true
+ case strings.HasPrefix(line, "show -p InvocationID --value "):
+ return m.inv[unit] + "\n", true
+ case strings.HasPrefix(line, "show -p ActiveState --value "):
+ if m.active[unit] {
+ return "active\n", true
+ }
+ return "inactive\n", true
+ }
+ return "", false
+}
+
+func (m *unitModel) setActive(unit string, active bool) {
+ m.mu.Lock()
+ m.active[unit] = active
+ m.mu.Unlock()
+}
+
+const (
+ ttyUnit = "carlos-instance-tty@h.example.com.service"
+ cmdUnit = "carlos-instance-cmd@h.example.com.service"
+)
+
+func TestTTYStartsTheTTYUnitInTheInstanceSlice(t *testing.T) {
+ ctl := &fakeCtl{}
+ newUnitModel(ctl)
+ _, c := newServer(t, ctl, fastCmd)
+ resp := post(t, c, "/tty?host=h.example.com&memory_max=536870912")
+ if resp.StatusCode != 200 {
+ t.Fatalf("status %d", resp.StatusCode)
+ }
+ var out StartResponse
+ if err := json.NewDecoder(resp.Body).Decode(&out); err != nil || out.InvocationID == "" {
+ t.Fatalf("response %+v, %v", out, err)
+ }
+ calls := ctl.joined()
+ for _, want := range []string{"set-property --runtime carlos-instances-h.example.com.slice", "start --no-block " + ttyUnit} {
+ if !strings.Contains(calls, want) {
+ t.Errorf("missing %q in\n%s", want, calls)
+ }
+ }
+ if strings.Contains(calls, "carlos-instance-cmd@") {
+ t.Errorf("a tty start touched the cmd unit:\n%s", calls)
+ }
+ if s, p := strings.Index(calls, "set-property"), strings.Index(calls, "start --no-block"); s < 0 || p < s {
+ t.Errorf("the cold slice's tier must come before the start:\n%s", calls)
+ }
+ // A failed tty unit is reset first, as a failed cmd unit is.
+ ctl2 := &fakeCtl{}
+ newUnitModel(ctl2)
+ ctl2.set("show -p ActiveState --value "+ttyUnit, "failed\n")
+ _, c2 := newServer(t, ctl2, fastCmd)
+ if resp := post(t, c2, "/tty?host=h.example.com&memory_max=536870912"); resp.StatusCode != 200 {
+ t.Fatalf("failed unit: status %d", resp.StatusCode)
+ }
+ calls = ctl2.joined()
+ if r, s := strings.Index(calls, "reset-failed "+ttyUnit), strings.Index(calls, "start --no-block "+ttyUnit); r < 0 || s < 0 || r > s {
+ t.Errorf("reset-failed of the tty unit must come before its start:\n%s", calls)
+ }
+}
+
+func TestTTYLeavesAPopulatedSliceAlone(t *testing.T) {
+ ctl := &fakeCtl{}
+ newUnitModel(ctl)
+ s, c := newServer(t, ctl, fastCmd)
+ ev := filepath.Join(s.CgroupRoot, parentSlices, SliceName("h.example.com"), "cgroup.events")
+ if err := os.MkdirAll(filepath.Dir(ev), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(ev, []byte("populated 1\nfrozen 0\n"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if resp := post(t, c, "/tty?host=h.example.com&memory_max=536870912"); resp.StatusCode != 200 {
+ t.Fatalf("status %d", resp.StatusCode)
+ }
+ if calls := ctl.joined(); strings.Contains(calls, "set-property") || !strings.Contains(calls, "start --no-block "+ttyUnit) {
+ t.Errorf("a session on an awake instance must start inside its slice and leave the limit alone:\n%s", calls)
+ }
+}
+
+func TestTTYAndCmdRunSideBySide(t *testing.T) {
+ ctl := &fakeCtl{}
+ m := newUnitModel(ctl)
+ _, c := newServer(t, ctl, fastCmd)
+ m.setActive(cmdUnit, true)
+ if resp := post(t, c, "/tty?host=h.example.com&memory_max=536870912"); resp.StatusCode != 200 {
+ t.Fatalf("tty beside an active cmd: status %d", resp.StatusCode)
+ }
+ if strings.Contains(ctl.joined(), "stop ") {
+ t.Errorf("a tty start stopped something:\n%s", ctl.joined())
+ }
+ // The tty unit is active now: a second session is refused, never
+ // restarted, and the cmd unit's own start still goes.
+ clearCalls(ctl)
+ if resp := post(t, c, "/tty?host=h.example.com&memory_max=536870912"); resp.StatusCode != http.StatusConflict {
+ t.Errorf("tty while tty is active: status %d, want 409", resp.StatusCode)
+ }
+ if calls := ctl.joined(); strings.Contains(calls, "start ") || strings.Contains(calls, "stop ") {
+ t.Errorf("a refused tty start reached start or stop:\n%s", calls)
+ }
+ m.setActive(cmdUnit, false)
+ if resp := post(t, c, "/cmd?host=h.example.com&memory_max=536870912"); resp.StatusCode != 200 {
+ t.Errorf("cmd beside an active tty: status %d", resp.StatusCode)
+ }
+ if !strings.Contains(ctl.joined(), "start --no-block "+cmdUnit) {
+ t.Errorf("the cmd start did not start the cmd unit:\n%s", ctl.joined())
+ }
+}
+
+// PF-7: the start locks are keyed by role and host. A cmd start held
+// mid-flight does not hold up a session's start on the same host; two
+// session starts for one host serialize, so the second reads the first's
+// unit loaded and is refused.
+func TestTTYAndCmdLocksAreSeparate(t *testing.T) {
+ ctl := &fakeCtl{}
+ newUnitModel(ctl)
+ _, c := newServer(t, ctl, fastCmd)
+ entered, release := holdStart(t, ctl)
+ cmdDone := make(chan int, 1)
+ go func() { cmdDone <- post(t, c, "/cmd?host=h.example.com&memory_max=536870912").StatusCode }()
+ awaitEntered(t, entered)
+ ttyDone := make(chan int, 1)
+ go func() { ttyDone <- post(t, c, "/tty?host=h.example.com&memory_max=536870912").StatusCode }()
+ select {
+ case code := <-ttyDone:
+ if code != 200 {
+ t.Errorf("tty beside a held cmd start: status %d", code)
+ }
+ case <-time.After(2 * time.Second):
+ t.Fatal("a tty start waited behind a cmd start's lock")
+ }
+ release()
+ if code := <-cmdDone; code != 200 {
+ t.Errorf("the held cmd start: status %d", code)
+ }
+
+ ctl = &fakeCtl{}
+ newUnitModel(ctl)
+ _, c = newServer(t, ctl, fastCmd)
+ entered, release = holdStart(t, ctl)
+ first := make(chan int, 1)
+ go func() { first <- post(t, c, "/tty?host=h.example.com&memory_max=536870912").StatusCode }()
+ awaitEntered(t, entered)
+ mark := len(strings.Split(ctl.joined(), "\n"))
+ second := make(chan int, 1)
+ go func() { second <- post(t, c, "/tty?host=h.example.com&memory_max=536870912").StatusCode }()
+ time.Sleep(150 * time.Millisecond)
+ if later := strings.Split(ctl.joined(), "\n")[mark:]; len(later) > 0 {
+ t.Errorf("a second session start ran while the first held the lock: %v", later)
+ }
+ select {
+ case code := <-second:
+ t.Fatalf("the second session start answered %d before the first finished", code)
+ default:
+ }
+ release()
+ if code := <-first; code != 200 {
+ t.Errorf("first session start: %d", code)
+ }
+ if code := <-second; code != http.StatusConflict {
+ t.Errorf("second session start: %d, want 409", code)
+ }
+}
+
+func TestTTYStatusLongPoll(t *testing.T) {
+ fields := cmdShowAll + " "
+ ctl := &fakeCtl{answers: map[string]string{
+ fields + ttyUnit: "InvocationID=inv1\nActiveState=activating\nSubState=start\nResult=success\nExecMainStatus=0\nExecMainCode=0\n",
+ fields + cmdUnit: "InvocationID=inv1\nActiveState=inactive\nSubState=dead\nResult=success\nExecMainStatus=9\nExecMainCode=1\n",
+ }}
+ _, c := newServer(t, ctl, fastCmd)
+ // Running at the bound.
+ if st := getStatus(t, c, "/tty/h.example.com?invocation=inv1"); st.State != CmdRunning {
+ t.Fatalf("running: %+v", st)
+ }
+ // Done when the tty unit finishes (never the cmd unit's answer).
+ go func() {
+ time.Sleep(50 * time.Millisecond)
+ ctl.set(fields+ttyUnit, "InvocationID=inv1\nActiveState=failed\nSubState=failed\nResult=exit-code\nExecMainStatus=3\nExecMainCode=1\n")
+ }()
+ if st := getStatus(t, c, "/tty/h.example.com?invocation=inv1&role=tty"); st.State != CmdDone || st.Status != "3" {
+ t.Fatalf("done: %+v", st)
+ }
+ // Gone for another invocation.
+ if st := getStatus(t, c, "/tty/h.example.com?invocation=inv2"); st.State != CmdGone {
+ t.Fatalf("gone: %+v", st)
+ }
+ if strings.Contains(ctl.joined(), cmdUnit) {
+ t.Errorf("the tty poll showed the cmd unit:\n%s", ctl.joined())
+ }
+ // Each poll is its own role's: a role field naming another role is a
+ // 400 before any unit is shown, on both routes.
+ for _, path := range []string{"/tty/h.example.com?invocation=inv1&role=cmd", "/cmd/h.example.com?invocation=inv1&role=tty"} {
+ clearCalls(ctl)
+ resp, err := c.Get("http://unix" + path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ resp.Body.Close()
+ if resp.StatusCode != http.StatusBadRequest {
+ t.Errorf("GET %s: status %d, want 400", path, resp.StatusCode)
+ }
+ if strings.Contains(ctl.joined(), "show") {
+ t.Errorf("GET %s showed a unit:\n%s", path, ctl.joined())
+ }
+ }
+}
+
+func TestTTYRefusedWithClaimControlArmed(t *testing.T) {
+ called := false
+ s := &Server{ClaimStop: http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}), Systemctl: func(context.Context, ...string) (string, error) { called = true; return "", nil }}
+ for _, req := range []*http.Request{
+ httptest.NewRequest(http.MethodPost, "/tty?host=app.example&memory_max=536870912", nil),
+ httptest.NewRequest(http.MethodGet, "/tty/app.example?invocation=x", nil),
+ } {
+ w := httptest.NewRecorder()
+ s.Handler().ServeHTTP(w, req)
+ if w.Code != http.StatusServiceUnavailable {
+ t.Errorf("%s %s: status %d", req.Method, req.URL, w.Code)
+ }
+ }
+ if called {
+ t.Fatal("a tty route reached systemctl with claim control armed")
+ }
+}
+
+// The binary stop and reset take the tty role (PF-27) and name its unit.
+func TestTTYStopAndResetNameTheTTYUnit(t *testing.T) {
+ ctl := &fakeCtl{}
+ newUnitModel(ctl)
+ _, c := newServer(t, ctl, fastCmd)
+ for _, verb := range []string{"/stop", "/reset"} {
+ if resp := post(t, c, verb+"?host=h.example.com&role=tty"); resp.StatusCode != http.StatusNoContent {
+ t.Errorf("%s role=tty: status %d", verb, resp.StatusCode)
+ }
+ }
+ calls := ctl.joined()
+ for _, want := range []string{"stop " + ttyUnit, "reset-failed " + ttyUnit} {
+ if !strings.Contains(calls, want) {
+ t.Errorf("missing %q in\n%s", want, calls)
+ }
+ }
+ if strings.Contains(calls, cmdUnit) {
+ t.Errorf("a tty stop or reset named the cmd unit:\n%s", calls)
+ }
+}
+
+func TestClientTTYAndTTYStatus(t *testing.T) {
+ ctl := &fakeCtl{}
+ newUnitModel(ctl)
+ _, cl := newClient(t, ctl, fastCmd)
+ inv, err := cl.TTY(context.Background(), "h.example.com", 536870912)
+ if err != nil || inv == "" {
+ t.Fatalf("TTY = %q, %v", inv, err)
+ }
+ if !strings.Contains(ctl.joined(), "start --no-block "+ttyUnit) {
+ t.Fatalf("TTY did not start the tty unit:\n%s", ctl.joined())
+ }
+ ctl.set(cmdShowAll+" "+ttyUnit, "InvocationID="+inv+"\nActiveState=failed\nSubState=failed\nResult=exit-code\nExecMainStatus=2\nExecMainCode=1\n")
+ st, err := cl.TTYStatus(context.Background(), "h.example.com", inv)
+ if err != nil || st.State != CmdDone || st.Status != "2" {
+ t.Fatalf("TTYStatus = %+v, %v", st, err)
+ }
+ if st, err := cl.CmdStatus(context.Background(), "h.example.com", inv); err != nil || st.State != CmdGone {
+ t.Fatalf("CmdStatus of a tty invocation = %+v, %v, want gone", st, err)
+ }
+}
+
+// awaitEntered waits for a held start to reach systemctl start, and fails
+// the test rather than hang when it never does.
+func awaitEntered(t *testing.T, entered <-chan struct{}) {
+ t.Helper()
+ select {
+ case <-entered:
+ case <-time.After(5 * time.Second):
+ t.Fatal("the held start never reached systemctl start")
+ }
+}
+
+// holdStart holds the next systemctl start until release is called: entered
+// closes when a start reaches it. The release also runs at cleanup, before
+// the server's, so a failing test never leaves a handler held.
+func holdStart(t *testing.T, ctl *fakeCtl) (<-chan struct{}, func()) {
+ t.Helper()
+ entered, held := make(chan struct{}), make(chan struct{})
+ var once sync.Once
+ release := func() { once.Do(func() { close(held) }) }
+ ctl.mu.Lock()
+ ctl.before = map[string]func(){"start": func() { close(entered); <-held }}
+ ctl.mu.Unlock()
+ t.Cleanup(release)
+ return entered, release
+}
+
+// clearCalls forgets the calls recorded so far (fakeCtl.reset is linux-only).
+func clearCalls(ctl *fakeCtl) {
+ ctl.mu.Lock()
+ ctl.calls = nil
+ ctl.mu.Unlock()
+}
diff --git a/internal/instancectl/rootfs.go b/internal/instancectl/rootfs.go
index c183af8ef..20a6800c7 100644
--- a/internal/instancectl/rootfs.go
+++ b/internal/instancectl/rootfs.go
@@ -213,12 +213,14 @@ func (s *Server) validateStagedImage(host string, role Role, img StagedImage) (R
// resolveRootfsLaunch is the command half of validateStagedImage: from the
// root-staged manifest m, the launch for role. The run role is the web
-// process; a worker is its own declared process; a cmd is a declared
-// process other than web (the release process for Plan 3, a worker for a
-// one-off run), or an operator's argv (carlos run), which runs where and
-// with what the web process runs (Astra R1 finding 7), so a relative
-// command resolves against the image's working_dir and along its PATH.
-// jit comes from this manifest and nowhere else (spec §5.11).
+// process; a worker is its own declared process; a cmd or a tty session is
+// a declared process other than web (the release process for Plan 3, a
+// worker for a one-off run, console for carlos console), with that
+// process's own env and working_dir, or an operator's argv (carlos run,
+// carlos run -it), which runs where and with what the web process runs
+// (Astra R1 finding 7), so a relative command resolves against the image's
+// working_dir and along its PATH. jit comes from this manifest and nowhere
+// else (spec §5.11).
func resolveRootfsLaunch(m *release.Manifest, host string, role Role, img StagedImage) (RootfsLaunch, error) {
if !m.IsRootfs() {
return RootfsLaunch{}, fmt.Errorf("%w: %s", ErrStagedImage, rootfsNotRootfsText)
@@ -271,13 +273,13 @@ func resolveRootfsLaunch(m *release.Manifest, host string, role Role, img Staged
return RootfsLaunch{}, err
}
fill(img.Process, p)
- case RoleCmd:
+ case RoleCmd, RoleTTY:
switch {
case img.Process != "" && len(img.Argv) > 0:
- return RootfsLaunch{}, fmt.Errorf("%w: a cmd names a process or carries an argv, not both", ErrStagedImage)
+ return RootfsLaunch{}, fmt.Errorf("%w: a %s names a process or carries an argv, not both", ErrStagedImage, role)
case img.Process != "":
if img.Process == release.ProcessWeb {
- return RootfsLaunch{}, fmt.Errorf("%w: web is the run role's process, not a cmd's", ErrStagedImage)
+ return RootfsLaunch{}, fmt.Errorf("%w: web is the run role's process, not a %s's", ErrStagedImage, role)
}
p, err := declared(img.Process)
if err != nil {
@@ -289,12 +291,14 @@ func resolveRootfsLaunch(m *release.Manifest, host string, role Role, img Staged
if err != nil {
return RootfsLaunch{}, err
}
+ // An argv's launch is the cmd shape for a session too
+ // (Process "cmd"): it names no declared process.
launch.Process = string(RoleCmd)
launch.Argv = slices.Clone(img.Argv)
launch.Env = maps.Clone(web.Env)
launch.WorkingDir = web.WorkingDir
default:
- return RootfsLaunch{}, fmt.Errorf("%w: a cmd names a process or carries an argv", ErrStagedImage)
+ return RootfsLaunch{}, fmt.Errorf("%w: a %s names a process or carries an argv", ErrStagedImage, role)
}
default:
return RootfsLaunch{}, fmt.Errorf("%w: role %s has no rootfs unit", ErrStagedImage, role)
@@ -315,7 +319,7 @@ func (s *Server) ensureRootfsExe(key string, role Role, imagePath string, launch
if key == "" || strings.ContainsAny(key, "/\x00") || key == "." || key == ".." {
return fmt.Errorf("exe: %q is not a key", key)
}
- if role != RoleRun && role != RoleWorker && role != RoleCmd {
+ if role != RoleRun && role != RoleWorker && !OneShot(role) {
return fmt.Errorf("exe: role %s has no rootfs layout", role)
}
dir := RootfsExeDir(s.ExeRoot, key, role)
@@ -414,8 +418,8 @@ func (s *Server) removeWorkerFiles(unit string) (removed bool, err error) {
}
// removeRootfsFiles removes what a stopped rootfs unit leaves, by its kind:
-// a generation's or a worker's files, a cmd's layout, and in every case
-// the unit's jit drop-in. The run unit's standing layout stays, as the
+// a generation's or a worker's files, a cmd's or a tty session's layout
+// (its own role's only), and in every case the unit's jit drop-in. The run unit's standing layout stays, as the
// binary host's exe layout does.
func (s *Server) removeRootfsFiles(unit string) {
switch {
@@ -423,11 +427,11 @@ func (s *Server) removeRootfsFiles(unit string) {
_, _ = s.removeRootfsGenFiles(unit)
case strings.HasPrefix(unit, UnitPrefixRootfsWorker):
_, _ = s.removeWorkerFiles(unit)
- case strings.HasPrefix(unit, UnitPrefixRootfsCmd):
+ case strings.HasPrefix(unit, UnitPrefixRootfsCmd), strings.HasPrefix(unit, UnitPrefixRootfsTTY):
s.removeJITDropIn(unit)
- if _, esc, ok := ParseUnitName(unit); ok {
+ if role, esc, ok := ParseUnitName(unit); ok && OneShot(role) {
if iid, ok := Unescape(esc); ok {
- s.removeRootfsExe(iid, RoleCmd)
+ s.removeRootfsExe(iid, role)
}
}
case strings.HasPrefix(unit, UnitPrefixRootfs):
@@ -561,7 +565,8 @@ func (s *Server) jitDaemonReload(ctx context.Context) error {
}
// rootfsUnitOf is the rootfs unit a parsed request names: the worker's,
-// the generation's, or the run or cmd template's. "" for any other role.
+// the generation's, or the run, cmd or tty template's. "" for any other
+// role.
func rootfsUnitOf(req request) string {
switch {
case req.role == RoleWorker:
@@ -571,7 +576,7 @@ func rootfsUnitOf(req request) string {
return WorkerUnitName(req.host, req.worker)
case req.role == RoleRun && req.gen != 0:
return RootfsGenUnitName(req.host, req.gen)
- case req.role == RoleRun, req.role == RoleCmd:
+ case req.role == RoleRun, OneShot(req.role):
return RootfsUnitName(req.role, req.host)
}
return ""
@@ -1001,25 +1006,31 @@ func (s *Server) reportedGroupEmpty(ctx, wait context.Context, unit string, ever
return waitCgroupFileEmpty(wait, filepath.Join(s.CgroupRoot, cg, "cgroup.events"), unit, every)
}
-// startRootfsCmd is handleCmd's rootfs branch (run spec §5.4 for a rootfs
-// row), on the rootfs cmd unit: the per-host cmd lock, the loaded-state
-// refusal and reset-failed, the rootfs preflight, the layout, the jit
+// startRootfsCmd is handleOneShot's rootfs branch (run spec §5.4 for a
+// rootfs row) for either one-shot role, cmd or tty, on that role's rootfs
+// unit and layout: the role's per-host lock, the loaded-state refusal and
+// reset-failed, the rootfs preflight for the role, the layout, the jit
// drop-in and its reload, the tier rule of a populated slice, start
// --no-block, the invocation poll, then the post-start check on the new
-// invocation.
-func (s *Server) startRootfsCmd(w http.ResponseWriter, r *http.Request, req request) {
- lock, _ := s.cmdLocks.LoadOrStore(req.host, new(sync.Mutex))
- lock.(*sync.Mutex).Lock()
- defer lock.(*sync.Mutex).Unlock()
+// invocation. The jit drop-in, its reload and the effective-property check
+// are the same for both roles (R11).
+func (s *Server) startRootfsCmd(w http.ResponseWriter, r *http.Request, req request, role Role) {
+ if !OneShot(role) {
+ http.Error(w, "role "+string(role)+" is not a one-shot role", http.StatusInternalServerError)
+ return
+ }
+ lock := s.oneShotLock(role, req.host)
+ lock.Lock()
+ defer lock.Unlock()
ctx := r.Context()
- unit := RootfsUnitName(RoleCmd, req.host)
+ unit := RootfsUnitName(role, req.host)
if s.DropInDir == "" || s.ExeRoot == "" {
http.Error(w, "not starting "+unit+": rootfs units are not configured on this service", http.StatusNotImplemented)
return
}
switch state := s.showValue(ctx, "ActiveState", unit); state {
case "active", "activating", "deactivating", "reloading", "refreshing":
- http.Error(w, "cmd: "+unit+" is "+state, http.StatusConflict)
+ http.Error(w, string(role)+": "+unit+" is "+state, http.StatusConflict)
return
case "failed":
if out, err := s.Systemctl(ctx, "reset-failed", unit); err != nil {
@@ -1027,21 +1038,21 @@ func (s *Server) startRootfsCmd(w http.ResponseWriter, r *http.Request, req requ
return
}
}
- launch, answered := s.rootfsPreflight(w, req.host, RoleCmd, unit, req.image)
+ launch, answered := s.rootfsPreflight(w, req.host, role, unit, req.image)
if answered {
return
}
key := provision.InstanceID(req.host)
files := func() {
s.removeJITDropIn(unit)
- s.removeRootfsExe(key, RoleCmd)
+ s.removeRootfsExe(key, role)
}
// The unit's lock (task 11 fix E6), as startRootfs holds it; the
- // per-host cmd lock above already keeps two cmd starts apart, and
- // cleanCmdExe takes both in the same order.
+ // role's per-host lock above already keeps two starts of the role
+ // apart, and cleanCmdExe takes both in the same order.
hold, err := s.holdRootfsUnit(ctx, unit)
if err != nil {
- http.Error(w, "cmd: "+err.Error(), http.StatusConflict)
+ http.Error(w, string(role)+": "+err.Error(), http.StatusConflict)
return
}
defer hold.release()
@@ -1053,7 +1064,7 @@ func (s *Server) startRootfsCmd(w http.ResponseWriter, r *http.Request, req requ
}
removeOnce := func() { _ = s.removeRootfsUnitFilesOnce(ctx, hold, req.host, unit, files) }
if s.refuseStart(w, req.host, unit, func() error {
- err := s.ensureRootfsExe(key, RoleCmd, req.image.Path, launch)
+ err := s.ensureRootfsExe(key, role, req.image.Path, launch)
if err != nil {
removeOnce()
}
@@ -1082,8 +1093,9 @@ func (s *Server) startRootfsCmd(w http.ResponseWriter, r *http.Request, req requ
return
}
}
- // A command runs beside an awake instance, whose start set the slice;
- // a populated slice is left alone, as handleCmd leaves it.
+ // A command or session runs beside an awake instance, whose start set
+ // the slice; a populated slice is left alone, as the binary branch
+ // leaves it, so a session is inside the instance's slice and tier.
if s.slicePopulated(req.host) {
s.logf("instance-control: %s: slice populated, leaving its limit to the instance's owner", req.host)
} else if err := s.setTier(ctx, req.host, req.tier); err != nil {
@@ -1110,7 +1122,7 @@ func (s *Server) startRootfsCmd(w http.ResponseWriter, r *http.Request, req requ
dctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
s.stopUnit(dctx, unit)
cancel()
- failAfter(http.StatusBadGateway, "cmd: "+unit+" showed no new invocation")
+ failAfter(http.StatusBadGateway, string(role)+": "+unit+" showed no new invocation")
return
}
time.Sleep(s.cmdPoll())
@@ -1119,12 +1131,12 @@ func (s *Server) startRootfsCmd(w http.ResponseWriter, r *http.Request, req requ
// stopRootfs is /stop with runtime=rootfs: the run unit (with the legacy
// start fence, as the binary run unit), a generation (kill=1 kills it
-// outright), a worker, or the cmd unit. A stopped unit's files go with it:
-// a generation's or worker's drop-in directory and exe layout, a cmd's
-// layout, and in every case the unit's jit drop-in. Every role's go only
+// outright), a worker, or the cmd or tty unit. A stopped unit's files go
+// with it: a generation's or worker's drop-in directory and exe layout, a
+// cmd's or session's layout, and in every case the unit's jit drop-in. Every role's go only
// once it is proven gone (removeRootfsUnitFiles); unproven, they stay for
// the sweep and the answer is statusGenUnproven for a generation or
-// worker, 502 for the run or cmd unit.
+// worker, 502 for the run, cmd or tty unit.
func (s *Server) stopRootfs(w http.ResponseWriter, r *http.Request, req request) {
ctx := r.Context()
unit := rootfsUnitOf(req)
@@ -1158,8 +1170,8 @@ func (s *Server) stopRootfs(w http.ResponseWriter, r *http.Request, req request)
// generation's or worker's are what it finds them by), and the answer
// says so: statusGenUnproven for a generation or worker, 502 otherwise.
var err error
- if req.role == RoleCmd {
- err = s.cleanCmdExe(ctx, req.host, true)
+ if OneShot(req.role) {
+ err = s.cleanCmdExe(ctx, req.role, req.host, true)
} else if hold, ok := s.tryHoldRootfsUnit(unit); !ok {
err = errRootfsUnitInFlight(unit)
} else {
diff --git a/internal/instancectl/rootfs_test.go b/internal/instancectl/rootfs_test.go
index d77ee71dd..1612cb7c9 100644
--- a/internal/instancectl/rootfs_test.go
+++ b/internal/instancectl/rootfs_test.go
@@ -104,6 +104,7 @@ func rootfsFixture(t *testing.T) *rootfsBox {
release.ProcessWeb: {Command: []string{"/app/serve"}, WorkingDir: "/app", Env: map[string]string{"PATH": "/app/bin:/usr/local/bundle/bin:/usr/bin", "RAILS_ENV": "production"}},
"jobs": {Command: []string{"/app/jobs"}},
release.ProcessRelease: {Command: []string{"/app/migrate"}, WorkingDir: "/app", Env: map[string]string{"PATH": "/app/bin:/usr/bin"}},
+ release.ProcessConsole: {Command: []string{"/app/bin/rails", "console"}, WorkingDir: "/app", Env: map[string]string{"PATH": "/app/bin:/usr/bin"}},
}}
f.restageManifest(t, func(*release.Manifest) {})
return f
@@ -500,6 +501,8 @@ func (f *rootfsBox) unitFor(role string) string {
return WorkerUnitName(f.host, "jobs")
case "cmd":
return RootfsUnitName(RoleCmd, f.host)
+ case "tty":
+ return RootfsUnitName(RoleTTY, f.host)
}
return RootfsUnitName(RoleRun, f.host)
}
@@ -520,6 +523,8 @@ func roleOf(role string) Role {
return RoleWorker
case "cmd":
return RoleCmd
+ case "tty":
+ return RoleTTY
}
return RoleRun
}
@@ -535,6 +540,8 @@ func (f *rootfsBox) startRole(t *testing.T, role string) (int, string) {
return f.post(t, "/start", q)
case "cmd":
return f.post(t, "/cmd", f.cmdQuery("release", nil))
+ case "tty":
+ return f.post(t, "/tty", f.cmdQuery(release.ProcessConsole, nil))
}
return f.post(t, "/start", f.startQuery(RoleRun, release.ProcessWeb, 0))
}
@@ -1688,7 +1695,7 @@ func TestCmdStatusRefusesARoleOtherThanCmd(t *testing.T) {
f.srv.cmdWaitBound = 50 * time.Millisecond
var st CmdStatus
for _, rt := range []string{"rootfs", ""} {
- for _, role := range []string{"worker", "run", "seed", "sidecar", "nonsense"} {
+ for _, role := range []string{"worker", "run", "seed", "sidecar", "tty", "nonsense"} {
q := url.Values{"invocation": {x}, "role": {role}}
if rt != "" {
q.Set("runtime", rt)
@@ -1781,55 +1788,84 @@ func TestRootfsGenStartLeavesAPopulatedSliceAlone(t *testing.T) {
func TestRootfsJITReleaseStartsWithoutMDWEAndANonJITWithIt(t *testing.T) {
for _, role := range []string{"run", "gen", "worker", "cmd"} {
for _, jit := range []bool{true, false} {
- t.Run(fmt.Sprintf("%s/jit=%v", role, jit), func(t *testing.T) {
- f := rootfsFixture(t)
- f.warm(t)
- f.restageManifest(t, func(m *release.Manifest) { m.JIT = jit })
- unit := f.unitFor(role)
- // A stale drop-in from an earlier jit release of this app.
- if !jit {
- f.plantJITDropIn(t, unit)
- }
- f.answerStart(t, unit, jit)
- if status, body := f.startRole(t, role); status != 200 {
- t.Fatalf("start: %d %s", status, body)
- }
- _, err := os.Stat(filepath.Join(f.srv.DropInDir, unit+".d", JITDropInName))
- if jit && err != nil {
- t.Errorf("jit release: no %s for %s", JITDropInName, unit)
- }
- if !jit && err == nil {
- t.Errorf("non-jit release: %s left for %s", JITDropInName, unit)
- }
- if jit {
- if got, _ := os.ReadFile(filepath.Join(f.srv.DropInDir, unit+".d", JITDropInName)); string(got) != JITDropIn {
- t.Errorf("jit drop-in:\n%s", got)
- }
- }
- f.ctl.mustHaveCallsInOrder(t, "daemon-reload", "start")
- l := f.readLaunch(t, RootfsExeDir(f.srv.ExeRoot, f.keyFor(role), roleOf(role)))
- if l.JIT != jit {
- t.Errorf("launch.json jit = %v", l.JIT)
- }
- // A second start that changes no file does not reload (wake
- // latency). A cmd or worker unit must be stopped first (a
- // loaded one is refused), and a stop of a jit unit deletes
- // its jit drop-in, which the next start owes a reload for.
- mark := f.ctl.callCount()
- if role == "cmd" || role == "worker" {
- if status, body := f.stopRole(t, role); status != 204 {
- t.Fatalf("stop: %d %s", status, body)
- }
- }
- if status, body := f.startRole(t, role); status != 200 {
- t.Fatalf("second start: %d %s", status, body)
- }
- if jit && (role == "cmd" || role == "worker") {
- f.ctl.mustHaveCallsInOrderFrom(t, mark, "daemon-reload", "start")
- } else {
- f.ctl.mustNotHaveCallFrom(t, mark, "daemon-reload")
- }
- })
+ t.Run(fmt.Sprintf("%s/jit=%v", role, jit), func(t *testing.T) { rootfsJITStartCase(t, role, jit) })
+ }
+ }
+}
+
+// R11: a session of a jit release runs without MemoryDenyWriteExecute, like
+// every other process of it, through Plan 2's own start path: the same
+// assertions as the cmd role's, so the two cannot drift.
+func TestRootfsTTYStartFollowsTheReleasesJIT(t *testing.T) {
+ for _, jit := range []bool{true, false} {
+ t.Run(fmt.Sprintf("jit=%v", jit), func(t *testing.T) { rootfsJITStartCase(t, "tty", jit) })
+ }
+}
+
+// rootfsJITStartCase is one role's jit start: the drop-in written for a jit
+// release and removed for a non-jit one, the reload before the start, the
+// launch's jit, the post-start check passing on the effective property, and
+// a second start reloading only when a stop removed a jit drop-in.
+func rootfsJITStartCase(t *testing.T, role string, jit bool) {
+ t.Helper()
+ oneShot := role == "cmd" || role == "tty" || role == "worker"
+ f := rootfsFixture(t)
+ f.warm(t)
+ f.restageManifest(t, func(m *release.Manifest) { m.JIT = jit })
+ unit := f.unitFor(role)
+ // A stale drop-in from an earlier jit release of this app.
+ if !jit {
+ f.plantJITDropIn(t, unit)
+ }
+ f.answerStart(t, unit, jit)
+ if status, body := f.startRole(t, role); status != 200 {
+ t.Fatalf("start: %d %s", status, body)
+ }
+ _, err := os.Stat(filepath.Join(f.srv.DropInDir, unit+".d", JITDropInName))
+ if jit && err != nil {
+ t.Errorf("jit release: no %s for %s", JITDropInName, unit)
+ }
+ if !jit && err == nil {
+ t.Errorf("non-jit release: %s left for %s", JITDropInName, unit)
+ }
+ if jit {
+ if got, _ := os.ReadFile(filepath.Join(f.srv.DropInDir, unit+".d", JITDropInName)); string(got) != JITDropIn {
+ t.Errorf("jit drop-in:\n%s", got)
+ }
+ }
+ f.ctl.mustHaveCallsInOrder(t, "daemon-reload", "start")
+ f.ctl.mustHaveCall(t, rootfsPostStartShow+" "+unit)
+ l := f.readLaunch(t, RootfsExeDir(f.srv.ExeRoot, f.keyFor(role), roleOf(role)))
+ if l.JIT != jit {
+ t.Errorf("launch.json jit = %v", l.JIT)
+ }
+ // A second start that changes no file does not reload (wake
+ // latency). A cmd, tty or worker unit must be stopped first (a
+ // loaded one is refused), and a stop of a jit unit deletes its jit
+ // drop-in, which the next start owes a reload for.
+ mark := f.ctl.callCount()
+ if oneShot {
+ if status, body := f.stopRole(t, role); status != 204 {
+ t.Fatalf("stop: %d %s", status, body)
+ }
+ }
+ if status, body := f.startRole(t, role); status != 200 {
+ t.Fatalf("second start: %d %s", status, body)
+ }
+ if jit && oneShot {
+ f.ctl.mustHaveCallsInOrderFrom(t, mark, "daemon-reload", "start")
+ } else {
+ f.ctl.mustNotHaveCallFrom(t, mark, "daemon-reload")
+ }
+ // The effective-property check is the same one: a session whose loaded
+ // MemoryDenyWriteExecute disagrees with the release is stopped, 502.
+ if role == "tty" {
+ if status, body := f.stopRole(t, role); status != 204 {
+ t.Fatalf("stop: %d %s", status, body)
+ }
+ f.answerStart(t, unit, !jit)
+ if status, body := f.startRole(t, role); status != 502 || !strings.Contains(body, "MemoryDenyWriteExecute") {
+ t.Errorf("a session whose effective property disagrees: %d %s, want 502", status, body)
}
}
}
@@ -1888,30 +1924,56 @@ func TestRootfsJITComesOnlyFromTheStagedManifest(t *testing.T) {
// property changes only on daemon-reload.
func TestRootfsNonJITStartAfterJITCleanupReloads(t *testing.T) {
for _, role := range []string{"run", "worker", "cmd"} {
- t.Run(role, func(t *testing.T) {
- f := rootfsFixture(t)
- f.loadedJIT(t)
- unit := f.unitFor(role)
- f.restageManifest(t, func(m *release.Manifest) { m.JIT = true })
- if status, body := f.startRole(t, role); status != 200 {
- t.Fatalf("jit start: %d %s", status, body)
- }
- if status, body := f.stopRole(t, role); status != 204 {
- t.Fatalf("stop: %d %s", status, body)
- }
- if _, err := os.Stat(filepath.Join(f.srv.DropInDir, unit+".d", JITDropInName)); err == nil {
- t.Fatal("the stop left the jit drop-in")
- }
- mark := f.ctl.callCount()
- f.restageManifest(t, func(m *release.Manifest) { m.JIT = false })
- if status, body := f.startRole(t, role); status != 200 {
- t.Fatalf("non-jit start after cleanup: %d %s (it started on the cached jit setting)", status, body)
- }
- f.ctl.mustHaveCallsInOrderFrom(t, mark, "daemon-reload", "start")
- })
+ t.Run(role, func(t *testing.T) { rootfsNonJITAfterJITCase(t, role) })
}
}
+// Astra R2 finding 1 for sessions: the tty unit's name is reused across
+// sessions, so a non-jit session after a jit one is the same stale-load
+// case, covered by the same owed reload.
+func TestRootfsTTYNonJITSessionAfterAJITOneReloads(t *testing.T) {
+ rootfsNonJITAfterJITCase(t, "tty")
+}
+
+// rootfsNonJITAfterJITCase is one role's jit start, its stop (which removes
+// the jit drop-in and does not reload), then a non-jit start of the same
+// unit name, on the loaded-configuration model: it must reload before it
+// starts, and pass the post-start check with MemoryDenyWriteExecute=yes.
+func rootfsNonJITAfterJITCase(t *testing.T, role string) {
+ t.Helper()
+ f := rootfsFixture(t)
+ f.loadedJIT(t)
+ unit := f.unitFor(role)
+ f.restageManifest(t, func(m *release.Manifest) { m.JIT = true })
+ if status, body := f.startRole(t, role); status != 200 {
+ t.Fatalf("jit start: %d %s", status, body)
+ }
+ mark := f.ctl.callCount()
+ if status, body := f.stopRole(t, role); status != 204 {
+ t.Fatalf("stop: %d %s", status, body)
+ }
+ f.ctl.mustNotHaveCallFrom(t, mark, "daemon-reload")
+ if _, err := os.Stat(filepath.Join(f.srv.DropInDir, unit+".d", JITDropInName)); err == nil {
+ t.Fatal("the stop left the jit drop-in")
+ }
+ mark = f.ctl.callCount()
+ f.restageManifest(t, func(m *release.Manifest) { m.JIT = false })
+ if status, body := f.startRole(t, role); status != 200 {
+ t.Fatalf("non-jit start after cleanup: %d %s (it started on the cached jit setting)", status, body)
+ }
+ f.ctl.mustHaveCallsInOrderFrom(t, mark, "daemon-reload", "start")
+ if got := f.mdwe(unit); got != "yes" {
+ t.Errorf("the non-jit start runs with MemoryDenyWriteExecute=%s", got)
+ }
+}
+
+// mdwe is the model's effective MemoryDenyWriteExecute for unit now.
+func (f *rootfsBox) mdwe(unit string) string {
+ f.shared.mu.Lock()
+ defer f.shared.mu.Unlock()
+ return f.mdweLocked(unit)
+}
+
// The owed reload is cleared only by a reload that succeeds. After a jit
// start and its stop: daemon-reload fails once, so the non-jit start answers
// 502 and no "start" follows; the next start reloads and answers 200. A new
@@ -2979,3 +3041,329 @@ func sha256Hex(s string) string {
sum := sha256.Sum256([]byte(s))
return hex.EncodeToString(sum[:])
}
+
+// The rootfs /tty start is Plan 2's rootfs /cmd branch on the tty role's
+// unit and layout (D3): a declared process (console) or an argv body,
+// validated and resolved by the same rule; web is refused.
+func TestRootfsRowStartsTheRootfsTTYUnit(t *testing.T) {
+ f := rootfsFixture(t)
+ unit := RootfsUnitName(RoleTTY, f.host)
+ status, body := f.post(t, "/tty", f.cmdQuery(release.ProcessConsole, nil))
+ if status != 200 {
+ t.Fatalf("tty console: %d %s", status, body)
+ }
+ var resp StartResponse
+ if err := json.Unmarshal([]byte(body), &resp); err != nil || len(resp.InvocationID) != 32 {
+ t.Errorf("response %s: %v", body, err)
+ }
+ f.ctl.mustHaveCallsInOrder(t, "start --no-block "+unit, rootfsPostStartShow+" "+unit)
+ for _, other := range []string{UnitName(RoleTTY, f.host), UnitName(RoleCmd, f.host), RootfsUnitName(RoleCmd, f.host)} {
+ f.ctl.mustNotHaveCall(t, "start --no-block "+other)
+ }
+ ttyDir := RootfsExeDir(f.srv.ExeRoot, provision.InstanceID(f.host), RoleTTY)
+ l := f.readLaunch(t, ttyDir)
+ if l.Process != release.ProcessConsole || !reflect.DeepEqual(l.Argv, []string{"/app/bin/rails", "console"}) || l.Host != f.host || l.Digest != f.digest {
+ t.Errorf("console launch = %+v", l)
+ }
+ if got, err := os.Readlink(filepath.Join(ttyDir, RootfsExeImage)); err != nil || got != f.imagePath {
+ t.Errorf("rootfs/tty/image = %q (%v)", got, err)
+ }
+ if exists(RootfsExeDir(f.srv.ExeRoot, provision.InstanceID(f.host), RoleCmd)) {
+ t.Error("a session's start laid out rootfs/cmd/")
+ }
+ // An argv body (carlos run -it): the cmd launch shape.
+ f = rootfsFixture(t)
+ if status, body := f.post(t, "/tty", f.cmdQuery("", []string{"bin/rails", "db:migrate:status"})); status != 200 {
+ t.Fatalf("tty argv: %d %s", status, body)
+ }
+ l = f.readLaunch(t, RootfsExeDir(f.srv.ExeRoot, provision.InstanceID(f.host), RoleTTY))
+ if l.Process != "cmd" || !reflect.DeepEqual(l.Argv, []string{"bin/rails", "db:migrate:status"}) {
+ t.Errorf("argv launch = %+v", l)
+ }
+ // The refusals are the cmd role's, before anything starts.
+ for _, bad := range []struct {
+ process string
+ argv []string
+ status int
+ want string
+ }{{release.ProcessWeb, nil, 403, "web is the run role's process, not a tty's"}, {"", nil, 400, "process"}, {release.ProcessConsole, []string{"x"}, 400, "process"}, {"cron", nil, 403, "cron is not a process this release declares"}} {
+ f := rootfsFixture(t)
+ status, body := f.post(t, "/tty", f.cmdQuery(bad.process, bad.argv))
+ if status != bad.status || !strings.Contains(body, bad.want) {
+ t.Errorf("tty process=%q argv=%v: %d %q, want %d with %q", bad.process, bad.argv, status, body, bad.status, bad.want)
+ }
+ f.ctl.mustNotHaveCall(t, "start")
+ if exists(RootfsExeDir(f.srv.ExeRoot, provision.InstanceID(f.host), RoleTTY)) {
+ t.Errorf("tty process=%q argv=%v: a refused session laid out rootfs/tty/", bad.process, bad.argv)
+ }
+ }
+ // A binary row is never started from an image.
+ f = rootfsFixture(t)
+ f.srv.HostRuntime = func(string) (string, error) { return "", nil }
+ if status, _ := f.post(t, "/tty", f.cmdQuery(release.ProcessConsole, nil)); status != 403 {
+ t.Errorf("a rootfs session on a binary row answered %d, want 403", status)
+ }
+ f.ctl.mustNotHaveCall(t, "start")
+ // process= on a binary request (no runtime) is refused.
+ if status, body := f.post(t, "/tty", url.Values{"host": {f.host}, "memory_max": {strconv.FormatInt(cgroup.TierChildren.MemoryMax, 10)}, "process": {release.ProcessConsole}}); status != 400 {
+ t.Errorf("a binary session naming a process answered %d %s, want 400", status, body)
+ }
+}
+
+// Rev 2 P1-2: a declared process keeps its own env and working directory;
+// an argv with the same command gets web's.
+func TestRootfsTTYDeclaredProcessKeepsItsEnvAndDir(t *testing.T) {
+ f := rootfsFixture(t)
+ f.restageManifest(t, func(m *release.Manifest) {
+ m.Processes[release.ProcessWeb] = release.Process{Command: []string{"/app/bin/rails", "console"}, WorkingDir: "/app", Env: map[string]string{"PATH": "/app/bin:/usr/bin", "RAILS_ENV": "production"}}
+ m.Processes[release.ProcessConsole] = release.Process{Command: []string{"/app/bin/rails", "console"}, WorkingDir: "/srv/console", Env: map[string]string{"PATH": "/srv/console/bin:/usr/bin", "RAILS_ENV": "console"}}
+ })
+ dir := RootfsExeDir(f.srv.ExeRoot, provision.InstanceID(f.host), RoleTTY)
+ if status, body := f.post(t, "/tty", f.cmdQuery(release.ProcessConsole, nil)); status != 200 {
+ t.Fatalf("tty console: %d %s", status, body)
+ }
+ l := f.readLaunch(t, dir)
+ if l.Process != release.ProcessConsole || l.WorkingDir != "/srv/console" || l.Env["RAILS_ENV"] != "console" || l.Env["PATH"] != "/srv/console/bin:/usr/bin" {
+ t.Errorf("console launch = %+v, want the console's env and working_dir", l)
+ }
+ if status, body := f.stopRole(t, "tty"); status != 204 {
+ t.Fatalf("stop: %d %s", status, body)
+ }
+ if status, body := f.post(t, "/tty", f.cmdQuery("", []string{"/app/bin/rails", "console"})); status != 200 {
+ t.Fatalf("tty argv: %d %s", status, body)
+ }
+ l = f.readLaunch(t, dir)
+ if l.Process != "cmd" || l.WorkingDir != "/app" || l.Env["RAILS_ENV"] != "production" || l.Env["PATH"] != "/app/bin:/usr/bin" {
+ t.Errorf("argv launch = %+v, want web's env and working_dir", l)
+ }
+}
+
+// A session's stop names the rootfs tty unit, takes rootfs/tty/ and the
+// unit's jit drop-in through the proof, and leaves rootfs/cmd/ alone.
+func TestRootfsTTYStopNamesTheTTYUnit(t *testing.T) {
+ f := rootfsFixture(t)
+ ttyUnit, cmdUnit := RootfsUnitName(RoleTTY, f.host), RootfsUnitName(RoleCmd, f.host)
+ if status, body := f.startRole(t, "cmd"); status != 200 {
+ t.Fatalf("cmd: %d %s", status, body)
+ }
+ if status, body := f.startRole(t, "tty"); status != 200 {
+ t.Fatalf("tty beside a running cmd: %d %s", status, body)
+ }
+ if status, body := f.startRole(t, "tty"); status != 409 {
+ t.Fatalf("tty while tty runs: %d %s, want 409", status, body)
+ }
+ f.plantJITDropIn(t, ttyUnit)
+ f.plantJITDropIn(t, cmdUnit)
+ iid := provision.InstanceID(f.host)
+ q := url.Values{"host": {f.host}, "role": {"tty"}, "runtime": {"rootfs"}}
+ if status, body := f.post(t, "/stop", q); status != 204 {
+ t.Fatalf("stop: %d %s", status, body)
+ }
+ if status, body := f.post(t, "/reset", q); status != 204 {
+ t.Fatalf("reset: %d %s", status, body)
+ }
+ f.ctl.mustHaveCall(t, "stop "+ttyUnit)
+ f.ctl.mustHaveCall(t, "reset-failed "+ttyUnit)
+ for _, other := range []string{cmdUnit, UnitName(RoleTTY, f.host), UnitName(RoleCmd, f.host)} {
+ f.ctl.mustNotHaveCall(t, "stop "+other)
+ f.ctl.mustNotHaveCall(t, "reset-failed "+other)
+ }
+ if exists(RootfsExeDir(f.srv.ExeRoot, iid, RoleTTY)) {
+ t.Error("rootfs/tty/ survived the session's stop")
+ }
+ if exists(filepath.Join(f.srv.DropInDir, ttyUnit+".d", JITDropInName)) {
+ t.Error("the tty unit's jit drop-in survived its stop")
+ }
+ if !exists(RootfsExeDir(f.srv.ExeRoot, iid, RoleCmd)) {
+ t.Error("a session's stop removed rootfs/cmd/")
+ }
+ if !exists(filepath.Join(f.srv.DropInDir, cmdUnit+".d", JITDropInName)) {
+ t.Error("a session's stop removed the cmd unit's jit drop-in")
+ }
+ // And the cmd stop leaves a session's layout alone.
+ if status, body := f.startRole(t, "tty"); status != 200 {
+ t.Fatalf("tty again: %d %s", status, body)
+ }
+ if status, body := f.stopRole(t, "cmd"); status != 204 {
+ t.Fatalf("cmd stop: %d %s", status, body)
+ }
+ if exists(RootfsExeDir(f.srv.ExeRoot, iid, RoleCmd)) {
+ t.Error("rootfs/cmd/ survived the command's stop")
+ }
+ if !exists(RootfsExeDir(f.srv.ExeRoot, iid, RoleTTY)) {
+ t.Error("a command's stop removed rootfs/tty/")
+ }
+ // An unproven tty stop keeps its files and answers 502.
+ f.ctl.set("show -p ActiveState --value "+ttyUnit, "active\n")
+ f.srv.cgroupWaitBudget = 50 * time.Millisecond
+ if status, body := f.post(t, "/stop", q); status != 502 || !strings.Contains(body, "termination unproven") {
+ t.Errorf("an unproven tty stop: %d %s, want 502", status, body)
+ }
+ if !exists(RootfsExeDir(f.srv.ExeRoot, iid, RoleTTY)) {
+ t.Error("an unproven tty stop removed rootfs/tty/")
+ }
+}
+
+// PF-7 on the rootfs branch: a rootfs cmd start held mid-flight does not
+// hold up a rootfs session's start on the same host.
+func TestRootfsTTYAndCmdLocksAreSeparate(t *testing.T) {
+ f := rootfsFixture(t)
+ f.warm(t)
+ entered, release := holdStart(t, f.ctl)
+ cmdDone := make(chan int, 1)
+ go func() { s, _ := f.startRole(t, "cmd"); cmdDone <- s }()
+ awaitEntered(t, entered)
+ ttyDone := make(chan int, 1)
+ go func() { s, _ := f.startRole(t, "tty"); ttyDone <- s }()
+ select {
+ case code := <-ttyDone:
+ if code != 200 {
+ t.Errorf("rootfs tty beside a held rootfs cmd start: %d", code)
+ }
+ case <-time.After(3 * time.Second):
+ t.Fatal("a rootfs session start waited behind a rootfs cmd start's lock")
+ }
+ release()
+ if code := <-cmdDone; code != 200 {
+ t.Errorf("the held rootfs cmd start: %d", code)
+ }
+}
+
+// PF-6: the fifth verb. The rootfs session poll reads the rootfs tty unit
+// and never the binary tty unit or either cmd unit.
+func TestTTYStatusRootfsPollsTheRootfsTTYUnit(t *testing.T) {
+ f := rootfsFixture(t)
+ c := f.client(t)
+ ctx := context.Background()
+ x := strings.Repeat("ab", 16)
+ fields := cmdShowAll + " "
+ f.ctl.set(fields+RootfsUnitName(RoleTTY, f.host), "InvocationID="+x+"\nActiveState=inactive\nSubState=dead\nResult=success\nExecMainStatus=0\nExecMainCode=exited\n")
+ for _, other := range []string{UnitName(RoleTTY, f.host), UnitName(RoleCmd, f.host), RootfsUnitName(RoleCmd, f.host)} {
+ f.ctl.set(fields+other, "InvocationID="+x+"\nActiveState=active\nSubState=running\nResult=success\nExecMainStatus=0\nExecMainCode=0\n")
+ }
+ f.srv.cmdWaitBound = 50 * time.Millisecond
+ st, err := c.TTYStatusRootfs(ctx, f.host, x)
+ if err != nil || st.State != CmdDone {
+ t.Fatalf("TTYStatusRootfs = %+v, %v, want done", st, err)
+ }
+ f.ctl.mustHaveCall(t, fields+RootfsUnitName(RoleTTY, f.host))
+ for _, other := range []string{UnitName(RoleTTY, f.host), UnitName(RoleCmd, f.host), RootfsUnitName(RoleCmd, f.host)} {
+ f.ctl.mustNotHaveCall(t, fields+other)
+ }
+ // The other three verbs each read their own unit.
+ for _, c2 := range []struct {
+ poll func() (CmdStatus, error)
+ unit string
+ }{
+ {func() (CmdStatus, error) { return c.TTYStatus(ctx, f.host, x) }, UnitName(RoleTTY, f.host)},
+ {func() (CmdStatus, error) { return c.CmdStatus(ctx, f.host, x) }, UnitName(RoleCmd, f.host)},
+ {func() (CmdStatus, error) { return c.CmdStatusRootfs(ctx, f.host, x) }, RootfsUnitName(RoleCmd, f.host)},
+ } {
+ f.ctl.reset()
+ if st, err := c2.poll(); err != nil || st.State != CmdRunning {
+ t.Errorf("poll of %s = %+v, %v, want running", c2.unit, st, err)
+ }
+ f.ctl.mustHaveCall(t, fields+c2.unit)
+ }
+}
+
+// Every tty client verb reaches the real parser, and root's 403 on the
+// rootfs session start is ErrStagedImage, as CmdRootfs's is.
+func TestClientTTYRootfsReachesTheRealParser(t *testing.T) {
+ f := rootfsFixture(t)
+ c := f.client(t)
+ ctx := context.Background()
+ img := f.img(release.ProcessConsole)
+ inv, err := c.TTYRootfs(ctx, f.host, cgroup.TierChildren.MemoryMax, img)
+ if err != nil || len(inv) != 32 {
+ t.Fatalf("TTYRootfs: %q %v", inv, err)
+ }
+ f.ctl.mustHaveCall(t, "start --no-block "+RootfsUnitName(RoleTTY, f.host))
+ if err := c.StopRootfs(ctx, f.host, RoleTTY, 0, "", false); err != nil {
+ t.Fatalf("StopRootfs(tty): %v", err)
+ }
+ f.ctl.mustHaveCall(t, "stop "+RootfsUnitName(RoleTTY, f.host))
+ if inv, err := c.TTYRootfs(ctx, f.host, cgroup.TierChildren.MemoryMax, StagedImage{Path: f.imagePath, Version: rootfsVer, Digest: f.digest, Argv: []string{"bin/rails", "console"}}); err != nil || len(inv) != 32 {
+ t.Fatalf("TTYRootfs argv: %q %v", inv, err)
+ }
+ if err := c.StopRootfs(ctx, f.host, RoleTTY, 0, "", false); err != nil {
+ t.Fatalf("StopRootfs(tty): %v", err)
+ }
+ bad := img
+ bad.Digest = strings.Repeat("0", 64)
+ if _, err := c.TTYRootfs(ctx, f.host, cgroup.TierChildren.MemoryMax, bad); !errors.Is(err, ErrStagedImage) {
+ t.Errorf("TTYRootfs with a bad digest: %v, want ErrStagedImage", err)
+ }
+ web := img
+ web.Process = release.ProcessWeb
+ if _, err := c.TTYRootfs(ctx, f.host, cgroup.TierChildren.MemoryMax, web); !errors.Is(err, ErrStagedImage) {
+ t.Errorf("TTYRootfs of web: %v, want ErrStagedImage", err)
+ }
+ both := img
+ both.Argv = []string{"x"}
+ if _, err := c.TTYRootfs(ctx, f.host, cgroup.TierChildren.MemoryMax, both); !errors.Is(err, ErrStartRefused) {
+ t.Errorf("TTYRootfs with a process and an argv: %v, want ErrStartRefused (400)", err)
+ }
+}
+
+// The sweep lists both tty templates and takes each one's files: the
+// binary session's tty-app and tty-live, the rootfs session's rootfs/tty/
+// and its jit drop-in.
+func TestSweepCoversTTYUnits(t *testing.T) {
+ f := rootfsFixture(t)
+ const binHost = "blog.example.com"
+ binTTY, rootTTY := UnitName(RoleTTY, binHost), RootfsUnitName(RoleTTY, f.host)
+ f.ctl.set("list-units", binTTY+" loaded active running\n"+rootTTY+" loaded active running\n")
+ f.ctl.set("list-jobs", "")
+ f.ctl.set("show -p ActiveState --value", "inactive\n")
+ binIID, iid := provision.InstanceID(binHost), provision.InstanceID(f.host)
+ if err := ensureExeAs(f.srv.ExeRoot, binIID, filepath.Join(LiveDir, binHost), binHost, TTYExeApp, TTYExeLive); err != nil {
+ t.Fatal(err)
+ }
+ if err := ensureExeAs(f.srv.ExeRoot, binIID, filepath.Join(LiveDir, binHost), binHost, CmdExeApp, CmdExeLive); err != nil {
+ t.Fatal(err)
+ }
+ for _, role := range []Role{RoleTTY, RoleCmd} {
+ if err := os.MkdirAll(RootfsExeDir(f.srv.ExeRoot, iid, role), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ }
+ f.plantJITDropIn(t, rootTTY)
+ status, body := f.post(t, "/sweep", nil)
+ if status != 200 {
+ t.Fatalf("sweep: %d %s", status, body)
+ }
+ f.ctl.mustHaveCall(t, "stop "+binTTY)
+ f.ctl.mustHaveCall(t, "stop "+rootTTY)
+ for _, name := range []string{TTYExeApp, TTYExeLive} {
+ if _, err := os.Lstat(filepath.Join(f.srv.ExeRoot, binIID, name)); !os.IsNotExist(err) {
+ t.Errorf("%s survived the sweep (%v)", name, err)
+ }
+ }
+ if _, err := os.Lstat(filepath.Join(f.srv.ExeRoot, binIID, CmdExeApp)); err != nil {
+ t.Errorf("the sweep of a session took cmd-app: %v", err)
+ }
+ if exists(RootfsExeDir(f.srv.ExeRoot, iid, RoleTTY)) {
+ t.Error("rootfs/tty/ survived the sweep")
+ }
+ if !exists(RootfsExeDir(f.srv.ExeRoot, iid, RoleCmd)) {
+ t.Error("the sweep of a session took rootfs/cmd/")
+ }
+ if exists(filepath.Join(f.srv.DropInDir, rootTTY+".d", JITDropInName)) {
+ t.Error("the rootfs session's jit drop-in survived the sweep")
+ }
+ listed := false
+ for _, call := range f.ctl.snapshot() {
+ if strings.HasPrefix(call, "list-units") {
+ listed = true
+ for _, p := range []string{UnitPrefixTTY, UnitPrefixRootfsTTY, UnitPrefixCmd, UnitPrefixRootfsCmd} {
+ if !strings.Contains(call, p+"*.service") {
+ t.Errorf("sweep does not list %s", p)
+ }
+ }
+ }
+ }
+ if !listed {
+ t.Error("no list-units call")
+ }
+}
diff --git a/internal/instancectl/server.go b/internal/instancectl/server.go
index 5d7e9e9bb..1d4a8e0db 100644
--- a/internal/instancectl/server.go
+++ b/internal/instancectl/server.go
@@ -110,15 +110,16 @@ type Server struct {
Statfs func(path string) (avail, total uint64, err error)
DiskEvery time.Duration
- // cmdPollEvery, cmdWaitBound and cmdStartBound pace the cmd routes:
- // how often GET /cmd/{host} re-reads the unit (250 ms), how long it
- // holds a request (30 s, run spec §5.4), and how long POST /cmd waits
- // for the queued start to show a new invocation (10 s). Zero is the
- // default; tests shorten them.
+ // cmdPollEvery, cmdWaitBound and cmdStartBound pace the one-shot
+ // routes (/cmd and /tty): how often GET /cmd/{host} re-reads the unit
+ // (250 ms), how long it holds a request (30 s, run spec §5.4), and how
+ // long POST /cmd waits for the queued start to show a new invocation
+ // (10 s). Zero is the default; tests shorten them.
cmdPollEvery, cmdWaitBound, cmdStartBound time.Duration
- // cmdLocks holds one *sync.Mutex per host, taken by handleCmd from its
- // ActiveState read to its answer, so two starts for one host cannot both
- // pass the check.
+ // cmdLocks holds one *sync.Mutex per one-shot role and host
+ // (oneShotKey, PF-7), taken by a start from its ActiveState read to its
+ // answer, so two starts of one role for one host cannot both pass the
+ // check, and a session's start never waits behind a command's.
cmdLocks sync.Map
// sliceLocks holds one *sync.Mutex per host slice, keyed by
// SliceName: /size and /parent, the two verbs that write a running
@@ -416,8 +417,12 @@ func (s *Server) Handler() http.Handler {
mux.HandleFunc("POST /reset", s.claimAwareLegacy(s.handleReset))
mux.HandleFunc("POST /sweep", s.claimAwareLegacy(s.handleSweep))
mux.HandleFunc("POST /parent", s.claimAwareLegacy(s.handleParent))
- mux.HandleFunc("POST /cmd", s.claimAwareLegacy(s.handleCmd))
- mux.HandleFunc("GET /cmd/{host}", s.claimAwareLegacy(s.handleCmdStatus))
+ mux.HandleFunc("POST /cmd", s.claimAwareLegacy(s.handleOneShot(RoleCmd)))
+ mux.HandleFunc("GET /cmd/{host}", s.claimAwareLegacy(s.handleOneShotStatus(RoleCmd)))
+ // An interactive session (rootfs apps design §5.10): /cmd's behaviour
+ // exactly, on the tty role's unit, exe sources and lock.
+ mux.HandleFunc("POST /tty", s.claimAwareLegacy(s.handleOneShot(RoleTTY)))
+ mux.HandleFunc("GET /tty/{host}", s.claimAwareLegacy(s.handleOneShotStatus(RoleTTY)))
// A live size is a legacy verb: with host claims on there is no live
// change, and a new size waits for the next start (#329, spec §5.4).
mux.HandleFunc("POST /size", s.claimAwareLegacy(s.handleSize))
@@ -489,12 +494,12 @@ type verbShape struct {
// seed is the /seed verb, which names no role: its unit is the seed
// unit, which may bind a staged build (settings spec §4.2).
seed bool
- // cmd is /cmd, whose staged build is the serving generation's, as the
+ // cmd is /cmd or /tty, whose staged build is the serving generation's, as the
// legacy sidecar's is (run spec §5.4 under zero-downtime spec §7.5).
cmd bool
- // rootfs is a launch verb (/start, /cmd): runtime=rootfs and the image
+ // rootfs is a launch verb (/start, /cmd, /tty): runtime=rootfs and the image
// fields come together or not at all. rootfsStop is a termination verb
- // or the status poll (/stop, /reset, GET /cmd/{host}): runtime=rootfs
+ // or the status poll (/stop, /reset, GET /cmd/{host}, GET /tty/{host}): runtime=rootfs
// alone, and any image field is a 400 (Astra R1 finding 6). worker
// admits worker=<name> beside role=worker.
rootfs bool
@@ -544,7 +549,7 @@ func parseRequest(r *http.Request, v verbShape) (request, error) {
}
// parseQuery is parseRequest over the query alone, for a verb whose host
-// is in its path (GET /cmd/{host}).
+// is in its path (GET /cmd/{host}, GET /tty/{host}).
func parseQuery(host string, q url.Values, v verbShape) (request, error) {
req := request{host: host}
// role=worker is a rootfs role only (preflight 1.1): without
@@ -923,7 +928,7 @@ func (s *Server) stopUnit(ctx context.Context, unit string) {
}
func (s *Server) handleStop(w http.ResponseWriter, r *http.Request) {
- req, err := parseRequest(r, verbShape{roles: []Role{RoleRun, RoleSeed, RoleSidecar, RoleCmd, RoleWorker}, gen: true, kill: true, rootfsStop: true, worker: true})
+ req, err := parseRequest(r, verbShape{roles: []Role{RoleRun, RoleSeed, RoleSidecar, RoleCmd, RoleWorker, RoleTTY}, gen: true, kill: true, rootfsStop: true, worker: true})
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
@@ -966,14 +971,14 @@ func (s *Server) handleStop(w http.ResponseWriter, r *http.Request) {
return
}
}
- if req.role == RoleCmd {
- _ = s.cleanCmdExe(r.Context(), req.host, false)
+ if OneShot(req.role) {
+ _ = s.cleanCmdExe(r.Context(), req.role, req.host, false)
}
w.WriteHeader(http.StatusNoContent)
}
func (s *Server) handleReset(w http.ResponseWriter, r *http.Request) {
- req, err := parseRequest(r, verbShape{roles: []Role{RoleRun, RoleSeed, RoleSidecar, RoleCmd, RoleWorker}, gen: true, rootfsStop: true, worker: true})
+ req, err := parseRequest(r, verbShape{roles: []Role{RoleRun, RoleSeed, RoleSidecar, RoleCmd, RoleWorker, RoleTTY}, gen: true, rootfsStop: true, worker: true})
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
@@ -1004,8 +1009,8 @@ func (s *Server) handleSweep(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
targets := map[string]bool{}
out, err := s.Systemctl(ctx, "list-units", "--all", "--plain", "--no-legend", "--no-pager",
- UnitPrefixRun+"*.service", UnitPrefixSeed+"*.service", UnitPrefixSidecar+"*.service", UnitPrefixCmd+"*.service", UnitPrefixGen+"*.service",
- UnitPrefixRootfs+"*.service", UnitPrefixRootfsGen+"*.service", UnitPrefixRootfsWorker+"*.service", UnitPrefixRootfsCmd+"*.service")
+ UnitPrefixRun+"*.service", UnitPrefixSeed+"*.service", UnitPrefixSidecar+"*.service", UnitPrefixCmd+"*.service", UnitPrefixTTY+"*.service", UnitPrefixGen+"*.service",
+ UnitPrefixRootfs+"*.service", UnitPrefixRootfsGen+"*.service", UnitPrefixRootfsWorker+"*.service", UnitPrefixRootfsCmd+"*.service", UnitPrefixRootfsTTY+"*.service")
if err != nil {
http.Error(w, "list-units: "+err.Error(), http.StatusBadGateway)
return
@@ -1087,9 +1092,9 @@ func (s *Server) handleSweep(w http.ResponseWriter, r *http.Request) {
}
stopped = append(stopped, unit)
s.removeGenFiles(unit)
- if role, esc, _ := ParseUnitName(unit); role == RoleCmd {
+ if role, esc, _ := ParseUnitName(unit); OneShot(role) {
if iid, ok := Unescape(esc); ok {
- s.removeCmdExe(iid)
+ s.removeCmdExe(role, iid)
}
}
}
diff --git a/internal/instancectl/stagedexe.go b/internal/instancectl/stagedexe.go
index f5753917f..d98116c45 100644
--- a/internal/instancectl/stagedexe.go
+++ b/internal/instancectl/stagedexe.go
@@ -123,29 +123,47 @@ func (s *Server) ensureHostExeAt(host string, x StagedExe) error {
return ensureExe(s.ExeRoot, provision.InstanceID(host), x.Path, host)
}
-// ensureCmdExeAt lays out a run's executable mount, apart from the host's
-// (merge ruling M4): <ExeRoot>/<id>/cmd-app and cmd-live/<host>, which only
-// the cmd template binds. A command and a sidecar starting on different
-// builds around a swap therefore never overwrite the source the other is
-// about to bind. It points at a validated staged build when x names one,
-// and at the live link otherwise.
-func (s *Server) ensureCmdExeAt(host string, x StagedExe) error {
+// ensureCmdExeAt lays out a one-shot role's executable mount, apart from
+// the host's (merge ruling M4): <ExeRoot>/<id>/cmd-app and cmd-live/<host>
+// for a command, tty-app and tty-live/<host> for a session, which only that
+// role's template binds. A command, a session and a sidecar starting on
+// different builds around a swap therefore never overwrite the source
+// another is about to bind. It points at a validated staged build when x
+// names one, and at the live link otherwise.
+func (s *Server) ensureCmdExeAt(role Role, host string, x StagedExe) error {
+ app, live, ok := oneShotExe(role)
+ if !ok {
+ return fmt.Errorf("exe: role %s has no one-shot sources", role)
+ }
target := x.Path
if target == "" {
target = filepath.Join(LiveDir, host)
}
- return ensureExeAs(s.ExeRoot, provision.InstanceID(host), target, host, CmdExeApp, CmdExeLive)
+ return ensureExeAs(s.ExeRoot, provision.InstanceID(host), target, host, app, live)
}
-// removeCmdExe removes a run's executable mount sources, once its unit is
-// stopped: they name a build the instance may no longer serve. Best-effort,
-// as removeGenFiles is: a leftover is two links in /run, rewritten by the
-// next run's start.
-func (s *Server) removeCmdExe(iid string) {
- if s.ExeRoot == "" || iid == "" || strings.ContainsAny(iid, "/\x00") || iid == "." || iid == ".." {
+// removeCmdExe removes a one-shot role's executable mount sources, once
+// its unit is stopped: they name a build the instance may no longer serve.
+// Only role's own two go; the other one-shot role's stay. Best-effort, as
+// removeGenFiles is: a leftover is two links in /run, rewritten by the next
+// start of the role.
+func (s *Server) removeCmdExe(role Role, iid string) {
+ app, live, ok := oneShotExe(role)
+ if !ok || s.ExeRoot == "" || iid == "" || strings.ContainsAny(iid, "/\x00") || iid == "." || iid == ".." {
return
}
dir := filepath.Join(s.ExeRoot, iid)
- _ = os.Remove(filepath.Join(dir, CmdExeApp))
- _ = os.RemoveAll(filepath.Join(dir, CmdExeLive))
+ _ = os.Remove(filepath.Join(dir, app))
+ _ = os.RemoveAll(filepath.Join(dir, live))
+}
+
+// oneShotExe is a one-shot role's two executable mount sources.
+func oneShotExe(role Role) (app, live string, ok bool) {
+ switch role {
+ case RoleCmd:
+ return CmdExeApp, CmdExeLive, true
+ case RoleTTY:
+ return TTYExeApp, TTYExeLive, true
+ }
+ return "", "", false
}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 95e727792..71ac85829 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 83f9adb63fe0eae7ad2cd5175000678f05f6a5c646828e05e663b0a03d67f106
+plan14-root-reads-rootfs-apps-6.tsv b611b6ff7f86bc5b046a41d3d89ababf673ebd13e6e4c2593d7d2de4112729e1
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 c4277ddaa..bac884585 100644
--- a/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv
+++ b/internal/provision/testdata/plan14-root-reads-rootfs-apps-6.tsv
@@ -1,32 +1,43 @@
# 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.
-# 9 body, 0 sites, 7 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
-# 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 2 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+# 12 body, 0 sites, 7 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.
+# 3 new dispositions: 0 reads re-frozen at their disposition with the claim, 3 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
@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
@legacy 4cb19ff14f607602d752f0e329036d5c52eb64f4b1547b2116918b77cb5f4af1 internal/host/units/carlos-instance-probe.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=one more BindReadOnlyPaths= line, so PID 1 opens one more bind source: /run/carlos-control/exe/_probe/box-addrs, bound to /opt/carlos/box-addrs, root's list of the box's own addresses, which RunProbe writes before every run (#367) in the root-only directory the unit already binds from; no tenant, app or agent input names or writes it;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, so the probe proves what the tenants get (its new pts-private line); fix round 1 (Astra P2, roll order): one line outside the namespace block, Environment=CARLOS_PROBE_PTS_PRIVATE=1, a constant the unit sets for its own process (the probe, as carlos, in the namespace); it names no path, adds no bind source or Exec line, and root reads nothing new file:external@0 a803c8e83ffd95ceca691e0c47e623acfa50e88dcddd3166e6660473aa86695b
@legacy 455d36b55c3d97593df35538d23dbb6a698875cdc63451f11eb09da0507ac05d internal/host/units/carlos-instance-seed@.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 bfc1af41ba6317bdd8595b8f25869cc45835649966ca2ab89373f4ececd8fd73
@legacy eb66783c14afecf46fc2add7bddc9544847f396658626ce8139d7a028f5905cf internal/host/units/carlos-instance-sidecar@.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 aed2039fd622fc3fa8455d21d9da0e55cd73ddc02b399482d75d546e0b310a30
@legacy 1572962cee0ed81c0ec52934c14b5f762d0b6643047c8790ec85daa26db14d0a internal/host/units/carlos-instance@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: one namespace-block line added after TemporaryFileSystem=/dev/mqueue:ro, TemporaryFileSystem=/dev/pts:ro (with its comment): PID 1 mounts an empty read-only tmpfs over the private /dev/pts, hiding the host devpts PrivateDevices= binds in; no bind source, Exec line, user or path read by root added; the block stays byte-identical across the binary templates (TestInstanceTemplatesShareOneNamespace) file:external@0 9454117e9e93f85aded1e9ee9ef27d7a90c99e0e3b6ceecd4ea82eed9e30cf4c
+@legacy d5913b4d6e9d3d70124b1e8b93d78fd9f73ca34156b0486ab4dfc954f4e3386a internal/instancectl/rootfs.go Server.ensureRootfsExe legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root);basis=root-input (J2,J4, as ensureExeAs): new (rootfs Plan 2 Task 5): lays out <exe root>/<key>/rootfs/<role>/ under /run/carlos-control/exe, only root's: Mkdir then Lstat of each level (refusing a non-directory), the image link (replaceLink) to the path validateStagedImage checked, launch.json (root's resolved launch) and a copy of the resolver file; the ReadFile is of resolverFile (/run/systemd/resolve/resolv.conf when present, else /etc/resolv.conf), the box's own, as allowResolvers reads it; key is an instance ID, GenKey or WorkerKey root built from a validated host, refused with a slash, a NUL, . or ..; no tenant file is read;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: the role check admits both one-shot roles (OneShot: cmd and tty), so a rootfs session's layout is <exe root>/<iid>/rootfs/tty/ beside the cmd one, under the same root-only /run/carlos-control/exe tree, with the same Mkdir/Lstat walk, image link to the path validateStagedImage checked, root's launch.json and the resolver copy; the same two read sites, no read added file:Lstat@672,file:ReadFile@1101 0370a51b81e8db23cee7e6d8a2e077f594dbcc22d8c39d13306462436399e96a
+@legacy c58d727fea7703fd5c98852092554189b1ea306bd6112c14419e59e317d135bc internal/instancectl/rootfs.go resolveRootfsLaunch legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root);basis=root-input (J2,J4, as parseRequest): new (rootfs Plan 2 Task 5): the command half of validateStagedImage, over the manifest root read itself (release.ReadStagedManifest beside the validated image): the scanner matches the word Command, here release.Process's argv field, not os/exec; it reads no file; the agent names only the process (web, a worker, a declared cmd process) or, for carlos run, an argv that runs inside the tenant's own namespace where web runs; the argv, env and working dir of a declared process are the manifest's, jit is the manifest's alone; an undeclared process is refused (RFS-2-C08);rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6 (PF-7): RoleTTY takes RoleCmd's rule in the same arm: a declared process other than web, with that process's own argv, env and working_dir from the root-staged manifest (console for carlos console), or an argv body that runs with web's env and working_dir (launch Process "cmd"); both or neither refused, web refused, an undeclared process refused (RFS-2-C08); refusal texts name the role; it still reads no file, the same three sites file:Command@1150,file:Command@898,file:Command@917 daa946a55b5aab7e1e6975ca9cefad4f43609d907ff7a582b5b97472c8c6b694
+@legacy b0ea1213fde7acb0806656b98b98e0dce986761c1e2a1ba3346860dbe0a0a393 internal/instancectl/server.go type Server 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 292, with no further change from this branch. Census ruling 292 reclassified this declaration accepted-legacy (J2,J4) for root's per-host ordering of legacy run starts against stops; this ruling kept the row as main classed it. Its own addition is the cmd start's poll and wait bounds and its per-host lock map: field declarations only;rev3=census-ruling-rootfs-apps-2;basis=new fields: HostRuntime, ProbeImage, ProbeImageFile, RootfsProbeOut, DenyEvery, the deny's lastDeny and denyMu, the rootfs probe's report and lock, the jit reload counters and imageDigests; genStarting counts binary generation starts per unit; rootfsLocksMu and rootfsLocks, one lock entry per rootfs unit name being started or removed right now, held by a start from its layout through systemctl start and its own cleanup and by a removal from its proof through the raw removal, a removal refusing while it is taken, a waiting start giving up when its request ends, an entry dropped with its last holder or waiter (fixes E6, L2, L3); rootfsProvenHook, a test hook run between the proof and the raw removal; field declarations only; no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 and #329 plan 3 Task 5: the declaration gains sliceLocks (one mutex per host slice, taken by /size and /parent) and Egress (the asserter every start path calls), and its comment names the egress allow (plan 3's ControlDropInDir field was deleted in ef38e13b, the P1 EROFS fix); the same one site, the Statfs field, offset moved; no read added.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: comments only: the one-shot pacing fields cover /cmd and /tty, and cmdLocks is now keyed by (role, host) (oneShotKey, PF-7) so a session's start never waits behind a command's; field declarations unchanged; the same one site, no read added file:Statfs@3571 9e629bd7a24ef519c007f0bfd5188b0d52d08801a25ba70105275cc06377703f
@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 a51e04d46da95100335449f3aeeb490bf419c089a5924e26288ccfe192257535 internal/host/units/carlos-instance-rootfs-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the rootfs tty template, carlos-instance-rootfs-cmd@.service outside named lines held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit --rootfs tty %I, StandardInput=file:/run/carlos/logs/%I.tty.sock with StandardOutput/StandardError=journal, and RootImage plus the two BindReadOnlyPaths sources under /run/carlos-control/exe/%I/rootfs/tty/ (root-only exe layout) instead of rootfs/cmd/. The rootfs namespace block byte for byte (TestRootfsTemplatesShareOneNamespace), runs as carlos, binds only the instance own and root paths (TestRootfsTemplatesBindOnlyTheInstancesOwnAndRoots). Nothing starts it yet (Task 6) file:external@0 d57f6d6fbe553e5ba5a5762ab2bd72586835ce1db748b67044edd1bf90af6953
-@legacy dc75d2ec43e68117fd04c29c2c90eb33b8eaa4cc3b4aa7531e423eb1c2d012ac internal/host/units/carlos-instance-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the binary tty template, carlos-instance-cmd@.service outside six named lines held by TestTTYTemplateEqualsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit tty %I (the same root binary as every template), StandardInput=file:/run/carlos/logs/%I.tty.sock replacing the cmd StandardOutput socket (PID 1 opens it as root on the nosymfollow logs mount, as the cmd streams), StandardOutput=journal, StandardError=journal, and BindReadOnlyPaths sources tty-app/tty-live under /run/carlos-control/exe/%I (root-only exe layout, as cmd-app/cmd-live). Same namespace block byte for byte, runs as carlos. Nothing starts it yet (Task 6 adds POST /tty) file:external@0 060295d0956afad52db77dba1988c508cf4289f9b5a18242a206a315145b8e0d
+@legacy 14cec7be2873b15f373f40e319f5c6c61d441f521121499f2a04b331bd3453f3 internal/host/units/carlos-instance-rootfs-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the rootfs tty template, carlos-instance-rootfs-cmd@.service outside named lines held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit --rootfs tty %I, StandardInput=file:/run/carlos/logs/%I.tty.sock with StandardOutput/StandardError=journal, and RootImage plus the two BindReadOnlyPaths sources under /run/carlos-control/exe/%I/rootfs/tty/ (root-only exe layout) instead of rootfs/cmd/. The rootfs namespace block byte for byte (TestRootfsTemplatesShareOneNamespace), runs as carlos, binds only the instance own and root paths (TestRootfsTemplatesBindOnlyTheInstancesOwnAndRoots). Task 6: POST /tty runtime=rootfs (startRootfsCmd with RoleTTY) starts it through Plan 2's rootfs one-shot path (preflight, validateStagedImage, ensureRootfsExe under rootfs/tty/, jit drop-in and owed reload, post-start MemoryDenyWriteExecute check); its files go only through removeRootfsUnitFiles (stopRootfs and cleanCmdExe with RoleTTY, the sweep) file:external@0 d57f6d6fbe553e5ba5a5762ab2bd72586835ce1db748b67044edd1bf90af6953
+@legacy b18625dfcfcaa6d4e0ae128e2b77ad7fb53d0a4206458b43ef4125d248e6ef58 internal/host/units/carlos-instance-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the binary tty template, carlos-instance-cmd@.service outside six named lines held by TestTTYTemplateEqualsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit tty %I (the same root binary as every template), StandardInput=file:/run/carlos/logs/%I.tty.sock replacing the cmd StandardOutput socket (PID 1 opens it as root on the nosymfollow logs mount, as the cmd streams), StandardOutput=journal, StandardError=journal, and BindReadOnlyPaths sources tty-app/tty-live under /run/carlos-control/exe/%I (root-only exe layout, as cmd-app/cmd-live). Same namespace block byte for byte, runs as carlos. Task 6: POST /tty (handleOneShot(RoleTTY), claimAwareLegacy) starts it, after the role lock, the loaded-state refusal and refuseStagedExe; the tty-app/tty-live sources are laid out by ensureCmdExeAt(RoleTTY) and removed by removeCmdExe(RoleTTY) at /stop role=tty and /sweep file:external@0 060295d0956afad52db77dba1988c508cf4289f9b5a18242a206a315145b8e0d
+@legacy 9491fe16a762f2bfb2e6b288428f67b157b813d01c226917ec4c3366ebffb305 internal/instancectl/cmd.go Server.oneShotStatus legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: handleCmdStatus's body moved whole and made role-aware (it serves GET /cmd/{host} and GET /tty/{host} through handleOneShotStatus(role), both claimAwareLegacy): the same three file:Query sites (the URL query read for the invocation, for parseQuery and for the role check); the role check now refuses any role field but the route's own (role=tty on /cmd and role=cmd on /tty are 400, before any show); the unit shown is UnitName(role, host) or RootfsUnitName(role, host) for runtime=rootfs, a name root builds from a validated host and a route constant; read-only systemctl show, starts and stops nothing; no file read added file:Query@1090,file:Query@384,file:Query@759 9ea847d9a1e6b0e0929f27b27a9ade5c783c0de1ba0d997523c939be8293e701
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
internal/host/units/carlos-instance-probe.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=one more BindReadOnlyPaths= line, so PID 1 opens one more bind source: /run/carlos-control/exe/_probe/box-addrs, bound to /opt/carlos/box-addrs, root's list of the box's own addresses, which RunProbe writes before every run (#367) in the root-only directory the unit already binds from; no tenant, app or agent input names or writes it;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, so the probe proves what the tenants get (its new pts-private line); fix round 1 (Astra P2, roll order): one line outside the namespace block, Environment=CARLOS_PROBE_PTS_PRIVATE=1, a constant the unit sets for its own process (the probe, as carlos, in the namespace); it names no path, adds no bind source or Exec line, and root reads nothing new file:external@0 a803c8e83ffd95ceca691e0c47e623acfa50e88dcddd3166e6660473aa86695b
internal/host/units/carlos-instance-seed@.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 bfc1af41ba6317bdd8595b8f25869cc45835649966ca2ab89373f4ececd8fd73
internal/host/units/carlos-instance-sidecar@.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 aed2039fd622fc3fa8455d21d9da0e55cd73ddc02b399482d75d546e0b310a30
internal/host/units/carlos-instance@.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5: one namespace-block line added after TemporaryFileSystem=/dev/mqueue:ro, TemporaryFileSystem=/dev/pts:ro (with its comment): PID 1 mounts an empty read-only tmpfs over the private /dev/pts, hiding the host devpts PrivateDevices= binds in; no bind source, Exec line, user or path read by root added; the block stays byte-identical across the binary templates (TestInstanceTemplatesShareOneNamespace) file:external@0 9454117e9e93f85aded1e9ee9ef27d7a90c99e0e3b6ceecd4ea82eed9e30cf4c
+internal/instancectl/rootfs.go Server.ensureRootfsExe legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root);basis=root-input (J2,J4, as ensureExeAs): new (rootfs Plan 2 Task 5): lays out <exe root>/<key>/rootfs/<role>/ under /run/carlos-control/exe, only root's: Mkdir then Lstat of each level (refusing a non-directory), the image link (replaceLink) to the path validateStagedImage checked, launch.json (root's resolved launch) and a copy of the resolver file; the ReadFile is of resolverFile (/run/systemd/resolve/resolv.conf when present, else /etc/resolv.conf), the box's own, as allowResolvers reads it; key is an instance ID, GenKey or WorkerKey root built from a validated host, refused with a slash, a NUL, . or ..; no tenant file is read;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: the role check admits both one-shot roles (OneShot: cmd and tty), so a rootfs session's layout is <exe root>/<iid>/rootfs/tty/ beside the cmd one, under the same root-only /run/carlos-control/exe tree, with the same Mkdir/Lstat walk, image link to the path validateStagedImage checked, root's launch.json and the resolver copy; the same two read sites, no read added file:Lstat@672,file:ReadFile@1101 0370a51b81e8db23cee7e6d8a2e077f594dbcc22d8c39d13306462436399e96a
+internal/instancectl/rootfs.go resolveRootfsLaunch legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-2;identity=instance control (/opt/carlos/carlos instance-control, carlos-instance-control.service, root);basis=root-input (J2,J4, as parseRequest): new (rootfs Plan 2 Task 5): the command half of validateStagedImage, over the manifest root read itself (release.ReadStagedManifest beside the validated image): the scanner matches the word Command, here release.Process's argv field, not os/exec; it reads no file; the agent names only the process (web, a worker, a declared cmd process) or, for carlos run, an argv that runs inside the tenant's own namespace where web runs; the argv, env and working dir of a declared process are the manifest's, jit is the manifest's alone; an undeclared process is refused (RFS-2-C08);rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6 (PF-7): RoleTTY takes RoleCmd's rule in the same arm: a declared process other than web, with that process's own argv, env and working_dir from the root-staged manifest (console for carlos console), or an argv body that runs with web's env and working_dir (launch Process "cmd"); both or neither refused, web refused, an undeclared process refused (RFS-2-C08); refusal texts name the role; it still reads no file, the same three sites file:Command@1150,file:Command@898,file:Command@917 daa946a55b5aab7e1e6975ca9cefad4f43609d907ff7a582b5b97472c8c6b694
+internal/instancectl/server.go type Server 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 292, with no further change from this branch. Census ruling 292 reclassified this declaration accepted-legacy (J2,J4) for root's per-host ordering of legacy run starts against stops; this ruling kept the row as main classed it. Its own addition is the cmd start's poll and wait bounds and its per-host lock map: field declarations only;rev3=census-ruling-rootfs-apps-2;basis=new fields: HostRuntime, ProbeImage, ProbeImageFile, RootfsProbeOut, DenyEvery, the deny's lastDeny and denyMu, the rootfs probe's report and lock, the jit reload counters and imageDigests; genStarting counts binary generation starts per unit; rootfsLocksMu and rootfsLocks, one lock entry per rootfs unit name being started or removed right now, held by a start from its layout through systemctl start and its own cleanup and by a removal from its proof through the raw removal, a removal refusing while it is taken, a waiting start giving up when its request ends, an entry dropped with its last holder or waiter (fixes E6, L2, L3); rootfsProvenHook, a test hook run between the proof and the raw removal; field declarations only; no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 and #329 plan 3 Task 5: the declaration gains sliceLocks (one mutex per host slice, taken by /size and /parent) and Egress (the asserter every start path calls), and its comment names the egress allow (plan 3's ControlDropInDir field was deleted in ef38e13b, the P1 EROFS fix); the same one site, the Statfs field, offset moved; no read added.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: comments only: the one-shot pacing fields cover /cmd and /tty, and cmdLocks is now keyed by (role, host) (oneShotKey, PF-7) so a session's start never waits behind a command's; field declarations unchanged; the same one site, no read added file:Statfs@3571 9e629bd7a24ef519c007f0bfd5188b0d52d08801a25ba70105275cc06377703f
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/host/units/carlos-instance-rootfs-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the rootfs tty template, carlos-instance-rootfs-cmd@.service outside named lines held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit --rootfs tty %I, StandardInput=file:/run/carlos/logs/%I.tty.sock with StandardOutput/StandardError=journal, and RootImage plus the two BindReadOnlyPaths sources under /run/carlos-control/exe/%I/rootfs/tty/ (root-only exe layout) instead of rootfs/cmd/. The rootfs namespace block byte for byte (TestRootfsTemplatesShareOneNamespace), runs as carlos, binds only the instance own and root paths (TestRootfsTemplatesBindOnlyTheInstancesOwnAndRoots). Nothing starts it yet (Task 6) file:external@0 d57f6d6fbe553e5ba5a5762ab2bd72586835ce1db748b67044edd1bf90af6953
-internal/host/units/carlos-instance-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the binary tty template, carlos-instance-cmd@.service outside six named lines held by TestTTYTemplateEqualsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit tty %I (the same root binary as every template), StandardInput=file:/run/carlos/logs/%I.tty.sock replacing the cmd StandardOutput socket (PID 1 opens it as root on the nosymfollow logs mount, as the cmd streams), StandardOutput=journal, StandardError=journal, and BindReadOnlyPaths sources tty-app/tty-live under /run/carlos-control/exe/%I (root-only exe layout, as cmd-app/cmd-live). Same namespace block byte for byte, runs as carlos. Nothing starts it yet (Task 6 adds POST /tty) file:external@0 060295d0956afad52db77dba1988c508cf4289f9b5a18242a206a315145b8e0d
+internal/host/units/carlos-instance-rootfs-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the rootfs tty template, carlos-instance-rootfs-cmd@.service outside named lines held by TestRootfsTTYTemplateEqualsRootfsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit --rootfs tty %I, StandardInput=file:/run/carlos/logs/%I.tty.sock with StandardOutput/StandardError=journal, and RootImage plus the two BindReadOnlyPaths sources under /run/carlos-control/exe/%I/rootfs/tty/ (root-only exe layout) instead of rootfs/cmd/. The rootfs namespace block byte for byte (TestRootfsTemplatesShareOneNamespace), runs as carlos, binds only the instance own and root paths (TestRootfsTemplatesBindOnlyTheInstancesOwnAndRoots). Task 6: POST /tty runtime=rootfs (startRootfsCmd with RoleTTY) starts it through Plan 2's rootfs one-shot path (preflight, validateStagedImage, ensureRootfsExe under rootfs/tty/, jit drop-in and owed reload, post-start MemoryDenyWriteExecute check); its files go only through removeRootfsUnitFiles (stopRootfs and cleanCmdExe with RoleTTY, the sweep) file:external@0 d57f6d6fbe553e5ba5a5762ab2bd72586835ce1db748b67044edd1bf90af6953
+internal/host/units/carlos-instance-tty@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 5, new: the binary tty template, carlos-instance-cmd@.service outside six named lines held by TestTTYTemplateEqualsCmdOutsideTheNamedLines: Description (tty), ExecStart/ExecStopPost instance-exec/instance-exit tty %I (the same root binary as every template), StandardInput=file:/run/carlos/logs/%I.tty.sock replacing the cmd StandardOutput socket (PID 1 opens it as root on the nosymfollow logs mount, as the cmd streams), StandardOutput=journal, StandardError=journal, and BindReadOnlyPaths sources tty-app/tty-live under /run/carlos-control/exe/%I (root-only exe layout, as cmd-app/cmd-live). Same namespace block byte for byte, runs as carlos. Task 6: POST /tty (handleOneShot(RoleTTY), claimAwareLegacy) starts it, after the role lock, the loaded-state refusal and refuseStagedExe; the tty-app/tty-live sources are laid out by ensureCmdExeAt(RoleTTY) and removed by removeCmdExe(RoleTTY) at /stop role=tty and /sweep file:external@0 060295d0956afad52db77dba1988c508cf4289f9b5a18242a206a315145b8e0d
+internal/instancectl/cmd.go Server.oneShotStatus legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: handleCmdStatus's body moved whole and made role-aware (it serves GET /cmd/{host} and GET /tty/{host} through handleOneShotStatus(role), both claimAwareLegacy): the same three file:Query sites (the URL query read for the invocation, for parseQuery and for the role check); the role check now refuses any role field but the route's own (role=tty on /cmd and role=cmd on /tty are 400, before any show); the unit shown is UnitName(role, host) or RootfsUnitName(role, host) for runtime=rootfs, a name root builds from a validated host and a route constant; read-only systemctl show, starts and stops nothing; no file read added file:Query@1090,file:Query@384,file:Query@759 9ea847d9a1e6b0e0929f27b27a9ade5c783c0de1ba0d997523c939be8293e701
+@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/appconfig cac8d8ef7538a456d034801c95ce6508a4983e5516b3bbbd302bec0fbafdd479
@coverage internal/host/units c3cc4f3b917fdb938f20d406b1704ec54e24553851c298e312056d397d10b0e1
-@coverage internal/instancectl d76867d3677604d151b617220b8cc201fc21998275d6660acff6e1baae3db203
+@coverage internal/instancectl ee755f7827ba8ab62cfe3d67c29a6ce9cc88c276ab995fb58a5fb5a36f18b51a
@coverage internal/instanceexec 16221b476a2d996eb5325ce97a683329639679144b4dcc136b2a018b7abdd9df
@coverage internal/layout 1527c3b31d87743798002b1ebefcd2cb0dc422a8642f72a3ff8dbefbd2c84d9b
@coverage internal/provision e1ecfdc3d169773ac6dd9dc09a6d0feea768ceb1b80195199c5ef74b2f0e6f5c