test_findings_verdict.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
2 days ago
| 1 | """Unit tests for findings, verdicts, citations (§K5.6).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from tools.freeze_reviewer.findings import ( |
| 6 | assign_finding_ids, |
| 7 | derive_verdict, |
| 8 | validate_and_repair_findings, |
| 9 | verdict_exit_code, |
| 10 | ) |
| 11 | from tools.freeze_reviewer.types import Finding |
| 12 | |
| 13 | |
| 14 | def test_zero_findings_pass() -> None: |
| 15 | assert derive_verdict([], human_escalation=["security"]) == "pass" |
| 16 | assert verdict_exit_code("pass") == 0 |
| 17 | |
| 18 | |
| 19 | def test_major_only_findings() -> None: |
| 20 | findings = [ |
| 21 | Finding(check="C1", severity="MAJOR", category="completeness", path="docs/a.md", line=2, message="x").with_citation() |
| 22 | ] |
| 23 | assert derive_verdict(findings, human_escalation=["security"]) == "findings" |
| 24 | assert verdict_exit_code("findings") == 7 |
| 25 | |
| 26 | |
| 27 | def test_blocker_blocked() -> None: |
| 28 | findings = [ |
| 29 | Finding(check="C2", severity="BLOCKER", category="completeness", path="docs/a.md", line=1, message="x").with_citation() |
| 30 | ] |
| 31 | assert derive_verdict(findings, human_escalation=[]) == "blocked" |
| 32 | assert verdict_exit_code("blocked") == 8 |
| 33 | |
| 34 | |
| 35 | def test_escalation_category_blocked_even_if_major() -> None: |
| 36 | findings = [ |
| 37 | Finding(check="C4", severity="MAJOR", category="security", path="docs/a.md", line=3, message="x").with_citation() |
| 38 | ] |
| 39 | assert derive_verdict(findings, human_escalation=["security"]) == "blocked" |
| 40 | |
| 41 | |
| 42 | def test_uncited_finding_becomes_synthetic_blocked() -> None: |
| 43 | raw = [Finding(check="C1", severity="MAJOR", category="other", path="", line=0, message="bad")] |
| 44 | repaired = validate_and_repair_findings(raw, artifact_path="docs/a.md") |
| 45 | assert repaired[0].severity == "BLOCKER" |
| 46 | assert repaired[0].citation == "docs/a.md:1" |
| 47 | |
| 48 | |
| 49 | def test_stable_sort_and_ids() -> None: |
| 50 | findings = [ |
| 51 | Finding(check="C2", severity="MINOR", category="other", path="docs/b.md", line=1, message="b").with_citation(), |
| 52 | Finding(check="C1", severity="MAJOR", category="other", path="docs/a.md", line=5, message="a").with_citation(), |
| 53 | ] |
| 54 | assigned = assign_finding_ids(findings) |
| 55 | assert [item.id for item in assigned] == ["F1", "F2"] |
| 56 | assert assigned[0].path == "docs/a.md" |
File History
2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
2 days ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439
feat: K1-P1 complete — agent provenance, build-verification…
Sonnet 4.6
patch
54 days ago