from __future__ import annotations import os def write_reports(run_dir: str, verdicts: list[dict]) -> None: gated = [v for v in verdicts if v["bucket"] == "gated_queue"] watch = [v for v in verdicts if v["bucket"] == "watchlist_report"] def table(path, title, rows): lines = [f"# {title}", "", "| Stem | Latest English | Reason |", "|---|---|---|"] for v in rows: lines.append(f"| {v['stem']} | {v.get('latest_english_version') or ''} | {v.get('reason') or ''} |") lines.append("") open(path, "w", encoding="utf-8").write("\n".join(lines)) table(os.path.join(run_dir, "gated.md"), "Gated queue", gated) table(os.path.join(run_dir, "watchlist-report.md"), "Watchlist check-in", watch)