test_k7_bridge_footprint.py python
153 lines 5.2 KB
Raw
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83 chore(governance): sync handover+roadmap to 84db8c8 (drift:… Human 1 day ago
1 """Integration tests for K7 bridge footprint init/sync/status (§K7.8 integration tier)."""
2
3 from __future__ import annotations
4
5 import stat
6 from pathlib import Path
7
8 from adapters.config import load_config
9 from cli.footprint import MUSE_BRIDGE_DEPLOY_DEST, MUSE_BRIDGE_WORKFLOW_DEST
10 from cli.footprint_writes import FOOTPRINT_EXECUTABLE_MODE
11 from cli.kit_root import kit_root
12 from cli.version_lock import read_version_lock
13 from tests.support import FIXTURES, git_status_runner, muse_mirror_status_runner, run_cli
14
15
16 def _init_mirror(tmp_path: Path) -> None:
17 code = run_cli(
18 [
19 "init",
20 "--from-config",
21 str(FIXTURES / "config-muse-git-mirror.yaml"),
22 "--non-interactive",
23 ],
24 cwd=tmp_path,
25 kit=kit_root(),
26 runner=muse_mirror_status_runner(tmp_path),
27 )
28 assert code == 0
29
30
31 def test_muse_git_mirror_init_writes_bridge_files_executable(tmp_path: Path) -> None:
32 _init_mirror(tmp_path)
33 workflow = tmp_path / MUSE_BRIDGE_WORKFLOW_DEST
34 script = tmp_path / MUSE_BRIDGE_DEPLOY_DEST
35 assert workflow.is_file()
36 assert script.is_file()
37 assert stat.S_IMODE(script.stat().st_mode) == FOOTPRINT_EXECUTABLE_MODE
38 lock = read_version_lock(tmp_path / ".overseer" / "version.lock")
39 paths = {e.path for e in lock.footprint}
40 assert MUSE_BRIDGE_WORKFLOW_DEST in paths
41 assert MUSE_BRIDGE_DEPLOY_DEST in paths
42
43
44 def test_git_only_init_has_no_bridge_files(tmp_path: Path) -> None:
45 code = run_cli(
46 ["init", "--regime", "git-only", "--non-interactive"],
47 cwd=tmp_path,
48 kit=kit_root(),
49 )
50 assert code == 0
51 assert not (tmp_path / MUSE_BRIDGE_WORKFLOW_DEST).exists()
52 assert not (tmp_path / MUSE_BRIDGE_DEPLOY_DEST).exists()
53
54
55 def test_muse_mirror_status_check_footprint_ok(tmp_path: Path) -> None:
56 _init_mirror(tmp_path)
57 code = run_cli(
58 ["status", "--check-footprint"],
59 cwd=tmp_path,
60 runner=muse_mirror_status_runner(tmp_path),
61 )
62 assert code == 0
63
64
65 def test_sync_noop_at_same_version_with_bridge_files(tmp_path: Path) -> None:
66 _init_mirror(tmp_path)
67 code = run_cli(
68 ["sync", "-y"],
69 cwd=tmp_path,
70 runner=muse_mirror_status_runner(tmp_path),
71 )
72 assert code == 0
73
74
75 def test_migrate_conflict_on_differing_preexisting_deploy_script(tmp_path: Path) -> None:
76 scripts = tmp_path / "scripts"
77 scripts.mkdir(parents=True)
78 (scripts / "muse-bridge-deploy.sh").write_text("#!/bin/bash\necho hand-tuned\n", encoding="utf-8")
79 (tmp_path / MUSE_BRIDGE_WORKFLOW_DEST).write_text("# hand workflow\n", encoding="utf-8")
80 code = run_cli(
81 [
82 "init",
83 "--migrate",
84 "--from-config",
85 str(FIXTURES / "config-muse-git-mirror.yaml"),
86 "--non-interactive",
87 ],
88 cwd=tmp_path,
89 kit=kit_root(),
90 runner=muse_mirror_status_runner(tmp_path),
91 )
92 assert code == 4
93
94
95 def test_sync_seeds_new_bridge_destinations_when_absent_from_lock(tmp_path: Path) -> None:
96 run_cli(
97 ["init", "--regime", "git-only", "--non-interactive"],
98 cwd=tmp_path,
99 kit=kit_root(),
100 )
101 mirror_cfg = (FIXTURES / "config-muse-git-mirror.yaml").read_text(encoding="utf-8")
102 (tmp_path / ".overseer" / "config.yaml").write_text(mirror_cfg, encoding="utf-8")
103 assert not (tmp_path / MUSE_BRIDGE_WORKFLOW_DEST).exists()
104 assert not (tmp_path / MUSE_BRIDGE_DEPLOY_DEST).exists()
105 code = run_cli(
106 ["sync", "-y"],
107 cwd=tmp_path,
108 runner=muse_mirror_status_runner(tmp_path),
109 )
110 assert code == 0
111 assert (tmp_path / MUSE_BRIDGE_WORKFLOW_DEST).is_file()
112 assert (tmp_path / MUSE_BRIDGE_DEPLOY_DEST).is_file()
113 lock = read_version_lock(tmp_path / ".overseer" / "version.lock")
114 assert MUSE_BRIDGE_DEPLOY_DEST in {e.path for e in lock.footprint}
115
116
117 def test_sync_conflicts_when_bridge_on_disk_not_in_lock(tmp_path: Path) -> None:
118 run_cli(
119 ["init", "--regime", "git-only", "--non-interactive"],
120 cwd=tmp_path,
121 kit=kit_root(),
122 )
123 mirror_cfg = (FIXTURES / "config-muse-git-mirror.yaml").read_text(encoding="utf-8")
124 (tmp_path / ".overseer" / "config.yaml").write_text(mirror_cfg, encoding="utf-8")
125 scripts = tmp_path / "scripts"
126 scripts.mkdir(parents=True)
127 (scripts / "muse-bridge-deploy.sh").write_text("#!/bin/bash\necho consumer\n", encoding="utf-8")
128 (tmp_path / MUSE_BRIDGE_WORKFLOW_DEST).write_text("# consumer workflow\n", encoding="utf-8")
129 code = run_cli(
130 ["sync", "-y"],
131 cwd=tmp_path,
132 runner=muse_mirror_status_runner(tmp_path),
133 )
134 assert code == 4
135
136
137 def test_overseer_kit_dogfood_fixture_init(tmp_path: Path) -> None:
138 code = run_cli(
139 [
140 "init",
141 "--from-config",
142 str(FIXTURES / "config-overseer-kit-dogfood.yaml"),
143 "--non-interactive",
144 ],
145 cwd=tmp_path,
146 kit=kit_root(),
147 runner=muse_mirror_status_runner(tmp_path),
148 )
149 assert code == 0
150 config = load_config(tmp_path / ".overseer" / "config.yaml")
151 assert config.repo.name == "overseer-kit"
152 assert config.docs.coordination is None
153 assert (tmp_path / MUSE_BRIDGE_WORKFLOW_DEST).is_file()
File History 1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199 fix(ISR): default require_independent_second_reviewer to require Human minor 1 day ago