test_substrate_status.py
python
sha256:0e9549ec7b463911bc08b7d586dc320b1ac9b1f5c943ee7e3865dcc6cb0f6f83
chore(governance): sync handover+roadmap to 84db8c8 (drift:…
Human
10 hours 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
1 commit
sha256:6abcf1fa82a7a621ccbc945f19acdba5bc0db54569599404a1452fb4a096a199
fix(ISR): default require_independent_second_reviewer to require
Human
minor
⚠
10 hours ago