test_cost_awareness_integrity.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
1 day ago
| 1 | """Data-integrity tests for Track P / P-cost (§PC.9).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import json |
| 6 | from pathlib import Path |
| 7 | |
| 8 | from adapters.config import load_config |
| 9 | from cli.kit_root import kit_root |
| 10 | from tests.fixtures.cost_awareness import seed_cost_awareness_repo, seed_cost_e2e_repo |
| 11 | from tests.support import git_status_runner, run_cli |
| 12 | from tools.cost_awareness.derive import derive_cost_view |
| 13 | from tools.cost_awareness.surface import build_cost_awareness_report |
| 14 | |
| 15 | |
| 16 | def test_surface_idempotent_same_inputs(tmp_path: Path) -> None: |
| 17 | seed_cost_e2e_repo(tmp_path) |
| 18 | config = load_config(tmp_path / ".overseer" / "config.yaml") |
| 19 | handover = (tmp_path / "docs" / "OVERSEER-HANDOVER.md").read_text(encoding="utf-8") |
| 20 | roadmap = (tmp_path / "docs" / "ROADMAP.md").read_text(encoding="utf-8") |
| 21 | first = build_cost_awareness_report( |
| 22 | config, tmp_path, kit_root=kit_root(), handover_text=handover, roadmap_text=roadmap |
| 23 | ) |
| 24 | second = build_cost_awareness_report( |
| 25 | config, tmp_path, kit_root=kit_root(), handover_text=handover, roadmap_text=roadmap |
| 26 | ) |
| 27 | assert first == second |
| 28 | |
| 29 | |
| 30 | def test_paid_derivation_deterministic() -> None: |
| 31 | bands = {"standard": "moderate", "fast": "low"} |
| 32 | results = {derive_cost_view("standard", bands) for _ in range(20)} |
| 33 | assert results == {("moderate", True)} |
| 34 | |
| 35 | |
| 36 | def test_enabling_cost_awareness_does_not_mutate_files(tmp_path: Path) -> None: |
| 37 | seed_cost_awareness_repo(tmp_path, enabled=True) |
| 38 | lock_path = tmp_path / ".overseer" / "version.lock" |
| 39 | lock_path.write_text( |
| 40 | "lock_version: 1\nkit_version: 0.1.0\nconfig_version: 1\n" |
| 41 | "footprint_digest: sha256:abc\ninstalled_at: '2026-01-01'\n" |
| 42 | "synced_at: '2026-01-01'\nfootprint: []\n", |
| 43 | encoding="utf-8", |
| 44 | ) |
| 45 | before = lock_path.read_bytes() |
| 46 | run_cli( |
| 47 | ["status", "--json"], |
| 48 | cwd=tmp_path, |
| 49 | runner=git_status_runner(), |
| 50 | kit=kit_root(), |
| 51 | json_mode=True, |
| 52 | ) |
| 53 | assert lock_path.read_bytes() == before |
| 54 | |
| 55 | |
| 56 | def test_disabled_cost_awareness_status_unchanged(tmp_path: Path, capsys) -> None: |
| 57 | seed_cost_awareness_repo(tmp_path, enabled=False) |
| 58 | lock_path = tmp_path / ".overseer" / "version.lock" |
| 59 | lock_path.write_text( |
| 60 | "lock_version: 1\nkit_version: 0.1.0\nconfig_version: 1\n" |
| 61 | "footprint_digest: sha256:abc\ninstalled_at: '2026-01-01'\n" |
| 62 | "synced_at: '2026-01-01'\nfootprint: []\n", |
| 63 | encoding="utf-8", |
| 64 | ) |
| 65 | run_cli( |
| 66 | ["status", "--json"], |
| 67 | cwd=tmp_path, |
| 68 | runner=git_status_runner(), |
| 69 | kit=kit_root(), |
| 70 | json_mode=True, |
| 71 | ) |
| 72 | payload = json.loads(capsys.readouterr().out) |
| 73 | assert "cost_awareness" not in payload |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
1 day ago