test_cost_awareness_stress.py python
80 lines 2.7 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 13 hours ago
1 """Stress tests for Track P / P-cost (§PC.9)."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 from cli.kit_root import kit_root
8 from tests.fixtures.cost_awareness import seed_cost_e2e_repo
9 from tests.fixtures.model_routing import write_routing_policy
10 from tools.cost_awareness.surface import build_cost_awareness_report
11 from adapters.config import load_config
12
13
14 def _large_roadmap(phase_count: int) -> str:
15 lines = [
16 "# Roadmap stress",
17 "",
18 "| Phase | Model | Status | Deliverable |",
19 "| --- | --- | --- | --- |",
20 ]
21 for index in range(phase_count):
22 lines.append(
23 f"| **Phase {index:03d}** | Auto | **TODO** | slice {index} |"
24 )
25 return "\n".join(lines) + "\n"
26
27
28 def test_many_active_slices_resolve_within_bound(tmp_path: Path) -> None:
29 seed_cost_e2e_repo(tmp_path)
30 config = load_config(tmp_path / ".overseer" / "config.yaml")
31 handover = (tmp_path / "docs" / "OVERSEER-HANDOVER.md").read_text(encoding="utf-8")
32 roadmap = _large_roadmap(40)
33 report = build_cost_awareness_report(
34 config,
35 tmp_path,
36 kit_root=kit_root(),
37 handover_text=handover,
38 roadmap_text=roadmap,
39 )
40 assert report.enabled is True
41 assert len(report.slices) >= 1
42
43
44 def test_active_slice_surface_order_stable(tmp_path: Path) -> None:
45 seed_cost_e2e_repo(tmp_path)
46 config_path = tmp_path / ".overseer" / "config.yaml"
47 config = load_config(config_path)
48 handover = (tmp_path / "docs" / "OVERSEER-HANDOVER.md").read_text(encoding="utf-8")
49 roadmap = (tmp_path / "docs" / "ROADMAP.md").read_text(encoding="utf-8")
50 first = build_cost_awareness_report(
51 config, tmp_path, kit_root=kit_root(), handover_text=handover, roadmap_text=roadmap
52 )
53 second = build_cost_awareness_report(
54 config, tmp_path, kit_root=kit_root(), handover_text=handover, roadmap_text=roadmap
55 )
56 assert first.slices == second.slices
57
58
59 def test_large_routing_policy_annotate(tmp_path: Path) -> None:
60 seed_cost_e2e_repo(tmp_path)
61 routes = [
62 "version: 1",
63 "defaults:",
64 " model_tier: standard",
65 " fallback: [standard, human]",
66 "routes:",
67 ]
68 for index in range(50):
69 routes.extend(
70 [
71 f" - id: route-{index}",
72 f" when: {{ phase_tier: auto, gate: gate-{index} }}",
73 " model_tier: fast",
74 " fallback: [fast, human]",
75 ]
76 )
77 write_routing_policy(tmp_path, "\n".join(routes) + "\n")
78 config = load_config(tmp_path / ".overseer" / "config.yaml")
79 report = build_cost_awareness_report(config, tmp_path, kit_root=kit_root())
80 assert report.enabled is True
File History 1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 13 hours ago