test_stamp_atomic.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
9 hours ago
| 1 | """Data-integrity tests for atomic stamp writes (§K5.12).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | from unittest.mock import patch |
| 7 | |
| 8 | import pytest |
| 9 | |
| 10 | from cli.atomic import WriteFailure |
| 11 | from tests.support import FIXTURES |
| 12 | from tools.freeze_reviewer.artifact import parse_artifact |
| 13 | from tools.freeze_reviewer.stamp import build_stamp, write_stamp |
| 14 | from tools.freeze_reviewer.types import ReviewerSettings |
| 15 | |
| 16 | |
| 17 | def test_oserror_mid_stamp_preserves_original(tmp_path: Path) -> None: |
| 18 | path = tmp_path / "freeze.yaml" |
| 19 | original = (FIXTURES / "freeze-artifact.yaml").read_text(encoding="utf-8") |
| 20 | path.write_text(original, encoding="utf-8") |
| 21 | parsed = parse_artifact(path, rel_path="freeze.yaml") |
| 22 | stamp = build_stamp( |
| 23 | parsed, |
| 24 | reviewer=ReviewerSettings("agent", "thinking-high", "local", "human"), |
| 25 | kit_version="0.1.0", |
| 26 | ) |
| 27 | with patch("tools.freeze_reviewer.stamp.atomic_write_text", side_effect=WriteFailure(path, OSError("fail"))): |
| 28 | with pytest.raises(WriteFailure): |
| 29 | write_stamp(path, parsed, stamp) |
| 30 | assert path.read_text(encoding="utf-8") == original |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
8 hours ago