carlos / platform Public

gvisor demos: define sandbox contract and fail-closed admission

Co-Authored-By: Astra (gpt-6-astra) via codex
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev d08ab715a5d355c5a2fb62711eb114f93d58708c parent 6418821
22 files changed, +961 −16
  • docs/superpowers/notes/census-proposal-gvisor-demos.md +39 −0
  • internal/execsandbox/contract_test.go +116 −0
  • internal/execsandbox/limits.go +15 −0
  • internal/execsandbox/lock.go +128 −0
  • internal/execsandbox/lock_test.go +68 −0
  • internal/execsandbox/mode.go +78 −0
  • internal/execsandbox/paths.go +13 −0
  • internal/execsandbox/runsc.lock.json +15 −0
  • internal/host/agent.go +6 −1
  • internal/host/claimstop_run.go +12 −3
  • internal/host/claimunit.go +1 −2
  • internal/host/execsandbox.go +81 −0
  • internal/host/execsandbox_test.go +131 −0
  • internal/host/units/carlos-instance-control.service +1 −0
  • internal/instancectl/claim.go +2 −2
  • internal/instancectl/demo_build.go +16 −0
  • internal/instancectl/rootfs.go +4 −0
  • internal/instancectl/sandbox.go +71 −0
  • internal/instancectl/sandbox_test.go +100 −0
  • internal/instancectl/server.go +39 −8
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv +24 −0

CI failed — run details

