carlos / platform Public

census: propose systemdUnits.Show (-p Job) for #452; review rounds 1-2 and the round-3 brief

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Summary

Census overlay and card for the Show argv change; Astra round 1-2 findings with dispositions; round-3 brief.
claude agent, operated by paul@keymail.dev 250c74660ffc00645c2d5b419bec8f0e12be5a84 parent 776d374
6 files changed, +156 −0
  • docs/superpowers/notes/census-proposal-stage-foreign-restart-452.md +19 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r1.md +39 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r2.md +31 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-stage-foreign-restart-452-R3.md +62 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-stage-foreign-restart-452.tsv +4 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/notes/census-proposal-stage-foreign-restart-452.md b/docs/superpowers/notes/census-proposal-stage-foreign-restart-452.md
new file mode 100644
index 000000000..14f9eec0e
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-stage-foreign-restart-452.md
@@ -0,0 +1,19 @@
+# Census approval: stage-foreign-restart-452
+
+Ruling `census-ruling-stage-foreign-restart-452`. 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/host/unitsettle.go` `systemdUnits.Show` | body | unchanged (1) | Adds "-p Job" to the fixed `systemctl show <unit>` argv, so settleUnit can tell an operator stop (inactive/dead, no job) from a foreign restart in flight (inactive/dead, start job queued). Same exec, same unit argument from the caller, read-only systemd query; no new read kind; parseShow takes the extra Job= line into unitProps.Job. |
+
+Envelopes re-pinned: `internal/host`.
+
+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. Escalate 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. An escalation goes to the census owner as a decision.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/host/unitsettle.go` `systemdUnits.Show`: authority, task B3,J1,J4. Basis: root-input
+
+Seal: `4337475617b84cadf26e62a31387b7de1b6e9174bf5e6fa4d191f2d2a024e930` → `4337475617b84cadf26e62a31387b7de1b6e9174bf5e6fa4d191f2d2a024e930`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-stage-foreign-restart-452.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r1.md b/docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r1.md
new file mode 100644
index 000000000..163ac234c
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r1.md
@@ -0,0 +1,39 @@
+# Astra findings: stage-foreign-restart-452 (#452), round 1
+
+Reviewer: Astra (codex exec -m gpt-6-astra, read-only). Brief: the problem statement and the diff against main at round 1's tip.
+
+**Two blockers. I would not merge this as written.**
+
+1. **Blocker — an external restart’s stop/start gap bypasses settling.**
+ `internal/host/unitsettle.go:232–236`, ahead of the changed branch at `:245`.
+
+ CARLOS’s completed `try-restart` does not imply that another caller’s later `restart` has completed. Systemd finishes the stop half, converts the restart job into a queued start job, and can expose `inactive/dead` while that start is pending. [https://raw.githubusercontent.com/systemd/systemd/v257/src/core/job.c](https://raw.githubusercontent.com/systemd/systemd/v257/src/core/job.c)
+
+ Reproducer: `active/ours, not ready → inactive/dead with external start pending → active/theirs`. The second observation returns `errUnitStopped`; the third is never checked. Agent and legacy restart callers translate that error into `nil`, including rollback callers. Consequently, adoption can proceed without establishing that the replacement build came up—even if the pending start subsequently fails. Strict root callers also abandon the check rather than waiting for the external restart.
+
+ Distinguish a completed stop from a pending restart before returning `errUnitStopped`. Add tests covering the gap followed by both a healthy replacement and a failed replacement, while retaining deliberate-stop coverage.
+
+2. **Blocker — the replacement invocation inherits an executable-check bypass.**
+ `internal/host/unitsettle.go:253–255`, interacting with `:265–271`.
+
+ The new branch resets `inv` and `activeSince`, but preserves `binCheckSkipped`. Concrete sequence:
+
+ - Invocation A: `Exe` returns `EACCES`; readiness fails.
+ - External restart creates invocation B, with `NRestarts=0`.
+ - B runs the **old executable**, which is now readable; readiness succeeds.
+
+ The function returns success without calling `Exe` for B. Previously, the invocation change failed. This affects agent and legacy paths, including rollback; `RequireExe=true` protects the strict root paths.
+
+ Reset the permission-based bypass when changing invocations so the replacement gets its own executable check. Add this sequence as a regression test and assert that the readable old executable is rejected.
+
+The central systemd assumption otherwise holds: a manual start resets `NRestarts`, whereas an automatic restart increments it. However, the initial `activating/auto-restart` waiting period can still carry the **previous invocation and `NRestarts=0`**; the counter increments when the restart job is queued. The new crash-loop test skips that phase. Add it before the incremented-counter observation. [https://raw.githubusercontent.com/systemd/systemd/v257/src/core/service.c](https://raw.githubusercontent.com/systemd/systemd/v257/src/core/service.c)
+
+I traced all production `settleUnit` callers. The Hold reset, unchanged deadline, per-poll `wrongExe` reset, and transient `lastExeErr` handling look sound. `lastReady` cannot itself produce a false success. The pre-switch counter check still rejects observed automatic restarts before accepting readiness.
+
+No files changed. Tests were inspected, not executed; this environment permits only filesystem reads.
+
+## Author's disposition (Claude)
+
+1. Stop half of a foreign restart read as an operator stop: **fixed** in 776d3748. `systemdUnits.Show` reads `Job`; only `inactive`/`dead` with no pending job returns `errUnitStopped`. Tests: `TestSettleWaitsOutTheStopHalfOfAForeignRestart`, `TestSettleStopHalfOfAForeignRestartThenFailed`. Deliberate-stop coverage kept (`TestSettleStoppedUnitIsErrUnitStopped`, `TestNamedRestartStopDuringSettleIsNotJudged`).
+2. `binCheckSkipped` inherited by a replacement invocation: **fixed** in 776d3748. It is reset with `inv`. Test: `TestSettleForeignRestartGetsItsOwnExeCheck`.
+3. Crash-loop test skipped the RestartSec wait: **fixed**. `TestSettleCrashLoopAfterAForeignRestartStillFails` now includes `activating/auto-restart` on the old invocation with NRestarts 0.
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r2.md b/docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r2.md
new file mode 100644
index 000000000..8a5f8a54c
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r2.md
@@ -0,0 +1,31 @@
+# Astra findings: stage-foreign-restart-452 (#452), round 2
+
+Reviewer: Astra (codex exec -m gpt-6-astra, read-only). Brief: the problem statement and the diff against main at round 2's tip.
+
+**Round 2: one blocker, one nit.** I found no new functional false-pass regression in the changed settle logic.
+
+1. **Blocker — missing census update:** `internal/host/unitsettle.go:63`.
+ `systemdUnits.Show` now requests `Job`, but its old fingerprint remains at `internal/provision/testdata/census-base.tsv:3918`. The branch contains no census overlay or envelope update. Consequently, the required root-read census will reject this source change. Generate the proposal, obtain the required independent approval, and verify the census before merging.
+ **Invariant:** changes to root’s inputs must match the reviewed census.
+
+2. **Nit — foreign-restart diagnostics miss invocations that never become active:** `internal/host/unitsettle.go:250`.
+ The counter depends on `inv`, which is populated only when an invocation reaches `active` and cleared when its replacement is first observed. For example, `activating/A → activating/B → failed/B`, with `NRestarts=0`, produces only “unit entered failed state”; it omits the foreign restart. Likewise, multiple replacements during startup are undercounted. Track the last observed nonempty invocation separately from the invocation used for Hold, and add that sequence as a diagnostic test. The failure verdict itself remains correct.
+ **Invariant:** failure diagnostics distinguish external restarts from automatic restarts.
+
+The three round-1 findings are **resolved**:
+
+- `inactive/dead` with a pending job now continues polling.
+- A replacement invocation resets `binCheckSkipped` and must undergo its own executable check.
+- The crash-loop test includes `activating/auto-restart` before the counter increases.
+
+The `Job` parser matches systemctl’s numeric-or-empty output. The revised crash-loop sequence also matches systemd’s delayed increment of `NRestarts`. Sources: [https://github.com/systemd/systemd/blob/v257/src/systemctl/systemctl-show.c#L1050-L1062](https://github.com/systemd/systemd/blob/v257/src/systemctl/systemctl-show.c#L1050-L1062), [https://github.com/systemd/systemd/blob/v257/src/core/service.c#L309-L312](https://github.com/systemd/systemd/blob/v257/src/core/service.c#L309-L312).
+
+I checked all production callers, including rollback and root restart requests. The deadline remains fixed; Hold restarts for a replacement invocation; wrong-executable observations still prevent readiness checks; and the positive `NRestarts` checks precede acceptance.
+
+**Validation limitation:** targeted tests could not start: Go’s build-directory creation failed with “read-only file system.” No files changed.
+
+
+## Author's disposition (Claude)
+
+1. Census not updated for `systemdUnits.Show`: **done**. `make census-propose NAME=stage-foreign-restart-452` wrote the overlay, its chain line and `docs/superpowers/notes/census-proposal-stage-foreign-restart-452.md`. The census tests pass. The verdict is round 3.
+2. Nit: a foreign restart whose invocations never reach `active` is not counted in the message. This is a P3, so it went on the branch's follow-up list (task 905), as the stopping rules require. The failure verdict is unaffected.
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-stage-foreign-restart-452-R3.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-stage-foreign-restart-452-R3.md
new file mode 100644
index 000000000..6964f70da
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-stage-foreign-restart-452-R3.md
@@ -0,0 +1,62 @@
+# Review brief: branch stage-foreign-restart-452 (#452), round 3 of 3
+
+Repo carlos/platform, branch `stage-foreign-restart-452`, the commit that adds this brief (the tip named in your prompt).
+Under review: the diff `origin/main...HEAD`, and the census card `docs/superpowers/notes/census-proposal-stage-foreign-restart-452.md`.
+Authorities: `docs/superpowers/specs/2026-10-06-console-release-defences-design.md` §2.3 (the settle check; amended on this branch for #452), AGENTS.md "The census: the reviewer decides" and "Stopping rules". Do not review against unmerged branches.
+
+You are an independent reviewer. Read the card and the diff, then the code they name, and check every claim against that code.
+
+## The problem
+
+Discussion #452. On Tito production, `carlos-stage` rolled back a healthy build as "did not come up: systemd restarted it (new invocation)". The app's own control daemon had run `systemctl restart` on the same unit at the same second as the staging pass's try-restart. `settleUnit` (internal/host/unitsettle.go) fixed on the first new invocation and failed on any later one. The fix: a later invocation that systemd's Restart= did not start (NRestarts 0) is a foreign restart. The check moves onto it and applies the same proof until the original deadline. Failures after such a restart say so.
+
+## Fixed: do not re-argue
+
+- Paul's ruling on #280 (2026-10-26): the census reviewer decides every class; nothing escalates to the census owner.
+- Round 2's P3 (an invocation that never reaches active is not counted in the message) is on the follow-up list. It is not a reason for another round.
+
+## What to check
+
+1. **Census verdict.** Give a verdict for the unit `internal/host/unitsettle.go` `systemdUnits.Show` (body change: `-p Job` added to the argv) and for the re-pinned `internal/host` envelope (read every changed function in the package and what it reaches), per AGENTS.md "Getting a change approved" step 4. Cite the lines you read.
+2. Does any change let `settleUnit` PASS a build that did not come up: a crash loop, a failed unit, the old build, or a build never ready or held? A false pass is worse than a false fail here.
+3. Does the `Job` check change the verdict for a genuine operator stop (inactive/dead, no job)?
+
+## Round 3
+
+Earlier rounds: `docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r1.md`, `docs/superpowers/reviews/CODEX-FINDINGS-stage-foreign-restart-452-r2.md`. The round number counts every earlier review of this change.
+
+First give one line per P1 and P2 from round 2 (`CODEX-FINDINGS-stage-foreign-restart-452-r2.md`): resolved, partly, or not. Carry every unresolved or partly resolved finding forward at its current severity, then add new findings. The verdict covers everything outstanding, earlier rounds included.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work.
+ Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The
+ census, and review of any newly changed security, root, termination
+ or production-storage behaviour, still check the fix; see AGENTS.md,
+ "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for
+ another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not
+raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the section or task, the problem,
+the evidence (file:line, verified), the failure scenario, a concrete
+fix and the invariant or trust boundary it breaks (that is its fault
+family). Then the census verdict per unit and envelope (approve or
+reject, with the lines read). End with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another
+ round.
+- **NOT READY**: one or more P1s, listed.
+
+In round 3, a NOT READY also says whether the P1s share one cause, and
+whether refusing the case up front or cutting the feature would remove
+them.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 96a507acc..fc3759877 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -18,3 +18,4 @@ plan14-root-reads-plans-6b-checkout-flow.tsv f5afdacd495705841fcc8441eaefe0efb9d
plan14-root-reads-nearest-region-followups.tsv f5afdacd495705841fcc8441eaefe0efb9db7056de281bb06d1714960a5575b7
plan14-root-reads-region-ha-p1b1.tsv 185170fe393cb565d18a3359dee5ace12676b3e1adecb8b638199d25ceeb779f
plan14-root-reads-rootfs-apps-3.tsv 4337475617b84cadf26e62a31387b7de1b6e9174bf5e6fa4d191f2d2a024e930
+plan14-root-reads-stage-foreign-restart-452.tsv 4337475617b84cadf26e62a31387b7de1b6e9174bf5e6fa4d191f2d2a024e930
diff --git a/internal/provision/testdata/plan14-root-reads-stage-foreign-restart-452.tsv b/internal/provision/testdata/plan14-root-reads-stage-foreign-restart-452.tsv
new file mode 100644
index 000000000..1a89710fe
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-stage-foreign-restart-452.tsv
@@ -0,0 +1,4 @@
+# Census overlay stage-foreign-restart-452, written by census-propose (#369). census-ruling-stage-foreign-restart-452, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-stage-foreign-restart-452.md.
+# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+internal/host/unitsettle.go systemdUnits.Show authority B3,J1,J4 root-input;rev3=census-ruling-stage-foreign-restart-452;basis=Adds "-p Job" to the fixed `systemctl show <unit>` argv, so settleUnit can tell an operator stop (inactive/dead, no job) from a foreign restart in flight (inactive/dead, start job queued). Same exec, same unit argument from the caller, read-only systemd query; no new read kind; parseShow takes the extra Job= line into unitProps.Job. file:Command@72 08fe1018d226a54fbef492c8472f6e5cc833d96f117f999a4493fc3aee769090
+@coverage internal/host 549ad795e3f300756113688b05a2b58a73851cf1437b182656f34f672884d0ba