test_footprint_integrity_gate_cycle.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
1 day ago
| 1 | """E2E: the footprint self-integrity gate blocks then clears across review + governance-sync |
| 2 | (§KH3.8 e2e tier).""" |
| 3 | |
| 4 | from __future__ import annotations |
| 5 | |
| 6 | import json |
| 7 | from pathlib import Path |
| 8 | |
| 9 | from cli.kit_root import kit_root |
| 10 | from tests.support import ( |
| 11 | FIXTURES, |
| 12 | make_runner, |
| 13 | ok, |
| 14 | pass_provider_factory, |
| 15 | run_cli, |
| 16 | ) |
| 17 | |
| 18 | |
| 19 | def _git_only_runner() -> object: |
| 20 | return make_runner( |
| 21 | { |
| 22 | "git rev-parse --abbrev-ref HEAD": ok("main"), |
| 23 | "git status --porcelain": ok(""), |
| 24 | } |
| 25 | ) |
| 26 | |
| 27 | |
| 28 | def _init(tmp_path: Path, runner, config_name: str = "config-git-only.yaml") -> None: |
| 29 | assert ( |
| 30 | run_cli( |
| 31 | ["init", "--from-config", str(FIXTURES / config_name), "--non-interactive"], |
| 32 | cwd=tmp_path, |
| 33 | runner=runner, |
| 34 | ) |
| 35 | == 0 |
| 36 | ) |
| 37 | |
| 38 | |
| 39 | def test_review_freeze_refuses_then_proceeds_across_a_simulated_sync(tmp_path: Path) -> None: |
| 40 | runner = _git_only_runner() |
| 41 | _init(tmp_path, runner) |
| 42 | docs = tmp_path / "docs" |
| 43 | docs.mkdir(exist_ok=True) |
| 44 | artifact = docs / "FREEZE.md" |
| 45 | artifact.write_text( |
| 46 | (FIXTURES / "freeze-artifact.md").read_text(encoding="utf-8"), encoding="utf-8" |
| 47 | ) |
| 48 | |
| 49 | # Simulate this session's own incident: a declared kit-owned file vanishes from disk. |
| 50 | victim = tmp_path / ".cursor" / "rules" / "governance-sync.mdc" |
| 51 | saved = victim.read_text(encoding="utf-8") |
| 52 | victim.unlink() |
| 53 | |
| 54 | code = run_cli( |
| 55 | ["review", "--freeze", str(artifact.relative_to(tmp_path))], |
| 56 | cwd=tmp_path, |
| 57 | runner=runner, |
| 58 | kit=kit_root(), |
| 59 | review_provider_factory=pass_provider_factory(), |
| 60 | ) |
| 61 | assert code == 2 |
| 62 | |
| 63 | # `overseer sync` (simulated by restoring the file) — the documented remediation. |
| 64 | victim.write_text(saved, encoding="utf-8") |
| 65 | code = run_cli( |
| 66 | ["review", "--freeze", str(artifact.relative_to(tmp_path))], |
| 67 | cwd=tmp_path, |
| 68 | runner=runner, |
| 69 | kit=kit_root(), |
| 70 | review_provider_factory=pass_provider_factory(), |
| 71 | ) |
| 72 | assert code == 0 |
| 73 | |
| 74 | |
| 75 | def test_governance_sync_refuses_then_proceeds_across_a_simulated_sync(tmp_path: Path) -> None: |
| 76 | runner = _git_only_runner() |
| 77 | runner.responses.update( |
| 78 | { |
| 79 | "git rev-parse origin/main": ok("a" * 40), |
| 80 | "gh pr list --state merged --limit 5 --json number,title,mergeCommit,mergedAt": ok( |
| 81 | json.dumps([]) |
| 82 | ), |
| 83 | } |
| 84 | ) |
| 85 | _init(tmp_path, runner) |
| 86 | |
| 87 | victim = tmp_path / ".overseer" / "policy" / "tiers.yaml" |
| 88 | saved = victim.read_text(encoding="utf-8") |
| 89 | victim.unlink() |
| 90 | |
| 91 | code = run_cli(["governance-sync", "--dry-run"], cwd=tmp_path, runner=runner) |
| 92 | assert code == 2 |
| 93 | |
| 94 | victim.write_text(saved, encoding="utf-8") |
| 95 | code = run_cli(["governance-sync", "--dry-run"], cwd=tmp_path, runner=runner) |
| 96 | assert code == 0 |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
1 day ago