carlos / platform Public

fix: snapshot unit check accepts systemd's omitted empty property

codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev 9f1ea42ce9d5bdb1175cd98fa9b5a8d0141688d0 parent 7bab947
7 files changed, +137 −3
  • docs/superpowers/notes/census-demo-snapshot-unit-check-claims.md +1 −0
  • docs/superpowers/notes/census-proposal-demo-snapshot-unit-check.md +19 −0
  • internal/instancectl/demo_snapshot_disk.go +3 −3
  • internal/instancectl/demo_snapshot_unit_test.go +51 −0
  • internal/instancectl/testdata/systemd257-snapshot-unit.txt +57 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-demo-snapshot-unit-check.tsv +5 −0

CI passed — run details

Intent

Human

<paseo-system version="1" kind="agent-message" source-agent-id="39e7acfa-a56a-470b-8ef5-70de5c57a6f2" message-id="2663ba2c-829a-4665-97c3-69d741a852d5" source-agent-title="agent /start demo program controller"> From 39e7acfa: A, then B. Run the witness on the root runner now: a throwaway t4g.small in dev (kass), the existing root-runner pattern; my brief allows a small dev box for minutes. Terminate it at the end, confirm it&apos;s gone, and record the instance ID and its termination on #527. Hold the merge until the witness result, so any fault lands on the same branch (at most two more fault rounds, then stop and report). B follows naturally: after v0.34.12 reaches box-1, the claimAvailable check and your prepare.sh, with no live-demo conflict, are the real-box proof. </paseo-system>

