carlos / platform Public

review: round 2 findings and scoped-check brief, bounded-systemctl

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev fe8da668241e9c3c2d09eec6ab6184f51df98eea parent 9b22c61
2 files changed, +143 −0
  • docs/superpowers/reviews/CHECK-BRIEF-bounded-systemctl-R2-fix.md +28 −0
  • docs/superpowers/reviews/FINDINGS-bounded-systemctl-R2.md +115 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/reviews/CHECK-BRIEF-bounded-systemctl-R2-fix.md b/docs/superpowers/reviews/CHECK-BRIEF-bounded-systemctl-R2-fix.md
new file mode 100644
index 000000000..0edb17051
--- /dev/null
+++ b/docs/superpowers/reviews/CHECK-BRIEF-bounded-systemctl-R2-fix.md
@@ -0,0 +1,28 @@
+# Scoped check: bounded-systemctl, after round 2 (not a review round)
+
+Repo carlos/platform, branch `bounded-systemctl` (tip in the prompt).
+Round 2 (`docs/superpowers/reviews/FINDINGS-bounded-systemctl-R2.md`) ended
+READY AFTER FIXES with two P2s in round-1 families; stopping rule 2
+applied and Paul chose the centralized fix (2026-11-17). The fix is commit
+0fa550f8, census 9b22c61f. AGENTS.md rule 1: the review does not reopen;
+root behaviour and the census are checked. Scope: `git show 0fa550f8`
+and the census card `docs/superpowers/notes/census-proposal-bounded-systemctl.md`
+(only systemdUnits.Show's claim changed since round 2).
+
+Check:
+1. Each round-2 P2: resolved, partly, not.
+2. Settle: a deadline reached through temporary observation failures
+ returns one error that is both UnitNotUpError (errors.As) and
+ Temporary(). Through adopt: rollback restart selected (process
+ replaced), version not poisoned. An observed failure (failed state,
+ wrong executable, not ready) is non-temporary as before. Any path where
+ a genuinely broken build is now retried forever, or a plain start is
+ used after a rollback?
+3. Guard: one complete AST traversal (function literals, methods,
+ package-level var initializers, init). Any remaining bypass form?
+4. Census: verdict for systemdUnits.Show and the internal/host and
+ internal/systemd envelopes at this tip, citing lines read.
+
+Answer each: OK, or a finding with file:line, failure scenario and fix,
+marked P1 or P2. End with exactly one line: CHECK PASSED, or CHECK FAILED
+with the P1s. Do not edit files, spawn reviewers or run full suites.
diff --git a/docs/superpowers/reviews/FINDINGS-bounded-systemctl-R2.md b/docs/superpowers/reviews/FINDINGS-bounded-systemctl-R2.md
new file mode 100644
index 000000000..103b7ec78
--- /dev/null
+++ b/docs/superpowers/reviews/FINDINGS-bounded-systemctl-R2.md
@@ -0,0 +1,115 @@
+- **R1 P1 — Resolved:** mutations receive no helper deadline, removing the newly introduced ambiguous restart outcome.
+- **R1 P2-2 — Partly resolved:** caps now wraps with `%w`; settle still discards the temporary classification.
+- **R1 P2-3 — Resolved:** the 18-minute apply/recovery class is removed.
+- **R1 P2-4 — Partly resolved:** ordinary function bodies are covered, but package-level function literals bypass the shell scan.
+- **R1 P2-5 — Resolved:** `Detached()` is removed; host call sites use commented, explicitly recorded `context.Background()` calls.
+
+Reviewed `origin/main...bd3a6f3b06d962b4ef4c1a616ad01f2a73d2bbf9`, with merge base `7e50962dd68738bf9fc77cd49e6e73032ce0148b`. `origin` points to amadan. Round 2 of 3.
+
+No P1 findings. Two P2 findings remain.
+
+1. **P2 — Preserve temporary observation failure without losing rollback recovery.**
+
+ Locations: [unitsettle.go:64](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/unitsettle.go:64), [unitsettle.go:215](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/unitsettle.go:215).
+
+ After a successful restart, a hung `show` consumes the settle window and returns `TimeoutError`. `settleUnit` then constructs a `UnitNotUpError`, retaining only the timeout’s text. Adoption consequently poisons that version for the rest of the pass at [adopt.go:1976](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/release/adopt.go:1976), despite having no evidence that the build failed.
+
+ Keeping the not-up recovery is appropriate: it replaces the process after restoring the symlink. However, this does **not** require losing the temporary classification. Adoption checks `Temporary()` and `UnitNotUpError` independently; the latter selects the stronger recovery at [adopt.go:2066](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/release/adopt.go:2066).
+
+ **Invariant / fault family:** inability to observe a process must remain distinguishable from evidence that its build is unhealthy, while rollback retains process-replacement recovery.
+
+ **Fix:** for a settle deadline reached through temporary observation failures, return an error that remains discoverable as `UnitNotUpError` and reports `Temporary() == true`. Preserve ordinary non-temporary verdicts for observed failures. Extend the adoption regression to prove that a timed-out observation selects rollback restart, never plain start, and does not poison the version for the second route. The existing adoption test covers an observed failed unit only.
+
+2. **P2 — Package-level function literals bypass the local-shell guard.**
+
+ Location: [guard_test.go:238](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/systemd/guard_test.go:238).
+
+ The shell scan visits only top-level `*ast.FuncDecl` bodies. This package-level command seam escapes it:
+
+ ```go
+ var query = func() error {
+ return exec.Command("sh", "-c",
+ "systemctl show carlos-edge.service").Run()
+ }
+ ```
+
+ The literal scan also misses it: the command string is neither exactly a program name nor a path ending in that name. Package-level function literals are an established pattern here, including `claimSystemctl` and demobuild’s `systemctl`.
+
+ A future query introduced in this form can therefore hang indefinitely while the guard passes. This is a source-level counterexample; I could not execute the fixture in this sandbox.
+
+ **Invariant / fault family:** routing local systemctl/journalctl execution through the helper must not depend on whether its enclosing function is declared or assigned.
+
+ **Fix:** apply the invocation check throughout the file, including function literals and package initializers, with the necessary local bindings. Add a negative fixture for the example above while retaining the narrow remote-script distinction.
+
+No P3 findings.
+
+Both remaining findings belong to fault families raised in R1. The repeated-family stopping rule applies before another patch. I recommend its centralized-invariant option: preserve recovery and temporary classification together at the settle error boundary, and inspect executable calls through one complete AST traversal. Cutting bounded settle observations would remove the first branch-specific failure; removing the guard would abandon a required deliverable. No further whole-branch review round is warranted without a P1; any production fix still needs its scoped root/census check.
+
+The following census verdicts cover all **48 units and nine envelopes**. “Approve” retains the recorded disposition and obligations. “Reject” withholds approval for the implementation; it does not downgrade its classification.
+
+| Unit and source read | Recorded disposition | Verdict and basis |
+|---|---|---|
+| `Ops.query` — [converge.go:1061](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/caps/converge.go:1061) | authority E4,J1,J4 | **Approve.** Same arguments and existing false-on-error behavior. |
+| `Ops.systemctl` — [converge.go:1037](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/caps/converge.go:1037) | authority E4,J1,J4 | **Approve.** Mutations retain their previous lifetime; `%w` preserves the underlying error. |
+| `unitsAreActive` — [adopt_advice.go:52](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/adopt_advice.go:52) | diagnostic H3 | **Approve.** Same host-derived query and positional-count refusal. |
+| `systemctlStartUnit` — [agent.go:5697](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/agent.go:5697) | legacy | **Approve.** Same start arguments and error handling; no added deadline. |
+| `systemctlTryRestart` — [agent.go:5548](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/agent.go:5548) | legacy | **Approve.** No newly introduced timeout reaches the existing log-and-continue path. |
+| `systemctlTryRestartUnit` — [agent.go:5574](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/agent.go:5574) | legacy | **Approve.** Same single unit argument and returned mutation error. |
+| `systemctl` — [bootstrap.go:852](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/bootstrap.go:852) | legacy | **Approve.** Existing arguments retained; mutations remain unbounded by the helper. |
+| `adoptTimerActive` — [probes.go:45](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/probes.go:45) | legacy | **Approve.** Fixed timer query and existing parser retained. |
+| `configPathActive` — [probes.go:64](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/probes.go:64) | legacy | **Approve.** Fixed path-unit query and parser retained. |
+| `restartPathActive` — [probes.go:84](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/probes.go:84) | legacy | **Approve.** Fixed path-unit query and parser retained. |
+| `systemUpdatePathActive` — [probes.go:99](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/probes.go:99) | legacy | **Approve.** Fixed update-path query and parser retained. |
+| `productionSysOps` — [systemapply.go:205](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/systemapply.go:205) | authority D,F,J4 | **Approve.** Apply/recovery mutations retain prior behavior; query arguments and protected decisions are unchanged. |
+| `systemctlProbe` — [systemunits.go:327](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/systemunits.go:327) | legacy | **Approve.** Same stdout and error interface, with bounded queries. |
+| `daemonReload` — [unitops.go:192](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/unitops.go:192) | legacy | **Approve.** Fixed reload command, same error handling and lifetime. |
+| `probeUnits` — [unitops.go:140](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/unitops.go:140) | legacy | **Approve.** Same properties, positional parser and count-mismatch refusal. |
+| `systemctlRestartUnit` — [unitops.go:204](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/unitops.go:204) | legacy | **Approve.** Existing bound-unit delivery prerequisites remain; no helper deadline. |
+| `systemctlVerb` — [unitsettle.go:107](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/unitsettle.go:107) | authority B3,J1,J4 | **Approve.** Existing mutation arguments and error wrapping retained. |
+| `systemdUnits.JournalTail` — [unitsettle.go:75](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/unitsettle.go:75) | authority B3,J1,J4 | **Approve.** Same journal selection and output handling; no added read source. |
+| `systemdUnits.Show` — [unitsettle.go:61](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/unitsettle.go:61) | authority B3,J1,J4 | **Reject.** Finding 1: the newly bounded observation reaches settle’s non-temporary build verdict. |
+| `Server.runGVisorProbe` — [gvisorprobe.go:154](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/instancectl/gvisorprobe.go:154) | legacy | **Approve.** Fixed unit, attempt-specific journal window and five-second diagnostic context retained; cleanup proof unchanged. |
+| `type Server` — [server.go:180](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/instancectl/server.go:180) | legacy | **Approve.** Journal callback declaration only; no request-controlled callback introduced. |
+| `Cmd.run` — [command.go:124](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/systemd/command.go:124) | new legacy | **Approve.** Closed program selector; caller arguments, environment and directory retained; mutations use only the caller context. |
+| `Command` — [command.go:98](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/systemd/command.go:98) | new legacy | **Approve.** Constructor retains conservative caller census sites and introduces no externally selected executable. |
+| `bounded` — [command.go:172](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/systemd/command.go:172) | new legacy | **Approve.** Query deadline and pipe-wait bound reach execution; helper timeout is distinguishable from the caller’s cancellation. |
+| `UnitBackend.systemctl` — [backend_unit.go:104](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/activator/backend_unit.go:104) | legacy | **Approve.** Sandbox launch gate, seam, arguments and caller context retained. |
+| `systemctlControlGroup` — [control.go:200](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/activator/control.go:200) | legacy | **Approve.** Same property; observation failure remains an error. |
+| `systemctlUnitMainExit` — [control.go:167](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/activator/control.go:167) | legacy | **Approve.** Same exit properties and parser. |
+| `systemctlUnitState` — [control.go:121](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/activator/control.go:121) | legacy | **Approve.** Same state/invocation query; no error-to-success conversion. |
+| `systemctlUnitsListed` — [control.go:144](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/activator/control.go:144) | legacy | **Approve.** Same listing arguments and glob. |
+| `var systemctl` — [unit.go:78](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/demobuild/unit.go:78) | legacy | **Approve.** Absolute executable, fixed environment and capped combined output retained. |
+| `MainProcess` — [native_linux.go:78](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/hairpin/native_linux.go:78) | legacy | **Approve.** Fixed edge query and kernel identity binding retained. |
+| `filesSeedEdgePID` — [claimfilesseed_delegation_linux.go:19](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/claimfilesseed_delegation_linux.go:19) | authority C,J4 | **Approve.** Fixed edge query, three-second caller deadline and PID validation retained. |
+| `var claimSystemctl` — [claimjournal_migration_linux.go:42](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/claimjournal_migration_linux.go:42) | authority C,G,J4 | **Approve.** Same caller context, arguments and output; no new mutation deadline. |
+| `claimLaunchFor` — [claimlaunch_production.go:87](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/claimlaunch_production.go:87) | authority C,D,J4 | **Approve.** Authentication, delegation and fixed roots retained; execution callback preserves caller context. |
+| `NewProductionClaimStopHandler` — [claimstop_production.go:24](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/claimstop_production.go:24) | authority C,J4 | **Approve.** Three-second fixed-unit query, controller verification and peer authentication retained. |
+| `agentUnitCgroup` — [claimstop_writers_linux.go:388](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/claimstop_writers_linux.go:388) | authority C,G,J4 | **Approve.** Caller deadline and local-path validation retained. |
+| `rootStopAgentCgroup` — [claimstop_writers_linux.go:433](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/claimstop_writers_linux.go:433) | authority C,J4 | **Approve.** Fixed identity properties, deadline and containment parser retained. |
+| `captureProductionClaimUnitSocket` — [claimunit_socket_migration_linux.go:86](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/claimunit_socket_migration_linux.go:86) | authority E2 | **Approve.** Predecessor-unit query, peer proof and socket identity recheck retained. |
+| `dbReadUnits` — [dbreads_linux.go:20](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/dbreads_linux.go:20) | legacy | **Approve.** Fixed read-only listing; query failure remains an error. |
+| `systemctlOutput` — [egress_source.go:386](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/egress_source.go:386) | legacy | **Approve.** Same caller-selected arguments, output and context; existing validation boundaries remain. |
+| `maintenanceEdgeProcess` — [group_maintenance_verbs_linux.go:166](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/group_maintenance_verbs_linux.go:166) | legacy | **Approve.** Absolute executable, fixed environment/directory, one-second deadline, bounded output and process identity read retained. |
+| `platformUnitRestarts` — [restartwatch.go:258](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/restartwatch.go:258) | legacy | **Approve.** Fixed glob, existing deadline and nil-on-error handling retained. |
+| `generationServiceShow` — [rootgeneration_services_linux.go:108](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/rootgeneration_services_linux.go:108) | authority E2 | **Approve.** Same service properties; failed observation returns before parsing. |
+| `runscSystemctl` — [runscensure.go:36](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/host/runscensure.go:36) | legacy | **Approve.** Same arguments and caller context; no added executable choice. |
+| `newHairpinResetServer` — [hairpin.go:324](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/instancectl/hairpin.go:324) | legacy | **Approve.** Existing runner replaced without changing arguments or authority. |
+| `systemdEdgeMainPID` — [peer_linux.go:99](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/instancectl/peer_linux.go:99) | legacy | **Approve.** Fixed query and three-second deadline retained; no peer-controlled argument. |
+| `runWithClaim` — [server.go:315](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/instancectl/server.go:315) | authority C,D,G | **Approve.** Existing start guard remains installed; separate journal callback preserves the diagnostic’s arguments and context. |
+| `systemdDaemonReload` — [ops.go:232](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/ops/ops.go:232) | legacy | **Approve.** Fixed reload command and existing one-minute caller deadline retained. |
+
+| Re-pinned envelope | Verdict and basis |
+|---|---|
+| `internal/activator` | **Approve.** Changed runner and query functions cited above preserve launch checks and observation-error handling. |
+| `internal/caps` | **Approve.** Changed runners preserve mutation authorization and arguments; `%w` improves error propagation. |
+| `internal/demobuild` | **Approve.** Fixed executable/environment and output cap remain at [unit.go:78](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/demobuild/unit.go:78). |
+| `internal/edge` | **Approve.** [prober.go:137](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/edge/prober.go:137) applies the effective probe timeout; [upstreamdial.go:51](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/edge/upstreamdial.go:51) retains `upstreamguard`, whose refusal precedes connection and custom hooks. |
+| `internal/hairpin` | **Approve.** Fixed systemd identity query and kernel binding remain at [native_linux.go:78](/home/paulca/amadan.net/carlos/platform-bounded-systemctl/internal/hairpin/native_linux.go:78). |
+| `internal/host` | **Reject.** Finding 1 remains in the bounded-show-to-settle path. Other changed functions retain their existing arguments, validation, environments and mutation lifetimes. |
+| `internal/instancectl` | **Approve.** Journal rewiring is diagnostic only; start fencing, peer checks and probe cleanup remain intact. |
+| `internal/ops` | **Approve.** Existing reload deadline and command retained. |
+| `internal/systemd` | **Approve for census authority.** Production execution preserves the reviewed callers’ executable choices, arguments and environments. Finding 2 concerns guard coverage and remains a branch-level P2. |
+
+The focused command `GOFLAGS=-mod=mod GOPROXY=off go test ./internal/systemd -count=1` could not start: Go could not create its work directory on the read-only filesystem. No tests executed, and I ran no full suites. Diff whitespace checks passed for Go, census and ratchet changes; the full check reports five Markdown hard-break lines in the saved R1 review. I changed no files and spawned no reviewers.
+
+READY AFTER FIXES
\ No newline at end of file