carlos / platform Public

gvisor demos: task 3 fix round 1 (host.env, one resolver, buffer)

Tolerate unrelated EnvironmentFile syntax, retain strict recovery on untrusted settings, share sandbox resolution across callers, and allocate candidate bytes once from fstat size.
Co-Authored-By: Astra (gpt-6-astra) via codex
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 315147316874db5b126852ade95fac4cf39b8a2c parent 51e4466
13 files changed, +535 −67
  • docs/superpowers/notes/census-proposal-gvisor-demos.md +3 −5
  • internal/execsandbox/config.go +21 −8
  • internal/execsandbox/config_fix1_test.go +26 −0
  • internal/host/execsandboxfix1_test.go +151 −0
  • internal/host/execsandboxfloor.go +22 −28
  • internal/host/execsandboxfloor_test.go +4 −4
  • internal/host/execsandboxresolver_test.go +140 −0
  • internal/host/runscensure.go +7 −2
  • internal/host/runscensure_test.go +6 −1
  • internal/host/sandboxenv.go +136 −0
  • internal/host/systemapply.go +9 −8
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv +9 −10

CI failed — run details

diff --git a/docs/superpowers/notes/census-proposal-gvisor-demos.md b/docs/superpowers/notes/census-proposal-gvisor-demos.md
index f655a3ead..66f3064c4 100644
--- a/docs/superpowers/notes/census-proposal-gvisor-demos.md
+++ b/docs/superpowers/notes/census-proposal-gvisor-demos.md
@@ -8,7 +8,6 @@ Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or reject
| `internal/host/bootstrap.go` `bootstrapWithGroup` | body | unchanged (3) | Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. |
| `internal/host/claimstop_run.go` `RunInstanceControl` | body | unchanged (0) | Retain Task 1 admission and claim separation; wire host-owned exact recovery baseline and pinned-set verification/retry callbacks. No new direct read. |
| `internal/host/claimunit.go` `claimUnitContent` | body | unchanged (1) | Mark only claim/demo renderings explicitly; common host.env remains loaded. Ordinary rendering masks CARLOS_HOST_CLAIM with UnsetEnvironment, removed only for a successfully parsed enabled claim rendering. Existing template read unchanged. |
-| `internal/host/systemapply.go` `systemApplier.Run` | body | unchanged (1) | Refuse malformed sandbox setting before staging cleanup or lock mutation. Existing root state reads unchanged. |
| `internal/host/systemapply.go` `systemApplier.install` | body | unchanged (0) | Check staged and previous executable awareness before unit-plan execution. Existing reads unchanged; no unaware prev executes in gvisor mode. |
| `internal/host/systemapply.go` `systemApplier.installUnits` | body | unchanged (6) | Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. |
| `internal/host/systemapply.go` `systemApplier.restoreFiles` | body | unchanged (1) | Check prev awareness before quiesce/copy/restore and check the copied restore executable before rename. Existing stat unchanged. |
@@ -23,7 +22,7 @@ Ruling `census-ruling-gvisor-demos`. The independent reviewer approves or reject
| `internal/instancectl/server.go` `type Server` | body | unchanged (1) | Retain Task 1 mode/error/readiness fields; add baseline and runtime callbacks. No new direct read. |
| `system.go` `runSystem` | body | unchanged (0) | Dispatch fixed runsc-ensure and exec-sandbox-allows-prev system applets; no direct reads. |
| `system.go` `systemVerb` | body | unchanged (0) | Recognize two root sandbox applets; no direct reads. |
-| `internal/host/systemapply.go` `systemApplier.stageCandidate` | sites | -file:OpenFile | Read agent cache once into bounded buffer; signed hash and marker before clearing staging; write those exact bytes durably and check root-owned staged binary before version execution. Removes direct OpenFile site. Retain staging on floor refusal for both apply and install-channel callers; floor authority reopens root-owned host.env by default. |
+| `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/execsandbox`, `internal/host`, `internal/host/units`, `internal/instancectl`, `internal/instanceexec`.
@@ -35,7 +34,6 @@ Recorded dispositions, which each change must still satisfy:
- `internal/host/bootstrap.go` `bootstrapWithGroup`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.
- `internal/host/claimstop_run.go` `RunInstanceControl`: authority, task C,D,G. Basis: rev3=PROPOSED-p3;run=24;identity=root claim/adopt/update controller uid 0;basis=production root startup builds authenticated execution and launch handlers then uses activateClaimRoot for recovery, the registered census launch verifier and lifecycle start;rev3=census-ruling-rootfs-apps-2;basis=the claims-off path serves through instancectl.RunWithRegistryView with HostRuntime: instanceRegistryHostRuntime beside the same instanceRegistryHostApp(nil); the new read is instanceRegistryHostRuntime's own (a decision row in rootfs-apps-2-new); no read added in this body;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 4 and 6: the claims-off branch hands RunWithRegistryView the pre-claim egress asserter (newEgressAsserter over registryEgressSource and registryEgressHosts, which read the agent-written registry read-only, beside the instanceRegistryHostApp read it already had); the claims branch builds its runtime resources in instanceControlClaimResources, adding the claims asserter (claimsEgressSource writes no allow; the registry is read only to name slices), and serves through runClaimControl, which passes RunWithClaim the same handler, held-release route and host lookup plus that asserter. No read site in the unit, none added.;rev3=census-ruling-agent-start-demo-1;basis=Wires demo registry views and existing root release/adoption guard into instance control.;rev3=census-ruling-region-ha-p3b;basis=Add root hairpin identity verification, dormant install and reset CLI entries with bounded contexts. Indirect inputs are root-owned marker/identity/ingress/state and kernel/systemd process evidence; no request-controlled addresses or executable path. Existing control-service path remains.
- `internal/host/claimunit.go` `claimUnitContent`: authority, task E1,E3. Basis: rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=adds write permission for exactly the public retry directory only when the root settings reader has verified a complete census and prepared that directory;rev3=census-ruling-agent-start-demo-1;basis=Demo-only ReadWritePaths for instance data/runtime, staged files and root release lock; ordinary rendering unchanged.;rev3=census-ruling-agent-start-demo-1-followups;basis=In demo box mode, declare StateDirectory=carlos-release/private with mode 0700 so systemd creates root-owned release state before namespace setup and keeps it writable. Existing ReadWritePaths and ordinary/claims rendering stay unchanged. No new read site or caller-controlled path.;rev3=census-ruling-agent-start-demo-3;basis=Declare /var/lib/carlos-demo-snapshots as root-owned StateDirectory with mode 0700 only for configured demo boxes, including recovery with admission off. Ordinary claims units retain their original directories. The shared unit template is unchanged from main; no file read is added.
-- `internal/host/systemapply.go` `systemApplier.Run`: authority, task D,F,J4. Basis: rev3=PROPOSED-claims-on-gate-recover;identity=root apply/recovery uid 0;basis=re-pinned at its class and task; its lock-file read is unchanged. A checkGuardRecovery error wrapping errSettlementDeferred under --recover is logged and not fatal, and the end-of-run settlement is not retried after a deferral; every other refusal returns as before. root-input;kept=D,F;scope=protected-decision-only. TestRecoverDefersACensusRefusalWithNoJournalOpen, TestApplyStillFailsACensusRefusalWithNoJournalOpen. Fix round 2: a deferral that recoverIfNeeded returns after the journal was removed is consumed the same way, with no fatal error kept and no settlement retried. TestRecoverDefersARefusalAfterTheJournalIsRemoved. Fix round 3: the end-of-run marker settlement (settleMarker, settleUpdateBegun) also goes through settleWithoutJournal, so a legacy update-begun marker with no update record and no journal defers a census refusal with the recover-legacy barrier held; a barrier that cannot be written joins the run's error in every mode; every other marker failure is logged as on main. TestRecoverHoldsAcquisitionsForALegacyMarker, TestRecoverFailsALegacyMarkerWhoseBarrierCannotBeWritten.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 15: the no-op test is split so the installed build (onDiskBuild, the same read as before) is read once; a hand-run apply then refuses a candidate below the rootfs floor v0.29.0 on a box already at or above it unless the override flag is passed; the agent's pointer path is unchanged; adds a refusal only;rev3=census-ruling-region-ha-p3b;basis=Under the apply lock require the root marker-bound maintenance permit before group staging cleanup/floor/recovery work, then bind candidate digest before staging. Marker /etc/carlos/group.json is root boot output; permit /run/carlos-group-maintenance/permit.json is operator-written through root, never the agent receipt. Direct read unchanged.;rev3=census-ruling-region-ha-p3b2;basis=Body split: lock acquisition stays in Run, the unchanged apply body moves to runLocked so group-maintenance apply/rollback run it under the command's already-held lock. Same reads and guard calls (requireGroupMaintenance check first under the lock).
- `internal/host/systemapply.go` `systemApplier.install`: authority, task F,J4. Basis: rev3=PROPOSED-p3;identity=carlos system apply, root update unit or offline root CLI, uid 0;basis=root verifies staged signature and final locked bounds before rename, then records root accepted floor history only after health succeeds;rev3=census-ruling-region-ha-p1a;basis=root apply, uid 0: comment and error text only around the beginExecutableChange call (the wrapped error now reads "update not begun" instead of "update-begun marker"); the call, its position before the first box-changing step and the deferral on error are unchanged; no read added;rev3=census-ruling-region-ha-p3b;basis=Require groupTarget for the staged new artifact and propagate quiesce refusal before effects. Root-owned operator permit must authorize digest/action/current boot; existing signed image, floor and journal checks remain; no new direct read.
- `internal/host/systemapply.go` `systemApplier.installUnits`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.
- `internal/host/systemapply.go` `systemApplier.restoreFiles`: authority, task F,J4. Basis: rev3=PROPOSED-p3;identity=carlos system apply/recover, root systemd units or offline root CLI, uid 0;basis=selects signed prev identity and checks staged restore against both root bounds before rename; version sidecar cannot authorize;rev3=census-ruling-region-ha-p3b;basis=Authorize exact previous artifact before restore, propagate quiesce refusal and remove automatic group units from enable list. Existing signature/floor and staged plan reads remain; indirect permit must be root-owned and bind old digest/current boot.
@@ -64,7 +62,7 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/host/execsandbox.go:sandboxRouteGate`: reads +registry:Runtime, +whole:Route ×2; written legacy, accepted-legacy, frozen
- new `internal/host/execsandboxfloor.go:checkExecSandboxBaselineAt`: reads +file:Lstat ×2, +file:ReadFile; written legacy, accepted-legacy, frozen
- new `internal/host/execsandboxfloor.go:sandboxHostEnvironment`: reads +file:ReadAll; written legacy, accepted-legacy, frozen
-- new `internal/host/execsandboxfloor.go:verifiedSandboxCandidate`: reads +file:ReadAll; written legacy, accepted-legacy, frozen
+- new `internal/host/execsandboxfloor.go:verifiedSandboxCandidate`: reads +file:Read; written legacy, accepted-legacy, frozen
- new `internal/host/runscensure.go:installRunscSet`: reads +file:Lstat, +file:Open; written legacy, accepted-legacy, frozen
- new `internal/host/runscensure.go:pruneRunscSets`: reads +file:ReadDir; written legacy, accepted-legacy, frozen
- new `internal/host/runscensure.go:runscCommandInventory`: reads +file:EvalSymlinks, +file:ReadAt, +file:Stat, +file:WalkDir; written legacy, accepted-legacy, frozen
@@ -77,6 +75,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the
- new `internal/host/units/carlos-runsc.service:external`: reads +file:external; written legacy, accepted-legacy, frozen
- new `internal/instanceexec/sandbox_linux.go:gvisorProbeChecks`: reads +data-literal, +file:ReadFile; written legacy, accepted-legacy, frozen
-Seal: `b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c` → `7762153da75e4ae7e3cb58b5effabf08cb60589cc8beefc0d8a0f0f4aaf3056f`.
+Seal: `b970bb28c5a633d2572a1da549030e9258cfdabb6322ddffdd0ebf41b56c464c` → `8ed02e85fcb1c633e77408ec2ca92dc4f2fd88bad9876754530d2356d4c943e3`.
Overlay: `internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/execsandbox/config.go b/internal/execsandbox/config.go
index 9e1c9d8c3..6e86bfd37 100644
--- a/internal/execsandbox/config.go
+++ b/internal/execsandbox/config.go
@@ -5,21 +5,34 @@ import (
"github.com/carlosframework/platform/internal/hostwrite"
)
-// Configure captures the process's mode and startup refusal from its environment.
-func Configure(getenv func(string) string) (Configured, Effective, error) {
+// ResolveFromEnv is the common mode decision for launch, install and recovery.
+func ResolveFromEnv(getenv func(string) string) (Configured, Effective, error) {
+ return resolveFromEnv(getenv, AutoDemoGVisor)
+}
+
+// The explicit rollout argument lets tests exercise the future auto decision.
+func resolveFromEnv(getenv func(string) string, autoDemoGVisor bool) (Configured, Effective, error) {
configured, err := Parse(getenv)
- cfg, demoErr := demo.BoxConfig(getenv)
- effective := Resolve(configured, cfg.BoxMode())
if err != nil {
- return configured, effective, err
+ return configured, EffectiveGVisor, err
+ }
+ cfg, err := demo.BoxConfig(getenv)
+ if err != nil {
+ return configured, EffectiveGVisor, err
}
- if demoErr != nil {
- return configured, effective, demoErr
+ return configured, resolve(configured, cfg.BoxMode(), autoDemoGVisor), nil
+}
+
+// Configure adds launch admission to the shared mode decision.
+func Configure(getenv func(string) string) (Configured, Effective, error) {
+ configured, effective, err := ResolveFromEnv(getenv)
+ if err != nil {
+ return configured, effective, err
}
if effective == EffectiveGVisor && hostwrite.Enabled(getenv) {
return configured, effective, ErrClaims
}
- if effective == EffectiveGVisor && !cfg.BoxMode() {
+ if effective == EffectiveGVisor && getenv("CARLOS_DEMO_BOX") != "1" {
return configured, effective, ErrUnsupported
}
return configured, effective, nil
diff --git a/internal/execsandbox/config_fix1_test.go b/internal/execsandbox/config_fix1_test.go
new file mode 100644
index 000000000..87f28ba3f
--- /dev/null
+++ b/internal/execsandbox/config_fix1_test.go
@@ -0,0 +1,26 @@
+package execsandbox
+
+import "testing"
+
+func TestExecSandboxSharedResolver(t *testing.T) {
+ env := map[string]string{"CARLOS_DEMO_BOX": "1", "CARLOS_DEMO_ACCOUNT": "demo", "CARLOS_DEMO_FLEET": "demo", "CARLOS_DEMO_DOMAIN": "demo.example", "CARLOS_EXEC_SANDBOX": "auto"}
+ get := func(k string) string { return env[k] }
+ for _, on := range []bool{false, true} {
+ _, got, err := resolveFromEnv(get, on)
+ want := EffectiveSystemd
+ if on {
+ want = EffectiveGVisor
+ }
+ if got != want || err != nil {
+ t.Fatalf("auto=%v: %s %v", on, got, err)
+ }
+ }
+ for _, bad := range []string{"invalid", "1"} {
+ broken := map[string]string{"CARLOS_DEMO_BOX": bad, "CARLOS_EXEC_SANDBOX": "auto"}
+ _, mode, err := resolveFromEnv(func(k string) string { return broken[k] }, true)
+ if err == nil || mode != EffectiveGVisor {
+ t.Fatalf("invalid demo configuration: %s %v", mode, err)
+ }
+ }
+
+}
diff --git a/internal/host/execsandboxfix1_test.go b/internal/host/execsandboxfix1_test.go
new file mode 100644
index 000000000..d39d1d0ec
--- /dev/null
+++ b/internal/host/execsandboxfix1_test.go
@@ -0,0 +1,151 @@
+package host
+
+import (
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/execsandbox"
+)
+
+func fixtureSandboxEnvironment(t *testing.T, f *applyFixture, raw string) {
+ t.Helper()
+ path := filepath.Join(f.a.etcDir, "carlos", "host.env")
+ if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(path, []byte(raw), 0600); err != nil {
+ t.Fatal(err)
+ }
+ // The existing apply fixture uses a non-root box. Only its file-opening seam
+ // differs; both floor parsing and unit rendering read this hand-edited file.
+ f.a.sandboxEnvironment = func() (func(string) string, error) {
+ body, err := os.ReadFile(path)
+ return sandboxEnvironmentValues(body), err
+ }
+}
+
+func TestExecSandboxEnvironmentSyntax(t *testing.T) {
+ for _, tc := range []struct{ raw, want string }{
+ {"; comment\n# comment\n\nNOT AN ASSIGNMENT\nOTHER=first\nOTHER=second\nCARLOS_EXEC_SANDBOX=systemd\n", "systemd"},
+ {"CARLOS_EXEC_SANDBOX=gvisor\nCARLOS_EXEC_SANDBOX=systemd\n", "systemd"},
+ {"CARLOS_EXEC_SANDBOX=systemd\nCARLOS_EXEC_SANDBOX=gvisor\n", "gvisor"},
+ {" CARLOS_EXEC_SANDBOX = \"systemd\" \t\n", "systemd"},
+ {"CARLOS_EXEC_SANDBOX='systemd'\n", "systemd"},
+ {"CARLOS_EXEC_SANDBOX=sys\\\ntemd\n", "systemd"},
+ {"CARLOS_EXEC_SANDBOX=\"sys\\\ntemd\"\n", "systemd"},
+ {"OTHER='multi\nCARLOS_EXEC_SANDBOX=gvisor\nline'\nCARLOS_EXEC_SANDBOX=systemd\n", "systemd"},
+ {"OTHER=abc\"def\nCARLOS_EXEC_SANDBOX=systemd\n", "systemd"},
+ {"CARLOS_EXEC_SANDBOX=systemd # literal\n", "systemd # literal"},
+ {"CARLOS_EXEC_SANDBOX=\"systemd\n\"\n", "systemd\n"},
+ {"CARLOS_EXEC_SANDBOX=systemd\nCARLOS_EXEC_SANDBOX=\n", ""},
+ } {
+ getenv := sandboxEnvironmentValues([]byte(tc.raw))
+ if tc.want == "systemd" {
+ if err := ensureRunsc(context.Background(), getenv, nil, nil); err != nil {
+ t.Fatalf("ordinary installer: %v", err)
+ }
+ }
+ if got := getenv("CARLOS_EXEC_SANDBOX"); got != tc.want {
+ t.Errorf("%q: got %q want %q", tc.raw, got, tc.want)
+ }
+ }
+}
+
+func TestExecSandboxHandEditedEnvironment(t *testing.T) {
+ for _, mode := range []string{"systemd", "gvisor"} {
+ t.Run(mode, func(t *testing.T) {
+ f, _ := applyHappy(t)
+ fixtureSandboxEnvironment(t, f, "; edited by hand\nBARE LINE\nOTHER=one\nOTHER=two\nCARLOS_EXEC_SANDBOX=gvisor\nCARLOS_EXEC_SANDBOX="+mode+"\n")
+ if err := f.a.Run(context.Background(), false); err != nil {
+ t.Fatal(err)
+ }
+ r := f.result()
+ if mode == "systemd" {
+ if r == nil || r.Outcome != systemOutcomeApplied {
+ t.Fatalf("apply: %+v", r)
+ }
+ } else if r == nil || !strings.Contains(r.Reason, "exec-sandbox floor") {
+ t.Fatalf("gvisor apply: %+v", r)
+ }
+ os.WriteFile(systemPrevPath(f.a.optDir), []byte("#!/bin/sh\necho carlos v1\n"), 0755)
+ writeJSONDurable(f.a.file("journal.json"), systemJournal{Phase: systemPhaseUnits, Target: "v2", PrevBuild: "v1", StartedAt: f.now}, 0600)
+ f.edgeStartedThisBoot = false
+ err := f.a.Run(context.Background(), true)
+ if mode == "systemd" {
+ if err != nil {
+ t.Fatal(err)
+ }
+ if j, _ := readSystemJournal(f.a.optDir); j != nil {
+ t.Fatal("journal remains")
+ }
+ } else {
+ if err == nil || !strings.Contains(err.Error(), "exec-sandbox floor") {
+ t.Fatalf("gvisor recovery: %v", err)
+ }
+ }
+ })
+ }
+}
+
+func TestExecSandboxUntrustedEnvironmentRecovery(t *testing.T) {
+ for _, problem := range []string{"unreadable", "untrusted", "invalid"} {
+ t.Run(problem, func(t *testing.T) {
+ f, _ := applyHappy(t)
+ f.a.sandboxEnvironment = func() (func(string) string, error) {
+ if problem == "invalid" {
+ return sandboxEnvironmentValues([]byte("CARLOS_EXEC_SANDBOX=invalid\n")), nil
+ }
+ return nil, fmt.Errorf("%s host.env", problem)
+ }
+ if err := f.a.Run(context.Background(), false); err != nil {
+ t.Fatal("forward refusal not recorded:", err)
+ }
+ if r := f.result(); r == nil || r.Outcome != systemOutcomeRefused || !strings.Contains(r.Reason, "exec-sandbox floor") {
+ t.Fatalf("refusal %+v", r)
+ }
+ // Backing-up recovery only discards an incomplete backup; it must run even
+ // with unreadable configuration, without executing either binary.
+ writeJSONDurable(f.a.file("journal.json"), systemJournal{Phase: systemPhaseBackingUp, Target: "v2", PrevBuild: "v1", StartedAt: f.now}, 0600)
+ if err := f.a.Run(context.Background(), true); err != nil {
+ t.Fatal("recovery returned configuration error:", err)
+ }
+ if j, _ := readSystemJournal(f.a.optDir); j != nil {
+ t.Fatal("backing-up journal not recovered")
+ }
+ writeJSONDurable(f.a.file("journal.json"), systemJournal{Phase: systemPhaseUnits, Target: "v2", PrevBuild: "v1", StartedAt: f.now}, 0600)
+ err := f.a.Run(context.Background(), true)
+ if err == nil || !strings.Contains(err.Error(), "exec-sandbox floor") || strings.Contains(err.Error(), problem+" host.env") {
+ t.Fatalf("strict prev check not reached: %v", err)
+ }
+ })
+ }
+}
+
+func TestExecSandboxCandidateSize(t *testing.T) {
+ b := []byte("binary")
+ sha := fmt.Sprintf("%x", sha256.Sum256(b))
+ for _, size := range []int64{-1, 0, 5, 7, systemArtifactLimit + 1} {
+ if _, err := verifiedSandboxCandidate(bytes.NewReader(b), size, sha, execsandbox.EffectiveSystemd); err == nil {
+ t.Fatalf("size %d accepted", size)
+ }
+ }
+ got, err := verifiedSandboxCandidate(bytes.NewReader(b), int64(len(b)), sha, execsandbox.EffectiveSystemd)
+ if err != nil || !bytes.Equal(got, b) || cap(got) != len(b) {
+ t.Fatalf("buffer %d/%d %v", len(got), cap(got), err)
+ }
+ if _, err := verifiedSandboxCandidate(io.MultiReader(bytes.NewReader(b), errorReader{}), int64(len(b)), sha, execsandbox.EffectiveSystemd); err == nil {
+ t.Fatal("EOF check failure accepted")
+ }
+}
+
+type errorReader struct{}
+
+func (errorReader) Read([]byte) (int, error) { return 0, errors.New("reader failed") }
diff --git a/internal/host/execsandboxfloor.go b/internal/host/execsandboxfloor.go
index 8c8611bf7..78500947e 100644
--- a/internal/host/execsandboxfloor.go
+++ b/internal/host/execsandboxfloor.go
@@ -11,7 +11,6 @@ import (
"path/filepath"
"github.com/carlosframework/platform/internal/execsandbox"
- "github.com/carlosframework/platform/internal/hostenv"
)
var errExecSandboxFloor = fmt.Errorf("%w: exec-sandbox floor", errSystemRefused)
@@ -33,37 +32,34 @@ func sandboxHostEnvironment() (func(string) string, error) {
if len(raw) > 1<<20 {
return nil, execsandbox.ErrConfig
}
- values, err := hostenv.Parse(raw)
- if err != nil {
- return nil, err
- }
- return func(key string) string { return values[key] }, nil
+ return sandboxEnvironmentValues(raw), nil
}
func RunSystemExecSandboxAllowsPrev(args []string) {
if len(args) != 1 || args[0] != "/opt/carlos/carlos.prev" {
log.Fatal(execsandbox.ErrConfig)
}
- getenv, err := sandboxHostEnvironment()
- if err != nil {
- log.Fatal(err)
- }
- configured, err := execsandbox.Parse(getenv)
- if err != nil {
- log.Fatal(err)
- }
- if err := execsandbox.AllowsBinary(execsandbox.Resolve(configured, false), args[0]); err != nil {
+ if err := sandboxAllowsPrev(sandboxHostEnvironment, args[0]); err != nil {
log.Fatal(err)
}
}
-func verifiedSandboxCandidate(src io.Reader, wantSHA string, effective execsandbox.Effective) ([]byte, error) {
- raw, err := io.ReadAll(io.LimitReader(src, systemArtifactLimit+1))
- if err != nil {
+func sandboxAllowsPrev(read func() (func(string) string, error), path string) error {
+ a := systemApplier{sandboxEnvironment: read}
+ return a.sandboxAllows(path)
+}
+
+func verifiedSandboxCandidate(src io.Reader, size int64, wantSHA string, effective execsandbox.Effective) ([]byte, error) {
+ if size < 0 || size > systemArtifactLimit {
+ return nil, fmt.Errorf("candidate: invalid size %d (limit %d)", size, systemArtifactLimit)
+ }
+ raw := make([]byte, int(size))
+ if _, err := io.ReadFull(src, raw); err != nil {
return nil, err
}
- if int64(len(raw)) > systemArtifactLimit {
- return nil, fmt.Errorf("candidate: larger than %d bytes", systemArtifactLimit)
+ var extra [1]byte
+ if n, err := src.Read(extra[:]); n != 0 || err != io.EOF {
+ return nil, errors.New("candidate: size changed or EOF check failed")
}
if got := fmt.Sprintf("%x", sha256.Sum256(raw)); got != wantSHA {
return nil, fmt.Errorf("candidate: sha256 %s does not match the signed %s", got, wantSHA)
@@ -87,19 +83,17 @@ func (a *systemApplier) sandboxMode() (execsandbox.Effective, error) {
}
getenv, err := read()
if err != nil {
- return "", fmt.Errorf("%w: %v", errExecSandboxFloor, err)
+ return execsandbox.EffectiveGVisor, fmt.Errorf("%w: %v", errExecSandboxFloor, err)
}
- configured, err := execsandbox.Parse(getenv)
+ _, effective, err := execsandbox.ResolveFromEnv(getenv)
if err != nil {
- return "", fmt.Errorf("%w: %v", errExecSandboxFloor, err)
+ return execsandbox.EffectiveGVisor, fmt.Errorf("%w: %v", errExecSandboxFloor, err)
}
- return execsandbox.Resolve(configured, false), nil
+ return effective, nil
}
func (a *systemApplier) sandboxAllows(path string) error {
- effective, err := a.sandboxMode()
- if err != nil {
- return err
- }
+ // Configuration uncertainty restricts recovery; it does not disable it.
+ effective, _ := a.sandboxMode()
if err := execsandbox.AllowsBinary(effective, path); err != nil {
return fmt.Errorf("%w: %v", errExecSandboxFloor, err)
}
diff --git a/internal/host/execsandboxfloor_test.go b/internal/host/execsandboxfloor_test.go
index 7530d5561..f40b82f73 100644
--- a/internal/host/execsandboxfloor_test.go
+++ b/internal/host/execsandboxfloor_test.go
@@ -20,7 +20,7 @@ func TestExecSandboxFloor(t *testing.T) {
if aware {
b = append(b, execsandbox.ProtocolMarker...)
}
- got, err := verifiedSandboxCandidate(bytes.NewReader(b), fmt.Sprintf("%x", sha256.Sum256(b)), mode)
+ got, err := verifiedSandboxCandidate(bytes.NewReader(b), int64(len(b)), fmt.Sprintf("%x", sha256.Sum256(b)), mode)
allowed := mode == execsandbox.EffectiveSystemd || mode == execsandbox.EffectiveGVisor && aware
if (err == nil) != allowed {
t.Fatalf("%s aware=%v: %v", mode, aware, err)
@@ -28,7 +28,7 @@ func TestExecSandboxFloor(t *testing.T) {
if allowed && !bytes.Equal(got, b) {
t.Fatal("changed bytes")
}
- if _, err := verifiedSandboxCandidate(bytes.NewReader(b), strings.Repeat("0", 64), mode); err == nil {
+ if _, err := verifiedSandboxCandidate(bytes.NewReader(b), int64(len(b)), strings.Repeat("0", 64), mode); err == nil {
t.Fatal("bad hash accepted")
}
}
@@ -112,8 +112,8 @@ func TestExecSandboxFloorNoMutation(t *testing.T) {
if r == nil || r.Reason != "refused: exec-sandbox floor" {
t.Fatalf("result %+v", r)
}
- } else if runErr == nil {
- t.Fatal("malformed setting allowed")
+ } else if runErr != nil || f.result() == nil || !strings.Contains(f.result().Reason, "EXEC-SANDBOX-CONFIG") {
+ t.Fatalf("malformed setting refusal: %v %+v", runErr, f.result())
}
if b, _ := os.ReadFile(sentinel); string(b) != "untouched" {
t.Fatal("Run removed staging after refusal")
diff --git a/internal/host/execsandboxresolver_test.go b/internal/host/execsandboxresolver_test.go
new file mode 100644
index 000000000..86427f8e4
--- /dev/null
+++ b/internal/host/execsandboxresolver_test.go
@@ -0,0 +1,140 @@
+package host
+
+import (
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/execsandbox"
+ "github.com/carlosframework/platform/internal/instancectl"
+)
+
+func TestExecSandboxResolverCallers(t *testing.T) {
+ forced := os.Getenv("CARLOS_RESOLVER_TEST_CHILD") == "1"
+ env := map[string]string{"CARLOS_DEMO_BOX": "1", "CARLOS_DEMO_ACCOUNT": "demo", "CARLOS_DEMO_FLEET": "demo", "CARLOS_DEMO_DOMAIN": "demo.example"}
+ for _, configured := range []string{"auto", "systemd", "gvisor"} {
+ env["CARLOS_EXEC_SANDBOX"] = configured
+ get := func(k string) string { return env[k] }
+ want := execsandbox.EffectiveSystemd
+ if configured == "gvisor" || configured == "auto" && forced {
+ want = execsandbox.EffectiveGVisor
+ }
+ _, agent, err := execSandboxConfig(get)
+ if err != nil || agent != want {
+ t.Fatalf("agent %s: %s %v", configured, agent, err)
+ }
+ control := instancectl.SandboxSettingsFromEnvironment(get)
+ if control.Err != nil || control.Effective != want {
+ t.Fatalf("control %s: %+v", configured, control)
+ }
+ read := func() (func(string) string, error) { return get, nil }
+ a := systemApplier{sandboxEnvironment: read}
+ floor, err := a.sandboxMode()
+ if err != nil || floor != want {
+ t.Fatalf("floor %s: %s %v", configured, floor, err)
+ }
+ required, err := runscRequired(get)
+ if err != nil || required != (want == execsandbox.EffectiveGVisor) {
+ t.Fatalf("installer %s: %v %v", configured, required, err)
+ }
+ // An absent prev is allowed only when no awareness floor applies.
+ err = sandboxAllowsPrev(read, filepath.Join(t.TempDir(), "absent-prev"))
+ if (err != nil) != (want == execsandbox.EffectiveGVisor) {
+ t.Fatalf("recovery gate %s: %v", configured, err)
+ }
+ b := []byte("unaware candidate")
+ _, err = verifiedSandboxCandidate(bytes.NewReader(b), int64(len(b)), fmt.Sprintf("%x", sha256.Sum256(b)), floor)
+ if (err != nil) != (want == execsandbox.EffectiveGVisor) {
+ t.Fatalf("candidate %s: %v", configured, err)
+ }
+ }
+ if forced {
+ return
+ }
+ root, err := filepath.Abs("../..")
+ if err != nil {
+ t.Fatal(err)
+ }
+ // Bind the tested decision helpers to their production callers.
+ for _, binding := range []struct{ file, caller, callee string }{
+ {"internal/host/agent.go", "runAgent", "execSandboxConfig"},
+ {"internal/host/claimstop_run.go", "RunInstanceControl", "execSandboxConfig"},
+ {"internal/host/execsandbox.go", "execSandboxConfig", "Configure"},
+ {"internal/instancectl/sandbox.go", "SandboxSettingsFromEnvironment", "Configure"},
+ {"internal/execsandbox/config.go", "Configure", "ResolveFromEnv"},
+ {"internal/host/execsandboxfloor.go", "sandboxMode", "ResolveFromEnv"},
+ {"internal/host/execsandboxfloor.go", "RunSystemExecSandboxAllowsPrev", "sandboxAllowsPrev"},
+ {"internal/host/execsandboxfloor.go", "sandboxAllowsPrev", "sandboxAllows"},
+ {"internal/host/execsandboxfloor.go", "sandboxAllows", "sandboxMode"},
+ {"internal/host/runscensure.go", "ensureRunsc", "runscRequired"},
+ {"internal/host/runscensure.go", "runscRequired", "ResolveFromEnv"},
+ } {
+ tree, err := parser.ParseFile(token.NewFileSet(), filepath.Join(root, binding.file), nil, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ found := false
+ for _, decl := range tree.Decls {
+ fn, ok := decl.(*ast.FuncDecl)
+ if !ok || fn.Name.Name != binding.caller {
+ continue
+ }
+ ast.Inspect(fn.Body, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+ name := ""
+ switch f := call.Fun.(type) {
+ case *ast.Ident:
+ name = f.Name
+ case *ast.SelectorExpr:
+ name = f.Sel.Name
+ }
+ if name == binding.callee {
+ found = true
+ }
+ return true
+ })
+ }
+ if !found {
+ t.Fatalf("%s: %s no longer calls %s", binding.file, binding.caller, binding.callee)
+ }
+ }
+ // Rebuild only the test dependency through the resolver's private rollout
+ // argument. Neither the shipped constant nor the checkout is edited.
+ config := filepath.Join(root, "internal/execsandbox/config.go")
+ raw, err := os.ReadFile(config)
+ if err != nil {
+ t.Fatal(err)
+ }
+ hook := []byte("resolveFromEnv(getenv, AutoDemoGVisor)")
+ if bytes.Count(raw, hook) != 1 {
+ t.Fatal("private resolver test hook changed")
+ }
+ dir := t.TempDir()
+ replacement := filepath.Join(dir, "config.go")
+ overlay := filepath.Join(dir, "overlay.json")
+ if err := os.WriteFile(replacement, bytes.Replace(raw, hook, []byte("resolveFromEnv(getenv, true)"), 1), 0600); err != nil {
+ t.Fatal(err)
+ }
+ data, _ := json.Marshal(map[string]any{"Replace": map[string]string{config: replacement}})
+ if err := os.WriteFile(overlay, data, 0600); err != nil {
+ t.Fatal(err)
+ }
+ cmd := exec.CommandContext(context.Background(), "go", "test", "-overlay", overlay, "./internal/host", "-short", "-run", "^TestExecSandboxResolverCallers$", "-count=1")
+ cmd.Dir = root
+ cmd.Env = append(os.Environ(), "CARLOS_RESOLVER_TEST_CHILD=1", "GOFLAGS=-buildvcs=false")
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("auto-demo enabled caller guard: %v\n%s", err, out)
+ }
+}
diff --git a/internal/host/runscensure.go b/internal/host/runscensure.go
index 23a865279..667d59c8e 100644
--- a/internal/host/runscensure.go
+++ b/internal/host/runscensure.go
@@ -38,12 +38,17 @@ func runscSystemctl(ctx context.Context, args ...string) (string, error) {
return string(out), err
}
+func runscRequired(getenv func(string) string) (bool, error) {
+ _, effective, err := execsandbox.ResolveFromEnv(getenv)
+ return effective == execsandbox.EffectiveGVisor, err
+}
+
func ensureRunsc(ctx context.Context, getenv func(string) string, store release.Store, systemctl func(context.Context, ...string) (string, error)) error {
- configured, err := execsandbox.Parse(getenv)
+ required, err := runscRequired(getenv)
if err != nil {
return err
}
- if execsandbox.Resolve(configured, false) == execsandbox.EffectiveSystemd {
+ if !required {
return nil
}
platform := runtime.GOOS + "-" + runtime.GOARCH
diff --git a/internal/host/runscensure_test.go b/internal/host/runscensure_test.go
index c824c7dd9..68b97bde6 100644
--- a/internal/host/runscensure_test.go
+++ b/internal/host/runscensure_test.go
@@ -33,7 +33,12 @@ func runscTestPin(t *testing.T) (execsandbox.RunscPin, map[string][]byte) {
return pin, data
}
func TestRunscEnsure(t *testing.T) {
- if err := ensureRunsc(context.Background(), func(string) string { return "systemd" }, nil, nil); err != nil {
+ if err := ensureRunsc(context.Background(), func(k string) string {
+ if k == "CARLOS_EXEC_SANDBOX" {
+ return "systemd"
+ }
+ return ""
+ }, nil, nil); err != nil {
t.Fatal(err)
}
pin, data := runscTestPin(t)
diff --git a/internal/host/sandboxenv.go b/internal/host/sandboxenv.go
new file mode 100644
index 000000000..2d6a91269
--- /dev/null
+++ b/internal/host/sandboxenv.go
@@ -0,0 +1,136 @@
+package host
+
+import "strings"
+
+// Only requested values are extracted. Unrelated assignments, comments and bare
+// lines never become configuration errors. Quoting and continuation follow
+// systemd's EnvironmentFile grammar; later assignments replace earlier ones.
+func sandboxEnvironmentValues(raw []byte) func(string) string {
+ return func(want string) string {
+ const (
+ beforeKey = iota
+ key
+ beforeValue
+ value
+ singleQuote
+ doubleQuote
+ escape
+ doubleEscape
+ comment
+ )
+ state := beforeKey
+ var name, text strings.Builder
+ selected := false
+ trailing := -1
+ result := ""
+ appendByte := func(c byte) {
+ if selected {
+ text.WriteByte(c)
+ }
+ }
+ finish := func() {
+ if selected {
+ v := text.String()
+ if state == value && trailing >= 0 {
+ v = v[:trailing]
+ }
+ result = v
+ }
+ name.Reset()
+ text.Reset()
+ selected = false
+ trailing = -1
+ state = beforeKey
+ }
+ space := func(c byte) bool { return c == ' ' || c == '\t' || c == '\r' }
+ for _, c := range raw {
+ if c == 0 {
+ break
+ }
+ switch state {
+ case beforeKey:
+ if c == '#' || c == ';' {
+ state = comment
+ } else if c != '\n' && !space(c) {
+ name.WriteByte(c)
+ state = key
+ }
+ case key:
+ if c == '\n' {
+ name.Reset()
+ state = beforeKey
+ } else if c == '=' {
+ selected = strings.TrimRight(name.String(), " \t\r") == want
+ state = beforeValue
+ } else {
+ name.WriteByte(c)
+ }
+ case beforeValue:
+ switch {
+ case c == '\n':
+ finish()
+ case c == '\'':
+ state = singleQuote
+ case c == '"':
+ state = doubleQuote
+ case c == '\\':
+ state = escape
+ case !space(c):
+ appendByte(c)
+ state = value
+ }
+ case value:
+ if c == '\n' {
+ finish()
+ } else if c == '\\' {
+ trailing = -1
+ state = escape
+ } else {
+ if space(c) {
+ if trailing < 0 {
+ trailing = text.Len()
+ }
+ } else {
+ trailing = -1
+ }
+ appendByte(c)
+ }
+ case singleQuote:
+ if c == '\'' {
+ state = beforeValue
+ } else {
+ appendByte(c)
+ }
+ case doubleQuote:
+ if c == '"' {
+ state = beforeValue
+ } else if c == '\\' {
+ state = doubleEscape
+ } else {
+ appendByte(c)
+ }
+ case escape:
+ state = value
+ if c != '\n' {
+ appendByte(c)
+ }
+ case doubleEscape:
+ state = doubleQuote
+ if c != '\n' {
+ if c != '"' && c != '\\' && c != '`' && c != '$' {
+ appendByte('\\')
+ }
+ appendByte(c)
+ }
+ case comment:
+ if c == '\n' {
+ state = beforeKey
+ }
+ }
+ }
+ if state != beforeKey && state != key && state != comment {
+ finish()
+ }
+ return result
+ }
+}
diff --git a/internal/host/systemapply.go b/internal/host/systemapply.go
index 8279daf51..6b34780f8 100644
--- a/internal/host/systemapply.go
+++ b/internal/host/systemapply.go
@@ -309,9 +309,6 @@ func (a *systemApplier) file(name string) string { return filepath.Join(a.rootDi
// journal is closed, and re-firing OnFailure= over a finished recovery
// would only start it again with nothing left to do.
func (a *systemApplier) Run(ctx context.Context, recover bool) (retErr error) {
- if _, err := a.sandboxMode(); err != nil {
- return err
- }
defer func() {
if errors.Is(retErr, context.DeadlineExceeded) {
if required, err := a.participationDisk().ParticipationRequired(context.WithoutCancel(ctx)); err == nil && required {
@@ -354,9 +351,6 @@ func (a *systemApplier) Run(ctx context.Context, recover bool) (retErr error) {
// Keep recovery, participation settlement and staging cleanup shared with apply.
func (a *systemApplier) runLocked(ctx context.Context, recover bool, operation func(context.Context) error) (retErr error) {
a.sandboxRefused = false
- if _, err := a.sandboxMode(); err != nil {
- return err
- }
a.resetGroupMaintenance()
if err := a.requireGroupMaintenance("check"); err != nil {
return err
@@ -434,6 +428,9 @@ func (a *systemApplier) runLocked(ctx context.Context, recover bool, operation f
return nil
}
if operation != nil {
+ if _, err := a.sandboxMode(); err != nil {
+ return err
+ }
return operation(ctx)
}
req, err := a.readRequest()
@@ -453,6 +450,9 @@ func (a *systemApplier) runLocked(ctx context.Context, recover bool, operation f
a.ops.logf("system apply: %s %s was already %s on this box; not applying it again", a.channel, req.Version, r.Outcome)
return nil
}
+ if _, err := a.sandboxMode(); err != nil {
+ return a.record(req, err)
+ }
p, err := a.verifyPointer(ctx)
if err != nil {
return a.record(req, err)
@@ -2403,14 +2403,15 @@ func (a *systemApplier) stageCandidate(ctx context.Context, p *release.SystemPoi
}
defer src.Close()
// openBeneath checked the inode before opening it for I/O.
- if st, err := src.Stat(); err != nil || !st.Mode().IsRegular() {
+ st, err := src.Stat()
+ if err != nil || !st.Mode().IsRegular() {
return "", errors.New("candidate: not a regular file")
}
effective, err := a.sandboxMode()
if err != nil {
return "", err
}
- raw, err := verifiedSandboxCandidate(src, art.SHA256, effective)
+ raw, err := verifiedSandboxCandidate(src, st.Size(), art.SHA256, effective)
if err != nil {
return "", err
}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index e65532ef7..3d6ba2ef9 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 7762153da75e4ae7e3cb58b5effabf08cb60589cc8beefc0d8a0f0f4aaf3056f
+plan14-root-reads-gvisor-demos.tsv 8ed02e85fcb1c633e77408ec2ca92dc4f2fd88bad9876754530d2356d4c943e3
diff --git a/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv b/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv
index 485b308af..28a143b53 100644
--- a/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv
+++ b/internal/provision/testdata/plan14-root-reads-gvisor-demos.tsv
@@ -1,5 +1,5 @@
# 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.
-# 19 body, 1 sites, 6 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 18 body, 1 sites, 6 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
# 22 new dispositions: 0 reads re-frozen at their disposition with the claim, 22 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
@legacy 4ef93c4470151048cf05dc69a2c0c2375a4f25b65e6af8c33ab740705a6b33b5 internal/host/bootstrap.go bootstrapWithGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.;rev3=census-ruling-gvisor-demos;basis=Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. file:Command@12057,file:ReadFile@564,file:ReadFile@7111 2710b4ae0c444e7742e91dfffc6c136a698927eb62c42eae7cfc4eb1b06d2453
@legacy ef8c8c20a6fd6daec8dc2c84b454a0cb05e9fc604300a1d3098f843ae5b6b67a internal/host/systemapply.go systemApplier.installUnits legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.;rev3=census-ruling-gvisor-demos;basis=Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. file:ReadDir@1509,file:ReadFile@1060,file:ReadFile@2100,file:ReadFile@5135,file:Stat@2758,file:Stat@4051 f20ce9ef05e19ccb08e68d7c7935aaf20175892fa2616c794ac6adad5303a8a8
@@ -18,8 +18,8 @@
@legacy ee7a88073c08baf804220709c6e2d7778d7d277054f413be0443d2ac431643ef internal/host/execsandbox.go sandboxExecGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read the existing registry route through injected lookup only for gVisor; require the same route admission before BeforeExec. No new path; lookup is the existing registry handle. whole:Route@493,whole:Route@587 e66292565a6718b38622cfbd0747888356fb66fca161d782399067a0db23a1f5
@legacy 8d2537e489c6d9c5782c1548a3cdabe421f20a9d4eae4b71d008d089c071a43c internal/host/execsandbox.go sandboxRouteGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read existing route layout, demo marker and runtime to refuse unsupported or direct gVisor launches before the next config gate. No new path; layout inputs are the backend's existing ones. registry:Runtime@700,whole:Route@432,whole:Route@802 6d3b45864d6e551a523e37dbec39f6d7befd414d02ce6751531ac312c7ec1d67
@legacy 8b1d8ef0abb6f01ce57096673c47b69b9a48b6922da8f8760e18f126108b2235 internal/host/execsandboxfloor.go checkExecSandboxBaselineAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Lstat journal and guard executable/census/moves paths for absence on every readiness call; compare installed recovery bytes with exact embedded unit. No guard execution or state alteration. file:Lstat@289,file:Lstat@488,file:ReadFile@617 f7e75448f38d25a703aedef82e102da70f8e9e84ce8e6aed98ecfc8a7f86b0c2
-@legacy 8c9bc81afc11dc8d6f7b5ebf7cd6125697019608113ee63aa0125a29eb4891ad internal/host/execsandboxfloor.go sandboxHostEnvironment legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Reopen fixed root-owned host.env without links, bound bytes at 1 MiB, parse with existing hostenv parser; no inherited values used as authority. file:ReadAll@296 740a2ebf07d90e3f3829361fbf18f24df4d2f73593a8f90b80b8b1a5a78c6705
-@legacy e5e5ebe17b2fc9c687f76fdf3184be0f843526192d65235794ce4842682888c0 internal/host/execsandboxfloor.go verifiedSandboxCandidate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Bounded single read of untrusted cache stream; require signed pointer SHA256 before protocol scan over same immutable byte buffer. No execution or staging mutation. file:ReadAll@125 4a41f564e8d1025a2070bae6d1e301ba48bb44bdbff29184dbb6d545094a9633
+@legacy 38062d55b0755b5d88a0704a042530cbf1de66c1a052ea50f1cefacd98e80bb5 internal/host/execsandboxfloor.go sandboxHostEnvironment legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Reopen fixed root-owned host.env with unchanged no-follow/owner/link/mode checks and 1 MiB bound. Extract only requested EnvironmentFile values with last-assignment-wins quoting/continuation semantics; unrelated comments, bare lines and duplicate assignments do not reject the file. Shared resolution requests sandbox and demo identity settings; installer may also request its store settings. No inherited values used as authority. file:ReadAll@296 797680ede1326b2f98f4765d78b8bf9c897ec1590319886e818d18ce77510353
+@legacy b5364535673f179cbb1113345c807a896dcba245ff98542f00e7c2fcb7da923c internal/host/execsandboxfloor.go verifiedSandboxCandidate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read the same untrusted candidate stream into one fstat-sized allocation capped at 96 MiB using io.ReadFull, then use one-byte Read to require EOF. Signed pointer hash and marker are checked over those exact bytes. Scanner sites change ReadAll to Read; ReadFull also consumes that already-open stream. No new file/path or execution authority. file:Read@401 c9ac211fe09e49e7e239a694614b920814735ef2de96cd479b82035e24c0e731
@legacy c5c7ce8e96666643370f65654423c247b19a4d2862e1c3d1caf890f13bb5285a internal/host/runscensure.go installRunscSet legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Check root-owned destination parent; fetch five compiled-pin object keys into exclusive temporary set, bounded hashes and fsync, verify complete set, publish by atomic directory rename/exchange. No unverified executable published. file:Lstat@431,file:Open@1395 5d1264fd744af58eb38a236203fd93b2bfeca2c8fa618fe37089ccbd1b865e14
@legacy 0f982a9b20cd4e766747e1d410ef8565645a5562c1532e4f61a30b369f4379d6 internal/host/runscensure.go pruneRunscSets legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read runtime directory only after complete command inventory; retain current/referenced sets and everything on inventory failure; remove only unreferenced 64-hex root-owned set directories. file:ReadDir@232 164a94ccd333048342691664b7a30e8b0f34b7a67d2d0f717498b5cabe41f96b
@legacy 360866378b0c01183a994d44c4137689950369e4d5963ff7b65629e65644f995 internal/host/runscensure.go runscCommandInventory legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Enumerate loaded units, jobs, installed units and checked root-owned installed unit/drop-in files; any failure retains old sets. Reads only fixed systemd roots or checked symlink destinations. file:EvalSymlinks@1559,file:ReadAt@1951,file:Stat@1817,file:WalkDir@1171 bf2d652ffb21a228a6a917b4d5280cbd59c9cddf764e2a2d8ceebaeb8e37697e
@@ -31,12 +31,11 @@
@legacy 4de04c1583d5fa335adadb7227f9ce1ec35e28280744d6571ebe92c72b4442f2 internal/host/units/carlos-instance-gvisor@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Add the unarmed root gVisor run skeleton with empty ExecStart and all twelve measured host properties. Defines per-instance data/run writable paths and socket output, root runtime directory, mixed kill with SIGCONT, and the existing bounded stop. A root-prepared validated command drop-in is required before it can start; no command or pin placeholder is installed here. file:external@0 914a3c0486d83b6b87ce14c473aab9005ff7bc004cb984040a81ddc60087a5c1
@legacy dd34ca6003fd907b4919382e5d960722556e8d322311cfa1d70b1eb76d96274d internal/host/units/carlos-runsc.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Root oneshot reads fixed root-owned host.env through its applet and installs compiled runtime set only under /opt/carlos/runsc; no RemainAfterExit. file:external@0 215ca2aea9519d14d0e20b5f9b6588b43ff7c5ef7b485982274fbbbfe2cf02b5
@legacy 6c407dd1a2b848bef09894cb174b933331bbc0b2c8147e7e533b41c9f6bb7464 internal/instanceexec/sandbox_linux.go gvisorProbeChecks legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Preliminary guest-only probe reads the fixed /proc/self/status to check empty capability sets and NoNewPrivs, and SelfCheck opens the fixed own /data/instances/_probe directory with unchanged safe-open flags. Runs as the guest carlos identity; reports readiness incomplete until the later root challenges exist. No tenant-selected host path or root authority is added. Echo CARLOS_GVISOR_PROBE_NONCE from the initial guest environment in the additive omitempty report field; root supplies the challenge in the OCI environment. No new filesystem read or readiness grant. data-literal@696,file:ReadFile@202 b201174cac395aea50cbe7c306859c47a120d1a954d988a43e9746a1386f658a
-@legacy 7de6b66932d7e63833d949ae349a5b99445cefce0cf3a60f3e5495d47fedc9c2 internal/host/systemapply.go systemApplier.stageCandidate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupStageDigest before staging/candidate execution; action and new digest come from root-owned operator permit bound to boot marker. Existing signed pointer/artifact verification and two direct read sites remain.;rev3=census-ruling-gvisor-demos;basis=Read agent cache once into bounded buffer; signed hash and marker before clearing staging; write those exact bytes durably and check root-owned staged binary before version execution. Removes direct OpenFile site. Retain staging on floor refusal for both apply and install-channel callers; floor authority reopens root-owned host.env by default. file:Stat@697 4d62d6d3fc76650d19493cdecf3a9ce47034ab5b0194fbac796e2773224c50bd
+@legacy 0284ae0a93f4d19ad551b3a2f7946966a11c0b7c8eb16529d0920f314284a530 internal/host/systemapply.go systemApplier.stageCandidate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupStageDigest before staging/candidate execution; action and new digest come from root-owned operator permit bound to boot marker. Existing signed pointer/artifact verification and two direct read sites remain.;rev3=census-ruling-gvisor-demos;basis=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. file:Stat@694 ea8c519d19786af346500c289fc768bd7047639d90154af6ec6ecefdfb41d57f
internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): builds the box's lifetime judge once (newBoxJudge, nil with host claims on) and hands it to the seed placement, the moves and runs workers and every loop it starts; read sites unchanged, offsets moved; B,C,D,F authority retained; self-serve moves 1 Task 8: derives the box's lifetimes switch from the judge once (lifetimes := boxJudge != nil) and hands it to the edges file loop; read sites unchanged, offsets moved;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 9b81d97b (with main's plan rate ceiling, edge request records, regional box names, self-serve moves plan 1, plans 4d-1 lapse and its other later changes under main's own census rulings) plus the rootfs placement wiring in the activator start: an agentRootfs built from eb.NestedOK, CARLOS_DEPLOYMENT_SINGLE_TENANT, CARLOS_POOLS, the claim flag, swapArming's answer, the control client's /ready/rootfs and, on a fleet box whose identity resolved, fleetOwnerCheck over the deploy store main already opens for the fleet label (fleetStore), then arm and armedRootfs.Store; this body reads nothing new itself; the closures it wires read later, at a rootfs wake and each status tick: GET /ready/rootfs over the control socket, NestedOK's checks, and release.FleetOwnerKey for the judged row's own account and this box's fleet from the deploy store;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 7 and 11, #329 plan 3 Task 7 and plan 1 Task 7's policy cache: the control client is built once and handed to eb.Control, to the status tick (egressStatus) and to a new egressNudgeLoop goroutine; armSizeSource(svc, "/sys/fs/cgroup") after the activator Service; armPolicyCache() after armChangeIndex; statusLoop takes egressStatus. The reads are those units' own (decision rows); this body reads nothing new: the same five sites, offsets moved, in the agent; B,C,D,F authority retained.;rev3=census-ruling-remote-instance-metrics;basis=builds the metrics loop's owners closure (metricsOwners over the agent's registry, the activator and cgm.Leftover) when an activator exists and hands it to metricsLoop; reads nothing new itself;rev3=census-ruling-edge-asset-cache-3;basis=adds file:Statfs. runAgent keeps its authority (B,C,D,F). The new site is assetcache.Statfs, an exported assetcache.FS interface value (var Statfs FS = statfsFS{}), not a function value and not a call in runAgent: the ready hook passes it to armEdgeAssetCache as the store's filesystem, and armEdgeAssetCache calls its Space method on the configured data directory (dataDir(): $CARLOS_DATA_DIR, else /data), which calls unix.Statfs there (statfsFS.Space, accepted legacy at census-ruling-edge-asset-cache-2). No request-supplied pathname reaches it.;rev3=census-ruling-remote-metrics-nested;basis=main's body (merged origin/main acfa4f80, under main's own census rulings) plus: snapshots the nested layout (snapshotNestedUnits over /sys/fs/cgroup/carlos.slice/carlos-instances.slice) once at start, before the activator, and hands the metrics loop a unitSources struct (stamped units, routeHostNames, that root and the snapshot); reads nothing new itself;rev3=census-ruling-region-ha-p1a;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): wires region HA P1a into the activator: cfg.Record = haRecordFacts(openDeployStore, boxJudge) (the box's lifetime judge this body already builds with newBoxJudge, nil with host claims on; CI fix) and cfg.Self = lease.CurrentSelf; eb.Lifetimes (the process's lifetime index), eb.Registry, eb.StartupSwept (seedSweptAtStart.Load), eb.FilesStore from newProductionFilesStore (now lease.NewFilesStore, rootaws-loaded, a log line on failure) and lease.SetObligationDir(<data>/.ha-owed) (logged on failure; HA acquires then refuse); this body reads nothing new itself, the same five sites; the reads are those units' own (haRecordFacts and lease's SetObligationDir are new rows on this card); merge of origin/main d7ae1d76: main's own later changes to this body are kept as main has them, under main's rulings (census-ruling-remote-instance-metrics: the metricsOwners closure for metricsLoop; census-ruling-edge-asset-cache-3: the +file:Statfs site, assetcache.Statfs handed to the asset ready hook); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b1;basis=region HA P1b-1: builds one termfence.Confirmer (Self from lease.CurrentSelf at each call, EC2 DescribeInstances method only, client from rootaws.LoadDefaultConfig with retries off, built lazily on first use) and sets eb.OwnerTerminated; this body reads nothing new itself, the same six sites;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 7: the startup Sweep literal hands its answer to startupSwept, which logs as before and, only on a clean sweep, marks rootfs admission swept (MarkRootfsSwept); same Sweep call, no read added;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): sets svc.Fleet = fleetWakeFor(os.Getenv, identity, identErr, fleetStore) from the identity it already resolves once and the deployment store the fleet loops already opened, and logs an ERROR naming the identity error when the box is on a fleet with an invalid identity. fleetWakeFor reads CARLOS_REGION and CARLOS_FLEET from the same environment. Read sites unchanged (6). Agent, not root; a platform box is unchanged.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 12: one call more beside armRunsPass, armInteractivePass(svc, reg, rolloutSink, boxJudge), in the same activator Configure hook, handing it the same box judge; fix round 1 (Astra P2, shutdown): after svc.Shutdown(ctx), shutdownInteractive(ctx) ends and joins every interactive session under the same shutdown budget; the worker's own reads are its units' (interactive.go); this body reads nothing new, the same six sites; merge of origin/main 6f1f6ca6: main's svc.Fleet = fleetWakeFor(...) and its invalid-identity ERROR line are kept as main has them (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (6);rev3=census-ruling-fix-set-aside-exdev;basis=set-aside EXDEV fix: one field more on the agent ExecBackend literal, RawInstanceDir: layout.RawInstanceDir (a pure path join: <dataDir>/.instances/<InstanceID(host)>), so the start rule set-aside moves a copy out through the raw directory instead of through the nosymfollow bind; this body reads nothing new, the same six sites;rev3=census-ruling-durability-3a-escrow;basis=durability 3a Task 3: one more assignment beside eb.FilesStore: eb.EscrowKey = haEscrowKey(os.Getenv("CARLOS_SECRETS_KEY")), the agent's own environment parsed by appconfig.ParsePrivateKey as the moves pass parses it (unset or unparseable: a log line and nil, and HA publication refuses on the box). No path is opened or read, no read site added; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 4: one more goroutine beside configSyncLoop: go escrowLoop(agentCtx, reg, svc), the escrow sweep every 30 s over the same registry and Service. This body reads nothing new itself; the same six sites, offsets moved; B,C,D,F authority retained. Durability 3a Task 5: one more call beside eb.EscrowKey: wireRawSecretPages(eb, PageOperator, metricsBoxLabel(os.Getenv, readMachineID())), which sets eb.OnRawSecret to page an operator (alerting.Page through PageOperator, LevelIncident) on its own goroutine with a 20 s timeout; metricsBoxLabel and readMachineID are the reads this body already makes for the moves refusal log; no new read site; the same six sites, offsets moved; B,C,D,F authority retained. Merge of origin/main 90c4d3aa: main's own later changes to this body are kept as main has them, under main's rulings; this branch's change is the same as above. Merge of origin/main 00bf5b8c (fleet set-aside EXDEV fix): main's change to this body is kept as main has it, under its own census ruling; this branch's change is unchanged.;rev3=census-ruling-probe-burst-limit;basis=two more sink wirings beside setAnalyticsSink: setProtectionSink(e.SetProtectionRecordOnly) and setAssetOwnersSource(e.AssetOwners), function values the telemetry pass calls; this body reads nothing new, the same six sites; authority B,C,D,F retained; no new root read or write kind;rev3=census-ruling-region-ha-p1b3a;basis=Arm HA placement exactly once on the existing Service before activatorStart and edges publication, wiring AwakeApps and the PageOperator callback; existing six read sites unchanged, no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: start the concrete coordinator's renewal worker with agent setup; existing closeReplicaCoordinator shutdown cancels and joins it before release. No new read sites or credentials. Merge origin/main c59715e7: retain main's armHAPlacement(svc, PageOperator) wiring beside the existing activator setup; stateless coordinator and shutdown wiring remain. Same read sites; no new root read or credential.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): in the edge-ready callback, calls act.SetHeldWakeHook(e.HeldWake) when act is non-nil (installing the non-blocking wake callback) and stores e.HeldStreamsForStatus in heldStreamsSource. Wiring of in-memory callbacks only; no read added.;rev3=census-ruling-region-ha-p1b3b-t;basis=Wire Service.SetDutyView to the live edge DutySnapshot in the ready callback. No new read; no new loop or cloud operation. B2 wires the registry as the persistent DutyStore before service startup; no new cloud or filesystem path. B3b: arm one journal-backed termination consumer before service startup using agentCtx and the shared confirmer; expose edge tick and join at edge shutdown. No new direct read sites.;rev3=census-ruling-agent-start-demo-1;basis=Passes the existing registry, data store and hibernation prefix into the demo worker, and the existing instance-control client into the demo before-exec hook. No alternate data store or polling loop. Merge resolution against origin/main 9bd45488 retains main's HA departure controller, lifecycle and duty wiring alongside the demo data store and worker; no read site added by the resolution.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: install closed fixed admission before every launch source, bind activator/backend and edge, wire the real termination Started lifecycle and role reader after the change index; close before cancellation/child shutdown. No new external reads or cloud authority. Fix R1: move bind/lifecycle/edge-option wiring into wireAgentAdmission and worker listing into runWorkerBootPassAfterAdmission. Worker boot waits for admission before listing then uses unchanged bounded wakes and per-host serialization; whole Route read moves to the helper. No new storage, cloud, or root execution authority. Preserve merged main's agent wiring and census basis; the branch removes one whole Route use by moving worker iteration to the helper, with no added read kind.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: arms a fleet-only worker using the existing registry, activator, backend and authenticated console transport. Owned worker stops and joins at shutdown. No new bucket reader. merge of origin/main 9b8b2c50: retain HA duty/departure lifecycle, wake-slot and existing agent wiring alongside the replica placement worker; no new read introduced by resolution. merge of origin/main 6be08467: Retain main demo configuration, admission, build and expiry wiring alongside the replica worker; merge-only body change, no additional read. merge of origin/main 7920cccf: Retain main box-role/group admission wiring and boot publication beside the owned replica worker and shutdown; main moves the boot registry List into runWorkerBootPassAfterAdmission, removing its inline whole Route site. No new read introduced by conflict resolution.;rev3=census-ruling-stateless-replicas-3;basis=Task 1 fix round 1 M3: retain the private snapshot source and cancel/join ownership, but use the replica-health-specific retry loop. It logs its first failure only and retains the existing exponential backoff capped at 30 seconds; unsupported builds return nil. Existing five direct read sites unchanged; no new credentials, bucket reader or app lifecycle action. Fix round 1 Q20: publish Edge.ReplicaSnapshots as a separate in-memory status source, leaving the tenant-visible Upstreams source unchanged. No new external reader or authority.;rev3=census-ruling-region-ha-p3b;basis=Load root-written group marker/configuration, configure signed boot binding and agent receipt completer, wire cancellable admission into departure work and expose cached GroupReaderSnapshot. New indirect boot reads use protected root files; agent-owned receipt controls duplicate initial completion only, never root restart permission. Same five direct sites. Merge 45cebde4 retains the replica health socket lifecycle and setReplicaSource beside GroupReaderSnapshot; no extra read beyond main.;rev3=census-ruling-agent-start-demo-2;basis=agent.go:309-329 opens demo-traffic.db beside the operator-configured registry when a demo domain exists, closes it at shutdown and wires drain-before-purge; :1010-1019 shares the worker and write gate; :1164-1177 installs the fleet identity and closed-until-worker serving callback. One added whole Route pass; the new indirect filesystem/SQL reads are claimed in openDemoTraffic and worker/store units. No request chooses the database pathname.;rev3=census-ruling-region-ha-p1b3b-s;basis=Wire the service duty view to authoritative cached sidecar manifest placement in LifetimeIndex and the edge sidecar projection; missing policy denies duty. Existing instance duty wiring remains.;rev3=census-ruling-region-ha-g2-t3;basis=T3a: wire eb.Page = PageOperator beside OwnerTerminated before departures arm, so suspect-holder pages work if departure setup fails; no new read; existing nine sites and authority unchanged; pages through the existing sink. T3b: publish the same backend through an atomic pointer for the metrics observer, and clear it on return; no new external read or authority.;rev3=census-ruling-agent-start-demo-3;basis=Wire the claim activator and root snapshot client into the demo worker; pass moved readiness to status reporting. Census read-site delta: unchanged (9).;rev3=census-ruling-region-ha-g2-fixes;basis=Wire local pool evidence, live withdrawal activator, startup ingress scan and alias publication, and edge lookup; no new direct sites; new indirect record/claim reads use existing store/judge paths described in ingress helpers.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: starts the existing record-view backstop loop with a departure-inventory listener (non-blocking, coalesced signal) even without an armed RecordView; it requests the existing full pass (backstopFullDue) there. Same nine read sites; no new read or authority.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Derive one signal-time deadline with a 90-second budget; cap departure stop and startup/seed/service shutdown joins by it. No read added.;rev3=census-ruling-static-sweep-periodic;basis=in the edge-ready callback, publishes e.LargestStaticTree in staticTreeSource for the disk alert line (diskAlertFrac in the metrics loop); in-memory wiring only, no read added; read sites unchanged (9);rev3=census-ruling-gvisor-demos;basis=Capture sandbox resolution and refusal once; log errors once; gate route admission and BeforeExec before process launch. No new root read. file:Exec@19431,file:Open@1837,file:Statfs@50774,registry:App@12933,registry:Host@46810,whole:Route@12925,whole:Route@45968,whole:Route@46933,whole:Route@46995 c618605dd17ada0fb0b53b3c4d2176fd737c4f44b38a25298fbc1c48bae9fa0e
internal/host/bootstrap.go bootstrapWithGroup legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p3b;basis=Move bootstrapWith body here, retaining host.env, embedded unit reads and tmpfiles execution. Group live caller holds root mutation guard; skip automatic update/recovery units, preserve Restart=no/nftables drop-in and masks, and write separate root-owned /run/carlos-group-maintenance tmpfiles rule outside service ownership walk. No agent receipt read.;rev3=census-ruling-gvisor-demos;basis=Create the rootfs parent at 0700 and runtime root at 0755. Existing host.env/unit reads unchanged; workload templates remain unarmed. file:Command@12057,file:ReadFile@564,file:ReadFile@7111 2710b4ae0c444e7742e91dfffc6c136a698927eb62c42eae7cfc4eb1b06d2453
internal/host/claimstop_run.go RunInstanceControl authority C,D,G rev3=PROPOSED-p3;run=24;identity=root claim/adopt/update controller uid 0;basis=production root startup builds authenticated execution and launch handlers then uses activateClaimRoot for recovery, the registered census launch verifier and lifecycle start;rev3=census-ruling-rootfs-apps-2;basis=the claims-off path serves through instancectl.RunWithRegistryView with HostRuntime: instanceRegistryHostRuntime beside the same instanceRegistryHostApp(nil); the new read is instanceRegistryHostRuntime's own (a decision row in rootfs-apps-2-new); no read added in this body;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Tasks 4 and 6: the claims-off branch hands RunWithRegistryView the pre-claim egress asserter (newEgressAsserter over registryEgressSource and registryEgressHosts, which read the agent-written registry read-only, beside the instanceRegistryHostApp read it already had); the claims branch builds its runtime resources in instanceControlClaimResources, adding the claims asserter (claimsEgressSource writes no allow; the registry is read only to name slices), and serves through runClaimControl, which passes RunWithClaim the same handler, held-release route and host lookup plus that asserter. No read site in the unit, none added.;rev3=census-ruling-agent-start-demo-1;basis=Wires demo registry views and existing root release/adoption guard into instance control.;rev3=census-ruling-region-ha-p3b;basis=Add root hairpin identity verification, dormant install and reset CLI entries with bounded contexts. Indirect inputs are root-owned marker/identity/ingress/state and kernel/systemd process evidence; no request-controlled addresses or executable path. Existing control-service path remains.;rev3=census-ruling-gvisor-demos;basis=Retain Task 1 admission and claim separation; wire host-owned exact recovery baseline and pinned-set verification/retry callbacks. No new direct read. adec0e3fbfd7af8ccf056cf35334bff29c4a8555cfed4ce0de4617199838e790
internal/host/claimunit.go claimUnitContent authority E1,E3 rev3=PROPOSED-p3;identity=root claim/adoption controller uid 0;basis=adds write permission for exactly the public retry directory only when the root settings reader has verified a complete census and prepared that directory;rev3=census-ruling-agent-start-demo-1;basis=Demo-only ReadWritePaths for instance data/runtime, staged files and root release lock; ordinary rendering unchanged.;rev3=census-ruling-agent-start-demo-1-followups;basis=In demo box mode, declare StateDirectory=carlos-release/private with mode 0700 so systemd creates root-owned release state before namespace setup and keeps it writable. Existing ReadWritePaths and ordinary/claims rendering stay unchanged. No new read site or caller-controlled path.;rev3=census-ruling-agent-start-demo-3;basis=Declare /var/lib/carlos-demo-snapshots as root-owned StateDirectory with mode 0700 only for configured demo boxes, including recovery with admission off. Ordinary claims units retain their original directories. The shared unit template is unchanged from main; no file read is added.;rev3=census-ruling-gvisor-demos;basis=Mark only claim/demo renderings explicitly; common host.env remains loaded. Ordinary rendering masks CARLOS_HOST_CLAIM with UnsetEnvironment, removed only for a successfully parsed enabled claim rendering. Existing template read unchanged. data-literal@1364 dc20399778b94614bc05db6f6046949008921df8e0d9adef1b0d07be097d1bd3
-internal/host/systemapply.go systemApplier.Run authority D,F,J4 rev3=PROPOSED-claims-on-gate-recover;identity=root apply/recovery uid 0;basis=re-pinned at its class and task; its lock-file read is unchanged. A checkGuardRecovery error wrapping errSettlementDeferred under --recover is logged and not fatal, and the end-of-run settlement is not retried after a deferral; every other refusal returns as before. root-input;kept=D,F;scope=protected-decision-only. TestRecoverDefersACensusRefusalWithNoJournalOpen, TestApplyStillFailsACensusRefusalWithNoJournalOpen. Fix round 2: a deferral that recoverIfNeeded returns after the journal was removed is consumed the same way, with no fatal error kept and no settlement retried. TestRecoverDefersARefusalAfterTheJournalIsRemoved. Fix round 3: the end-of-run marker settlement (settleMarker, settleUpdateBegun) also goes through settleWithoutJournal, so a legacy update-begun marker with no update record and no journal defers a census refusal with the recover-legacy barrier held; a barrier that cannot be written joins the run's error in every mode; every other marker failure is logged as on main. TestRecoverHoldsAcquisitionsForALegacyMarker, TestRecoverFailsALegacyMarkerWhoseBarrierCannotBeWritten.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 15: the no-op test is split so the installed build (onDiskBuild, the same read as before) is read once; a hand-run apply then refuses a candidate below the rootfs floor v0.29.0 on a box already at or above it unless the override flag is passed; the agent's pointer path is unchanged; adds a refusal only;rev3=census-ruling-region-ha-p3b;basis=Under the apply lock require the root marker-bound maintenance permit before group staging cleanup/floor/recovery work, then bind candidate digest before staging. Marker /etc/carlos/group.json is root boot output; permit /run/carlos-group-maintenance/permit.json is operator-written through root, never the agent receipt. Direct read unchanged.;rev3=census-ruling-region-ha-p3b2;basis=Body split: lock acquisition stays in Run, the unchanged apply body moves to runLocked so group-maintenance apply/rollback run it under the command's already-held lock. Same reads and guard calls (requireGroupMaintenance check first under the lock).;rev3=census-ruling-gvisor-demos;basis=Refuse malformed sandbox setting before staging cleanup or lock mutation. Existing root state reads unchanged. file:OpenFile@583 75842202c3bf5222cdf9040c1c91454e074cdc780eee45eb8de8a2a184a769ff
internal/host/systemapply.go systemApplier.install authority F,J4 rev3=PROPOSED-p3;identity=carlos system apply, root update unit or offline root CLI, uid 0;basis=root verifies staged signature and final locked bounds before rename, then records root accepted floor history only after health succeeds;rev3=census-ruling-region-ha-p1a;basis=root apply, uid 0: comment and error text only around the beginExecutableChange call (the wrapped error now reads "update not begun" instead of "update-begun marker"); the call, its position before the first box-changing step and the deferral on error are unchanged; no read added;rev3=census-ruling-region-ha-p3b;basis=Require groupTarget for the staged new artifact and propagate quiesce refusal before effects. Root-owned operator permit must authorize digest/action/current boot; existing signed image, floor and journal checks remain; no new direct read.;rev3=census-ruling-gvisor-demos;basis=Check staged and previous executable awareness before unit-plan execution. Existing reads unchanged; no unaware prev executes in gvisor mode. a22f4cbbab3f7aea6a8f12ae494b8dfe808caee6ea6048ab7a1b8eb600945897
internal/host/systemapply.go systemApplier.installUnits legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-agent-start-demo-1;basis=Renders the staged build slice against live root host configuration; preserves it when settings cannot be parsed.;rev3=census-ruling-region-ha-p3b;basis=Require group apply/rollback permit, preserve root Restart=no/nftables drop-in and masks, and skip automatic update/recovery units. Existing staged unit and host.env reads remain; new indirect marker/permit reads are protected and agent receipts are excluded.;rev3=census-ruling-gvisor-demos;basis=Create rootfs/runtime parent directories before controller restart. Existing staged unit and root-owned host.env reads unchanged. file:ReadDir@1509,file:ReadFile@1060,file:ReadFile@2100,file:ReadFile@5135,file:Stat@2758,file:Stat@4051 f20ce9ef05e19ccb08e68d7c7935aaf20175892fa2616c794ac6adad5303a8a8
internal/host/systemapply.go systemApplier.restoreFiles authority F,J4 rev3=PROPOSED-p3;identity=carlos system apply/recover, root systemd units or offline root CLI, uid 0;basis=selects signed prev identity and checks staged restore against both root bounds before rename; version sidecar cannot authorize;rev3=census-ruling-region-ha-p3b;basis=Authorize exact previous artifact before restore, propagate quiesce refusal and remove automatic group units from enable list. Existing signature/floor and staged plan reads remain; indirect permit must be root-owned and bind old digest/current boot.;rev3=census-ruling-gvisor-demos;basis=Check prev awareness before quiesce/copy/restore and check the copied restore executable before rename. Existing stat unchanged. file:Stat@430 6a1bc52aac86cd48cde5b568cdcb8b7299227e4ac2373f60f2e92c9ab10bad25
@@ -60,8 +59,8 @@ internal/execsandbox/verifier.go RunscVerifier.verify legacy accepted-legacy acc
internal/host/execsandbox.go sandboxExecGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read the existing registry route through injected lookup only for gVisor; require the same route admission before BeforeExec. No new path; lookup is the existing registry handle. whole:Route@493,whole:Route@587 e66292565a6718b38622cfbd0747888356fb66fca161d782399067a0db23a1f5
internal/host/execsandbox.go sandboxRouteGate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read existing route layout, demo marker and runtime to refuse unsupported or direct gVisor launches before the next config gate. No new path; layout inputs are the backend's existing ones. registry:Runtime@700,whole:Route@432,whole:Route@802 6d3b45864d6e551a523e37dbec39f6d7befd414d02ce6751531ac312c7ec1d67
internal/host/execsandboxfloor.go checkExecSandboxBaselineAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Lstat journal and guard executable/census/moves paths for absence on every readiness call; compare installed recovery bytes with exact embedded unit. No guard execution or state alteration. file:Lstat@289,file:Lstat@488,file:ReadFile@617 f7e75448f38d25a703aedef82e102da70f8e9e84ce8e6aed98ecfc8a7f86b0c2
-internal/host/execsandboxfloor.go sandboxHostEnvironment legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Reopen fixed root-owned host.env without links, bound bytes at 1 MiB, parse with existing hostenv parser; no inherited values used as authority. file:ReadAll@296 740a2ebf07d90e3f3829361fbf18f24df4d2f73593a8f90b80b8b1a5a78c6705
-internal/host/execsandboxfloor.go verifiedSandboxCandidate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Bounded single read of untrusted cache stream; require signed pointer SHA256 before protocol scan over same immutable byte buffer. No execution or staging mutation. file:ReadAll@125 4a41f564e8d1025a2070bae6d1e301ba48bb44bdbff29184dbb6d545094a9633
+internal/host/execsandboxfloor.go sandboxHostEnvironment legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Reopen fixed root-owned host.env with unchanged no-follow/owner/link/mode checks and 1 MiB bound. Extract only requested EnvironmentFile values with last-assignment-wins quoting/continuation semantics; unrelated comments, bare lines and duplicate assignments do not reject the file. Shared resolution requests sandbox and demo identity settings; installer may also request its store settings. No inherited values used as authority. file:ReadAll@296 797680ede1326b2f98f4765d78b8bf9c897ec1590319886e818d18ce77510353
+internal/host/execsandboxfloor.go verifiedSandboxCandidate legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read the same untrusted candidate stream into one fstat-sized allocation capped at 96 MiB using io.ReadFull, then use one-byte Read to require EOF. Signed pointer hash and marker are checked over those exact bytes. Scanner sites change ReadAll to Read; ReadFull also consumes that already-open stream. No new file/path or execution authority. file:Read@401 c9ac211fe09e49e7e239a694614b920814735ef2de96cd479b82035e24c0e731
internal/host/runscensure.go installRunscSet legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Check root-owned destination parent; fetch five compiled-pin object keys into exclusive temporary set, bounded hashes and fsync, verify complete set, publish by atomic directory rename/exchange. No unverified executable published. file:Lstat@431,file:Open@1395 5d1264fd744af58eb38a236203fd93b2bfeca2c8fa618fe37089ccbd1b865e14
internal/host/runscensure.go pruneRunscSets legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Read runtime directory only after complete command inventory; retain current/referenced sets and everything on inventory failure; remove only unreferenced 64-hex root-owned set directories. file:ReadDir@232 164a94ccd333048342691664b7a30e8b0f34b7a67d2d0f717498b5cabe41f96b
internal/host/runscensure.go runscCommandInventory legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Enumerate loaded units, jobs, installed units and checked root-owned installed unit/drop-in files; any failure retains old sets. Reads only fixed systemd roots or checked symlink destinations. file:EvalSymlinks@1559,file:ReadAt@1951,file:Stat@1817,file:WalkDir@1171 bf2d652ffb21a228a6a917b4d5280cbd59c9cddf764e2a2d8ceebaeb8e37697e
@@ -73,10 +72,10 @@ internal/host/units/carlos-instance-gvisor-probe.service external legacy accepte
internal/host/units/carlos-instance-gvisor@.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Add the unarmed root gVisor run skeleton with empty ExecStart and all twelve measured host properties. Defines per-instance data/run writable paths and socket output, root runtime directory, mixed kill with SIGCONT, and the existing bounded stop. A root-prepared validated command drop-in is required before it can start; no command or pin placeholder is installed here. file:external@0 914a3c0486d83b6b87ce14c473aab9005ff7bc004cb984040a81ddc60087a5c1
internal/host/units/carlos-runsc.service external legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Root oneshot reads fixed root-owned host.env through its applet and installs compiled runtime set only under /opt/carlos/runsc; no RemainAfterExit. file:external@0 215ca2aea9519d14d0e20b5f9b6588b43ff7c5ef7b485982274fbbbfe2cf02b5
internal/instanceexec/sandbox_linux.go gvisorProbeChecks legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Preliminary guest-only probe reads the fixed /proc/self/status to check empty capability sets and NoNewPrivs, and SelfCheck opens the fixed own /data/instances/_probe directory with unchanged safe-open flags. Runs as the guest carlos identity; reports readiness incomplete until the later root challenges exist. No tenant-selected host path or root authority is added. Echo CARLOS_GVISOR_PROBE_NONCE from the initial guest environment in the additive omitempty report field; root supplies the challenge in the OCI environment. No new filesystem read or readiness grant. data-literal@696,file:ReadFile@202 b201174cac395aea50cbe7c306859c47a120d1a954d988a43e9746a1386f658a
-internal/host/systemapply.go systemApplier.stageCandidate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupStageDigest before staging/candidate execution; action and new digest come from root-owned operator permit bound to boot marker. Existing signed pointer/artifact verification and two direct read sites remain.;rev3=census-ruling-gvisor-demos;basis=Read agent cache once into bounded buffer; signed hash and marker before clearing staging; write those exact bytes durably and check root-owned staged binary before version execution. Removes direct OpenFile site. Retain staging on floor refusal for both apply and install-channel callers; floor authority reopens root-owned host.env by default. file:Stat@697 4d62d6d3fc76650d19493cdecf3a9ce47034ab5b0194fbac796e2773224c50bd
+internal/host/systemapply.go systemApplier.stageCandidate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-region-ha-p3b;basis=Require groupStageDigest before staging/candidate execution; action and new digest come from root-owned operator permit bound to boot marker. Existing signed pointer/artifact verification and two direct read sites remain.;rev3=census-ruling-gvisor-demos;basis=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. file:Stat@694 ea8c519d19786af346500c289fc768bd7047639d90154af6ec6ecefdfb41d57f
@coverage . e359ebe397bac9cf64ba77fb85322e55c3409dc5ca63c9a7c1dc51348ca0ade0
-@coverage internal/execsandbox 25dd9c82cb6ff1b682f1acbd921012d8b7ca01ed1b73be91592bf63d04dbca29
-@coverage internal/host 5f87b62537235d16958a6d0f68f12e3fc31f45bdc662749696c171f6bdace336
+@coverage internal/execsandbox 99bcd711051dfb53d8c9b2e36c059271b47a940779777f6734d49fc102617465
+@coverage internal/host 4afed13ce7dc29d1f8e0d58ea174010846c71273a80b7475a7390e33501f96cf
@coverage internal/host/units 93402572d2fc9c32b563820a36d565afa2ed951637bde9561fe2e845137a6524
@coverage internal/instancectl 540d394b34894c830106f093152a449f152a51f6fd422ab9a9595c96a9beef7f
@coverage internal/instanceexec 451a4cb9a8fc078f883afab1c361678185c332a1e294c24420ab4ae2fb3face9