Attributed to this commit: 13.8 g CO₂e (1,810,557 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on demo-snapshot-unit-check, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/docs/superpowers/notes/census-demo-snapshot-unit-check-claims.md b/docs/superpowers/notes/census-demo-snapshot-unit-check-claims.md
new file mode 100644
index 000000000..c5820b517
--- /dev/null
+++ b/docs/superpowers/notes/census-demo-snapshot-unit-check-claims.md
@@ -0,0 +1 @@
+internal/instancectl/demo_snapshot_disk.go:demoSnapshotSupervisor.checkUnit Accept an omitted EnvironmentFiles property as empty, as emitted by systemd 257; continue requesting it and reject every non-empty value. All other property checks remain unchanged. No read added; the existing systemctl query requests the same properties.
diff --git a/docs/superpowers/notes/census-proposal-demo-snapshot-unit-check.md b/docs/superpowers/notes/census-proposal-demo-snapshot-unit-check.md
new file mode 100644
index 000000000..e2f496a7f
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-demo-snapshot-unit-check.md
@@ -0,0 +1,19 @@
+# Census approval: demo-snapshot-unit-check
+
+Ruling `census-ruling-demo-snapshot-unit-check`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/instancectl/demo_snapshot_disk.go` `demoSnapshotSupervisor.checkUnit` | body | unchanged (1) | Accept an omitted EnvironmentFiles property as empty, as emitted by systemd 257; continue requesting it and reject every non-empty value. All other property checks remain unchanged. No read added; the existing systemctl query requests the same properties. |
+
+Envelopes re-pinned: `internal/instancectl`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/instancectl/demo_snapshot_disk.go` `demoSnapshotSupervisor.checkUnit`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-agent-start-demo-3;basis=Inspect the effective fixed systemd snapshot unit and require its declared isolation, resource and execution settings. Census read-site delta: +data-literal.
+
+Seal: `ebeaa693941f5592cd7bc3458effc2a333a8d12ba4f192a93d0aa32589048939` → `62613178975daa6640bb46d87f143bf5291e51921e350b6c731438a77daf61f7`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-demo-snapshot-unit-check.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/instancectl/demo_snapshot_disk.go b/internal/instancectl/demo_snapshot_disk.go
index 58283afdf..8f9f4e529 100644
--- a/internal/instancectl/demo_snapshot_disk.go
+++ b/internal/instancectl/demo_snapshot_disk.go
@@ -130,9 +130,9 @@ func (p *demoSnapshotSupervisor) checkUnit(ctx context.Context, id string) error
"MemoryDenyWriteExecute": "yes", "NetworkNamespacePath": "", "JoinsNamespaceOf": "", "IPAddressAllow": "",
"ProtectKernelTunables": "yes", "ProtectKernelModules": "yes", "ProtectKernelLogs": "yes", "ProtectClock": "yes", "ProtectHostname": "yes",
"RemoveIPC": "yes", "LockPersonality": "yes", "RestrictRealtime": "yes", "Slice": "system.slice",
- "StandardInput": "null", "StandardOutput": "null", "StandardError": "null", "PassEnvironment": "", "EnvironmentFiles": "",
+ "StandardInput": "null", "StandardOutput": "null", "StandardError": "null", "PassEnvironment": "",
}
- keys := []string{"BindPaths", "BindReadOnlyPaths", "TemporaryFileSystem", "Environment", "ExecStart", "IPAddressDeny", "RootDirectory", "RootImage", "ReadWritePaths"}
+ keys := []string{"BindPaths", "BindReadOnlyPaths", "TemporaryFileSystem", "Environment", "EnvironmentFiles", "ExecStart", "IPAddressDeny", "RootDirectory", "RootImage", "ReadWritePaths"}
for k := range want {
keys = append(keys, k)
}
@@ -152,7 +152,7 @@ func (p *demoSnapshotSupervisor) checkUnit(ctx context.Context, id string) error
if !binds(actual["BindPaths"], filepath.Join(p.root, id, "work")+":/work") || !binds(actual["BindReadOnlyPaths"], "/opt/carlos/carlos:/snapshot-worker") {
return democlaim.ErrSnapshot
}
- if actual["RootDirectory"] != "" || actual["RootImage"] != "" || actual["ReadWritePaths"] != "" {
+ if actual["RootDirectory"] != "" || actual["RootImage"] != "" || actual["ReadWritePaths"] != "" || actual["EnvironmentFiles"] != "" {
return democlaim.ErrSnapshot
}
if strings.Join(strings.Fields(actual["Environment"]), " ") != "HOME=/work TMPDIR=/work GOMEMLIMIT=192MiB" {
diff --git a/internal/instancectl/demo_snapshot_unit_test.go b/internal/instancectl/demo_snapshot_unit_test.go
index 96b7f98f6..b1d85c020 100644
--- a/internal/instancectl/demo_snapshot_unit_test.go
+++ b/internal/instancectl/demo_snapshot_unit_test.go
@@ -2,11 +2,62 @@ package instancectl
import (
"context"
+ "errors"
+ "os"
"path/filepath"
+ "slices"
"strings"
"testing"
+
+ "github.com/carlosframework/platform/internal/democlaim"
)
+func TestDemoSnapshotCheckUnitSystemd257(t *testing.T) {
+ fixture, err := os.ReadFile("testdata/systemd257-snapshot-unit.txt")
+ if err != nil {
+ t.Fatal(err)
+ }
+ properties := string(fixture)
+ id := strings.Repeat("A", 43)
+ for _, tc := range []struct {
+ name string
+ raw string
+ wantErr bool
+ }{
+ {name: "omittedEnvironmentFiles", raw: properties},
+ {name: "emptyEnvironmentFiles", raw: properties + "EnvironmentFiles=\n"},
+ {name: "environmentFiles", raw: properties + "EnvironmentFiles=/work/env (ignore_errors=no)\n", wantErr: true},
+ {name: "memoryMax", raw: strings.Replace(properties, "MemoryMax=268435456\n", "MemoryMax=infinity\n", 1), wantErr: true},
+ {name: "execStartPath", raw: strings.Replace(properties, "path=/snapshot-worker ;", "path=/work/worker ;", 1), wantErr: true},
+ {name: "bindPaths", raw: strings.Replace(properties, "BindPaths="+filepath.Join(demoSnapshotRoot, id, "work"), "BindPaths=/work/other", 1), wantErr: true},
+ {name: "missingNonEmptyProperty", raw: strings.Replace(properties, "PrivatePIDs=yes\n", "", 1), wantErr: true},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ if tc.wantErr && tc.raw == properties {
+ t.Fatal("fault did not change the fixture")
+ }
+ s := &Server{Systemctl: func(_ context.Context, args ...string) (string, error) {
+ if len(args) != 4 || args[0] != "show" || args[1] != snapshotUnit(id) || args[2] != "-p" {
+ t.Fatalf("unexpected systemctl arguments: %q", args)
+ }
+ if !slices.Contains(strings.Split(args[3], ","), "EnvironmentFiles") {
+ t.Fatal("EnvironmentFiles must still be requested")
+ }
+ return tc.raw, nil
+ }}
+ p := &demoSnapshotSupervisor{s: s, root: demoSnapshotRoot}
+ err := p.checkUnit(t.Context(), id)
+ if tc.wantErr {
+ if !errors.Is(err, democlaim.ErrSnapshot) {
+ t.Fatalf("checkUnit = %v, want ErrSnapshot", err)
+ }
+ } else if err != nil {
+ t.Fatalf("checkUnit = %v, want nil", err)
+ }
+ })
+ }
+}
+
func TestDemoClaimSnapshotEffectiveUnit(t *testing.T) {
const properties = `Type=exec
RemainAfterExit=yes
diff --git a/internal/instancectl/testdata/systemd257-snapshot-unit.txt b/internal/instancectl/testdata/systemd257-snapshot-unit.txt
new file mode 100644
index 000000000..153c1cbb1
--- /dev/null
+++ b/internal/instancectl/testdata/systemd257-snapshot-unit.txt
@@ -0,0 +1,57 @@
+Type=exec
+Restart=no
+TimeoutStopUSec=5s
+RuntimeMaxUSec=2min
+RemainAfterExit=yes
+OOMPolicy=kill
+ExecStart={ path=/snapshot-worker ; argv[]=/snapshot-worker __demo-snapshot ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
+Slice=system.slice
+CPUQuotaPerSecUSec=500ms
+MemoryMax=268435456
+MemorySwapMax=0
+TasksMax=32
+IPAddressAllow=
+IPAddressDeny=::/0 0.0.0.0/0
+Environment=HOME=/work TMPDIR=/work GOMEMLIMIT=192MiB
+PassEnvironment=
+LimitFSIZE=268435456
+LimitFSIZESoft=268435456
+WorkingDirectory=/work
+RootDirectory=
+RootImage=
+StandardInput=null
+StandardOutput=null
+StandardError=null
+CapabilityBoundingSet=
+AmbientCapabilities=
+DynamicUser=yes
+RemoveIPC=yes
+ReadWritePaths=
+PrivateDevices=yes
+ProtectClock=yes
+ProtectKernelTunables=yes
+ProtectKernelModules=yes
+ProtectKernelLogs=yes
+ProtectControlGroups=yes
+PrivateNetwork=yes
+PrivateIPC=yes
+PrivatePIDs=yes
+ProtectHome=yes
+ProtectSystem=strict
+NoNewPrivileges=yes
+LockPersonality=yes
+RestrictAddressFamilies=AF_UNIX
+MemoryDenyWriteExecute=yes
+RestrictRealtime=yes
+RestrictNamespaces=yes
+BindPaths=/var/lib/carlos-demo-snapshots/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/work:/work:rbind
+BindReadOnlyPaths=/opt/carlos/carlos:/snapshot-worker:rbind
+TemporaryFileSystem=/data:ro /run:ro /var:ro /opt:ro /etc:ro /tmp:ro /dev/shm:ro /dev/mqueue:ro /dev/pts:ro
+ProtectProc=invisible
+ProcSubset=pid
+ProtectHostname=yes
+NetworkNamespacePath=
+KillMode=control-group
+SendSIGKILL=yes
+JoinsNamespaceOf=
+LoadState=loaded
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 9b1f76693..808106031 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -108,3 +108,4 @@ plan14-root-reads-agent-start-demo-3.tsv ebeaa693941f5592cd7bc3458effc2a333a8d12
plan14-root-reads-lease-renew-after-pause.tsv ebeaa693941f5592cd7bc3458effc2a333a8d12ba4f192a93d0aa32589048939
plan14-root-reads-demo-api-claim-paths.tsv ebeaa693941f5592cd7bc3458effc2a333a8d12ba4f192a93d0aa32589048939
plan14-root-reads-demo-moved-capability.tsv ebeaa693941f5592cd7bc3458effc2a333a8d12ba4f192a93d0aa32589048939
+plan14-root-reads-demo-snapshot-unit-check.tsv 62613178975daa6640bb46d87f143bf5291e51921e350b6c731438a77daf61f7
diff --git a/internal/provision/testdata/plan14-root-reads-demo-snapshot-unit-check.tsv b/internal/provision/testdata/plan14-root-reads-demo-snapshot-unit-check.tsv
new file mode 100644
index 000000000..2d2acb175
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-demo-snapshot-unit-check.tsv
@@ -0,0 +1,5 @@
+# Census overlay demo-snapshot-unit-check, written by census-propose (#369). census-ruling-demo-snapshot-unit-check, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-demo-snapshot-unit-check.md.
+# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy a9f4a77dc7d8520df2ca3bdad419a9036584fb6d321eb698be683b1a583d882d internal/instancectl/demo_snapshot_disk.go demoSnapshotSupervisor.checkUnit legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-3;basis=Inspect the effective fixed systemd snapshot unit and require its declared isolation, resource and execution settings. Census read-site delta: +data-literal.;rev3=census-ruling-demo-snapshot-unit-check;basis=Accept an omitted EnvironmentFiles property as empty, as emitted by systemd 257; continue requesting it and reject every non-empty value. All other property checks remain unchanged. No read added; the existing systemctl query requests the same properties. data-literal@2502 45a6caa9bbf6c9c099a6510bc3b24f86fd991c327a088c921a8d93ad845e965e
+internal/instancectl/demo_snapshot_disk.go demoSnapshotSupervisor.checkUnit legacy accepted-legacy accepted-legacy;rev3=census-ruling-agent-start-demo-3;basis=Inspect the effective fixed systemd snapshot unit and require its declared isolation, resource and execution settings. Census read-site delta: +data-literal.;rev3=census-ruling-demo-snapshot-unit-check;basis=Accept an omitted EnvironmentFiles property as empty, as emitted by systemd 257; continue requesting it and reject every non-empty value. All other property checks remain unchanged. No read added; the existing systemctl query requests the same properties. data-literal@2502 45a6caa9bbf6c9c099a6510bc3b24f86fd991c327a088c921a8d93ad845e965e
+@coverage internal/instancectl 0a26ffced872e6261a077002c7fb869ed636a468e7335b57f363adc5115abf38