test_frv_e2e.py python
110 lines 4.1 KB
Raw
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 4 days ago
1 """E2E tests for FRV authorization loop (§FRV.12)."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 import yaml
8
9 from adapters.config import load_config
10 from tests.support import seed_honesty_repo, write_config
11 from tools.freeze_reviewer.artifact import artifact_digest, parse_artifact
12 from tools.governance_hygiene.next_regen import decide_split_emission
13 from tools.governance_hygiene.types import QueueRow
14 from tools.honesty.ledger import append_entry
15 from tools.honesty.types import LedgerAppendOptions
16
17
18 def _seed(repo: Path) -> None:
19 seed_honesty_repo(repo)
20 cfg = repo / ".overseer" / "config.yaml"
21 data = yaml.safe_load(cfg.read_text(encoding="utf-8"))
22 data["freeze_contract"] = {
23 "enabled": True,
24 "reviewer": {"mode": "agent", "model": "thinking-high", "provider": "local", "fallback": "human"},
25 "human_escalation": ["security"],
26 }
27 cfg.write_text(yaml.safe_dump(data), encoding="utf-8")
28 docs = repo / "docs"
29 docs.mkdir(parents=True, exist_ok=True)
30
31
32 def test_two_row_convention_requires_ledger(tmp_path: Path) -> None:
33 _seed(tmp_path)
34 art = tmp_path / "docs" / "PHASE-FRV.md"
35 body = (
36 "# Freeze\n\n```yaml\nphase: FRV\noutputs:\n - id: a\n path: docs/a.md\n frozen: true\n"
37 "review_stamp:\n gate: mechanical\n mechanical_verdict: pass\n"
38 " produced_by: checklist_engine\n provider_kind: rule_engine\n"
39 " reviewer_mode: agent\n reviewer_model: null\n reviewer_provider: local\n"
40 " checklist_ids: [C1]\n checklist_source: builtin\n findings_count: 0\n"
41 " override_applied: false\n kit_version: 0.1.0\n"
42 " artifact_digest: sha256:deadbeef\n```\n\nseven-tier matrix\nfile+line\n"
43 )
44 # Write without bogus digest — compute after parse
45 art.write_text(
46 "# Freeze\n\n```yaml\nphase: FRV\noutputs:\n - id: a\n path: docs/a.md\n frozen: true\n```\n\n"
47 "Ground truth frozen: true. seven-tier matrix. file+line citation.\n",
48 encoding="utf-8",
49 )
50 parsed = parse_artifact(art, rel_path="docs/PHASE-FRV.md")
51 digest = artifact_digest(parsed)
52 config = load_config(tmp_path / ".overseer" / "config.yaml")
53
54 auto_row = QueueRow(
55 phase_label="**FRV-b**",
56 model="Auto",
57 status="**NEXT**",
58 deliverable="docs/PHASE-FRV.md",
59 raw_line="",
60 )
61 emit, reason, _, _ = decide_split_emission(auto_row, tmp_path, config=config)
62 assert reason == "freeze_not_substantive"
63
64 append_entry(
65 config=config,
66 repo_root=tmp_path,
67 options=LedgerAppendOptions(
68 kind="freeze_review",
69 body={
70 "actor_role": "verifier",
71 "actor_session_id": "review-1",
72 "phase_id": "FRV-b",
73 "frozen_spec": "docs/PHASE-FRV.md",
74 "round": 1,
75 "gate": "substantive",
76 "freeze_verdict": "pass",
77 "artifact_digest": digest,
78 "reviewer_model": "thinking-high",
79 },
80 ),
81 )
82 emit, reason, _, _ = decide_split_emission(auto_row, tmp_path, config=config)
83 assert emit == "Auto"
84 assert reason is None
85
86 # One-byte edit invalidates digest binding
87 art.write_text(art.read_text(encoding="utf-8") + "x", encoding="utf-8")
88 emit, reason, _, _ = decide_split_emission(auto_row, tmp_path, config=config)
89 assert reason == "freeze_not_substantive"
90
91
92 def test_prose_bold_pass_never_authorizes(tmp_path: Path) -> None:
93 write_config(tmp_path, "config-git-only.yaml")
94 docs = tmp_path / "docs"
95 docs.mkdir(parents=True, exist_ok=True)
96 (docs / "PHASE-PROSE.md").write_text(
97 "# Review\n\n| Round | Verdict |\n| --- | --- |\n| 1 | **pass** |\n\nreviewed → pass\n",
98 encoding="utf-8",
99 )
100 config = load_config(tmp_path / ".overseer" / "config.yaml")
101 row = QueueRow(
102 phase_label="**PROSE**",
103 model="Thinking → Auto",
104 status="**NEXT**",
105 deliverable="docs/PHASE-PROSE.md",
106 raw_line="",
107 )
108 emit, reason, is_b, advisory = decide_split_emission(row, tmp_path, config=config)
109 assert emit == "Thinking"
110 assert is_b is False
File History 1 commit
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 4 days ago