land_closeout.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
20 hours ago
| 1 | """``ok land-closeout`` — post-merge closeout probe (§PMHF.6.3; never merges/writes).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from argparse import Namespace |
| 6 | |
| 7 | from adapters.config import load_config |
| 8 | from adapters.errors import ConfigError |
| 9 | from cli.context import CliContext |
| 10 | from cli.paths import is_within_repo, resolve_config_path, resolve_repo_root |
| 11 | from cli.sanitize import format_config_error |
| 12 | from tools.land_closeout import check_land_closeout, land_closeout_payload |
| 13 | |
| 14 | |
| 15 | def run_land_closeout_command(args: Namespace, ctx: CliContext) -> int: |
| 16 | """Execute ``ok land-closeout``; exit 0 when ``report.ok`` else 2.""" |
| 17 | repo_root = resolve_repo_root(cwd=ctx.cwd, repo_arg=args.repo, command="land-closeout") |
| 18 | config_path = resolve_config_path(repo_root, args.config) |
| 19 | if not is_within_repo(repo_root, config_path): |
| 20 | ctx.output.error("refused: config path outside repo root") |
| 21 | return 4 |
| 22 | |
| 23 | try: |
| 24 | config = load_config(config_path) |
| 25 | except ConfigError as exc: |
| 26 | ctx.output.error(format_config_error(exc, repo_root)) |
| 27 | return 2 |
| 28 | |
| 29 | probe = getattr(args, "probe_merged_pr", None) |
| 30 | if probe is None: |
| 31 | # §PMHF.5.3 default: probe when the regime has git/gh; never for muse-only. |
| 32 | probe = config.vcs.regime != "muse-only" |
| 33 | |
| 34 | report = check_land_closeout( |
| 35 | config, |
| 36 | repo_root, |
| 37 | runner=ctx.runner, |
| 38 | probe_merged_pr=probe, |
| 39 | ) |
| 40 | |
| 41 | exit_code = 0 if report.ok else 2 |
| 42 | if ctx.output.json_mode: |
| 43 | payload = land_closeout_payload(report) |
| 44 | payload["exit_code"] = exit_code |
| 45 | ctx.output.emit_json(payload) |
| 46 | else: |
| 47 | ctx.output.emit(f"land_closeout: {report.state} — {report.message}") |
| 48 | if report.remediation: |
| 49 | ctx.output.emit(f"land_closeout-remediation: {report.remediation}") |
| 50 | return exit_code |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
20 hours ago