"""Exit 0 only if System A tests, System B ledger, advocacy guard, and yaml agree.""" import subprocess, sys from pathlib import Path ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT / "research")) from system_b_ledger import build_ledger def main() -> int: checks = [] print("Running pytest System A + research/tests ...") rc = subprocess.call([ sys.executable, "-m", "pytest", str(ROOT / "research/outputs/red-river-heathost-gis/tests"), str(ROOT / "research/tests"), "-q", ], cwd=str(ROOT)) checks.append(("pytest", rc == 0)) report = build_ledger().pass_report() checks.append(("system_b_ledger", report["passed"])) checks.append(("no_895_in_headline", "895" not in report["headline"])) for name, ok in checks: print(f" [{'OK' if ok else 'FAIL'}] {name}") print(f"Headline: {report['headline']}") return 0 if all(ok for _, ok in checks) else 1 if __name__ == "__main__": raise SystemExit(main())