test_governance_gates.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
2 days ago
| 1 | """Unit tests for governance gate reminders (§KH1.9).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from adapters.config import ConfigError, load_config |
| 10 | from tests.support import FIXTURES |
| 11 | from tools.governance_gates import scan_governance_gates |
| 12 | from tools.governance_gates.checklist import governance_gates_checklist_lines |
| 13 | |
| 14 | |
| 15 | def test_config_parses_governance_gates_defaults() -> None: |
| 16 | config = load_config(FIXTURES / "config-git-only.yaml") |
| 17 | assert config.governance_gates.remind is True |
| 18 | assert config.governance_gates.freeze_review_required is True |
| 19 | assert config.governance_gates.build_verification_required is True |
| 20 | |
| 21 | |
| 22 | def test_config_parses_governance_gates_explicit() -> None: |
| 23 | config = load_config(FIXTURES / "config-governance-gates.yaml") |
| 24 | assert config.governance_gates.remind is True |
| 25 | assert "status" in config.governance_gates.surfaces |
| 26 | assert "handover-paste" in config.governance_gates.surfaces |
| 27 | |
| 28 | |
| 29 | def test_config_rejects_unknown_governance_gates_key() -> None: |
| 30 | with pytest.raises(ConfigError): |
| 31 | load_config(FIXTURES / "config-governance-gates-bad.yaml") |
| 32 | |
| 33 | |
| 34 | def test_scan_detects_pending_freeze_review_and_build_verification(tmp_path: Path) -> None: |
| 35 | config = load_config(FIXTURES / "config-governance-gates.yaml") |
| 36 | docs = tmp_path / "docs" |
| 37 | docs.mkdir(parents=True) |
| 38 | (docs / "ROADMAP.md").write_text( |
| 39 | (FIXTURES / "governance-gates-roadmap.md").read_text(encoding="utf-8"), |
| 40 | encoding="utf-8", |
| 41 | ) |
| 42 | (docs / "OVERSEER-HANDOVER.md").write_text( |
| 43 | (FIXTURES / "governance-gates-handover.md").read_text(encoding="utf-8"), |
| 44 | encoding="utf-8", |
| 45 | ) |
| 46 | (docs / "PHASE-DEMO-THINKING.md").write_text( |
| 47 | (FIXTURES / "governance-gates-phase-thinking.md").read_text(encoding="utf-8"), |
| 48 | encoding="utf-8", |
| 49 | ) |
| 50 | |
| 51 | result = scan_governance_gates(config, tmp_path) |
| 52 | gate_ids = {gate.gate_id for gate in result.pending} |
| 53 | assert "freeze_review" in gate_ids |
| 54 | assert "build_verification" in gate_ids |
| 55 | |
| 56 | |
| 57 | def test_scan_suppressed_when_remind_false(tmp_path: Path) -> None: |
| 58 | config = load_config(FIXTURES / "config-governance-gates-suppressed.yaml") |
| 59 | result = scan_governance_gates(config, tmp_path) |
| 60 | assert result.suppressed is True |
| 61 | assert result.pending == () |
| 62 | |
| 63 | |
| 64 | def test_checklist_lines_include_invoke_commands() -> None: |
| 65 | lines = governance_gates_checklist_lines() |
| 66 | joined = "\n".join(lines) |
| 67 | assert "freeze-review-loop" in joined |
| 68 | assert "build-verification-review" in joined |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
2 days ago