test_upgrade_regime_e2e.py python
127 lines 3.5 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 3 days ago
1 """E2E — Track O / O3 upgrade-regime dry-run + product-contract retarget (§O2.9 e2e)."""
2
3 from __future__ import annotations
4
5 import json
6 import sys
7 from io import StringIO
8 from pathlib import Path
9
10 from cli.context import CliContext
11 from cli.footprint import MUSE_BRIDGE_DEPLOY_DEST
12 from cli.kit_root import kit_root
13 from cli.main import main
14 from cli.output import OutputContext
15 from tests.support import (
16 FIXTURES,
17 make_runner,
18 muse_mirror_status_runner,
19 muse_status_runner,
20 ok,
21 run_cli,
22 seed_muse_substrate,
23 )
24 from tools.track_o.validate import CONTRACT_REL, RUNBOOK_REL, validate_track_o_pack
25
26 KIT_ROOT = Path(__file__).resolve().parents[2]
27
28
29 def _init_muse_only(tmp_path: Path) -> None:
30 seed_muse_substrate(tmp_path)
31 assert (
32 run_cli(
33 [
34 "init",
35 "--from-config",
36 str(FIXTURES / "config-muse-only.yaml"),
37 "--non-interactive",
38 ],
39 cwd=tmp_path,
40 kit=kit_root(),
41 runner=muse_status_runner(tmp_path),
42 )
43 == 0
44 )
45
46
47 def _runner(tmp_path: Path):
48 base = muse_mirror_status_runner(tmp_path)
49 responses = dict(base.responses)
50 responses["git remote get-url origin"] = ok("https://github.com/example/repo.git")
51 return make_runner(responses)
52
53
54 def test_dry_run_full_ceremony_report(tmp_path: Path) -> None:
55 _init_muse_only(tmp_path)
56 buf = StringIO()
57 old = sys.stdout
58 sys.stdout = buf
59 try:
60 ctx = CliContext.create(
61 runner=_runner(tmp_path),
62 cwd=tmp_path,
63 kit=kit_root(),
64 output=OutputContext(json_mode=True),
65 )
66 code = main(
67 [
68 "upgrade-regime",
69 "--from",
70 "muse-only",
71 "--to",
72 "muse+git-mirror",
73 "--dry-run",
74 "--json",
75 ],
76 ctx=ctx,
77 )
78 finally:
79 sys.stdout = old
80 assert code == 0
81 payload = json.loads(buf.getvalue())
82 assert payload["dry_run"] is True
83 assert payload["start_state"] == "muse-only"
84 assert "G1" in payload["gates"]
85 assert "G8" in payload["gates"]
86 assert payload["live_bridge_invoked"] is False
87 assert "Tier 3" in payload["hard_stop_c8"]
88 # Default e2e never invokes live bridge; tree unchanged for bridge files
89 assert not (tmp_path / MUSE_BRIDGE_DEPLOY_DEST).exists()
90
91
92 def test_git_only_fixture_refused(tmp_path: Path) -> None:
93 assert (
94 run_cli(
95 ["init", "--regime", "git-only", "--non-interactive"],
96 cwd=tmp_path,
97 kit=kit_root(),
98 )
99 == 0
100 )
101 code = run_cli(
102 [
103 "upgrade-regime",
104 "--from",
105 "muse-only",
106 "--to",
107 "muse+git-mirror",
108 "--dry-run",
109 ],
110 cwd=tmp_path,
111 kit=kit_root(),
112 )
113 assert code == 4
114
115
116 def test_product_contract_and_runbook_after_o3() -> None:
117 result = validate_track_o_pack(KIT_ROOT)
118 assert result.ok, result.errors
119 contract = (KIT_ROOT / CONTRACT_REL).read_text(encoding="utf-8")
120 assert "ok upgrade-regime" in contract
121 assert "PHASE-TRACK-O-O2-STAGE3-UPGRADE-CEREMONY" in contract
122 assert "deferred to Thinking O2" not in contract
123 assert "coming soon / operator-assisted" not in contract
124 assert (KIT_ROOT / RUNBOOK_REL).is_file()
125 runbook = (KIT_ROOT / RUNBOOK_REL).read_text(encoding="utf-8")
126 assert "ok upgrade-regime" in runbook
127 assert "C8" in runbook
File History 1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 3 days ago