test_governance_freshness_stress.py python
66 lines 2.3 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 12 hours ago
1 """Stress: large roadmap — freshness skips R4 (§GFG.9 stress)."""
2
3 from __future__ import annotations
4
5 import time
6 from pathlib import Path
7 from unittest.mock import MagicMock
8
9 from adapters.types import AnchorResult, HeadResult, StatusResult
10 from tests.support import load_fixture_config, write_config
11 from tools.governance_freshness import check_governance_freshness
12
13
14 def test_large_roadmap_freshness_bounded(tmp_path: Path) -> None:
15 write_config(tmp_path, "config-git-only.yaml")
16 (tmp_path / ".overseer" / "version.lock").write_text(
17 _minimal_lock(),
18 encoding="utf-8",
19 )
20 docs = tmp_path / "docs"
21 docs.mkdir(parents=True, exist_ok=True)
22 (docs / "OVERSEER-HANDOVER.md").write_text(
23 "| GitHub `main` | `cafebabe` |\n", encoding="utf-8"
24 )
25 rows = [
26 "| Phase | Model | Status | Deliverable |",
27 "| --- | --- | --- | --- |",
28 ]
29 for i in range(220):
30 rows.append(f"| **P{i}** | Auto | DONE | deliverable {i} |")
31 (docs / "ROADMAP.md").write_text("## Build queue\n\n" + "\n".join(rows) + "\n", encoding="utf-8")
32 (tmp_path / ".overseer" / "last_governance_sync").write_text(
33 "2026-07-28T00:00:00Z\nr1=cafebabe\nr3=cafebabe\n", encoding="utf-8"
34 )
35
36 adapter = MagicMock()
37 adapter.status.return_value = StatusResult(
38 regime="git-only", dirty=False, branch="main", muse_dirty=None, git_dirty=False
39 )
40 adapter.read_head.return_value = HeadResult(sha="cafebabe", kind="git")
41 adapter.read_canonical_anchor.return_value = AnchorResult(
42 anchor_sha="cafebabe", source="origin/main"
43 )
44 runner = MagicMock()
45 config = load_fixture_config(tmp_path, "config-git-only.yaml")
46
47 start = time.perf_counter()
48 report = check_governance_freshness(config, tmp_path, adapter=adapter, runner=runner)
49 elapsed = time.perf_counter() - start
50
51 assert report.ok
52 assert report.state == "ok"
53 assert elapsed < 2.0
54 # Never called gh
55 for call in runner.run.call_args_list:
56 cmd = call.args[0] if call.args else ""
57 assert "gh " not in cmd
58
59
60 def _minimal_lock() -> str:
61 return (
62 "lock_version: 1\nkit_version: 0.1.0\nconfig_version: 1\n"
63 "footprint_digest: sha256:" + ("0" * 64) + "\n"
64 "installed_at: \"2026-01-01T00:00:00Z\"\nsynced_at: \"2026-01-01T00:00:00Z\"\n"
65 "footprint: []\n"
66 )
File History 1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 12 hours ago