test_substrate_status.py python
55 lines 1.8 KB
Raw
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
1 """Integration: status surfaces hollow Muse substrate."""
2
3 from __future__ import annotations
4
5 import json
6 import shutil
7 from io import StringIO
8 from pathlib import Path
9 from unittest.mock import patch
10
11 from cli.context import CliContext
12 from cli.main import main
13 from cli.output import OutputContext
14 from tests.support import FIXTURES, make_runner, ok
15
16
17 def _seed_muse_mirror_repo(tmp_path: Path) -> None:
18 overseer = tmp_path / ".overseer"
19 overseer.mkdir()
20 shutil.copy(FIXTURES / "config-muse-git-mirror.yaml", overseer / "config.yaml")
21 (overseer / "version.lock").write_text(
22 "lock_version: 1\nkit_version: 0.1.0\nconfig_version: 1\n"
23 "footprint_digest: sha256:0\ninstalled_at: '2026-01-01'\n"
24 "synced_at: '2026-01-01'\nfootprint: []\n",
25 encoding="utf-8",
26 )
27 (tmp_path / ".muse").mkdir()
28
29
30 def test_status_exit_code_on_hollow_muse_substrate(tmp_path: Path) -> None:
31 _seed_muse_mirror_repo(tmp_path)
32 root = str(tmp_path)
33 runner = make_runner(
34 {
35 f"muse -C {root} rev-parse --abbrev-ref HEAD": ok("main"),
36 f"muse -C {root} status --json": ok('{"dirty": true}'),
37 "git rev-parse --abbrev-ref HEAD": ok("main"),
38 "git status --porcelain": ok(""),
39 }
40 )
41 out = StringIO()
42 with patch("sys.stdout", out):
43 code = main(
44 ["status", "--json", "--exit-code"],
45 ctx=CliContext.create(
46 cwd=tmp_path,
47 runner=runner,
48 output=OutputContext(json_mode=True),
49 ),
50 )
51 assert code == 2
52 payload = json.loads(out.getvalue())
53 assert payload["substrate"]["state"] == "hollow"
54 assert payload["substrate"]["ok"] is False
55 assert "muse init --force" in (payload["substrate"]["remediation"] or "")
File History 2 commits
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1 docs: MuseHub-first before ISR #74 — staging solidify NEXT Human 1 day ago
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 52 days ago