test_track_o_integrity.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
10 hours ago
| 1 | """Data-integrity — Track O harness idempotency and no rewrite (§O0.8 data-integrity).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | from tools.track_o.validate import CONTRACT_REL, validate_track_o_pack |
| 8 | |
| 9 | KIT_ROOT = Path(__file__).resolve().parents[2] |
| 10 | |
| 11 | |
| 12 | def test_harness_idempotent_same_verdict() -> None: |
| 13 | r1 = validate_track_o_pack(KIT_ROOT) |
| 14 | r2 = validate_track_o_pack(KIT_ROOT) |
| 15 | assert r1.ok and r2.ok |
| 16 | assert r1.errors == r2.errors == [] |
| 17 | |
| 18 | |
| 19 | def test_contract_bytes_not_rewritten_by_harness() -> None: |
| 20 | path = KIT_ROOT / CONTRACT_REL |
| 21 | before = path.read_bytes() |
| 22 | result = validate_track_o_pack(KIT_ROOT) |
| 23 | after = path.read_bytes() |
| 24 | assert result.ok, result.errors |
| 25 | assert before == after |
| 26 | |
| 27 | |
| 28 | def test_no_partial_write_on_induced_failure(tmp_path: Path) -> None: |
| 29 | """Missing pack under tmp_path fails closed without creating contract files.""" |
| 30 | # Seed only an empty docs tree — no contract. |
| 31 | (tmp_path / "docs").mkdir() |
| 32 | before = list(tmp_path.rglob("*")) |
| 33 | result = validate_track_o_pack(tmp_path) |
| 34 | after = list(tmp_path.rglob("*")) |
| 35 | assert not result.ok |
| 36 | assert any(e.startswith("missing_file:") for e in result.errors) |
| 37 | assert before == after |
| 38 | assert not (tmp_path / CONTRACT_REL).exists() |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
10 hours ago