carlos / platform Public

gvisor demos: install pinned runtime and guard recovery

Install and verify the five-member runtime set atomically, enforce the executable awareness floor before staging and restore, and gate readiness on the recovery baseline.
Co-Authored-By: Astra (gpt-6-astra) via codex
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 51e4466c3ea675687f492a599d0bc79d1d83dda8 parent 0d12532
30 files changed, +1,819 −66
  • docs/superpowers/notes/census-proposal-gvisor-demos.md +41 −10
  • internal/execsandbox/file_linux.go +108 −0
  • internal/execsandbox/file_linux_test.go +134 −0
  • internal/execsandbox/file_other.go +12 −0
  • internal/execsandbox/protocol.go +112 −0
  • internal/execsandbox/protocol_test.go +120 −0
  • internal/execsandbox/verifier.go +69 −0
  • internal/host/bootstrap.go +2 −0
  • internal/host/claimstop_run.go +1 −0
  • internal/host/execsandboxfloor.go +135 −0
  • internal/host/execsandboxfloor_test.go +212 −0
  • internal/host/host_test.go +1 −0
  • internal/host/installchannel.go +5 −1
  • internal/host/runscensure.go +330 −0
  • internal/host/runscensure_test.go +289 −0
  • internal/host/runscset_linux.go +39 −0
  • internal/host/runscset_other.go +10 −0
  • internal/host/systemapply.go +65 −28
  • internal/host/systemapply_test.go +4 −3
  • internal/host/systemunits.go +5 −1
  • internal/host/units/carlos-instance-control.service +3 −1
  • internal/host/units/carlos-runsc.service +17 −0
  • internal/host/units/carlos-system-recover.service +1 −1
  • internal/instancectl/sandbox.go +14 −0
  • internal/instancectl/sandbox_test.go +20 −2
  • internal/instancectl/server.go +3 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv +58 −17
  • main.go +3 −0
  • system.go +5 −1

CI failed — run details

