carlos / platform Public

review: Astra round 4 (NOT READY, 1 P1) and census round 3 (ESCALATED 6), unedited

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 7e2320a63222dc877fbc5a93379683fa94667162 parent 1690cc1
2 files changed, +131 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-census-named-unit-delivery-114-R3.md +94 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-named-unit-delivery-114-r4.md +37 −0

CI passed — run details

Intent

Human

<task-notification> <task-id>b8jjxczpo</task-id> <tool-use-id>toolu_01Wdi4DhNSoJYS3dKxsw1AVv</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/63b05f1b-b484-408d-8802-e9909f687e39/tasks/b8jjxczpo.output</output-file> <status>completed</status> <summary>Background command "Run Astra census round 3" completed (exit code 0)</summary> </task-notification>

diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-census-named-unit-delivery-114-R3.md b/docs/superpowers/reviews/CODEX-FINDINGS-census-named-unit-delivery-114-R3.md
new file mode 100644
index 000000000..71d67d02d
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-census-named-unit-delivery-114-R3.md
@@ -0,0 +1,94 @@
+- R2 `runAdoptUnderRootRelease`: **not resolved** — production still reaches the declaration-authority gaps below.
+- R2 `ensureDropInDir`: **resolved** — the directory chain is checked before file writes.
+- R2 `rootRead`: **resolved** — descriptor traversal now checks ancestors and the final file.
+- R2 `stampedForDelivery`: **resolved locally** — current declared hosts face an independent dispatch check; retained old bindings remain unprotected.
+- R2 `applyStamped`: **resolved** — drop-in reads use the trusted descriptor chain.
+- R2 `planStamped`: **resolved** — declaration and drop-in reads use the trusted descriptor chain.
+- R2 `prepareStamped`: **resolved** — base/drop-in reads and the destination directory receive the added protection.
+- R2 `SyncWithCallbacks`: **not resolved** — retained old bindings and ordinary writes after declaration changes remain unprotected.
+- R2 envelope `internal/appconfig`: **not resolved** — R3-E1/E2 below.
+- R2 envelope `internal/host`: **not resolved** — production enables those paths.
+
+Reviewed `f9ad96e47ae4a22a37f567e8b9fd4b81180eb21c` using the brief at `1690cc11a9c9ea95b6d6010dd12da5370e8615f9`. The requested three-dot diff has merge base `9bcbab0f5646c11c7d05c9346dcfcea8c84f0751`; local `origin/main` is `de23fa5ec21dddbae95a6be44867abd2652baa81`.
+
+**42 rows reviewed; six escalated rows covering two P1 findings.**
+
+| Unit or envelope | Verdict | Reason |
+|---|---|---|
+| `cli.go:runRouteUnit` | approve | Line 1802 validates the proposed stamp before the existing write. |
+| `internal/appconfig/sync.go:reap` | escalate | Lines 460–488 can delete an old host’s env file still referenced by a retained drop-in; R3-E1. |
+| `internal/host/agent.go:runAdoptUnderRootRelease` | escalate | Line 5275 enables the affected delivery and cleanup paths; R3-E1/E2. |
+| `cli.go:runRouteHibernate` | approve | Line 1635 adds a refusal before the existing daemon check. |
+| `internal/appconfig/sync.go:UnitConfigApps` | approve | Lines 565–586 extend discovery without granting mutation authority. |
+| `internal/appconfig/sync.go:syncHostClaimed` | approve | Lines 616–637 preserve the existing guarded writer; the missing declaration gate concerns its dispatch integration. |
+| `internal/appconfig/syncexec.go:AwaitingRestart` | approve | Lines 1163–1333 retain account, environment and owned-bundle narrowing. |
+| `internal/appconfig/syncexec.go:SyncExecWithCallbacks` | approve | Lines 713–749 keep the added `Stat` behind the route filter, for notices only. |
+| `cli.go:hibernateRail` | approve | Lines 1857–1862 only refuse hibernation on a named unit. |
+| `internal/appconfig/declarations.go:declarations.DeclaredBinding` | approve | Lines 172–181 compare unit, host, account and app against trusted declarations. |
+| `internal/appconfig/dropin.go:dirIsPlain` | approve | Lines 76–79 inspect the final directory entry without following it. |
+| `internal/appconfig/dropin.go:ensureDropInDir` | approve | Lines 51–72 establish trusted ancestry before file writes; planning already checks the drop-in path. |
+| `internal/appconfig/dropin.go:hasPending` | approve | Lines 131–134 inspect marker existence without reading its target. |
+| `internal/appconfig/dropin.go:unitDirs` | approve | Lines 139–159 enumerate the configured root and exclude symlinked child directories. |
+| `internal/appconfig/rootread.go:rootRead` | approve | Lines 54–70 perform bounded reads through trusted descriptors, anchored at `/` in production. |
+| `internal/appconfig/stamped.go:StampShape` | approve | Lines 57–61 wrap the shared refusal predicate. |
+| `internal/appconfig/stamped.go:Stamped` | approve | Lines 25–28 classify fields without privileged effects. |
+| `internal/appconfig/stamped.go:stampShapeReason` | approve | Lines 70–79 refuse socket, missing-address and hibernating shapes. |
+| `internal/appconfig/stamped.go:stampedForDelivery` | approve | Lines 48–49 classify delivery; current declared hosts now face an independent dispatch check. |
+| `internal/appconfig/stamped.go:unitDelivered` | approve | Lines 34–35 combine eligibility for discovery and fingerprints. |
+| `internal/appconfig/sync.go:finishHost` | approve | Lines 778–825 preserve the extracted restart, claim and acknowledgement behavior. |
+| `internal/appconfig/sync.go:prepareHost` | approve | Lines 656–755 preserve basename, existing-file, key-loss and rendering checks. |
+| `internal/appconfig/syncexec.go:BlockedStamps` | approve | Lines 1106–1141 narrow notices without exposing another account’s host. |
+| `internal/appconfig/unitsync.go:applyStamped` | approve | Lines 410–489 retain trusted reads, prepared-work checks, declared identity and a fresh declaration check before restart. |
+| `internal/appconfig/unitsync.go:planStamped` | approve | Lines 120–228 validate declared identity before probing, then check canonical identity and trusted drop-ins. |
+| `internal/appconfig/unitsync.go:prepareStamped` | approve | Lines 250–342 bind the row, check the base and destination, and recheck declarations before env/drop-in writes. |
+| `internal/appconfig/unitsync.go:stampedPlan.declaredHostRefusal` | escalate | Lines 98–100 admit a former host even when its env file remains referenced; R3-E1. |
+| `internal/host/unitops.go:daemonReload` | approve | Lines 115–120 execute fixed arguments. |
+| `internal/host/unitops.go:lockConfigSync` | approve | Lines 31 and 47–56 use the fixed production env-directory lock path. |
+| `internal/host/unitops.go:probeUnits` | approve | Lines 64–70 receive validated declared names separately; ambiguous batch attribution is refused. |
+| `internal/host/unitops.go:systemctlRestartUnit` | approve | Lines 126–131 execute one validated unit argument without shell interpolation. |
+| `internal/rootstate/file_linux.go:OpenTrustedDirFrom` | approve | Lines 40–65 constrain paths to the anchor and reuse checked descriptor descent. |
+| `internal/rootstate/file_linux.go:OpenTrustedFileFrom` | approve | Lines 72–93 require a trusted parent and a regular, single-link file with trusted ownership and permissions. |
+| `cli.go:runAdd` | approve | Lines 211–245 and 394–405 validate the resulting stamped shape before writing. |
+| `cli.go:unitRail` | approve | Lines 1838–1851 allow clearing and refuse unsupported proposed stamps. |
+| `internal/appconfig/routefingerprint.go:ConfigRouteFingerprints` | approve | Lines 79–85 add unit identity to change detection only. |
+| `internal/appconfig/sync.go:SyncWithCallbacks` | escalate | Lines 118–125, 374 and 399–408 incompletely enforce declaration authority; R3-E1/E2. |
+| `internal/appconfig/syncexec.go:execRouteBase` | approve | Lines 875–879 exclude stamped routes from exec delivery. |
+| Envelope `.` | approve | Changes add CLI refusals and additive notices; subprocess witnesses isolate environment and cwd. |
+| Envelope `internal/appconfig` | escalate | Dispatch and cleanup leave retained env references and ordinary writes outside complete declaration enforcement. |
+| Envelope `internal/host` | escalate | Production wiring at `agent.go:5275` reaches R3-E1/E2. |
+| Envelope `internal/rootstate` | approve | New openers reuse descriptor checks; the existing opener is unchanged and non-Linux implementations refuse. |
+
+**R3-E1 — P1: reassigning a unit’s host releases protection of its still-loaded env file.**
+
+**Fault family:** invariant A — declaration authority must cover every writer and remover of configuration a declared unit still consumes.
+
+Start with successful delivery of `relay.service` for `old.example.com`. Its managed drop-in names `/etc/carlos/apps/old.example.com.env`. An operator changes the declaration to bind that same unit to `new.example.com`. Leave the new route absent or refused.
+
+The box agent controls registry rows ([registryowner.go:42](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/host/registryowner.go:42)). It can now:
+
+1. Change the old row to `Backing=unit`, clear its stamp and substitute its account/app. [`declaredHostRefusal`:98](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/unitsync.go:98) admits it because the old host is absent from the current declaration map. Dispatch reaches the ordinary writer, and root replaces the old env file with the substituted app’s configuration at [sync.go:628](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:628).
+2. Alternatively, delete the old row while retaining an unrelated row. The reaper protects only registry hosts and current declaration hosts, so root deletes the old env file at [sync.go:488](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:488).
+
+In both cases, [`reapDropIns`:375](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/unitsync.go:375) retains the old drop-in because the unit name remains declared. With no deliverable new route, nothing replaces it. **The declared unit still loads the overwritten file, or loses its configuration, on its next start.**
+
+This persists across passes; it requires neither a filesystem race nor attacker access to the declaration. The new backing-change and deletion witnesses keep the declaration’s host unchanged. The re-stamp witness changes the unit while keeping the host unchanged. None covers this inverse reassignment.
+
+Protection must cover retained file references until the old binding has actually been retired, or this reassignment must be refused before either writer or reaper runs.
+
+**R3-E2 — P1: the ordinary writer bypasses the declaration-change guard.**
+
+**Fault family:** invariant A — authorization must remain valid through the effect it permits.
+
+[`SyncWithCallbacks`:118](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:118) builds `declaredRefusal` once from the planning snapshot. Its ordinary branch invokes `syncHostClaimed` at [line 374](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:374) without calling `plan.guard.check`. The write and rename check host claims, not declarations.
+
+With claims disabled, an agent-selected ordinary row therefore still writes if root has since declared that host for a different account/app. Ordinary delivery can also continue after a stamped route has marked the shared declaration guard stale.
+
+A deterministic witness can include an unrelated declared stamped route, then use the existing first-probe hook to add a declaration for an ordinary row’s host with a different account/app. Planning retains the earlier map; the ordinary row remains admitted and its env file is written. The declaration check before reaping at [sync.go:399](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:399) detects the change only after replacement.
+
+This is a missing mutation gate, separate from a narrow check/action race. The current declaration-change witness exercises only stamped delivery. Ordinary delivery needs the same declaration guard.
+
+Census history remains R1 **ESCALATED (10)**, R2 **ESCALATED (10)**, R3 **ESCALATED (6)**. These findings retain the existing declaration-authority family. I recommend withholding named-unit delivery until that boundary is enforced consistently; no further review round was started.
+
+Static review only: I changed no files, spawned no subagents, ran no tests and left `GOCACHE` untouched. Posting the complete verdict to #280 failed because the sandbox denied the network socket.
+
+ESCALATED (6)
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-named-unit-delivery-114-r4.md b/docs/superpowers/reviews/CODEX-FINDINGS-named-unit-delivery-114-r4.md
new file mode 100644
index 000000000..01341bbe8
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-named-unit-delivery-114-r4.md
@@ -0,0 +1,37 @@
+- **R3 P1-1 — Resolved:** declared-host checks precede both writers and refuse backing, stamp, account and app substitutions.
+- **R3 P1-2 — Resolved:** env cleanup retains declared hosts and skips unreadable declarations.
+- **R3 P1-3 — Partly resolved:** stamped operations re-read declarations, but the ordinary writer and several mutation boundaries remain unguarded.
+- **R3 P1-4 — Resolved:** printable-ASCII-only parsing rejects the Unicode counterexamples.
+- **R3 P2-5 — Resolved:** descriptor traversal checks directory ownership and permissions. Production anchors at `/`; only tests set the private alternate anchor.
+- **R3 P2-6 — Resolved:** declaration parsing now requires EOF.
+- **Census E1 — Resolved for the reported backing-change case:** refusal occurs before either writer; the temporal bypass remains under P1-3.
+- **Census E2 — Resolved for the reported registry-deletion case:** declaration-based env retention now applies.
+- **Census E3 — Resolved:** trusted traversal covers the three readers and drop-in directory validation.
+
+1. **P1 — Invariant A / R3 P1-3: declaration changes still permit unauthorized mutations.**
+
+ **Evidence:** the refusal map is computed once at [sync.go:118](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:118). The ordinary writer is subsequently called without `declGuard` at [sync.go:374](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:374), and replaces the env file at [sync.go:632](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:632).
+
+ **Failure scenario:** planning sees an ordinary unit-backed host H for app B. During bucket reads, an operator declares unit U for H and app A. The cached refusal map still admits H, so root writes B’s configuration into the file U loads. Even a guard already marked stale by another stamped route does not stop this writer.
+
+ Cleanup also lacks the promised check at each mutation: [unitsync.go:378](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/unitsync.go:378) checks before writing the pending marker, then removes the drop-in without another check. Env cleanup checks once at [sync.go:399](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:399), before directory enumeration and potentially many deletions at [sync.go:488](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/sync.go:488). A declaration added during these intervals does not protect its files. The requested serialization with declaration replacement remains absent.
+
+ **Fix:** make declaration stability cover the entire mutation transaction, including the ordinary writer and cleanup. Refuse further effects after a change; coordinate declaration replacement with that transaction. Add witnesses for a newly declared ordinary host and declarations changing during cleanup.
+
+ **Fault family:** authorization must remain valid through every effect it permits.
+
+2. **P2 — Invariant A / new guard: absent and empty declaration files compare equal.**
+
+ **Evidence:** absence becomes `nil` at [declarations.go:70](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/declarations.go:70). Planning hashes those bytes at line 88. The guard compares only the byte digest at [declarations.go:161](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-unit-delivery-114/internal/appconfig/declarations.go:161). Missing and zero-length files have the same digest.
+
+ **Failure scenario:** planning starts with no declaration file. An operator creates an empty, invalid file before cleanup. The guard accepts it as unchanged and permits reaping, although `loadDeclarations` would reject that file and block cleanup.
+
+ **Fix:** include presence in the guarded state and reject invalid replacement contents. Add an absent-to-empty witness asserting that cleanup stops.
+
+ **Fault family:** invalid or changed authority data must fail closed.
+
+No P3 findings. Reviewed `f9ad96e47ae4a22a37f567e8b9fd4b81180eb21c` against `origin/main`; merge base is `9bcbab0f5646c11c7d05c9346dcfcea8c84f0751`. Targeted Go tests could not start because the sandbox refused the temporary build directory. No files changed, subagents spawned, or full suites run; `GOCACHE` remained unset.
+
+The blocking paths share one cause: incomplete enforcement of declaration stability. Refusing mutations unless that stability is guaranteed, or cutting named-unit delivery from this branch, removes the exposure. This final round does not authorize another review.
+
+**NOT READY**
\ No newline at end of file