carlos / platform Public

plan: Astra R2 — share only the guard match, keep proofnamed's read

R2 closed all six R1 findings; its one new P1 (the guard helper dropped read errors and binding evidence) is fixed as Astra proposed. No R3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev bdf68e130e2a754e64368cf7c599984340cac118 parent 5c09514
2 files changed, +32 −8
  • docs/superpowers/plans/2026-11-19-named-units-from-parameters.md +16 −8
  • docs/superpowers/reviews/CODEX-FINDINGS-named-units-param-114-plan-R2.md +16 −0
diff --git a/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md b/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md
index 57ae437e4..4ded883a3 100644
--- a/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md
+++ b/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md
@@ -148,12 +148,19 @@ per `awsssm.go:21-25`); `rootstate` public stores; systemd root units.
`validateForInstall`, then the box guard rule, then the lock, then
`installNamedUnitsLocked`.
```go
- // consoleGuardHost: the host the armed console guard names, read as
- // proofnamed.go:126-133 does (trusted read of
- // <opt>/system/guard/console-ready.json, matched against
- // release.LiveLink). Extract that match into this one helper and have
- // proofnamed.go call it too.
- func consoleGuardHost(optDir string) (host string, ok bool)
+ // guardNames: the pure match proofnamed.go:133 does over bytes it has
+ // ALREADY read: string(marker) == release.LiveLink(optDir, host).
+ // proofnamed.go keeps its own add(marker) read, its error handling and
+ // its binding evidence, and calls only this. (Astra plan R2 #1.)
+ func guardNames(marker []byte, optDir, host string) bool
+ // consoleGuardHost is for the install callers only (never proofnamed):
+ // a trusted read (rootstate.OpenTrustedFile) of
+ // <opt>/system/guard/console-ready.json. Absent → ok=false, err=nil.
+ // Any other read failure → err, and the caller refuses the install.
+ // Present → the host whose LiveLink the marker equals (found by
+ // matching guardNames against the hosts in the candidate file and the
+ // current file); ok=false if none match.
+ func consoleGuardHost(optDir string, candidates []string) (host string, ok bool, err error)
// checkGuardRule: if guarded, the guarded host's entry, when present,
// must be console.service / app console / empty account (proofnamed.go:142).
func checkGuardRule(entries []namedunits.Entry, guardHost string, guarded bool) error
@@ -164,7 +171,8 @@ per `awsssm.go:21-25`); `rootstate` public stores; systemd root units.
- [ ] **Step 1: Failing tests**
- `TestInstallNamedUnitsRefusesWhatTheReleasePathRefuses`: a file with an unknown field, or an entry without `addr`, returns an error, and `dst` is not created.
- `TestCheckGuardRuleRefusesNonConsoleForGuardedHost`: guarded `a.example.com` mapped to `shop.service` → error; the same host as console → nil; other hosts unaffected.
- - The existing `TestPlan14NamedUnits*` tests still pass with `proofnamed.go` calling `consoleGuardHost`.
+ - `TestConsoleGuardHostRefusesUntrustedMarker`: a marker that is a symlink or group-writable → err (the install refuses), not ok=false.
+ - The existing `TestPlan14NamedUnits*` tests still pass with `proofnamed.go` calling `guardNames`, and a proofnamed test that replaces the marker with identical bytes but a new inode still changes the binding source.
- [ ] **Step 2:** `go test ./internal/host -run 'TestInstallNamedUnits'`. Expect the new test to FAIL and `TestInstallNamedUnitsWaitsForTheConfigSyncLock` to PASS. That test must keep passing; if its fixture lacks addr/health, give it both.
- [ ] **Step 3:** Implement the split.
- [ ] **Step 4:** Run step 2 again: PASS.
@@ -256,7 +264,7 @@ per `awsssm.go:21-25`); `rootstate` public stores; systemd root units.
lock func() (func(), error)
dst string
inUse func(host string) (bool, error) // declarationBindingInUse, bound
- guardHost func() (host string, ok bool) // consoleGuardHost(release.OptDir())
+ guardHost func(candidates []string) (host string, ok bool, err error) // consoleGuardHost(release.OptDir(), ...); err → outcome invalid
now func() time.Time
}
func (f namedUnitsFetch) run(ctx context.Context) status.NamedUnitsStatus
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-named-units-param-114-plan-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-named-units-param-114-plan-R2.md
new file mode 100644
index 000000000..69dc48202
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-named-units-param-114-plan-R2.md
@@ -0,0 +1,16 @@
+At `5c09514b`, all six R1 findings are addressed in the revised plan:
+
+- **R1 #1, P1 — Closed:** pending history completion holds replacement regardless of `Settled` or deadline ([plan:242](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md:242)).
+- **R1 #2, P1 — Closed:** affected hosts include the guarded console, even with no declaration file ([plan:275](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md:275)).
+- **R1 #3, P2 — Closed:** outcomes accumulate per host and emit once after application, with explicit coverage for unchanged delivery, later refusal, missing routes and unresolved config ([plan:323](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md:323)).
+- **R1 #4, P2 — Closed:** both installation paths apply the guard rule ([plan:147](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md:147)). The proposed extraction introduces the separate issue below.
+- **R1 #5, P2 — Closed:** the fetch result is written before public-key parsing ([plan:283](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md:283)).
+- **R1 #6, P2 — Closed:** separate command nodes, audiences, parity rows and checks are specified ([plan:375](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md:375)).
+
+1. **P1 — The new guard-reader extraction loses required release-proof information.**
+ **Invariant:** guard reads must fail closed and remain part of the release binding.
+ **Evidence:** [plan:151](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/docs/superpowers/plans/2026-11-19-named-units-from-parameters.md:151) specifies a shared reader returning only `(host, ok)` and directs `proofnamed.go` to use it. The existing [proofnamed.go:126](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/internal/host/proofnamed.go:126) propagates every marker-read error except absence. Its `add(marker)` also incorporates the marker’s bytes and identity into the source hash and file evidence ([proofnamed.go:83](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/named-units-param-114/internal/host/proofnamed.go:83)).
+ **Failure:** the proposed return contract cannot distinguish an absent guard from an unreadable or untrusted marker, or carry its binding evidence. Replacing the existing read with this helper can turn a refusal into an unguarded declaration resolution and stop marker replacement from invalidating recorded proofs.
+ **Smallest fix:** share only the matching logic over already-read bytes. Retain `add(marker)` and its error handling in `proofnamed.go`; installation callers perform their own trusted read and propagate failures. Add tests for an untrusted marker and replacement with identical bytes but a different identity.
+
+NOT READY
\ No newline at end of file