test_checkpoints_manifest.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
1 day ago
| 1 | """Data-integrity tests for checkpoint manifest writes.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import yaml |
| 6 | |
| 7 | from tests.support import load_checkpoint_config, seed_checkpoint_repo |
| 8 | from tools.checkpoints.orchestrator import VerifyStepOptions, run_verify_step |
| 9 | |
| 10 | |
| 11 | def test_idempotent_reverify(repo_root: Path) -> None: |
| 12 | config = load_checkpoint_config(repo_root) |
| 13 | assert run_verify_step( |
| 14 | config=config, |
| 15 | repo_root=repo_root, |
| 16 | options=VerifyStepOptions(step_id="alpha"), |
| 17 | ).exit_code == 0 |
| 18 | after_first = (repo_root / "manifests" / "work-unit.yaml").read_text(encoding="utf-8") |
| 19 | assert run_verify_step( |
| 20 | config=config, |
| 21 | repo_root=repo_root, |
| 22 | options=VerifyStepOptions(step_id="alpha"), |
| 23 | ).exit_code == 0 |
| 24 | after_second = (repo_root / "manifests" / "work-unit.yaml").read_text(encoding="utf-8") |
| 25 | data1 = yaml.safe_load(after_first) |
| 26 | data2 = yaml.safe_load(after_second) |
| 27 | assert data1["steps"]["alpha"]["verified"] is True |
| 28 | assert data2["steps"]["alpha"]["verified"] is True |
| 29 | |
| 30 | |
| 31 | def test_mid_through_fail_keeps_prior_writes(repo_root: Path) -> None: |
| 32 | seed_checkpoint_repo(repo_root) |
| 33 | manifest_path = repo_root / "manifests" / "work-unit.yaml" |
| 34 | data = yaml.safe_load(manifest_path.read_text(encoding="utf-8")) |
| 35 | data["template_id"] = "three_step" |
| 36 | data["current_step"] = "gamma" |
| 37 | data["steps"]["gamma"] = {"verified": False, "verified_at": None, "artifact_sha256": None} |
| 38 | manifest_path.write_text(yaml.safe_dump(data), encoding="utf-8") |
| 39 | from adapters.config import load_config |
| 40 | |
| 41 | config = load_config(repo_root / ".overseer" / "config.yaml") |
| 42 | result = run_verify_step( |
| 43 | config=config, |
| 44 | repo_root=repo_root, |
| 45 | options=VerifyStepOptions(through_current=True), |
| 46 | ) |
| 47 | assert result.exit_code == 10 |
| 48 | manifest = yaml.safe_load(manifest_path.read_text(encoding="utf-8")) |
| 49 | assert manifest["steps"]["alpha"]["verified"] is True |
| 50 | assert manifest["steps"]["beta"]["verified"] is True |
| 51 | assert manifest["steps"]["gamma"]["verified"] is False |
| 52 | |
| 53 | |
| 54 | def test_dry_run_writes_nothing(repo_root: Path) -> None: |
| 55 | config = load_checkpoint_config(repo_root) |
| 56 | manifest_path = repo_root / "manifests" / "work-unit.yaml" |
| 57 | progress_path = repo_root / "PROGRESS.md" |
| 58 | before_manifest = manifest_path.read_bytes() |
| 59 | code = run_verify_step( |
| 60 | config=config, |
| 61 | repo_root=repo_root, |
| 62 | options=VerifyStepOptions(verify_all=True, dry_run=True), |
| 63 | ).exit_code |
| 64 | assert code == 0 |
| 65 | assert manifest_path.read_bytes() == before_manifest |
| 66 | assert not progress_path.exists() |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
1 day ago