test_model_routing_performance.py file-level

at sha256:a · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:8 docs: queue board-identity follow-ups so they survive the session Capt… · aaronrene · Sep 5, 2026
1 """Performance tests for Track P / P-route (§PR.8)."""
2
3 from __future__ import annotations
4
5 import time
6 from unittest.mock import patch
7
8 from cli.kit_root import kit_root
9 from tests.fixtures.model_routing import seed_routing_repo
10 from tests.support import git_status_runner, run_cli
11 from tools.model_routing.policy import validate_routing_policy
12
13 BOUND_MS = 500
14
15
16 def test_route_resolve_bounded(tmp_path) -> None:
17 seed_routing_repo(tmp_path)
18 start = time.perf_counter()
19 code = run_cli(
20 ["route", "--position", "worker", "--gate", "default"],
21 cwd=tmp_path,
22 runner=git_status_runner(),
23 kit=kit_root(),
24 )
25 elapsed_ms = (time.perf_counter() - start) * 1000
26 assert code == 0
27 assert elapsed_ms < BOUND_MS
28
29
30 def test_route_validate_bounded(tmp_path) -> None:
31 policy_path = seed_routing_repo(tmp_path)
32 start = time.perf_counter()
33 result = validate_routing_policy(policy_path, kit_root=kit_root())
34 elapsed_ms = (time.perf_counter() - start) * 1000
35 assert result.valid is True
36 assert elapsed_ms < BOUND_MS
37
38
39 def test_route_does_not_scan_vcs(tmp_path) -> None:
40 seed_routing_repo(tmp_path)
41 with patch("cli.vcs_status.read_vcs_status") as mocked:
42 mocked.side_effect = AssertionError("route must not scan VCS")
43 code = run_cli(
44 ["route", "--validate"],
45 cwd=tmp_path,
46 runner=git_status_runner(),
47 kit=kit_root(),
48 )
49 assert code == 0