test_muse_sync_stress.py python
51 lines 1.5 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
1 """Stress test: muse-sync gate stays O(1) regardless of how many files Muse reports (§KH2.8 stress tier)."""
2
3 from __future__ import annotations
4
5 import json
6 import time
7 from pathlib import Path
8
9 from tests.support import FIXTURES, make_runner, ok, run_cli, seed_muse_substrate
10
11
12 def test_muse_sync_gate_bounded_with_large_muse_status_payload(tmp_path: Path) -> None:
13 root = str(tmp_path.resolve())
14 # Muse's own status --json is free to report thousands of changed files; the gate
15 # only ever inspects the boolean `dirty` field, never the file list itself.
16 huge_payload = json.dumps(
17 {
18 "dirty": True,
19 "total_changes": 5000,
20 "changes": [f"src/module_{i}.py" for i in range(5000)],
21 }
22 )
23 runner = make_runner(
24 {
25 f"muse -C {root} rev-parse --abbrev-ref HEAD": ok("main"),
26 f"muse -C {root} status --json": ok(huge_payload),
27 "git rev-parse --abbrev-ref HEAD": ok("main"),
28 "git status --porcelain": ok(""),
29 }
30 )
31 assert (
32 run_cli(
33 [
34 "init",
35 "--from-config",
36 str(FIXTURES / "config-muse-git-mirror.yaml"),
37 "--non-interactive",
38 ],
39 cwd=tmp_path,
40 runner=runner,
41 )
42 == 0
43 )
44 seed_muse_substrate(tmp_path)
45
46 start = time.perf_counter()
47 code = run_cli(["status", "--exit-code"], cwd=tmp_path, runner=runner)
48 elapsed = time.perf_counter() - start
49
50 assert code == 2
51 assert elapsed < 5.0
File History 1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago