__init__.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
1 day ago
| 1 | """Shared fixtures for Track P / P-route tests (§PR.8).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | import yaml |
| 8 | |
| 9 | from cli.kit_root import kit_root |
| 10 | from tests.support import FIXTURES, write_config |
| 11 | |
| 12 | |
| 13 | def copy_default_routing_policy(repo_root: Path, *, dest: str | None = None) -> Path: |
| 14 | """Copy vendored routing policy into a test repo.""" |
| 15 | target_rel = dest or "policy/model-routing.yaml" |
| 16 | source = kit_root() / "policy" / "model-routing.yaml" |
| 17 | target = repo_root / target_rel |
| 18 | target.parent.mkdir(parents=True, exist_ok=True) |
| 19 | target.write_text(source.read_text(encoding="utf-8"), encoding="utf-8") |
| 20 | return target |
| 21 | |
| 22 | |
| 23 | def seed_routing_repo( |
| 24 | repo_root: Path, |
| 25 | *, |
| 26 | config_name: str = "config-git-only.yaml", |
| 27 | policy_dest: str | None = None, |
| 28 | enabled: bool = False, |
| 29 | policy_path: str | None = None, |
| 30 | ) -> Path: |
| 31 | """Write config + routing policy for route CLI tests.""" |
| 32 | write_config(repo_root, config_name) |
| 33 | policy_file = copy_default_routing_policy(repo_root, dest=policy_dest) |
| 34 | if enabled or policy_path is not None: |
| 35 | cfg_path = repo_root / ".overseer" / "config.yaml" |
| 36 | data = yaml.safe_load(cfg_path.read_text(encoding="utf-8")) |
| 37 | block: dict[str, object] = {"enabled": enabled} |
| 38 | if policy_path is not None: |
| 39 | block["policy"] = policy_path |
| 40 | data["model_routing"] = block |
| 41 | cfg_path.write_text(yaml.safe_dump(data, sort_keys=False), encoding="utf-8") |
| 42 | return policy_file |
| 43 | |
| 44 | |
| 45 | def write_routing_policy(repo_root: Path, content: str, *, rel: str = "policy/model-routing.yaml") -> Path: |
| 46 | """Write a custom routing policy file.""" |
| 47 | path = repo_root / rel |
| 48 | path.parent.mkdir(parents=True, exist_ok=True) |
| 49 | path.write_text(content, encoding="utf-8") |
| 50 | return path |
| 51 | |
| 52 | |
| 53 | def minimal_valid_policy_yaml() -> str: |
| 54 | return (kit_root() / "policy" / "model-routing.yaml").read_text(encoding="utf-8") |
| 55 | |
| 56 | |
| 57 | ROUTING_FIXTURES = FIXTURES / "model_routing" |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
1 day ago