#!/usr/bin/env python3 """Refuse release while runtime copy or the Plan 3 review inventory is pending.""" from pathlib import Path import re import sys import runpy SURFACES = ( "internal/equipo/copy.go", "docs/api/equipo-v1.md", "docs/plan-3-acceptance.md", "docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md", ) def copy_reviewed(root): for name in SURFACES: try: text = (root / name).read_text() except (OSError, UnicodeError): return False if name.endswith("CONTROLLER-REPORT-plan-3.md"): # Historical task reports keep their original evidence. Only the # consolidated current inventory represents the review decision. heading = "## Plan 3 copy inventory (for Paul's review)" if heading in text: text = text.split(heading, 1)[1].split("\n## ", 1)[0] if re.search(r"COPY REVIEW REQUIRED|COPY REVIEW PENDING|pending copy review", text, re.I): return False adapter = root / "scripts/copy-contract.py" if adapter.exists(): api = runpy.run_path(str(adapter)) return api["status"]({"candidate": str(root)}, "verify")["valid"] return True if __name__ == "__main__": sys.exit(0 if copy_reviewed(Path(__file__).resolve().parent.parent) else 1)