gvisor demos: build offline demos in pinned sandboxes
Co-Authored-By: Astra (gpt-6-astra) via codex
19 files changed,
+1,051
−82
docs/superpowers/notes/census-proposal-gvisor-demos.md+20 −5internal/cgroup/export_role_linux_test.go+12 −0internal/cgroup/role_intention_linux_test.go+21 −14internal/demobuild/gvisor.go+352 −0internal/demobuild/gvisor_test.go+397 −0internal/demobuild/probe.go+1 −1internal/demobuild/purge.go+1 −1internal/demobuild/runner.go+21 −2internal/demobuild/unit.go+115 −18internal/demobuild/unit_test.go+4 −3internal/demobuild/worker.go+42 −22internal/demobuild/worker_test.go+1 −1internal/host/claimunit.go+14 −2internal/host/demo_build_linux_test.go+21 −0internal/instancectl/demo_build.go+0 −3internal/instancectl/demo_build_test.go+1 −1internal/instancectl/server.go+5 −2internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv+22 −6
CI failed — run details
Intent
diff --git a/docs/superpowers/notes/census-proposal-gvisor-demos.md b/docs/superpowers/notes/census-proposal-gvisor-demos.md| index 9579a50ec..3a6258cd7 100644 |
| --- a/docs/superpowers/notes/census-proposal-gvisor-demos.md |
| +++ b/docs/superpowers/notes/census-proposal-gvisor-demos.md |
| @@ -1,6 +1,6 @@ |
| # Census approval: gvisor-demos |
| -Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or rejects every change below, 59 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| +Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or rejects every change below, 60 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| | unit | change | read sites | what changed | |
| |---|---|---|---| |
| @@ -8,11 +8,18 @@ Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or reject |
| | `internal/activator/sidecar_ha.go` `ExecBackend.startHAWorker` | body | unchanged (13) | Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. | |
| | `internal/activator/unitproc.go` `ExecBackend.newUnitProc` | body | unchanged (1) | Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. | |
| | `internal/activator/unitproc.go` `unitProc.Stop` | body | unchanged (2) | Task 5 fix round 2: keep original-run owner stop proof failure latched until a successful plain fenced stop, in the owner Stop path. The foreign-invocation observer again completes from main's existing cgroup evidence after its plain stop attempt. Same control channel and retained unit kind; no new read. | |
| +| `internal/demobuild/purge.go` `Worker.PurgeDemo` | body | unchanged (3) | Task 7: derive the selected build family for existing authenticated job retirement; cleanup proves both named families before any shared mount or bundle removal. Existing marker and scratch reads unchanged. | |
| +| `internal/demobuild/runner.go` `Run` | body | unchanged (1) | Task 7: retain bounded no-follow diagnostics/output reads after termination proof; filter gVisor runtime timestamp lines before returning compiler diagnostics. No new read. | |
| +| `internal/demobuild/unit.go` `Worker.assertUnit` | body | unchanged (1) | Task 7: gVisor branch verifies measured host properties, exact pinned command source/readback, work/cache dependencies, append diagnostics destination, physical budget and byte-identical root-derived bundle/rootfs. Native verification retained. | |
| +| `internal/demobuild/unit.go` `Worker.prepareUnit` | body | unchanged (1) | Task 7: derive family and ID from validated job/attempt; retain validated root extraction and warm overlay. gVisor uses cache-upper/view so mounted-root ownership cannot transfer cache-upper itself; chown only out/tmp/home and mounted cache directories through no-follow descriptors, then write shared OCI bundle/skeleton. No tenant-supplied path or command. | |
| +| `internal/demobuild/unit.go` `emptyBuildCgroup` | body | unchanged (2) | Task 7: retain fixed derived kernel cgroup.events read; reject duplicate or malformed populated fields rather than accepting any populated 0 substring. | |
| +| `internal/demobuild/worker.go` `NewWorker` | body | unchanged (1) | Task 7: capture only fixed policy from the supplied roleBuild callback; readiness remains per-build and during the selected-family probe. Existing root directory checks and lock unchanged. | |
| | `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. Task 5: pass the once-captured sandbox effective mode/config error into ExecBackend, UnitBackend and the immutable Client expectation. Same startup environment/registry reads; swapArming declines gVisor before placement. | |
| | `internal/host/bootstrap.go` `bootstrapWithGroup` | body | unchanged (3) | Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. | |
| | `internal/host/claimactivation_preflight.go` `claimActivationLocalUnits` | body | unchanged (4) | Fix round 1 I2: preserve the existing native preflight skip decision in a named helper for tests; ParseUnitName now returns a distinct discovery kind for gVisor so its leftover drop-ins are not skipped. Same walks and reads, no new paths or native authority. | |
| | `internal/host/claimstop_run.go` `RunInstanceControl` | body | unchanged (0) | Retain Task 1 admission and claim separation; wire host-owned exact recovery baseline and pinned-set verification/retry callbacks. No new direct read. Task 6: In effective gVisor mode serve the cleanup-capable registry-view controller before claim recovery or assembly; preserve the retained Configure error so CLAIMS and invalid config still block launches. No new direct read. | |
| -| `internal/host/claimunit.go` `claimUnitContent` | body | unchanged (1) | Mark only claim/demo renderings explicitly; common host.env remains loaded. Ordinary rendering masks CARLOS_HOST_CLAIM with UnsetEnvironment, removed only for a successfully parsed enabled claim rendering. Existing template read unchanged. | |
| +| `internal/host/claimunit.go` `claimUnitContent` | body | unchanged (1) | Mark only claim/demo renderings explicitly; common host.env remains loaded. Ordinary rendering masks CARLOS_HOST_CLAIM with UnsetEnvironment, removed only for a successfully parsed enabled claim rendering. Existing template read unchanged. Task 7: render aggregate build slice through SlicePropertiesFor using the resolved host mode, with 32 MiB and 64-task gVisor overhead per slot. Existing control permissions unchanged. | |
| +| `internal/host/claimunit.go` `readClaimUnitSettings` | body | unchanged (3) | Task 7: parse CARLOS_EXEC_SANDBOX in the existing host.env reader and resolve fixed mode for installed build-slice budgets. No new file read; invalid values refuse rendering. | |
| | `internal/host/systemapply.go` `systemApplier.install` | body | unchanged (0) | Check staged and previous executable awareness before unit-plan execution. Existing reads unchanged; no unaware prev executes in gvisor mode. | |
| | `internal/host/systemapply.go` `systemApplier.installUnits` | body | unchanged (6) | Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. | |
| | `internal/host/systemapply.go` `systemApplier.restoreFiles` | body | unchanged (1) | Check prev awareness before quiesce/copy/restore and check the copied restore executable before rename. Existing stat unchanged. | |
| @@ -26,7 +33,7 @@ Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or reject |
| | `internal/instancectl/gen.go` `Server.handleParent` | body | unchanged (1) | Validate logical parent input as before, require the demo route in gVisor mode and apply Physical once to the small demo parent. Existing request query read unchanged; shares stay logical. | |
| | `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. Task 6: Effective gVisor refuses ROOTFS explicitly before native/rootfs probe preparation; no fallback. Existing native reads unchanged. | |
| | `internal/instancectl/server.go` `Server.RunProbe` | body | unchanged (1) | Select the fixed root-private probe family and delegate gVisor to its serialized root/guest proof, with no native/rootfs fallback. Task 6 fix round 1: remove mode drain from probe execution (Ready/ReadyDemo only), and let runGVisorProbe atomically publish the report/runtime identity including start lines once. Existing native report read unchanged. | |
| -| `internal/instancectl/server.go` `runWithClaim` | body | unchanged (4) | Retain sandbox modes and error; bind host-provided baseline and runtime callbacks without importing host templates. Existing reads unchanged. Task 6: Capture HostClaims once from ControlConfig/hostwrite.Enabled and set the fixed root-owned bundle discovery directory. Existing command and configuration reads unchanged. | |
| +| `internal/instancectl/server.go` `runWithClaim` | body | unchanged (4) | Retain sandbox modes and error; bind host-provided baseline and runtime callbacks without importing host templates. Existing reads unchanged. Task 6: Capture HostClaims once from ControlConfig/hostwrite.Enabled and set the fixed root-owned bundle discovery directory. Existing command and configuration reads unchanged. Task 7: enable gVisor worker construction through fixed unitFamily(roleBuild); readiness proof rechecks sandbox admission and current Ready without reaching the constructor fatal path for transient refusals. Existing command/config reads unchanged. | |
| | `internal/instancectl/server.go` `type Server` | body | unchanged (1) | Retain Task 1 mode/error/readiness fields, baseline/runtime callbacks, Task 4 per-host validated staged descriptors and root-selected probe nonce. Fix round 1 adds a private writer-operation seam assigned only in package tests, after the unchanged GVisorID admission check; production defaults still call the same checked constructor, WriteRootfs, WriteBundle and verifier. No new direct read or request-controlled callback. Task 5: private injected removal seam for unprivileged tests; production default removes only root-derived bundle and skeleton after both-family proof inside existing start fence. No new request field or agent-selected unit. Task 6: Retain serialized probe nonce, runtime-set identity verifier/token, fixed claims flag, bundle discovery root, and private unprivileged identity seam. No request-controlled callback or path; existing declaration read-site classification unchanged. Task 6 fix round 1: private gvisorProbeTestOps is set only in package tests; production defaults retain all fixed paths and the checked root output opener. No externally supplied callback or new direct read. | |
| | `system.go` `runSystem` | body | unchanged (0) | Dispatch fixed runsc-ensure and exec-sandbox-allows-prev system applets; no direct reads. | |
| | `system.go` `systemVerb` | body | unchanged (0) | Recognize two root sandbox applets; no direct reads. | |
| @@ -64,7 +71,7 @@ Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or reject |
| | `internal/activator/unitproc.go` `ExecBackend.observe` | sites | -registry:Runtime ×2, -whole:Route ×2 | Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. Fix round 2: rootfs log says stop accepted and waits for termination proof; no claim of termination from stop acceptance. Foreign observer uses plain fenced stop with main's existing cgroup evidence. | |
| | `internal/host/systemapply.go` `systemApplier.stageCandidate` | sites | -file:OpenFile | Pass the already-open regular file fstat size to bounded preflight. Allocate payload once at exactly that size, use ReadFull then confirm EOF; hash and scan those same bytes before staging. Root-owned staged target is still checked before execution. Preserve staging on floor refusal for apply/install-channel. | |
| -Envelopes re-pinned: `.`, `internal/activator`, `internal/execsandbox`, `internal/host`, `internal/host/units`, `internal/instancectl`, `internal/instanceexec`. |
| +Envelopes re-pinned: `.`, `internal/activator`, `internal/demobuild`, `internal/execsandbox`, `internal/host`, `internal/host/units`, `internal/instancectl`, `internal/instanceexec`. |
| Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| @@ -74,11 +81,18 @@ Recorded dispositions, which each change must still satisfy: |
| - `internal/activator/sidecar_ha.go` `ExecBackend.startHAWorker`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-s;basis=Require nested HA sidecar shape and closed worker identity environment; prepare and acknowledge sealed secrets before writing the existing run launch file. Start the previously verified staged executable through existing root StartExe, mark uncertain starts for stop proof, and observe the same run unit. No health dial or new root verb. |
| - `internal/activator/unitproc.go` `ExecBackend.newUnitProc`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=returns newUnitProcFor's error alongside the handle; the same one site, no read added |
| - `internal/activator/unitproc.go` `unitProc.Stop`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route |
| +- `internal/demobuild/purge.go` `Worker.PurgeDemo`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads root-owned seen/job-ID marker and scratch existence; checks demo/box/job binding before existing stop/cgroup/unmount cleanup. Fix round 1: also requires the job marker host to match the purge host; no new file reads. |
| +- `internal/demobuild/runner.go` `Run`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Consumes only its private root-prepared invocation, proves stop, then no-follow reads bounded diagnostics/output beneath that job. |
| +- `internal/demobuild/unit.go` `Worker.assertUnit`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads effective sandbox, resource, environment and bind properties; missing or mismatched properties refuse compiler start. |
| +- `internal/demobuild/unit.go` `Worker.prepareUnit`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Cleanup now has its own five-second context; stop, empty-cgroup and unmount gates remain unchanged. |
| +- `internal/demobuild/unit.go` `emptyBuildCgroup`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads only the derived cgroup.events path; absent directory or populated 0 proves termination. |
| +- `internal/demobuild/worker.go` `NewWorker`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Wires existing root-owned recovery into cleanup retry; existing bundle/root reads unchanged.;rev3=census-ruling-agent-start-demo-3;basis=Start with snapshot recovery poisoned; builder readiness stays closed until orphan helper cleanup succeeds. Census read-site delta: unchanged (1). |
| - `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/bootstrap.go` `bootstrapWithGroup`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read. |
| - `internal/host/claimactivation_preflight.go` `claimActivationLocalUnits`: authority, task G. Basis: rev3=PROPOSED-p3;run=22;identity=agent uid carlos; root migration/adopt/control uid 0;basis=refusal-only local named-unit inventory; agent skips only ordinary claim runtime drop-in directories under /run/systemd/system, whose private contents root still inventories and verifies before launch; legacy and named units remain checked |
| - `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/claimunit.go` `readClaimUnitSettings`: authority, task C,E3,G,J4. Basis: rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=retains exact no-census unit settings; a claims-enabled complete census prepares the root-owned retry directory before the hardened controller starts;rev3=census-ruling-agent-start-demo-1;basis=Reads worker/concurrency/toolchain settings from the existing host.env parser; requires box mode and refuses claims coexistence. |
| - `internal/host/systemapply.go` `systemApplier.install`: authority, task F,J4. Basis: rev3=PROPOSED-p3;identity=carlos system apply, root update unit or offline root CLI, uid 0;basis=root verifies staged signature and final locked bounds before rename, then records root accepted floor history only after health succeeds;rev3=census-ruling-region-ha-p1a;basis=root apply, uid 0: comment and error text only around the beginExecutableChange call (the wrapped error now reads "update not begun" instead of "update-begun marker"); the call, its position before the first box-changing step and the deferral on error are unchanged; no read added;rev3=census-ruling-region-ha-p3b;basis=Require groupTarget for the staged new artifact and propagate quiesce refusal before effects. Root-owned operator permit must authorize digest/action/current boot; existing signed image, floor and journal checks remain; no new direct read. |
| - `internal/host/systemapply.go` `systemApplier.installUnits`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded. |
| - `internal/host/systemapply.go` `systemApplier.restoreFiles`: authority, task F,J4. Basis: rev3=PROPOSED-p3;identity=carlos system apply/recover, root systemd units or offline root CLI, uid 0;basis=selects signed prev identity and checks staged restore against both root bounds before rename; version sidecar cannot authorize;rev3=census-ruling-region-ha-p3b;basis=Authorize exact previous artifact before restore, propagate quiesce refusal and remove automatic group units from enable list. Existing signature/floor and staged plan reads remain; indirect permit must be root-owned and bind old digest/current boot. |
| @@ -136,6 +150,7 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - new `internal/activator/backend_rootfs.go:uncertainWorkerProc.Stop`: reads +whole:Route; written legacy, accepted-legacy, frozen |
| - new `internal/activator/sandbox.go:ExecBackend.sandboxLaunch`: reads +registry:Backing, +registry:Runtime, +whole:Route; written legacy, accepted-legacy, frozen |
| - new `internal/activator/sandbox.go:UnitBackend.sandboxLaunch`: reads +registry:Runtime; written legacy, accepted-legacy, frozen |
| +- new `internal/demobuild/gvisor.go:ownBuildDirectories`: reads +file:WalkDir; written legacy, accepted-legacy, frozen |
| - new `internal/execsandbox/cleanup_linux.go:bundleStore.removeDirectory`: reads +file:Lstat, +file:OpenRoot, +file:Stat ×2; written legacy, accepted-legacy, frozen |
| - new `internal/execsandbox/file_linux.go:checkRunscDir`: reads +file:Stat; written legacy, accepted-legacy, frozen |
| - new `internal/execsandbox/file_linux.go:openCheckedDir`: reads +file:Open, +file:Openat, +file:Stat; written legacy, accepted-legacy, frozen |
| @@ -192,6 +207,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - reads `internal/activator/cmdunit.go:cmdUnit.StopAndSettle`: +registry:Runtime ×2, +whole:Route ×2; keeps legacy, task accepted-legacy |
| - reads `internal/activator/unitproc.go:unitProc.stopUnit`: +registry:Runtime ×2, +whole:Route; keeps legacy, task accepted-legacy |
| -Seal: `b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c` → `ba1df741e686c684a41c8ac7ba9edc1c2690346276423e7376b144a033d09687`. |
| +Seal: `b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c` → `5706d5ec40dfe497b0eae7933135ef9ff9f89025c58b4721ed576516cc3ceb7a`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/cgroup/export_role_linux_test.go b/internal/cgroup/export_role_linux_test.go| new file mode 100644 |
| index 000000000..d7d831c95 |
| --- /dev/null |
| +++ b/internal/cgroup/export_role_linux_test.go |
| @@ -0,0 +1,12 @@ |
| +//go:build linux |
| + |
| +package cgroup |
| + |
| +import "testing" |
| + |
| +// The journal integration lives in cgroup_test to avoid importing packages |
| +// that depend on cgroup back into its internal test package. |
| +func StrictRoleFixture(t *testing.T) (*Prepared, string, string) { |
| + p := strictFixture(t) |
| + return p, p.root.Name(), p.host |
| +} |
diff --git a/internal/cgroup/role_intention_linux_test.go b/internal/cgroup/role_intention_linux_test.go| index d8e654c5e..111cdad4b 100644 |
| --- a/internal/cgroup/role_intention_linux_test.go |
| +++ b/internal/cgroup/role_intention_linux_test.go |
| @@ -1,13 +1,15 @@ |
| //go:build linux |
| -package cgroup |
| +package cgroup_test |
| import ( |
| "errors" |
| "os" |
| "path/filepath" |
| + "syscall" |
| "testing" |
| + "github.com/carlosframework/platform/internal/cgroup" |
| "github.com/carlosframework/platform/internal/hostbox" |
| "github.com/carlosframework/platform/internal/hostguard" |
| ) |
| @@ -16,15 +18,19 @@ import ( |
| // fails after the actual mkdir and before a launch reservation can be written. |
| func TestLaunchChildFailureBeforeReservationSettlesAndRetries(t *testing.T) { |
| ctx := t.Context() |
| - p := strictFixture(t) |
| + p, root, host := cgroup.StrictRoleFixture(t) |
| journalPath := filepath.Join(t.TempDir(), "launch.db") |
| j, err := hostbox.OpenLaunchJournal(journalPath) |
| if err != nil { |
| t.Fatal(err) |
| } |
| defer func() { j.Close() }() |
| - target := hostguard.FenceTarget{Host: p.host, Incarnation: "inc", Stamp: 1, Session: 1, Box: "box", Enrollment: "enroll", BootID: "boot", ControllerID: "ctrl"} |
| - parent := hostbox.LaunchGroup{RelativePath: ExecName(p.host), Device: p.identity.device, Inode: p.identity.inode} |
| + target := hostguard.FenceTarget{Host: host, Incarnation: "inc", Stamp: 1, Session: 1, Box: "box", Enrollment: "enroll", BootID: "boot", ControllerID: "ctrl"} |
| + identity, err := p.Identity() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + parent := hostbox.LaunchGroup{RelativePath: cgroup.ExecName(host), Device: identity.Device, Inode: identity.Inode} |
| if err := j.Prelaunch(ctx, hostbox.LaunchInventory{Target: target, ControllerPID: 42, ProcessStart: "start", Groups: []hostbox.LaunchGroup{parent}, NoState: true}); err != nil { |
| t.Fatal(err) |
| } |
| @@ -32,9 +38,9 @@ func TestLaunchChildFailureBeforeReservationSettlesAndRetries(t *testing.T) { |
| return hostbox.LaunchReservation{Target: target, ID: name, Role: "main", InvocationID: name, Inputs: "inputs", Parent: parent, Group: hostbox.LaunchGroup{RelativePath: filepath.Join(parent.RelativePath, "role-"+name), InvocationID: name}, Executable: hostbox.LaunchFile{Device: 1, Inode: 2}} |
| } |
| r := reservation("first") |
| - childPath := filepath.Join(p.root.Name(), r.Group.RelativePath) |
| + childPath := filepath.Join(root, r.Group.RelativePath) |
| called := false |
| - child, err := p.PrepareRoleChildWithIntent("first", func(id ContainmentIdentity) error { |
| + child, err := p.PrepareRoleChildWithIntent("first", func(id cgroup.ContainmentIdentity) error { |
| called = true |
| if id.Device != parent.Device || id.Inode != parent.Inode { |
| t.Fatal("wrong parent") |
| @@ -70,13 +76,13 @@ func TestLaunchChildFailureBeforeReservationSettlesAndRetries(t *testing.T) { |
| if err := os.WriteFile(filepath.Join(childPath, "cgroup.events"), []byte("populated 1\n"), 0600); err != nil { |
| t.Fatal(err) |
| } |
| - if err := j.ResolveRoleIntentions(ctx, target, p.root.Name(), false); err == nil { |
| + if err := j.ResolveRoleIntentions(ctx, target, root, false); err == nil { |
| t.Fatal("populated child accepted") |
| } |
| if err := os.WriteFile(filepath.Join(childPath, "cgroup.events"), []byte("populated 0\n"), 0600); err != nil { |
| t.Fatal(err) |
| } |
| - if err := j.ResolveRoleIntentions(ctx, target, p.root.Name(), false); err != nil { |
| + if err := j.ResolveRoleIntentions(ctx, target, root, false); err != nil { |
| t.Fatal(err) |
| } |
| stop, err = j.ReadStopKernelJournal(ctx, target) |
| @@ -88,7 +94,7 @@ func TestLaunchChildFailureBeforeReservationSettlesAndRetries(t *testing.T) { |
| if err := j.IntendRole(ctx, next); err != nil { |
| t.Fatal(err) |
| } |
| - nextPath := filepath.Join(p.root.Name(), next.Group.RelativePath) |
| + nextPath := filepath.Join(root, next.Group.RelativePath) |
| if err := os.Mkdir(nextPath, 0700); err != nil { |
| t.Fatal(err) |
| } |
| @@ -96,12 +102,13 @@ func TestLaunchChildFailureBeforeReservationSettlesAndRetries(t *testing.T) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - id, err := strictID(f) |
| + info, err := f.Stat() |
| f.Close() |
| if err != nil { |
| t.Fatal(err) |
| } |
| - next.Group.Device, next.Group.Inode = id.device, id.inode |
| + id := info.Sys().(*syscall.Stat_t) |
| + next.Group.Device, next.Group.Inode = uint64(id.Dev), id.Ino |
| if err := j.Reserve(ctx, next); err != nil { |
| t.Fatal("retry reservation failed", err) |
| } |
| @@ -112,13 +119,13 @@ func TestLaunchChildFailureBeforeReservationSettlesAndRetries(t *testing.T) { |
| } |
| func TestLaunchChildIntentionFailureCreatesNothing(t *testing.T) { |
| - p := strictFixture(t) |
| + p, root, host := cgroup.StrictRoleFixture(t) |
| failure := errors.New("journal unavailable") |
| - _, err := p.PrepareRoleChildWithIntent("first", func(ContainmentIdentity) error { return failure }) |
| + _, err := p.PrepareRoleChildWithIntent("first", func(cgroup.ContainmentIdentity) error { return failure }) |
| if !errors.Is(err, failure) { |
| t.Fatal(err) |
| } |
| - if _, err := os.Stat(filepath.Join(p.dir.Name(), "role-first")); !errors.Is(err, os.ErrNotExist) { |
| + if _, err := os.Stat(filepath.Join(root, cgroup.ExecName(host), "role-first")); !errors.Is(err, os.ErrNotExist) { |
| t.Fatalf("child created before durable intention: %v", err) |
| } |
| } |
diff --git a/internal/demobuild/gvisor.go b/internal/demobuild/gvisor.go| new file mode 100644 |
| index 000000000..c17122681 |
| --- /dev/null |
| +++ b/internal/demobuild/gvisor.go |
| @@ -0,0 +1,352 @@ |
| +package demobuild |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "io/fs" |
| + "os" |
| + "path/filepath" |
| + "runtime" |
| + "slices" |
| + "strings" |
| + |
| + "github.com/carlosframework/platform/internal/execsandbox" |
| + "github.com/carlosframework/platform/internal/instancefs" |
| +) |
| + |
| +func (w *Worker) buildMountLayout(l buildLayout) (execsandbox.MountLayout, error) { |
| + expected, err := layoutFor(w.root, l.dir, execsandbox.FamilyGVisor) |
| + if err != nil || expected != l { |
| + return execsandbox.MountLayout{}, ErrBuild |
| + } |
| + binds := []execsandbox.BindMount{{Destination: "/opt/carlos/demo-toolchain", Source: w.cfg.ToolchainDir, ReadOnly: true}, {Destination: "/work/src", Source: l.work + "/src", ReadOnly: true}} |
| + for _, name := range []string{"out", "tmp", "home", "cache"} { |
| + binds = append(binds, execsandbox.BindMount{Destination: "/work/" + name, Source: l.work + "/" + name}) |
| + } |
| + return execsandbox.NewMountLayout(binds) |
| +} |
| + |
| +func (w *Worker) gvisorBuildBundle(l buildLayout) ([]byte, error) { |
| + mounts, err := w.buildMountLayout(l) |
| + if err != nil { |
| + return nil, err |
| + } |
| + mask := uint32(0077) |
| + spec := execsandbox.Spec{Version: "1.0.2", Root: execsandbox.Root{Path: execsandbox.RootfsDir(l.id), Readonly: true}, Mounts: mounts.Mounts, Linux: execsandbox.Linux{Namespaces: execsandbox.PrivateNamespaces()}, Process: execsandbox.Process{ |
| + User: execsandbox.User{UID: 65534, GID: 65534, AdditionalGids: []uint32{}, Umask: &mask}, |
| + Args: []string{"/opt/carlos/demo-toolchain/bin/go", "build", "-mod=readonly", "-trimpath", "-buildvcs=false", "-o", "/work/out/app", "."}, |
| + Env: append(BuildEnvironment(), "GOMEMLIMIT=966367638"), Cwd: "/work/src", Capabilities: execsandbox.EmptyCapabilities(), NoNewPrivileges: true, |
| + Rlimits: []execsandbox.Rlimit{{Type: "RLIMIT_FSIZE", Soft: 33554432, Hard: 33554432}}, |
| + }} |
| + return json.Marshal(spec) |
| +} |
| + |
| +func (w *Worker) writeGVisorBuildBundle(l buildLayout) error { |
| + mounts, err := w.buildMountLayout(l) |
| + if err != nil { |
| + return err |
| + } |
| + raw, err := w.gvisorBuildBundle(l) |
| + if err != nil { |
| + return err |
| + } |
| + if err = execsandbox.WriteRootfs(l.id, mounts); err != nil { |
| + return err |
| + } |
| + return execsandbox.WriteBundle(l.id, raw) |
| +} |
| + |
| +// Only directories in the mounted view receive guest ownership. Never walk the |
| +// backing trees or chown cache files: doing so would copy the warm cache up. |
| +func ownBuildDirectories(l buildLayout, chown func(*os.File, int, int) error) error { |
| + own := func(path string) error { |
| + f, err := instancefs.OpenDirBeneath(l.work, strings.TrimPrefix(path, l.work+"/")) |
| + if err != nil { |
| + return err |
| + } |
| + defer f.Close() |
| + if err = chown(f, 65534, 65534); err != nil { |
| + return err |
| + } |
| + return f.Chmod(0700) |
| + } |
| + for _, name := range []string{"out", "tmp", "home"} { |
| + if err := own(filepath.Join(l.work, name)); err != nil { |
| + return err |
| + } |
| + } |
| + return filepath.WalkDir(l.cache, func(path string, d fs.DirEntry, err error) error { |
| + if err != nil { |
| + return err |
| + } |
| + if d.Type()&os.ModeSymlink != 0 { |
| + return ErrBuild |
| + } |
| + if d.IsDir() { |
| + return own(path) |
| + } |
| + return nil |
| + }) |
| +} |
| + |
| +type buildCommand struct { |
| + args []string |
| + ignore bool |
| +} |
| + |
| +func gvisorBuildCommands(l buildLayout) (map[string][]buildCommand, error) { |
| + pin, err := execsandbox.RunscFor(runtime.GOOS + "-" + runtime.GOARCH) |
| + if err != nil { |
| + return nil, err |
| + } |
| + path := execsandbox.RunscPath(pin) |
| + if path == "" || !execsandbox.ValidID(l.id) { |
| + return nil, ErrBuild |
| + } |
| + return map[string][]buildCommand{ |
| + "ExecStartPre": {{[]string{path, "--root=/run/carlos-runsc", "delete", "-force", l.id}, true}}, |
| + "ExecStart": {{[]string{path, "--root=/run/carlos-runsc", "--ignore-cgroups", "--network=none", "--host-uds=create", "--overlay2=none", "run", "--bundle", execsandbox.BundleDir(l.id), l.id}, false}}, |
| + "ExecStopPost": {{[]string{path, "--root=/run/carlos-runsc", "delete", "-force", l.id}, true}}, |
| + }, nil |
| +} |
| + |
| +var buildCommandKeys = []string{"ExecCondition", "ExecStartPre", "ExecStart", "ExecStartPost", "ExecReload", "ExecStop", "ExecStopPost"} |
| + |
| +func buildCommandLine(c buildCommand) string { |
| + prefix := "" |
| + if c.ignore { |
| + prefix = "-" |
| + } |
| + return prefix + strings.Join(c.args, " ") |
| +} |
| +func gvisorBuildDropIn(l buildLayout) (string, error) { |
| + commands, err := gvisorBuildCommands(l) |
| + if err != nil { |
| + return "", err |
| + } |
| + var b strings.Builder |
| + fmt.Fprintf(&b, "[Unit]\nBindsTo=%s %s carlos-instance-control.service\nAfter=%s %s carlos-instance-control.service\n[Service]\nStandardOutput=append:%s/diagnostics\nStandardError=inherit\nReadWritePaths=%s/out %s/tmp %s/home %s/cache\n", l.workMount, l.cacheMount, l.workMount, l.cacheMount, l.work, l.work, l.work, l.work, l.work) |
| + for _, key := range buildCommandKeys { |
| + fmt.Fprintf(&b, "%s=\n", key) |
| + for _, cmd := range commands[key] { |
| + fmt.Fprintf(&b, "%s=%s\n", key, buildCommandLine(cmd)) |
| + } |
| + } |
| + return b.String(), nil |
| +} |
| + |
| +func gvisorBuildProperties(l buildLayout) map[string]string { |
| + p := execsandbox.GVisorHardening() |
| + for key, value := range map[string]string{ |
| + "Type": "exec", "RemainAfterExit": "yes", "User": "root", "Group": "root", "DynamicUser": "no", "Restart": "no", "KillMode": "control-group", "RuntimeMaxUSec": "3min", "TimeoutStopUSec": "5s", "SendSIGKILL": "yes", "OOMPolicy": "kill", |
| + "MemoryMax": "1107296256", "MemoryHigh": "996566625", "MemorySwapMax": "0", "TasksMax": "192", "CPUQuotaPerSecUSec": "500ms", "CPUWeight": "10", "LimitFSIZE": "infinity", "LimitFSIZESoft": "infinity", "UMask": "0077", |
| + "Slice": "carlos-demo-builds.slice", "StandardInput": "null", "StandardOutput": "append", "StandardError": "inherit", "RuntimeDirectory": "carlos-runsc", "RuntimeDirectoryMode": "0700", "RuntimeDirectoryPreserve": "yes", "NeedDaemonReload": "no", |
| + "BindPaths": "", "BindReadOnlyPaths": "", "RootDirectory": "", "RootImage": "", |
| + } { |
| + p[key] = value |
| + } |
| + return p |
| +} |
| + |
| +func (w *Worker) assertGVisorBuildUnit(ctx context.Context, l buildLayout) error { |
| + want := gvisorBuildProperties(l) |
| + keys := append([]string{}, buildCommandKeys...) |
| + keys = append(keys, "BindsTo", "After", "ReadWritePaths") |
| + for key := range want { |
| + keys = append(keys, key) |
| + } |
| + out, err := systemctl(ctx, "show", l.unit, "-p", strings.Join(keys, ",")) |
| + if err != nil { |
| + return err |
| + } |
| + if err = gvisorBuildShown(out, l); err != nil { |
| + return err |
| + } |
| + source, err := systemctl(ctx, "cat", "--no-pager", l.unit) |
| + if err != nil { |
| + return err |
| + } |
| + if err = gvisorBuildSource(source, l); err != nil { |
| + return err |
| + } |
| + raw, err := execsandbox.ReadBundle(l.id) |
| + if err != nil { |
| + return err |
| + } |
| + expected, err := w.gvisorBuildBundle(l) |
| + if err != nil { |
| + return err |
| + } |
| + if err = execsandbox.CompareBundle(raw, expected); err != nil { |
| + return err |
| + } |
| + mounts, err := w.buildMountLayout(l) |
| + if err != nil { |
| + return err |
| + } |
| + return execsandbox.VerifyRootfs(l.id, mounts) |
| +} |
| + |
| +func gvisorBuildShown(out string, l buildLayout) error { |
| + got := map[string]string{} |
| + for _, line := range strings.Split(out, "\n") { |
| + key, value, ok := strings.Cut(line, "=") |
| + if !ok { |
| + continue |
| + } |
| + if _, present := got[key]; present { |
| + return ErrBuild |
| + } |
| + got[key] = value |
| + } |
| + for key, want := range gvisorBuildProperties(l) { |
| + value, ok := got[key] |
| + if !ok || value != want { |
| + return ErrBuild |
| + } |
| + } |
| + for _, key := range []string{"BindsTo", "After"} { |
| + for _, unit := range []string{l.workMount, l.cacheMount, "carlos-instance-control.service"} { |
| + if !containsField(got[key], unit) { |
| + return ErrBuild |
| + } |
| + } |
| + } |
| + if !sameBuildFields(got["ReadWritePaths"], []string{"/run/carlos-runsc", l.work + "/out", l.work + "/tmp", l.work + "/home", l.cache}) { |
| + return ErrBuild |
| + } |
| + commands, err := gvisorBuildCommands(l) |
| + if err != nil { |
| + return err |
| + } |
| + for _, key := range buildCommandKeys { |
| + raw, present := got[key] |
| + if !present { |
| + return ErrBuild |
| + } |
| + for _, cmd := range commands[key] { |
| + ignore := "no" |
| + if cmd.ignore { |
| + ignore = "yes" |
| + } |
| + prefix := "{ path=" + cmd.args[0] + " ; argv[]=" + strings.Join(cmd.args, " ") + " ; ignore_errors=" + ignore + " ; " |
| + if !strings.HasPrefix(raw, prefix) { |
| + return ErrBuild |
| + } |
| + end := strings.Index(raw[len(prefix):], " }") |
| + if end < 0 { |
| + return ErrBuild |
| + } |
| + raw = strings.TrimSpace(raw[len(prefix)+end+2:]) |
| + } |
| + if raw != "" { |
| + return ErrBuild |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// Check exact source arguments too: systemctl's argv display loses quoting. |
| +// StandardOutput's filename is available only in the unit source on systemd 257. |
| +func gvisorBuildSource(source string, l buildLayout) error { |
| + commands, err := gvisorBuildCommands(l) |
| + if err != nil { |
| + return err |
| + } |
| + actual := map[string][]string{} |
| + output, section := "", "" |
| + for _, line := range strings.Split(source, "\n") { |
| + line = strings.TrimSpace(line) |
| + if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, ";") { |
| + continue |
| + } |
| + if strings.HasSuffix(line, "\\") || strings.HasPrefix(line, ".include") { |
| + return ErrBuild |
| + } |
| + if strings.HasPrefix(line, "[") { |
| + section = line |
| + continue |
| + } |
| + key, value, ok := strings.Cut(line, "=") |
| + if !ok || section != "[Service]" { |
| + continue |
| + } |
| + key = strings.TrimSpace(key) |
| + value = strings.TrimSpace(value) |
| + if key == "StandardOutput" { |
| + output = value |
| + } |
| + if strings.HasPrefix(key, "Exec") { |
| + if value == "" { |
| + actual[key] = nil |
| + } else { |
| + actual[key] = append(actual[key], value) |
| + } |
| + } |
| + } |
| + if output != "append:"+l.work+"/diagnostics" { |
| + return ErrBuild |
| + } |
| + for _, key := range buildCommandKeys { |
| + var expected []string |
| + for _, cmd := range commands[key] { |
| + expected = append(expected, buildCommandLine(cmd)) |
| + } |
| + if !slices.Equal(actual[key], expected) { |
| + return ErrBuild |
| + } |
| + delete(actual, key) |
| + } |
| + if len(actual) != 0 { |
| + return ErrBuild |
| + } |
| + return nil |
| +} |
| +func sameBuildFields(raw string, want []string) bool { |
| + got := strings.Fields(raw) |
| + if len(got) != len(want) { |
| + return false |
| + } |
| + for _, value := range want { |
| + if slices.Index(got, value) < 0 { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| + |
| +// Runtime log timestamps resemble file:line records. Keep compiler source |
| +// records only, and retain the original raw-byte truncation signal. |
| +func trimGVisorBuildDiagnostics(raw []byte) ([]Diagnostic, bool) { |
| + cut := len(raw) > diagnosticRawMax |
| + if cut { |
| + raw = raw[:diagnosticRawMax] |
| + if end := strings.LastIndexByte(string(raw), '\n'); end >= 0 { |
| + raw = raw[:end] |
| + } else { |
| + return nil, true |
| + } |
| + } |
| + var compiler strings.Builder |
| + for _, line := range strings.Split(string(raw), "\n") { |
| + file, _, ok := strings.Cut(line, ":") |
| + if ok && (strings.HasSuffix(file, ".go") || file == "go.mod" || file == "go.sum") { |
| + compiler.WriteString(line) |
| + compiler.WriteByte('\n') |
| + } |
| + } |
| + diagnostics, trimmed := TrimDiagnosticsWithStatus([]byte(compiler.String())) |
| + return diagnostics, cut || trimmed |
| +} |
| + |
| +// Overlay root attributes belong to the actual upper directory. Keep that |
| +// directory inside a root-owned wrapper so chown of the mounted view cannot |
| +// transfer ownership of cache-upper itself. |
| +func cacheUpperDir(l buildLayout) string { |
| + upper := l.work + "/cache-upper" |
| + if l.family == execsandbox.FamilyGVisor { |
| + upper += "/view" |
| + } |
| + return upper |
| +} |
diff --git a/internal/demobuild/gvisor_test.go b/internal/demobuild/gvisor_test.go| new file mode 100644 |
| index 000000000..42c7b4c9d |
| --- /dev/null |
| +++ b/internal/demobuild/gvisor_test.go |
| @@ -0,0 +1,397 @@ |
| +//go:build linux |
| + |
| +package demobuild |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "os" |
| + "path/filepath" |
| + "reflect" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/execsandbox" |
| +) |
| + |
| +func TestGVisorBuildBundle(t *testing.T) { |
| + w, j, _, _ := workerFixture(t) |
| + w.cfg.ToolchainDir = "/opt/carlos/demo-toolchain" |
| + l, err := layoutFor(w.root, filepath.Join(w.root, j.ID, "1"), execsandbox.FamilyGVisor) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, err := w.gvisorBuildBundle(l) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var s execsandbox.Spec |
| + if err = json.Unmarshal(raw, &s); err != nil { |
| + t.Fatal(err) |
| + } |
| + if s.Root.Path != execsandbox.RootfsDir(l.id) || !s.Root.Readonly || s.Process.User.UID != 65534 || s.Process.User.GID != 65534 || s.Process.User.Umask == nil || *s.Process.User.Umask != 0077 { |
| + t.Fatal(s) |
| + } |
| + if !reflect.DeepEqual(s.Process.Args, []string{"/opt/carlos/demo-toolchain/bin/go", "build", "-mod=readonly", "-trimpath", "-buildvcs=false", "-o", "/work/out/app", "."}) || s.Process.Cwd != "/work/src" { |
| + t.Fatal(s.Process) |
| + } |
| + if !reflect.DeepEqual(s.Process.Env, append(BuildEnvironment(), "GOMEMLIMIT=966367638")) || !reflect.DeepEqual(s.Process.Rlimits, []execsandbox.Rlimit{{Type: "RLIMIT_FSIZE", Soft: 33554432, Hard: 33554432}}) { |
| + t.Fatal(s.Process) |
| + } |
| + want := map[string]string{"/opt/carlos/demo-toolchain": w.cfg.ToolchainDir, "/work/src": l.work + "/src", "/work/out": l.work + "/out", "/work/tmp": l.work + "/tmp", "/work/home": l.work + "/home", "/work/cache": l.cache} |
| + if len(s.Mounts) != 11 { |
| + t.Fatal(s.Mounts) |
| + } |
| + for _, m := range s.Mounts[5:] { |
| + if want[m.Destination] != m.Source { |
| + t.Fatal(m) |
| + } |
| + delete(want, m.Destination) |
| + ro := m.Destination == "/work/src" || m.Destination == "/opt/carlos/demo-toolchain" |
| + if containsField(strings.Join(m.Options, " "), "ro") != ro { |
| + t.Fatal(m) |
| + } |
| + } |
| + if len(want) != 0 { |
| + t.Fatal(want) |
| + } |
| + l.unit = "caller.service" |
| + if _, err := w.gvisorBuildBundle(l); err == nil { |
| + t.Fatal("accepted supplied unit") |
| + } |
| +} |
| + |
| +func TestGVisorBuildOwnership(t *testing.T) { |
| + work := t.TempDir() |
| + for _, d := range []string{"out", "tmp", "home", "src", "cache/aa", "cache-upper/view", "cache-work", "toolchain/cache/aa"} { |
| + if err := os.MkdirAll(filepath.Join(work, d), 0755); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + lower := filepath.Join(work, "toolchain/cache/aa/seed") |
| + if err := os.WriteFile(lower, []byte("seed bytes"), 0444); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Link(lower, filepath.Join(work, "cache/aa/seed")); err != nil { |
| + t.Fatal(err) |
| + } |
| + before, _ := os.Stat(lower) |
| + seen := map[string]bool{} |
| + err := ownBuildDirectories(buildLayout{work: work, cache: work + "/cache"}, func(f *os.File, uid, gid int) error { |
| + st, err := f.Stat() |
| + if err != nil { |
| + return err |
| + } |
| + if !st.IsDir() || uid != 65534 || gid != 65534 { |
| + t.Fatal(f.Name(), uid, gid) |
| + } |
| + rel, _ := filepath.Rel(work, f.Name()) |
| + seen[rel] = true |
| + return nil |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !reflect.DeepEqual(seen, map[string]bool{"out": true, "tmp": true, "home": true, "cache": true, "cache/aa": true}) { |
| + t.Fatal(seen) |
| + } |
| + for p := range seen { |
| + st, _ := os.Stat(filepath.Join(work, p)) |
| + if st.Mode().Perm() != 0700 { |
| + t.Fatal(p, st.Mode()) |
| + } |
| + } |
| + after, _ := os.Stat(lower) |
| + raw, _ := os.ReadFile(lower) |
| + upper, _ := os.ReadDir(work + "/cache-upper") |
| + if !os.SameFile(before, after) || string(raw) != "seed bytes" || len(upper) != 1 || upper[0].Name() != "view" { |
| + t.Fatal("lower changed or file copied up") |
| + } |
| +} |
| + |
| +func TestGVisorBuildCacheUpperOwnershipBoundary(t *testing.T) { |
| + l := buildLayout{work: "/work", family: execsandbox.FamilyGVisor} |
| + if got := cacheUpperDir(l); got != "/work/cache-upper/view" { |
| + t.Fatal("overlay root would change cache-upper ownership", got) |
| + } |
| + l.family = execsandbox.FamilySystemd |
| + if got := cacheUpperDir(l); got != "/work/cache-upper" { |
| + t.Fatal("native cache layout changed", got) |
| + } |
| +} |
| + |
| +func TestGVisorBuildBudget(t *testing.T) { |
| + fakeUnitController(t) |
| + for n := 1; n <= 4; n++ { |
| + p := SlicePropertiesFor(n, execsandbox.FamilyGVisor) |
| + if p["MemoryMax"] != int64(n)*1107296256 || p["TasksMax"] != int64(n)*192 || p["CPUQuota"] != int64(n)*50 || p["MemorySwapMax"] != 0 { |
| + t.Fatal(p) |
| + } |
| + systemctl = func(context.Context, ...string) (string, error) { |
| + return fmt.Sprintf("MemoryMax=%d\nMemorySwapMax=0\nTasksMax=%d\nCPUQuotaPerSecUSec=%s\n", n*1107296256, n*192, quotaString(n)), nil |
| + } |
| + w := &Worker{family: execsandbox.FamilyGVisor, slots: make(chan struct{}, n)} |
| + if err := w.assertBudget(t.Context()); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| +} |
| + |
| +func TestGVisorBuildRecoveryBothFamilies(t *testing.T) { |
| + for _, blocked := range []bool{false, true} { |
| + t.Run(fmt.Sprint(blocked), func(t *testing.T) { |
| + fakeUnitController(t) |
| + w, j, _, _ := workerFixture(t) |
| + dir := filepath.Join(w.root, j.ID, "1") |
| + os.MkdirAll(dir+"/work", 0700) |
| + stops := map[string]bool{} |
| + removed := false |
| + w.removeSandbox = func(id string) error { |
| + if len(stops) != 2 || blocked { |
| + t.Fatal("bundle removed before both proofs", stops) |
| + } |
| + removed = true |
| + return nil |
| + } |
| + systemctl = func(_ context.Context, args ...string) (string, error) { |
| + if args[0] == "stop" && strings.HasSuffix(args[len(args)-1], ".service") { |
| + stops[args[len(args)-1]] = true |
| + } |
| + if args[0] == "show" { |
| + job := "" |
| + if blocked && strings.Contains(args[1], "gvisor") { |
| + job = "7" |
| + } |
| + return "LoadState=not-found\nActiveState=inactive\nSubState=dead\nMainPID=0\nControlPID=0\nJob=" + job + "\n", nil |
| + } |
| + if args[0] == "stop" && strings.HasSuffix(args[len(args)-1], ".mount") && len(stops) != 2 { |
| + t.Fatal("unmounted before stopping both", stops) |
| + } |
| + return "", nil |
| + } |
| + ctx, cancel := context.WithTimeout(t.Context(), 50*time.Millisecond) |
| + defer cancel() |
| + err := w.recover(ctx) |
| + if blocked { |
| + if err == nil { |
| + t.Fatal("accepted pending stop job") |
| + } |
| + if _, e := os.Stat(dir); e != nil { |
| + t.Fatal("lost work", e) |
| + } |
| + } else if err != nil || len(stops) != 2 || !removed { |
| + t.Fatal(err, stops) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestGVisorBuildWindow(t *testing.T) { |
| + if BuildWindow != 180*time.Second { |
| + t.Fatal(BuildWindow) |
| + } |
| + for _, path := range []string{"../host/units/carlos-demo-build@.service", "../host/units/carlos-demo-build-gvisor@.service"} { |
| + raw, err := os.ReadFile(path) |
| + if err != nil || !strings.Contains(string(raw), "RuntimeMaxSec=180\n") { |
| + t.Fatal(path, err) |
| + } |
| + } |
| +} |
| + |
| +func TestGVisorBuildUnitReadback(t *testing.T) { |
| + w, j, _, _ := workerFixture(t) |
| + l, err := layoutFor(w.root, filepath.Join(w.root, j.ID, "1"), execsandbox.FamilyGVisor) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + drop, err := gvisorBuildDropIn(l) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err = gvisorBuildSource(drop, l); err != nil { |
| + t.Fatal(err) |
| + } |
| + p := gvisorBuildProperties(l) |
| + p["BindsTo"] = l.workMount + " " + l.cacheMount + " carlos-instance-control.service" |
| + p["After"] = p["BindsTo"] + " basic.target" |
| + p["ReadWritePaths"] = "/run/carlos-runsc " + l.work + "/out " + l.work + "/tmp " + l.work + "/home " + l.cache |
| + commands, err := gvisorBuildCommands(l) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, key := range buildCommandKeys { |
| + p[key] = "" |
| + for _, cmd := range commands[key] { |
| + ignore := "no" |
| + if cmd.ignore { |
| + ignore = "yes" |
| + } |
| + p[key] += "{ path=" + cmd.args[0] + " ; argv[]=" + strings.Join(cmd.args, " ") + " ; ignore_errors=" + ignore + " ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }" |
| + } |
| + } |
| + render := func() string { |
| + var b strings.Builder |
| + for key, value := range p { |
| + fmt.Fprintf(&b, "%s=%s\n", key, value) |
| + } |
| + return b.String() |
| + } |
| + if err = gvisorBuildShown(render(), l); err != nil { |
| + t.Fatal(err, render()) |
| + } |
| + for key := range p { |
| + t.Run(key, func(t *testing.T) { |
| + old := p[key] |
| + p[key] = "wrong" |
| + defer func() { p[key] = old }() |
| + if gvisorBuildShown(render(), l) == nil { |
| + t.Fatal("accepted changed property") |
| + } |
| + }) |
| + } |
| + for _, change := range [][2]string{{"--overlay2=none", "--overlay2=root:memory"}, {"--network=none", "--network=host"}, {"--bundle ", "--bundle '/"}, {"StandardOutput=append:", "StandardOutput=truncate:"}, {"/diagnostics", "/elsewhere"}, {"ExecStop=\n", "ExecStop=/bin/true\n"}} { |
| + if gvisorBuildSource(strings.ReplaceAll(drop, change[0], change[1]), l) == nil { |
| + t.Fatal("accepted source mutation", change) |
| + } |
| + } |
| +} |
| + |
| +func TestGVisorBuildDiagnostics(t *testing.T) { |
| + dir := t.TempDir() |
| + i := &runInvocation{family: execsandbox.FamilyGVisor, dir: dir, startWait: func(context.Context) error { |
| + raw := "runsc: error creating container\nW1109 01:02:03.123 runtime warning\nmain.go:3:4: undefined: missing\n" + strings.Repeat("runsc runtime warning\n", 4000) |
| + if err := os.WriteFile(filepath.Join(dir, "diagnostics"), []byte(raw), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + return ErrBuild |
| + }, stop: func() error { return nil }} |
| + out, err := Run(context.WithValue(t.Context(), runContextKey{}, i), dir, testLock(t)) |
| + if err == nil || !out.DiagnosticsTruncated || len(out.Diagnostics) != 1 || out.Diagnostics[0].File != "main.go" || out.Diagnostics[0].Message != "undefined: missing" { |
| + t.Fatal(out, err) |
| + } |
| +} |
| + |
| +func TestGVisorBuildReadinessRetries(t *testing.T) { |
| + w, j, key, src := workerFixture(t) |
| + w.family = execsandbox.FamilyGVisor |
| + attempts, runs := 0, 0 |
| + w.proof = func(context.Context) error { |
| + attempts++ |
| + if attempts == 1 { |
| + return execsandbox.ErrRunsc |
| + } |
| + return nil |
| + } |
| + w.run = func(ctx context.Context, dir string, _ Lock) (BuildOutput, error) { |
| + runs++ |
| + l, err := layoutFor(w.root, dir, w.SandboxFamily()) |
| + if err != nil || l.family != execsandbox.FamilyGVisor { |
| + t.Fatal(l, err) |
| + } |
| + deadline, ok := ctx.Deadline() |
| + if !ok || !deadline.Equal(j.Deadline) { |
| + t.Fatal(deadline, j.Deadline) |
| + } |
| + return BuildOutput{}, nil |
| + } |
| + j.Deadline = time.Now().Add(180 * time.Second) |
| + wire, err := SignJob(key, j) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err = w.Build(t.Context(), wire, neverRead{t}); err == nil { |
| + t.Fatal("readiness failure admitted") |
| + } |
| + if _, err = w.Build(t.Context(), wire, strings.NewReader(string(src))); err != nil { |
| + t.Fatal(err) |
| + } |
| + if attempts != 2 || runs != 1 || w.SandboxFamily() != execsandbox.FamilyGVisor { |
| + t.Fatal(attempts, runs) |
| + } |
| +} |
| + |
| +func TestGVisorBuildInitializationRecoversBeforeBundle(t *testing.T) { |
| + fakeUnitController(t) |
| + w, j, _, _ := workerFixture(t) |
| + w.ready = false |
| + w.cfg.ToolchainDir = "/nonexistent-toolchain" |
| + dir := filepath.Join(w.root, j.ID, "1") |
| + if err := os.MkdirAll(dir+"/work", 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := w.Initialize(t.Context()); err == nil || w.available() { |
| + t.Fatal("invalid toolchain ready", err) |
| + } |
| + if _, err := os.Stat(dir); !os.IsNotExist(err) { |
| + t.Fatal("toolchain refusal prevented recovery", err) |
| + } |
| +} |
| + |
| +func TestGVisorBuildStopProof(t *testing.T) { |
| + for _, fault := range []string{"missing-job", "queued-job", "main-pid", "control-pid", "populated", "duplicate-populated"} { |
| + t.Run(fault, func(t *testing.T) { |
| + fakeUnitController(t) |
| + w, j, _, _ := workerFixture(t) |
| + l, err := layoutFor(w.root, filepath.Join(w.root, j.ID, "1"), execsandbox.FamilyGVisor) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + ctl := systemctl |
| + systemctl = func(ctx context.Context, args ...string) (string, error) { |
| + if args[0] == "kill" { |
| + t.Fatal("extra kill could terminate runtime deletion") |
| + } |
| + out, err := ctl(ctx, args...) |
| + if fault == "missing-job" { |
| + out = strings.ReplaceAll(out, "Job=\n", "") |
| + } |
| + if fault == "queued-job" { |
| + out = strings.ReplaceAll(out, "Job=\n", "Job=3\n") |
| + } |
| + if fault == "main-pid" { |
| + out = strings.ReplaceAll(out, "MainPID=0", "MainPID=10") |
| + } |
| + if fault == "control-pid" { |
| + out = strings.ReplaceAll(out, "ControlPID=0", "ControlPID=10") |
| + } |
| + return out, err |
| + } |
| + if strings.Contains(fault, "populated") { |
| + dir := filepath.Join(buildCgroupRoot, l.unit) |
| + if err := os.Mkdir(dir, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + raw := "populated 1\n" |
| + if fault == "duplicate-populated" { |
| + raw += "populated 0\n" |
| + } |
| + if err := os.WriteFile(filepath.Join(dir, "cgroup.events"), []byte(raw), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + ctx, cancel := context.WithTimeout(t.Context(), 25*time.Millisecond) |
| + defer cancel() |
| + if err := stopBuildContext(ctx, l); err == nil { |
| + t.Fatal("accepted failed stop proof") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestGVisorBuildRecoveryMultipleAttempts(t *testing.T) { |
| + fakeUnitController(t) |
| + w, j, _, _ := workerFixture(t) |
| + for _, attempt := range []string{"1", "2"} { |
| + if err := os.MkdirAll(filepath.Join(w.root, j.ID, attempt, "work"), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if err := w.recover(t.Context()); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := os.Stat(filepath.Join(w.root, j.ID)); !os.IsNotExist(err) { |
| + t.Fatal("attempt survived", err) |
| + } |
| +} |
diff --git a/internal/demobuild/probe.go b/internal/demobuild/probe.go| index 54d7eb92e..917860a65 100644 |
| --- a/internal/demobuild/probe.go |
| +++ b/internal/demobuild/probe.go |
| @@ -11,7 +11,7 @@ import ( |
| "strings" |
| ) |
| -// The readiness build proves the native compiler, offline dependency closure, |
| +// The readiness build proves the selected compiler family, offline dependency closure, |
| // overlay support and actual namespace setup before advertising this bundle. |
| // It imports the locked framework, never executes the resulting binary, and |
| // uses the same resource, output and termination gates as submitted builds. |
diff --git a/internal/demobuild/purge.go b/internal/demobuild/purge.go| index 6c90515b5..a247f8701 100644 |
| --- a/internal/demobuild/purge.go |
| +++ b/internal/demobuild/purge.go |
| @@ -50,7 +50,7 @@ func (w *Worker) PurgeDemo(ctx context.Context, demoID, host string, ids []strin |
| err = w.purgeUnit(ctx, dir) |
| } else { |
| var l buildLayout |
| - l, err = layoutIn(w.root, dir) |
| + l, err = layoutFor(w.root, dir, w.SandboxFamily()) |
| if err == nil { |
| err = w.cleanUnit(ctx, l) |
| } |
diff --git a/internal/demobuild/runner.go b/internal/demobuild/runner.go| index 727e1f4d1..c57d62441 100644 |
| --- a/internal/demobuild/runner.go |
| +++ b/internal/demobuild/runner.go |
| @@ -14,6 +14,7 @@ import ( |
| "path/filepath" |
| "strings" |
| + "github.com/carlosframework/platform/internal/execsandbox" |
| "github.com/carlosframework/platform/internal/instancefs" |
| ) |
| @@ -27,10 +28,23 @@ const ( |
| var ErrBuild = errors.New("DEMO-BUILD") |
| func SliceProperties(slots int) map[string]int64 { |
| + return SlicePropertiesFor(slots, execsandbox.FamilySystemd) |
| +} |
| + |
| +func SlicePropertiesFor(slots int, family execsandbox.Family) map[string]int64 { |
| if slots < 1 || slots > 4 { |
| return nil |
| } |
| - return map[string]int64{"MemoryMax": int64(slots) * MemoryMax, "MemorySwapMax": 0, "TasksMax": int64(slots) * TasksMax, "CPUQuota": int64(slots) * 50} |
| + memory, tasks := MemoryMax, TasksMax |
| + switch family { |
| + case execsandbox.FamilySystemd: |
| + case execsandbox.FamilyGVisor: |
| + memory += execsandbox.GVisorOverhead |
| + tasks = execsandbox.PhysicalTasks(tasks) |
| + default: |
| + return nil |
| + } |
| + return map[string]int64{"MemoryMax": int64(slots) * memory, "MemorySwapMax": 0, "TasksMax": int64(slots) * tasks, "CPUQuota": int64(slots) * 50} |
| } |
| func BuildEnvironment() []string { |
| @@ -128,6 +142,7 @@ func extractSource(dir string, src Source) error { |
| type runContextKey struct{} |
| type runInvocation struct { |
| + family execsandbox.Family |
| dir string |
| startWait func(context.Context) error |
| stop func() error |
| @@ -154,7 +169,11 @@ func Run(ctx context.Context, workDir string, lock Lock) (BuildOutput, error) { |
| if e != nil { |
| return out, ErrBuild |
| } |
| - out.Diagnostics, out.DiagnosticsTruncated = TrimDiagnosticsWithStatus(raw) |
| + if i.family == execsandbox.FamilyGVisor { |
| + out.Diagnostics, out.DiagnosticsTruncated = trimGVisorBuildDiagnostics(raw) |
| + } else { |
| + out.Diagnostics, out.DiagnosticsTruncated = TrimDiagnosticsWithStatus(raw) |
| + } |
| } |
| if runErr != nil { |
| return out, ErrBuild |
diff --git a/internal/demobuild/unit.go b/internal/demobuild/unit.go| index d8221e22f..4ec4974d0 100644 |
| --- a/internal/demobuild/unit.go |
| +++ b/internal/demobuild/unit.go |
| @@ -12,19 +12,31 @@ import ( |
| "path/filepath" |
| "strconv" |
| "strings" |
| + "syscall" |
| "time" |
| + "github.com/carlosframework/platform/internal/execsandbox" |
| "github.com/carlosframework/platform/internal/instancefs" |
| ) |
| var unitRoot = "/run/systemd/system" |
| var buildCgroupRoot = "/sys/fs/cgroup/carlos.slice/carlos-demo.slice/carlos-demo-builds.slice" |
| -type buildLayout struct{ dir, work, cache, unit, workMount, cacheMount string } |
| +type buildLayout struct { |
| + dir, work, cache, unit, workMount, cacheMount, id string |
| + family execsandbox.Family |
| +} |
| func layout(dir string) (buildLayout, error) { return layoutIn(BuildRoot, dir) } |
| func layoutIn(root, dir string) (buildLayout, error) { |
| + return layoutFor(root, dir, execsandbox.FamilySystemd) |
| +} |
| + |
| +func layoutFor(root, dir string, family execsandbox.Family) (buildLayout, error) { |
| + if family != execsandbox.FamilySystemd && family != execsandbox.FamilyGVisor { |
| + return buildLayout{}, ErrBuild |
| + } |
| rel, err := filepath.Rel(root, dir) |
| p := strings.Split(rel, string(filepath.Separator)) |
| if err != nil || len(p) != 2 || !ValidJobID(p[0]) { |
| @@ -37,6 +49,11 @@ func layoutIn(root, dir string) (buildLayout, error) { |
| id, _ := base64.RawURLEncoding.DecodeString(p[0]) |
| key := hex.EncodeToString(id) + "_" + p[1] |
| l := buildLayout{dir: dir, work: dir + "/work", cache: dir + "/work/cache", unit: "carlos-demo-build@" + key + ".service"} |
| + l.family = family |
| + l.id = "build-" + key |
| + if family == execsandbox.FamilyGVisor { |
| + l.unit = "carlos-demo-build-gvisor@" + key + ".service" |
| + } |
| l.workMount = mountName(l.work) |
| l.cacheMount = mountName(l.cache) |
| return l, nil |
| @@ -93,7 +110,7 @@ func writeUnit(name, content string) error { |
| } |
| func (w *Worker) prepareUnit(ctx context.Context, dir string, src Source) (func() error, error) { |
| - l, err := layoutIn(w.root, dir) |
| + l, err := layoutFor(w.root, dir, w.SandboxFamily()) |
| if err != nil { |
| return nil, err |
| } |
| @@ -137,7 +154,7 @@ func (w *Worker) prepareUnit(ctx context.Context, dir string, src Source) (func( |
| defer wr.Close() |
| for _, d := range []string{"out", "tmp", "home", "cache", "cache-upper", "cache-work"} { |
| mode := os.FileMode(0700) |
| - if d == "out" || d == "tmp" || d == "home" { |
| + if l.family == execsandbox.FamilySystemd && (d == "out" || d == "tmp" || d == "home") { |
| mode = 0777 |
| } |
| if err = wr.Mkdir(d, mode); err != nil { |
| @@ -147,6 +164,11 @@ func (w *Worker) prepareUnit(ctx context.Context, dir string, src Source) (func( |
| return cleanup, err |
| } |
| } |
| + if l.family == execsandbox.FamilyGVisor { |
| + if err = wr.Mkdir("cache-upper/view", 0700); err != nil { |
| + return cleanup, err |
| + } |
| + } |
| if err = extractSource(l.work, src); err != nil { |
| return cleanup, err |
| } |
| @@ -155,7 +177,7 @@ func (w *Worker) prepareUnit(ctx context.Context, dir string, src Source) (func( |
| return cleanup, err |
| } |
| d.Close() |
| - content = fmt.Sprintf("[Unit]\nBindsTo=%s\nAfter=%s\n[Mount]\nWhat=overlay\nWhere=%s\nType=overlay\nOptions=lowerdir=%s/cache,upperdir=%s/cache-upper,workdir=%s/cache-work,nosuid,nodev,noexec\nTimeoutSec=5\n", l.workMount, l.workMount, l.cache, w.cfg.ToolchainDir, l.work, l.work) |
| + content = fmt.Sprintf("[Unit]\nBindsTo=%s\nAfter=%s\n[Mount]\nWhat=overlay\nWhere=%s\nType=overlay\nOptions=lowerdir=%s/cache,upperdir=%s,workdir=%s/cache-work,nosuid,nodev,noexec\nTimeoutSec=5\n", l.workMount, l.workMount, l.cache, w.cfg.ToolchainDir, cacheUpperDir(l), l.work) |
| if err = writeUnit(l.cacheMount, content); err != nil { |
| return cleanup, err |
| } |
| @@ -167,7 +189,15 @@ func (w *Worker) prepareUnit(ctx context.Context, dir string, src Source) (func( |
| } |
| // Only directories copy up. Seed bytes stay on the root-owned lower |
| // mount; every writable cache file belongs to this private upper tree. |
| - if err = filepath.WalkDir(l.cache, func(p string, de fs.DirEntry, e error) error { |
| + if l.family == execsandbox.FamilyGVisor { |
| + err = ownBuildDirectories(l, func(f *os.File, uid, gid int) error { return f.Chown(uid, gid) }) |
| + if err == nil { |
| + err = w.writeGVisorBuildBundle(l) |
| + } |
| + if err != nil { |
| + return cleanup, err |
| + } |
| + } else if err = filepath.WalkDir(l.cache, func(p string, de fs.DirEntry, e error) error { |
| if e != nil { |
| return e |
| } |
| @@ -190,6 +220,12 @@ func (w *Worker) prepareUnit(ctx context.Context, dir string, src Source) (func( |
| return cleanup, err |
| } |
| drop := fmt.Sprintf("[Unit]\nBindsTo=%s %s carlos-instance-control.service\nAfter=%s %s carlos-instance-control.service\n[Service]\nBindPaths=%s:/work\nBindReadOnlyPaths=%s:/opt/carlos/demo-toolchain %s/src:/work/src\nStandardOutput=truncate:%s/diagnostics\nStandardError=inherit\n", l.workMount, l.cacheMount, l.workMount, l.cacheMount, l.work, w.cfg.ToolchainDir, l.work, l.work) |
| + if l.family == execsandbox.FamilyGVisor { |
| + drop, err = gvisorBuildDropIn(l) |
| + if err != nil { |
| + return cleanup, err |
| + } |
| + } |
| f, err := instancefs.OpenBeneath(unitRoot, l.unit+".d/50-job.conf", os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644) |
| if err != nil { |
| return cleanup, err |
| @@ -209,14 +245,28 @@ func (w *Worker) prepareUnit(ctx context.Context, dir string, src Source) (func( |
| } |
| func (w *Worker) runUnit(ctx context.Context, dir string, lock Lock) (BuildOutput, error) { |
| - l, err := layoutIn(w.root, dir) |
| + l, err := layoutFor(w.root, dir, w.SandboxFamily()) |
| if err != nil { |
| return BuildOutput{}, err |
| } |
| - i := &runInvocation{dir: l.work, startWait: func(ctx context.Context) error { |
| + i := &runInvocation{family: l.family, dir: l.work, startWait: func(ctx context.Context) error { |
| if err := w.assertUnit(ctx, l); err != nil { |
| return err |
| } |
| + if l.family == execsandbox.FamilyGVisor { |
| + if err := w.proof(ctx); err != nil { |
| + return err |
| + } |
| + r, err := instancefs.OpenRootBeneath(l.work, ".") |
| + if err != nil { |
| + return err |
| + } |
| + err = r.Remove("diagnostics") |
| + r.Close() |
| + if err != nil && !os.IsNotExist(err) { |
| + return err |
| + } |
| + } |
| if _, err := systemctl(ctx, "start", "--no-block", l.unit); err != nil { |
| return err |
| } |
| @@ -260,15 +310,19 @@ func stopBuildContext(ctx context.Context, l buildLayout) error { |
| return ErrBuild |
| } |
| } |
| - // Disposable compilers have no shutdown protocol. Kill descendants now; |
| - // systemd's stop job still owns reaping and the final inactive transition. |
| - _, _ = systemctl(ctx, "kill", "--kill-whom=all", "--signal=SIGKILL", l.unit) |
| + // Native compilers have no shutdown protocol. The gVisor unit owns |
| + // runtime deletion after its cgroup stop; an extra kill could hit that helper. |
| + if l.family == execsandbox.FamilySystemd { |
| + _, _ = systemctl(ctx, "kill", "--kill-whom=all", "--signal=SIGKILL", l.unit) |
| + } |
| tick := time.NewTicker(20 * time.Millisecond) |
| defer tick.Stop() |
| for { |
| - out, err := systemctl(ctx, "show", l.unit, "-p", "ActiveState,MainPID,ControlPID,LoadState") |
| + out, err := systemctl(ctx, "show", l.unit, "-p", "ActiveState,SubState,MainPID,ControlPID,LoadState,Job") |
| m := showProperties(out) |
| - inactive := m["LoadState"] == "not-found" || (m["ActiveState"] == "inactive" || m["ActiveState"] == "failed") && m["MainPID"] == "0" && m["ControlPID"] == "0" |
| + job, present := m["Job"] |
| + inactive := present && (job == "" || job == "0") && (m["ActiveState"] == "inactive" || m["ActiveState"] == "failed") && (m["SubState"] == "dead" || m["SubState"] == "failed") && m["MainPID"] == "0" && m["ControlPID"] == "0" |
| + |
| if err == nil && inactive && emptyBuildCgroup(l.unit) == nil { |
| return nil |
| } |
| @@ -297,15 +351,40 @@ func emptyBuildCgroup(unit string) error { |
| if err != nil { |
| return err |
| } |
| - if !strings.Contains("\n"+string(b[:n])+"\n", "\npopulated 0\n") { |
| + populated := "" |
| + for _, line := range strings.Split(string(b[:n]), "\n") { |
| + fields := strings.Fields(line) |
| + if len(fields) > 0 && fields[0] == "populated" { |
| + if len(fields) != 2 || populated != "" { |
| + return ErrBuild |
| + } |
| + populated = fields[1] |
| + } |
| + } |
| + if populated != "0" { |
| return ErrBuild |
| } |
| return nil |
| } |
| func (w *Worker) cleanUnit(ctx context.Context, l buildLayout) error { |
| - if err := stopBuildContext(ctx, l); err != nil { |
| - return err |
| + expected, err := layoutFor(w.root, l.dir, l.family) |
| + if err != nil || expected != l { |
| + return ErrBuild |
| + } |
| + // Both families share these mounts. Never remove them after proving only one. |
| + var stopped error |
| + var layouts []buildLayout |
| + for _, family := range []execsandbox.Family{execsandbox.FamilySystemd, execsandbox.FamilyGVisor} { |
| + other, err := layoutFor(w.root, l.dir, family) |
| + if err != nil { |
| + return err |
| + } |
| + layouts = append(layouts, other) |
| + stopped = errors.Join(stopped, stopBuildContext(ctx, other)) |
| + } |
| + if stopped != nil { |
| + return stopped |
| } |
| for _, unit := range []string{l.cacheMount, l.workMount} { |
| out, err := systemctl(ctx, "show", unit, "-p", "LoadState,ActiveState") |
| @@ -321,6 +400,13 @@ func (w *Worker) cleanUnit(ctx context.Context, l buildLayout) error { |
| if mountedAt(l.work) || mountedAt(l.cache) { |
| return ErrBuild |
| } |
| + remove := w.removeSandbox |
| + if remove == nil { |
| + remove = execsandbox.RemoveRunFiles |
| + } |
| + if err := remove(l.id); err != nil { |
| + return err |
| + } |
| r, err := instancefs.OpenRootBeneath(w.root, ".") |
| if err != nil { |
| return err |
| @@ -330,7 +416,7 @@ func (w *Worker) cleanUnit(ctx context.Context, l buildLayout) error { |
| if err = r.RemoveAll(rel); err != nil { |
| return err |
| } |
| - if err = r.Remove(filepath.Dir(rel)); err != nil && !os.IsNotExist(err) { |
| + if err = r.Remove(filepath.Dir(rel)); err != nil && !os.IsNotExist(err) && !errors.Is(err, syscall.ENOTEMPTY) { |
| return err |
| } |
| ur, err := instancefs.OpenRootBeneath(unitRoot, ".") |
| @@ -338,7 +424,11 @@ func (w *Worker) cleanUnit(ctx context.Context, l buildLayout) error { |
| return err |
| } |
| defer ur.Close() |
| - for _, p := range []string{l.unit + ".d/50-job.conf", l.unit + ".d", l.cacheMount, l.workMount} { |
| + paths := []string{l.cacheMount, l.workMount} |
| + for _, other := range layouts { |
| + paths = append(paths, other.unit+".d/50-job.conf", other.unit+".d") |
| + } |
| + for _, p := range paths { |
| if err = ur.Remove(p); err != nil && !os.IsNotExist(err) { |
| return err |
| } |
| @@ -405,7 +495,11 @@ func (w *Worker) assertBudget(ctx context.Context) error { |
| } |
| m := showProperties(out) |
| n := cap(w.slots) |
| - if m["MemoryMax"] != strconv.FormatInt(int64(n)*MemoryMax, 10) || m["MemorySwapMax"] != "0" || m["TasksMax"] != strconv.Itoa(n*int(TasksMax)) || m["CPUQuotaPerSecUSec"] != quotaString(n) { |
| + p := SlicePropertiesFor(n, w.SandboxFamily()) |
| + if p == nil { |
| + return ErrBuild |
| + } |
| + if m["MemoryMax"] != strconv.FormatInt(p["MemoryMax"], 10) || m["MemorySwapMax"] != "0" || m["TasksMax"] != strconv.FormatInt(p["TasksMax"], 10) || m["CPUQuotaPerSecUSec"] != quotaString(n) { |
| return ErrBuild |
| } |
| return nil |
| @@ -425,6 +519,9 @@ func (w *Worker) assertUnit(ctx context.Context, l buildLayout) error { |
| if err := w.assertBudget(ctx); err != nil { |
| return err |
| } |
| + if l.family == execsandbox.FamilyGVisor { |
| + return w.assertGVisorBuildUnit(ctx, l) |
| + } |
| want := map[string]string{"DynamicUser": "yes", "PrivateNetwork": "yes", "RestrictAddressFamilies": "AF_UNIX", "MemoryMax": "1073741824", "MemorySwapMax": "0", "LimitFSIZE": "33554432", "LimitFSIZESoft": "33554432", "TasksMax": "128", "CPUQuotaPerSecUSec": "500ms", "CPUWeight": "10", "RuntimeMaxUSec": "3min", "TimeoutStopUSec": "5s", "KillMode": "control-group", "MemoryDenyWriteExecute": "yes", "CapabilityBoundingSet": "", "AmbientCapabilities": "", "NoNewPrivileges": "yes", "ProtectSystem": "strict", "ProtectHome": "yes", "PrivateDevices": "yes", "PrivateIPC": "yes", "PrivatePIDs": "yes", "RestrictNamespaces": "yes", "ProtectControlGroups": "yes", "ProtectProc": "invisible", "ProcSubset": "pid", "NetworkNamespacePath": "", "JoinsNamespaceOf": "", "Slice": "carlos-demo-builds.slice", "WorkingDirectory": "/work/src", "IPAddressAllow": ""} |
| keys := []string{} |
| for k := range want { |
diff --git a/internal/demobuild/unit_test.go b/internal/demobuild/unit_test.go| index 5f8cb42b0..10900a48f 100644 |
| --- a/internal/demobuild/unit_test.go |
| +++ b/internal/demobuild/unit_test.go |
| @@ -4,6 +4,7 @@ package demobuild |
| import ( |
| "context" |
| + "github.com/carlosframework/platform/internal/execsandbox" |
| "os" |
| "path/filepath" |
| "strings" |
| @@ -18,7 +19,7 @@ func fakeUnitController(t *testing.T) { |
| buildCgroupRoot = t.TempDir() |
| systemctl = func(_ context.Context, args ...string) (string, error) { |
| if args[0] == "show" { |
| - return "LoadState=not-found\nActiveState=inactive\nMainPID=0\nControlPID=0\n", nil |
| + return "LoadState=not-found\nActiveState=inactive\nMainPID=0\nControlPID=0\nSubState=dead\nJob=\n", nil |
| } |
| return "", nil |
| } |
| @@ -107,7 +108,7 @@ func TestDemoBuildStartupSwitch(t *testing.T) { |
| t.Fatal("off switch read", k) |
| } |
| return "" |
| - }, func(context.Context) error { called = true; return nil }) |
| + }, func(context.Context) error { called = true; return nil }, func() (execsandbox.Family, error) { return execsandbox.FamilySystemd, nil }) |
| if w != nil || err != nil || called { |
| t.Fatal(w, err, called) |
| } |
| @@ -117,7 +118,7 @@ func TestDemoBuildStartupSwitch(t *testing.T) { |
| return value |
| } |
| return "" |
| - }, func(context.Context) error { return nil }); err == nil { |
| + }, func(context.Context) error { return nil }, func() (execsandbox.Family, error) { return execsandbox.FamilySystemd, nil }); err == nil { |
| t.Fatal("worker without root box tuple") |
| } |
| } |
diff --git a/internal/demobuild/worker.go b/internal/demobuild/worker.go| index 8b06b70ad..e6b531f97 100644 |
| --- a/internal/demobuild/worker.go |
| +++ b/internal/demobuild/worker.go |
| @@ -18,6 +18,7 @@ import ( |
| "time" |
| "github.com/carlosframework/platform/internal/demo" |
| + "github.com/carlosframework/platform/internal/execsandbox" |
| "github.com/carlosframework/platform/internal/hostwrite" |
| "github.com/carlosframework/platform/internal/instancefs" |
| "github.com/carlosframework/platform/internal/registry" |
| @@ -29,32 +30,44 @@ const BuildRoot = "/var/lib/carlos-demo-builds" |
| // Worker belongs to the root service, surviving agent disconnects and restarts. |
| // An exclusive root-process lock and recovery precede any readiness response. |
| type Worker struct { |
| - retryCleanup func(context.Context) error |
| - buildPurge sync.RWMutex |
| - purgeUnit func(context.Context, string) error |
| - cfg demo.Config |
| - box string |
| - pub ed25519.PublicKey |
| - lock Lock |
| - digest, root string |
| - slots chan struct{} |
| - proof func(context.Context) error |
| - prepare func(context.Context, string, Source) (func() error, error) |
| - run func(context.Context, string, Lock) (BuildOutput, error) |
| - processLock *os.File |
| - mu sync.Mutex |
| - poisoned bool |
| - ready bool |
| - initMu sync.Mutex |
| - initDone bool |
| + family execsandbox.Family |
| + removeSandbox func(string) error |
| + retryCleanup func(context.Context) error |
| + buildPurge sync.RWMutex |
| + purgeUnit func(context.Context, string) error |
| + cfg demo.Config |
| + box string |
| + pub ed25519.PublicKey |
| + lock Lock |
| + digest, root string |
| + slots chan struct{} |
| + proof func(context.Context) error |
| + prepare func(context.Context, string, Source) (func() error, error) |
| + run func(context.Context, string, Lock) (BuildOutput, error) |
| + processLock *os.File |
| + mu sync.Mutex |
| + poisoned bool |
| + ready bool |
| + initMu sync.Mutex |
| + initDone bool |
| snapshotPoisoned bool |
| } |
| -func NewWorker(getenv func(string) string, proof func(context.Context) error) (*Worker, error) { |
| +func NewWorker(getenv func(string) string, proof func(context.Context) error, family func() (execsandbox.Family, error)) (*Worker, error) { |
| if getenv("CARLOS_DEMO_BUILD_WORKER") == "" { |
| return nil, nil |
| } |
| + if family == nil { |
| + return nil, ErrBuild |
| + } |
| + selected, err := family() |
| + if err != nil { |
| + return nil, err |
| + } |
| + if selected != execsandbox.FamilySystemd && selected != execsandbox.FamilyGVisor { |
| + return nil, ErrBuild |
| + } |
| boxCfg, err := demo.BoxConfig(getenv) |
| if err != nil || !boxCfg.BoxMode() || hostwrite.Enabled(getenv) || runtime.GOOS != "linux" || runtime.GOARCH != "arm64" || os.Geteuid() != 0 { |
| return nil, ErrBuild |
| @@ -97,7 +110,7 @@ func NewWorker(getenv func(string) string, proof func(context.Context) error) (* |
| } |
| // A snapshot helper can outlive instance-control. Only snapshot recovery |
| // proves that a previous process left no helper running. |
| - w := &Worker{cfg: cfg, box: box, pub: pub, lock: lock, root: BuildRoot, slots: make(chan struct{}, cfg.BuildConcurrency), proof: proof, processLock: guard, snapshotPoisoned: true} |
| + w := &Worker{family: selected, cfg: cfg, box: box, pub: pub, lock: lock, root: BuildRoot, slots: make(chan struct{}, cfg.BuildConcurrency), proof: proof, processLock: guard, snapshotPoisoned: true} |
| w.retryCleanup = w.recover |
| w.prepare = w.prepareUnit |
| w.run = w.runUnit |
| @@ -107,13 +120,13 @@ func NewWorker(getenv func(string) string, proof func(context.Context) error) (* |
| // Initialize runs after the control server starts. Readiness and admission stay |
| // closed until every startup check succeeds, including probe cleanup. |
| func (w *Worker) Initialize(ctx context.Context) error { |
| - return w.initialize(ctx, func(context.Context) error { |
| + return w.initialize(ctx, w.recover, func(context.Context) error { |
| digest, err := CheckBundle(w.cfg.ToolchainDir, w.lock) |
| if err == nil { |
| w.digest = digest |
| } |
| return err |
| - }, w.recover, w.probeBundle) |
| + }, w.probeBundle) |
| } |
| func (w *Worker) initialize(ctx context.Context, stages ...func(context.Context) error) error { |
| @@ -337,3 +350,10 @@ func (w *Worker) expireMarkers() error { |
| } |
| return nil |
| } |
| + |
| +func (w *Worker) SandboxFamily() execsandbox.Family { |
| + if w.family == "" { |
| + return execsandbox.FamilySystemd |
| + } |
| + return w.family |
| +} |
diff --git a/internal/demobuild/worker_test.go b/internal/demobuild/worker_test.go| index 7de6f6413..45890f632 100644 |
| --- a/internal/demobuild/worker_test.go |
| +++ b/internal/demobuild/worker_test.go |
| @@ -31,7 +31,7 @@ func workerFixture(t *testing.T) (*Worker, Job, ed25519.PrivateKey, []byte) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - w := &Worker{ready: true, cfg: demo.Config{Account: "shop", Fleet: "demo", Domain: "example.com", BuildConcurrency: 1}, box: "box-1", pub: pub, lock: testLock(t), digest: strings.Repeat("b", 64), root: t.TempDir(), slots: make(chan struct{}, 1), proof: func(context.Context) error { return nil }} |
| + w := &Worker{removeSandbox: func(string) error { return nil }, ready: true, cfg: demo.Config{Account: "shop", Fleet: "demo", Domain: "example.com", BuildConcurrency: 1}, box: "box-1", pub: pub, lock: testLock(t), digest: strings.Repeat("b", 64), root: t.TempDir(), slots: make(chan struct{}, 1), proof: func(context.Context) error { return nil }} |
| w.prepare = func(context.Context, string, Source) (func() error, error) { return func() error { return nil }, nil } |
| w.run = func(context.Context, string, Lock) (BuildOutput, error) { return BuildOutput{}, nil } |
| j := Job{ID: base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{1}, 32)), DemoID: base64.RawURLEncoding.EncodeToString(bytes.Repeat([]byte{2}, 16)), Account: "shop", App: "tmp-demo-bright-otter-42", Host: "bright-otter-42.example.com", Lifetime: "life-1", Fleet: "demo", Box: "box-1", SourceSHA256: v.SHA256, BundleSHA256: w.digest, Generation: 1, Attempt: 1, Deadline: time.Now().UTC().Add(time.Minute)} |
diff --git a/internal/host/claimunit.go b/internal/host/claimunit.go| index 5469ce94c..c8f35abfc 100644 |
| --- a/internal/host/claimunit.go |
| +++ b/internal/host/claimunit.go |
| @@ -11,6 +11,8 @@ import ( |
| "strings" |
| "github.com/carlosframework/platform/internal/demo" |
| + "github.com/carlosframework/platform/internal/demobuild" |
| + "github.com/carlosframework/platform/internal/execsandbox" |
| "github.com/carlosframework/platform/internal/hostwrite" |
| ) |
| @@ -35,6 +37,7 @@ func claimControlRendered(content []byte) bool { |
| } |
| type claimUnitSettings struct { |
| + sandbox execsandbox.Effective |
| demo demo.Config |
| enabled bool |
| rootRetry bool |
| @@ -42,7 +45,7 @@ type claimUnitSettings struct { |
| } |
| func readClaimUnitSettings(path string) (settings claimUnitSettings, readErr error) { |
| - values := map[string]string{"CARLOS_HOST_CLAIM": "", "CARLOS_DATA_DIR": "", "CARLOS_OPT_DIR": "", "CARLOS_DEMO_BOX": "", "CARLOS_DEMO_ACCOUNT": "", "CARLOS_DEMO_FLEET": "", "CARLOS_DEMO_DOMAIN": "", "CARLOS_DEMO_BUILD_WORKER": "", "CARLOS_DEMO_BUILD_CONCURRENCY": "", "CARLOS_DEMO_TOOLCHAIN_DIR": ""} |
| + values := map[string]string{"CARLOS_EXEC_SANDBOX": "", "CARLOS_HOST_CLAIM": "", "CARLOS_DATA_DIR": "", "CARLOS_OPT_DIR": "", "CARLOS_DEMO_BOX": "", "CARLOS_DEMO_ACCOUNT": "", "CARLOS_DEMO_FLEET": "", "CARLOS_DEMO_DOMAIN": "", "CARLOS_DEMO_BUILD_WORKER": "", "CARLOS_DEMO_BUILD_CONCURRENCY": "", "CARLOS_DEMO_TOOLCHAIN_DIR": ""} |
| raw, err := readClaimUnitFile(path) |
| defer func() { |
| if readErr != nil && demoBoxSettingPresent(raw) { |
| @@ -95,6 +98,10 @@ func readClaimUnitSettings(path string) (settings claimUnitSettings, readErr err |
| if err != nil { |
| return claimUnitSettings{}, err |
| } |
| + _, cfg.sandbox, err = execsandbox.ResolveFromEnv(func(k string) string { return values[k] }) |
| + if err != nil { |
| + return claimUnitSettings{}, err |
| + } |
| if values["CARLOS_DEMO_BUILD_WORKER"] != "" { |
| worker, e := demo.LoadConfig(func(k string) string { return values[k] }) |
| if e != nil || !cfg.demo.BoxMode() || cfg.enabled { |
| @@ -126,7 +133,12 @@ func readClaimUnitSettings(path string) (settings claimUnitSettings, readErr err |
| func claimUnitContent(name string, content []byte, cfg claimUnitSettings) []byte { |
| if name == "carlos-demo-builds.slice" && cfg.demo.BuildWorker { |
| - return []byte(fmt.Sprintf("[Unit]\nDescription=carlos offline demo build budget\n\n[Slice]\nMemoryMax=%d\nMemorySwapMax=0\nTasksMax=%d\nCPUQuota=%d%%\nCPUWeight=10\n", int64(cfg.demo.BuildConcurrency)*1073741824, cfg.demo.BuildConcurrency*128, cfg.demo.BuildConcurrency*50)) |
| + family := execsandbox.FamilySystemd |
| + if cfg.sandbox == execsandbox.EffectiveGVisor { |
| + family = execsandbox.FamilyGVisor |
| + } |
| + p := demobuild.SlicePropertiesFor(cfg.demo.BuildConcurrency, family) |
| + return []byte(fmt.Sprintf("[Unit]\nDescription=carlos offline demo build budget\n\n[Slice]\nMemoryMax=%d\nMemorySwapMax=0\nTasksMax=%d\nCPUQuota=%d%%\nCPUWeight=10\n", p["MemoryMax"], p["TasksMax"], p["CPUQuota"])) |
| } |
| if name != claimControlUnit { |
| return content |
diff --git a/internal/host/demo_build_linux_test.go b/internal/host/demo_build_linux_test.go| index f96c56be9..25c29850f 100644 |
| --- a/internal/host/demo_build_linux_test.go |
| +++ b/internal/host/demo_build_linux_test.go |
| @@ -4,6 +4,7 @@ package host |
| import ( |
| "context" |
| + "fmt" |
| "os" |
| "os/exec" |
| "path/filepath" |
| @@ -151,3 +152,23 @@ func TestDemoBuildAllInstallers(t *testing.T) { |
| ensureSystemUnits(etc, filepath.Join(t.TempDir(), "lock"), ctl, probe, t.Logf) |
| check(etc, 4) |
| } |
| + |
| +func TestGVisorBuildInstallation(t *testing.T) { |
| + for n := 1; n <= 4; n++ { |
| + path := filepath.Join(t.TempDir(), "host.env") |
| + raw := fmt.Sprintf("CARLOS_EXEC_SANDBOX=gvisor\nCARLOS_DEMO_BOX=1\nCARLOS_DEMO_ACCOUNT=shop\nCARLOS_DEMO_FLEET=demo\nCARLOS_DEMO_DOMAIN=example.com\nCARLOS_DEMO_BUILD_WORKER=1\nCARLOS_DEMO_BUILD_CONCURRENCY=%d\nCARLOS_DEMO_TOOLCHAIN_DIR=/opt/demo-toolchain\n", n) |
| + if err := os.WriteFile(path, []byte(raw), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + cfg, err := readClaimUnitSettings(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + got := string(claimUnitContent("carlos-demo-builds.slice", nil, cfg)) |
| + for _, line := range []string{fmt.Sprintf("MemoryMax=%d\n", n*1107296256), fmt.Sprintf("TasksMax=%d\n", n*192), fmt.Sprintf("CPUQuota=%d%%\n", n*50), "MemorySwapMax=0\n"} { |
| + if !strings.Contains(got, line) { |
| + t.Fatal(line, got) |
| + } |
| + } |
| + } |
| +} |
diff --git a/internal/instancectl/demo_build.go b/internal/instancectl/demo_build.go| index 7331ee7c7..4d64d57fd 100644 |
| --- a/internal/instancectl/demo_build.go |
| +++ b/internal/instancectl/demo_build.go |
| @@ -175,9 +175,6 @@ func (s *Server) handleDemoBuild(w http.ResponseWriter, r *http.Request) { |
| } |
| func (s *Server) initializeDemoBuilder(ctx context.Context) error { |
| - if err := s.sandboxAdmission(ctx); err != nil { |
| - return err |
| - } |
| if s.DemoBuilder == nil { |
| return demobuild.ErrBuild |
| } |
diff --git a/internal/instancectl/demo_build_test.go b/internal/instancectl/demo_build_test.go| index 5495e276d..b860c389c 100644 |
| --- a/internal/instancectl/demo_build_test.go |
| +++ b/internal/instancectl/demo_build_test.go |
| @@ -73,7 +73,7 @@ func TestDemoBuildStartupKeepsInstanceVerbsServed(t *testing.T) { |
| for _, outcome := range []string{"success", "failure", "unavailable", "cancel"} { |
| t.Run(outcome, func(t *testing.T) { |
| b := &startupBuilder{entered: make(chan struct{}), release: make(chan struct{}), done: make(chan struct{}), fail: outcome == "failure"} |
| - s := &Server{DemoBox: true, PeerOK: func(net.Conn) error { return nil }, Systemctl: new(fakeCtl).run} |
| + s := &Server{CgroupRoot: t.TempDir(), DropInDir: t.TempDir(), removeSandbox: func(string) error { return nil }, DemoBox: true, PeerOK: func(net.Conn) error { return nil }, Systemctl: new(fakeCtl).run} |
| if outcome != "unavailable" { |
| s.DemoBuilder = b |
| } |
diff --git a/internal/instancectl/server.go b/internal/instancectl/server.go| index b86cb0bc8..f4f293226 100644 |
| --- a/internal/instancectl/server.go |
| +++ b/internal/instancectl/server.go |
| @@ -370,7 +370,7 @@ func runWithClaim(args []string, claim, heldRelease http.Handler, view RegistryV |
| s.InspectMountpoints(ctx) |
| firstProbe := make(chan struct{}) |
| builderEnv := os.Getenv |
| - if settings.Err != nil || settings.Effective == execsandbox.EffectiveGVisor { |
| + if settings.Err != nil { |
| builderEnv = func(k string) string { |
| if k == "CARLOS_DEMO_BUILD_WORKER" { |
| return "" |
| @@ -384,11 +384,14 @@ func runWithClaim(args []string, claim, heldRelease http.Handler, view RegistryV |
| case <-ctx.Done(): |
| return ctx.Err() |
| } |
| + if err := s.sandboxAdmission(ctx); err != nil { |
| + return err |
| + } |
| if _, ready := s.Ready(); !ready { |
| return demobuild.ErrBuild |
| } |
| return nil |
| - }) |
| + }, func() (execsandbox.Family, error) { return s.unitFamily(s.effectiveSandbox(), roleBuild, nil) }) |
| if err != nil { |
| log.Fatalf("instance-control: demo builder: %v", err) |
| } |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 5201f2a2d..1b425b608 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -128,4 +128,4 @@ plan14-root-reads-fix-activator-backoff-flake.tsv feba66806ddfcbdfaf369d72413bb1 |
| plan14-root-reads-region-ha-dr5.tsv f19eb78c1da1475cbf8e11a3d6c394d828aa1c8f88ae24469fe8d473581b934b |
| plan14-root-reads-instance-syscall-filter.tsv b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c |
| plan14-root-reads-instance-restore-658-cli.tsv b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c |
| -plan14-root-reads-gvisor-demos.tsv ba1df741e686c684a41c8ac7ba9edc1c2690346276423e7376b144a033d09687 |
| +plan14-root-reads-gvisor-demos.tsv 5706d5ec40dfe497b0eae7933135ef9ff9f89025c58b4721ed576516cc3ceb7a |
diff --git a/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv b/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv| index fe9e0ca6b..213ef928b 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv |
| @@ -1,10 +1,16 @@ |
| # 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. |
| -# 26 body, 33 sites, 7 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -# 59 new dispositions: 4 reads re-frozen at their disposition with the claim, 54 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| +# 33 body, 33 sites, 8 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 60 new dispositions: 4 reads re-frozen at their disposition with the claim, 55 new units frozen accepted-legacy, 1 quiet units retired while they read nothing, 0 other. |
| @legacy c704be8adc98ef362ac25f0ee4916e4bd6b7d636fbf3e62a068643790aadc9eb internal/activator/backend_unit.go UnitBackend.systemctl legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-gvisor-demos;basis=Task 5: gate launch using startup-captured mode and existing route/role/layout before preparation or execution; migrate structured root start identity and reject mismatches. Unsupported gVisor paths refuse; native behavior and existing root authority checks retained. No new root read source. file:CommandContext@332 fc3481b0f6f5410479d649b20bed2f0870bf574e67d5b00e6e47bd6262036c1b |
| @legacy bba784d6c5913e5483457620b8c6b0cea30cef7eaa19954b148cea75d1a944ae internal/activator/sidecar_ha.go ExecBackend.startHAWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-s;basis=Require nested HA sidecar shape and closed worker identity environment; prepare and acknowledge sealed secrets before writing the existing run launch file. Start the previously verified staged executable through existing root StartExe, mark uncertain starts for stop proof, and observe the same run unit. No health dial or new root verb.;rev3=census-ruling-gvisor-demos;basis=Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. registry:Host@1355,registry:Host@1391,registry:Host@2005,registry:Host@270,registry:Host@320,whole:Route@1049,whole:Route@1433,whole:Route@1504,whole:Route@1637,whole:Route@1692,whole:Route@184,whole:Route@2048,whole:Route@853 f90fb0c55c16840a832498cd96ffdbf8bbc3bc8adca210372a731679afb36edd |
| @legacy 6becaa7d7d3b47c82db5f5edc9a18c080948feeaebc835f8455a5130cadb9d5d internal/activator/unitproc.go ExecBackend.newUnitProc legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=returns newUnitProcFor's error alongside the handle; the same one site, no read added;rev3=census-ruling-gvisor-demos;basis=Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. whole:Route@220 2c4479b8182bd8f0fc235dd213776e6c59b22b341e6a470c0f690bee428f42ad |
| @legacy 8a1d54c72d48200fb3774f636caf471bc15122405399e598ffae6bd1caf25d38 internal/activator/unitproc.go unitProc.Stop legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-gvisor-demos;basis=Task 5 fix round 2: keep original-run owner stop proof failure latched until a successful plain fenced stop, in the owner Stop path. The foreign-invocation observer again completes from main's existing cgroup evidence after its plain stop attempt. Same control channel and retained unit kind; no new read. registry:Host@703,whole:Route@705 246d7bf501f06517b73496be89d55c2618ce5968fe06a259f6d6d7b0c3ebea0a |
| +@legacy 53927e0d3ea245b498cb2a72f3574b3de4d0328169afbcdc0302d64b7f057639 internal/demobuild/purge.go Worker.PurgeDemo legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads root-owned seen/job-ID marker and scratch existence; checks demo/box/job binding before existing stop/cgroup/unmount cleanup. Fix round 1: also requires the job marker host to match the purge host; no new file reads.;rev3=census-ruling-gvisor-demos;basis=Task 7: derive the selected build family for existing authenticated job retirement; cleanup proves both named families before any shared mount or bundle removal. Existing marker and scratch reads unchanged. file:Lstat@423,file:Lstat@906,file:ReadAll@581 2ec4d6cbaeece4e687ef8923a84afe6bb717ea83688266007bacf072b95675fb |
| +@legacy 00be7eb31dbc64d77c61bfd0f11bbf5274660e718896c2b870b8ff14c8d436d6 internal/demobuild/runner.go Run legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Consumes only its private root-prepared invocation, proves stop, then no-follow reads bounded diagnostics/output beneath that job.;rev3=census-ruling-gvisor-demos;basis=Task 7: retain bounded no-follow diagnostics/output reads after termination proof; filter gVisor runtime timestamp lines before returning compiler diagnostics. No new read. file:ReadAll@518 bf2258e410bd5c69ee33feb3daa5a0442f5d79ea90ac870c7df24d43349d8edf |
| +@legacy 7ccfb0e3f2aa2a684e6733ae6e9df9003bcc844622f33a187531dcc42577e878 internal/demobuild/unit.go Worker.assertUnit legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads effective sandbox, resource, environment and bind properties; missing or mismatched properties refuse compiler start.;rev3=census-ruling-gvisor-demos;basis=Task 7: gVisor branch verifies measured host properties, exact pinned command source/readback, work/cache dependencies, append diagnostics destination, physical budget and byte-identical root-derived bundle/rootfs. Native verification retained. data-literal@1729 3b549cdd23cb7c77b43d21c9f8fb82c4fdc7dc398caf5f06f02b1210becfa7e8 |
| +@legacy c01a71e80d4915f88b934d21202a8eadbd8b14292d41dbd2f905c54b331db2c7 internal/demobuild/unit.go Worker.prepareUnit legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Cleanup now has its own five-second context; stop, empty-cgroup and unmount gates remain unchanged.;rev3=census-ruling-gvisor-demos;basis=Task 7: derive family and ID from validated job/attempt; retain validated root extraction and warm overlay. gVisor uses cache-upper/view so mounted-root ownership cannot transfer cache-upper itself; chown only out/tmp/home and mounted cache directories through no-follow descriptors, then write shared OCI bundle/skeleton. No tenant-supplied path or command. file:WalkDir@3085 c244485861c5ffea9f252024523c71bc199005dde5ebee94f14604c1b02e365e |
| +@legacy 8456634cfb250bb8a182ae7013d06e838802359c6942f49be1e218ac60fde637 internal/demobuild/unit.go emptyBuildCgroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads only the derived cgroup.events path; absent directory or populated 0 proves termination.;rev3=census-ruling-gvisor-demos;basis=Task 7: retain fixed derived kernel cgroup.events read; reject duplicate or malformed populated fields rather than accepting any populated 0 substring. file:Lstat@256,file:Read@403 2f3123f43a398a5b67c4f7ded787de0d05a743a878b63cb1cc1d0204cf0db936 |
| +@legacy 95c151f83a7a2ce229c6c79b5ccd19e90101ce4ffe50a84b58557538b91f33da internal/demobuild/worker.go NewWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Wires existing root-owned recovery into cleanup retry; existing bundle/root reads unchanged.;rev3=census-ruling-agent-start-demo-3;basis=Start with snapshot recovery poisoned; builder readiness stays closed until orphan helper cleanup succeeds. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Task 7: capture only fixed policy from the supplied roleBuild callback; readiness remains per-build and during the selected-family probe. Existing root directory checks and lock unchanged. file:Stat@1419 71be598c63a7ba7e62e90905ae6b1d5b29fe79946ca7c1f814c55916bdb84f5a |
| @legacy 4ef93c4470151048cf05dc69a2c0c2375a4f25b65e6af8c33ab740705a6b33b5 internal/host/bootstrap.go bootstrapWithGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.;rev3=census-ruling-gvisor-demos;basis=Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. file:Command@12057,file:ReadFile@564,file:ReadFile@7111 2710b4ae0c444e7742e91dfffc6c136a698927eb62c42eae7cfc4eb1b06d2453 |
| @legacy ef8c8c20a6fd6daec8dc2c84b454a0cb05e9fc604300a1d3098f843ae5b6b67a internal/host/systemapply.go systemApplier.installUnits legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.;rev3=census-ruling-gvisor-demos;basis=Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. file:ReadDir@1509,file:ReadFile@1060,file:ReadFile@2100,file:ReadFile@5135,file:Stat@2758,file:Stat@4051 f20ce9ef05e19ccb08e68d7c7935aaf20175892fa2616c794ac6adad5303a8a8 |
| @legacy 396d3405311b55e3a1a748760a780bf8688577abacc3317cda791764969f5d74 internal/host/systemapply.go systemApplier.stagePlan legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupExecutable before staged bootstrap execution, matching the authorized old/new artifact through existing no-follow slot checks. New indirect marker/permit reads are root-protected; staged path still subject to existing release verification, direct read site unchanged.;rev3=census-ruling-gvisor-demos;basis=Require sandbox awareness before clearing or creating staged unit plan and invoking bootstrap. No added direct read. file:ReadDir@710 29ad3b5339fafc83341b78d5d9542c36c7919e9258aa7ac2df6a723f2c888241 |
| @@ -19,6 +25,7 @@ |
| @legacy 11be0650a243f28cddd173711c6fb6a695ac3778804055d8284b6f64efc84529 internal/activator/backend_rootfs.go uncertainWorkerProc.Stop legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. whole:Route@166 c75ed435c88311a74616e4bf44a73694e0f5f99276b92a489a15674ab849a451 |
| @legacy ccfa0c9fb480e3258ad0036dc10a42f3259a803ebe6db6257c50102a2c2eb5c1 internal/activator/sandbox.go ExecBackend.sandboxLaunch legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 5: read only existing in-memory route layout, demo marker, role, runtime and backing plus startup-captured mode/config error. AgentLaunchAllowed refuses direct/native/unsupported work in gVisor. No environment re-resolution or new filesystem path. registry:Backing@695,registry:Runtime@754,whole:Route@482 3d78de6e0c4be99af3ae7269be831588345389f4e9b8329ebab64475884e32f8 |
| @legacy c413c77d1a2bbfdf5bb2e3c653409dd489fd3992621f2ed7d30b5f9a5be34e21 internal/activator/sandbox.go UnitBackend.sandboxLaunch legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 5: read only existing in-memory route layout, demo marker, role, runtime and backing plus startup-captured mode/config error. AgentLaunchAllowed refuses direct/native/unsupported work in gVisor. No environment re-resolution or new filesystem path. registry:Runtime@298 5a09911e17377e70105f7e8c347b5354da6e82233cd8b4a189570931f3dde17a |
| +@legacy 686a7947ac6aabda8465e5c8fc533651f00b71c26b6a920da0f099ea0b7d756e internal/demobuild/gvisor.go ownBuildDirectories legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 7: walk only root-selected mounted cache view before compiler launch, reject symlinks, open directory descriptors beneath root-owned work and chown/chmod directories only. Never change cache files or lower/backing trees directly. Actual overlay upper is a view child inside root-owned cache-upper. file:WalkDir@493 4710c8a9666236838e43235e2b01a6a1f8b1f7040899ce735b94776d9d51e21a |
| @legacy 456ce0d5ff6dec6c7d779b6dc6cddd6eece5c2ebcc2e892b4805ca0b53c973fd internal/execsandbox/cleanup_linux.go bundleStore.removeDirectory legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 5: no-follow checked root-owned parent, descriptor-scoped OpenRoot removal of only BundleDir(id) or RootfsDir(id). Compare parent identity after OpenRoot; reject a symlink leaf. No launch/tenant data read. Caller holds original-start fence and has proven both siblings stopped; partial skeletons are removable. file:Lstat@699,file:OpenRoot@381,file:Stat@482,file:Stat@545 ef37850640814033411c8a6c245567a03d9b1560f526f261a6abfc50122a7c22 |
| @legacy 4fb49c7ba8d52c022c0748d216f18a99d973c0a5a858e790446558f2eff9500c internal/execsandbox/file_linux.go checkRunscDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Open and fstat root-owned no-follow runtime directories; require 0755. Paths selected by compiled pin or root-owned installation temp. file:Stat@137 39283ba464884471a3085ea8bbb9260eb7b82c7300444aff12680cbee6018a05 |
| @legacy 3a6e0c0d7ef5c570e3b1d1d803ac705cd45c84fb9b50868a9582446548a9e956 internal/execsandbox/file_linux.go openCheckedDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Walk absolute clean path from root with O_DIRECTORY/O_NOFOLLOW; fstat each ancestor for root ownership and no non-root write bits. No agent-selected path in production. file:Open@197,file:Openat@458,file:Stat@687 8b45bad16e2732bd7fdfc69a8beb7f4961936cedd7f36ad4d957b02df3e2dddf |
| @@ -105,11 +112,18 @@ internal/activator/backend_unit.go UnitBackend.systemctl legacy accepted-legacy |
| internal/activator/sidecar_ha.go ExecBackend.startHAWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-s;basis=Require nested HA sidecar shape and closed worker identity environment; prepare and acknowledge sealed secrets before writing the existing run launch file. Start the previously verified staged executable through existing root StartExe, mark uncertain starts for stop proof, and observe the same run unit. No health dial or new root verb.;rev3=census-ruling-gvisor-demos;basis=Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. registry:Host@1355,registry:Host@1391,registry:Host@2005,registry:Host@270,registry:Host@320,whole:Route@1049,whole:Route@1433,whole:Route@1504,whole:Route@1637,whole:Route@1692,whole:Route@184,whole:Route@2048,whole:Route@853 f90fb0c55c16840a832498cd96ffdbf8bbc3bc8adca210372a731679afb36edd |
| internal/activator/unitproc.go ExecBackend.newUnitProc legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=returns newUnitProcFor's error alongside the handle; the same one site, no read added;rev3=census-ruling-gvisor-demos;basis=Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. whole:Route@220 2c4479b8182bd8f0fc235dd213776e6c59b22b341e6a470c0f690bee428f42ad |
| internal/activator/unitproc.go unitProc.Stop legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-gvisor-demos;basis=Task 5 fix round 2: keep original-run owner stop proof failure latched until a successful plain fenced stop, in the owner Stop path. The foreign-invocation observer again completes from main's existing cgroup evidence after its plain stop attempt. Same control channel and retained unit kind; no new read. registry:Host@703,whole:Route@705 246d7bf501f06517b73496be89d55c2618ce5968fe06a259f6d6d7b0c3ebea0a |
| +internal/demobuild/purge.go Worker.PurgeDemo legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads root-owned seen/job-ID marker and scratch existence; checks demo/box/job binding before existing stop/cgroup/unmount cleanup. Fix round 1: also requires the job marker host to match the purge host; no new file reads.;rev3=census-ruling-gvisor-demos;basis=Task 7: derive the selected build family for existing authenticated job retirement; cleanup proves both named families before any shared mount or bundle removal. Existing marker and scratch reads unchanged. file:Lstat@423,file:Lstat@906,file:ReadAll@581 2ec4d6cbaeece4e687ef8923a84afe6bb717ea83688266007bacf072b95675fb |
| +internal/demobuild/runner.go Run legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Consumes only its private root-prepared invocation, proves stop, then no-follow reads bounded diagnostics/output beneath that job.;rev3=census-ruling-gvisor-demos;basis=Task 7: retain bounded no-follow diagnostics/output reads after termination proof; filter gVisor runtime timestamp lines before returning compiler diagnostics. No new read. file:ReadAll@518 bf2258e410bd5c69ee33feb3daa5a0442f5d79ea90ac870c7df24d43349d8edf |
| +internal/demobuild/unit.go Worker.assertUnit legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads effective sandbox, resource, environment and bind properties; missing or mismatched properties refuse compiler start.;rev3=census-ruling-gvisor-demos;basis=Task 7: gVisor branch verifies measured host properties, exact pinned command source/readback, work/cache dependencies, append diagnostics destination, physical budget and byte-identical root-derived bundle/rootfs. Native verification retained. data-literal@1729 3b549cdd23cb7c77b43d21c9f8fb82c4fdc7dc398caf5f06f02b1210becfa7e8 |
| +internal/demobuild/unit.go Worker.prepareUnit legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Cleanup now has its own five-second context; stop, empty-cgroup and unmount gates remain unchanged.;rev3=census-ruling-gvisor-demos;basis=Task 7: derive family and ID from validated job/attempt; retain validated root extraction and warm overlay. gVisor uses cache-upper/view so mounted-root ownership cannot transfer cache-upper itself; chown only out/tmp/home and mounted cache directories through no-follow descriptors, then write shared OCI bundle/skeleton. No tenant-supplied path or command. file:WalkDir@3085 c244485861c5ffea9f252024523c71bc199005dde5ebee94f14604c1b02e365e |
| +internal/demobuild/unit.go emptyBuildCgroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Reads only the derived cgroup.events path; absent directory or populated 0 proves termination.;rev3=census-ruling-gvisor-demos;basis=Task 7: retain fixed derived kernel cgroup.events read; reject duplicate or malformed populated fields rather than accepting any populated 0 substring. file:Lstat@256,file:Read@403 2f3123f43a398a5b67c4f7ded787de0d05a743a878b63cb1cc1d0204cf0db936 |
| +internal/demobuild/worker.go NewWorker legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-1;basis=Wires existing root-owned recovery into cleanup retry; existing bundle/root reads unchanged.;rev3=census-ruling-agent-start-demo-3;basis=Start with snapshot recovery poisoned; builder readiness stays closed until orphan helper cleanup succeeds. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Task 7: capture only fixed policy from the supplied roleBuild callback; readiness remains per-build and during the selected-family probe. Existing root directory checks and lock unchanged. file:Stat@1419 71be598c63a7ba7e62e90905ae6b1d5b29fe79946ca7c1f814c55916bdb84f5a |
| 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. Task 5: pass the once-captured sandbox effective mode/config error into ExecBackend, UnitBackend and the immutable Client expectation. Same startup environment/registry reads; swapArming declines gVisor before placement. file:Exec@19523,file:Open@1837,file:Statfs@50932,registry:App@12933,registry:Host@46968,whole:Route@12925,whole:Route@46126,whole:Route@47091,whole:Route@47153 dba09c350aa2bb8e85768567467346c489904eea29cfd0c3eba7ea99a0ceade5 |
| internal/host/bootstrap.go bootstrapWithGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.;rev3=census-ruling-gvisor-demos;basis=Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. file:Command@12057,file:ReadFile@564,file:ReadFile@7111 2710b4ae0c444e7742e91dfffc6c136a698927eb62c42eae7cfc4eb1b06d2453 |
| internal/host/claimactivation_preflight.go claimActivationLocalUnits authority G rev3=PROPOSED-p3;run=22;identity=agent uid carlos; root migration/adopt/control uid 0;basis=refusal-only local named-unit inventory; agent skips only ordinary claim runtime drop-in directories under /run/systemd/system, whose private contents root still inventories and verifies before launch; legacy and named units remain checked;rev3=census-ruling-gvisor-demos;basis=Fix round 1 I2: preserve the existing native preflight skip decision in a named helper for tests; ParseUnitName now returns a distinct discovery kind for gVisor so its leftover drop-ins are not skipped. Same walks and reads, no new paths or native authority. file:ReadDir@215,file:ReadFile@1303,file:ReadFile@1386,file:WalkDir@603 ed9d41211897d86e11e1797fe52ad8adacaad0766f901d0c68225ddb827421e2 |
| internal/host/claimstop_run.go RunInstanceControl authority C,D,G rev3=PROPOSED-p3;run=24;identity=root claim/adopt/update controller uid 0;basis=production root startup builds authenticated execution and launch handlers then uses activateClaimRoot for recovery, the registered census launch verifier and lifecycle start;rev3=census-ruling-rootfs-apps-2;basis=the claims-off path serves through instancectl.RunWithRegistryView with HostRuntime: instanceRegistryHostRuntime beside the same instanceRegistryHostApp(nil); the new read is instanceRegistryHostRuntime's own (a decision row in rootfs-apps-2-new); no read added in this body;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 4 and 6: the claims-off branch hands RunWithRegistryView the pre-claim egress asserter (newEgressAsserter over registryEgressSource and registryEgressHosts, which read the agent-written registry read-only, beside the instanceRegistryHostApp read it already had); the claims branch builds its runtime resources in instanceControlClaimResources, adding the claims asserter (claimsEgressSource writes no allow; the registry is read only to name slices), and serves through runClaimControl, which passes RunWithClaim the same handler, held-release route and host lookup plus that asserter. No read site in the unit, none added.;rev3=census-ruling-agent-start-demo-1;basis=Wires demo registry views and existing root release/adoption guard into instance control.;rev3=census-ruling-region-ha-p3b;basis=Add root hairpin identity verification, dormant install and reset CLI entries with bounded contexts. Indirect inputs are root-owned marker/identity/ingress/state and kernel/systemd process evidence; no request-controlled addresses or executable path. Existing control-service path remains.;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 admission and claim separation; wire host-owned exact recovery baseline and pinned-set verification/retry callbacks. No new direct read. Task 6: In effective gVisor mode serve the cleanup-capable registry-view controller before claim recovery or assembly; preserve the retained Configure error so CLAIMS and invalid config still block launches. No new direct read. 9b56b2d8c8461852e6d6af0b62397b11694fd5edfecc980a9eaa7b291a0777a8 |
| -internal/host/claimunit.go claimUnitContent authority E1,E3 rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=adds write permission for exactly the public retry directory only when the root settings reader has verified a complete census and prepared that directory;rev3=census-ruling-agent-start-demo-1;basis=Demo-only ReadWritePaths for instance data/runtime, staged files and root release lock; ordinary rendering unchanged.;rev3=census-ruling-agent-start-demo-1-followups;basis=In demo box mode, declare StateDirectory=carlos-release/private with mode 0700 so systemd creates root-owned release state before namespace setup and keeps it writable. Existing ReadWritePaths and ordinary/claims rendering stay unchanged. No new read site or caller-controlled path.;rev3=census-ruling-agent-start-demo-3;basis=Declare /var/lib/carlos-demo-snapshots as root-owned StateDirectory with mode 0700 only for configured demo boxes, including recovery with admission off. Ordinary claims units retain their original directories. The shared unit template is unchanged from main; no file read is added.;rev3=census-ruling-gvisor-demos;basis=Mark only claim/demo renderings explicitly; common host.env remains loaded. Ordinary rendering masks CARLOS_HOST_CLAIM with UnsetEnvironment, removed only for a successfully parsed enabled claim rendering. Existing template read unchanged. data-literal@1364 dc20399778b94614bc05db6f6046949008921df8e0d9adef1b0d07be097d1bd3 |
| +internal/host/claimunit.go claimUnitContent authority E1,E3 rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=adds write permission for exactly the public retry directory only when the root settings reader has verified a complete census and prepared that directory;rev3=census-ruling-agent-start-demo-1;basis=Demo-only ReadWritePaths for instance data/runtime, staged files and root release lock; ordinary rendering unchanged.;rev3=census-ruling-agent-start-demo-1-followups;basis=In demo box mode, declare StateDirectory=carlos-release/private with mode 0700 so systemd creates root-owned release state before namespace setup and keeps it writable. Existing ReadWritePaths and ordinary/claims rendering stay unchanged. No new read site or caller-controlled path.;rev3=census-ruling-agent-start-demo-3;basis=Declare /var/lib/carlos-demo-snapshots as root-owned StateDirectory with mode 0700 only for configured demo boxes, including recovery with admission off. Ordinary claims units retain their original directories. The shared unit template is unchanged from main; no file read is added.;rev3=census-ruling-gvisor-demos;basis=Mark only claim/demo renderings explicitly; common host.env remains loaded. Ordinary rendering masks CARLOS_HOST_CLAIM with UnsetEnvironment, removed only for a successfully parsed enabled claim rendering. Existing template read unchanged. Task 7: render aggregate build slice through SlicePropertiesFor using the resolved host mode, with 32 MiB and 64-task gVisor overhead per slot. Existing control permissions unchanged. data-literal@1504 90df27de34be8e60ea1b9f03dd3eff5eb8291f05b93e8a488460150f51e70725 |
| +internal/host/claimunit.go readClaimUnitSettings authority C,E3,G,J4 rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=retains exact no-census unit settings; a claims-enabled complete census prepares the root-owned retry directory before the hardened controller starts;rev3=census-ruling-agent-start-demo-1;basis=Reads worker/concurrency/toolchain settings from the existing host.env parser; requires box mode and refuses claims coexistence.;rev3=census-ruling-gvisor-demos;basis=Task 7: parse CARLOS_EXEC_SANDBOX in the existing host.env reader and resolve fixed mode for installed build-slice budgets. No new file read; invalid values refuse rendering. data-literal@167,data-literal@2091,data-literal@2823 2f4d6a1a09c9cf646ddc30339526d62cb7d9a69f613f6c786da607d21156a288 |
| internal/host/systemapply.go systemApplier.install authority F,J4 rev3=PROPOSED-p3;identity=carlos system apply, root update unit or offline root CLI, uid 0;basis=root verifies staged signature and final locked bounds before rename, then records root accepted floor history only after health succeeds;rev3=census-ruling-region-ha-p1a;basis=root apply, uid 0: comment and error text only around the beginExecutableChange call (the wrapped error now reads "update not begun" instead of "update-begun marker"); the call, its position before the first box-changing step and the deferral on error are unchanged; no read added;rev3=census-ruling-region-ha-p3b;basis=Require groupTarget for the staged new artifact and propagate quiesce refusal before effects. Root-owned operator permit must authorize digest/action/current boot; existing signed image, floor and journal checks remain; no new direct read.;rev3=census-ruling-gvisor-demos;basis=Check staged and previous executable awareness before unit-plan execution. Existing reads unchanged; no unaware prev executes in gvisor mode. a22f4cbbab3f7aea6a8f12ae494b8dfe808caee6ea6048ab7a1b8eb600945897 |
| internal/host/systemapply.go systemApplier.installUnits legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.;rev3=census-ruling-gvisor-demos;basis=Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. file:ReadDir@1509,file:ReadFile@1060,file:ReadFile@2100,file:ReadFile@5135,file:Stat@2758,file:Stat@4051 f20ce9ef05e19ccb08e68d7c7935aaf20175892fa2616c794ac6adad5303a8a8 |
| internal/host/systemapply.go systemApplier.restoreFiles authority F,J4 rev3=PROPOSED-p3;identity=carlos system apply/recover, root systemd units or offline root CLI, uid 0;basis=selects signed prev identity and checks staged restore against both root bounds before rename; version sidecar cannot authorize;rev3=census-ruling-region-ha-p3b;basis=Authorize exact previous artifact before restore, propagate quiesce refusal and remove automatic group units from enable list. Existing signature/floor and staged plan reads remain; indirect permit must be root-owned and bind old digest/current boot.;rev3=census-ruling-gvisor-demos;basis=Check prev awareness before quiesce/copy/restore and check the copied restore executable before rename. Existing stat unchanged. file:Stat@430 6a1bc52aac86cd48cde5b568cdcb8b7299227e4ac2373f60f2e92c9ab10bad25 |
| @@ -123,7 +137,7 @@ internal/instancectl/demo_policy.go Server.demoHandler legacy accepted-legacy ac |
| internal/instancectl/gen.go Server.handleParent legacy accepted-legacy accepted-legacy;rev3=J2,J4;basis=root-input;rev3=census-ruling-instance-egress-sizes-328-329;basis=#329 plan 3 Task 5: holds the host's slice lock (lockSliceWrites) around its one set-property, so /parent and /size never interleave on one slice. Its one site is still r.URL.Query() of the agent's request (counted as file:Query). The checks in this body are unchanged, though cgroup.ValidParentLimit, which it calls, now accepts one size or the sum of any two from the four-row table (up to 4 GiB, was 2 GiB); no read added.;rev3=census-ruling-agent-start-demo-1;basis=Reads fixed DemoBox and clamps the existing parent memory writer to small.;rev3=census-ruling-gvisor-demos;basis=Validate logical parent input as before, require the demo route in gVisor mode and apply Physical once to the small demo parent. Existing request query read unchanged; shares stay logical. file:Query@78 0646b2e418f426992e35bb05ec9a2c23fa0f916f7af1e4366f3ade14ddc12c69 |
| 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. Task 6: Effective gVisor refuses ROOTFS explicitly before native/rootfs probe preparation; no fallback. Existing native reads unchanged. file:ReadFile@2133 9f191518546c42664f607e5b8dbc85bc273fc7abc29bb12283edad58223b73a3 |
| 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=Select the fixed root-private probe family and delegate gVisor to its serialized root/guest proof, with no native/rootfs fallback. Task 6 fix round 1: remove mode drain from probe execution (Ready/ReadyDemo only), and let runGVisorProbe atomically publish the report/runtime identity including start lines once. Existing native report read unchanged. file:ReadFile@2874 d77aeeac7de9d58663980809014bd4c83060235b63ac4c85cf25bcb89827c80b |
| -internal/instancectl/server.go runWithClaim authority C,D,G Claim instance controller adds held-release RPC dispatch within existing launch/participation execution boundary.;rev3=census-ruling-rootfs-apps-2;basis=takes a RegistryView (HostApp and HostRuntime) for the bare hostApp, and the production Server literal gains HostRuntime, ProbeImage: BuildProbeImage, ProbeImageFile: ProbeImagePath, RootfsProbeOut under /run/carlos-control and DenyEvery: 10s; this body reads nothing new itself; the readers it wires (instanceRegistryHostRuntime, BuildProbeImage, the rootfs probe's output) are decision rows;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 4 and #329 plan 3 Task 5: takes the egress asserter as a parameter, sets it on the production Server literal (Egress) and starts its 30 s Loop beside probeLoop and diskLoop; the literal also names the fixture check ProbeFixturesOK (renamed in plan 2 Task 14). It sets no control drop-in directory: plan 3's ControlDropInDir default (/run/systemd/system.control) was deleted with removeGenControlDropIn in ef38e13b (the P1 EROFS fix), so instance control names systemd's control directory only to read it (TrustedDropinReader). The same four sites (the two exec.CommandContext closures, statfsBytes, the data literal), offsets moved; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Wires root-owned demo config and existing fixed paths into the service.;rev3=census-ruling-region-ha-p3b;basis=Resume root-owned hairpin state before probes/control service work; verify current systemd agent identity and kernel fence/addresses, restore pidfd watch or revoke stale state. Same direct exec/statfs/data sites; indirect inputs are protected root snapshot/state and kernel evidence, never receipt data.;rev3=census-ruling-agent-start-demo-3;basis=Construct the demo snapshot supervisor for configured demo boxes; startup cleanup gates builder readiness. Census read-site delta: unchanged (4).;rev3=census-ruling-gvisor-demos;basis=Retain sandbox modes and error; bind host-provided baseline and runtime callbacks without importing host templates. Existing reads unchanged. Task 6: Capture HostClaims once from ControlConfig/hostwrite.Enabled and set the fixed root-owned bundle discovery directory. Existing command and configuration reads unchanged. data-literal@2476,file:CommandContext@1109,file:CommandContext@1287,file:Statfs@2497 eebfc7f2053b6f18d4efa46a2f2b8f3296d9828bf39c45f92b047c1bbd693822 |
| +internal/instancectl/server.go runWithClaim authority C,D,G Claim instance controller adds held-release RPC dispatch within existing launch/participation execution boundary.;rev3=census-ruling-rootfs-apps-2;basis=takes a RegistryView (HostApp and HostRuntime) for the bare hostApp, and the production Server literal gains HostRuntime, ProbeImage: BuildProbeImage, ProbeImageFile: ProbeImagePath, RootfsProbeOut under /run/carlos-control and DenyEvery: 10s; this body reads nothing new itself; the readers it wires (instanceRegistryHostRuntime, BuildProbeImage, the rootfs probe's output) are decision rows;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 4 and #329 plan 3 Task 5: takes the egress asserter as a parameter, sets it on the production Server literal (Egress) and starts its 30 s Loop beside probeLoop and diskLoop; the literal also names the fixture check ProbeFixturesOK (renamed in plan 2 Task 14). It sets no control drop-in directory: plan 3's ControlDropInDir default (/run/systemd/system.control) was deleted with removeGenControlDropIn in ef38e13b (the P1 EROFS fix), so instance control names systemd's control directory only to read it (TrustedDropinReader). The same four sites (the two exec.CommandContext closures, statfsBytes, the data literal), offsets moved; no read added.;rev3=census-ruling-agent-start-demo-1;basis=Wires root-owned demo config and existing fixed paths into the service.;rev3=census-ruling-region-ha-p3b;basis=Resume root-owned hairpin state before probes/control service work; verify current systemd agent identity and kernel fence/addresses, restore pidfd watch or revoke stale state. Same direct exec/statfs/data sites; indirect inputs are protected root snapshot/state and kernel evidence, never receipt data.;rev3=census-ruling-agent-start-demo-3;basis=Construct the demo snapshot supervisor for configured demo boxes; startup cleanup gates builder readiness. Census read-site delta: unchanged (4).;rev3=census-ruling-gvisor-demos;basis=Retain sandbox modes and error; bind host-provided baseline and runtime callbacks without importing host templates. Existing reads unchanged. Task 6: Capture HostClaims once from ControlConfig/hostwrite.Enabled and set the fixed root-owned bundle discovery directory. Existing command and configuration reads unchanged. Task 7: enable gVisor worker construction through fixed unitFamily(roleBuild); readiness proof rechecks sandbox admission and current Ready without reaching the constructor fatal path for transient refusals. Existing command/config reads unchanged. data-literal@2476,file:CommandContext@1109,file:CommandContext@1287,file:Statfs@2497 51b727207f3d3b577f428a8d1cdabb214ca7b410de6e813bf1fd916446ef8321 |
| internal/instancectl/server.go type Server legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. Census ruling 292 reclassified this declaration accepted-legacy (J2,J4) for root's per-host ordering of legacy run starts against stops; this ruling kept the row as main classed it. Its own addition is the cmd start's poll and wait bounds and its per-host lock map: field declarations only;rev3=census-ruling-rootfs-apps-2;basis=new fields: HostRuntime, ProbeImage, ProbeImageFile, RootfsProbeOut, DenyEvery, the deny's lastDeny and denyMu, the rootfs probe's report and lock, the jit reload counters and imageDigests; genStarting counts binary generation starts per unit; rootfsLocksMu and rootfsLocks, one lock entry per rootfs unit name being started or removed right now, held by a start from its layout through systemctl start and its own cleanup and by a removal from its proof through the raw removal, a removal refusing while it is taken, a waiting start giving up when its request ends, an entry dropped with its last holder or waiter (fixes E6, L2, L3); rootfsProvenHook, a test hook run between the proof and the raw removal; field declarations only; no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 and #329 plan 3 Task 5: the declaration gains sliceLocks (one mutex per host slice, taken by /size and /parent) and Egress (the asserter every start path calls), and its comment names the egress allow (plan 3's ControlDropInDir field was deleted in ef38e13b, the P1 EROFS fix); the same one site, the Statfs field, offset moved; no read added.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 6: comments only: the one-shot pacing fields cover /cmd and /tty, and cmdLocks is now keyed by (role, host) (oneShotKey, PF-7) so a session's start never waits behind a command's; field declarations unchanged; the same one site, no read added;rev3=census-ruling-agent-start-demo-1;basis=Adds fixed demo configuration, registry views, derived runtime root, synchronization and purge guard.;rev3=census-ruling-region-ha-p3b;basis=Add hairpinActive boolean alongside lastDeny under existing deny synchronization. Field declaration only; existing Statfs selector unchanged, no new read or externally supplied authority.;rev3=census-ruling-region-ha-p3b2-rolls;basis=adds one field holding the current hairpin exit watcher, guarded by the root hairpin flock; no new read;rev3=census-ruling-agent-start-demo-3;basis=Retain the snapshot supervisor in instance-control state; no new request-selected path. Census read-site delta: unchanged (1).;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 mode/error/readiness fields, baseline/runtime callbacks, Task 4 per-host validated staged descriptors and root-selected probe nonce. Fix round 1 adds a private writer-operation seam assigned only in package tests, after the unchanged GVisorID admission check; production defaults still call the same checked constructor, WriteRootfs, WriteBundle and verifier. No new direct read or request-controlled callback. Task 5: private injected removal seam for unprivileged tests; production default removes only root-derived bundle and skeleton after both-family proof inside existing start fence. No new request field or agent-selected unit. Task 6: Retain serialized probe nonce, runtime-set identity verifier/token, fixed claims flag, bundle discovery root, and private unprivileged identity seam. No request-controlled callback or path; existing declaration read-site classification unchanged. Task 6 fix round 1: private gvisorProbeTestOps is set only in package tests; production defaults retain all fixed paths and the checked root output opener. No externally supplied callback or new direct read. file:Statfs@4829 1541a3b0e5f9972f07c1d94b85d1067fa83d1b24099ebf6b65d783716d4a7353 |
| system.go runSystem authority B,C,D,F,G,J4 rev3=census-ruling-self-serve-moves-1;identity=explicit operator CLI uid 0;basis=adds the lifetimes family to the system dispatch (carlos system lifetimes cutover, a console door call as the operator); every existing command branch unchanged;rev3=census-ruling-claims-cleanup-r2;basis=claims cleanup R2: drops the claims case (host.RunSystemClaims, deleted); every other branch unchanged; no read added;rev3=census-ruling-nearest-region-a;basis=adds the hosts-used family to the system dispatch (carlos system hosts-used status, one GET of a console door as the operator); every existing command branch unchanged; no read added;rev3=census-ruling-region-ha-p1a;basis=explicit operator CLI and root units, uid 0: drops the "join" case (host.RunSystemJoin, deleted with internal/host/joinroot.go, its only caller) and its line in the usage text; every other branch unchanged; no read added;rev3=census-ruling-named-unit-delivery-114;basis=the system verb dispatch gains named-units, routed to host.RunSystemNamedUnits; no read of its own;rev3=census-ruling-design-pdf-service;basis=add dispatch for carlos system pdf; no new reads;rev3=census-ruling-managed-fleets-2a;basis=Adds managed-fleets operator CLI dispatch; no direct read added; existing root command branches unchanged.;rev3=census-ruling-agent-start-demo-2;basis=system.go:62-66 adds the demos family dispatch to the console-only operator client (system_demos.go:19, system_demos_api.go:23); no direct read added and other root commands are unchanged.;rev3=census-ruling-region-ha-p3b2;basis=Dispatches carlos system group-maintenance {status|permit|revoke|prepare|apply|rollback} to internal/host; no read of its own.;rev3=census-ruling-gvisor-demos;basis=Dispatch fixed runsc-ensure and exec-sandbox-allows-prev system applets; no direct reads. b2d431b47f8d15cd017b8fd7507865f099465973c9f1eef8e5cc0ee6e3d1f588 |
| system.go systemVerb authority B,C,D,F,G,J4 rev3=census-ruling-self-serve-moves-1;identity=explicit operator CLI uid 0;basis=adds the lifetimes family to the system dispatch (carlos system lifetimes cutover, a console door call as the operator); every existing command branch unchanged;rev3=census-ruling-claims-cleanup-r2;basis=claims cleanup R2: drops "claims" from the verb list, so it now falls to the unknown-verb message; no read added;rev3=census-ruling-nearest-region-a;basis=adds "hosts-used" to the verb list, routed to runSystemHostsUsedVerb; no read added;rev3=census-ruling-region-ha-p1a;basis=explicit operator CLI and root units, uid 0: drops "join" from the verb list, so `carlos system join` now falls to the unknown-verb message; no read added;rev3=census-ruling-named-unit-delivery-114;basis=the known-verb list gains named-units; no read of its own;rev3=census-ruling-design-pdf-service;basis=add recognition for carlos system pdf; no new reads;rev3=census-ruling-managed-fleets-2a;basis=Recognizes managed-fleets as a CLI family; no read added.;rev3=census-ruling-agent-start-demo-2;basis=system.go:43-57 recognizes demos; parsing only, no direct read added.;rev3=census-ruling-region-ha-p3b2;basis=Recognizes group-maintenance as a system verb; parsing only.;rev3=census-ruling-gvisor-demos;basis=Recognize two root sandbox applets; no direct reads. 05f652ae4aa1ba135b6bb0358be5570fe13c74e385609124a66d9947ad1f906b |
| @@ -131,6 +145,7 @@ internal/activator/backend_exec.go ExecBackend.waitLegacyRunGone legacy accepted |
| internal/activator/backend_rootfs.go uncertainWorkerProc.Stop legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 5: migrate structured root start identity, validate binding, retain actual unit for observation/exit/stop. Unknown worker response retains only a cleanup request and listener, never a guessed observed identity. Existing route/control/cgroup inputs; no new root read. whole:Route@166 c75ed435c88311a74616e4bf44a73694e0f5f99276b92a489a15674ab849a451 |
| internal/activator/sandbox.go ExecBackend.sandboxLaunch legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 5: read only existing in-memory route layout, demo marker, role, runtime and backing plus startup-captured mode/config error. AgentLaunchAllowed refuses direct/native/unsupported work in gVisor. No environment re-resolution or new filesystem path. registry:Backing@695,registry:Runtime@754,whole:Route@482 3d78de6e0c4be99af3ae7269be831588345389f4e9b8329ebab64475884e32f8 |
| internal/activator/sandbox.go UnitBackend.sandboxLaunch legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 5: read only existing in-memory route layout, demo marker, role, runtime and backing plus startup-captured mode/config error. AgentLaunchAllowed refuses direct/native/unsupported work in gVisor. No environment re-resolution or new filesystem path. registry:Runtime@298 5a09911e17377e70105f7e8c347b5354da6e82233cd8b4a189570931f3dde17a |
| +internal/demobuild/gvisor.go ownBuildDirectories legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 7: walk only root-selected mounted cache view before compiler launch, reject symlinks, open directory descriptors beneath root-owned work and chown/chmod directories only. Never change cache files or lower/backing trees directly. Actual overlay upper is a view child inside root-owned cache-upper. file:WalkDir@493 4710c8a9666236838e43235e2b01a6a1f8b1f7040899ce735b94776d9d51e21a |
| internal/execsandbox/cleanup_linux.go bundleStore.removeDirectory legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 5: no-follow checked root-owned parent, descriptor-scoped OpenRoot removal of only BundleDir(id) or RootfsDir(id). Compare parent identity after OpenRoot; reject a symlink leaf. No launch/tenant data read. Caller holds original-start fence and has proven both siblings stopped; partial skeletons are removable. file:Lstat@699,file:OpenRoot@381,file:Stat@482,file:Stat@545 ef37850640814033411c8a6c245567a03d9b1560f526f261a6abfc50122a7c22 |
| internal/execsandbox/file_linux.go checkRunscDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Open and fstat root-owned no-follow runtime directories; require 0755. Paths selected by compiled pin or root-owned installation temp. file:Stat@137 39283ba464884471a3085ea8bbb9260eb7b82c7300444aff12680cbee6018a05 |
| internal/execsandbox/file_linux.go openCheckedDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Walk absolute clean path from root with O_DIRECTORY/O_NOFOLLOW; fstat each ancestor for root ownership and no non-root write bits. No agent-selected path in production. file:Open@197,file:Openat@458,file:Stat@687 8b45bad16e2732bd7fdfc69a8beb7f4961936cedd7f36ad4d957b02df3e2dddf |
| @@ -222,8 +237,9 @@ internal/host/systemapply.go systemApplier.stageCandidate legacy accepted-legacy |
| @removed internal/instancectl/demo_policy.go Server.demoCgroup H3 census-ruling-gvisor-demos;basis=Delegate the existing readback to demoCgroupReadback; wrapper has no direct read and retains its callers. |
| @coverage . e359ebe397bac9cf64ba77fb85322e55c3409dc5ca63c9a7c1dc51348ca0ade0 |
| @coverage internal/activator 3279192b5e65ed56cafc66b164553e9eb992e4dbc0f7c327c4c12aebd6163e1c |
| +@coverage internal/demobuild a4e1514f857e1a3a7a77af7aecbe35d1c7b1f38aa224a9e560e278fa2e0a6c0d |
| @coverage internal/execsandbox c7bd59e07acf65b54d2c020a9b380b64a7319569ff8cf183a33a3dbcc2360b8d |
| -@coverage internal/host 31bd5f36055951dd77509481de7ba03c5d130d99e5eded05a53ec93f3ace0682 |
| +@coverage internal/host 58ada6f86c661b8715fd72df237e295f4a862308000b50c7db2ca85d91467396 |
| @coverage internal/host/units 93402572d2fc9c32b563820a36d565afa2ed951637bde9561fe2e845137a6524 |
| -@coverage internal/instancectl 16edee001e5a53faad8da40a94a86496cb5d0c9aeca55f7e6aea00188d53d674 |
| +@coverage internal/instancectl 10e29ecda69c9f2d42612bf3c4d50817b249a324a84601bae15eb2b108d8ed69 |
| @coverage internal/instanceexec f45ee9b5ec7862c3a07fd9270b38df322c91e73f13e297813698dee30b8efd2c |