carlos / platform Public

ship --check: mount the check volumes with nocopy (R2 P1)

Astra round 2 (P1): Docker, and Podman's default copy, fill an EMPTY
named volume from the image's directory at the mount point when a
container starts, restoring that directory's owner and mode. Prepare
leaves the data volume empty (it changes only the root), so an image
holding an empty /data/instances/check (0:0 0755) could hand the volume
back to root when release or web started, and uid 65534 could not create
CARLOS_DB. Every mount of the data volume (the prepare helper and every
process) and of the run volume now says nocopy (rootfsCheck.volumeMount),
which Docker's and Podman's -v both accept for a named volume (podman-run
5.4: [no]copy). The run volume gets it too: it is a tmpfs volume, empty at
every start, so the same copy-up would re-own it whenever the image has
/run/carlos/instances/check.

Test first: TestRootfsCheckVolumesNeverCopyUp checks every run's volume
mounts (prepare: data; release, web, jobs: data and run), and the exact
argv tests carry :nocopy. Mutations caught: drop nocopy from prepare's
data mount, from the processes' data mount, from the run mount.

Box witness (r10r, rootful Podman, this tip's linux/arm64 build): the
check passes on shop.tar and on a variant built FROM shop:1 with
RUN mkdir -p /data/instances/check (0:0 755, empty): release finished,
web answered GET / with 200, worker still running after 5 s, passed; no
carlos-check volumes, containers or images left; the variant image, tar
and binary removed.

Census re-proposed (card changed: rootfsCheck.runArgs body, its
disposition kept); seal 94b8ccf9... -> 042684bf.... Includes Astra's R2
findings file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev d203093bd4ff55fe8b1ab58b3693e09e09dfa9c8 parent d57b4bf
6 files changed, +99 −12
  • docs/superpowers/notes/census-proposal-rootfs-check-volumes.md +9 −1
  • docs/superpowers/reviews/CODEX-FINDINGS-rootfs-check-volumes-R2.md +26 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-rootfs-check-volumes.tsv +4 −2
  • ship_check.go +15 −3
  • ship_check_test.go +44 −5
diff --git a/docs/superpowers/notes/census-proposal-rootfs-check-volumes.md b/docs/superpowers/notes/census-proposal-rootfs-check-volumes.md
index 8b91c78d8..c23666568 100644
--- a/docs/superpowers/notes/census-proposal-rootfs-check-volumes.md
+++ b/docs/superpowers/notes/census-proposal-rootfs-check-volumes.md
@@ -2,14 +2,22 @@
Ruling `census-ruling-rootfs-check-volumes`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `ship_check.go` `rootfsCheck.runArgs` | body | unchanged (2) | R2 P1: the data and run volume mounts (-v) now carry :nocopy through rootfsCheck.volumeMount, so Docker and Podman never fill an empty check volume from the image directory at the mount point (which would reset the prepared owner and mode); same volumes, same paths, same probe mount, nothing else in the argv changed. Runs on the person's machine as the person; no box unit; no read added. |
+
Envelopes re-pinned: `.`.
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:
+
+- `ship_check.go` `rootfsCheck.runArgs`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-rootfs-apps-1;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (rootfs Plan 1), builds the docker or podman run argv for one check container; the scanner matches the word Command, here a field of release.Process (a process's argv), not os/exec; reads no file; decides nothing for root
+
New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
- new `ship_check_probe.go:prepareCheckDir`: reads +file:Lstat; written legacy, accepted-legacy, frozen
-Seal: `94b8ccf921f64be24a4773f72d55a8e24ceba3acfb40eefe3b56af6f5b008138` → `4fb2a2add6757c23f458237fe34e6b0e6c2c788518b4dc492dc981961f393118`.
+Seal: `94b8ccf921f64be24a4773f72d55a8e24ceba3acfb40eefe3b56af6f5b008138` → `042684bf5af6f61ce8b87f10b68a42b08d131ba4cb5bcab16320c7b032a724e6`.
Overlay: `internal/provision/testdata/plan14-root-reads-rootfs-check-volumes.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-check-volumes-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-check-volumes-R2.md
new file mode 100644
index 000000000..cad84514b
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-check-volumes-R2.md
@@ -0,0 +1,26 @@
+- **R1 P1 — resolved.** The helper uses `<prefix>_prepare`, outside the worker-name grammar ([ship_check.go:215](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-check-volumes/ship_check.go:215)). The fake rejects duplicate names, and the regression covers worker `prepare`.
+- **R1 P2 — resolved.** [ship_check_prepare_test.go:86](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-check-volumes/ship_check_prepare_test.go:86) asserts chmod 0700 before lchown 65534:65534, through both function and verb. Removing or reversing those calls breaks the assertion.
+
+Reviewed `d57b4bf04c4908f519fc17f6255e0e0dc2a3acc9`, round 2/3.
+
+**P1 — Docker volume population can undo preparation before the first app process starts.** Both the helper ([ship_check.go:220](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-check-volumes/ship_check.go:220)) and app processes ([ship_check.go:286](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/rootfs-check-volumes/ship_check.go:286)) mount the data volume without disabling image-content copying.
+
+Failure scenario: a valid image contains an empty `/data/instances/check` directory, mode 0755. Import normalizes its owner to 0:0. Preparation leaves the volume empty but changes its owner to 65534:65534. When Docker creates release—or web without release—it populates the still-empty volume again, restoring the image directory’s ownership and mode. UID 65534 then cannot create `CARLOS_DB`, so a healthy app fails its check.
+
+Verified by source inspection, not a runtime reproduction: Docker skips population only when the destination contains entries; its copy implementation restores directory metadata.
+
+[https://raw.githubusercontent.com/moby/moby/v27.5.1/container/container_unix.go](https://raw.githubusercontent.com/moby/moby/v27.5.1/container/container_unix.go), [https://raw.githubusercontent.com/containerd/continuity/main/fs/copy.go](https://raw.githubusercontent.com/containerd/continuity/main/fs/copy.go), [https://raw.githubusercontent.com/containerd/continuity/main/fs/copy_linux.go](https://raw.githubusercontent.com/containerd/continuity/main/fs/copy_linux.go)
+
+**Fix:** disable image-content copying on every data-volume mount, using syntax supported by each runtime. Add a regression with that empty directory present in the image, asserting UID 65534 can write after the next container starts. **Invariant/fault family:** prepared data-volume ownership must remain writable by the check user across container launches.
+
+No new P2 or P3 findings.
+
+Census verdicts:
+
+- **APPROVE — `ship_check_probe.go:prepareCheckDir`.** Read lines 108–147. `file:Lstat` and `legacy / accepted-legacy` match the container-only caller. Final symlinks and non-directories are refused; chmod precedes lchown; neither recurses.
+- **APPROVE — envelope `.`.** Read `main.go:21–51`, `ship_check.go:132–243,303–369`, and `ship_check_probe.go:108–147`; traced import, probe selection and cleanup. No box-root caller gains an input path or weaker validation. The finding above concerns local-check functionality.
+- **APPROVE — record-write re-pin `main.go:main`.** Read the dispatch and `internal/provision/rootfs_check_volumes_census_test.go:16–37`. The added dispatch writes no record; the `instances` and `sidecars` literals remain unchanged.
+
+Targeted check and census tests stopped before compilation because `$TMPDIR` is read-only. GOCACHE remained unset. No full suites ran; no files changed.
+
+NOT READY
\ No newline at end of file
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 9fa3c3c69..33b508de6 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -34,4 +34,4 @@ plan14-root-reads-static-dir-slash.tsv fb7cd756f7c3eb2dc019c8fd55fea5475e2df7ee3
plan14-root-reads-named-unit-delivery-114.tsv d92c9d40eb2a9e66c859e2fe6df3af10a1b9d3a83b1d717ec928cb432eebb1aa
plan14-root-reads-fleet-secrets-key.tsv 9df7f5aca9a502966c9643b7062829c1c25bfbd86fa20e92d764d66f676d2cd6
plan14-root-reads-static-headers.tsv 94b8ccf921f64be24a4773f72d55a8e24ceba3acfb40eefe3b56af6f5b008138
-plan14-root-reads-rootfs-check-volumes.tsv 4fb2a2add6757c23f458237fe34e6b0e6c2c788518b4dc492dc981961f393118
+plan14-root-reads-rootfs-check-volumes.tsv 042684bf5af6f61ce8b87f10b68a42b08d131ba4cb5bcab16320c7b032a724e6
diff --git a/internal/provision/testdata/plan14-root-reads-rootfs-check-volumes.tsv b/internal/provision/testdata/plan14-root-reads-rootfs-check-volumes.tsv
index ef2ad0430..714a190c3 100644
--- a/internal/provision/testdata/plan14-root-reads-rootfs-check-volumes.tsv
+++ b/internal/provision/testdata/plan14-root-reads-rootfs-check-volumes.tsv
@@ -1,6 +1,8 @@
# Census overlay rootfs-check-volumes, written by census-propose (#369). census-ruling-rootfs-check-volumes, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-rootfs-check-volumes.md.
-# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 055963a9e0d8e690476664799c9ab21df3fcd3ab42960247a6abe38fbf2baa17 ship_check.go rootfsCheck.runArgs legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-1;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (rootfs Plan 1), builds the docker or podman run argv for one check container; the scanner matches the word Command, here a field of release.Process (a process's argv), not os/exec; reads no file; decides nothing for root;rev3=census-ruling-rootfs-check-volumes;basis=R2 P1: the data and run volume mounts (-v) now carry :nocopy through rootfsCheck.volumeMount, so Docker and Podman never fill an empty check volume from the image directory at the mount point (which would reset the prepared owner and mode); same volumes, same paths, same probe mount, nothing else in the argv changed. Runs on the person's machine as the person; no box unit; no read added. file:Command@764,file:Command@848 a7bd986343e647262402a363cfb374c34bdd3ecf35cbb452d9e8816d88d4a02c
@legacy b88e56ecd81527322832b883453084fda8bde581689e0e13fbe3a79170889c2e ship_check_probe.go prepareCheckDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-check-volumes;basis=new: __rootfs-check-prepare (carlos ship --check), run only inside the check's prepare container on the person's machine (as 0:0 with CAP_CHOWN alone, no network, read-only root), never by a box: Lstats the one directory it is given (the check's data volume at /data/instances/check), refuses a symlink or non-directory, then chmod 0700 and lchown to --uid:--uid; no recursion. Read added: file:Lstat of that path. R1 P2: the chmod and lchown go through package vars checkChmod/checkLchown (os.Chmod, os.Lchown; only tests change them) so a test pins the order; same calls, same arguments. main.go dispatches the verb before the command switch beside __rootfs-check-probe; no root unit calls it. file:Lstat@67 8633a0299cf2abee0b320ba4701137f31ada646c0d6c8310b6052054d5dad87f
+ship_check.go rootfsCheck.runArgs legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-1;basis=root-input (J4, as main's db.go units); the carlos CLI on a person's machine, as the person (no box unit): new (rootfs Plan 1), builds the docker or podman run argv for one check container; the scanner matches the word Command, here a field of release.Process (a process's argv), not os/exec; reads no file; decides nothing for root;rev3=census-ruling-rootfs-check-volumes;basis=R2 P1: the data and run volume mounts (-v) now carry :nocopy through rootfsCheck.volumeMount, so Docker and Podman never fill an empty check volume from the image directory at the mount point (which would reset the prepared owner and mode); same volumes, same paths, same probe mount, nothing else in the argv changed. Runs on the person's machine as the person; no box unit; no read added. file:Command@764,file:Command@848 a7bd986343e647262402a363cfb374c34bdd3ecf35cbb452d9e8816d88d4a02c
ship_check_probe.go prepareCheckDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-check-volumes;basis=new: __rootfs-check-prepare (carlos ship --check), run only inside the check's prepare container on the person's machine (as 0:0 with CAP_CHOWN alone, no network, read-only root), never by a box: Lstats the one directory it is given (the check's data volume at /data/instances/check), refuses a symlink or non-directory, then chmod 0700 and lchown to --uid:--uid; no recursion. Read added: file:Lstat of that path. R1 P2: the chmod and lchown go through package vars checkChmod/checkLchown (os.Chmod, os.Lchown; only tests change them) so a test pins the order; same calls, same arguments. main.go dispatches the verb before the command switch beside __rootfs-check-probe; no root unit calls it. file:Lstat@67 8633a0299cf2abee0b320ba4701137f31ada646c0d6c8310b6052054d5dad87f
-@coverage . 9d08bade6d01166a87e1538b79466d952a010d5cb5f9208b418adc3a07d3c978
+@coverage . b86ad1c792b5fb3a92985bad439972463cdec87b3f066fe5e37f0beb32954d7d
diff --git a/ship_check.go b/ship_check.go
index f3d6ce055..2e3abe4fb 100644
--- a/ship_check.go
+++ b/ship_check.go
@@ -217,7 +217,7 @@ func (c *rootfsCheck) prepareData(ctx context.Context) bool {
"--read-only", "--network", "none",
"--cap-drop", "ALL", "--cap-add", "CHOWN", "--security-opt", "no-new-privileges",
"--platform", "linux/arm64", "--user", "0:0",
- "-v", c.volumes[0] + ":" + checkDataDir,
+ "-v", c.volumeMount(0, checkDataDir),
"-v", c.probe + ":" + checkProbeMount + ":ro",
"--entrypoint", checkProbeMount,
"--label", "carlos-check=" + c.id,
@@ -243,6 +243,18 @@ func (c *rootfsCheck) prepareData(ctx context.Context) bool {
return false
}
+// volumeMount is the -v value that mounts the check's volume i at path,
+// with nocopy, which Docker and Podman both take for a named volume.
+// Without it both fill an empty volume from the image's directory at path
+// each time a container starts, the directory's owner and mode included:
+// an image holding an empty /data/instances/check would hand the prepared
+// data volume back to root when release or web started, and the run
+// volume, a tmpfs volume emptied whenever no container holds it, would be
+// re-owned the same way at every start. Every mount of either says nocopy.
+func (c *rootfsCheck) volumeMount(i int, path string) string {
+ return c.volumes[i] + ":" + path + ":nocopy"
+}
+
// processVars is process name's environment in the check: its own env,
// then --env's values, then the instance's CARLOS_* values (validation keeps CARLOS_ names out of
// a process's env). There is no CARLOS_CONTROL_SOCKET or CARLOS_PURGE:
@@ -283,8 +295,8 @@ func (c *rootfsCheck) runArgs(ctr, name string) []string {
"--memory", mem, "--memory-swap", mem,
"--cap-drop", "ALL", "--security-opt", "no-new-privileges",
"--platform", "linux/arm64", "--user", user,
- "-v", c.volumes[0] + ":" + checkDataDir,
- "-v", c.volumes[1] + ":" + checkRunDir,
+ "-v", c.volumeMount(0, checkDataDir),
+ "-v", c.volumeMount(1, checkRunDir),
"-v", c.probe + ":" + checkProbeMount + ":ro",
}
vars := c.processVars(name)
diff --git a/ship_check_test.go b/ship_check_test.go
index d9af4dbcf..cd59958b2 100644
--- a/ship_check_test.go
+++ b/ship_check_test.go
@@ -416,8 +416,8 @@ func TestRootfsCheckRunArgs(t *testing.T) {
}
}
wantMounts := []string{
- prefix + "-data:/data/instances/check",
- prefix + "-run:/run/carlos/instances/check",
+ prefix + "-data:/data/instances/check:nocopy",
+ prefix + "-run:/run/carlos/instances/check:nocopy",
"/probe/carlos:/opt/carlos/carlos:ro",
}
if !slices.Equal(mounts, wantMounts) {
@@ -633,7 +633,7 @@ func TestRootfsCheckPreparesTheDataVolume(t *testing.T) {
"--read-only", "--network", "none",
"--cap-drop", "ALL", "--cap-add", "CHOWN", "--security-opt", "no-new-privileges",
"--platform", "linux/arm64", "--user", "0:0",
- "-v", prefix + "-data:/data/instances/check",
+ "-v", prefix + "-data:/data/instances/check:nocopy",
"-v", "/probe/carlos:/opt/carlos/carlos:ro",
"--entrypoint", "/opt/carlos/carlos",
"--label", "carlos-check=" + id,
@@ -686,6 +686,45 @@ func TestRootfsCheckWorkerNamedLikeTheHelper(t *testing.T) {
f.checkLeftNothing(t)
}
+// Docker and Podman fill an empty named volume from the image's directory
+// at the mount point each time a container starts, owner and mode
+// included. The data volume stays empty after prepare, so an image with an
+// empty /data/instances/check would hand it back to root at release's or
+// web's start; the run volume, tmpfs, is empty at every start. So every
+// mount of either volume, in every container the check runs, says nocopy.
+func TestRootfsCheckVolumesNeverCopyUp(t *testing.T) {
+ noSettle(t)
+ f := newFakeCheck(t)
+ if r := runRootfsCheck(context.Background(), f.rt(), shopBuild(t, shopProcs()), "/probe/carlos", f.out); r.failed {
+ t.Fatalf("report = %q", r.lines)
+ }
+ runs := 0
+ for _, c := range f.calls {
+ if c[0] != "run" {
+ continue
+ }
+ runs++
+ name := flagValue(c, "--name")
+ prefix := name[:len("carlos-check-")+8]
+ var vols []string
+ for i, a := range c {
+ if a == "-v" && strings.HasPrefix(c[i+1], prefix+"-") {
+ vols = append(vols, c[i+1])
+ }
+ }
+ want := []string{prefix + "-data:/data/instances/check:nocopy", prefix + "-run:/run/carlos/instances/check:nocopy"}
+ if procOf(name) == "_prepare" {
+ want = want[:1]
+ }
+ if !slices.Equal(vols, want) {
+ t.Errorf("%s mounts %q, want %q", procOf(name), vols, want)
+ }
+ }
+ if runs != 4 {
+ t.Errorf("%d runs, want prepare, release, web and jobs", runs)
+ }
+}
+
// A prepare that does not exit 0 fails the check before any process runs,
// and the check still removes everything it made.
func TestRootfsCheckPrepareFailureStopsTheCheck(t *testing.T) {
@@ -1112,8 +1151,8 @@ func TestShipCheckWithoutEnvUnchanged(t *testing.T) {
"--memory", "1073741824", "--memory-swap", "1073741824",
"--cap-drop", "ALL", "--security-opt", "no-new-privileges",
"--platform", "linux/arm64", "--user", "65534:65534",
- "-v", prefix + "-data:/data/instances/check",
- "-v", prefix + "-run:/run/carlos/instances/check",
+ "-v", prefix + "-data:/data/instances/check:nocopy",
+ "-v", prefix + "-run:/run/carlos/instances/check:nocopy",
"-v", "/probe/carlos:/opt/carlos/carlos:ro",
"-e", "A_FIRST=1",
"-e", "CARLOS_DB=/data/instances/check/shop.example.com.db",