test_gsw_write_bounded.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
12 hours ago
| 1 | """Performance: reordered §GSW apply path stays within governance-sync bounds. |
| 2 | |
| 3 | Kit-sized docs through the full ``--write`` path — the reorder must not add |
| 4 | unbounded VCS log scans (§GSW.10 performance tier). |
| 5 | """ |
| 6 | |
| 7 | from __future__ import annotations |
| 8 | |
| 9 | import time |
| 10 | from pathlib import Path |
| 11 | |
| 12 | from cli.kit_root import kit_root |
| 13 | from tests.support import gsw_runner, run_cli, seed_gsw_repo |
| 14 | |
| 15 | |
| 16 | def test_write_path_bounded_on_kit_sized_docs(tmp_path: Path) -> None: |
| 17 | kit_docs = Path(__file__).resolve().parents[2] / "docs" |
| 18 | seed_gsw_repo( |
| 19 | tmp_path, |
| 20 | "git-only", |
| 21 | handover_text=(kit_docs / "OVERSEER-HANDOVER.md").read_text(encoding="utf-8"), |
| 22 | roadmap_text=(kit_docs / "ROADMAP.md").read_text(encoding="utf-8"), |
| 23 | ) |
| 24 | runner = gsw_runner(tmp_path, "git-only") |
| 25 | |
| 26 | start = time.perf_counter() |
| 27 | code = run_cli(["governance-sync", "--write"], cwd=tmp_path, runner=runner, kit=kit_root()) |
| 28 | elapsed = time.perf_counter() - start |
| 29 | |
| 30 | assert code in {0, 2} |
| 31 | assert elapsed < 2.0 |
| 32 | # No unbounded history scans introduced by the reorder. |
| 33 | assert not any(c.startswith("git log") for c, _ in runner.calls) |
| 34 | assert not any( |
| 35 | c.startswith("git rev-list") and "--count" not in c for c, _ in runner.calls |
| 36 | ) |
| 37 | # Bounded command count: capture + reads + ensure + commit + push, no loops. |
| 38 | assert len(runner.calls) < 40 |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
12 hours ago