test_pilot_migrate_cycle.py file-level

at main · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:6 fix(ISR): default require_independent_second_reviewer to require Opera… · aaronrene · Sep 2, 2026
1 """E2E migrate cycle on pilot fixtures (§K6.10)."""
2
3 from __future__ import annotations
4
5 import json
6 from pathlib import Path
7
8 from cli.version_lock import ORIGIN_PRESERVED
9 from tests.support import (
10 PILOT,
11 lock_origins,
12 muse_mirror_status_runner,
13 ok,
14 run_cli,
15 seed_pilot_tree,
16 seed_muse_substrate,
17 )
18
19
20 def test_pilot_migrate_cycle_preserves_and_seeds(tmp_path: Path) -> None:
21 seed_pilot_tree(
22 tmp_path,
23 handover_rel="docs/OVERSEER-HANDOVER.md",
24 handover_text="# pre-existing handover ≠ template\n",
25 roadmap_rel=None,
26 )
27 runner = muse_mirror_status_runner(tmp_path)
28 root = str(tmp_path.resolve())
29 runner.responses.update(
30 {
31 f"muse -C {root} rev-parse main": ok("a" * 40),
32 "git rev-parse origin/main": ok("b" * 40),
33 "gh pr list --state merged --limit 5 --json number,title,mergeCommit,mergedAt": ok(
34 json.dumps([])
35 ),
36 }
37 )
38 seed_muse_substrate(tmp_path)
39 (tmp_path / ".muse" / "git-bridge.toml").write_text(
40 '[last_export]\n'
41 'muse_commit_id = "' + ("a" * 40) + '"\n'
42 'git_sha = "' + ("c" * 40) + '"\n'
43 '[last_import]\ngit_sha = "' + ("c" * 40) + '"\n',
44 encoding="utf-8",
45 )
46
47 code = run_cli(
48 [
49 "init",
50 "--migrate",
51 "--from-config",
52 str(PILOT / "config-knowtation.yaml"),
53 "--non-interactive",
54 ],
55 cwd=tmp_path,
56 runner=runner,
57 )
58 assert code == 0
59 assert (
60 tmp_path / "docs/OVERSEER-HANDOVER.md"
61 ).read_text(encoding="utf-8") == "# pre-existing handover ≠ template\n"
62 assert (tmp_path / "docs/ROADMAP.md").is_file()
63 origins = lock_origins(tmp_path)
64 assert origins["docs/OVERSEER-HANDOVER.md"] == ORIGIN_PRESERVED
65 assert origins["docs/ROADMAP.md"] == ORIGIN_PRESERVED
66 assert (tmp_path / ".overseer/policy/tiers.yaml").is_file()
67 assert (tmp_path / ".cursor/rules/governance-sync.mdc").is_file()
68
69 assert run_cli(["status", "--check-footprint"], cwd=tmp_path, runner=runner) == 0
70
71 # Second migrate no-op while config + lock + on-disk still match
72 lock_before = (tmp_path / ".overseer/version.lock").read_text(encoding="utf-8")
73 code2 = run_cli(
74 [
75 "init",
76 "--migrate",
77 "--from-config",
78 str(PILOT / "config-knowtation.yaml"),
79 "--non-interactive",
80 ],
81 cwd=tmp_path,
82 runner=runner,
83 )
84 assert code2 == 0
85 assert (tmp_path / ".overseer/version.lock").read_text(encoding="utf-8") == lock_before
86
87 # Hand-edit seeded roadmap leaves check-footprint ok
88 (tmp_path / "docs/ROADMAP.md").write_text("# seeded hand-edit\n", encoding="utf-8")
89 assert run_cli(["status", "--check-footprint"], cwd=tmp_path, runner=runner) == 0
90
91 gs = run_cli(["governance-sync", "--dry-run"], cwd=tmp_path, runner=runner)
92 assert gs == 0
93 assert (tmp_path / "docs/ROADMAP.md").read_text(encoding="utf-8") == "# seeded hand-edit\n"