test_muse_sync_performance.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
2 days ago
| 1 | """Performance tests: the muse-sync gate adds no extra command invocations (§KH2.8 performance tier).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | from unittest.mock import patch |
| 7 | |
| 8 | from tests.support import FIXTURES, make_runner, ok, run_cli, seed_muse_substrate |
| 9 | from tools.governance_freshness import GovernanceFreshnessReport |
| 10 | |
| 11 | |
| 12 | _OK_FRESHNESS = GovernanceFreshnessReport( |
| 13 | state="ok", message="patched for muse-sync perf", remediation=None |
| 14 | ) |
| 15 | |
| 16 | |
| 17 | def _runner(root: str) -> object: |
| 18 | return make_runner( |
| 19 | { |
| 20 | f"muse -C {root} rev-parse --abbrev-ref HEAD": ok("main"), |
| 21 | f"muse -C {root} status --json": ok('{"dirty": false}'), |
| 22 | "git rev-parse --abbrev-ref HEAD": ok("main"), |
| 23 | "git status --porcelain": ok(""), |
| 24 | } |
| 25 | ) |
| 26 | |
| 27 | |
| 28 | def test_status_call_count_unchanged_by_muse_sync_gate(tmp_path: Path) -> None: |
| 29 | """§KH2.5: the gate reuses the StatusResult status() already fetched — zero new commands.""" |
| 30 | root = str(tmp_path.resolve()) |
| 31 | runner = _runner(root) |
| 32 | assert ( |
| 33 | run_cli( |
| 34 | ["init", "--from-config", str(FIXTURES / "config-muse-git-mirror.yaml"), "--non-interactive"], |
| 35 | cwd=tmp_path, |
| 36 | runner=runner, |
| 37 | ) |
| 38 | == 0 |
| 39 | ) |
| 40 | seed_muse_substrate(tmp_path) |
| 41 | |
| 42 | runner.calls.clear() |
| 43 | with patch("cli.commands.status.check_governance_freshness", return_value=_OK_FRESHNESS): |
| 44 | run_cli(["status", "--exit-code"], cwd=tmp_path, runner=runner) |
| 45 | |
| 46 | # Exactly the four calls adapter.status() already made pre-KH2: two muse, two git. |
| 47 | # (muse status --json succeeds so the --porcelain fallback is never invoked.) |
| 48 | # GFG freshness is patched out so this test isolates the muse-sync gate only. |
| 49 | assert len(runner.calls) == 4 |
| 50 | commands = [c[0] for c in runner.calls] |
| 51 | assert sum(1 for c in commands if "status --json" in c) == 1 |
| 52 | assert sum(1 for c in commands if "status --porcelain" in c and "muse" in c) == 0 |
| 53 | assert sum(1 for c in commands if c == "git status --porcelain") == 1 |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
2 days ago