test_pilot_migrate_cycle.py python
91 lines 3.0 KB
Raw
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 54 days ago
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('{"commit_id": "' + "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]\ngit_sha = "' + ("c" * 40) + '"\n'
41 '[last_import]\ngit_sha = "' + ("c" * 40) + '"\n',
42 encoding="utf-8",
43 )
44
45 code = run_cli(
46 [
47 "init",
48 "--migrate",
49 "--from-config",
50 str(PILOT / "config-knowtation.yaml"),
51 "--non-interactive",
52 ],
53 cwd=tmp_path,
54 runner=runner,
55 )
56 assert code == 0
57 assert (
58 tmp_path / "docs/OVERSEER-HANDOVER.md"
59 ).read_text(encoding="utf-8") == "# pre-existing handover ≠ template\n"
60 assert (tmp_path / "docs/ROADMAP.md").is_file()
61 origins = lock_origins(tmp_path)
62 assert origins["docs/OVERSEER-HANDOVER.md"] == ORIGIN_PRESERVED
63 assert origins["docs/ROADMAP.md"] == ORIGIN_PRESERVED
64 assert (tmp_path / ".overseer/policy/tiers.yaml").is_file()
65 assert (tmp_path / ".cursor/rules/governance-sync.mdc").is_file()
66
67 assert run_cli(["status", "--check-footprint"], cwd=tmp_path, runner=runner) == 0
68
69 # Second migrate no-op while config + lock + on-disk still match
70 lock_before = (tmp_path / ".overseer/version.lock").read_text(encoding="utf-8")
71 code2 = run_cli(
72 [
73 "init",
74 "--migrate",
75 "--from-config",
76 str(PILOT / "config-knowtation.yaml"),
77 "--non-interactive",
78 ],
79 cwd=tmp_path,
80 runner=runner,
81 )
82 assert code2 == 0
83 assert (tmp_path / ".overseer/version.lock").read_text(encoding="utf-8") == lock_before
84
85 # Hand-edit seeded roadmap leaves check-footprint ok
86 (tmp_path / "docs/ROADMAP.md").write_text("# seeded hand-edit\n", encoding="utf-8")
87 assert run_cli(["status", "--check-footprint"], cwd=tmp_path, runner=runner) == 0
88
89 gs = run_cli(["governance-sync", "--dry-run"], cwd=tmp_path, runner=runner)
90 assert gs == 0
91 assert (tmp_path / "docs/ROADMAP.md").read_text(encoding="utf-8") == "# seeded hand-edit\n"
File History 1 commit
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 54 days ago