#!/usr/bin/env python """Results-to-claim audit. Reads results/claim_registry.csv (claim, metric, value, benchmark, run_ids, artifact, status) and verifies that (i) every artifact path exists, (ii) every run id has a manifest with state completed (or the registry explicitly says 'partial'), (iii) every numeric macro used in the manuscript exists in paper/tables/numbers.tex, and (iv) the manuscript does not use forbidden promotional words. Exit code 1 on any failure. Usage: python scripts/verify_manuscript_claims.py """ from __future__ import annotations import csv, glob, json, re, sys from pathlib import Path FORBIDDEN = ["revolutionary", "state-of-the-art", "breakthrough", "groundbreaking", "unprecedented", "novel architecture that outperforms"] def main() -> int: ok = True reg = Path("results/claim_registry.csv") if not reg.exists(): print("FAIL: results/claim_registry.csv missing"); return 1 rows = list(csv.DictReader(open(reg))) print(f"{len(rows)} registered claims") for r in rows: for art in filter(None, [a.strip() for a in r["artifact"].split(";")]): if not Path(art).exists(): print(f"FAIL artifact missing for claim '{r['claim'][:60]}': {art}"); ok = False for rid in filter(None, [x.strip() for x in r["run_ids"].split(";")]): mans = glob.glob(f"experiments/runs/{rid}*/manifest.json") + glob.glob(f"experiments/runs/{rid}/manifest.json") if not mans: print(f"FAIL run manifest missing for '{r['claim'][:60]}': {rid}"); ok = False; continue st = json.load(open(mans[0])).get("state", "") if st != "completed" and r.get("status", "") not in ("partial", "stopped-run-used"): print(f"FAIL run {rid} state={st} but claim status={r.get('status')}"); ok = False nums = Path("paper/tables/numbers.tex").read_text() if Path("paper/tables/numbers.tex").exists() else "" defined = set(re.findall(r"\\newcommand\{\\([A-Za-z]+)\}", nums)) tex = "\n".join(Path(p).read_text() for p in glob.glob("paper/sections/*.tex") + glob.glob("paper/appendix/*.tex")) used = set(re.findall(r"\\(params[A-Za-z]+|labels[A-Za-z]+|ctrl[A-Za-z]+|oracle[A-Za-z]+|vtwo[A-Za-z]+|latency[A-Za-z]+|cost[A-Za-z]+|ntrain[A-Za-z]+|pilot[A-Za-z]+|em[A-Z][A-Za-z]+)", tex)) for u in sorted(used - defined): print(f"FAIL macro \\{u} used in manuscript but not generated"); ok = False low = tex.lower() for w in FORBIDDEN: if w in low: print(f"FAIL forbidden phrase in manuscript: '{w}'"); ok = False # unresolved placeholders for p in glob.glob("paper/sections/*.tex") + glob.glob("paper/appendix/*.tex"): if "% to be written" in Path(p).read_text() or "TODO" in Path(p).read_text(): print(f"FAIL placeholder left in {p}"); ok = False print("AUDIT", "PASS" if ok else "FAIL") return 0 if ok else 1 if __name__ == "__main__": raise SystemExit(main())