"""CLI: write the review report draft (.md + .pdf + report_check.json) for a pier run folder. usage: python make_report.py [] [--author 이름] run dir defaults to /runs/current. Gates whose recorded inputs hash differs from the current params/expected are reported as void (same rule as the web app). """ import argparse import sys from pathlib import Path APP = Path(__file__).resolve().parents[1] sys.path.insert(0, str(APP)) sys.path.insert(0, str(APP / "web")) from engine import report_files # noqa: E402 from engine.pipeline import gate_ids # noqa: E402 import store # noqa: E402 if __name__ == "__main__": ap = argparse.ArgumentParser() ap.add_argument("pier") ap.add_argument("run", nargs="?") ap.add_argument("--author", default="") a = ap.parse_args() pier = Path(a.pier).resolve() run = Path(a.run).resolve() if a.run else pier / "runs" / "current" cur = store.sha([store.rjson(pier / "params.json"), store.rjson(pier / "expected.json")]) stale = {g for g in gate_ids() if (rep := store.rjson(run / f"{g}_gate.json")) and rep.get("inputs_sha") not in (None, cur)} out = report_files.write(pier, run, a.author, stale) print(out["md"], "\n", out["pdf"], "\n", out["check"]) sys.exit(0 if out["check"]["ok"] else 1)