test: harden governance adapter release coverage#27
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR adds test-only coverage: new veto-hook boundary tests in the governance install test suite covering identity mismatch, strict mode, freshness windows, and malformed input handling, plus a new end-to-end packaging test verifying the installed CLI scaffolds governance adapter files correctly. ChangesGovernance Test Additions
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_packaging.py (1)
187-193: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd timeouts to subprocess calls to avoid indefinite CI hangs.
Neither the
git initnor thegovernance installinvocation has atimeout=. If the installed CLI unexpectedly blocks (e.g., an unhandled prompt), this test can hang the whole CI job rather than fail with a clear timeout error.♻️ Proposed fix
- subprocess.run(["git", "init", "-q"], cwd=repo, check=True, capture_output=True) + subprocess.run(["git", "init", "-q"], cwd=repo, check=True, capture_output=True, timeout=30) r = subprocess.run( [str(installed_dorian), "--repo", str(repo), "governance", "install"], capture_output=True, text=True, + timeout=60, )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_packaging.py` around lines 187 - 193, Add explicit timeouts to the subprocess calls in this test so CI cannot hang indefinitely. Update both the git init invocation and the installed CLI call in the test_packaging flow to use a timeout, and keep the existing assertions on the return code and stderr so failures still surface clearly. Locate the affected calls around the governance install test case using the subprocess.run usages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_packaging.py`:
- Around line 187-193: Add explicit timeouts to the subprocess calls in this
test so CI cannot hang indefinitely. Update both the git init invocation and the
installed CLI call in the test_packaging flow to use a timeout, and keep the
existing assertions on the return code and stderr so failures still surface
clearly. Locate the affected calls around the governance install test case using
the subprocess.run usages.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7bb14226-d2d3-4c81-b0d3-f6af7e66af5b
📒 Files selected for processing (2)
tests/test_governance_install.pytests/test_packaging.py
Summary
Release-hardening test coverage for the v1.4 governance adapter, ahead of cutting v1.4.0.
Tests only — no source, no version bump, no behavior change. Pins the fail-closed PreToolUse
veto contract at its boundaries and proves the shipped wheel scaffolds
dorian governance installfor a real
pip install dorian-vwpuser.What changed
tests/test_governance_install.py— 7 new functional PreToolUse veto subprocess tests (reusethe existing
_run_veto/_fresh_packethelpers; execute the hook as a real subprocess):base_ref ≠ DORIAN_BASE) blocks under strict → exit 2;DORIAN_EFFORT=godmodeforces strict and blocks a standing escalate → exit 2;file_pathblocks even when attended → exit 2;tests/test_packaging.py—test_installed_scaffolds_governance_adapter(slow): builds thewheel, installs it into a fresh venv, runs the packaged
dorian governance install, and assertsboth hooks + settings + docs exist, the installed veto carries
return 2/ "FAIL CLOSED", and theSubagentStop hook emits
hookSpecificOutput.Why
v1.4's headline surface is a fail-closed enforcement veto; functional veto tests of exactly this
class already caught a real false-block-everything bug during v1.4 development, and the wheel path was
the one governance install scenario not yet covered end-to-end. This closes both before the GA tag.
Invariants
Purely additive (+89/−0). No
src/change; version stays1.3.0; no Lawbook, provenance, effortmodes, provider abstraction, pane/TUI, or design work; exit-code contract / warrant schema / checker
grammar / fold policy unchanged. CI (
uv sync --all-extrason 3.11/3.12/3.13) is authoritative.🤖 Generated with Claude Code
Summary by CodeRabbit