diff --git a/docs/superpowers/notes/census-proposal-gvisor-demos.md b/docs/superpowers/notes/census-proposal-gvisor-demos.md
new file mode 100644
index 000000000..ff07f82a4
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-gvisor-demos.md
@@ -0,0 +1,39 @@
+# Census approval: gvisor-demos
+
+Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or rejects every change below, 3 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `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/claimstop_run.go` `RunInstanceControl` | body | unchanged (0) | Resolve sandbox before claim assembly; serve legacy cleanup with starts refused for invalid config or unsupported gVisor claims; pass fixed settings to control. No new root read. |
+| `internal/host/claimunit.go` `claimUnitContent` | body | unchanged (1) | Remove conditional host.env injection because the common control unit now includes it on every box. Existing template read unchanged. |
+| `internal/host/units/carlos-instance-control.service` `external` | body | unchanged (1) | Load root-owned /etc/carlos/host.env on ordinary boxes as well as claim/demo boxes so sandbox configuration cannot be ignored. No new agent-writable source or permissions. |
+| `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) | Retain fixed startup sandbox settings; preserve cleanup in gVisor claims refusal; disable native egress restarts and builder construction while sandbox admission is unavailable. Existing source 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. |
+
+Envelopes re-pinned: `internal/execsandbox`, `internal/host`, `internal/host/units`, `internal/instancectl`.
+
+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.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/host/agent.go` `runAgent`: authority, task B,C,D,F. Basis: 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)
+- `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/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/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).
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `internal/execsandbox/runsc.lock.json:external`: reads +file:external; 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
+
+Seal: `b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c` → `218776be89b3c83e9f015c5b52abe79be0be27f102f003387ecc9693e676e05e`.
+
+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/contract_test.go b/internal/execsandbox/contract_test.go
new file mode 100644
index 000000000..33a0b9845
--- /dev/null
+++ b/internal/execsandbox/contract_test.go
@@ -0,0 +1,116 @@
+package execsandbox
+
+import (
+ "fmt"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/cgroup"
+)
+
+func TestParseExecSandbox(t *testing.T) {
+ for _, tc := range []struct {
+ raw string
+ want Configured
+ }{{"", Auto}, {"auto", Auto}, {"systemd", Systemd}, {"gvisor", GVisor}} {
+ got, err := Parse(func(key string) string {
+ if key != "CARLOS_EXEC_SANDBOX" {
+ t.Fatalf("key %q", key)
+ }
+ return tc.raw
+ })
+ if err != nil || got != tc.want {
+ t.Fatalf("%q: %q %v", tc.raw, got, err)
+ }
+ }
+ for _, raw := range []string{" auto", "auto ", "\tgvisor", "gvisor\n", "GVisor", "SYSTEMD", "unknown"} {
+ if _, err := Parse(func(string) string { return raw }); err == nil || !strings.Contains(err.Error(), "EXEC-SANDBOX-CONFIG") {
+ t.Errorf("%q: %v", raw, err)
+ }
+ }
+}
+
+func TestResolveExecSandbox(t *testing.T) {
+ if AutoDemoGVisor {
+ t.Fatal("auto rollout is not authorized")
+ }
+ for _, demo := range []bool{false, true} {
+ for _, on := range []bool{false, true} {
+ for _, configured := range []Configured{Auto, Systemd, GVisor} {
+ want := EffectiveSystemd
+ if configured == GVisor || configured == Auto && demo && on {
+ want = EffectiveGVisor
+ }
+ if got := resolve(configured, demo, on); got != want {
+ t.Errorf("%s/%v/%v: %s", configured, demo, on, got)
+ }
+ }
+ }
+ if Resolve(Auto, demo) != EffectiveSystemd {
+ t.Fatal("shipped auto changed")
+ }
+ }
+}
+
+func TestPhysicalLimits(t *testing.T) {
+ small, _ := cgroup.SizeByName("small")
+ for _, tc := range []struct {
+ tier cgroup.Limit
+ want int64
+ }{{small.Limit, 301989888}, {cgroup.Limit{MemoryMax: 1073741824}, 1107296256}} {
+ before := tc.tier
+ if got := Physical(tc.tier); got.MemoryMax != tc.want {
+ t.Errorf("physical: %+v", got)
+ }
+ if before != tc.tier {
+ t.Fatal("logical limit changed")
+ }
+ if GuestMemoryLimit(tc.tier) != tc.tier.MemoryMax/10*9 {
+ t.Fatal("guest limit rounding")
+ }
+ }
+ if GVisorOverhead != 32<<20 || GVisorTaskOverhead != 64 || PhysicalTasks(256) != 320 || PhysicalTasks(128) != 192 {
+ t.Fatal("overhead")
+ }
+ if got := cgroup.SharesOf(small.Limit); got != (cgroup.Shares{CPUWeight: 50, CPUQuotaPercent: 50, IOWeight: 50}) {
+ t.Fatal(got)
+ }
+}
+
+func TestBundleDir(t *testing.T) {
+ for _, id := range []string{"run-demo.example", "a", "A_1-x.y", strings.Repeat("a", 255)} {
+ if !ValidID(id) || BundleDir(id) != "/run/carlos-control/oci/"+id {
+ t.Errorf("valid id %q", id)
+ }
+ }
+ for _, id := range []string{"", ".", "..", "../x", "/x", "a/b", `a\b`, "a%2fb", " a", "a ", "a\t", "a\n", "-x", "_x", strings.Repeat("a", 256), "é"} {
+ if ValidID(id) || BundleDir(id) != "" {
+ t.Errorf("unsafe id %q", id)
+ }
+ }
+}
+
+func TestAgentLaunchAllowed(t *testing.T) {
+ for _, nested := range []bool{false, true} {
+ for _, demo := range []bool{false, true} {
+ for _, root := range []bool{false, true} {
+ for _, role := range []string{"run", "gen", "seed", "cmd", "tty", "sidecar", "worker", "build", "probe", ""} {
+ for _, runtime := range []string{"", "rootfs-v1", "unknown"} {
+ for _, gen := range []uint64{0, 1} {
+ l := Launch{Nested: nested, Demo: demo, ThroughRoot: root, Role: role, Runtime: runtime, Generation: gen}
+ t.Run(fmt.Sprintf("%v", l), func(t *testing.T) {
+ allowed := nested && demo && root && role == "run" && runtime == "" && gen == 0
+ if err := AgentLaunchAllowed(EffectiveGVisor, l); (err == nil) != allowed {
+ t.Fatalf("allowed=%v: %v", allowed, err)
+ }
+ if err := AgentLaunchAllowed(EffectiveSystemd, l); err != nil {
+ t.Fatal(err)
+ }
+ })
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/internal/execsandbox/limits.go b/internal/execsandbox/limits.go
new file mode 100644
index 000000000..ca3b1d5e7
--- /dev/null
+++ b/internal/execsandbox/limits.go
@@ -0,0 +1,15 @@
+package execsandbox
+
+import "github.com/carlosframework/platform/internal/cgroup"
+
+const GVisorOverhead int64 = 32 << 20
+const GVisorTaskOverhead int64 = 64
+
+// Physical is applied once, only for FamilyGVisor. Shares use the logical tier.
+func Physical(tier cgroup.Limit) cgroup.Limit {
+ tier.MemoryMax += GVisorOverhead
+ return tier
+}
+
+func PhysicalTasks(native int64) int64 { return native + GVisorTaskOverhead }
+func GuestMemoryLimit(tier cgroup.Limit) int64 { return cgroup.HighOf(tier.MemoryMax) }
diff --git a/internal/execsandbox/lock.go b/internal/execsandbox/lock.go
new file mode 100644
index 000000000..494f0a63b
--- /dev/null
+++ b/internal/execsandbox/lock.go
@@ -0,0 +1,128 @@
+package execsandbox
+
+import (
+ "bytes"
+ _ "embed"
+ "encoding/json"
+ "fmt"
+ "io"
+ "regexp"
+ "strings"
+)
+
+//go:embed runsc.lock.json
+var runscLock []byte
+
+type RunscLock struct {
+ Release string `json:"release"`
+ Platforms map[string]RunscPin `json:"platforms"`
+}
+
+type RunscPin struct {
+ TarballURL string `json:"tarball_url"`
+ TarballSHA512 string `json:"tarball_sha512"`
+ SHA256 string `json:"sha256"`
+}
+
+var releaseName = regexp.MustCompile(`^release-[0-9]{8}\.[0-9]+$`)
+
+func LoadRunscLock() (RunscLock, error) { return parseRunscLock(runscLock) }
+
+func parseRunscLock(raw []byte) (RunscLock, error) {
+ var lock RunscLock
+ fail := func() (RunscLock, error) { return RunscLock{}, fmt.Errorf("%w: invalid embedded lock", ErrRunsc) }
+ tokens := json.NewDecoder(bytes.NewReader(raw))
+ if uniqueJSON(tokens, 0) != nil {
+ return fail()
+ }
+ d := json.NewDecoder(bytes.NewReader(raw))
+ d.DisallowUnknownFields()
+ if d.Decode(&lock) != nil || d.Decode(new(any)) != io.EOF || !releaseName.MatchString(lock.Release) || len(lock.Platforms) != 2 {
+ return fail()
+ }
+ for platform, arch := range map[string]string{"linux-arm64": "aarch64", "linux-amd64": "x86_64"} {
+ pin, ok := lock.Platforms[platform]
+ want := "https://storage.googleapis.com/gvisor/releases/release/" + strings.TrimPrefix(lock.Release, "release-") + "/" + arch + "/gvisor.tar.zstd"
+ if !ok || pin.TarballURL != want || !lowerHex(pin.TarballSHA512, 128) || !lowerHex(pin.SHA256, 64) {
+ return fail()
+ }
+ }
+ return lock, nil
+}
+
+// Reject repeated keys and case aliases that encoding/json otherwise accepts.
+func uniqueJSON(d *json.Decoder, depth int) error {
+ token, err := d.Token()
+ if err != nil {
+ return err
+ }
+ delim, ok := token.(json.Delim)
+ if !ok {
+ return nil
+ }
+ if delim != '{' || depth > 2 {
+ return ErrRunsc
+ }
+ allowed := []map[string]bool{
+ {"release": true, "platforms": true},
+ {"linux-arm64": true, "linux-amd64": true},
+ {"tarball_url": true, "tarball_sha512": true, "sha256": true},
+ }[depth]
+ seen := map[string]bool{}
+ for d.More() {
+ if delim == '{' {
+ key, err := d.Token()
+ if err != nil {
+ return err
+ }
+ name, ok := key.(string)
+ if !ok || seen[name] || !allowed[name] {
+ return ErrRunsc
+ }
+ seen[name] = true
+ }
+ if err := uniqueJSON(d, depth+1); err != nil {
+ return err
+ }
+ }
+ _, err = d.Token()
+ return err
+}
+
+func lowerHex(value string, size int) bool {
+ if len(value) != size {
+ return false
+ }
+ for _, c := range value {
+ if !(c >= '0' && c <= '9' || c >= 'a' && c <= 'f') {
+ return false
+ }
+ }
+ return true
+}
+
+func RunscFor(platform string) (RunscPin, error) {
+ lock, err := LoadRunscLock()
+ if err != nil {
+ return RunscPin{}, err
+ }
+ pin, ok := lock.Platforms[platform]
+ if !ok {
+ return RunscPin{}, ErrUnsupported
+ }
+ return pin, nil
+}
+
+func RunscPath(pin RunscPin) string {
+ if !lowerHex(pin.SHA256, 64) {
+ return ""
+ }
+ return "/opt/carlos/runsc/" + pin.SHA256 + "/runsc"
+}
+
+func RunscObjectKey(platform string, pin RunscPin) string {
+ if (platform != "linux-arm64" && platform != "linux-amd64") || !lowerHex(pin.SHA256, 64) {
+ return ""
+ }
+ return "bootstrap/router/runsc-" + pin.SHA256 + "/runsc-" + platform
+}
diff --git a/internal/execsandbox/lock_test.go b/internal/execsandbox/lock_test.go
new file mode 100644
index 000000000..37e427dcd
--- /dev/null
+++ b/internal/execsandbox/lock_test.go
@@ -0,0 +1,68 @@
+package execsandbox
+
+import (
+ "encoding/json"
+ "strings"
+ "testing"
+)
+
+func TestRunscLock(t *testing.T) {
+ const digest = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
+ if got := RunscObjectKey("linux-arm64", RunscPin{SHA256: digest}); got != "bootstrap/router/runsc-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef/runsc-linux-arm64" {
+ t.Fatalf("rev 5.1 object key: %s", got)
+ }
+ lock, err := LoadRunscLock()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if lock.Release != "release-20261102.0" || len(lock.Platforms) != 2 {
+ t.Fatalf("%+v", lock)
+ }
+ for _, platform := range []string{"linux-arm64", "linux-amd64"} {
+ pin, err := RunscFor(platform)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if RunscPath(pin) != "/opt/carlos/runsc/"+pin.SHA256+"/runsc" {
+ t.Fatal("runtime path")
+ }
+ if RunscObjectKey(platform, pin) != "bootstrap/router/runsc-"+pin.SHA256+"/runsc-"+platform {
+ t.Fatal("object key")
+ }
+ }
+ if _, err := RunscFor("darwin-arm64"); err == nil {
+ t.Fatal("unsupported platform")
+ }
+ raw, err := json.Marshal(lock)
+ if err != nil {
+ t.Fatal(err)
+ }
+ base := string(raw)
+ cases := map[string]string{
+ "duplicate platform": strings.Replace(base, `"platforms":{`, `"platforms":{"linux-arm64":{},`, 1),
+ "duplicate field": strings.Replace(base, `"release":`, `"release":"release-20261102.0","release":`, 1),
+ "unknown field": strings.Replace(base, `"release":`, `"extra":true,"release":`, 1),
+ "unknown pin field": strings.Replace(base, `"sha256":`, `"extra":true,"sha256":`, 1),
+ "case alias": strings.Replace(base, `"release":`, `"Release":`, 1),
+ "unknown platform": strings.Replace(base, `"linux-arm64":`, `"freebsd-arm64":`, 1),
+ "uppercase pin field": strings.Replace(base, `"sha256":`, `"SHA256":`, 1),
+ "trailing": base + ` {}`,
+ "http": strings.Replace(base, "https://", "http://", 1),
+ "latest": strings.ReplaceAll(base, "/20261102.0/", "/latest/"),
+ "other release": strings.Replace(base, "/20261102.0/", "/20261101.0/", 1),
+ "short digest": strings.Replace(base, lock.Platforms["linux-arm64"].SHA256, "abc", 1),
+ "uppercase digest": strings.Replace(base, lock.Platforms["linux-arm64"].SHA256, strings.ToUpper(lock.Platforms["linux-arm64"].SHA256), 1),
+ "short archive digest": strings.Replace(base, lock.Platforms["linux-arm64"].TarballSHA512, "abc", 1),
+ "wrong architecture": strings.Replace(base, "/aarch64/", "/x86_64/", 1),
+ }
+ delete(lock.Platforms, "linux-arm64")
+ missing, _ := json.Marshal(lock)
+ cases["missing platform"] = string(missing)
+ for name, raw := range cases {
+ t.Run(name, func(t *testing.T) {
+ if _, err := parseRunscLock([]byte(raw)); err == nil {
+ t.Fatal("accepted invalid lock")
+ }
+ })
+ }
+}
diff --git a/internal/execsandbox/mode.go b/internal/execsandbox/mode.go
new file mode 100644
index 000000000..5e82a90f4
--- /dev/null
+++ b/internal/execsandbox/mode.go
@@ -0,0 +1,78 @@
+// Package execsandbox defines the portable execution sandbox contract.
+package execsandbox
+
+import "errors"
+
+type Configured string
+type Effective string
+type Family string
+
+const (
+ Auto Configured = "auto"
+ Systemd Configured = "systemd"
+ GVisor Configured = "gvisor"
+ EffectiveSystemd Effective = "systemd"
+ EffectiveGVisor Effective = "gvisor"
+ FamilySystemd Family = "systemd"
+ FamilyGVisor Family = "gvisor"
+ // AutoDemoGVisor stays off until the flagship go-live window.
+ AutoDemoGVisor = false
+)
+
+var (
+ ErrConfig = errors.New("EXEC-SANDBOX-CONFIG")
+ ErrRunsc = errors.New("EXEC-SANDBOX-RUNSC")
+ ErrUnsupported = errors.New("EXEC-SANDBOX-UNSUPPORTED")
+ ErrClaims = errors.New("EXEC-SANDBOX-CLAIMS")
+ ErrRole = errors.New("EXEC-SANDBOX-ROLE")
+ ErrRootfs = errors.New("EXEC-SANDBOX-ROOTFS")
+)
+
+func Parse(getenv func(string) string) (Configured, error) {
+ switch Configured(getenv("CARLOS_EXEC_SANDBOX")) {
+ case "", Auto:
+ return Auto, nil
+ case Systemd:
+ return Systemd, nil
+ case GVisor:
+ return GVisor, nil
+ default:
+ return "", ErrConfig
+ }
+}
+
+func Resolve(configured Configured, demoBox bool) Effective {
+ return resolve(configured, demoBox, AutoDemoGVisor)
+}
+
+func resolve(configured Configured, demoBox, autoDemoGVisor bool) Effective {
+ if configured == GVisor || configured == Auto && demoBox && autoDemoGVisor {
+ return EffectiveGVisor
+ }
+ return EffectiveSystemd
+}
+
+type Launch struct {
+ Nested, Demo, ThroughRoot bool
+ Role, Runtime string
+ Generation uint64
+}
+
+func AgentLaunchAllowed(effective Effective, launch Launch) error {
+ if effective == EffectiveSystemd {
+ return nil
+ }
+ if effective != EffectiveGVisor {
+ return ErrConfig
+ }
+ if launch.Runtime != "" {
+ return ErrRootfs
+ }
+ if launch.Role != "run" || launch.Generation != 0 {
+ return ErrRole
+ }
+ if !launch.Nested || !launch.Demo || !launch.ThroughRoot {
+ return ErrUnsupported
+ }
+ return nil
+}
diff --git a/internal/execsandbox/paths.go b/internal/execsandbox/paths.go
new file mode 100644
index 000000000..c1fd606f1
--- /dev/null
+++ b/internal/execsandbox/paths.go
@@ -0,0 +1,13 @@
+package execsandbox
+
+import "regexp"
+
+var validID = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9_.-]{0,254}$`)
+
+func ValidID(id string) bool { return validID.MatchString(id) }
+func BundleDir(id string) string {
+ if !ValidID(id) {
+ return ""
+ }
+ return "/run/carlos-control/oci/" + id
+}
diff --git a/internal/execsandbox/runsc.lock.json b/internal/execsandbox/runsc.lock.json
new file mode 100644
index 000000000..749a17c03
--- /dev/null
+++ b/internal/execsandbox/runsc.lock.json
@@ -0,0 +1,15 @@
+{
+ "platforms": {
+ "linux-amd64": {
+ "sha256": "c5a5a7ba1209b605d08874fdd4429035f95afcb2d482bc95ed3fb13d31a25098",
+ "tarball_sha512": "3c400f72be459b57b99b1c4f69be96bcd67eef3caf2078e595fc98e688b6b9a3af7802646b3dde7da8a9aba96d34f86be303e0430c7868ab2d13becdd403c0c1",
+ "tarball_url": "https://storage.googleapis.com/gvisor/releases/release/20261102.0/x86_64/gvisor.tar.zstd"
+ },
+ "linux-arm64": {
+ "sha256": "cbca2f059fdbfd3563d7d7c10b4d77d534aaaa1f524ddb47d76b36285acc6499",
+ "tarball_sha512": "e829ca32eef36f4e960460a6dcb094d7945ab507e9bfe0275f09467ab9bfeb846528fddfd42349ad64bb4f5b02148e1065c06e573feb8f6a8b3f47efa30a7d2e",
+ "tarball_url": "https://storage.googleapis.com/gvisor/releases/release/20261102.0/aarch64/gvisor.tar.zstd"
+ }
+ },
+ "release": "release-20261102.0"
+}
diff --git a/internal/host/agent.go b/internal/host/agent.go
index 5dd252a99..ad6d47b78 100644
--- a/internal/host/agent.go
+++ b/internal/host/agent.go
@@ -262,6 +262,10 @@ func RunAgent(args []string) {
}
func runAgent(args []string, buildClaims ClaimFactory) {
+ _, sandboxEffective, sandboxErr := execSandboxConfig(os.Getenv)
+ if sandboxErr != nil {
+ log.Printf("agent: %v", sandboxErr)
+ }
agentCtx, cancelAgent := context.WithCancel(context.Background())
defer cancelAgent()
groupBoot, err := loadGroupConfiguration(os.Getenv)
@@ -598,6 +602,7 @@ func runAgent(args []string, buildClaims ClaimFactory) {
Journal: func(host string) bool { return layout.JournalPresent(dd, host) },
Peers: reg.List,
}
+ eb.ConfigGate = sandboxRouteGate(sandboxEffective, sandboxErr, &eb.LayoutFacts, eb.ConfigGate)
// The layout pass is handed this same gate below, so it never makes
// a nested tenant this backend would refuse to start. The gate's
// first question is about this process itself: the probe of design
@@ -700,7 +705,7 @@ func runAgent(args []string, buildClaims ClaimFactory) {
// instance's database, the build state names it, under the lease. A
// store that failed to start refuses every spawn (never "run
// unrecorded"). Set before Start, like Routes.
- svc.BeforeExec = demoPolicyHook(os.Getenv, reg, eb.Control, buildStateHook(bs, bsErr))
+ svc.BeforeExec = sandboxExecGate(sandboxEffective, sandboxErr, reg.Get, eb.ConfigGate, demoPolicyHook(os.Getenv, reg, eb.Control, buildStateHook(bs, bsErr)))
// The held wake check (settings spec §4.3 rule 3): a held instance
// never wakes on an installed build other than its target. The copy
// is refreshed before every wake that could be held (wakeTarget), and
diff --git a/internal/host/claimstop_run.go b/internal/host/claimstop_run.go
index ed7b30a55..6c927b153 100644
--- a/internal/host/claimstop_run.go
+++ b/internal/host/claimstop_run.go
@@ -10,6 +10,7 @@ import (
"time"
"github.com/carlosframework/platform/internal/demo"
+ "github.com/carlosframework/platform/internal/execsandbox"
"github.com/carlosframework/platform/internal/hairpin"
"github.com/carlosframework/platform/internal/hostwrite"
"github.com/carlosframework/platform/internal/instancectl"
@@ -46,10 +47,16 @@ func RunInstanceControl(args []string) {
}
return
}
+ configured, effective, sandboxErr := execSandboxConfig(os.Getenv)
+ sandbox := instancectl.SandboxSettings{Configured: configured, Effective: effective, Err: sandboxErr}
cfg, err := demo.BoxConfig(os.Getenv)
- if err != nil || cfg.BoxMode() && hostwrite.Enabled(os.Getenv) {
+ if err != nil || cfg.BoxMode() && hostwrite.Enabled(os.Getenv) && sandboxErr == nil {
log.Fatal("instance-control: demo box configuration refused")
}
+ if sandboxErr != nil || effective == execsandbox.EffectiveGVisor {
+ instancectl.RunWithRegistryView(args, instancectl.RegistryView{HostApp: instanceRegistryHostApp(nil), HostRuntime: instanceRegistryHostRuntime, HostDemo: instanceRegistryDemo, DemoRoutes: instanceRegistryDemoRoutes, DemoPurgeGuard: instanceDemoPurgeGuard}, nil, sandbox)
+ return
+ }
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if err := registerProductionLaunchVerifier(); err != nil {
@@ -72,7 +79,7 @@ func RunInstanceControl(args []string) {
if !cfg.BoxMode() {
egress = newEgressAsserter(registryEgressSource(dataDir(), time.Now), registryEgressHosts(dataDir()))
}
- instancectl.RunWithRegistryView(args, instancectl.RegistryView{HostApp: instanceRegistryHostApp(nil), HostRuntime: instanceRegistryHostRuntime, HostDemo: instanceRegistryDemo, DemoRoutes: instanceRegistryDemoRoutes, DemoPurgeGuard: instanceDemoPurgeGuard}, egress)
+ instancectl.RunWithRegistryView(args, instancectl.RegistryView{HostApp: instanceRegistryHostApp(nil), HostRuntime: instanceRegistryHostRuntime, HostDemo: instanceRegistryDemo, DemoRoutes: instanceRegistryDemoRoutes, DemoPurgeGuard: instanceDemoPurgeGuard}, egress, sandbox)
return
}
reg, err := openServiceRegistry(filepath.Join(dataDir(), "registry.db"))
@@ -125,7 +132,9 @@ func RunInstanceControl(args []string) {
fenceDone := make(chan struct{})
go func() { defer close(fenceDone); runHostFencePass(ctx) }()
defer func() { cancel(); <-fenceDone }()
- runClaimControl(ctx, args, handler, instancectl.RunWithClaim)
+ runClaimControl(ctx, args, handler, func(args []string, handler, heldRelease http.Handler, hostApp func(string) (string, string, error), egress *instancectl.EgressAsserter) {
+ instancectl.RunWithClaim(args, handler, heldRelease, hostApp, egress, sandbox)
+ })
}
// claimControlRunner is instancectl.RunWithClaim's shape.
diff --git a/internal/host/claimunit.go b/internal/host/claimunit.go
index 3454c189a..397f01b76 100644
--- a/internal/host/claimunit.go
+++ b/internal/host/claimunit.go
@@ -128,7 +128,6 @@ func claimUnitContent(name string, content []byte, cfg claimUnitSettings) []byte
// paths, including on boxes that have never written release state.
content = bytes.Replace(content, []byte("[Service]\n"), []byte("[Service]\nStateDirectory=carlos-release/private\nStateDirectoryMode=0700\n"), 1)
content = bytes.Replace(content, []byte("[Service]\n"), []byte("[Service]\nReadWritePaths=/data /run/carlos/instances /opt/carlos/live /opt/carlos/versions /var/lib/carlos-release/private\n"), 1)
- content = bytes.Replace(content, []byte("[Service]\n"), []byte("[Service]\n"+claimControlEnvironment), 1)
if cfg.demo.BuildWorker {
content = bytes.Replace(content, []byte("[Service]\n"), []byte("[Service]\nStateDirectory=carlos-demo-builds\nStateDirectoryMode=0700\nReadWritePaths=/var/lib/carlos-demo-builds\n"), 1)
content = bytes.Replace(content, []byte("MemoryMax=64M\n"), []byte("MemoryMax=1073741824\nEnvironment=GOMEMLIMIT=768MiB\n"), 1)
@@ -150,7 +149,7 @@ func claimUnitContent(name string, content []byte, cfg claimUnitSettings) []byte
for i, p := range roots {
roots[i] = quote(p)
}
- content = bytes.Replace(content, []byte("[Service]\n"), []byte("[Service]\nStateDirectory=carlos-claims\nStateDirectoryMode=0700\n"+claimControlEnvironment), 1)
+ content = bytes.Replace(content, []byte("[Service]\n"), []byte("[Service]\nStateDirectory=carlos-claims\nStateDirectoryMode=0700\n"), 1)
content = bytes.Replace(content, []byte("ReadWritePaths=/run/carlos-control /run/systemd/system\n"), []byte("ReadWritePaths="+strings.Join(roots, " ")+"\n"), 1)
content = bytes.Replace(content, []byte("RestrictAddressFamilies=AF_UNIX\n"), []byte("RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6\n"), 1)
// Claim mode adds the root journal service, the offline legacy migration
diff --git a/internal/host/execsandbox.go b/internal/host/execsandbox.go
new file mode 100644
index 000000000..d65fd9a39
--- /dev/null
+++ b/internal/host/execsandbox.go
@@ -0,0 +1,81 @@
+package host
+
+import (
+ "context"
+
+ "github.com/carlosframework/platform/internal/activator"
+ "github.com/carlosframework/platform/internal/demo"
+ "github.com/carlosframework/platform/internal/execsandbox"
+ "github.com/carlosframework/platform/internal/hostwrite"
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+func execSandboxConfig(getenv func(string) string) (execsandbox.Configured, execsandbox.Effective, error) {
+ configured, err := execsandbox.Parse(getenv)
+ cfg, demoErr := demo.BoxConfig(getenv)
+ effective := execsandbox.Resolve(configured, cfg.BoxMode())
+ if err != nil {
+ return configured, effective, err
+ }
+ if demoErr != nil {
+ return configured, effective, demoErr
+ }
+ if effective == execsandbox.EffectiveGVisor && hostwrite.Enabled(getenv) {
+ return configured, effective, execsandbox.ErrClaims
+ }
+ if effective == execsandbox.EffectiveGVisor && !cfg.BoxMode() {
+ return configured, effective, execsandbox.ErrUnsupported
+ }
+ return configured, effective, nil
+}
+
+// Classification is the same one the backend uses to choose root or direct exec.
+func sandboxRouteGate(effective execsandbox.Effective, configErr error, facts *activator.LayoutInputs, next func(context.Context, registry.Route) error) func(context.Context, registry.Route) error {
+ return func(ctx context.Context, rt registry.Route) error {
+ if configErr != nil {
+ return configErr
+ }
+ if effective == execsandbox.EffectiveGVisor {
+ nested := false
+ if facts != nil {
+ layout, _ := activator.Classify(rt, *facts)
+ nested = layout == activator.LayoutNested
+ }
+ role := "run"
+ if rt.IsSidecar() {
+ role = "sidecar"
+ }
+ if err := execsandbox.AgentLaunchAllowed(effective, execsandbox.Launch{Nested: nested, ThroughRoot: nested, Demo: rt.IsDemo(), Runtime: rt.Runtime, Role: role}); err != nil {
+ return err
+ }
+ }
+ if next != nil {
+ return next(ctx, rt)
+ }
+ return nil
+ }
+}
+
+func sandboxExecGate(effective execsandbox.Effective, configErr error, lookup func(string) (*registry.Route, error), gate func(context.Context, registry.Route) error, next func(context.Context, string, string) error) func(context.Context, string, string) error {
+ return func(ctx context.Context, host, build string) error {
+ if configErr != nil {
+ return configErr
+ }
+ if effective == execsandbox.EffectiveGVisor {
+ rt, err := lookup(host)
+ if err != nil {
+ return err
+ }
+ if rt == nil || gate == nil {
+ return execsandbox.ErrUnsupported
+ }
+ if err := gate(ctx, *rt); err != nil {
+ return err
+ }
+ }
+ if next != nil {
+ return next(ctx, host, build)
+ }
+ return nil
+ }
+}
diff --git a/internal/host/execsandbox_test.go b/internal/host/execsandbox_test.go
new file mode 100644
index 000000000..9f2e73e9a
--- /dev/null
+++ b/internal/host/execsandbox_test.go
@@ -0,0 +1,131 @@
+package host
+
+import (
+ "context"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/activator"
+ "github.com/carlosframework/platform/internal/demo"
+ "github.com/carlosframework/platform/internal/execsandbox"
+ "github.com/carlosframework/platform/internal/provision"
+ "github.com/carlosframework/platform/internal/registry"
+)
+
+func TestParseExecSandboxHost(t *testing.T) {
+ for _, mode := range []string{"", "auto", "systemd", "gvisor", "bad"} {
+ c, e, err := execSandboxConfig(func(k string) string {
+ if k == "CARLOS_EXEC_SANDBOX" {
+ return mode
+ }
+ return ""
+ })
+ if mode == "bad" {
+ if err == nil || !strings.Contains(err.Error(), "EXEC-SANDBOX-CONFIG") {
+ t.Fatal(err)
+ }
+ continue
+ }
+ if mode == "gvisor" {
+ if err != execsandbox.ErrUnsupported {
+ t.Fatal(err)
+ }
+ if e != execsandbox.EffectiveGVisor {
+ t.Fatal(e)
+ }
+ } else if e != execsandbox.EffectiveSystemd || err != nil {
+ t.Fatalf("%s: %v", e, err)
+ }
+ if mode == "" && c != execsandbox.Auto {
+ t.Fatal(c)
+ }
+ }
+}
+
+func TestSandboxIncompleteAdmissionControlEnvironment(t *testing.T) {
+ raw, err := unitsFS.ReadFile("units/" + claimControlUnit)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, cfg := range []claimUnitSettings{{}, {enabled: true, data: "/data", opt: "/opt/carlos"}, {demo: demo.Config{Account: "demo", Fleet: "dev", Domain: "demo.example"}}} {
+ content := string(claimUnitContent(claimControlUnit, raw, cfg))
+ if strings.Count(content, claimControlEnvironment) != 1 {
+ t.Fatal(content)
+ }
+ }
+}
+
+func TestSandboxIncompleteAdmissionAgent(t *testing.T) {
+ ctx := context.Background()
+ called := 0
+ next := func(context.Context, registry.Route) error { called++; return nil }
+ for _, demoBox := range []bool{false, true} {
+ env := map[string]string{"CARLOS_EXEC_SANDBOX": "invalid"}
+ if demoBox {
+ env["CARLOS_DEMO_BOX"] = "1"
+ env["CARLOS_DEMO_ACCOUNT"] = "demo"
+ env["CARLOS_DEMO_FLEET"] = "dev"
+ env["CARLOS_DEMO_DOMAIN"] = "demo.example"
+ }
+ _, mode, err := execSandboxConfig(func(k string) string { return env[k] })
+ env["CARLOS_EXEC_SANDBOX"] = "systemd"
+ gate := sandboxRouteGate(mode, err, nil, next)
+ if e := gate(ctx, registry.Route{}); e != execsandbox.ErrConfig {
+ t.Fatal(e)
+ }
+ spawn := sandboxExecGate(mode, err, nil, gate, func(context.Context, string, string) error { called++; return nil })
+ if e := spawn(ctx, "demo.example", "v1"); e != execsandbox.ErrConfig {
+ t.Fatal(e)
+ }
+ }
+ if called != 0 {
+ t.Fatal("invalid config reached next gate")
+ }
+ if err := sandboxRouteGate(execsandbox.EffectiveGVisor, nil, nil, next)(ctx, registry.Route{}); err != execsandbox.ErrUnsupported {
+ t.Fatal(err)
+ }
+ if err := sandboxRouteGate(execsandbox.EffectiveSystemd, nil, nil, next)(ctx, registry.Route{}); err != nil || called != 1 {
+ t.Fatalf("systemd: %v %d", err, called)
+ }
+}
+
+func TestSandboxIncompleteAdmissionClaimsConfig(t *testing.T) {
+ env := map[string]string{"CARLOS_EXEC_SANDBOX": "gvisor", "CARLOS_DEMO_BOX": "1", "CARLOS_DEMO_ACCOUNT": "demo", "CARLOS_DEMO_FLEET": "dev", "CARLOS_DEMO_DOMAIN": "demo.example", "CARLOS_HOST_CLAIM": "1"}
+ configured, effective, err := execSandboxConfig(func(k string) string { return env[k] })
+ if configured != execsandbox.GVisor || effective != execsandbox.EffectiveGVisor || err != execsandbox.ErrClaims {
+ t.Fatalf("%s %s %v", configured, effective, err)
+ }
+}
+
+func TestAgentLaunchAllowedHostRoutes(t *testing.T) {
+ facts := activator.LayoutInputs{DataDir: "/data"}
+ base := registry.Route{Host: "demo.example", DemoID: "demo", Hibernate: true, DBPath: provision.NestedDBPath("/data", "demo.example"), Socket: "/run/carlos/instances/demo.example/app.sock"}
+ calls := 0
+ gate := sandboxRouteGate(execsandbox.EffectiveGVisor, nil, &facts, func(context.Context, registry.Route) error { calls++; return nil })
+ for _, tc := range []struct {
+ name string
+ change func(*registry.Route)
+ allowed bool
+ }{
+ {"nested demo", func(*registry.Route) {}, true},
+ {"ordinary", func(r *registry.Route) { r.DemoID = "" }, false},
+ {"rootfs", func(r *registry.Route) { r.Runtime = registry.RuntimeRootfsV1 }, false},
+ {"sidecar", func(r *registry.Route) { r.Kind = "sidecar" }, false},
+ {"flat", func(r *registry.Route) {
+ r.DBPath = provision.DefaultDBPath("/data", r.Host)
+ r.Socket = "/run/carlos/" + r.Host + ".sock"
+ }, false},
+ {"foreign", func(r *registry.Route) { r.Socket = "/somewhere/app.sock" }, false},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ rt := base
+ tc.change(&rt)
+ if err := gate(context.Background(), rt); (err == nil) != tc.allowed {
+ t.Fatalf("allowed=%v: %v", tc.allowed, err)
+ }
+ })
+ }
+ if calls != 1 {
+ t.Fatalf("admitted %d", calls)
+ }
+}
diff --git a/internal/host/units/carlos-instance-control.service b/internal/host/units/carlos-instance-control.service
index e5c385b42..1b48c9d64 100644
--- a/internal/host/units/carlos-instance-control.service
+++ b/internal/host/units/carlos-instance-control.service
@@ -32,6 +32,7 @@ After=data-instances.mount run-carlos-instances.mount run-carlos-logs.mount
After=nftables.service
[Service]
+EnvironmentFile=-/etc/carlos/host.env
ExecStart=/opt/carlos/carlos instance-control
# The edge is ordered After= control (T1/DR-4), so a socket-activated start
# of a dead control queues behind any edge stop job and stalls the agent's
diff --git a/internal/instancectl/claim.go b/internal/instancectl/claim.go
index 5d66fec30..76abfac04 100644
--- a/internal/instancectl/claim.go
+++ b/internal/instancectl/claim.go
@@ -21,8 +21,8 @@ func requestConnContext(ctx context.Context, c net.Conn) context.Context {
// host passes it only with both flags on; nil leaves the route absent).
// egress is as for RunWithRegistry; under claims its source writes no
// allow (ruling 9).
-func RunWithClaim(args []string, handler, heldRelease http.Handler, hostApp func(string) (string, string, error), egress *EgressAsserter) {
+func RunWithClaim(args []string, handler, heldRelease http.Handler, hostApp func(string) (string, string, error), egress *EgressAsserter, sandbox ...SandboxSettings) {
// The claim root reads account and app only: under claim control no
// rootfs unit starts (RFS-2-C06), so the service needs no runtime view.
- runWithClaim(args, handler, heldRelease, RegistryView{HostApp: hostApp}, egress)
+ runWithClaim(args, handler, heldRelease, RegistryView{HostApp: hostApp}, egress, sandbox...)
}
diff --git a/internal/instancectl/demo_build.go b/internal/instancectl/demo_build.go
index f62a35127..aed0daca6 100644
--- a/internal/instancectl/demo_build.go
+++ b/internal/instancectl/demo_build.go
@@ -89,6 +89,9 @@ func (c *Client) DemoBuildReadiness(ctx context.Context) (demobuild.WorkerReady,
func (s *Server) handleDemoBuildReady(w http.ResponseWriter, r *http.Request) {
w.Header().Set(BuildHeader, s.Build)
+ if !s.sandboxHTTP(w, r) {
+ return
+ }
if s.DemoBuilder == nil {
http.Error(w, demobuild.ErrBuild.Error(), http.StatusServiceUnavailable)
return
@@ -110,6 +113,9 @@ func (s *Server) handleDemoBuildReady(w http.ResponseWriter, r *http.Request) {
}
func (s *Server) handleDemoBuild(w http.ResponseWriter, r *http.Request) {
+ if !s.sandboxHTTP(w, r) {
+ return
+ }
if s.DemoBuilder == nil {
http.Error(w, demobuild.ErrBuild.Error(), http.StatusServiceUnavailable)
return
@@ -158,3 +164,13 @@ func (s *Server) handleDemoBuild(w http.ResponseWriter, r *http.Request) {
}
json.NewEncoder(w).Encode(out)
}
+
+func (s *Server) initializeDemoBuilder(ctx context.Context) error {
+ if err := s.sandboxAdmission(ctx); err != nil {
+ return err
+ }
+ if s.DemoBuilder == nil {
+ return demobuild.ErrBuild
+ }
+ return s.DemoBuilder.Initialize(ctx)
+}
diff --git a/internal/instancectl/rootfs.go b/internal/instancectl/rootfs.go
index f804d4efa..693bd0836 100644
--- a/internal/instancectl/rootfs.go
+++ b/internal/instancectl/rootfs.go
@@ -1220,6 +1220,10 @@ func (s *Server) setRootfsReport(r ProbeReport) {
// drop-in: it proves the default (R11). Whatever goes wrong is a failing
// line, so readiness is never the default.
func (s *Server) runRootfsProbe(ctx context.Context) {
+ if err := s.sandboxAdmission(ctx); err != nil {
+ s.setRootfsReport(sandboxReport(err))
+ return
+ }
if s.DemoBox {
s.setRootfsReport(ProbeReport{Lines: []VerdictLine{{Check: "demo", Verdict: "fail", Detail: "DEMO-POLICY"}}})
return
diff --git a/internal/instancectl/sandbox.go b/internal/instancectl/sandbox.go
new file mode 100644
index 000000000..6055ac96d
--- /dev/null
+++ b/internal/instancectl/sandbox.go
@@ -0,0 +1,71 @@
+package instancectl
+
+import (
+ "context"
+ "net/http"
+
+ "github.com/carlosframework/platform/internal/demo"
+ "github.com/carlosframework/platform/internal/execsandbox"
+ "github.com/carlosframework/platform/internal/hostwrite"
+)
+
+// SandboxSettings is captured by the host entry point before claim assembly.
+type SandboxSettings struct {
+ Configured execsandbox.Configured
+ Effective execsandbox.Effective
+ Err error
+}
+
+func sandboxSettings(getenv func(string) string, cfg demo.Config) SandboxSettings {
+ configured, err := execsandbox.Parse(getenv)
+ effective := execsandbox.Resolve(configured, cfg.BoxMode())
+ if err == nil && effective == execsandbox.EffectiveGVisor && hostwrite.Enabled(getenv) {
+ err = execsandbox.ErrClaims
+ }
+ return SandboxSettings{configured, effective, err}
+}
+
+func (s *Server) sandboxAdmission(ctx context.Context) error {
+ if s.SandboxConfigErr != nil {
+ return s.SandboxConfigErr
+ }
+ if s.SandboxEffective == "" || s.SandboxEffective == execsandbox.EffectiveSystemd {
+ return nil
+ }
+ if s.SandboxEffective != execsandbox.EffectiveGVisor {
+ return execsandbox.ErrConfig
+ }
+ if !s.DemoBox {
+ return execsandbox.ErrUnsupported
+ }
+ if s.SandboxReady == nil {
+ return execsandbox.ErrRunsc
+ }
+ return s.SandboxReady(ctx)
+}
+
+func sandboxReport(err error) ProbeReport {
+ return ProbeReport{Lines: []VerdictLine{{Check: "exec-sandbox", Verdict: "fail", Detail: err.Error()}}}
+}
+
+func (s *Server) sandboxHTTP(w http.ResponseWriter, r *http.Request) bool {
+ if err := s.sandboxAdmission(r.Context()); err != nil {
+ http.Error(w, err.Error(), http.StatusServiceUnavailable)
+ return false
+ }
+ return true
+}
+
+func (s *Server) sandboxHandler(next http.Handler) http.Handler {
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.Method == http.MethodPost {
+ switch r.URL.Path {
+ case "/start", "/seed", "/cmd", "/tty", "/claim/launch", "/egress", "/demo-build":
+ if !s.sandboxHTTP(w, r) {
+ return
+ }
+ }
+ }
+ next.ServeHTTP(w, r)
+ })
+}
diff --git a/internal/instancectl/sandbox_test.go b/internal/instancectl/sandbox_test.go
new file mode 100644
index 000000000..2f86a55b4
--- /dev/null
+++ b/internal/instancectl/sandbox_test.go
@@ -0,0 +1,100 @@
+package instancectl
+
+import (
+ "context"
+ "errors"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/demobuild"
+ "github.com/carlosframework/platform/internal/execsandbox"
+)
+
+func TestSandboxIncompleteAdmission(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ mode execsandbox.Effective
+ demo bool
+ configErr error
+ want string
+ }{
+ {"missing runtime", execsandbox.EffectiveGVisor, true, nil, "EXEC-SANDBOX-RUNSC"},
+ {"ordinary box", execsandbox.EffectiveGVisor, false, nil, "EXEC-SANDBOX-UNSUPPORTED"},
+ {"invalid ordinary", execsandbox.EffectiveSystemd, false, errors.New("EXEC-SANDBOX-CONFIG"), "EXEC-SANDBOX-CONFIG"},
+ {"invalid demo", execsandbox.EffectiveSystemd, true, errors.New("EXEC-SANDBOX-CONFIG"), "EXEC-SANDBOX-CONFIG"},
+ {"claims", execsandbox.EffectiveGVisor, true, errors.New("EXEC-SANDBOX-CLAIMS"), "EXEC-SANDBOX-CLAIMS"},
+ } {
+ 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 }}
+ 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", "/egress", "/demo-build"} {
+ w := httptest.NewRecorder()
+ s.Handler().ServeHTTP(w, httptest.NewRequest("POST", path, nil))
+ if w.Code != 503 || !strings.Contains(w.Body.String(), tc.want) {
+ t.Errorf("%s: %d %s", path, w.Code, w.Body.String())
+ }
+ }
+ for _, handler := range []func(http.ResponseWriter, *http.Request){s.handleDemoBuild, s.handleDemoBuildReady} {
+ w := httptest.NewRecorder()
+ handler(w, httptest.NewRequest("POST", "/demo-build", nil))
+ if w.Code != 503 || !strings.Contains(w.Body.String(), tc.want) {
+ t.Errorf("builder admission: %d %s", w.Code, w.Body.String())
+ }
+ }
+ if err := s.initializeDemoBuilder(context.Background()); err == nil || !strings.Contains(err.Error(), tc.want) {
+ t.Fatalf("builder initialization: %v", err)
+ }
+ s.RunProbe(context.Background())
+ s.runRootfsProbe(context.Background())
+ rep, ready := s.Ready()
+ if ready || len(rep.Lines) == 0 || !strings.Contains(rep.Lines[0].Detail, tc.want) {
+ t.Errorf("ready %+v", rep)
+ }
+ if calls != 0 {
+ t.Fatalf("native effects: %d", calls)
+ }
+ for _, path := range []string{"/stop?host=demo.example&role=run", "/reset?host=demo.example&role=run", "/sweep"} {
+ w := httptest.NewRecorder()
+ s.Handler().ServeHTTP(w, httptest.NewRequest("POST", path, nil))
+ if w.Code >= 400 || strings.Contains(w.Body.String(), "EXEC-SANDBOX") {
+ t.Errorf("cleanup blocked: %s", w.Body.String())
+ }
+ }
+ if calls == 0 {
+ t.Fatal("cleanup did not reach systemctl")
+ }
+ })
+ }
+ t.Run("systemd callback unused", func(t *testing.T) {
+ s := &Server{SandboxEffective: execsandbox.EffectiveSystemd, SandboxReady: func(context.Context) error { t.Fatal("systemd asked gvisor readiness"); return nil }}
+ if err := s.sandboxAdmission(context.Background()); err != nil {
+ t.Fatal(err)
+ }
+ })
+ 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") }}
+ if err := s.sandboxAdmission(context.Background()); err == nil || !strings.Contains(err.Error(), "fixture") {
+ t.Fatal(err)
+ }
+ })
+}
+
+type sandboxTestBuilder struct{ called func() }
+
+func (b sandboxTestBuilder) Initialize(context.Context) error { b.called(); return nil }
+func (b sandboxTestBuilder) Readiness(context.Context) (demobuild.WorkerReady, error) {
+ b.called()
+ return demobuild.WorkerReady{}, nil
+}
+func (b sandboxTestBuilder) GrantDeadline([]byte) (time.Time, error) {
+ b.called()
+ return time.Time{}, nil
+}
+func (b sandboxTestBuilder) Build(context.Context, []byte, io.Reader) (demobuild.BuildOutput, error) {
+ b.called()
+ return demobuild.BuildOutput{}, nil
+}
diff --git a/internal/instancectl/server.go b/internal/instancectl/server.go
index 6714a6882..8f1526d5e 100644
--- a/internal/instancectl/server.go
+++ b/internal/instancectl/server.go
@@ -27,6 +27,7 @@ import (
"github.com/carlosframework/platform/internal/controlsock"
"github.com/carlosframework/platform/internal/demo"
"github.com/carlosframework/platform/internal/demobuild"
+ "github.com/carlosframework/platform/internal/execsandbox"
"github.com/carlosframework/platform/internal/hostwrite"
"github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/registry"
@@ -42,6 +43,11 @@ import (
// UnitName/SliceName, and every allowed address comes from the egress
// source; nothing from a request reaches systemctl as a string.
type Server struct {
+ SandboxConfigured execsandbox.Configured
+ SandboxEffective execsandbox.Effective
+ SandboxConfigErr error
+ SandboxReady func(context.Context) error
+
// DemoBox is fixed from root-owned environment at service startup.
DemoBox bool
DemoBuilder demoBuilder
@@ -260,11 +266,11 @@ func RunWithRegistry(args []string, hostApp func(string) (string, string, error)
// registry, and with the egress asserter (#328): the start paths and POST
// /egress assert through it, and its Loop re-asserts every populated host
// slice every 30 s. A nil egress is off.
-func RunWithRegistryView(args []string, view RegistryView, egress *EgressAsserter) {
- runWithClaim(args, nil, nil, view, egress)
+func RunWithRegistryView(args []string, view RegistryView, egress *EgressAsserter, sandbox ...SandboxSettings) {
+ runWithClaim(args, nil, nil, view, egress, sandbox...)
}
-func runWithClaim(args []string, claim, heldRelease http.Handler, view RegistryView, egress *EgressAsserter) {
+func runWithClaim(args []string, claim, heldRelease http.Handler, view RegistryView, egress *EgressAsserter, sandbox ...SandboxSettings) {
fs := flag.NewFlagSet("instance-control", flag.ExitOnError)
fs.Usage = cliflag.Usage(fs, "usage: carlos instance-control (socket-activated by carlos-instance-control.socket)")
_ = fs.Parse(args)
@@ -272,14 +278,21 @@ func runWithClaim(args []string, claim, heldRelease http.Handler, view RegistryV
log.Fatal("instance-control: this is the root service behind carlos-instance-control.socket; it is not for operators")
}
cfg, cfgErr := demo.BoxConfig(os.Getenv)
- if cfgErr != nil || cfg.BoxMode() && hostwrite.Enabled(os.Getenv) {
+ settings := SandboxSettings{}
+ if len(sandbox) > 0 {
+ settings = sandbox[0]
+ } else {
+ settings = sandboxSettings(os.Getenv, cfg)
+ }
+ if cfgErr != nil || cfg.BoxMode() && hostwrite.Enabled(os.Getenv) && settings.Err == nil {
log.Fatal("instance-control: demo box configuration refused")
}
- if cfg.BoxMode() {
+ if cfg.BoxMode() || settings.Err != nil || settings.Effective == execsandbox.EffectiveGVisor {
// Fixed demo unit restrictions need no registry-derived allow or restart sweep.
egress = nil
}
s := &Server{
+ SandboxConfigured: settings.Configured, SandboxEffective: settings.Effective, SandboxConfigErr: settings.Err,
DemoBox: cfg.BoxMode(),
ClaimStop: claim,
ClaimHeldRelease: heldRelease,
@@ -340,7 +353,16 @@ func runWithClaim(args []string, claim, heldRelease http.Handler, view RegistryV
}
s.InspectMountpoints(ctx)
firstProbe := make(chan struct{})
- builder, err := demobuild.NewWorker(os.Getenv, func(ctx context.Context) error {
+ builderEnv := os.Getenv
+ if settings.Err != nil || settings.Effective == execsandbox.EffectiveGVisor {
+ builderEnv = func(k string) string {
+ if k == "CARLOS_DEMO_BUILD_WORKER" {
+ return ""
+ }
+ return os.Getenv(k)
+ }
+ }
+ builder, err := demobuild.NewWorker(builderEnv, func(ctx context.Context) error {
select {
case <-firstProbe:
case <-ctx.Done():
@@ -383,7 +405,7 @@ func (s *Server) Serve(ctx context.Context, ln net.Listener) error {
go func() {
defer close(done)
for {
- if err := s.DemoBuilder.Initialize(ctx); err == nil {
+ if err := s.initializeDemoBuilder(ctx); err == nil {
return
} else {
s.logf("instance-control: demo builder: %v", err)
@@ -526,7 +548,7 @@ func (s *Server) Handler() http.Handler {
mux.HandleFunc("POST /egress", s.handleEgress)
mux.HandleFunc("GET /egress", s.handleEgressStatus)
mux.HandleFunc("GET "+RootfsReadyPath, s.handleReadyRootfs)
- return s.demoHandler(mux)
+ return s.sandboxHandler(s.demoHandler(mux))
}
// handleEgress re-asserts one host's slice now (the agent's nudge after
@@ -1266,6 +1288,9 @@ func (s *Server) handleReady(w http.ResponseWriter, r *http.Request) {
// 6): a caller reading /ready during startup should see why, not a report
// that looks like every check silently passed.
func (s *Server) Ready() (ProbeReport, bool) {
+ if err := s.sandboxAdmission(context.Background()); err != nil {
+ return sandboxReport(err), false
+ }
s.mu.Lock()
rep, probed := s.report, s.probed
s.mu.Unlock()
@@ -1363,6 +1388,12 @@ func (s *Server) probeLoop(ctx context.Context, firstProbe chan<- struct{}) {
// could not be read all leave the box not ready, with the reason on a
// verdict line; readiness is never the default.
func (s *Server) RunProbe(ctx context.Context) {
+ if err := s.sandboxAdmission(ctx); err != nil {
+ s.mu.Lock()
+ s.report, s.probed = sandboxReport(err), true
+ s.mu.Unlock()
+ return
+ }
ctx, unlock, lockErr := hairpinLocked(ctx)
defer unlock()
set := func(r ProbeReport) {
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 78806e37c..30d7f2963 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -128,3 +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 218776be89b3c83e9f015c5b52abe79be0be27f102f003387ecc9693e676e05e
diff --git a/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv b/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv
new file mode 100644
index 000000000..bfa962176
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv
@@ -0,0 +1,24 @@
+# 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.
+# 8 body, 0 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 3 new dispositions: 0 reads re-frozen at their disposition with the claim, 3 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 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 24a87a48463d7f66b86dbce845c4b4616816cf16181852c6b635bb8fba874c7f internal/execsandbox/runsc.lock.json external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Embed verified release-20261102.0 runsc archive and binary digests for both Linux platforms; URLs are immutable upstream HTTPS sources. No external runtime read. file:external@0 ee02ee9a4290bae7bf2a33fd60d1bf07484c75efd5d481c2af50523a374375e8
+@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
+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/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 before claim assembly; serve legacy cleanup with starts refused for invalid config or unsupported gVisor claims; pass fixed settings to control. No new root read. 95d936bd0340a54c55b2fa19cd66f72dcd46d9220653383d0ce8b0f0ccd468c2
+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=Remove conditional host.env injection because the common control unit now includes it on every box. Existing template read unchanged. data-literal@1127 f0638f1d09817a59f7dc8058a3158e4aa5b2cd6e1cbb7fe3d4203abab4addc04
+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 /etc/carlos/host.env on ordinary boxes as well as claim/demo boxes so sandbox configuration cannot be ignored. No new agent-writable source or permissions. file:external@0 c482cd60550eafdc5d37c0d96882e85e33515dd1791e971a6c1ab65b000eeabe
+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=Retain fixed startup sandbox settings; preserve cleanup in gVisor claims refusal; disable native egress restarts and builder construction while sandbox admission is unavailable. Existing source reads unchanged. data-literal@2576,file:CommandContext@1329,file:CommandContext@1507,file:Statfs@2597 a29d6cd24a299daa433a3aeb3a90736d09ffb46ad84154d64a8b29c92d76121c
+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/execsandbox/runsc.lock.json external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Embed verified release-20261102.0 runsc archive and binary digests for both Linux platforms; URLs are immutable upstream HTTPS sources. No external runtime read. file:external@0 ee02ee9a4290bae7bf2a33fd60d1bf07484c75efd5d481c2af50523a374375e8
+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
+@coverage internal/execsandbox 89521b5ee8c6cc353f08679228be7c6eddd624b0f80e1b39542f694ba1a0c897
+@coverage internal/host d5462b0d5649e6e277f12368384cf5f3dd30aa0626f1477585c6494444417862
+@coverage internal/host/units 937fa7f6bc87f9a11ca5b3d5f1baa71ff79bd79fd67a571988abdc8d95b486dc
+@coverage internal/instancectl 8b9b45e0219ead00708ac24d18f81c19aab0c4128bb5f584f703a040506f4bc8