test_preserve_shared_assets_integrity.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
9 hours ago
| 1 | """Data-integrity — preserved shared lock sha + kit-only digest (§PSA.8).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | from cli.digest import sha256_hex |
| 8 | from cli.version_lock import ORIGIN_PRESERVED, compute_lock_digest, read_version_lock |
| 9 | from tests.support import PILOT, muse_mirror_status_runner, run_cli, seed_pilot_tree |
| 10 | |
| 11 | |
| 12 | def test_preserved_shared_lock_sha_matches_disk_and_digest(tmp_path: Path) -> None: |
| 13 | seed_pilot_tree( |
| 14 | tmp_path, |
| 15 | handover_rel="docs/OVERSEER-HANDOVER.md", |
| 16 | handover_text="# H\n", |
| 17 | roadmap_rel="docs/ROADMAP.md", |
| 18 | roadmap_text="# R\n", |
| 19 | ) |
| 20 | policy = tmp_path / ".overseer" / "policy" |
| 21 | policy.mkdir(parents=True, exist_ok=True) |
| 22 | hand = b"consumer-owned: true\n" |
| 23 | (policy / "tiers.yaml").write_bytes(hand) |
| 24 | |
| 25 | args = [ |
| 26 | "init", |
| 27 | "--migrate", |
| 28 | "--force", |
| 29 | "--preserve-shared-assets", |
| 30 | "--from-config", |
| 31 | str(PILOT / "config-scooling.yaml"), |
| 32 | "--non-interactive", |
| 33 | ] |
| 34 | runner = muse_mirror_status_runner(tmp_path) |
| 35 | assert run_cli(args, cwd=tmp_path, runner=runner) == 0 |
| 36 | lock1 = read_version_lock(tmp_path / ".overseer" / "version.lock") |
| 37 | entry1 = next(e for e in lock1.footprint if e.path == ".overseer/policy/tiers.yaml") |
| 38 | assert entry1.origin == ORIGIN_PRESERVED |
| 39 | assert entry1.sha256 == sha256_hex(hand) |
| 40 | assert (policy / "tiers.yaml").read_bytes() == hand |
| 41 | assert lock1.footprint_digest == compute_lock_digest(list(lock1.footprint)) |
| 42 | |
| 43 | assert run_cli(args, cwd=tmp_path, runner=runner) == 0 |
| 44 | lock2 = read_version_lock(tmp_path / ".overseer" / "version.lock") |
| 45 | entry2 = next(e for e in lock2.footprint if e.path == ".overseer/policy/tiers.yaml") |
| 46 | assert entry2.origin == ORIGIN_PRESERVED |
| 47 | assert entry2.sha256 == entry1.sha256 |
| 48 | assert (policy / "tiers.yaml").read_bytes() == hand |
| 49 | assert lock2.footprint_digest == compute_lock_digest(list(lock2.footprint)) |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
9 hours ago