diff --git a/docs/superpowers/notes/census-proposal-gvisor-demos.md b/docs/superpowers/notes/census-proposal-gvisor-demos.md
index d54caa194..f655a3ead 100644
--- a/docs/superpowers/notes/census-proposal-gvisor-demos.md
+++ b/docs/superpowers/notes/census-proposal-gvisor-demos.md
@@ -1,23 +1,31 @@
# Census approval: gvisor-demos
-Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or rejects every change below, 7 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or rejects every change below, 22 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
| unit | change | read sites | what changed |
|---|---|---|---|
| `internal/host/agent.go` `runAgent` | body | unchanged (9) | Capture sandbox resolution and refusal once; log errors once; gate route admission and BeforeExec before process launch. No new root read. |
-| `internal/host/bootstrap.go` `bootstrapWithGroup` | body | unchanged (3) | Use the distinct claim/demo rendering marker, with historic state-directory recognition, for the 6b-N2 keep-installed decision; ordinary units are repaired on malformed host.env. Existing reads unchanged. |
-| `internal/host/claimstop_run.go` `RunInstanceControl` | body | unchanged (0) | Resolve sandbox once through shared Configure; select claim protocol independently of sandbox refusal and retain claim stop/recovery, activation and host-fence pass. Relax demo-plus-claims fatal only for ErrClaims. Keep egress asserter and install its restart-only refusal before claim recovery. No new root read. |
+| `internal/host/bootstrap.go` `bootstrapWithGroup` | body | unchanged (3) | Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. |
+| `internal/host/claimstop_run.go` `RunInstanceControl` | body | unchanged (0) | Retain Task 1 admission and claim separation; wire host-owned exact recovery baseline and pinned-set verification/retry callbacks. No new direct read. |
| `internal/host/claimunit.go` `claimUnitContent` | body | unchanged (1) | Mark only claim/demo renderings explicitly; common host.env remains loaded. Ordinary rendering masks CARLOS_HOST_CLAIM with UnsetEnvironment, removed only for a successfully parsed enabled claim rendering. Existing template read unchanged. |
-| `internal/host/systemapply.go` `systemApplier.installUnits` | body | unchanged (6) | Use claim/demo rendering evidence instead of the now-common EnvironmentFile line to preserve installed control on settings errors. Ordinary control stays flag-off and does not gain automatic restarts. Existing reads unchanged. |
-| `internal/host/systemunits.go` `ensureSystemUnitsWithGuard` | body | unchanged (5) | Use claim/demo rendering evidence for repair/restart selection and 6b-N2 preservation. Ordinary environment loading does not classify a box as claims-enabled. Existing reads unchanged. |
-| `internal/host/units/carlos-instance-control.service` `external` | body | unchanged (1) | Load root-owned host.env on every box for sandbox configuration; mask CARLOS_HOST_CLAIM in the default flag-off rendering. Only claim-enabled rendering removes that mask. No new agent-writable source or permission. |
+| `internal/host/systemapply.go` `systemApplier.Run` | body | unchanged (1) | Refuse malformed sandbox setting before staging cleanup or lock mutation. Existing root state reads unchanged. |
+| `internal/host/systemapply.go` `systemApplier.install` | body | unchanged (0) | Check staged and previous executable awareness before unit-plan execution. Existing reads unchanged; no unaware prev executes in gvisor mode. |
+| `internal/host/systemapply.go` `systemApplier.installUnits` | body | unchanged (6) | Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. |
+| `internal/host/systemapply.go` `systemApplier.restoreFiles` | body | unchanged (1) | Check prev awareness before quiesce/copy/restore and check the copied restore executable before rename. Existing stat unchanged. |
+| `internal/host/systemapply.go` `systemApplier.stagePlan` | body | unchanged (1) | Require sandbox awareness before clearing or creating staged unit plan and invoking bootstrap. No added direct read. |
+| `internal/host/systemunits.go` `ensureSystemUnitsWithGuard` | body | unchanged (5) | Create runtime/rootfs directories and repair installer plus three measured workload templates without arming them. Existing unit/host.env reads unchanged. |
+| `internal/host/units/carlos-instance-control.service` `external` | body | unchanged (1) | Add Wants/After installer and narrowly writable rootfs parent. Keep one host.env EnvironmentFile and other hardening. |
+| `internal/host/units/carlos-system-recover.service` `external` | body | unchanged (1) | Insert current-binary sandbox gate immediately before second-branch prev exec. Preserve guard branch and all other shell bytes. |
| `internal/instancectl/demo_policy.go` `Server.demoHandler` | body | unchanged (4) | Retain authenticated claim cleanup routes on demo-plus-claims sandbox refusal when a ClaimStop handler exists; sandbox admission still rejects claim launches, and claimAwareLegacy rejects legacy mutations. Existing registry reads unchanged. |
| `internal/instancectl/rootfs.go` `Server.runRootfsProbe` | body | unchanged (1) | Refuse sandbox configuration or readiness errors before preparing or starting the native rootfs probe. Existing image read unchanged. |
| `internal/instancectl/server.go` `Server.RunProbe` | body | unchanged (1) | Refuse sandbox configuration or readiness errors before fixture reads and native probe dispatch. Existing probe read unchanged. |
-| `internal/instancectl/server.go` `runWithClaim` | body | unchanged (4) | Require fixed sandbox settings from shared Configure; retain claim handler and legacy-route refusals; preserve egress asserter and revokes for invalid settings and gate only native restart dispatch. Native probe/build/start admission remains refused. Existing root reads unchanged. |
-| `internal/instancectl/server.go` `type Server` | body | unchanged (1) | Add fixed configured and effective sandbox modes, configuration error and runtime readiness callback. No new path or read. |
+| `internal/instancectl/server.go` `runWithClaim` | body | unchanged (4) | Retain sandbox modes and error; bind host-provided baseline and runtime callbacks without importing host templates. Existing reads unchanged. |
+| `internal/instancectl/server.go` `type Server` | body | unchanged (1) | Retain Task 1 mode/error/readiness fields; add baseline and runtime callbacks. No new direct read. |
+| `system.go` `runSystem` | body | unchanged (0) | Dispatch fixed runsc-ensure and exec-sandbox-allows-prev system applets; no direct reads. |
+| `system.go` `systemVerb` | body | unchanged (0) | Recognize two root sandbox applets; no direct reads. |
+| `internal/host/systemapply.go` `systemApplier.stageCandidate` | sites | -file:OpenFile | Read agent cache once into bounded buffer; signed hash and marker before clearing staging; write those exact bytes durably and check root-owned staged binary before version execution. Removes direct OpenFile site. Retain staging on floor refusal for both apply and install-channel callers; floor authority reopens root-owned host.env by default. |
-Envelopes re-pinned: `internal/execsandbox`, `internal/host`, `internal/host/units`, `internal/instancectl`, `internal/instanceexec`.
+Envelopes re-pinned: `.`, `internal/execsandbox`, `internal/host`, `internal/host/units`, `internal/instancectl`, `internal/instanceexec`.
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.
@@ -27,25 +35,48 @@ Recorded dispositions, which each change must still satisfy:
- `internal/host/bootstrap.go` `bootstrapWithGroup`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.
- `internal/host/claimstop_run.go` `RunInstanceControl`: authority, task C,D,G. Basis: rev3=PROPOSED-p3;run=24;identity=root claim/adopt/update controller uid 0;basis=production root startup builds authenticated execution and launch handlers then uses activateClaimRoot for recovery, the registered census launch verifier and lifecycle start;rev3=census-ruling-rootfs-apps-2;basis=the claims-off path serves through instancectl.RunWithRegistryView with HostRuntime: instanceRegistryHostRuntime beside the same instanceRegistryHostApp(nil); the new read is instanceRegistryHostRuntime's own (a decision row in rootfs-apps-2-new); no read added in this body;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 4 and 6: the claims-off branch hands RunWithRegistryView the pre-claim egress asserter (newEgressAsserter over registryEgressSource and registryEgressHosts, which read the agent-written registry read-only, beside the instanceRegistryHostApp read it already had); the claims branch builds its runtime resources in instanceControlClaimResources, adding the claims asserter (claimsEgressSource writes no allow; the registry is read only to name slices), and serves through runClaimControl, which passes RunWithClaim the same handler, held-release route and host lookup plus that asserter. No read site in the unit, none added.;rev3=census-ruling-agent-start-demo-1;basis=Wires demo registry views and existing root release/adoption guard into instance control.;rev3=census-ruling-region-ha-p3b;basis=Add root hairpin identity verification, dormant install and reset CLI entries with bounded contexts. Indirect inputs are root-owned marker/identity/ingress/state and kernel/systemd process evidence; no request-controlled addresses or executable path. Existing control-service path remains.
- `internal/host/claimunit.go` `claimUnitContent`: authority, task E1,E3. Basis: rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=adds write permission for exactly the public retry directory only when the root settings reader has verified a complete census and prepared that directory;rev3=census-ruling-agent-start-demo-1;basis=Demo-only ReadWritePaths for instance data/runtime, staged files and root release lock; ordinary rendering unchanged.;rev3=census-ruling-agent-start-demo-1-followups;basis=In demo box mode, declare StateDirectory=carlos-release/private with mode 0700 so systemd creates root-owned release state before namespace setup and keeps it writable. Existing ReadWritePaths and ordinary/claims rendering stay unchanged. No new read site or caller-controlled path.;rev3=census-ruling-agent-start-demo-3;basis=Declare /var/lib/carlos-demo-snapshots as root-owned StateDirectory with mode 0700 only for configured demo boxes, including recovery with admission off. Ordinary claims units retain their original directories. The shared unit template is unchanged from main; no file read is added.
+- `internal/host/systemapply.go` `systemApplier.Run`: authority, task D,F,J4. Basis: rev3=PROPOSED-claims-on-gate-recover;identity=root apply/recovery uid 0;basis=re-pinned at its class and task; its lock-file read is unchanged. A checkGuardRecovery error wrapping errSettlementDeferred under --recover is logged and not fatal, and the end-of-run settlement is not retried after a deferral; every other refusal returns as before. root-input;kept=D,F;scope=protected-decision-only. TestRecoverDefersACensusRefusalWithNoJournalOpen, TestApplyStillFailsACensusRefusalWithNoJournalOpen. Fix round 2: a deferral that recoverIfNeeded returns after the journal was removed is consumed the same way, with no fatal error kept and no settlement retried. TestRecoverDefersARefusalAfterTheJournalIsRemoved. Fix round 3: the end-of-run marker settlement (settleMarker, settleUpdateBegun) also goes through settleWithoutJournal, so a legacy update-begun marker with no update record and no journal defers a census refusal with the recover-legacy barrier held; a barrier that cannot be written joins the run's error in every mode; every other marker failure is logged as on main. TestRecoverHoldsAcquisitionsForALegacyMarker, TestRecoverFailsALegacyMarkerWhoseBarrierCannotBeWritten.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 15: the no-op test is split so the installed build (onDiskBuild, the same read as before) is read once; a hand-run apply then refuses a candidate below the rootfs floor v0.29.0 on a box already at or above it unless the override flag is passed; the agent's pointer path is unchanged; adds a refusal only;rev3=census-ruling-region-ha-p3b;basis=Under the apply lock require the root marker-bound maintenance permit before group staging cleanup/floor/recovery work, then bind candidate digest before staging. Marker /etc/carlos/group.json is root boot output; permit /run/carlos-group-maintenance/permit.json is operator-written through root, never the agent receipt. Direct read unchanged.;rev3=census-ruling-region-ha-p3b2;basis=Body split: lock acquisition stays in Run, the unchanged apply body moves to runLocked so group-maintenance apply/rollback run it under the command's already-held lock. Same reads and guard calls (requireGroupMaintenance check first under the lock).
+- `internal/host/systemapply.go` `systemApplier.install`: authority, task F,J4. Basis: rev3=PROPOSED-p3;identity=carlos system apply, root update unit or offline root CLI, uid 0;basis=root verifies staged signature and final locked bounds before rename, then records root accepted floor history only after health succeeds;rev3=census-ruling-region-ha-p1a;basis=root apply, uid 0: comment and error text only around the beginExecutableChange call (the wrapped error now reads "update not begun" instead of "update-begun marker"); the call, its position before the first box-changing step and the deferral on error are unchanged; no read added;rev3=census-ruling-region-ha-p3b;basis=Require groupTarget for the staged new artifact and propagate quiesce refusal before effects. Root-owned operator permit must authorize digest/action/current boot; existing signed image, floor and journal checks remain; no new direct read.
- `internal/host/systemapply.go` `systemApplier.installUnits`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.
+- `internal/host/systemapply.go` `systemApplier.restoreFiles`: authority, task F,J4. Basis: rev3=PROPOSED-p3;identity=carlos system apply/recover, root systemd units or offline root CLI, uid 0;basis=selects signed prev identity and checks staged restore against both root bounds before rename; version sidecar cannot authorize;rev3=census-ruling-region-ha-p3b;basis=Authorize exact previous artifact before restore, propagate quiesce refusal and remove automatic group units from enable list. Existing signature/floor and staged plan reads remain; indirect permit must be root-owned and bind old digest/current boot.
+- `internal/host/systemapply.go` `systemApplier.stagePlan`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupExecutable before staged bootstrap execution, matching the authorized old/new artifact through existing no-follow slot checks. New indirect marker/permit reads are root-protected; staged path still subject to existing release verification, direct read site unchanged.
- `internal/host/systemunits.go` `ensureSystemUnitsWithGuard`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move unit-repair body here with existing lock/unit/host.env reads; under lock require operator repair permit on groups before writes and each systemctl effect, preserve root masks/drop-in and omit automatic update/recovery units. New indirect protected marker/permit reads, never agent receipt; fixed repair unchanged.
- `internal/host/units/carlos-instance-control.service` `external`: authority, task B3,C,D,E1,J4. Basis: root-input;kept=B3,C,D,E1;scope=protected-decision-only;rev3=census-ruling-agent-start-demo-3;basis=Correct the runtime-write comment to include escaped demo snapshot .mount units alongside per-generation drop-ins; service directives are unchanged.;rev3=census-ruling-region-ha-graceful-terminate-t1;basis=Region HA T1/DR-4 final fix: retain After=nftables.service without Wants or Requires; add Restart=on-failure and RestartSec=1 so a crashed control restarts before a later edge stop can block socket activation and shutdown proofs; rewrap the header and explain this ordering. Same ExecStart and protections; no new root read, input, path, command or capability.
+- `internal/host/units/carlos-system-recover.service` `external`: authority, task F,J4. Basis: rev3=PROPOSED-p3;identity=systemd update/recover oneshot shell uid 0;basis=guard branch is conditional on executable presence; unarmed units retain main selector; installed guard selects from root local floor
- `internal/instancectl/demo_policy.go` `Server.demoHandler`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=R26: HostDemo and the demo start/purge lock run only in demo mode. Ordinary starts do not read HostDemo or gain its read-error refusal. Demo-mode missing/non-demo/held-row and read-error refusals remain.
- `internal/instancectl/rootfs.go` `Server.runRootfsProbe`: 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 Server.RunProbe): new (rootfs Plan 2 Task 7): builds the probe image once per service start, hashes it (fileSHA256), lays out the _probe rootfs exe layout and its box-addrs, starts carlos-instance-rootfs-probe.service and ReadFiles its report from /run/carlos-control/rootfs-probe.out, which PID 1 writes from the probe's stdout; the probe runs the platform binary from root's own probe image, no tenant code; the report only decides readiness, and without an ok root-image line it is never ready, whatever it says;rev3=census-ruling-agent-start-demo-1;basis=Reads DemoBox and refuses before preparing or launching a rootfs probe; ordinary probe behavior unchanged.
- `internal/instancectl/server.go` `Server.RunProbe`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J2,J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=after the resolver allow it applies the box-address deny (denyLocalAddrs: set-property IPAddressDeny on carlos-instances.slice from localPrefixes, which reads /proc/net/fib_trie and /proc/net/if_inet6 as LocalAddrs already did), writes the probe's box-addrs under its own exe layout (writeFileExcl, a decision row), and after the binary probe runs the rootfs probe (runRootfsProbe, a decision row); its own direct read, probe.out, is unchanged;rev3=census-ruling-region-ha-p3b;basis=Take shared root hairpin lease for the entire probe so deny refresh and hairpin mutation cannot race it. Indirect reads validate root boot snapshot, root state/fence and interface inventory; existing probe.out direct read remains and lock/config errors fail readiness.
- `internal/instancectl/server.go` `runWithClaim`: authority, task C,D,G. Basis: Claim instance controller adds held-release RPC dispatch within existing launch/participation execution boundary.;rev3=census-ruling-rootfs-apps-2;basis=takes a RegistryView (HostApp and HostRuntime) for the bare hostApp, and the production Server literal gains HostRuntime, ProbeImage: BuildProbeImage, ProbeImageFile: ProbeImagePath, RootfsProbeOut under /run/carlos-control and DenyEvery: 10s; this body reads nothing new itself; the readers it wires (instanceRegistryHostRuntime, BuildProbeImage, the rootfs probe's output) are decision rows;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 4 and #329 plan 3 Task 5: takes the egress asserter as a parameter, sets it on the production Server literal (Egress) and starts its 30 s Loop beside probeLoop and diskLoop; the literal also names the fixture check ProbeFixturesOK (renamed in plan 2 Task 14). It sets no control drop-in directory: plan 3's ControlDropInDir default (/run/systemd/system.control) was deleted with removeGenControlDropIn in ef38e13b (the P1 EROFS fix), so instance control names systemd's control directory only to read it (TrustedDropinReader). The same four sites (the two exec.CommandContext closures, statfsBytes, the data literal), offsets moved; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Wires root-owned demo config and existing fixed paths into the service.;rev3=census-ruling-region-ha-p3b;basis=Resume root-owned hairpin state before probes/control service work; verify current systemd agent identity and kernel fence/addresses, restore pidfd watch or revoke stale state. Same direct exec/statfs/data sites; indirect inputs are protected root snapshot/state and kernel evidence, never receipt data.;rev3=census-ruling-agent-start-demo-3;basis=Construct the demo snapshot supervisor for configured demo boxes; startup cleanup gates builder readiness. Census read-site delta: unchanged (4).
- `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.;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;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).
+- `system.go` `runSystem`: authority, task B,C,D,F,G,J4. Basis: rev3=census-ruling-self-serve-moves-1;identity=explicit operator CLI uid 0;basis=adds the lifetimes family to the system dispatch (carlos system lifetimes cutover, a console door call as the operator); every existing command branch unchanged;rev3=census-ruling-claims-cleanup-r2;basis=claims cleanup R2: drops the claims case (host.RunSystemClaims, deleted); every other branch unchanged; no read added;rev3=census-ruling-nearest-region-a;basis=adds the hosts-used family to the system dispatch (carlos system hosts-used status, one GET of a console door as the operator); every existing command branch unchanged; no read added;rev3=census-ruling-region-ha-p1a;basis=explicit operator CLI and root units, uid 0: drops the "join" case (host.RunSystemJoin, deleted with internal/host/joinroot.go, its only caller) and its line in the usage text; every other branch unchanged; no read added;rev3=census-ruling-named-unit-delivery-114;basis=the system verb dispatch gains named-units, routed to host.RunSystemNamedUnits; no read of its own;rev3=census-ruling-design-pdf-service;basis=add dispatch for carlos system pdf; no new reads;rev3=census-ruling-managed-fleets-2a;basis=Adds managed-fleets operator CLI dispatch; no direct read added; existing root command branches unchanged.;rev3=census-ruling-agent-start-demo-2;basis=system.go:62-66 adds the demos family dispatch to the console-only operator client (system_demos.go:19, system_demos_api.go:23); no direct read added and other root commands are unchanged.;rev3=census-ruling-region-ha-p3b2;basis=Dispatches carlos system group-maintenance {status|permit|revoke|prepare|apply|rollback} to internal/host; no read of its own.
+- `system.go` `systemVerb`: authority, task B,C,D,F,G,J4. Basis: rev3=census-ruling-self-serve-moves-1;identity=explicit operator CLI uid 0;basis=adds the lifetimes family to the system dispatch (carlos system lifetimes cutover, a console door call as the operator); every existing command branch unchanged;rev3=census-ruling-claims-cleanup-r2;basis=claims cleanup R2: drops "claims" from the verb list, so it now falls to the unknown-verb message; no read added;rev3=census-ruling-nearest-region-a;basis=adds "hosts-used" to the verb list, routed to runSystemHostsUsedVerb; no read added;rev3=census-ruling-region-ha-p1a;basis=explicit operator CLI and root units, uid 0: drops "join" from the verb list, so `carlos system join` now falls to the unknown-verb message; no read added;rev3=census-ruling-named-unit-delivery-114;basis=the known-verb list gains named-units; no read of its own;rev3=census-ruling-design-pdf-service;basis=add recognition for carlos system pdf; no new reads;rev3=census-ruling-managed-fleets-2a;basis=Recognizes managed-fleets as a CLI family; no read added.;rev3=census-ruling-agent-start-demo-2;basis=system.go:43-57 recognizes demos; parsing only, no direct read added.;rev3=census-ruling-region-ha-p3b2;basis=Recognizes group-maintenance as a system verb; parsing only.
+- `internal/host/systemapply.go` `systemApplier.stageCandidate`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupStageDigest before staging/candidate execution; action and new digest come from root-owned operator permit bound to boot marker. Existing signed pointer/artifact verification and two direct read sites remain.
New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+- new `internal/execsandbox/file_linux.go:checkRunscDir`: reads +file:Stat; written legacy, accepted-legacy, frozen
+- new `internal/execsandbox/file_linux.go:openCheckedDir`: reads +file:Open, +file:Openat, +file:Stat; written legacy, accepted-legacy, frozen
+- new `internal/execsandbox/file_linux.go:openCheckedFile`: reads +file:Openat, +file:Stat; written legacy, accepted-legacy, frozen
+- new `internal/execsandbox/protocol.go:ReadProtocol`: reads +file:Stat; written legacy, accepted-legacy, frozen
- new `internal/execsandbox/runsc.lock.json:external`: reads +file:external; written legacy, accepted-legacy, frozen
+- new `internal/execsandbox/verifier.go:RunscVerifier.verify`: reads +file:Stat ×2; written legacy, accepted-legacy, frozen
- new `internal/host/execsandbox.go:sandboxExecGate`: reads +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/host/execsandbox.go:sandboxRouteGate`: reads +registry:Runtime, +whole:Route ×2; written legacy, accepted-legacy, frozen
+- new `internal/host/execsandboxfloor.go:checkExecSandboxBaselineAt`: reads +file:Lstat ×2, +file:ReadFile; written legacy, accepted-legacy, frozen
+- new `internal/host/execsandboxfloor.go:sandboxHostEnvironment`: reads +file:ReadAll; written legacy, accepted-legacy, frozen
+- new `internal/host/execsandboxfloor.go:verifiedSandboxCandidate`: reads +file:ReadAll; written legacy, accepted-legacy, frozen
+- new `internal/host/runscensure.go:installRunscSet`: reads +file:Lstat, +file:Open; written legacy, accepted-legacy, frozen
+- new `internal/host/runscensure.go:pruneRunscSets`: reads +file:ReadDir; written legacy, accepted-legacy, frozen
+- new `internal/host/runscensure.go:runscCommandInventory`: reads +file:EvalSymlinks, +file:ReadAt, +file:Stat, +file:WalkDir; written legacy, accepted-legacy, frozen
+- new `internal/host/runscensure.go:runscSystemctl`: reads +file:CommandContext; written legacy, accepted-legacy, frozen
+- new `internal/host/runscensure.go:wireSandboxReadiness`: reads +file:ReadFile; written legacy, accepted-legacy, frozen
+- new `internal/host/runscset_linux.go:openRunscLock`: reads +file:Fstat, +file:Open; written legacy, accepted-legacy, frozen
- new `internal/host/units/carlos-demo-build-gvisor@.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
- new `internal/host/units/carlos-instance-gvisor-probe.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
- new `internal/host/units/carlos-instance-gvisor@.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
+- new `internal/host/units/carlos-runsc.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
- new `internal/instanceexec/sandbox_linux.go:gvisorProbeChecks`: reads +data-literal, +file:ReadFile; written legacy, accepted-legacy, frozen
-Seal: `b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c` → `8c254ae5f1dc65f4a15b894f366c74dda7a147956d198e0281c76957f5970565`.
+Seal: `b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c` → `7762153da75e4ae7e3cb58b5effabf08cb60589cc8beefc0d8a0f0f4aaf3056f`.
Overlay: `internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/execsandbox/file_linux.go b/internal/execsandbox/file_linux.go
new file mode 100644
index 000000000..3ee2c65f8
--- /dev/null
+++ b/internal/execsandbox/file_linux.go
@@ -0,0 +1,108 @@
+//go:build linux
+
+package execsandbox
+
+import (
+ "fmt"
+ "golang.org/x/sys/unix"
+ "os"
+ "path/filepath"
+ "strings"
+ "syscall"
+)
+
+// OpenRootFile validates every ancestor and the opened inode, without following links.
+func OpenRootFile(path string) (*os.File, error) { return openCheckedFile(path, 0, false) }
+func CheckRootDir(path string) error {
+ f, err := openCheckedDir(path, 0)
+ if err != nil {
+ return err
+ }
+ return f.Close()
+}
+
+func openCheckedDir(path string, owner uint32) (*os.File, error) {
+ if !filepath.IsAbs(path) || filepath.Clean(path) != path {
+ return nil, fmt.Errorf("unsafe directory: %s", path)
+ }
+ fd, err := unix.Open("/", unix.O_RDONLY|unix.O_DIRECTORY|unix.O_CLOEXEC, 0)
+ if err != nil {
+ return nil, err
+ }
+ f := os.NewFile(uintptr(fd), "/")
+ for _, part := range strings.Split(strings.TrimPrefix(path, "/"), "/") {
+ if part == "" {
+ continue
+ }
+ next, err := unix.Openat(int(f.Fd()), part, unix.O_RDONLY|unix.O_DIRECTORY|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0)
+ f.Close()
+ if err != nil {
+ return nil, fmt.Errorf("%s: %w", path, err)
+ }
+ f = os.NewFile(uintptr(next), part)
+ st, err := f.Stat()
+ if err != nil {
+ f.Close()
+ return nil, err
+ }
+ stat := st.Sys().(*syscall.Stat_t)
+ // Test fixtures can use their own uid, but root-owned ancestors remain required
+ // to be immutable to other users. Production always passes owner=0.
+ if stat.Uid != owner && stat.Uid != 0 || st.Mode().Perm()&0022 != 0 {
+ f.Close()
+ return nil, fmt.Errorf("unsafe directory: %s", path)
+ }
+ }
+ return f, nil
+}
+func openCheckedFile(path string, owner uint32, executable bool) (*os.File, error) {
+ if filepath.Clean(path) != path {
+ return nil, fmt.Errorf("unsafe file: %s", path)
+ }
+ dir, err := openCheckedDir(filepath.Dir(path), owner)
+ if err != nil {
+ return nil, err
+ }
+ defer dir.Close()
+ fd, err := unix.Openat(int(dir.Fd()), filepath.Base(path), unix.O_RDONLY|unix.O_NONBLOCK|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0)
+ if err != nil {
+ return nil, fmt.Errorf("%s: %w", path, err)
+ }
+ f := os.NewFile(uintptr(fd), path)
+ st, err := f.Stat()
+ if err == nil {
+ err = checkFileMetadata(st, owner, executable)
+ }
+ if err != nil {
+ f.Close()
+ return nil, fmt.Errorf("%s: %w", path, err)
+ }
+ return f, nil
+}
+func checkFileMetadata(st os.FileInfo, owner uint32, executable bool) error {
+ stat, ok := st.Sys().(*syscall.Stat_t)
+ if !ok || !st.Mode().IsRegular() || stat.Uid != owner || stat.Nlink != 1 || st.Mode()&0022 != 0 || st.Size() > BinaryLimit || st.Mode()&(os.ModeSetuid|os.ModeSetgid|os.ModeSticky) != 0 || executable && st.Mode().Perm() != 0755 {
+ return ErrRunsc
+ }
+ return nil
+}
+func fileIdentity(st os.FileInfo) identity {
+ stat := st.Sys().(*syscall.Stat_t)
+ return identity{dev: uint64(stat.Dev), ino: stat.Ino, size: st.Size(), mtime: st.ModTime().UnixNano(), ctime: stat.Ctim.Sec*1e9 + stat.Ctim.Nsec}
+}
+
+func checkRunscDir(path string) error {
+ f, err := openCheckedDir(path, 0)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ st, err := f.Stat()
+ if err != nil {
+ return err
+ }
+ if st.Mode().Perm() != 0755 {
+ return fmt.Errorf("%w: %s", ErrRunsc, path)
+ }
+ return nil
+}
diff --git a/internal/execsandbox/file_linux_test.go b/internal/execsandbox/file_linux_test.go
new file mode 100644
index 000000000..897f724eb
--- /dev/null
+++ b/internal/execsandbox/file_linux_test.go
@@ -0,0 +1,134 @@
+//go:build linux
+
+package execsandbox
+
+import (
+ "crypto/sha256"
+ "fmt"
+ "os"
+ "path/filepath"
+ "syscall"
+ "testing"
+ "time"
+)
+
+func TestRunscIdentityCache(t *testing.T) {
+ pin, _ := RunscFor("linux-amd64")
+ root := t.TempDir()
+ os.Mkdir(filepath.Join(root, "gvisor-bin"), 0755)
+ for i := range pin.Files {
+ m := &pin.Files[i]
+ b := []byte(m.Path)
+ m.SHA256 = fmt.Sprintf("%x", sha256.Sum256(b))
+ if m.Path == "runsc" {
+ pin.SHA256 = m.SHA256
+ }
+ os.WriteFile(filepath.Join(root, m.Path), b, 0755)
+ }
+ // Only this fixture opener substitutes the unprivileged test uid. Production
+ // Verify always checks root ownership and every ancestor without links.
+ open := func(path string) (*os.File, error) {
+ fd, err := syscall.Open(path, syscall.O_RDONLY|syscall.O_NOFOLLOW|syscall.O_NONBLOCK, 0)
+ if err != nil {
+ return nil, err
+ }
+ f := os.NewFile(uintptr(fd), path)
+ st, err := f.Stat()
+ if err == nil {
+ err = checkFileMetadata(st, uint32(os.Geteuid()), true)
+ }
+ if err != nil {
+ f.Close()
+ return nil, err
+ }
+ return f, nil
+ }
+ path := filepath.Join(root, "runsc")
+ v := new(RunscVerifier)
+ check := func(t *testing.T, want bool) {
+ t.Helper()
+ err := v.verify(path, pin, open)
+ if (err == nil) != want {
+ t.Fatalf("verify want=%v: %v", want, err)
+ }
+ }
+ check(t, true)
+ check(t, true)
+ for _, name := range []string{"mode", "links", "size", "mtime", "inode", "helper"} {
+ t.Run(name, func(t *testing.T) {
+ target := path
+ if name == "helper" {
+ target = filepath.Join(root, pin.Files[0].Path)
+ }
+ original, _ := os.ReadFile(target)
+ st, _ := os.Stat(target)
+ switch name {
+ case "mode":
+ os.Chmod(target, 0700)
+ case "links":
+ if err := os.Link(target, target+".link"); err != nil {
+ t.Fatal(err)
+ }
+ case "size":
+ os.WriteFile(target, []byte("oversized changed fixture"), 0755)
+ case "mtime":
+ os.WriteFile(target, []byte("wrong"), 0755)
+ os.Chtimes(target, time.Now(), time.Now().Add(time.Second))
+ case "inode":
+ if err := os.WriteFile(target+".new", []byte("wrong"), 0755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Rename(target+".new", target); err != nil {
+ t.Fatal(err)
+ }
+ case "helper":
+ os.WriteFile(target, []byte("wrong helper"), 0755)
+ }
+ check(t, false)
+ if name == "links" {
+ os.Remove(target + ".link")
+ }
+ os.WriteFile(target, original, 0755)
+ os.Chmod(target, 0755)
+ os.Chtimes(target, st.ModTime(), st.ModTime())
+ check(t, true)
+ })
+ }
+ id := identity{dev: 1, ino: 2, size: 3, mtime: 4}
+ changed := id
+ changed.dev++
+ if id == changed {
+ t.Fatal("device not part of identity")
+ }
+}
+func TestExecSandboxReadProtocolMetadata(t *testing.T) {
+ root := t.TempDir()
+ path := filepath.Join(root, "carlos")
+ os.WriteFile(path, ProtocolMarker, 0755)
+ if os.Geteuid() != 0 {
+ if _, err := ReadProtocol(path); err == nil {
+ t.Fatal("non-root file accepted")
+ }
+ }
+ st, _ := os.Stat(path)
+ if err := checkFileMetadata(st, uint32(os.Geteuid()+1), false); err == nil {
+ t.Fatal("wrong owner")
+ }
+ os.Link(path, path+".link")
+ st, _ = os.Stat(path)
+ if err := checkFileMetadata(st, uint32(os.Geteuid()), false); err == nil {
+ t.Fatal("hardlink")
+ }
+ os.Symlink(path, path+".symlink")
+ if _, err := ReadProtocol(path + ".symlink"); err == nil {
+ t.Fatal("symlink")
+ }
+ if _, err := ReadProtocol(root); err == nil {
+ t.Fatal("directory")
+ }
+ os.Symlink(root, root+"-link")
+ defer os.Remove(root + "-link")
+ if _, err := ReadProtocol(filepath.Join(root+"-link", "carlos")); err == nil {
+ t.Fatal("ancestor link")
+ }
+}
diff --git a/internal/execsandbox/file_other.go b/internal/execsandbox/file_other.go
new file mode 100644
index 000000000..1737bef28
--- /dev/null
+++ b/internal/execsandbox/file_other.go
@@ -0,0 +1,12 @@
+//go:build !linux
+
+package execsandbox
+
+import "os"
+
+func OpenRootFile(string) (*os.File, error) { return nil, ErrUnsupported }
+func CheckRootDir(string) error { return ErrUnsupported }
+func openCheckedFile(string, uint32, bool) (*os.File, error) { return nil, ErrUnsupported }
+func fileIdentity(os.FileInfo) identity { return identity{} }
+
+func checkRunscDir(string) error { return ErrUnsupported }
diff --git a/internal/execsandbox/protocol.go b/internal/execsandbox/protocol.go
new file mode 100644
index 000000000..2b1a859ba
--- /dev/null
+++ b/internal/execsandbox/protocol.go
@@ -0,0 +1,112 @@
+package execsandbox
+
+import (
+ "bytes"
+ "errors"
+ "io"
+)
+
+const Protocol = 1
+const BinaryLimit int64 = 96 << 20
+
+var ProtocolMarker = []byte("CARLOS-EXEC-SANDBOX-PROTOCOL:1\n")
+var protocolPrefix = append([]byte(nil), ProtocolMarker[:len(ProtocolMarker)-2]...)
+var ErrProtocol = errors.New("exec-sandbox protocol: malformed or duplicate marker")
+var ErrFloor = errors.New("exec-sandbox floor")
+
+// ScanProtocol consumes exactly size bytes, keeping prefix overlap across chunks.
+func ScanProtocol(r io.Reader, size int64) (int, error) {
+ if size < 0 || size > BinaryLimit {
+ return 0, ErrProtocol
+ }
+ buf := make([]byte, 64<<10)
+ tail := make([]byte, 0, len(protocolPrefix)-1)
+ found, reading, digits := false, false, false
+ value := 0
+ for left := size; left > 0; {
+ n := int64(len(buf))
+ if left < n {
+ n = left
+ }
+ if _, err := io.ReadFull(r, buf[:n]); err != nil {
+ return 0, err
+ }
+ left -= n
+ chunk := append(tail, buf[:n]...)
+ for i := 0; i < len(chunk); i++ {
+ if reading {
+ c := chunk[i]
+ if c == '\n' {
+ if !digits {
+ return 0, ErrProtocol
+ }
+ reading = false
+ } else if c >= '0' && c <= '9' {
+ d := int(c - '0')
+ if value > (int(^uint(0)>>1)-d)/10 {
+ return 0, ErrProtocol
+ }
+ value = value*10 + d
+ digits = true
+ } else {
+ return 0, ErrProtocol
+ }
+ continue
+ }
+ if chunk[i] != protocolPrefix[0] {
+ continue
+ }
+ remaining := chunk[i:]
+ if len(remaining) < len(protocolPrefix) {
+ if left > 0 && bytes.HasPrefix(protocolPrefix, remaining) {
+ tail = append(tail[:0], remaining...)
+ goto next
+ }
+ continue
+ }
+ if bytes.HasPrefix(remaining, protocolPrefix) {
+ if found {
+ return 0, ErrProtocol
+ }
+ found = true
+ reading = true
+ i += len(protocolPrefix) - 1
+ }
+ }
+ tail = tail[:0]
+ next:
+ }
+ if reading {
+ return 0, ErrProtocol
+ }
+ return value, nil
+}
+
+func ReadProtocol(path string) (int, error) {
+ f, err := openCheckedFile(path, 0, false)
+ if err != nil {
+ return 0, err
+ }
+ defer f.Close()
+ st, err := f.Stat()
+ if err != nil {
+ return 0, err
+ }
+ return ScanProtocol(f, st.Size())
+}
+func AllowsBinary(effective Effective, path string) error {
+ if effective == EffectiveSystemd {
+ return nil
+ }
+ if effective != EffectiveGVisor {
+ return ErrConfig
+ }
+ protocol, err := ReadProtocol(path)
+ if err != nil {
+ return err
+ }
+ if protocol < Protocol {
+ return ErrFloor
+ }
+ return nil
+}
diff --git a/internal/execsandbox/protocol_test.go b/internal/execsandbox/protocol_test.go
new file mode 100644
index 000000000..d595900d7
--- /dev/null
+++ b/internal/execsandbox/protocol_test.go
@@ -0,0 +1,120 @@
+package execsandbox
+
+import (
+ "bytes"
+ "io"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestExecSandboxProtocol(t *testing.T) {
+ if string(protocolPrefix) != "CARLOS-EXEC-SANDBOX-PROTOCOL:" {
+ t.Fatal("prefix")
+ }
+ for _, tc := range []struct {
+ name, text string
+ want int
+ bad bool
+ }{
+ {"absent", "unaware", 0, false}, {"aware", string(ProtocolMarker), 1, false},
+ {"future", string(protocolPrefix) + "123\n", 123, false},
+ {"empty", string(protocolPrefix) + "\n", 0, true}, {"negative", string(protocolPrefix) + "-1\n", 0, true},
+ {"overflow", string(protocolPrefix) + strings.Repeat("9", 40) + "\n", 0, true},
+ {"unterminated", string(protocolPrefix) + "1", 0, true},
+ {"duplicate", string(ProtocolMarker) + string(ProtocolMarker), 0, true},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ got, err := ScanProtocol(strings.NewReader(tc.text), int64(len(tc.text)))
+ if got != tc.want || (err != nil) != tc.bad {
+ t.Fatalf("got %d, %v", got, err)
+ }
+ })
+ }
+ for offset := 65500; offset < 65540; offset++ {
+ b := append(bytes.Repeat([]byte{'x'}, offset), ProtocolMarker...)
+ if got, err := ScanProtocol(bytes.NewReader(b), int64(len(b))); got != 1 || err != nil {
+ t.Fatalf("offset %d: %d %v", offset, got, err)
+ }
+ }
+ if _, err := ScanProtocol(strings.NewReader(""), 96<<20+1); err == nil {
+ t.Fatal("oversize")
+ }
+ if _, err := ScanProtocol(strings.NewReader("x"), 2); err == nil {
+ t.Fatal("short reader")
+ }
+}
+
+func TestExecSandboxProtocolReleaseBuild(t *testing.T) {
+ root := filepath.Join("..", "..")
+ err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
+ if err != nil {
+ return err
+ }
+ if d.IsDir() && (d.Name() == ".git" || strings.HasPrefix(d.Name(), ".") && path != root) {
+ return filepath.SkipDir
+ }
+ if d.IsDir() || !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") {
+ return nil
+ }
+ b, e := os.ReadFile(path)
+ if e != nil {
+ return e
+ }
+ count := bytes.Count(b, protocolPrefix)
+ want := 0
+ if filepath.Clean(path) == filepath.Join(root, "internal", "execsandbox", "protocol.go") {
+ want = 1
+ }
+ if count != want {
+ t.Errorf("%s: prefix count %d want %d", path, count, want)
+ }
+ return nil
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if testing.Short() {
+ t.Skip("release builds skipped in short mode")
+ }
+ for _, arch := range []string{"arm64", "amd64"} {
+ t.Run(arch, func(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "carlos")
+ cmd := exec.Command("go", "build", "-ldflags", "-s -w", "-o", path, ".")
+ cmd.Dir = root
+ cmd.Env = append(os.Environ(), "GOOS=linux", "GOARCH="+arch, "CGO_ENABLED=0", "GOFLAGS=-buildvcs=false")
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("build: %v\n%s", err, out)
+ }
+ f, err := os.Open(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+ st, _ := f.Stat()
+ if got, err := ScanProtocol(f, st.Size()); got != 1 || err != nil {
+ t.Fatalf("protocol %d: %v", got, err)
+ }
+ })
+ }
+}
+func TestExecSandboxProtocolPreviousRelease(t *testing.T) {
+ path := os.Getenv("CARLOS_EXEC_SANDBOX_PREVIOUS_RELEASE")
+ if path == "" {
+ t.Skip("previous release not provided")
+ }
+ f, err := os.Open(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer f.Close()
+ st, err := f.Stat()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got, err := ScanProtocol(io.NewSectionReader(f, 0, st.Size()), st.Size()); got != 0 || err != nil {
+ t.Fatalf("previous: %d %v", got, err)
+ }
+}
diff --git a/internal/execsandbox/verifier.go b/internal/execsandbox/verifier.go
new file mode 100644
index 000000000..3ed342111
--- /dev/null
+++ b/internal/execsandbox/verifier.go
@@ -0,0 +1,69 @@
+package execsandbox
+
+import (
+ "crypto/sha256"
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+ "sync"
+)
+
+type identity struct {
+ dev, ino uint64
+ size, mtime, ctime int64
+}
+type verifiedIdentity struct {
+ identity identity
+ sha string
+}
+type RunscVerifier struct {
+ mu sync.Mutex
+ cache map[string]verifiedIdentity
+}
+
+func (v *RunscVerifier) Verify(path string, pin RunscPin) error {
+ for _, dir := range []string{filepath.Dir(filepath.Dir(path)), filepath.Dir(path), filepath.Join(filepath.Dir(path), "gvisor-bin")} {
+ if err := checkRunscDir(dir); err != nil {
+ return err
+ }
+ }
+ return v.verify(path, pin, func(path string) (*os.File, error) { return openCheckedFile(path, 0, true) })
+}
+func (v *RunscVerifier) verify(path string, pin RunscPin, open func(string) (*os.File, error)) error {
+ v.mu.Lock()
+ defer v.mu.Unlock()
+ if pin.SetID() == "" || filepath.Base(path) != "runsc" {
+ return ErrRunsc
+ }
+ if v.cache == nil {
+ v.cache = make(map[string]verifiedIdentity)
+ }
+ for _, member := range pin.Files {
+ p := filepath.Join(filepath.Dir(path), member.Path)
+ f, err := open(p)
+ if err != nil {
+ return fmt.Errorf("%w: %v", ErrRunsc, err)
+ }
+ st, err := f.Stat()
+ if err != nil {
+ f.Close()
+ return err
+ }
+ id := fileIdentity(st)
+ cached, ok := v.cache[p]
+ if !ok || cached.identity != id || cached.sha != member.SHA256 {
+ h := sha256.New()
+ n, err := io.Copy(h, io.LimitReader(f, BinaryLimit+1))
+ after, e := f.Stat()
+ if err != nil || e != nil || n != st.Size() || n > BinaryLimit || fileIdentity(after) != id || fmt.Sprintf("%x", h.Sum(nil)) != member.SHA256 {
+ f.Close()
+ delete(v.cache, p)
+ return fmt.Errorf("%w: %s", ErrRunsc, p)
+ }
+ v.cache[p] = verifiedIdentity{id, member.SHA256}
+ }
+ f.Close()
+ }
+ return nil
+}
diff --git a/internal/host/bootstrap.go b/internal/host/bootstrap.go
index 29b356222..f200a3331 100644
--- a/internal/host/bootstrap.go
+++ b/internal/host/bootstrap.go
@@ -452,6 +452,8 @@ func bootstrapWithGroup(root string, consumers []string, planJSON, group bool) e
mode os.FileMode
}
dirs := []dir{
+ {filepath.Join(root, "var/lib/carlos/oci-rootfs"), 0700},
+ {filepath.Join(root, "opt/carlos/runsc"), 0755},
{dataDir, 0o750},
{filepath.Join(dataDir, "acme"), 0o750},
// The relay's one writable state dir (carlos-relay.service's
diff --git a/internal/host/claimstop_run.go b/internal/host/claimstop_run.go
index 6441cd416..f8d06805c 100644
--- a/internal/host/claimstop_run.go
+++ b/internal/host/claimstop_run.go
@@ -48,6 +48,7 @@ func RunInstanceControl(args []string) {
}
configured, effective, sandboxErr := execSandboxConfig(os.Getenv)
sandbox := instancectl.SandboxSettings{Configured: configured, Effective: effective, Err: sandboxErr}
+ wireSandboxReadiness(&sandbox)
cfg, claimsEnabled, err := instancectl.ControlConfig(os.Getenv, sandbox)
if err != nil {
log.Fatal("instance-control: demo box configuration refused")
diff --git a/internal/host/execsandboxfloor.go b/internal/host/execsandboxfloor.go
new file mode 100644
index 000000000..8c8611bf7
--- /dev/null
+++ b/internal/host/execsandboxfloor.go
@@ -0,0 +1,135 @@
+package host
+
+import (
+ "bytes"
+ "crypto/sha256"
+ "errors"
+ "fmt"
+ "io"
+ "log"
+ "os"
+ "path/filepath"
+
+ "github.com/carlosframework/platform/internal/execsandbox"
+ "github.com/carlosframework/platform/internal/hostenv"
+)
+
+var errExecSandboxFloor = fmt.Errorf("%w: exec-sandbox floor", errSystemRefused)
+
+func sandboxHostEnvironment() (func(string) string, error) {
+ const path = "/etc/carlos/host.env"
+ f, err := execsandbox.OpenRootFile(path)
+ if errors.Is(err, os.ErrNotExist) {
+ return func(string) string { return "" }, nil
+ }
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+ raw, err := io.ReadAll(io.LimitReader(f, 1<<20+1))
+ if err != nil {
+ return nil, err
+ }
+ if len(raw) > 1<<20 {
+ return nil, execsandbox.ErrConfig
+ }
+ values, err := hostenv.Parse(raw)
+ if err != nil {
+ return nil, err
+ }
+ return func(key string) string { return values[key] }, nil
+}
+
+func RunSystemExecSandboxAllowsPrev(args []string) {
+ if len(args) != 1 || args[0] != "/opt/carlos/carlos.prev" {
+ log.Fatal(execsandbox.ErrConfig)
+ }
+ getenv, err := sandboxHostEnvironment()
+ if err != nil {
+ log.Fatal(err)
+ }
+ configured, err := execsandbox.Parse(getenv)
+ if err != nil {
+ log.Fatal(err)
+ }
+ if err := execsandbox.AllowsBinary(execsandbox.Resolve(configured, false), args[0]); err != nil {
+ log.Fatal(err)
+ }
+}
+
+func verifiedSandboxCandidate(src io.Reader, wantSHA string, effective execsandbox.Effective) ([]byte, error) {
+ raw, err := io.ReadAll(io.LimitReader(src, systemArtifactLimit+1))
+ if err != nil {
+ return nil, err
+ }
+ if int64(len(raw)) > systemArtifactLimit {
+ return nil, fmt.Errorf("candidate: larger than %d bytes", systemArtifactLimit)
+ }
+ if got := fmt.Sprintf("%x", sha256.Sum256(raw)); got != wantSHA {
+ return nil, fmt.Errorf("candidate: sha256 %s does not match the signed %s", got, wantSHA)
+ }
+ if effective == execsandbox.EffectiveSystemd {
+ return raw, nil
+ }
+ if effective != execsandbox.EffectiveGVisor {
+ return nil, execsandbox.ErrConfig
+ }
+ protocol, err := execsandbox.ScanProtocol(bytes.NewReader(raw), int64(len(raw)))
+ if err != nil || protocol < execsandbox.Protocol {
+ return nil, errExecSandboxFloor
+ }
+ return raw, nil
+}
+func (a *systemApplier) sandboxMode() (execsandbox.Effective, error) {
+ read := a.sandboxEnvironment
+ if read == nil {
+ read = sandboxHostEnvironment
+ }
+ getenv, err := read()
+ if err != nil {
+ return "", fmt.Errorf("%w: %v", errExecSandboxFloor, err)
+ }
+ configured, err := execsandbox.Parse(getenv)
+ if err != nil {
+ return "", fmt.Errorf("%w: %v", errExecSandboxFloor, err)
+ }
+ return execsandbox.Resolve(configured, false), nil
+}
+func (a *systemApplier) sandboxAllows(path string) error {
+ effective, err := a.sandboxMode()
+ if err != nil {
+ return err
+ }
+ if err := execsandbox.AllowsBinary(effective, path); err != nil {
+ return fmt.Errorf("%w: %v", errExecSandboxFloor, err)
+ }
+ return nil
+}
+
+func checkExecSandboxBaseline(optDir, unitDir string, recovery []byte) error {
+ return checkExecSandboxBaselineAt(optDir, unitDir, "/var/lib/carlos-claims/authority/exec/census.json", recovery)
+}
+func checkExecSandboxBaselineAt(optDir, unitDir, census string, recovery []byte) error {
+ for _, path := range []string{filepath.Join(optDir, "system/router/journal.json"), filepath.Join(optDir, "system/guard/carlos"), census, filepath.Join(optDir, "system/guard/moves")} {
+ if _, err := os.Lstat(path); !errors.Is(err, os.ErrNotExist) {
+ return fmt.Errorf("EXEC-SANDBOX-BASELINE: %s: present or unreadable", path)
+ }
+ }
+ path := filepath.Join(unitDir, systemRecoverUnit)
+ st, err := os.Lstat(path)
+ if err != nil || !st.Mode().IsRegular() {
+ return fmt.Errorf("EXEC-SANDBOX-BASELINE: %s", path)
+ }
+ raw, err := os.ReadFile(path)
+ if err != nil || !bytes.Equal(raw, recovery) {
+ return fmt.Errorf("EXEC-SANDBOX-BASELINE: %s", path)
+ }
+ return nil
+}
+
+func ensureSandboxDirectories(root, optDir string) error {
+ if err := bootstrapMakeDir(filepath.Join(root, "var/lib/carlos/oci-rootfs"), 0700); err != nil {
+ return err
+ }
+ return bootstrapMakeDir(filepath.Join(optDir, "runsc"), 0755)
+}
diff --git a/internal/host/execsandboxfloor_test.go b/internal/host/execsandboxfloor_test.go
new file mode 100644
index 000000000..7530d5561
--- /dev/null
+++ b/internal/host/execsandboxfloor_test.go
@@ -0,0 +1,212 @@
+package host
+
+import (
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "fmt"
+ "github.com/carlosframework/platform/internal/execsandbox"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestExecSandboxFloor(t *testing.T) {
+ for _, mode := range []execsandbox.Effective{execsandbox.EffectiveSystemd, execsandbox.EffectiveGVisor, "invalid"} {
+ for _, aware := range []bool{false, true} {
+ b := []byte("binary")
+ if aware {
+ b = append(b, execsandbox.ProtocolMarker...)
+ }
+ got, err := verifiedSandboxCandidate(bytes.NewReader(b), fmt.Sprintf("%x", sha256.Sum256(b)), mode)
+ allowed := mode == execsandbox.EffectiveSystemd || mode == execsandbox.EffectiveGVisor && aware
+ if (err == nil) != allowed {
+ t.Fatalf("%s aware=%v: %v", mode, aware, err)
+ }
+ if allowed && !bytes.Equal(got, b) {
+ t.Fatal("changed bytes")
+ }
+ if _, err := verifiedSandboxCandidate(bytes.NewReader(b), strings.Repeat("0", 64), mode); err == nil {
+ t.Fatal("bad hash accepted")
+ }
+ }
+ }
+}
+func TestExecSandboxBaselinePresence(t *testing.T) {
+ for _, name := range []string{"system/router/journal.json", "system/guard/carlos", "system/guard/moves", "census"} {
+ for _, kind := range []string{"file", "directory", "symlink", "dangling"} {
+ t.Run(name+"/"+kind, func(t *testing.T) {
+ root := t.TempDir()
+ opt := filepath.Join(root, "opt")
+ units := filepath.Join(root, "units")
+ census := filepath.Join(root, "census.json")
+ os.MkdirAll(units, 0755)
+ os.WriteFile(filepath.Join(units, systemRecoverUnit), []byte("exact"), 0644)
+ path := filepath.Join(opt, name)
+ if name == "census" {
+ path = census
+ }
+ os.MkdirAll(filepath.Dir(path), 0755)
+ switch kind {
+ case "file":
+ os.WriteFile(path, nil, 0600)
+ case "directory":
+ os.Mkdir(path, 0700)
+ case "symlink":
+ os.Symlink(units, path)
+ case "dangling":
+ os.Symlink(filepath.Join(root, "missing"), path)
+ }
+ err := checkExecSandboxBaselineAt(opt, units, census, []byte("exact"))
+ if err == nil || !strings.Contains(err.Error(), "EXEC-SANDBOX-BASELINE") || !strings.Contains(err.Error(), path) {
+ t.Fatalf("%v", err)
+ }
+ })
+ }
+ }
+ root := t.TempDir()
+ os.WriteFile(filepath.Join(root, systemRecoverUnit), []byte("exact"), 0644)
+ if err := checkExecSandboxBaselineAt(filepath.Join(root, "opt"), root, filepath.Join(root, "absent"), []byte("exact")); err != nil {
+ t.Fatal(err)
+ }
+ if err := checkExecSandboxBaselineAt(filepath.Join(root, "opt"), root, filepath.Join(root, "absent"), []byte("exacT")); err == nil {
+ t.Fatal("changed recovery accepted")
+ }
+}
+
+func TestExecSandboxFloorNoMutation(t *testing.T) {
+ for _, mode := range []string{"gvisor", "malformed"} {
+ t.Run(mode, func(t *testing.T) {
+ f := newApplyFixture(t, "stable", "v1")
+ f.a.sandboxEnvironment = func() (func(string) string, error) {
+ return func(k string) string {
+ if k == "CARLOS_EXEC_SANDBOX" {
+ return mode
+ }
+ return ""
+ }, nil
+ }
+ os.MkdirAll(f.a.stagingDir(), 0700)
+ sentinel := filepath.Join(f.a.stagingDir(), "keep")
+ os.WriteFile(sentinel, []byte("untouched"), 0600)
+ req := f.promote("v2", []byte("#!/bin/sh\necho carlos v2\n"), false)
+ p, err := f.a.verifyPointer(context.Background())
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, err = f.a.stageCandidate(context.Background(), p, req)
+ if err == nil {
+ t.Fatal("unaware accepted")
+ }
+ if b, _ := os.ReadFile(sentinel); string(b) != "untouched" {
+ t.Fatal("staging changed")
+ }
+ runErr := f.a.Run(context.Background(), false)
+ if mode == "gvisor" {
+ if runErr != nil {
+ t.Fatal(runErr)
+ }
+ r := f.result()
+ if r == nil || r.Reason != "refused: exec-sandbox floor" {
+ t.Fatalf("result %+v", r)
+ }
+ } else if runErr == nil {
+ t.Fatal("malformed setting allowed")
+ }
+ if b, _ := os.ReadFile(sentinel); string(b) != "untouched" {
+ t.Fatal("Run removed staging after refusal")
+ }
+ if _, err := os.Stat(f.a.file("journal.json")); !os.IsNotExist(err) {
+ t.Fatalf("journal mutated: %v", err)
+ }
+ before, _ := os.ReadFile(systemBinaryPath(f.a.optDir))
+ calls := len(f.calls)
+ if _, err := f.a.restoreFiles(context.Background(), &systemJournal{}); err == nil {
+ t.Fatal("restore allowed")
+ }
+ after, _ := os.ReadFile(systemBinaryPath(f.a.optDir))
+ if !bytes.Equal(before, after) || len(f.calls) != calls {
+ t.Fatal("restore mutated box")
+ }
+ })
+ }
+}
+
+func TestExecSandboxRecoveryUnit(t *testing.T) {
+ raw, err := unitsFS.ReadFile("units/" + systemRecoverUnit)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var command string
+ for _, line := range strings.Split(string(raw), "\n") {
+ if strings.HasPrefix(line, "ExecStart=") {
+ command = strings.TrimSuffix(strings.TrimPrefix(line, "ExecStart=/bin/sh -c '"), "'")
+ }
+ }
+ gate := " && /opt/carlos/carlos system exec-sandbox-allows-prev /opt/carlos/carlos.prev"
+ if strings.Count(command, gate) != 1 || strings.ContainsAny(command, "%$") {
+ t.Fatalf("bad recovery command %s", command)
+ }
+ // Preserve the old expression byte for byte except for the one gate.
+ original := `if [ -x /opt/carlos/system/guard/carlos ] && { [ -e /var/lib/carlos-claims/authority/exec/census.json ] || [ -L /var/lib/carlos-claims/authority/exec/census.json ] || [ -e /opt/carlos/system/guard/moves ] || [ -L /opt/carlos/system/guard/moves ]; }; then exec /opt/carlos/system/guard/carlos system guard-exec recover; fi; if [ -f /opt/carlos/system/router/journal.json ] && [ -x /opt/carlos/carlos.prev ] && [ ! -L /data/.moves/floor.min-release ] && { [ ! -e /data/.moves/floor.min-release ] || [ -f /data/.moves/floor.min-release ]; } && { ! [ -s /data/.moves/floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/floor.min-release /opt/carlos/carlos.prev.allowed; } && [ ! -L /data/.moves/seeds-floor.min-release ] && { [ ! -e /data/.moves/seeds-floor.min-release ] || [ -f /data/.moves/seeds-floor.min-release ]; } && { ! [ -s /data/.moves/seeds-floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/seeds-floor.min-release /opt/carlos/carlos.prev.seeds-allowed; }; then exec /opt/carlos/carlos.prev system apply --recover; fi; exec /opt/carlos/carlos system apply --recover`
+ if strings.Replace(command, gate, "", 1) != original {
+ t.Fatal("recovery changed outside gate")
+ }
+ for _, gateBody := range []string{"exit 1\n", "missing"} {
+ t.Run(gateBody, func(t *testing.T) {
+ root := t.TempDir()
+ current := filepath.Join(root, "current")
+ prev := filepath.Join(root, "prev")
+ receipt := filepath.Join(root, "receipt")
+ body := "#!/bin/sh\ncase \"$1 $2\" in\n'system exec-sandbox-allows-prev') " + gateBody + ";;\n*) echo current > '" + receipt + "';;\nesac\n"
+ os.WriteFile(current, []byte(body), 0755)
+ os.WriteFile(prev, []byte("#!/bin/sh\necho prev > '"+receipt+"'\n"), 0755)
+ // Execute the real expression with only fixed box paths relocated.
+ cmd := strings.ReplaceAll(command, "/opt/carlos/carlos.prev", prev)
+ cmd = strings.ReplaceAll(cmd, "/opt/carlos/carlos", current)
+ for _, p := range []string{"/opt/carlos/system/guard/carlos", "/var/lib/carlos-claims/authority/exec/census.json", "/opt/carlos/system/guard/moves", "/data/.moves/floor.min-release", "/data/.moves/seeds-floor.min-release"} {
+ cmd = strings.ReplaceAll(cmd, p, filepath.Join(root, "absent", filepath.Base(p)))
+ }
+ journal := filepath.Join(root, "journal")
+ os.WriteFile(journal, nil, 0600)
+ cmd = strings.ReplaceAll(cmd, "/opt/carlos/system/router/journal.json", journal)
+ if gateBody == "missing" {
+ cmd = strings.Replace(cmd, current+" system exec-sandbox-allows-prev", filepath.Join(root, "missing-gate")+" system exec-sandbox-allows-prev", 1)
+ }
+ if out, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput(); err != nil {
+ t.Fatalf("recovery: %v %s", err, out)
+ }
+ b, _ := os.ReadFile(receipt)
+ if string(b) != "current\n" {
+ t.Fatalf("recovery ran %q", b)
+ }
+ })
+ }
+}
+
+func TestExecSandboxInstallChannelFloor(t *testing.T) {
+ f := newChannelFixture(t, "v1.2.0")
+ f.a.sandboxEnvironment = func() (func(string) string, error) {
+ return func(k string) string {
+ if k == "CARLOS_EXEC_SANDBOX" {
+ return "gvisor"
+ }
+ return ""
+ }, nil
+ }
+ os.MkdirAll(f.a.stagingDir(), 0700)
+ sentinel := filepath.Join(f.a.stagingDir(), "keep")
+ os.WriteFile(sentinel, []byte("untouched"), 0600)
+ if _, err := f.in.install(context.Background()); err == nil || !strings.Contains(err.Error(), "exec-sandbox floor") {
+ t.Fatalf("install result: %v", err)
+ }
+ if b, _ := os.ReadFile(sentinel); string(b) != "untouched" {
+ t.Fatal("install-channel removed staging")
+ }
+ current, prev := f.slots(t)
+ if len(current) != 0 || len(prev) != 0 {
+ t.Fatal("install-channel populated executable slots")
+ }
+}
diff --git a/internal/host/host_test.go b/internal/host/host_test.go
index dfa263c87..4e09236fd 100644
--- a/internal/host/host_test.go
+++ b/internal/host/host_test.go
@@ -32,6 +32,7 @@ import (
// must be added here (and a removed one taken out) or TestUnitsEmbedComplete
// fails, so the embed directive and the fleet's unit set can't drift apart.
var expectedUnits = []string{
+ "carlos-runsc.service",
"carlos-adopt.path",
"carlos-adopt.service",
"carlos-adopt.timer",
diff --git a/internal/host/installchannel.go b/internal/host/installchannel.go
index 288317288..f8a34d87f 100644
--- a/internal/host/installchannel.go
+++ b/internal/host/installchannel.go
@@ -413,7 +413,11 @@ func (in channelInstall) install(ctx context.Context) (channelInstalled, error)
}
}
cache := systemCachePath(a.dataDir, p.Current.Version)
- defer os.RemoveAll(a.stagingDir())
+ defer func() {
+ if !a.sandboxRefused {
+ os.RemoveAll(a.stagingDir())
+ }
+ }()
if err := in.cacheDir(p.Current.Version); err != nil {
return got, err
}
diff --git a/internal/host/runscensure.go b/internal/host/runscensure.go
new file mode 100644
index 000000000..23a865279
--- /dev/null
+++ b/internal/host/runscensure.go
@@ -0,0 +1,330 @@
+package host
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "io/fs"
+ "log"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/carlosframework/platform/internal/execsandbox"
+ "github.com/carlosframework/platform/internal/instancectl"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+func RunSystemRunscEnsure(args []string) {
+ if len(args) != 0 {
+ log.Fatal(execsandbox.ErrConfig)
+ }
+ getenv, err := sandboxHostEnvironment()
+ if err != nil {
+ log.Fatal(err)
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 110*time.Second)
+ defer cancel()
+ if err := ensureRunsc(ctx, getenv, nil, runscSystemctl); err != nil {
+ log.Fatal(err)
+ }
+}
+func runscSystemctl(ctx context.Context, args ...string) (string, error) {
+ out, err := exec.CommandContext(ctx, "systemctl", args...).CombinedOutput()
+ return string(out), err
+}
+
+func ensureRunsc(ctx context.Context, getenv func(string) string, store release.Store, systemctl func(context.Context, ...string) (string, error)) error {
+ configured, err := execsandbox.Parse(getenv)
+ if err != nil {
+ return err
+ }
+ if execsandbox.Resolve(configured, false) == execsandbox.EffectiveSystemd {
+ return nil
+ }
+ platform := runtime.GOOS + "-" + runtime.GOARCH
+ pin, err := execsandbox.RunscFor(platform)
+ if err != nil {
+ return err
+ }
+ root := filepath.Dir(execsandbox.RunscDir(pin))
+ if err := execsandbox.CheckRootDir(root); err != nil {
+ return err
+ }
+ // The oneshot and any manual retry share one lock under the only writable root.
+ lock, err := openRunscLock(filepath.Join(root, ".install.lock"))
+ if err != nil {
+ return err
+ }
+ defer lock.Close()
+ if err := flockExclusiveNonblock(lock); err != nil {
+ return err
+ }
+ if err := os.Chmod(root, 0755); err != nil {
+ return err
+ }
+ verifier := new(execsandbox.RunscVerifier)
+ if verifier.Verify(execsandbox.RunscPath(pin), pin) != nil {
+ if store == nil {
+ store, err = openDeployStoreEnv(ctx, getenv)
+ if err != nil {
+ return err
+ }
+ }
+ if err := installRunscSet(ctx, root, platform, pin, store, execsandbox.CheckRootDir, verifier.Verify); err != nil {
+ return err
+ }
+ }
+ if systemctl == nil {
+ return nil
+ }
+ // Enumeration failures retain all old sets; installation is still usable.
+ if err := pruneRunscSets(ctx, root, pin.SetID(), func(ctx context.Context) ([]byte, error) { return runscCommandInventory(ctx, systemctl) }, execsandbox.CheckRootDir); err != nil {
+ log.Printf("runsc-ensure: retain old sets: %v", err)
+ }
+ return nil
+}
+
+func installRunscSet(ctx context.Context, root, platform string, pin execsandbox.RunscPin, store release.Store, checkDir func(string) error, verify func(string, execsandbox.RunscPin) error) error {
+ if pin.SetID() == "" {
+ return execsandbox.ErrRunsc
+ }
+ if err := checkDir(root); err != nil {
+ return err
+ }
+ if err := os.Chmod(root, 0755); err != nil {
+ return err
+ }
+ target := filepath.Join(root, pin.SetID())
+ if _, err := os.Lstat(target); err == nil {
+ if err := checkDir(target); err != nil {
+ return err
+ }
+ } else if !errors.Is(err, os.ErrNotExist) {
+ return err
+ }
+ temp, err := os.MkdirTemp(root, ".set-")
+ if err != nil {
+ return err
+ }
+ defer os.RemoveAll(temp)
+ if err := os.Chmod(temp, 0755); err != nil {
+ return err
+ }
+ helpers := filepath.Join(temp, "gvisor-bin")
+ if err := os.Mkdir(helpers, 0755); err != nil {
+ return err
+ }
+ if err := os.Chmod(helpers, 0755); err != nil {
+ return err
+ }
+ for _, member := range pin.Files {
+ key := execsandbox.RunscObjectKey(platform, pin, member.Path)
+ if key == "" {
+ return execsandbox.ErrRunsc
+ }
+ path := filepath.Join(temp, member.Path)
+ if err := release.FetchToFile(ctx, store, key, path, execsandbox.BinaryLimit, member.SHA256); err != nil {
+ return fmt.Errorf("%w: store %T key %s: %v", execsandbox.ErrRunsc, store, key, err)
+ }
+ if err := os.Chmod(path, 0755); err != nil {
+ return err
+ }
+ f, err := os.Open(path)
+ if err != nil {
+ return err
+ }
+ err = f.Sync()
+ f.Close()
+ if err != nil {
+ return err
+ }
+ }
+ if err := syncDir(helpers); err != nil {
+ return err
+ }
+ if err := syncDir(temp); err != nil {
+ return err
+ }
+ if err := verify(filepath.Join(temp, "runsc"), pin); err != nil {
+ return err
+ }
+ if err := replaceRunscSet(temp, target); err != nil {
+ return err
+ }
+ return syncDir(root)
+}
+
+// The inventory includes loaded units, queued jobs, installed templates and drop-ins.
+// Any unresolved path or command aborts collection and therefore prevents pruning.
+func runscCommandInventory(ctx context.Context, systemctl func(context.Context, ...string) (string, error)) ([]byte, error) {
+ names := map[string]bool{}
+ var inventory strings.Builder
+ for _, verb := range []string{"list-units", "list-jobs", "list-unit-files"} {
+ out, err := systemctl(ctx, verb, "--all", "--plain", "--no-legend", "--no-pager")
+ if err != nil {
+ return nil, err
+ }
+ inventory.WriteString(out)
+ for _, line := range strings.Split(out, "\n") {
+ fields := strings.Fields(line)
+ if len(fields) == 0 {
+ continue
+ }
+ index := 0
+ if verb == "list-jobs" {
+ index = 1
+ }
+ if len(fields) <= index || !strings.Contains(fields[index], ".") {
+ return nil, execsandbox.ErrRunsc
+ }
+ names[fields[index]] = true
+ }
+ }
+ for name := range names {
+ out, err := systemctl(ctx, "show", name, "--property=ExecStart,ExecStartPre,ExecStop,ExecStopPost,FragmentPath,DropInPaths,LoadState", "--no-pager")
+ if err != nil || strings.TrimSpace(out) == "" {
+ return nil, execsandbox.ErrRunsc
+ }
+ inventory.WriteString(out)
+ }
+ for _, root := range []string{"/etc/systemd/system", "/run/systemd/system", "/usr/lib/systemd/system"} {
+ err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
+ if errors.Is(err, os.ErrNotExist) && path == root {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+ if d.IsDir() {
+ return execsandbox.CheckRootDir(path)
+ }
+ // Links to /dev/null mask units. Other links must resolve to checked files.
+ if d.Type()&os.ModeSymlink != 0 {
+ target, e := filepath.EvalSymlinks(path)
+ if e != nil {
+ return e
+ }
+ if target == "/dev/null" {
+ return nil
+ }
+ path = target
+ }
+ f, err := execsandbox.OpenRootFile(path)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ st, err := f.Stat()
+ if err != nil || st.Size() > 1<<20 {
+ return execsandbox.ErrRunsc
+ }
+ b := make([]byte, st.Size())
+ if _, err := f.ReadAt(b, 0); err != nil && len(b) > 0 {
+ return err
+ }
+ inventory.Write(b)
+ return nil
+ })
+ if err != nil {
+ return nil, err
+ }
+ }
+ return []byte(inventory.String()), nil
+}
+func pruneRunscSets(ctx context.Context, root, current string, inventory func(context.Context) ([]byte, error), checkDir func(string) error) error {
+ commands, err := inventory(ctx)
+ if err != nil {
+ return err
+ }
+ entries, err := os.ReadDir(root)
+ if err != nil {
+ return err
+ }
+ for _, entry := range entries {
+ name := entry.Name()
+ if name == current || len(name) != 64 || strings.Trim(name, "0123456789abcdef") != "" {
+ continue
+ }
+ path := filepath.Join(root, name)
+ if strings.Contains(string(commands), path) {
+ continue
+ }
+ if err := checkDir(path); err != nil {
+ return err
+ }
+ if err := os.RemoveAll(path); err != nil {
+ return err
+ }
+ }
+ return syncDir(root)
+}
+
+type runscReadiness struct {
+ verifier execsandbox.RunscVerifier
+ mu sync.Mutex
+ next time.Time
+ delay time.Duration
+ running bool
+ systemctl func(context.Context, ...string) (string, error)
+}
+
+func (r *runscReadiness) check(ctx context.Context) error {
+ pin, err := execsandbox.RunscFor(runtime.GOOS + "-" + runtime.GOARCH)
+ if err != nil {
+ return err
+ }
+ if err := r.verifier.Verify(execsandbox.RunscPath(pin), pin); err == nil {
+ r.mu.Lock()
+ r.delay = 0
+ r.next = time.Time{}
+ r.mu.Unlock()
+ return nil
+ }
+ r.retry()
+ return execsandbox.ErrRunsc
+}
+func (r *runscReadiness) retry() {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ if r.running || time.Now().Before(r.next) {
+ return
+ }
+ r.running = true
+ if r.delay == 0 {
+ r.delay = 2 * time.Second
+ } else {
+ r.delay *= 2
+ if r.delay > 30*time.Second {
+ r.delay = 30 * time.Second
+ }
+ }
+ go func() {
+ ctx, cancel := context.WithTimeout(context.Background(), 125*time.Second)
+ defer cancel()
+ _, err := r.systemctl(ctx, "start", "carlos-runsc.service")
+ if err != nil {
+ log.Printf("runsc-ensure retry: %v", err)
+ }
+ r.mu.Lock()
+ r.running = false
+ r.next = time.Now().Add(r.delay)
+ r.mu.Unlock()
+ }()
+}
+
+func wireSandboxReadiness(settings *instancectl.SandboxSettings) {
+ recovery, err := unitsFS.ReadFile("units/" + systemRecoverUnit)
+ settings.Baseline = func() error {
+ if err != nil {
+ return err
+ }
+ return checkExecSandboxBaseline("/opt/carlos", "/etc/systemd/system", recovery)
+ }
+ readiness := &runscReadiness{systemctl: runscSystemctl}
+ settings.Runsc = readiness.check
+}
diff --git a/internal/host/runscensure_test.go b/internal/host/runscensure_test.go
new file mode 100644
index 000000000..c824c7dd9
--- /dev/null
+++ b/internal/host/runscensure_test.go
@@ -0,0 +1,289 @@
+package host
+
+import (
+ "context"
+ "crypto/sha256"
+ "fmt"
+ "github.com/carlosframework/platform/internal/execsandbox"
+ "github.com/carlosframework/platform/internal/release"
+ "io"
+ "os"
+ "path/filepath"
+ "slices"
+ "strings"
+ "testing"
+ "time"
+)
+
+func runscTestPin(t *testing.T) (execsandbox.RunscPin, map[string][]byte) {
+ t.Helper()
+ pin, err := execsandbox.RunscFor("linux-amd64")
+ if err != nil {
+ t.Fatal(err)
+ }
+ data := map[string][]byte{}
+ for i := range pin.Files {
+ f := &pin.Files[i]
+ data[f.Path] = []byte("test:" + f.Path)
+ f.SHA256 = fmt.Sprintf("%x", sha256.Sum256(data[f.Path]))
+ if f.Path == "runsc" {
+ pin.SHA256 = f.SHA256
+ }
+ }
+ return pin, data
+}
+func TestRunscEnsure(t *testing.T) {
+ if err := ensureRunsc(context.Background(), func(string) string { return "systemd" }, nil, nil); err != nil {
+ t.Fatal(err)
+ }
+ pin, data := runscTestPin(t)
+ for _, bad := range []bool{false, true} {
+ t.Run(fmt.Sprint(bad), func(t *testing.T) {
+ root := t.TempDir()
+ store := release.NewDirStore(t.TempDir())
+ for _, m := range pin.Files {
+ b := data[m.Path]
+ if bad && m.Path == "runsc" {
+ b = []byte("bad")
+ }
+ if _, err := store.Put(context.Background(), execsandbox.RunscObjectKey("linux-amd64", pin, m.Path), b, ""); err != nil {
+ t.Fatal(err)
+ }
+ }
+ err := installRunscSet(context.Background(), root, "linux-amd64", pin, store, func(string) error { return nil }, func(string, execsandbox.RunscPin) error { return nil })
+ if (err != nil) != bad {
+ t.Fatalf("%v", err)
+ }
+ entries, _ := os.ReadDir(root)
+ if bad && len(entries) != 0 {
+ t.Fatal("failed install left artifacts")
+ }
+ if !bad {
+ for _, m := range pin.Files {
+ p := filepath.Join(root, pin.SetID(), m.Path)
+ b, e := os.ReadFile(p)
+ st, _ := os.Stat(p)
+ if e != nil || string(b) != string(data[m.Path]) || st.Mode().Perm() != 0755 {
+ t.Fatalf("member %s: %v", p, e)
+ }
+ }
+ }
+ })
+ }
+}
+func TestRunscGarbageCollection(t *testing.T) {
+ for _, scenario := range []string{"free", "loaded", "job", "installed", "failure"} {
+ t.Run(scenario, func(t *testing.T) {
+ root := t.TempDir()
+ old := strings.Repeat("a", 64)
+ current := strings.Repeat("b", 64)
+ os.Mkdir(filepath.Join(root, old), 0755)
+ inventory := func(context.Context) ([]byte, error) {
+ switch scenario {
+ case "failure":
+ return nil, fmt.Errorf("enumeration failed")
+ case "free":
+ return nil, nil
+ default:
+ return []byte(filepath.Join(root, old, "runsc")), nil
+ }
+ }
+ if err := pruneRunscSets(context.Background(), root, current, inventory, func(string) error { return nil }); err != nil && scenario != "failure" {
+ t.Fatal(err)
+ }
+ _, err := os.Stat(filepath.Join(root, old))
+ if os.IsNotExist(err) != (scenario == "free") {
+ t.Fatalf("%s: %v", scenario, err)
+ }
+ })
+ }
+}
+
+type interruptedRunscStore struct{ release.Store }
+
+func (s interruptedRunscStore) Open(context.Context, string) (io.ReadCloser, string, error) {
+ return io.NopCloser(&interruptedRunscReader{}), "", nil
+}
+
+type interruptedRunscReader struct{ sent bool }
+
+func (r *interruptedRunscReader) Read(p []byte) (int, error) {
+ if r.sent {
+ return 0, io.ErrUnexpectedEOF
+ }
+ r.sent = true
+ return copy(p, "partial"), nil
+}
+
+func TestRunscEnsureRetryAndPinChange(t *testing.T) {
+ pin, data := runscTestPin(t)
+ root := t.TempDir()
+ if err := os.Chmod(root, 0755); err != nil {
+ t.Fatal(err)
+ }
+ store := release.NewDirStore(t.TempDir())
+ publish := func(pin execsandbox.RunscPin) {
+ for _, m := range pin.Files {
+ if _, err := store.Put(context.Background(), execsandbox.RunscObjectKey("linux-amd64", pin, m.Path), data[m.Path], ""); err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+ check := func(path string) error {
+ st, err := os.Lstat(path)
+ if err != nil {
+ return err
+ }
+ if !st.IsDir() || st.Mode().Perm()&0022 != 0 {
+ return fmt.Errorf("unsafe dir %s: %v", path, st.Mode())
+ }
+ return nil
+ }
+ verify := func(path string, pin execsandbox.RunscPin) error {
+ for _, m := range pin.Files {
+ b, err := os.ReadFile(filepath.Join(filepath.Dir(path), m.Path))
+ if err != nil || fmt.Sprintf("%x", sha256.Sum256(b)) != m.SHA256 {
+ return fmt.Errorf("bad member")
+ }
+ }
+ return nil
+ }
+ install := func(pin execsandbox.RunscPin, s release.Store) error {
+ return installRunscSet(context.Background(), root, "linux-amd64", pin, s, check, verify)
+ }
+ publish(pin)
+ if err := install(pin, interruptedRunscStore{store}); err == nil {
+ t.Fatal("interrupted transfer installed")
+ }
+ if entries, _ := os.ReadDir(root); len(entries) != 0 {
+ t.Fatal("partial temp retained")
+ }
+ if err := install(pin, store); err != nil {
+ t.Fatal(err)
+ }
+ target := filepath.Join(root, pin.SetID(), "runsc")
+ os.WriteFile(target, []byte("bad old member"), 0755)
+ if err := install(pin, interruptedRunscStore{store}); err == nil {
+ t.Fatal("interrupted replacement succeeded")
+ }
+ if b, _ := os.ReadFile(target); string(b) != "bad old member" {
+ t.Fatal("failed transfer altered installed set")
+ }
+ if err := install(pin, store); err != nil {
+ t.Fatal(err)
+ }
+ if err := verify(target, pin); err != nil {
+ t.Fatal(err)
+ }
+ for _, dir := range []string{root, filepath.Dir(target), filepath.Join(filepath.Dir(target), "gvisor-bin")} {
+ st, _ := os.Stat(dir)
+ if st.Mode().Perm() != 0755 {
+ t.Fatalf("directory mode %s %v", dir, st.Mode())
+ }
+ }
+ oldID := pin.SetID()
+ data["runsc"] = []byte("new runsc")
+ pin.Files = append([]execsandbox.RunscFile(nil), pin.Files...)
+ for i := range pin.Files {
+ if pin.Files[i].Path == "runsc" {
+ pin.Files[i].SHA256 = fmt.Sprintf("%x", sha256.Sum256(data["runsc"]))
+ pin.SHA256 = pin.Files[i].SHA256
+ }
+ }
+ publish(pin)
+ if err := install(pin, store); err != nil {
+ t.Fatal(err)
+ }
+ if oldID == pin.SetID() {
+ t.Fatal("pin not changed")
+ }
+ if _, err := os.Stat(filepath.Join(root, oldID, "runsc")); err != nil {
+ t.Fatal("old set removed before inventory")
+ }
+ if err := verify(filepath.Join(root, pin.SetID(), "runsc"), pin); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestRunscRetryBackoff(t *testing.T) {
+ started := make(chan struct{}, 1)
+ finish := make(chan struct{})
+ r := &runscReadiness{systemctl: func(context.Context, ...string) (string, error) { started <- struct{}{}; <-finish; return "", nil }}
+ for _, delay := range []time.Duration{2, 4, 8, 16, 30, 30} {
+ r.mu.Lock()
+ r.next = time.Time{}
+ r.mu.Unlock()
+ r.retry()
+ <-started
+ r.retry()
+ r.mu.Lock()
+ got := r.delay
+ active := r.running
+ r.mu.Unlock()
+ if got != delay*time.Second || !active {
+ t.Fatalf("delay %s active=%v", got, active)
+ }
+ finish <- struct{}{}
+ deadline := time.Now().Add(time.Second)
+ for {
+ r.mu.Lock()
+ running := r.running
+ r.mu.Unlock()
+ if !running {
+ break
+ }
+ if time.Now().After(deadline) {
+ t.Fatal("retry did not finish")
+ }
+ time.Sleep(time.Millisecond)
+ }
+ r.retry()
+ select {
+ case <-started:
+ t.Fatal("retried before backoff")
+ default:
+ }
+ }
+}
+
+func TestRunscUnitsAndDirectories(t *testing.T) {
+ raw, err := unitsFS.ReadFile("units/carlos-runsc.service")
+ if err != nil {
+ t.Fatal(err)
+ }
+ want := "[Unit]\nDescription=carlos pinned runsc installation\nBefore=carlos-instance-control.service\n[Service]\nType=oneshot\nUser=root\nGroup=root\nExecStart=/opt/carlos/carlos system runsc-ensure\nEnvironmentFile=-/etc/carlos/host.env\nTimeoutStartSec=120\nProtectSystem=strict\nReadWritePaths=/opt/carlos/runsc\nProtectHome=yes\nPrivateDevices=yes\nNoNewPrivileges=yes\nRestrictAddressFamilies=AF_UNIX AF_INET AF_INET6\nUMask=0077\n"
+ if string(raw) != want {
+ t.Fatal("installer unit differs from contract")
+ }
+ control, err := unitsFS.ReadFile("units/" + claimControlUnit)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, settings := range []claimUnitSettings{{}, {enabled: true, data: "/data", opt: "/opt/carlos"}} {
+ rendered := string(claimUnitContent(claimControlUnit, control, settings))
+ for _, line := range []string{"EnvironmentFile=-/etc/carlos/host.env\n", "Wants=carlos-runsc.service\n", "After=data-instances.mount run-carlos-instances.mount run-carlos-logs.mount carlos-runsc.service\n", "ReadWritePaths=/var/lib/carlos/oci-rootfs\n"} {
+ if strings.Count(rendered, line) != 1 {
+ t.Fatalf("control lacks exactly one %q", line)
+ }
+ }
+ }
+ root := t.TempDir()
+ opt := filepath.Join(root, "opt/carlos")
+ if err := ensureSandboxDirectories(root, opt); err != nil {
+ t.Fatal(err)
+ }
+ for path, mode := range map[string]os.FileMode{filepath.Join(root, "var/lib/carlos/oci-rootfs"): 0700, filepath.Join(opt, "runsc"): 0755} {
+ st, err := os.Lstat(path)
+ if err != nil || !st.IsDir() || st.Mode().Perm() != mode {
+ t.Fatalf("directory %s: %v", path, err)
+ }
+ }
+ for _, name := range []string{"carlos-runsc.service", "carlos-instance-gvisor@.service", "carlos-instance-gvisor-probe.service", "carlos-demo-build-gvisor@.service"} {
+ if !slices.Contains(systemUnitFiles, name) {
+ t.Fatalf("repair missing %s", name)
+ }
+ if slices.Contains(ensureSystemArmed, name) {
+ t.Fatalf("armed dormant unit %s", name)
+ }
+ }
+}
diff --git a/internal/host/runscset_linux.go b/internal/host/runscset_linux.go
new file mode 100644
index 000000000..bc6c1c340
--- /dev/null
+++ b/internal/host/runscset_linux.go
@@ -0,0 +1,39 @@
+//go:build linux
+
+package host
+
+import (
+ "errors"
+ "golang.org/x/sys/unix"
+ "os"
+)
+
+func replaceRunscSet(temp, target string) error {
+ err := unix.Renameat2(unix.AT_FDCWD, temp, unix.AT_FDCWD, target, unix.RENAME_NOREPLACE)
+ if !errors.Is(err, unix.EEXIST) {
+ return err
+ }
+ // Exchange replaces an invalid existing set atomically; temp now names the old set.
+ if err := unix.Renameat2(unix.AT_FDCWD, temp, unix.AT_FDCWD, target, unix.RENAME_EXCHANGE); err != nil {
+ return err
+ }
+ return os.RemoveAll(temp)
+}
+
+func openRunscLock(path string) (*os.File, error) {
+ fd, err := unix.Open(path, unix.O_CREAT|unix.O_RDWR|unix.O_NOFOLLOW|unix.O_NONBLOCK|unix.O_CLOEXEC, 0600)
+ if err != nil {
+ return nil, err
+ }
+ f := os.NewFile(uintptr(fd), path)
+ var st unix.Stat_t
+ if err := unix.Fstat(fd, &st); err != nil {
+ f.Close()
+ return nil, err
+ }
+ if st.Uid != 0 || st.Nlink != 1 || st.Mode&unix.S_IFMT != unix.S_IFREG || st.Mode&0077 != 0 {
+ f.Close()
+ return nil, unix.EPERM
+ }
+ return f, nil
+}
diff --git a/internal/host/runscset_other.go b/internal/host/runscset_other.go
new file mode 100644
index 000000000..436ede450
--- /dev/null
+++ b/internal/host/runscset_other.go
@@ -0,0 +1,10 @@
+//go:build !linux
+
+package host
+
+import "os"
+import "github.com/carlosframework/platform/internal/execsandbox"
+
+func replaceRunscSet(string, string) error { return execsandbox.ErrUnsupported }
+
+func openRunscLock(string) (*os.File, error) { return nil, execsandbox.ErrUnsupported }
diff --git a/internal/host/systemapply.go b/internal/host/systemapply.go
index 39f531964..8279daf51 100644
--- a/internal/host/systemapply.go
+++ b/internal/host/systemapply.go
@@ -3,8 +3,6 @@ package host
import (
"context"
"crypto/ed25519"
- "crypto/sha256"
- "encoding/hex"
"encoding/json"
"errors"
"flag"
@@ -248,11 +246,13 @@ func productionSysOps() sysOps {
}
type systemApplier struct {
- groupMaintenance *groupMaintenance
- floorAlerted bool
- rootMoves rootFloorIdentitySource
- participation *rootparticipation.Ledger
- floor *hostfloor.Disk
+ sandboxEnvironment func() (func(string) string, error)
+ sandboxRefused bool
+ groupMaintenance *groupMaintenance
+ floorAlerted bool
+ rootMoves rootFloorIdentitySource
+ participation *rootparticipation.Ledger
+ floor *hostfloor.Disk
// floorHook, when set, decides legacy or floor-guarded state once Run
// holds the apply lock, so a concurrent run's marker write is never read.
floorHook func(*systemApplier) error
@@ -309,6 +309,9 @@ func (a *systemApplier) file(name string) string { return filepath.Join(a.rootDi
// journal is closed, and re-firing OnFailure= over a finished recovery
// would only start it again with nothing left to do.
func (a *systemApplier) Run(ctx context.Context, recover bool) (retErr error) {
+ if _, err := a.sandboxMode(); err != nil {
+ return err
+ }
defer func() {
if errors.Is(retErr, context.DeadlineExceeded) {
if required, err := a.participationDisk().ParticipationRequired(context.WithoutCancel(ctx)); err == nil && required {
@@ -350,6 +353,10 @@ func (a *systemApplier) Run(ctx context.Context, recover bool) (retErr error) {
// The attended rollback already holds the same lock through its command entry.
// Keep recovery, participation settlement and staging cleanup shared with apply.
func (a *systemApplier) runLocked(ctx context.Context, recover bool, operation func(context.Context) error) (retErr error) {
+ a.sandboxRefused = false
+ if _, err := a.sandboxMode(); err != nil {
+ return err
+ }
a.resetGroupMaintenance()
if err := a.requireGroupMaintenance("check"); err != nil {
return err
@@ -373,6 +380,9 @@ func (a *systemApplier) runLocked(ctx context.Context, recover bool, operation f
deferred = true
}
defer func() {
+ if a.sandboxRefused || errors.Is(retErr, errExecSandboxFloor) {
+ return
+ }
active, err := a.activeFloor()
if err != nil {
retErr = errors.Join(retErr, err)
@@ -504,6 +514,9 @@ func (a *systemApplier) runLocked(ctx context.Context, recover bool, operation f
}
staged, err := a.stageCandidate(ctx, p, req)
if err != nil {
+ if errors.Is(err, errExecSandboxFloor) {
+ return a.record(req, err)
+ }
return a.record(req, fmt.Errorf("%w: %v", errSystemRefused, err))
}
return a.install(ctx, req, p, staged)
@@ -589,6 +602,9 @@ func (a *systemApplier) install(ctx context.Context, req systemRequest, p *relea
if err := a.groupTarget(staged, false); err != nil {
return err
}
+ if err := a.sandboxAllows(staged); err != nil {
+ return a.record(req, err)
+ }
target := p.Current.Version
if err := a.guardImage(staged); err != nil {
return err
@@ -600,6 +616,9 @@ func (a *systemApplier) install(ctx context.Context, req systemRequest, p *relea
if !prevOK {
return a.record(req, fmt.Errorf("%w: no known-good carlos.prev to fall back to", errSystemRefused))
}
+ if err := a.sandboxAllows(systemPrevPath(a.optDir)); err != nil {
+ return a.record(req, err)
+ }
newDir, prevDir := filepath.Join(a.stagingDir(), "new"), filepath.Join(a.stagingDir(), "prev")
newPlan, newUnits, err := a.stagePlan(ctx, staged, newDir)
if err != nil {
@@ -1303,6 +1322,10 @@ func (a *systemApplier) freezeHolds(fn func(held []registry.Route) error) error
}
func (a *systemApplier) prevBuild(ctx context.Context) string {
+ if a.sandboxAllows(systemPrevPath(a.optDir)) != nil {
+ return ""
+ }
+
out, err := a.guardRun(ctx, systemVersionWait, systemPrevPath(a.optDir), "version")
if err != nil {
return ""
@@ -1315,6 +1338,10 @@ func (a *systemApplier) prevBuild(ctx context.Context) string {
// in <dir>/plan.json next to them, so a later step can pick up the whole
// staging (stagedPlan) without exec'ing the binary a second time.
func (a *systemApplier) stagePlan(ctx context.Context, binary, dir string) (bootstrapPlan, []string, error) {
+ if err := a.sandboxAllows(binary); err != nil {
+ return bootstrapPlan{}, nil, err
+ }
+
if err := a.groupExecutable(binary); err != nil {
return bootstrapPlan{}, nil, err
}
@@ -1454,6 +1481,9 @@ func (a *systemApplier) installUnits(ctx context.Context, stagedRoot string, rem
return settingsErr
}
}
+ if err := ensureSandboxDirectories(filepath.Dir(a.etcDir), a.optDir); err != nil {
+ return err
+ }
unitDir := filepath.Join(a.etcDir, "systemd", "system")
if err := os.MkdirAll(unitDir, 0o755); err != nil {
return err
@@ -1957,6 +1987,9 @@ func (a *systemApplier) rollback(ctx context.Context, req systemRequest, reason
// it comes up at the next boot. No restart, no start: what to do about the
// running edge is the caller's, and at boot the answer is nothing.
func (a *systemApplier) restoreFiles(ctx context.Context, j *systemJournal) (bootstrapPlan, error) {
+ if err := a.sandboxAllows(systemPrevPath(a.optDir)); err != nil {
+ return bootstrapPlan{}, err
+ }
if err := a.groupTarget(systemPrevPath(a.optDir), true); err != nil {
return bootstrapPlan{}, err
}
@@ -2001,6 +2034,9 @@ func (a *systemApplier) restoreFiles(ctx context.Context, j *systemJournal) (boo
}
renamed := false
if err := a.activationGuard(ctx, prevVersion, running, func(ctx context.Context) error {
+ if err := a.sandboxAllows(restore); err != nil {
+ return err
+ }
if err := a.rootProtocolAllowsBinary(restore); err != nil {
return err
}
@@ -2241,6 +2277,9 @@ func (a *systemApplier) recoverIfNeeded(ctx context.Context) (bool, error) {
// record turns a refusal or deferral into result.json and a nil return.
func (a *systemApplier) record(req systemRequest, err error) error {
+ if errors.Is(err, errExecSandboxFloor) {
+ a.sandboxRefused = true
+ }
outcome := systemOutcomeRefused
if errors.Is(err, errSystemDeferred) {
outcome = systemOutcomeDeferred
@@ -2345,7 +2384,12 @@ func carlosVersionOf(out string) string {
// stageCandidate copies the agent's cache into staging/ (0700) as 0600,
// verifies the copy's sha against the pointer, makes it executable, and
// runs its `version`. Nothing under /data is read after the copy.
-func (a *systemApplier) stageCandidate(ctx context.Context, p *release.SystemPointer, req systemRequest) (string, error) {
+func (a *systemApplier) stageCandidate(ctx context.Context, p *release.SystemPointer, req systemRequest) (path string, retErr error) {
+ defer func() {
+ if errors.Is(retErr, errExecSandboxFloor) {
+ a.sandboxRefused = true
+ }
+ }()
if err := a.groupStageDigest(p.Current.Artifacts[a.platform].SHA256); err != nil {
return "", err
}
@@ -2353,13 +2397,6 @@ func (a *systemApplier) stageCandidate(ctx context.Context, p *release.SystemPoi
if !ok {
return "", fmt.Errorf("pointer names no artifact for %s", a.platform)
}
- os.RemoveAll(a.stagingDir())
- if err := os.MkdirAll(a.stagingDir(), 0o700); err != nil {
- return "", err
- }
- if err := os.Chmod(a.stagingDir(), 0o700); err != nil {
- return "", err
- }
src, err := openBeneath(a.dataDir, systemCacheParts(req.Version)...)
if err != nil {
return "", fmt.Errorf("candidate: %w", err)
@@ -2369,26 +2406,26 @@ func (a *systemApplier) stageCandidate(ctx context.Context, p *release.SystemPoi
if st, err := src.Stat(); err != nil || !st.Mode().IsRegular() {
return "", errors.New("candidate: not a regular file")
}
- staged := filepath.Join(a.stagingDir(), "carlos")
- dst, err := os.OpenFile(staged, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o600)
+ effective, err := a.sandboxMode()
if err != nil {
return "", err
}
- h := sha256.New()
- n, err := io.Copy(io.MultiWriter(dst, h), io.LimitReader(src, systemArtifactLimit+1))
- if cerr := dst.Close(); err == nil {
- err = cerr // a close that fails is a copy that did not land
- }
+ raw, err := verifiedSandboxCandidate(src, art.SHA256, effective)
if err != nil {
- return "", fmt.Errorf("candidate: copying into staging: %w", err)
+ return "", err
}
- if n > systemArtifactLimit {
- return "", fmt.Errorf("candidate: larger than %d bytes", systemArtifactLimit)
+ os.RemoveAll(a.stagingDir())
+ if err := os.MkdirAll(a.stagingDir(), 0o700); err != nil {
+ return "", err
}
- if got := hex.EncodeToString(h.Sum(nil)); got != art.SHA256 {
- return "", fmt.Errorf("candidate: sha256 %s does not match the signed %s", got, art.SHA256)
+ if err := os.Chmod(a.stagingDir(), 0o700); err != nil {
+ return "", err
+ }
+ staged := filepath.Join(a.stagingDir(), "carlos")
+ if err := writeDurable(staged, 0755, func(w io.Writer) error { _, err := w.Write(raw); return err }); err != nil {
+ return "", err
}
- if err := os.Chmod(staged, 0o755); err != nil {
+ if err := a.sandboxAllows(staged); err != nil {
return "", err
}
out, err := a.guardRun(ctx, systemVersionWait, staged, "version")
diff --git a/internal/host/systemapply_test.go b/internal/host/systemapply_test.go
index 3df36d191..c0036eadc 100644
--- a/internal/host/systemapply_test.go
+++ b/internal/host/systemapply_test.go
@@ -51,9 +51,10 @@ func newApplyFixture(t *testing.T, channel, build string) *applyFixture {
now: time.Date(2026, 9, 6, 11, 0, 0, 0, time.UTC), edgeUp: true, nrestarts: "0", activeEnter: "1000", edgeStartedThisBoot: true}
f.pub = pub
f.a = &systemApplier{
- openStore: func(context.Context) (release.Store, ed25519.PublicKey, error) { return f.store, f.pub, nil },
- channel: channel,
- optDir: t.TempDir(), dataDir: t.TempDir(), etcDir: t.TempDir(), build: build,
+ sandboxEnvironment: func() (func(string) string, error) { return func(string) string { return "" }, nil },
+ openStore: func(context.Context) (release.Store, ed25519.PublicKey, error) { return f.store, f.pub, nil },
+ channel: channel,
+ optDir: t.TempDir(), dataDir: t.TempDir(), etcDir: t.TempDir(), build: build,
platform: "linux-arm64",
}
f.a.ops = sysOps{
diff --git a/internal/host/systemunits.go b/internal/host/systemunits.go
index eceb90232..b53e893f5 100644
--- a/internal/host/systemunits.go
+++ b/internal/host/systemunits.go
@@ -33,7 +33,7 @@ var ensureSystemArmed = []string{systemUpdatePathUnit, systemRecoverUnit, instan
// carlos-dbread.socket and its service template are the db-read worker's
// (db region forward spec §8.3): installed and the socket armed here, the
// template never started.
-var systemUnitFiles = []string{"carlos-system-update.path", "carlos-system-update.service", systemRecoverUnit, instanceControlSocket, "carlos-instance-control.service", dbReadSocketUnit, "carlos-dbread@.service", "carlos-demo-build@.service", "carlos-demo-builds.slice"}
+var systemUnitFiles = []string{"carlos-runsc.service", "carlos-instance-gvisor@.service", "carlos-instance-gvisor-probe.service", "carlos-demo-build-gvisor@.service", "carlos-system-update.path", "carlos-system-update.service", systemRecoverUnit, instanceControlSocket, "carlos-instance-control.service", dbReadSocketUnit, "carlos-dbread@.service", "carlos-demo-build@.service", "carlos-demo-builds.slice"}
// ensureSystemUnits is the second belt of spec §7: a box the roll script
// forgot to arm is armed within the hour by the root adopt pass. It
@@ -159,6 +159,10 @@ func ensureSystemUnitsWithGuard(etcDir, lockPath string, systemctl, probe func(a
logf("adopt: retired units this build no longer ships: %s", strings.Join(retiredUnits, ", "))
}
isEnabled := parseIsEnabled(enabled)
+ if err := ensureSandboxDirectories(filepath.Dir(etcDir), a.optDir); err != nil {
+ logf("adopt: sandbox directories: %v", err)
+ return
+ }
missing := false
for _, u := range systemUnitFiles {
if group && groupAutomaticUnit(u) {
diff --git a/internal/host/units/carlos-instance-control.service b/internal/host/units/carlos-instance-control.service
index 456c372c7..4636f281e 100644
--- a/internal/host/units/carlos-instance-control.service
+++ b/internal/host/units/carlos-instance-control.service
@@ -26,7 +26,8 @@
[Unit]
Description=carlos instance control (root: start/stop carlos-instance*@ units for the agent)
Requires=carlos-instance-control.socket data-instances.mount run-carlos-instances.mount run-carlos-logs.mount
-After=data-instances.mount run-carlos-instances.mount run-carlos-logs.mount
+Wants=carlos-runsc.service
+After=data-instances.mount run-carlos-instances.mount run-carlos-logs.mount carlos-runsc.service
# Startup hairpin recovery may revoke or roll back saved rules, so wait for
# nftables to load them. Ordering alone leaves non-group boxes unaffected.
After=nftables.service
@@ -44,6 +45,7 @@ ProtectSystem=strict
# /run/systemd/system: per-generation runtime drop-ins (zero-downtime
# deploys, plan 2 D1) and escaped .mount units for demo snapshot disks.
ReadWritePaths=/run/carlos-control /run/systemd/system
+ReadWritePaths=/var/lib/carlos/oci-rootfs
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
diff --git a/internal/host/units/carlos-runsc.service b/internal/host/units/carlos-runsc.service
new file mode 100644
index 000000000..b420839c0
--- /dev/null
+++ b/internal/host/units/carlos-runsc.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=carlos pinned runsc installation
+Before=carlos-instance-control.service
+[Service]
+Type=oneshot
+User=root
+Group=root
+ExecStart=/opt/carlos/carlos system runsc-ensure
+EnvironmentFile=-/etc/carlos/host.env
+TimeoutStartSec=120
+ProtectSystem=strict
+ReadWritePaths=/opt/carlos/runsc
+ProtectHome=yes
+PrivateDevices=yes
+NoNewPrivileges=yes
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+UMask=0077
diff --git a/internal/host/units/carlos-system-recover.service b/internal/host/units/carlos-system-recover.service
index 428bbd0fa..36bc1d8f6 100644
--- a/internal/host/units/carlos-system-recover.service
+++ b/internal/host/units/carlos-system-recover.service
@@ -38,7 +38,7 @@ DefaultDependencies=yes
Type=oneshot
TimeoutStartSec=10min
EnvironmentFile=-/etc/carlos/host.env
-ExecStart=/bin/sh -c 'if [ -x /opt/carlos/system/guard/carlos ] && { [ -e /var/lib/carlos-claims/authority/exec/census.json ] || [ -L /var/lib/carlos-claims/authority/exec/census.json ] || [ -e /opt/carlos/system/guard/moves ] || [ -L /opt/carlos/system/guard/moves ]; }; then exec /opt/carlos/system/guard/carlos system guard-exec recover; fi; if [ -f /opt/carlos/system/router/journal.json ] && [ -x /opt/carlos/carlos.prev ] && [ ! -L /data/.moves/floor.min-release ] && { [ ! -e /data/.moves/floor.min-release ] || [ -f /data/.moves/floor.min-release ]; } && { ! [ -s /data/.moves/floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/floor.min-release /opt/carlos/carlos.prev.allowed; } && [ ! -L /data/.moves/seeds-floor.min-release ] && { [ ! -e /data/.moves/seeds-floor.min-release ] || [ -f /data/.moves/seeds-floor.min-release ]; } && { ! [ -s /data/.moves/seeds-floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/seeds-floor.min-release /opt/carlos/carlos.prev.seeds-allowed; }; then exec /opt/carlos/carlos.prev system apply --recover; fi; exec /opt/carlos/carlos system apply --recover'
+ExecStart=/bin/sh -c 'if [ -x /opt/carlos/system/guard/carlos ] && { [ -e /var/lib/carlos-claims/authority/exec/census.json ] || [ -L /var/lib/carlos-claims/authority/exec/census.json ] || [ -e /opt/carlos/system/guard/moves ] || [ -L /opt/carlos/system/guard/moves ]; }; then exec /opt/carlos/system/guard/carlos system guard-exec recover; fi; if [ -f /opt/carlos/system/router/journal.json ] && [ -x /opt/carlos/carlos.prev ] && [ ! -L /data/.moves/floor.min-release ] && { [ ! -e /data/.moves/floor.min-release ] || [ -f /data/.moves/floor.min-release ]; } && { ! [ -s /data/.moves/floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/floor.min-release /opt/carlos/carlos.prev.allowed; } && [ ! -L /data/.moves/seeds-floor.min-release ] && { [ ! -e /data/.moves/seeds-floor.min-release ] || [ -f /data/.moves/seeds-floor.min-release ]; } && { ! [ -s /data/.moves/seeds-floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/seeds-floor.min-release /opt/carlos/carlos.prev.seeds-allowed; } && /opt/carlos/carlos system exec-sandbox-allows-prev /opt/carlos/carlos.prev; then exec /opt/carlos/carlos.prev system apply --recover; fi; exec /opt/carlos/carlos system apply --recover'
ProtectHome=yes
PrivateTmp=yes
diff --git a/internal/instancectl/sandbox.go b/internal/instancectl/sandbox.go
index 90884e5dd..01bddc9e9 100644
--- a/internal/instancectl/sandbox.go
+++ b/internal/instancectl/sandbox.go
@@ -12,6 +12,8 @@ import (
// SandboxSettings is captured by the host entry point before claim assembly.
type SandboxSettings struct {
+ Baseline func() error
+ Runsc func(context.Context) error
Configured execsandbox.Configured
Effective execsandbox.Effective
Err error
@@ -54,6 +56,18 @@ func (s *Server) sandboxAdmission(ctx context.Context) error {
if !s.DemoBox {
return execsandbox.ErrUnsupported
}
+ if s.SandboxBaseline == nil {
+ return errors.New("EXEC-SANDBOX-BASELINE")
+ }
+ if err := s.SandboxBaseline(); err != nil {
+ return err
+ }
+ if s.SandboxRunsc == nil {
+ return execsandbox.ErrRunsc
+ }
+ if err := s.SandboxRunsc(ctx); err != nil {
+ return err
+ }
if s.SandboxReady == nil {
return execsandbox.ErrRunsc
}
diff --git a/internal/instancectl/sandbox_test.go b/internal/instancectl/sandbox_test.go
index 745667591..618d7713c 100644
--- a/internal/instancectl/sandbox_test.go
+++ b/internal/instancectl/sandbox_test.go
@@ -30,7 +30,7 @@ func TestSandboxIncompleteAdmission(t *testing.T) {
} {
t.Run(tc.name, func(t *testing.T) {
calls := 0
- s := &Server{DemoBuilder: sandboxTestBuilder{called: func() { calls++ }}, SandboxEffective: tc.mode, SandboxConfigErr: tc.configErr, DemoBox: tc.demo, Systemctl: func(context.Context, ...string) (string, error) { calls++; return "", nil }, FixtureOK: func() error { calls++; return nil }, ProbeImage: func(string) error { calls++; return nil }}
+ s := &Server{SandboxBaseline: func() error { return nil }, DemoBuilder: sandboxTestBuilder{called: func() { calls++ }}, SandboxEffective: tc.mode, SandboxConfigErr: tc.configErr, DemoBox: tc.demo, Systemctl: func(context.Context, ...string) (string, error) { calls++; return "", nil }, FixtureOK: func() error { calls++; return nil }, ProbeImage: func(string) error { calls++; return nil }}
for _, path := range []string{"/start?host=demo.example&role=run", "/start?host=demo.example&role=sidecar", "/start?host=demo.example&role=run&gen=1", "/start?host=demo.example&runtime=rootfs", "/seed", "/cmd", "/tty", "/claim/launch", "/demo-build"} {
w := httptest.NewRecorder()
s.Handler().ServeHTTP(w, httptest.NewRequest("POST", path, nil))
@@ -76,7 +76,7 @@ func TestSandboxIncompleteAdmission(t *testing.T) {
}
})
t.Run("callback failure", func(t *testing.T) {
- s := &Server{DemoBox: true, SandboxEffective: execsandbox.EffectiveGVisor, SandboxReady: func(context.Context) error { return errors.New("EXEC-SANDBOX-RUNSC: fixture") }}
+ s := &Server{SandboxBaseline: func() error { return nil }, SandboxRunsc: func(context.Context) error { return nil }, DemoBox: true, SandboxEffective: execsandbox.EffectiveGVisor, SandboxReady: func(context.Context) error { return errors.New("EXEC-SANDBOX-RUNSC: fixture") }}
if err := s.sandboxAdmission(context.Background()); err == nil || !strings.Contains(err.Error(), "fixture") {
t.Fatal(err)
}
@@ -98,3 +98,21 @@ func (b sandboxTestBuilder) Build(context.Context, []byte, io.Reader) (demobuild
b.called()
return demobuild.BuildOutput{}, nil
}
+
+func TestExecSandboxBaselineEveryReady(t *testing.T) {
+ checks := 0
+ s := &Server{DemoBox: true, SandboxEffective: execsandbox.EffectiveGVisor,
+ SandboxBaseline: func() error {
+ checks++
+ if checks > 1 {
+ return errors.New("EXEC-SANDBOX-BASELINE: journal")
+ }
+ return nil
+ },
+ SandboxRunsc: func(context.Context) error { return nil }, SandboxReady: func(context.Context) error { return nil }}
+ s.Ready()
+ rep, ready := s.Ready()
+ if checks != 2 || ready || !strings.Contains(rep.Lines[0].Detail, "journal") {
+ t.Fatalf("checks=%d ready=%v report=%+v", checks, ready, rep)
+ }
+}
diff --git a/internal/instancectl/server.go b/internal/instancectl/server.go
index b55e0a411..fa50ce3d6 100644
--- a/internal/instancectl/server.go
+++ b/internal/instancectl/server.go
@@ -46,6 +46,8 @@ type Server struct {
SandboxEffective execsandbox.Effective
SandboxConfigErr error
SandboxReady func(context.Context) error
+ SandboxBaseline func() error
+ SandboxRunsc func(context.Context) error
// DemoBox is fixed from root-owned environment at service startup.
DemoBox bool
@@ -288,6 +290,7 @@ func runWithClaim(args []string, claim, heldRelease http.Handler, view RegistryV
}
s := &Server{
SandboxConfigured: settings.Configured, SandboxEffective: settings.Effective, SandboxConfigErr: settings.Err,
+ SandboxBaseline: settings.Baseline, SandboxRunsc: settings.Runsc,
DemoBox: cfg.BoxMode(),
ClaimStop: claim,
ClaimHeldRelease: heldRelease,
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 114ce60c8..e65532ef7 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -128,4 +128,4 @@ plan14-root-reads-fix-activator-backoff-flake.tsv feba66806ddfcbdfaf369d72413bb1
plan14-root-reads-region-ha-dr5.tsv f19eb78c1da1475cbf8e11a3d6c394d828aa1c8f88ae24469fe8d473581b934b
plan14-root-reads-instance-syscall-filter.tsv b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c
plan14-root-reads-instance-restore-658-cli.tsv b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c
-plan14-root-reads-gvisor-demos.tsv 8c254ae5f1dc65f4a15b894f366c74dda7a147956d198e0281c76957f5970565
+plan14-root-reads-gvisor-demos.tsv 7762153da75e4ae7e3cb58b5effabf08cb60589cc8beefc0d8a0f0f4aaf3056f
diff --git a/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv b/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv
index 7d8de0576..485b308af 100644
--- a/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv
+++ b/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv
@@ -1,41 +1,82 @@
# Census overlay gvisor-demos, written by census-propose (#369). census-ruling-gvisor-demos, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-gvisor-demos.md.
-# 12 body, 0 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
-# 7 new dispositions: 0 reads re-frozen at their disposition with the claim, 7 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
-@legacy 53142bae4c3f2ad8444ecd148a1e5389cf059e60e80b0366056a6f7dce33997b internal/host/bootstrap.go bootstrapWithGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.;rev3=census-ruling-gvisor-demos;basis=Use the distinct claim/demo rendering marker, with historic state-directory recognition, for the 6b-N2 keep-installed decision; ordinary units are repaired on malformed host.env. Existing reads unchanged. file:Command@11946,file:ReadFile@564,file:ReadFile@7000 3cb60d7cb52e0e04a5ed690938acd5376f38e8275bf92624610f05bd3f6b41ab
-@legacy 30cbb184502cda61320987fa438776a839eee01c610185e050779ae82eeed822 internal/host/systemapply.go systemApplier.installUnits legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.;rev3=census-ruling-gvisor-demos;basis=Use claim/demo rendering evidence instead of the now-common EnvironmentFile line to preserve installed control on settings errors. Ordinary control stays flag-off and does not gain automatic restarts. Existing reads unchanged. file:ReadDir@1409,file:ReadFile@2000,file:ReadFile@5035,file:ReadFile@960,file:Stat@2658,file:Stat@3951 957f210b9c50169a414cc99ddf5ddae35a804e7c2ff734fe755e85bf3388087a
-@legacy 16c52a77d87551d9536e381991f55ea95e527b1d647d5d58ff2f1797c0e1b971 internal/host/systemunits.go ensureSystemUnitsWithGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move unit-repair body here with existing lock/unit/host.env reads; under lock require operator repair permit on groups before writes and each systemctl effect, preserve root masks/drop-in and omit automatic update/recovery units. New indirect protected marker/permit reads, never agent receipt; fixed repair unchanged.;rev3=census-ruling-gvisor-demos;basis=Use claim/demo rendering evidence for repair/restart selection and 6b-N2 preservation. Ordinary environment loading does not classify a box as claims-enabled. Existing reads unchanged. file:OpenFile@293,file:ReadFile@4702,file:ReadFile@4835,file:ReadFile@6239,file:Stat@4611 123236f110db2d69dc2f425944485e52ba12fede7be07d07f7db0d08987f4f61
+# 19 body, 1 sites, 6 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 22 new dispositions: 0 reads re-frozen at their disposition with the claim, 22 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 4ef93c4470151048cf05dc69a2c0c2375a4f25b65e6af8c33ab740705a6b33b5 internal/host/bootstrap.go bootstrapWithGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.;rev3=census-ruling-gvisor-demos;basis=Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. file:Command@12057,file:ReadFile@564,file:ReadFile@7111 2710b4ae0c444e7742e91dfffc6c136a698927eb62c42eae7cfc4eb1b06d2453
+@legacy ef8c8c20a6fd6daec8dc2c84b454a0cb05e9fc604300a1d3098f843ae5b6b67a internal/host/systemapply.go systemApplier.installUnits legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.;rev3=census-ruling-gvisor-demos;basis=Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. file:ReadDir@1509,file:ReadFile@1060,file:ReadFile@2100,file:ReadFile@5135,file:Stat@2758,file:Stat@4051 f20ce9ef05e19ccb08e68d7c7935aaf20175892fa2616c794ac6adad5303a8a8
+@legacy 396d3405311b55e3a1a748760a780bf8688577abacc3317cda791764969f5d74 internal/host/systemapply.go systemApplier.stagePlan legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupExecutable before staged bootstrap execution, matching the authorized old/new artifact through existing no-follow slot checks. New indirect marker/permit reads are root-protected; staged path still subject to existing release verification, direct read site unchanged.;rev3=census-ruling-gvisor-demos;basis=Require sandbox awareness before clearing or creating staged unit plan and invoking bootstrap. No added direct read. file:ReadDir@710 29ad3b5339fafc83341b78d5d9542c36c7919e9258aa7ac2df6a723f2c888241
+@legacy 829fe6967598655fabebc39453c95135bfb8104fbf8b30f1292eea05b8064661 internal/host/systemunits.go ensureSystemUnitsWithGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move unit-repair body here with existing lock/unit/host.env reads; under lock require operator repair permit on groups before writes and each systemctl effect, preserve root masks/drop-in and omit automatic update/recovery units. New indirect protected marker/permit reads, never agent receipt; fixed repair unchanged.;rev3=census-ruling-gvisor-demos;basis=Create runtime/rootfs directories and repair installer plus three measured workload templates without arming them. Existing unit/host.env reads unchanged. file:OpenFile@293,file:ReadFile@4842,file:ReadFile@4975,file:ReadFile@6379,file:Stat@4751 a089332bfe4c82bdb92dbd23bca60fd1e643eeac4712fe9189cc42ff1d086ca8
@legacy 5fd7a23e052a152316c75b4c833012f4ac059e747fa492da80bf6e1706058039 internal/instancectl/demo_policy.go Server.demoHandler legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=R26: HostDemo and the demo start/purge lock run only in demo mode. Ordinary starts do not read HostDemo or gain its read-error refusal. Demo-mode missing/non-demo/held-row and read-error refusals remain.;rev3=census-ruling-gvisor-demos;basis=Retain authenticated claim cleanup routes on demo-plus-claims sandbox refusal when a ClaimStop handler exists; sandbox admission still rejects claim launches, and claimAwareLegacy rejects legacy mutations. Existing registry reads unchanged. file:Query@485,file:Query@525,registry:Status@703,whole:Route@658 b52ba1d3b35ed5195d5009ec59c180abd32262bd716ddbac4e1de245f1173d2e
@legacy 05b7a387b7ff2a6a99259dde4f508f308afaf7cfff9a08c2ddc648169578c082 internal/instancectl/rootfs.go Server.runRootfsProbe 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 Server.RunProbe): new (rootfs Plan 2 Task 7): builds the probe image once per service start, hashes it (fileSHA256), lays out the _probe rootfs exe layout and its box-addrs, starts carlos-instance-rootfs-probe.service and ReadFiles its report from /run/carlos-control/rootfs-probe.out, which PID 1 writes from the probe's stdout; the probe runs the platform binary from root's own probe image, no tenant code; the report only decides readiness, and without an ok root-image line it is never ready, whatever it says;rev3=census-ruling-agent-start-demo-1;basis=Reads DemoBox and refuses before preparing or launching a rootfs probe; ordinary probe behavior unchanged.;rev3=census-ruling-gvisor-demos;basis=Refuse sandbox configuration or readiness errors before preparing or starting the native rootfs probe. Existing image read unchanged. file:ReadFile@2005 6ad27d7fe661eba457ea01736b8c482e27fd3d1a64ed80e8afefa8ffe4e9f386
@legacy 7129928a96c588d2dcaf6e93b8c5e5f6977f2519ccb60f1af361f7b1c57602ee internal/instancectl/server.go Server.RunProbe legacy accepted-legacy accepted-legacy;rev3=J2,J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=after the resolver allow it applies the box-address deny (denyLocalAddrs: set-property IPAddressDeny on carlos-instances.slice from localPrefixes, which reads /proc/net/fib_trie and /proc/net/if_inet6 as LocalAddrs already did), writes the probe's box-addrs under its own exe layout (writeFileExcl, a decision row), and after the binary probe runs the rootfs probe (runRootfsProbe, a decision row); its own direct read, probe.out, is unchanged;rev3=census-ruling-region-ha-p3b;basis=Take shared root hairpin lease for the entire probe so deny refresh and hairpin mutation cannot race it. Indirect reads validate root boot snapshot, root state/fence and interface inventory; existing probe.out direct read remains and lock/config errors fail readiness.;rev3=census-ruling-gvisor-demos;basis=Refuse sandbox configuration or readiness errors before fixture reads and native probe dispatch. Existing probe read unchanged. file:ReadFile@2608 2a0e32e04c6e0c5f25021c62f760f72429fa5e91d7597fcc4b09b7fdf5790b34
-@legacy bc7cd834024c83776bd9b64133f191a03588dd973960954fd6a6ce853023ad69 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;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Add fixed configured and effective sandbox modes, configuration error and runtime readiness callback. No new path or read. file:Statfs@4123 4f7b68950f5e49b21ed52a7d58e416d90f2e062e4e3c01e44468a2bd87494b98
+@legacy eb02d318090e4d9fff2ea925355bc106b08d8a9bfdcdb33b5105454e0e85d014 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;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 mode/error/readiness fields; add baseline and runtime callbacks. No new direct read. file:Statfs@4202 7d410804e45d30e2d3537eec0d750021c28e129f5be1a472600d3e3f15141790
+@legacy 4fb49c7ba8d52c022c0748d216f18a99d973c0a5a858e790446558f2eff9500c internal/execsandbox/file_linux.go checkRunscDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Open and fstat root-owned no-follow runtime directories; require 0755. Paths selected by compiled pin or root-owned installation temp. file:Stat@137 39283ba464884471a3085ea8bbb9260eb7b82c7300444aff12680cbee6018a05
+@legacy 3a6e0c0d7ef5c570e3b1d1d803ac705cd45c84fb9b50868a9582446548a9e956 internal/execsandbox/file_linux.go openCheckedDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Walk absolute clean path from root with O_DIRECTORY/O_NOFOLLOW; fstat each ancestor for root ownership and no non-root write bits. No agent-selected path in production. file:Open@197,file:Openat@458,file:Stat@687 8b45bad16e2732bd7fdfc69a8beb7f4961936cedd7f36ad4d957b02df3e2dddf
+@legacy 518c5527298ee264e142c0d5e9ed806175417c5f87108b6d73b48f5f120899a7 internal/execsandbox/file_linux.go openCheckedFile legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Open leaf relative to checked root-owned parent with O_NOFOLLOW/O_NONBLOCK; fstat regular/single-link/root-owned/mode/size metadata before reading. No symlink traversal. file:Openat@297,file:Stat@524 fedd812d2fa99959f5b58a51ab767935396e922009eae3b5d1f93afd1f872be9
+@legacy 807394aaf07e87f763e48fa19c3b41d67b2d446c08a47161e599bf6780512300 internal/execsandbox/protocol.go ReadProtocol legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Scan one checked root-owned executable, bounded at 96 MiB, using its fstat size. Fixed staged/prev/restore paths. file:Stat@154 86de5a4136e7566f36ae84d044b78e3a8d05c666b08612c9092868be22db1c71
@legacy 39b3f98c010e512816b6964fd4de98193a850564e68021119a888e6a97f7befa internal/execsandbox/runsc.lock.json external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Extend the embedded release-20261102.0 pin to exactly the five R-T2 executable members on each Linux platform. Archive SHA512 was verified before extracting the named regular members; freeze each SHA256. Top-level SHA256 still equals runsc. No external runtime read. file:external@0 3a24ba581a95bc8fd8283984b5501f0002daff003e2d8fe90571e150ba15b617
+@legacy 3716cf34bc92818af29a7f7df21205eb21383beae521bfb8d5c004de2d553efa internal/execsandbox/verifier.go RunscVerifier.verify legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read and hash exactly five pin-selected members; fstat before/after hash; cache by device/inode/size/mtime/ctime and hash. Revalidate metadata and ancestors on every call. file:Stat@477,file:Stat@748 5a9c63db1637659b68a7b1784707a50ee38e7e7ae85f8c71dc250c84e53cfa25
@legacy ee7a88073c08baf804220709c6e2d7778d7d277054f413be0443d2ac431643ef internal/host/execsandbox.go sandboxExecGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read the existing registry route through injected lookup only for gVisor; require the same route admission before BeforeExec. No new path; lookup is the existing registry handle. whole:Route@493,whole:Route@587 e66292565a6718b38622cfbd0747888356fb66fca161d782399067a0db23a1f5
@legacy 8d2537e489c6d9c5782c1548a3cdabe421f20a9d4eae4b71d008d089c071a43c internal/host/execsandbox.go sandboxRouteGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read existing route layout, demo marker and runtime to refuse unsupported or direct gVisor launches before the next config gate. No new path; layout inputs are the backend's existing ones. registry:Runtime@700,whole:Route@432,whole:Route@802 6d3b45864d6e551a523e37dbec39f6d7befd414d02ce6751531ac312c7ec1d67
+@legacy 8b1d8ef0abb6f01ce57096673c47b69b9a48b6922da8f8760e18f126108b2235 internal/host/execsandboxfloor.go checkExecSandboxBaselineAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Lstat journal and guard executable/census/moves paths for absence on every readiness call; compare installed recovery bytes with exact embedded unit. No guard execution or state alteration. file:Lstat@289,file:Lstat@488,file:ReadFile@617 f7e75448f38d25a703aedef82e102da70f8e9e84ce8e6aed98ecfc8a7f86b0c2
+@legacy 8c9bc81afc11dc8d6f7b5ebf7cd6125697019608113ee63aa0125a29eb4891ad internal/host/execsandboxfloor.go sandboxHostEnvironment legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Reopen fixed root-owned host.env without links, bound bytes at 1 MiB, parse with existing hostenv parser; no inherited values used as authority. file:ReadAll@296 740a2ebf07d90e3f3829361fbf18f24df4d2f73593a8f90b80b8b1a5a78c6705
+@legacy e5e5ebe17b2fc9c687f76fdf3184be0f843526192d65235794ce4842682888c0 internal/host/execsandboxfloor.go verifiedSandboxCandidate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Bounded single read of untrusted cache stream; require signed pointer SHA256 before protocol scan over same immutable byte buffer. No execution or staging mutation. file:ReadAll@125 4a41f564e8d1025a2070bae6d1e301ba48bb44bdbff29184dbb6d545094a9633
+@legacy c5c7ce8e96666643370f65654423c247b19a4d2862e1c3d1caf890f13bb5285a internal/host/runscensure.go installRunscSet legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Check root-owned destination parent; fetch five compiled-pin object keys into exclusive temporary set, bounded hashes and fsync, verify complete set, publish by atomic directory rename/exchange. No unverified executable published. file:Lstat@431,file:Open@1395 5d1264fd744af58eb38a236203fd93b2bfeca2c8fa618fe37089ccbd1b865e14
+@legacy 0f982a9b20cd4e766747e1d410ef8565645a5562c1532e4f61a30b369f4379d6 internal/host/runscensure.go pruneRunscSets legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read runtime directory only after complete command inventory; retain current/referenced sets and everything on inventory failure; remove only unreferenced 64-hex root-owned set directories. file:ReadDir@232 164a94ccd333048342691664b7a30e8b0f34b7a67d2d0f717498b5cabe41f96b
+@legacy 360866378b0c01183a994d44c4137689950369e4d5963ff7b65629e65644f995 internal/host/runscensure.go runscCommandInventory legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Enumerate loaded units, jobs, installed units and checked root-owned installed unit/drop-in files; any failure retains old sets. Reads only fixed systemd roots or checked symlink destinations. file:EvalSymlinks@1559,file:ReadAt@1951,file:Stat@1817,file:WalkDir@1171 bf2d652ffb21a228a6a917b4d5280cbd59c9cddf764e2a2d8ceebaeb8e37697e
+@legacy 162c1096b241d3681b0a32f8a50b9f13beccb7ea6a15c1121a309bbc6e2cce29 internal/host/runscensure.go runscSystemctl legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Execute systemctl with fixed enumeration/start verbs and root-generated unit names, context bounded. No shell or request-provided executable. file:CommandContext@88 16614091a159f92b0575ac6980a90e468c50936662d6f1016425b4080951468e
+@legacy 89850dae525cb323ac5284d111ad6b2a490e170d07c67145ea2944da427f9fc8 internal/host/runscensure.go wireSandboxReadiness legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read exact embedded recovery unit and bind host baseline plus compiled-pin verification callbacks. No installed unit data enters instancectl imports. file:ReadFile@85 e46e312a601c7e91da51d537c8ebb580c2c59630f8608d5a65da5a4352245c0e
+@legacy 35a5420f20da576cdf58faa3263996e80ee6626aa488ce7ebcd1e9c6957a4306 internal/host/runscset_linux.go openRunscLock legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Open fixed installer lock under checked root runtime directory with O_NOFOLLOW; fstat root owner, single-link regular and private mode before flock. file:Fstat@264,file:Open@64 d44bfa3ce6f1e0bc68c2671ed5604044412de4e6f82b488436d119ee71b81d68
@legacy 7ce6741a7508b1a64de66d58ea342ff1ac4f4093c73a94e8e211949a574fca23 internal/host/units/carlos-demo-build-gvisor@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Add the unarmed root gVisor build skeleton with empty ExecStart, all twelve measured properties, control-group termination and fixed physical budgets. Host LimitFSIZE is omitted by ruling; guest OCI limit remains 33554432 and passed EFBIG measurement. Root prepares validated per-job writable paths, append diagnostics and runtime commands later; template output defaults remain null. file:external@0 8b6f939424c554aaf1e5ed38111ebd0bf67fdcbaaa5bc6415df55affb64ba17a
@legacy 1cb2a2b1f667f42c1b24eb4997c20b5ecc00a9571d92060dedfada948e8a0f5d internal/host/units/carlos-instance-gvisor-probe.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Add the unarmed root gVisor probe skeleton with empty ExecStart, all twelve measured properties, fixed probe data/run paths, append output and mixed kill with SIGCONT. Root command preparation must reset output and bind a fresh nonce before start; full readiness consumer remains a later task. file:external@0 b05d264190ef2172e87e5b2667164f2051e83016695595e32ccbcdce9186eb6b
@legacy 4de04c1583d5fa335adadb7227f9ce1ec35e28280744d6571ebe92c72b4442f2 internal/host/units/carlos-instance-gvisor@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Add the unarmed root gVisor run skeleton with empty ExecStart and all twelve measured host properties. Defines per-instance data/run writable paths and socket output, root runtime directory, mixed kill with SIGCONT, and the existing bounded stop. A root-prepared validated command drop-in is required before it can start; no command or pin placeholder is installed here. file:external@0 914a3c0486d83b6b87ce14c473aab9005ff7bc004cb984040a81ddc60087a5c1
+@legacy dd34ca6003fd907b4919382e5d960722556e8d322311cfa1d70b1eb76d96274d internal/host/units/carlos-runsc.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Root oneshot reads fixed root-owned host.env through its applet and installs compiled runtime set only under /opt/carlos/runsc; no RemainAfterExit. file:external@0 215ca2aea9519d14d0e20b5f9b6588b43ff7c5ef7b485982274fbbbfe2cf02b5
@legacy 6c407dd1a2b848bef09894cb174b933331bbc0b2c8147e7e533b41c9f6bb7464 internal/instanceexec/sandbox_linux.go gvisorProbeChecks legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Preliminary guest-only probe reads the fixed /proc/self/status to check empty capability sets and NoNewPrivs, and SelfCheck opens the fixed own /data/instances/_probe directory with unchanged safe-open flags. Runs as the guest carlos identity; reports readiness incomplete until the later root challenges exist. No tenant-selected host path or root authority is added. Echo CARLOS_GVISOR_PROBE_NONCE from the initial guest environment in the additive omitempty report field; root supplies the challenge in the OCI environment. No new filesystem read or readiness grant. data-literal@696,file:ReadFile@202 b201174cac395aea50cbe7c306859c47a120d1a954d988a43e9746a1386f658a
+@legacy 7de6b66932d7e63833d949ae349a5b99445cefce0cf3a60f3e5495d47fedc9c2 internal/host/systemapply.go systemApplier.stageCandidate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupStageDigest before staging/candidate execution; action and new digest come from root-owned operator permit bound to boot marker. Existing signed pointer/artifact verification and two direct read sites remain.;rev3=census-ruling-gvisor-demos;basis=Read agent cache once into bounded buffer; signed hash and marker before clearing staging; write those exact bytes durably and check root-owned staged binary before version execution. Removes direct OpenFile site. Retain staging on floor refusal for both apply and install-channel callers; floor authority reopens root-owned host.env by default. file:Stat@697 4d62d6d3fc76650d19493cdecf3a9ce47034ab5b0194fbac796e2773224c50bd
internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-region-ha-p1b3b-t;basis=Wire Service.SetDutyView to the live edge DutySnapshot in the ready callback. No new read; no new loop or cloud operation. B2 wires the registry as the persistent DutyStore before service startup; no new cloud or filesystem path. B3b: arm one journal-backed termination consumer before service startup using agentCtx and the shared confirmer; expose edge tick and join at edge shutdown. No new direct read sites.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. Merge resolution against origin/main 9bd45488 retains main's HA departure controller, lifecycle and duty wiring alongside the demo data store and worker; no read site added by the resolution.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: install closed fixed admission before every launch source, bind activator/backend and edge, wire the real termination Started lifecycle and role reader after the change index; close before cancellation/child shutdown. No new external reads or cloud authority. Fix R1: move bind/lifecycle/edge-option wiring into wireAgentAdmission and worker listing into runWorkerBootPassAfterAdmission. Worker boot waits for admission before listing then uses unchanged bounded wakes and per-host serialization; whole Route read moves to the helper. No new storage, cloud, or root execution authority. Preserve merged main's agent wiring and census basis; the branch removes one whole Route use by moving worker iteration to the helper, with no added read kind.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: arms a fleet-only worker using the existing registry, activator, backend and authenticated console transport. Owned worker stops and joins at shutdown. No new bucket reader. merge of origin/main 9b8b2c50: retain HA duty/departure lifecycle, wake-slot and existing agent wiring alongside the replica placement worker; no new read introduced by resolution. merge of origin/main 6be08467: Retain main demo configuration, admission, build and expiry wiring alongside the replica worker; merge-only body change, no additional read. merge of origin/main 7920cccf: Retain main box-role/group admission wiring and boot publication beside the owned replica worker and shutdown; main moves the boot registry List into runWorkerBootPassAfterAdmission, removing its inline whole Route site. No new read introduced by conflict resolution.;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 M3: retain the private snapshot source and cancel/join ownership, but use the replica-health-specific retry loop. It logs its first failure only and retains the existing exponential backoff capped at 30 seconds; unsupported builds return nil. Existing five direct read sites unchanged; no new credentials, bucket reader or app lifecycle action. Fix round 1 Q20: publish Edge.ReplicaSnapshots as a separate in-memory status source, leaving the tenant-visible Upstreams source unchanged. No new external reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Load root-written group marker/configuration, configure signed boot binding and agent receipt completer, wire cancellable admission into departure work and expose cached GroupReaderSnapshot. New indirect boot reads use protected root files; agent-owned receipt controls duplicate initial completion only, never root restart permission. Same five direct sites. Merge 45cebde4 retains the replica health socket lifecycle and setReplicaSource beside GroupReaderSnapshot; no extra read beyond main.;rev3=census-ruling-agent-start-demo-2;basis=agent.go:309-329 opens demo-traffic.db beside the operator-configured registry when a demo domain exists, closes it at shutdown and wires drain-before-purge; :1010-1019 shares the worker and write gate; :1164-1177 installs the fleet identity and closed-until-worker serving callback. One added whole Route pass; the new indirect filesystem/SQL reads are claimed in openDemoTraffic and worker/store units. No request chooses the database pathname.;rev3=census-ruling-region-ha-p1b3b-s;basis=Wire the service duty view to authoritative cached sidecar manifest placement in LifetimeIndex and the edge sidecar projection; missing policy denies duty. Existing instance duty wiring remains.;rev3=census-ruling-region-ha-g2-t3;basis=T3a: wire eb.Page = PageOperator beside OwnerTerminated before departures arm, so suspect-holder pages work if departure setup fails; no new read; existing nine sites and authority unchanged; pages through the existing sink. T3b: publish the same backend through an atomic pointer for the metrics observer, and clear it on return; no new external read or authority.;rev3=census-ruling-agent-start-demo-3;basis=Wire the claim activator and root snapshot client into the demo worker; pass moved readiness to status reporting. Census read-site delta: unchanged (9).;rev3=census-ruling-region-ha-g2-fixes;basis=Wire local pool evidence, live withdrawal activator, startup ingress scan and alias publication, and edge lookup; no new direct sites; new indirect record/claim reads use existing store/judge paths described in ingress helpers.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: starts the existing record-view backstop loop with a departure-inventory listener (non-blocking, coalesced signal) even without an armed RecordView; it requests the existing full pass (backstopFullDue) there. Same nine read sites; no new read or authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Derive one signal-time deadline with a 90-second budget; cap departure stop and startup/seed/service shutdown joins by it. No read added.;rev3=census-ruling-static-sweep-periodic;basis=in the edge-ready callback, publishes e.LargestStaticTree in staticTreeSource for the disk alert line (diskAlertFrac in the metrics loop); in-memory wiring only, no read added; read sites unchanged (9);rev3=census-ruling-gvisor-demos;basis=Capture sandbox resolution and refusal once; log errors once; gate route admission and BeforeExec before process launch. No new root read. file:Exec@19431,file:Open@1837,file:Statfs@50774,registry:App@12933,registry:Host@46810,whole:Route@12925,whole:Route@45968,whole:Route@46933,whole:Route@46995 c618605dd17ada0fb0b53b3c4d2176fd737c4f44b38a25298fbc1c48bae9fa0e
-internal/host/bootstrap.go bootstrapWithGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.;rev3=census-ruling-gvisor-demos;basis=Use the distinct claim/demo rendering marker, with historic state-directory recognition, for the 6b-N2 keep-installed decision; ordinary units are repaired on malformed host.env. Existing reads unchanged. file:Command@11946,file:ReadFile@564,file:ReadFile@7000 3cb60d7cb52e0e04a5ed690938acd5376f38e8275bf92624610f05bd3f6b41ab
-internal/host/claimstop_run.go RunInstanceControl authority C,D,G rev3=PROPOSED-p3;run=24;identity=root claim/adopt/update controller uid 0;basis=production root startup builds authenticated execution and launch handlers then uses activateClaimRoot for recovery, the registered census launch verifier and lifecycle start;rev3=census-ruling-rootfs-apps-2;basis=the claims-off path serves through instancectl.RunWithRegistryView with HostRuntime: instanceRegistryHostRuntime beside the same instanceRegistryHostApp(nil); the new read is instanceRegistryHostRuntime's own (a decision row in rootfs-apps-2-new); no read added in this body;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 4 and 6: the claims-off branch hands RunWithRegistryView the pre-claim egress asserter (newEgressAsserter over registryEgressSource and registryEgressHosts, which read the agent-written registry read-only, beside the instanceRegistryHostApp read it already had); the claims branch builds its runtime resources in instanceControlClaimResources, adding the claims asserter (claimsEgressSource writes no allow; the registry is read only to name slices), and serves through runClaimControl, which passes RunWithClaim the same handler, held-release route and host lookup plus that asserter. No read site in the unit, none added.;rev3=census-ruling-agent-start-demo-1;basis=Wires demo registry views and existing root release/adoption guard into instance control.;rev3=census-ruling-region-ha-p3b;basis=Add root hairpin identity verification, dormant install and reset CLI entries with bounded contexts. Indirect inputs are root-owned marker/identity/ingress/state and kernel/systemd process evidence; no request-controlled addresses or executable path. Existing control-service path remains.;rev3=census-ruling-gvisor-demos;basis=Resolve sandbox once through shared Configure; select claim protocol independently of sandbox refusal and retain claim stop/recovery, activation and host-fence pass. Relax demo-plus-claims fatal only for ErrClaims. Keep egress asserter and install its restart-only refusal before claim recovery. No new root read. 8defd30b08522508edaf87978bf7e7a70ff48fc0aef71a63a702231f387f0efb
+internal/host/bootstrap.go bootstrapWithGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.;rev3=census-ruling-gvisor-demos;basis=Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. file:Command@12057,file:ReadFile@564,file:ReadFile@7111 2710b4ae0c444e7742e91dfffc6c136a698927eb62c42eae7cfc4eb1b06d2453
+internal/host/claimstop_run.go RunInstanceControl authority C,D,G rev3=PROPOSED-p3;run=24;identity=root claim/adopt/update controller uid 0;basis=production root startup builds authenticated execution and launch handlers then uses activateClaimRoot for recovery, the registered census launch verifier and lifecycle start;rev3=census-ruling-rootfs-apps-2;basis=the claims-off path serves through instancectl.RunWithRegistryView with HostRuntime: instanceRegistryHostRuntime beside the same instanceRegistryHostApp(nil); the new read is instanceRegistryHostRuntime's own (a decision row in rootfs-apps-2-new); no read added in this body;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 4 and 6: the claims-off branch hands RunWithRegistryView the pre-claim egress asserter (newEgressAsserter over registryEgressSource and registryEgressHosts, which read the agent-written registry read-only, beside the instanceRegistryHostApp read it already had); the claims branch builds its runtime resources in instanceControlClaimResources, adding the claims asserter (claimsEgressSource writes no allow; the registry is read only to name slices), and serves through runClaimControl, which passes RunWithClaim the same handler, held-release route and host lookup plus that asserter. No read site in the unit, none added.;rev3=census-ruling-agent-start-demo-1;basis=Wires demo registry views and existing root release/adoption guard into instance control.;rev3=census-ruling-region-ha-p3b;basis=Add root hairpin identity verification, dormant install and reset CLI entries with bounded contexts. Indirect inputs are root-owned marker/identity/ingress/state and kernel/systemd process evidence; no request-controlled addresses or executable path. Existing control-service path remains.;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 admission and claim separation; wire host-owned exact recovery baseline and pinned-set verification/retry callbacks. No new direct read. adec0e3fbfd7af8ccf056cf35334bff29c4a8555cfed4ce0de4617199838e790
internal/host/claimunit.go claimUnitContent authority E1,E3 rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=adds write permission for exactly the public retry directory only when the root settings reader has verified a complete census and prepared that directory;rev3=census-ruling-agent-start-demo-1;basis=Demo-only ReadWritePaths for instance data/runtime, staged files and root release lock; ordinary rendering unchanged.;rev3=census-ruling-agent-start-demo-1-followups;basis=In demo box mode, declare StateDirectory=carlos-release/private with mode 0700 so systemd creates root-owned release state before namespace setup and keeps it writable. Existing ReadWritePaths and ordinary/claims rendering stay unchanged. No new read site or caller-controlled path.;rev3=census-ruling-agent-start-demo-3;basis=Declare /var/lib/carlos-demo-snapshots as root-owned StateDirectory with mode 0700 only for configured demo boxes, including recovery with admission off. Ordinary claims units retain their original directories. The shared unit template is unchanged from main; no file read is added.;rev3=census-ruling-gvisor-demos;basis=Mark only claim/demo renderings explicitly; common host.env remains loaded. Ordinary rendering masks CARLOS_HOST_CLAIM with UnsetEnvironment, removed only for a successfully parsed enabled claim rendering. Existing template read unchanged. data-literal@1364 dc20399778b94614bc05db6f6046949008921df8e0d9adef1b0d07be097d1bd3
-internal/host/systemapply.go systemApplier.installUnits legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.;rev3=census-ruling-gvisor-demos;basis=Use claim/demo rendering evidence instead of the now-common EnvironmentFile line to preserve installed control on settings errors. Ordinary control stays flag-off and does not gain automatic restarts. Existing reads unchanged. file:ReadDir@1409,file:ReadFile@2000,file:ReadFile@5035,file:ReadFile@960,file:Stat@2658,file:Stat@3951 957f210b9c50169a414cc99ddf5ddae35a804e7c2ff734fe755e85bf3388087a
-internal/host/systemunits.go ensureSystemUnitsWithGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move unit-repair body here with existing lock/unit/host.env reads; under lock require operator repair permit on groups before writes and each systemctl effect, preserve root masks/drop-in and omit automatic update/recovery units. New indirect protected marker/permit reads, never agent receipt; fixed repair unchanged.;rev3=census-ruling-gvisor-demos;basis=Use claim/demo rendering evidence for repair/restart selection and 6b-N2 preservation. Ordinary environment loading does not classify a box as claims-enabled. Existing reads unchanged. file:OpenFile@293,file:ReadFile@4702,file:ReadFile@4835,file:ReadFile@6239,file:Stat@4611 123236f110db2d69dc2f425944485e52ba12fede7be07d07f7db0d08987f4f61
-internal/host/units/carlos-instance-control.service external authority B3,C,D,E1,J4 root-input;kept=B3,C,D,E1;scope=protected-decision-only;rev3=census-ruling-agent-start-demo-3;basis=Correct the runtime-write comment to include escaped demo snapshot .mount units alongside per-generation drop-ins; service directives are unchanged.;rev3=census-ruling-region-ha-graceful-terminate-t1;basis=Region HA T1/DR-4 final fix: retain After=nftables.service without Wants or Requires; add Restart=on-failure and RestartSec=1 so a crashed control restarts before a later edge stop can block socket activation and shutdown proofs; rewrap the header and explain this ordering. Same ExecStart and protections; no new root read, input, path, command or capability.;rev3=census-ruling-gvisor-demos;basis=Load root-owned host.env on every box for sandbox configuration; mask CARLOS_HOST_CLAIM in the default flag-off rendering. Only claim-enabled rendering removes that mask. No new agent-writable source or permission. file:external@0 707e8b43835f0c7fab990cf814e0de6e06e81135da93ad82b01c858feab39254
+internal/host/systemapply.go systemApplier.Run authority D,F,J4 rev3=PROPOSED-claims-on-gate-recover;identity=root apply/recovery uid 0;basis=re-pinned at its class and task; its lock-file read is unchanged. A checkGuardRecovery error wrapping errSettlementDeferred under --recover is logged and not fatal, and the end-of-run settlement is not retried after a deferral; every other refusal returns as before. root-input;kept=D,F;scope=protected-decision-only. TestRecoverDefersACensusRefusalWithNoJournalOpen, TestApplyStillFailsACensusRefusalWithNoJournalOpen. Fix round 2: a deferral that recoverIfNeeded returns after the journal was removed is consumed the same way, with no fatal error kept and no settlement retried. TestRecoverDefersARefusalAfterTheJournalIsRemoved. Fix round 3: the end-of-run marker settlement (settleMarker, settleUpdateBegun) also goes through settleWithoutJournal, so a legacy update-begun marker with no update record and no journal defers a census refusal with the recover-legacy barrier held; a barrier that cannot be written joins the run's error in every mode; every other marker failure is logged as on main. TestRecoverHoldsAcquisitionsForALegacyMarker, TestRecoverFailsALegacyMarkerWhoseBarrierCannotBeWritten.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 15: the no-op test is split so the installed build (onDiskBuild, the same read as before) is read once; a hand-run apply then refuses a candidate below the rootfs floor v0.29.0 on a box already at or above it unless the override flag is passed; the agent's pointer path is unchanged; adds a refusal only;rev3=census-ruling-region-ha-p3b;basis=Under the apply lock require the root marker-bound maintenance permit before group staging cleanup/floor/recovery work, then bind candidate digest before staging. Marker /etc/carlos/group.json is root boot output; permit /run/carlos-group-maintenance/permit.json is operator-written through root, never the agent receipt. Direct read unchanged.;rev3=census-ruling-region-ha-p3b2;basis=Body split: lock acquisition stays in Run, the unchanged apply body moves to runLocked so group-maintenance apply/rollback run it under the command's already-held lock. Same reads and guard calls (requireGroupMaintenance check first under the lock).;rev3=census-ruling-gvisor-demos;basis=Refuse malformed sandbox setting before staging cleanup or lock mutation. Existing root state reads unchanged. file:OpenFile@583 75842202c3bf5222cdf9040c1c91454e074cdc780eee45eb8de8a2a184a769ff
+internal/host/systemapply.go systemApplier.install authority F,J4 rev3=PROPOSED-p3;identity=carlos system apply, root update unit or offline root CLI, uid 0;basis=root verifies staged signature and final locked bounds before rename, then records root accepted floor history only after health succeeds;rev3=census-ruling-region-ha-p1a;basis=root apply, uid 0: comment and error text only around the beginExecutableChange call (the wrapped error now reads "update not begun" instead of "update-begun marker"); the call, its position before the first box-changing step and the deferral on error are unchanged; no read added;rev3=census-ruling-region-ha-p3b;basis=Require groupTarget for the staged new artifact and propagate quiesce refusal before effects. Root-owned operator permit must authorize digest/action/current boot; existing signed image, floor and journal checks remain; no new direct read.;rev3=census-ruling-gvisor-demos;basis=Check staged and previous executable awareness before unit-plan execution. Existing reads unchanged; no unaware prev executes in gvisor mode. a22f4cbbab3f7aea6a8f12ae494b8dfe808caee6ea6048ab7a1b8eb600945897
+internal/host/systemapply.go systemApplier.installUnits legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.;rev3=census-ruling-gvisor-demos;basis=Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. file:ReadDir@1509,file:ReadFile@1060,file:ReadFile@2100,file:ReadFile@5135,file:Stat@2758,file:Stat@4051 f20ce9ef05e19ccb08e68d7c7935aaf20175892fa2616c794ac6adad5303a8a8
+internal/host/systemapply.go systemApplier.restoreFiles authority F,J4 rev3=PROPOSED-p3;identity=carlos system apply/recover, root systemd units or offline root CLI, uid 0;basis=selects signed prev identity and checks staged restore against both root bounds before rename; version sidecar cannot authorize;rev3=census-ruling-region-ha-p3b;basis=Authorize exact previous artifact before restore, propagate quiesce refusal and remove automatic group units from enable list. Existing signature/floor and staged plan reads remain; indirect permit must be root-owned and bind old digest/current boot.;rev3=census-ruling-gvisor-demos;basis=Check prev awareness before quiesce/copy/restore and check the copied restore executable before rename. Existing stat unchanged. file:Stat@430 6a1bc52aac86cd48cde5b568cdcb8b7299227e4ac2373f60f2e92c9ab10bad25
+internal/host/systemapply.go systemApplier.stagePlan legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupExecutable before staged bootstrap execution, matching the authorized old/new artifact through existing no-follow slot checks. New indirect marker/permit reads are root-protected; staged path still subject to existing release verification, direct read site unchanged.;rev3=census-ruling-gvisor-demos;basis=Require sandbox awareness before clearing or creating staged unit plan and invoking bootstrap. No added direct read. file:ReadDir@710 29ad3b5339fafc83341b78d5d9542c36c7919e9258aa7ac2df6a723f2c888241
+internal/host/systemunits.go ensureSystemUnitsWithGuard legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move unit-repair body here with existing lock/unit/host.env reads; under lock require operator repair permit on groups before writes and each systemctl effect, preserve root masks/drop-in and omit automatic update/recovery units. New indirect protected marker/permit reads, never agent receipt; fixed repair unchanged.;rev3=census-ruling-gvisor-demos;basis=Create runtime/rootfs directories and repair installer plus three measured workload templates without arming them. Existing unit/host.env reads unchanged. file:OpenFile@293,file:ReadFile@4842,file:ReadFile@4975,file:ReadFile@6379,file:Stat@4751 a089332bfe4c82bdb92dbd23bca60fd1e643eeac4712fe9189cc42ff1d086ca8
+internal/host/units/carlos-instance-control.service external authority B3,C,D,E1,J4 root-input;kept=B3,C,D,E1;scope=protected-decision-only;rev3=census-ruling-agent-start-demo-3;basis=Correct the runtime-write comment to include escaped demo snapshot .mount units alongside per-generation drop-ins; service directives are unchanged.;rev3=census-ruling-region-ha-graceful-terminate-t1;basis=Region HA T1/DR-4 final fix: retain After=nftables.service without Wants or Requires; add Restart=on-failure and RestartSec=1 so a crashed control restarts before a later edge stop can block socket activation and shutdown proofs; rewrap the header and explain this ordering. Same ExecStart and protections; no new root read, input, path, command or capability.;rev3=census-ruling-gvisor-demos;basis=Add Wants/After installer and narrowly writable rootfs parent. Keep one host.env EnvironmentFile and other hardening. file:external@0 1a673893f4e8e8012edcd63464de0897d6e8a2aa1144b7e6f00ea0f090cc7a3a
+internal/host/units/carlos-system-recover.service external authority F,J4 rev3=PROPOSED-p3;identity=systemd update/recover oneshot shell uid 0;basis=guard branch is conditional on executable presence; unarmed units retain main selector; installed guard selects from root local floor;rev3=census-ruling-gvisor-demos;basis=Insert current-binary sandbox gate immediately before second-branch prev exec. Preserve guard branch and all other shell bytes. file:external@0 deed8b6ebef429930060c24f0ff0dc50679e14d3728f5c3d922a8df3995e9483
internal/instancectl/demo_policy.go Server.demoHandler legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=R26: HostDemo and the demo start/purge lock run only in demo mode. Ordinary starts do not read HostDemo or gain its read-error refusal. Demo-mode missing/non-demo/held-row and read-error refusals remain.;rev3=census-ruling-gvisor-demos;basis=Retain authenticated claim cleanup routes on demo-plus-claims sandbox refusal when a ClaimStop handler exists; sandbox admission still rejects claim launches, and claimAwareLegacy rejects legacy mutations. Existing registry reads unchanged. file:Query@485,file:Query@525,registry:Status@703,whole:Route@658 b52ba1d3b35ed5195d5009ec59c180abd32262bd716ddbac4e1de245f1173d2e
internal/instancectl/rootfs.go Server.runRootfsProbe 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 Server.RunProbe): new (rootfs Plan 2 Task 7): builds the probe image once per service start, hashes it (fileSHA256), lays out the _probe rootfs exe layout and its box-addrs, starts carlos-instance-rootfs-probe.service and ReadFiles its report from /run/carlos-control/rootfs-probe.out, which PID 1 writes from the probe's stdout; the probe runs the platform binary from root's own probe image, no tenant code; the report only decides readiness, and without an ok root-image line it is never ready, whatever it says;rev3=census-ruling-agent-start-demo-1;basis=Reads DemoBox and refuses before preparing or launching a rootfs probe; ordinary probe behavior unchanged.;rev3=census-ruling-gvisor-demos;basis=Refuse sandbox configuration or readiness errors before preparing or starting the native rootfs probe. Existing image read unchanged. file:ReadFile@2005 6ad27d7fe661eba457ea01736b8c482e27fd3d1a64ed80e8afefa8ffe4e9f386
internal/instancectl/server.go Server.RunProbe legacy accepted-legacy accepted-legacy;rev3=J2,J4;basis=root-input;rev3=census-ruling-rootfs-apps-2;basis=after the resolver allow it applies the box-address deny (denyLocalAddrs: set-property IPAddressDeny on carlos-instances.slice from localPrefixes, which reads /proc/net/fib_trie and /proc/net/if_inet6 as LocalAddrs already did), writes the probe's box-addrs under its own exe layout (writeFileExcl, a decision row), and after the binary probe runs the rootfs probe (runRootfsProbe, a decision row); its own direct read, probe.out, is unchanged;rev3=census-ruling-region-ha-p3b;basis=Take shared root hairpin lease for the entire probe so deny refresh and hairpin mutation cannot race it. Indirect reads validate root boot snapshot, root state/fence and interface inventory; existing probe.out direct read remains and lock/config errors fail readiness.;rev3=census-ruling-gvisor-demos;basis=Refuse sandbox configuration or readiness errors before fixture reads and native probe dispatch. Existing probe read unchanged. file:ReadFile@2608 2a0e32e04c6e0c5f25021c62f760f72429fa5e91d7597fcc4b09b7fdf5790b34
-internal/instancectl/server.go runWithClaim authority C,D,G Claim instance controller adds held-release RPC dispatch within existing launch/participation execution boundary.;rev3=census-ruling-rootfs-apps-2;basis=takes a RegistryView (HostApp and HostRuntime) for the bare hostApp, and the production Server literal gains HostRuntime, ProbeImage: BuildProbeImage, ProbeImageFile: ProbeImagePath, RootfsProbeOut under /run/carlos-control and DenyEvery: 10s; this body reads nothing new itself; the readers it wires (instanceRegistryHostRuntime, BuildProbeImage, the rootfs probe's output) are decision rows;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 4 and #329 plan 3 Task 5: takes the egress asserter as a parameter, sets it on the production Server literal (Egress) and starts its 30 s Loop beside probeLoop and diskLoop; the literal also names the fixture check ProbeFixturesOK (renamed in plan 2 Task 14). It sets no control drop-in directory: plan 3's ControlDropInDir default (/run/systemd/system.control) was deleted with removeGenControlDropIn in ef38e13b (the P1 EROFS fix), so instance control names systemd's control directory only to read it (TrustedDropinReader). The same four sites (the two exec.CommandContext closures, statfsBytes, the data literal), offsets moved; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Wires root-owned demo config and existing fixed paths into the service.;rev3=census-ruling-region-ha-p3b;basis=Resume root-owned hairpin state before probes/control service work; verify current systemd agent identity and kernel fence/addresses, restore pidfd watch or revoke stale state. Same direct exec/statfs/data sites; indirect inputs are protected root snapshot/state and kernel evidence, never receipt data.;rev3=census-ruling-agent-start-demo-3;basis=Construct the demo snapshot supervisor for configured demo boxes; startup cleanup gates builder readiness. Census read-site delta: unchanged (4).;rev3=census-ruling-gvisor-demos;basis=Require fixed sandbox settings from shared Configure; retain claim handler and legacy-route refusals; preserve egress asserter and revokes for invalid settings and gate only native restart dispatch. Native probe/build/start admission remains refused. Existing root reads unchanged. data-literal@2255,file:CommandContext@1008,file:CommandContext@1186,file:Statfs@2276 5a007c635397921c0c08353e644bc95c90b4a3834742a983c848b6ec3845838d
-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;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Add fixed configured and effective sandbox modes, configuration error and runtime readiness callback. No new path or read. file:Statfs@4123 4f7b68950f5e49b21ed52a7d58e416d90f2e062e4e3c01e44468a2bd87494b98
+internal/instancectl/server.go runWithClaim authority C,D,G Claim instance controller adds held-release RPC dispatch within existing launch/participation execution boundary.;rev3=census-ruling-rootfs-apps-2;basis=takes a RegistryView (HostApp and HostRuntime) for the bare hostApp, and the production Server literal gains HostRuntime, ProbeImage: BuildProbeImage, ProbeImageFile: ProbeImagePath, RootfsProbeOut under /run/carlos-control and DenyEvery: 10s; this body reads nothing new itself; the readers it wires (instanceRegistryHostRuntime, BuildProbeImage, the rootfs probe's output) are decision rows;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 4 and #329 plan 3 Task 5: takes the egress asserter as a parameter, sets it on the production Server literal (Egress) and starts its 30 s Loop beside probeLoop and diskLoop; the literal also names the fixture check ProbeFixturesOK (renamed in plan 2 Task 14). It sets no control drop-in directory: plan 3's ControlDropInDir default (/run/systemd/system.control) was deleted with removeGenControlDropIn in ef38e13b (the P1 EROFS fix), so instance control names systemd's control directory only to read it (TrustedDropinReader). The same four sites (the two exec.CommandContext closures, statfsBytes, the data literal), offsets moved; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Wires root-owned demo config and existing fixed paths into the service.;rev3=census-ruling-region-ha-p3b;basis=Resume root-owned hairpin state before probes/control service work; verify current systemd agent identity and kernel fence/addresses, restore pidfd watch or revoke stale state. Same direct exec/statfs/data sites; indirect inputs are protected root snapshot/state and kernel evidence, never receipt data.;rev3=census-ruling-agent-start-demo-3;basis=Construct the demo snapshot supervisor for configured demo boxes; startup cleanup gates builder readiness. Census read-site delta: unchanged (4).;rev3=census-ruling-gvisor-demos;basis=Retain sandbox modes and error; bind host-provided baseline and runtime callbacks without importing host templates. Existing reads unchanged. data-literal@2323,file:CommandContext@1076,file:CommandContext@1254,file:Statfs@2344 6d9c80b9038fe17e9b1e71188557d0c9e93a5ba6efeaa9566f85bfce1207403b
+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;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 mode/error/readiness fields; add baseline and runtime callbacks. No new direct read. file:Statfs@4202 7d410804e45d30e2d3537eec0d750021c28e129f5be1a472600d3e3f15141790
+system.go runSystem authority B,C,D,F,G,J4 rev3=census-ruling-self-serve-moves-1;identity=explicit operator CLI uid 0;basis=adds the lifetimes family to the system dispatch (carlos system lifetimes cutover, a console door call as the operator); every existing command branch unchanged;rev3=census-ruling-claims-cleanup-r2;basis=claims cleanup R2: drops the claims case (host.RunSystemClaims, deleted); every other branch unchanged; no read added;rev3=census-ruling-nearest-region-a;basis=adds the hosts-used family to the system dispatch (carlos system hosts-used status, one GET of a console door as the operator); every existing command branch unchanged; no read added;rev3=census-ruling-region-ha-p1a;basis=explicit operator CLI and root units, uid 0: drops the "join" case (host.RunSystemJoin, deleted with internal/host/joinroot.go, its only caller) and its line in the usage text; every other branch unchanged; no read added;rev3=census-ruling-named-unit-delivery-114;basis=the system verb dispatch gains named-units, routed to host.RunSystemNamedUnits; no read of its own;rev3=census-ruling-design-pdf-service;basis=add dispatch for carlos system pdf; no new reads;rev3=census-ruling-managed-fleets-2a;basis=Adds managed-fleets operator CLI dispatch; no direct read added; existing root command branches unchanged.;rev3=census-ruling-agent-start-demo-2;basis=system.go:62-66 adds the demos family dispatch to the console-only operator client (system_demos.go:19, system_demos_api.go:23); no direct read added and other root commands are unchanged.;rev3=census-ruling-region-ha-p3b2;basis=Dispatches carlos system group-maintenance {status|permit|revoke|prepare|apply|rollback} to internal/host; no read of its own.;rev3=census-ruling-gvisor-demos;basis=Dispatch fixed runsc-ensure and exec-sandbox-allows-prev system applets; no direct reads. b2d431b47f8d15cd017b8fd7507865f099465973c9f1eef8e5cc0ee6e3d1f588
+system.go systemVerb authority B,C,D,F,G,J4 rev3=census-ruling-self-serve-moves-1;identity=explicit operator CLI uid 0;basis=adds the lifetimes family to the system dispatch (carlos system lifetimes cutover, a console door call as the operator); every existing command branch unchanged;rev3=census-ruling-claims-cleanup-r2;basis=claims cleanup R2: drops "claims" from the verb list, so it now falls to the unknown-verb message; no read added;rev3=census-ruling-nearest-region-a;basis=adds "hosts-used" to the verb list, routed to runSystemHostsUsedVerb; no read added;rev3=census-ruling-region-ha-p1a;basis=explicit operator CLI and root units, uid 0: drops "join" from the verb list, so `carlos system join` now falls to the unknown-verb message; no read added;rev3=census-ruling-named-unit-delivery-114;basis=the known-verb list gains named-units; no read of its own;rev3=census-ruling-design-pdf-service;basis=add recognition for carlos system pdf; no new reads;rev3=census-ruling-managed-fleets-2a;basis=Recognizes managed-fleets as a CLI family; no read added.;rev3=census-ruling-agent-start-demo-2;basis=system.go:43-57 recognizes demos; parsing only, no direct read added.;rev3=census-ruling-region-ha-p3b2;basis=Recognizes group-maintenance as a system verb; parsing only.;rev3=census-ruling-gvisor-demos;basis=Recognize two root sandbox applets; no direct reads. 05f652ae4aa1ba135b6bb0358be5570fe13c74e385609124a66d9947ad1f906b
+internal/execsandbox/file_linux.go checkRunscDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Open and fstat root-owned no-follow runtime directories; require 0755. Paths selected by compiled pin or root-owned installation temp. file:Stat@137 39283ba464884471a3085ea8bbb9260eb7b82c7300444aff12680cbee6018a05
+internal/execsandbox/file_linux.go openCheckedDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Walk absolute clean path from root with O_DIRECTORY/O_NOFOLLOW; fstat each ancestor for root ownership and no non-root write bits. No agent-selected path in production. file:Open@197,file:Openat@458,file:Stat@687 8b45bad16e2732bd7fdfc69a8beb7f4961936cedd7f36ad4d957b02df3e2dddf
+internal/execsandbox/file_linux.go openCheckedFile legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Open leaf relative to checked root-owned parent with O_NOFOLLOW/O_NONBLOCK; fstat regular/single-link/root-owned/mode/size metadata before reading. No symlink traversal. file:Openat@297,file:Stat@524 fedd812d2fa99959f5b58a51ab767935396e922009eae3b5d1f93afd1f872be9
+internal/execsandbox/protocol.go ReadProtocol legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Scan one checked root-owned executable, bounded at 96 MiB, using its fstat size. Fixed staged/prev/restore paths. file:Stat@154 86de5a4136e7566f36ae84d044b78e3a8d05c666b08612c9092868be22db1c71
internal/execsandbox/runsc.lock.json external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Extend the embedded release-20261102.0 pin to exactly the five R-T2 executable members on each Linux platform. Archive SHA512 was verified before extracting the named regular members; freeze each SHA256. Top-level SHA256 still equals runsc. No external runtime read. file:external@0 3a24ba581a95bc8fd8283984b5501f0002daff003e2d8fe90571e150ba15b617
+internal/execsandbox/verifier.go RunscVerifier.verify legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read and hash exactly five pin-selected members; fstat before/after hash; cache by device/inode/size/mtime/ctime and hash. Revalidate metadata and ancestors on every call. file:Stat@477,file:Stat@748 5a9c63db1637659b68a7b1784707a50ee38e7e7ae85f8c71dc250c84e53cfa25
internal/host/execsandbox.go sandboxExecGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read the existing registry route through injected lookup only for gVisor; require the same route admission before BeforeExec. No new path; lookup is the existing registry handle. whole:Route@493,whole:Route@587 e66292565a6718b38622cfbd0747888356fb66fca161d782399067a0db23a1f5
internal/host/execsandbox.go sandboxRouteGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read existing route layout, demo marker and runtime to refuse unsupported or direct gVisor launches before the next config gate. No new path; layout inputs are the backend's existing ones. registry:Runtime@700,whole:Route@432,whole:Route@802 6d3b45864d6e551a523e37dbec39f6d7befd414d02ce6751531ac312c7ec1d67
+internal/host/execsandboxfloor.go checkExecSandboxBaselineAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Lstat journal and guard executable/census/moves paths for absence on every readiness call; compare installed recovery bytes with exact embedded unit. No guard execution or state alteration. file:Lstat@289,file:Lstat@488,file:ReadFile@617 f7e75448f38d25a703aedef82e102da70f8e9e84ce8e6aed98ecfc8a7f86b0c2
+internal/host/execsandboxfloor.go sandboxHostEnvironment legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Reopen fixed root-owned host.env without links, bound bytes at 1 MiB, parse with existing hostenv parser; no inherited values used as authority. file:ReadAll@296 740a2ebf07d90e3f3829361fbf18f24df4d2f73593a8f90b80b8b1a5a78c6705
+internal/host/execsandboxfloor.go verifiedSandboxCandidate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Bounded single read of untrusted cache stream; require signed pointer SHA256 before protocol scan over same immutable byte buffer. No execution or staging mutation. file:ReadAll@125 4a41f564e8d1025a2070bae6d1e301ba48bb44bdbff29184dbb6d545094a9633
+internal/host/runscensure.go installRunscSet legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Check root-owned destination parent; fetch five compiled-pin object keys into exclusive temporary set, bounded hashes and fsync, verify complete set, publish by atomic directory rename/exchange. No unverified executable published. file:Lstat@431,file:Open@1395 5d1264fd744af58eb38a236203fd93b2bfeca2c8fa618fe37089ccbd1b865e14
+internal/host/runscensure.go pruneRunscSets legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read runtime directory only after complete command inventory; retain current/referenced sets and everything on inventory failure; remove only unreferenced 64-hex root-owned set directories. file:ReadDir@232 164a94ccd333048342691664b7a30e8b0f34b7a67d2d0f717498b5cabe41f96b
+internal/host/runscensure.go runscCommandInventory legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Enumerate loaded units, jobs, installed units and checked root-owned installed unit/drop-in files; any failure retains old sets. Reads only fixed systemd roots or checked symlink destinations. file:EvalSymlinks@1559,file:ReadAt@1951,file:Stat@1817,file:WalkDir@1171 bf2d652ffb21a228a6a917b4d5280cbd59c9cddf764e2a2d8ceebaeb8e37697e
+internal/host/runscensure.go runscSystemctl legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Execute systemctl with fixed enumeration/start verbs and root-generated unit names, context bounded. No shell or request-provided executable. file:CommandContext@88 16614091a159f92b0575ac6980a90e468c50936662d6f1016425b4080951468e
+internal/host/runscensure.go wireSandboxReadiness legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read exact embedded recovery unit and bind host baseline plus compiled-pin verification callbacks. No installed unit data enters instancectl imports. file:ReadFile@85 e46e312a601c7e91da51d537c8ebb580c2c59630f8608d5a65da5a4352245c0e
+internal/host/runscset_linux.go openRunscLock legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Open fixed installer lock under checked root runtime directory with O_NOFOLLOW; fstat root owner, single-link regular and private mode before flock. file:Fstat@264,file:Open@64 d44bfa3ce6f1e0bc68c2671ed5604044412de4e6f82b488436d119ee71b81d68
internal/host/units/carlos-demo-build-gvisor@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Add the unarmed root gVisor build skeleton with empty ExecStart, all twelve measured properties, control-group termination and fixed physical budgets. Host LimitFSIZE is omitted by ruling; guest OCI limit remains 33554432 and passed EFBIG measurement. Root prepares validated per-job writable paths, append diagnostics and runtime commands later; template output defaults remain null. file:external@0 8b6f939424c554aaf1e5ed38111ebd0bf67fdcbaaa5bc6415df55affb64ba17a
internal/host/units/carlos-instance-gvisor-probe.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Add the unarmed root gVisor probe skeleton with empty ExecStart, all twelve measured properties, fixed probe data/run paths, append output and mixed kill with SIGCONT. Root command preparation must reset output and bind a fresh nonce before start; full readiness consumer remains a later task. file:external@0 b05d264190ef2172e87e5b2667164f2051e83016695595e32ccbcdce9186eb6b
internal/host/units/carlos-instance-gvisor@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Add the unarmed root gVisor run skeleton with empty ExecStart and all twelve measured host properties. Defines per-instance data/run writable paths and socket output, root runtime directory, mixed kill with SIGCONT, and the existing bounded stop. A root-prepared validated command drop-in is required before it can start; no command or pin placeholder is installed here. file:external@0 914a3c0486d83b6b87ce14c473aab9005ff7bc004cb984040a81ddc60087a5c1
+internal/host/units/carlos-runsc.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Root oneshot reads fixed root-owned host.env through its applet and installs compiled runtime set only under /opt/carlos/runsc; no RemainAfterExit. file:external@0 215ca2aea9519d14d0e20b5f9b6588b43ff7c5ef7b485982274fbbbfe2cf02b5
internal/instanceexec/sandbox_linux.go gvisorProbeChecks legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Preliminary guest-only probe reads the fixed /proc/self/status to check empty capability sets and NoNewPrivs, and SelfCheck opens the fixed own /data/instances/_probe directory with unchanged safe-open flags. Runs as the guest carlos identity; reports readiness incomplete until the later root challenges exist. No tenant-selected host path or root authority is added. Echo CARLOS_GVISOR_PROBE_NONCE from the initial guest environment in the additive omitempty report field; root supplies the challenge in the OCI environment. No new filesystem read or readiness grant. data-literal@696,file:ReadFile@202 b201174cac395aea50cbe7c306859c47a120d1a954d988a43e9746a1386f658a
-@coverage internal/execsandbox 26eb160586c30b71111fff99a1614e58602ab834e12c494a72d2a3eca9e22882
-@coverage internal/host 6c84353dc2f5a136936c4872f2a69454d0f0578fc49583879fe8fa06854e87ae
-@coverage internal/host/units 92f06e9416505a1aa1912fa0bdf0666f3291c0a2c15923efac7e01065883d5e4
-@coverage internal/instancectl b659d8723cb3011984e9de6c4a79f75afaf7dcee5031b4e338742a9400c40c8e
+internal/host/systemapply.go systemApplier.stageCandidate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupStageDigest before staging/candidate execution; action and new digest come from root-owned operator permit bound to boot marker. Existing signed pointer/artifact verification and two direct read sites remain.;rev3=census-ruling-gvisor-demos;basis=Read agent cache once into bounded buffer; signed hash and marker before clearing staging; write those exact bytes durably and check root-owned staged binary before version execution. Removes direct OpenFile site. Retain staging on floor refusal for both apply and install-channel callers; floor authority reopens root-owned host.env by default. file:Stat@697 4d62d6d3fc76650d19493cdecf3a9ce47034ab5b0194fbac796e2773224c50bd
+@coverage . e359ebe397bac9cf64ba77fb85322e55c3409dc5ca63c9a7c1dc51348ca0ade0
+@coverage internal/execsandbox 25dd9c82cb6ff1b682f1acbd921012d8b7ca01ed1b73be91592bf63d04dbca29
+@coverage internal/host 5f87b62537235d16958a6d0f68f12e3fc31f45bdc662749696c171f6bdace336
+@coverage internal/host/units 93402572d2fc9c32b563820a36d565afa2ed951637bde9561fe2e845137a6524
+@coverage internal/instancectl 540d394b34894c830106f093152a449f152a51f6fd422ab9a9595c96a9beef7f
@coverage internal/instanceexec 451a4cb9a8fc078f883afab1c361678185c332a1e294c24420ab4ae2fb3face9
diff --git a/main.go b/main.go
index 5c19f423b..bdd626956 100644
--- a/main.go
+++ b/main.go
@@ -8,11 +8,13 @@ import (
"io"
"log"
"os"
+ "runtime"
"strings"
"github.com/carlosframework/platform/internal/cgroup"
"github.com/carlosframework/platform/internal/democlaim"
"github.com/carlosframework/platform/internal/edge"
+ "github.com/carlosframework/platform/internal/execsandbox"
"github.com/carlosframework/platform/internal/host"
"github.com/carlosframework/platform/internal/instanceexec"
"github.com/carlosframework/platform/internal/rootaws"
@@ -21,6 +23,7 @@ import (
)
func main() {
+ runtime.KeepAlive(execsandbox.ProtocolMarker)
// The placement shim (internal/cgroup, #272) must run before anything
// else touches the environment or the logger: a shim process carries
// none of the tenant's settings and exits from inside this call.
diff --git a/system.go b/system.go
index 6b10ac631..a04fbfab2 100644
--- a/system.go
+++ b/system.go
@@ -53,7 +53,7 @@ func systemVerb(args []string) (verb string, rest []string, component string) {
// untouched in rest for runSystemAntivirusVerb to read.
// layout is a family too: migrate|revert|status stay in rest for
// runSystemLayout.
- case "group-maintenance", "demos", "managed-fleets", "files", "guard-arm", "guard-exec", "journal-migrate", "floor-allows-prev", "update", "status", "rollback", "cancel-activation", "apply", "antivirus", "pdf", "layout", "geoip", "seeds-floor", "legacy-routes", "lifetimes", "hosts-used", "box", "group", "install-channel", "host-env", "db-worker", "named-units", "help", "-h", "--help":
+ case "runsc-ensure", "exec-sandbox-allows-prev", "group-maintenance", "demos", "managed-fleets", "files", "guard-arm", "guard-exec", "journal-migrate", "floor-allows-prev", "update", "status", "rollback", "cancel-activation", "apply", "antivirus", "pdf", "layout", "geoip", "seeds-floor", "legacy-routes", "lifetimes", "hosts-used", "box", "group", "install-channel", "host-env", "db-worker", "named-units", "help", "-h", "--help":
return args[0], args[1:], component
}
return "", args, component
@@ -62,6 +62,10 @@ func systemVerb(args []string) (verb string, rest []string, component string) {
func runSystem(args []string) {
verb, rest, _ := systemVerb(args)
switch verb {
+ case "runsc-ensure":
+ host.RunSystemRunscEnsure(rest)
+ case "exec-sandbox-allows-prev":
+ host.RunSystemExecSandboxAllowsPrev(rest)
case "group-maintenance":
os.Exit(host.RunGroupMaintenance(rest, os.Stdin, os.Stdout, os.Stderr))
case "demos":