fix(sdlc): activate inert INV-1..5 trace-checker + unify auto-mint onto the live escape-grant contract#3839
Conversation
…to the live escape-grant contract hapax-sdlc-invariants.service (#3820, the reform never-stuck keystone) crash-looped 203/EXEC every ~5min: ExecStart hardcoded %h/projects/hapax-council — the primary worktree a lane had parked on a feature branch where the script + shared/sdlc_invariants.py don't exist — and the wrapper then self-redirected back there via REPO=${HAPAX_COUNCIL_REPO:-$HOME/projects/hapax-council}. And even if it ran, the INV-3/4/5 auto-mint wrote <slug>-<id>.json into ~/.cache/hapax/escape-grants signed with ~/.config/hapax/coord-capability.key — none of which the live escape-grant.sh shim reads (it globs <coord>/grants/*.grant verified with <coord>/grant-key), so every auto-minted escape was inert. The chaos test passed only because it mint+verifies in-process with a shared tmp_path key, masking the production disconnect. Unit + wrapper (defect 1 — 203/EXEC): - Repoint ExecStart/ExecStartPre/Documentation/ConditionPathExists at the stable deploy worktree %h/.cache/hapax/rebuild/worktree (kept fresh on origin/main by reform-deploy-chain-repair) — the pattern the hapax-audio-health-* units already use — and set HAPAX_COUNCIL_REPO + PATH so the wrapper never self-redirects into the primary worktree. - Wrapper resolves REPO from its own location (the deploy worktree), resolves uv under a minimal systemd PATH, and grows a --verify mode used as ExecStartPre so a misdeploy fails loudly (OnFailure=notify-failure@%n -> ntfy) instead of a silent 203/EXEC; ConditionPathExists turns an absent/not-yet-deployed target into a clean skip. Auto-mint (defect 2 — inert escape): - shared/sdlc_invariants.py imports default_grant_dir()/default_grant_key() from shared.coord_event_log (the SSOT coord-grant-mint and the shim use), resolved at CALL TIME, and writes <grant_id>.grant — so an auto-minted escape lands where the shim globs, signed with the key the shim verifies. No module-level path snapshot (the snapshot WAS the bug). Tests: - New tests/test_sdlc_invariants_escape_grant_integration.py drives BOTH the Python minter and the REAL escape-grant.sh shim through the canonical resolvers (HAPAX_COORD_DIR-redirected) and asserts the shim's glob + HMAC-verify ACCEPTS the auto-minted grant — failing if dir, extension, or key diverge. Includes a control (empty dir -> shim denies, proving it can fail). - Update the chaos test's <slug>-<id>.json assertions to the <grant_id>.grant contract. Audit (AC#5): hapax-sdlc-invariants.service is now clean; hapax-opus-route-authority-receipt, hapax-reform-complete, policy-decide-promote, policy-decide-shadow-replay still hardcode the primary worktree — flagged for their clusters (out of this task's mutation scope). Activation (systemd Active rc=0 across >=2 cycles + scheduled findings.jsonl) lands when this fix deploys via reform-deploy-chain-repair. Verified in-session: --verify ok against the deploy worktree, FAIL against the stale primary worktree; full evaluator run exits 0; 46 tests pass. Task: reform-inv-trace-checker-activate-20260601 AuthorityCase: CASE-SDLC-REFORM-001 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughEscape-grant and SDLC invariant verification paths now resolve signing keys and grant directories at runtime instead of import time, aligning Python auto-mint logic and bash shim tooling. The deployment script adds dynamic repo discovery and a pre-flight ChangesEscape Grant Runtime Resolution and Deployment Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
What
Activate the inert SDLC never-stuck INV-1..5 trace-checker and unify its INV-3/4/5 auto-mint onto the live
escape-grant.shcontract. Two independent defects, both fixed.Defect 1 —
hapax-sdlc-invariants.servicecrash-looped 203/EXEC (the keystone ran ZERO times)ExecStart hardcoded
%h/projects/hapax-council— the primary worktree a lane had parked on a feature branch (alpha/screwm-xvfb-safe-smoke) wherescripts/hapax-sdlc-invariants+shared/sdlc_invariants.pydon't exist. The wrapper then self-redirected back viaREPO=${HAPAX_COUNCIL_REPO:-$HOME/projects/hapax-council}.%h/.cache/hapax/rebuild/worktree(kept fresh on origin/main byreform-deploy-chain-repair) — the pattern thehapax-audio-health-*units already use. SetHAPAX_COUNCIL_REPO+PATH.REPOfrom its own location (never self-redirects), resolvesuvunder a minimal systemd PATH, and grows a--verifymode used asExecStartPre+OnFailure=notify-failure@%nso a misdeploy fails loudly (ntfy) instead of a silent 203/EXEC;ConditionPathExiststurns an absent/not-yet-deployed target into a clean skip.Defect 2 — INV-3/4/5 auto-minted escapes were inert (wrong dir + extension + key)
The auto-mint wrote
<slug>-<id>.jsonto~/.cache/hapax/escape-grantssigned with~/.config/hapax/coord-capability.key— none of which the live shim reads (it globs<coord>/grants/*.grantverified with<coord>/grant-key). The chaos test masked this by mint+verifying in-process with a sharedtmp_pathkey.shared/sdlc_invariants.pynow importsdefault_grant_dir()/default_grant_key()fromshared.coord_event_log(the SSOTcoord-grant-mintand the shim use), resolved at call time, and writes<grant_id>.grant. No module-level path snapshot — the snapshot was the bug.Tests
tests/test_sdlc_invariants_escape_grant_integration.py: drives BOTH the Python minter and the realescape-grant.shthrough the canonical resolvers (HAPAX_COORD_DIR-redirected) and asserts the shim's glob + HMAC-verify accepts the auto-minted grant — fails if dir/extension/key diverge. Includes a control (empty dir → shim denies, proving it can fail).<slug>-<id>.jsonassertions updated to the<grant_id>.grantcontract.Audit (AC#5)
hapax-sdlc-invariants.serviceis now clean. Still hardcoding the primary worktree (other clusters, out of this task's mutation scope — flagged for them):hapax-opus-route-authority-receipt,hapax-reform-complete,policy-decide-promote,policy-decide-shadow-replay.Activation note
Systemd
Active rc=0 across ≥2 cycles+ scheduledfindings.jsonlland when this merges and deploys viareform-deploy-chain-repair(the deploy chain is currently severed — that sibling task is the keystone). Verified in-session:--verifyok against the deploy worktree, FAIL against the stale primary worktree; full evaluator run exits 0.Task:
reform-inv-trace-checker-activate-20260601· AuthorityCase:CASE-SDLC-REFORM-001🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements
.grantextension.