test_preserve_shared_assets.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
1 day ago
| 1 | """Integration — preserve shared bridge assets on migrate (§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.footprint import MUSE_BRIDGE_DEPLOY_DEST, MUSE_BRIDGE_WORKFLOW_DEST |
| 9 | from cli.kit_root import kit_root |
| 10 | from cli.version_lock import ORIGIN_KIT, ORIGIN_PRESERVED, read_version_lock |
| 11 | from tests.support import FIXTURES, muse_mirror_status_runner, run_cli |
| 12 | |
| 13 | |
| 14 | HAND_SCRIPT = "#!/bin/bash\necho knowtation-bridge\n# consumer-owned\n" |
| 15 | HAND_WORKFLOW = "# Knowtation MUSE-BRIDGE-WORKFLOW\nconsumer owned\n" |
| 16 | |
| 17 | |
| 18 | def _seed_hand_bridge(tmp_path: Path) -> None: |
| 19 | scripts = tmp_path / "scripts" |
| 20 | scripts.mkdir(parents=True) |
| 21 | (scripts / "muse-bridge-deploy.sh").write_text(HAND_SCRIPT, encoding="utf-8") |
| 22 | (tmp_path / MUSE_BRIDGE_WORKFLOW_DEST).write_text(HAND_WORKFLOW, encoding="utf-8") |
| 23 | (tmp_path / "docs").mkdir(parents=True, exist_ok=True) |
| 24 | (tmp_path / "docs" / "OVERSEER-HANDOVER.md").write_text("# hand handover\n", encoding="utf-8") |
| 25 | (tmp_path / "docs" / "ROADMAP.md").write_text("# hand roadmap\n", encoding="utf-8") |
| 26 | |
| 27 | |
| 28 | def test_migrate_preserve_shared_keeps_bridge_bytes(tmp_path: Path) -> None: |
| 29 | _seed_hand_bridge(tmp_path) |
| 30 | code = run_cli( |
| 31 | [ |
| 32 | "init", |
| 33 | "--migrate", |
| 34 | "--force", |
| 35 | "--preserve-shared-assets", |
| 36 | "--from-config", |
| 37 | str(FIXTURES / "config-muse-git-mirror.yaml"), |
| 38 | "--non-interactive", |
| 39 | ], |
| 40 | cwd=tmp_path, |
| 41 | kit=kit_root(), |
| 42 | runner=muse_mirror_status_runner(tmp_path), |
| 43 | ) |
| 44 | assert code == 0 |
| 45 | assert (tmp_path / MUSE_BRIDGE_DEPLOY_DEST).read_text(encoding="utf-8") == HAND_SCRIPT |
| 46 | assert (tmp_path / MUSE_BRIDGE_WORKFLOW_DEST).read_text(encoding="utf-8") == HAND_WORKFLOW |
| 47 | lock = read_version_lock(tmp_path / ".overseer" / "version.lock") |
| 48 | by_path = {e.path: e for e in lock.footprint} |
| 49 | assert by_path[MUSE_BRIDGE_DEPLOY_DEST].origin == ORIGIN_PRESERVED |
| 50 | assert by_path[MUSE_BRIDGE_WORKFLOW_DEST].origin == ORIGIN_PRESERVED |
| 51 | assert by_path[MUSE_BRIDGE_DEPLOY_DEST].sha256 == sha256_hex(HAND_SCRIPT.encode()) |
| 52 | |
| 53 | |
| 54 | def test_migrate_force_without_preserve_overwrites_bridge(tmp_path: Path) -> None: |
| 55 | _seed_hand_bridge(tmp_path) |
| 56 | code = run_cli( |
| 57 | [ |
| 58 | "init", |
| 59 | "--migrate", |
| 60 | "--force", |
| 61 | "--from-config", |
| 62 | str(FIXTURES / "config-muse-git-mirror.yaml"), |
| 63 | "--non-interactive", |
| 64 | ], |
| 65 | cwd=tmp_path, |
| 66 | kit=kit_root(), |
| 67 | runner=muse_mirror_status_runner(tmp_path), |
| 68 | ) |
| 69 | assert code == 0 |
| 70 | assert (tmp_path / MUSE_BRIDGE_DEPLOY_DEST).read_text(encoding="utf-8") != HAND_SCRIPT |
| 71 | lock = read_version_lock(tmp_path / ".overseer" / "version.lock") |
| 72 | by_path = {e.path: e for e in lock.footprint} |
| 73 | assert by_path[MUSE_BRIDGE_DEPLOY_DEST].origin == ORIGIN_KIT |
File History
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
1 day ago