carlos / platform Public

census: propose named-units-guard-fix (guard read split, two new openers)

consoleGuardHost now tells an untrusted directory chain (unguarded) from
an untrusted marker (refused); RunSystemNamedUnitsInstall prints the
reason; rootstate gains OpenTrustedDir and OpenTrustedFileIn, the two
halves of OpenTrustedFile. Awaits the cross-family reviewer on #280.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev b247fe7de147503c0e60e2780316a0f312f17018 parent e645509
3 files changed, +40 −0
  • docs/superpowers/notes/census-proposal-named-units-guard-fix.md +26 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-named-units-guard-fix.tsv +13 −0
diff --git a/docs/superpowers/notes/census-proposal-named-units-guard-fix.md b/docs/superpowers/notes/census-proposal-named-units-guard-fix.md
new file mode 100644
index 000000000..d48048ae7
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-named-units-guard-fix.md
@@ -0,0 +1,26 @@
+# Census approval: named-units-guard-fix
+
+Ruling `census-ruling-named-units-guard-fix`. The independent reviewer approves or rejects every change below, 2 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/host/unitops.go` `RunSystemNamedUnitsInstall` | body | unchanged (1) | InstallNamedUnits now also returns the unguarded reason; the verb prints it beside the installed path. No new read |
+| `internal/host/unitops.go` `consoleGuardHost` | body | unchanged (1) | the guard read now distinguishes an untrusted chain, which is treated as unguarded (Paul's ruling 2026-11-19): it walks <opt>/system/guard first with rootstate.OpenTrustedDir (same root-trusted walk as before); os.ErrPermission from that walk is ok=false, no error, with an unguarded reason; absent is ok=false as before; then it opens console-ready.json in the walked directory with rootstate.OpenTrustedFileIn (same file checks as OpenTrustedFile: no symlink, root-owned, one link, not group/other-writable) and an untrusted, oversized or hostless marker still refuses. No new read: the same marker through the same checks, split in two |
+
+Envelopes re-pinned: `internal/host`, `internal/rootstate`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/host/unitops.go` `RunSystemNamedUnitsInstall`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-named-units-param-114;basis=new (Task 7, renamed from RunSystemNamedUnits): carlos system named-units install <file>: refuses unless euid 0, reads the operator-given <file> by root's own choice at the command line and hands it to InstallNamedUnits, which now also runs both decoders and the console guard rule under the lock
+- `internal/host/unitops.go` `consoleGuardHost`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-named-units-param-114;basis=new (Task 2/4): root's trusted read (rootstate.OpenTrustedFile, MaxRecord cap) of <opt>/system/guard/console-ready.json, the marker root's guard-arm writes; absent is unguarded, any other failure or a marker naming no valid live host is an error that refuses the install; the host is taken only when the bytes equal release.LiveLink(opt, host)
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `internal/rootstate/file_linux.go:OpenTrustedDir`: reads +file:Open; written legacy, accepted-legacy, frozen
+- new `internal/rootstate/file_linux.go:OpenTrustedFileIn`: reads +file:Fstat; written legacy, accepted-legacy, frozen
+
+Seal: `879cc401365966a2ca23962245ce9dff4b7879fe7a27b7691c3d91a4e70ff6e8` → `39c41bd9c393bebfd68a1c48abf6f25c0d701615445f9085952790ba9178a04b`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-named-units-guard-fix.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 8c754d8f7..8caa517e0 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -256,3 +256,4 @@ plan14-root-reads-flake-lease-teardown.tsv 5d4a5eea79394145fdd59aa5eb87115cc1ee3
plan14-root-reads-ha-generations.tsv 5bf2d00767807be812b004a474352ec184788be3ce65607a45c37b04956714a2
plan14-root-reads-named-units-param-114.tsv 8daea28ba9b419e8680e8eb0d44a577c68ec01e02663a878288441dc579cc9f7
plan14-root-reads-race-activator-1249.tsv 879cc401365966a2ca23962245ce9dff4b7879fe7a27b7691c3d91a4e70ff6e8
+plan14-root-reads-named-units-guard-fix.tsv 39c41bd9c393bebfd68a1c48abf6f25c0d701615445f9085952790ba9178a04b
diff --git a/internal/provision/testdata/plan14-root-reads-named-units-guard-fix.tsv b/internal/provision/testdata/plan14-root-reads-named-units-guard-fix.tsv
new file mode 100644
index 000000000..8bf02b069
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-named-units-guard-fix.tsv
@@ -0,0 +1,13 @@
+# Census overlay named-units-guard-fix, written by census-propose (#369). census-ruling-named-units-guard-fix, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-named-units-guard-fix.md.
+# 2 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 2 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 460768a56c895733c6e75efa36f0f9c80d8edd8cd7eea6a79cd99560312e44f0 internal/host/unitops.go RunSystemNamedUnitsInstall legacy accepted-legacy accepted-legacy;rev3=census-ruling-named-units-param-114;basis=new (Task 7, renamed from RunSystemNamedUnits): carlos system named-units install <file>: refuses unless euid 0, reads the operator-given <file> by root's own choice at the command line and hands it to InstallNamedUnits, which now also runs both decoders and the console guard rule under the lock;rev3=census-ruling-named-units-guard-fix;basis=InstallNamedUnits now also returns the unguarded reason; the verb prints it beside the installed path. No new read file:ReadFile@278 03ab2984b8866a2a590a9867cf8b04fd1af853e1286b654c5f992ac46afa1c10
+@legacy 52bd09a6e1493f6816db6ca3ff4875fa7912f0f853df4253b0ae95daf70d19c6 internal/host/unitops.go consoleGuardHost legacy accepted-legacy accepted-legacy;rev3=census-ruling-named-units-param-114;basis=new (Task 2/4): root's trusted read (rootstate.OpenTrustedFile, MaxRecord cap) of <opt>/system/guard/console-ready.json, the marker root's guard-arm writes; absent is unguarded, any other failure or a marker naming no valid live host is an error that refuses the install; the host is taken only when the bytes equal release.LiveLink(opt, host);rev3=census-ruling-named-units-guard-fix;basis=the guard read now distinguishes an untrusted chain, which is treated as unguarded (Paul's ruling 2026-11-19): it walks <opt>/system/guard first with rootstate.OpenTrustedDir (same root-trusted walk as before); os.ErrPermission from that walk is ok=false, no error, with an unguarded reason; absent is ok=false as before; then it opens console-ready.json in the walked directory with rootstate.OpenTrustedFileIn (same file checks as OpenTrustedFile: no symlink, root-owned, one link, not group/other-writable) and an untrusted, oversized or hostless marker still refuses. No new read: the same marker through the same checks, split in two file:ReadAll@623 e7372aa14ec47f8b6deb88f20c8a8d15cccab06c7d6b0db7589ac85b6dfc23e6
+@legacy fd0ef2ab251290b608f54ff6b03a2f6df56d638b43b7da33aeb13185815bd006 internal/rootstate/file_linux.go OpenTrustedDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-named-units-guard-fix;basis=new: OpenTrustedFile's directory walk on its own (Open(path, false, true), every directory from / root-owned, not group/other-writable, r-x for both), returning the directory's descriptor; reads nothing new file:Open@64 de0f8222d4721aa93a5588b7cdb9953700c970a9c467d74ad6bc0fb72b378d33
+@legacy e3755aca1755d5cd80b474d720c4c7ea73f0bc12890220d75219f65ed516f58a internal/rootstate/file_linux.go OpenTrustedFileIn legacy accepted-legacy accepted-legacy;rev3=census-ruling-named-units-guard-fix;basis=new: OpenTrustedFile's file half: opens one name in a descriptor OpenTrustedDir or OpenTrustedDirFrom returned, through safefile.OpenFileAt (O_NOFOLLOW, regular, one link) and trusted() against the directory's owner (root for OpenTrustedDir); reads nothing new file:Fstat@101 988166d41e2f4702db8df21a2c56dad5b8d7fd0e34dc9ee0a76f5a501a22a842
+internal/host/unitops.go RunSystemNamedUnitsInstall legacy accepted-legacy accepted-legacy;rev3=census-ruling-named-units-param-114;basis=new (Task 7, renamed from RunSystemNamedUnits): carlos system named-units install <file>: refuses unless euid 0, reads the operator-given <file> by root's own choice at the command line and hands it to InstallNamedUnits, which now also runs both decoders and the console guard rule under the lock;rev3=census-ruling-named-units-guard-fix;basis=InstallNamedUnits now also returns the unguarded reason; the verb prints it beside the installed path. No new read file:ReadFile@278 03ab2984b8866a2a590a9867cf8b04fd1af853e1286b654c5f992ac46afa1c10
+internal/host/unitops.go consoleGuardHost legacy accepted-legacy accepted-legacy;rev3=census-ruling-named-units-param-114;basis=new (Task 2/4): root's trusted read (rootstate.OpenTrustedFile, MaxRecord cap) of <opt>/system/guard/console-ready.json, the marker root's guard-arm writes; absent is unguarded, any other failure or a marker naming no valid live host is an error that refuses the install; the host is taken only when the bytes equal release.LiveLink(opt, host);rev3=census-ruling-named-units-guard-fix;basis=the guard read now distinguishes an untrusted chain, which is treated as unguarded (Paul's ruling 2026-11-19): it walks <opt>/system/guard first with rootstate.OpenTrustedDir (same root-trusted walk as before); os.ErrPermission from that walk is ok=false, no error, with an unguarded reason; absent is ok=false as before; then it opens console-ready.json in the walked directory with rootstate.OpenTrustedFileIn (same file checks as OpenTrustedFile: no symlink, root-owned, one link, not group/other-writable) and an untrusted, oversized or hostless marker still refuses. No new read: the same marker through the same checks, split in two file:ReadAll@623 e7372aa14ec47f8b6deb88f20c8a8d15cccab06c7d6b0db7589ac85b6dfc23e6
+internal/rootstate/file_linux.go OpenTrustedDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-named-units-guard-fix;basis=new: OpenTrustedFile's directory walk on its own (Open(path, false, true), every directory from / root-owned, not group/other-writable, r-x for both), returning the directory's descriptor; reads nothing new file:Open@64 de0f8222d4721aa93a5588b7cdb9953700c970a9c467d74ad6bc0fb72b378d33
+internal/rootstate/file_linux.go OpenTrustedFileIn legacy accepted-legacy accepted-legacy;rev3=census-ruling-named-units-guard-fix;basis=new: OpenTrustedFile's file half: opens one name in a descriptor OpenTrustedDir or OpenTrustedDirFrom returned, through safefile.OpenFileAt (O_NOFOLLOW, regular, one link) and trusted() against the directory's owner (root for OpenTrustedDir); reads nothing new file:Fstat@101 988166d41e2f4702db8df21a2c56dad5b8d7fd0e34dc9ee0a76f5a501a22a842
+@coverage internal/host 00220429cf36f35b91261358f6748fe08aeae19defa5562f93ef749bb10ec53a
+@coverage internal/rootstate fa81cd055bfc3b6f0c19075b65ada2e0798cf14ca6ecb4ff8657159e915fd6d4