test_frv_stress.py python
61 lines 2.2 KB
Raw
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 4 days ago
1 """Stress tests for FRV (§FRV.12)."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 from tools.honesty.validate import find_matching_freeze_review
8 from tools.governance_hygiene.next_regen import discover_freeze_candidates
9 from tools.freeze_reviewer.artifact import parse_artifact
10
11
12 DIGEST = "sha256:" + ("d" * 64)
13
14
15 def test_match_last_wins_large_ledger() -> None:
16 entries: list[dict] = []
17 for i in range(60):
18 entries.append({"kind": "verdict", "actor_role": "verifier", "entry_hash": f"v{i}"})
19 for i in range(50):
20 entries.append(
21 {
22 "kind": "freeze_review",
23 "actor_role": "verifier",
24 "gate": "substantive",
25 "freeze_verdict": "pass" if i == 49 else "findings",
26 "phase_id": "FRV-b",
27 "frozen_spec": "docs/x.md",
28 "artifact_digest": DIGEST,
29 "entry_hash": f"f{i}",
30 }
31 )
32 # Only last freeze_review with pass
33 entries[-1]["freeze_verdict"] = "pass"
34 match = find_matching_freeze_review(
35 entries, phase_id="FRV-b", frozen_spec="docs/x.md", artifact_digest=DIGEST
36 )
37 assert match is not None
38 assert match["entry_hash"] == "f49"
39
40
41 def test_many_fences_parse(tmp_path: Path) -> None:
42 fences = "\n\n".join(f"```text\nblock {i}\n```" for i in range(200))
43 body = "x" * (1024 * 1024)
44 path = tmp_path / "big.md"
45 path.write_text(
46 f"# Big\n\n```yaml\nphase: FRV\noutputs:\n - id: a\n path: docs/a.md\n frozen: true\n```\n\n{fences}\n\n{body}\n",
47 encoding="utf-8",
48 )
49 parsed = parse_artifact(path, rel_path="big.md")
50 assert parsed.declaration == "present"
51
52
53 def test_discover_cap_top_level_only(tmp_path: Path) -> None:
54 docs = tmp_path / "docs"
55 nested = docs / "archive" / "phases"
56 nested.mkdir(parents=True)
57 (docs / "PHASE-FRV.md").write_text("# top\n", encoding="utf-8")
58 (nested / "PHASE-FRV-nested.md").write_text("# nested\n", encoding="utf-8")
59 found = discover_freeze_candidates(tmp_path, "FRV", "docs/archive/phases/PHASE-FRV-nested.md")
60 # top-level via glob + deliverable cite
61 assert any(p.name == "PHASE-FRV.md" for p in found) or any("nested" in p.name for p in found)
File History 1 commit
sha256:8461d44b77376fbf06fa7c3e085d309e3010fd8d5886d63c63e69ce118811ad4 docs: record AFF-b feature-tip SHAs after AFF-b-ISR commit. Human 4 days ago