test_model_routing_e2e.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
8 hours ago
| 1 | """End-to-end tests for Track P / P-route (§PR.8).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import json |
| 6 | from pathlib import Path |
| 7 | |
| 8 | from cli.footprint import resolve_footprint |
| 9 | from cli.kit_root import kit_root |
| 10 | from tests.fixtures.model_routing import seed_routing_repo |
| 11 | from tests.support import FIXTURES, git_status_runner, load_fixture_config, run_cli |
| 12 | |
| 13 | |
| 14 | def _seed_lock(tmp_path: Path) -> None: |
| 15 | (tmp_path / ".overseer" / "version.lock").write_text( |
| 16 | "lock_version: 1\nkit_version: 0.1.0\nconfig_version: 1\n" |
| 17 | "footprint_digest: sha256:0\ninstalled_at: '2026-01-01'\n" |
| 18 | "synced_at: '2026-01-01'\nfootprint: []\n", |
| 19 | encoding="utf-8", |
| 20 | ) |
| 21 | |
| 22 | |
| 23 | def test_e2e_resolve_cycle(tmp_path: Path, capsys) -> None: |
| 24 | seed_routing_repo(tmp_path) |
| 25 | cases = [ |
| 26 | (["--position", "overseer"], "overseer-ruling", "deep-reasoning"), |
| 27 | (["--phase-tier", "auto"], "auto-build", "standard"), |
| 28 | (["--position", "nobody"], "defaults", "standard"), |
| 29 | ] |
| 30 | for argv, route_id, tier in cases: |
| 31 | code = run_cli( |
| 32 | ["route", *argv, "--json"], |
| 33 | cwd=tmp_path, |
| 34 | runner=git_status_runner(), |
| 35 | kit=kit_root(), |
| 36 | json_mode=True, |
| 37 | ) |
| 38 | assert code == 0 |
| 39 | payload = json.loads(capsys.readouterr().out) |
| 40 | assert payload["route_id"] == route_id |
| 41 | assert payload["model_tier"] == tier |
| 42 | |
| 43 | |
| 44 | def test_e2e_identical_under_git_only_and_muse_regime(tmp_path: Path, capsys) -> None: |
| 45 | for config_name in ("config-git-only.yaml", "config-muse-only.yaml"): |
| 46 | repo = tmp_path / config_name |
| 47 | repo.mkdir() |
| 48 | seed_routing_repo(repo, config_name=config_name) |
| 49 | code = run_cli( |
| 50 | ["route", "--gate", "build_verification", "--json"], |
| 51 | cwd=repo, |
| 52 | runner=git_status_runner(), |
| 53 | kit=kit_root(), |
| 54 | json_mode=True, |
| 55 | ) |
| 56 | assert code == 0 |
| 57 | payload = json.loads(capsys.readouterr().out) |
| 58 | assert payload["route_id"] == "build-verification" |
| 59 | |
| 60 | |
| 61 | def test_e2e_status_routing_validity_only_when_enabled(tmp_path: Path, capsys) -> None: |
| 62 | seed_routing_repo(tmp_path, enabled=False) |
| 63 | _seed_lock(tmp_path) |
| 64 | run_cli( |
| 65 | ["status", "--json"], |
| 66 | cwd=tmp_path, |
| 67 | runner=git_status_runner(), |
| 68 | kit=kit_root(), |
| 69 | json_mode=True, |
| 70 | ) |
| 71 | disabled = json.loads(capsys.readouterr().out) |
| 72 | assert disabled["model_routing"]["enabled"] is False |
| 73 | |
| 74 | cfg = tmp_path / ".overseer" / "config.yaml" |
| 75 | import yaml |
| 76 | |
| 77 | data = yaml.safe_load(cfg.read_text(encoding="utf-8")) |
| 78 | data["model_routing"] = {"enabled": True, "policy": "policy/model-routing.yaml"} |
| 79 | cfg.write_text(yaml.safe_dump(data, sort_keys=False), encoding="utf-8") |
| 80 | run_cli( |
| 81 | ["status", "--json"], |
| 82 | cwd=tmp_path, |
| 83 | runner=git_status_runner(), |
| 84 | kit=kit_root(), |
| 85 | json_mode=True, |
| 86 | ) |
| 87 | enabled = json.loads(capsys.readouterr().out) |
| 88 | assert enabled["model_routing"]["enabled"] is True |
| 89 | assert "valid" in enabled["model_routing"] |
| 90 | |
| 91 | |
| 92 | def test_footprint_includes_model_routing_policy(git_only_config) -> None: |
| 93 | dests = {f.destination for f in resolve_footprint(git_only_config)} |
| 94 | assert ".overseer/policy/model-routing.yaml" in dests |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
7 hours ago