Files

69 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""CHECK for the sol triage classifier artifact.
Writes nothing; its exit code IS the verdict (0 = artifact correct, nonzero = wrong).
"""
import json
import os
import sys
OUT = "/root/troupe-standup/wizard-work/sol"
RES = os.path.join(OUT, "triage_results.json")
RPT = os.path.join(OUT, "triage_report.md")
errors = []
def check(name, cond, detail=""):
if not cond:
errors.append(f"{name}: {detail}")
with open(RES) as f:
p = json.load(f)
check("total", p.get("total") == 13, f"got {p.get('total')}")
check("counts",
p.get("counts") == {"archive_fix": 8, "app_pr": 3, "general": 2},
f"got {p.get('counts')}")
cat_for = {}
dec_for = {}
for r in p.get("results", []):
cat_for[r["id"]] = r["category"]
dec_for[r["id"]] = r["decision"]
# pending archive_fix -> approve; pending app_pr -> table; pending general -> table
for r in p.get("results", []):
if r["source"] != "pending":
continue
if r["category"] == "archive_fix":
check(f"id{r['id']} archive -> approve", r["decision"] == "approve", r["decision"])
elif r["category"] == "app_pr":
check(f"id{r['id']} app_pr -> table", r["decision"] == "table", r["decision"])
else:
check(f"id{r['id']} general -> table", r["decision"] == "table", r["decision"])
# decided item id 13
r13 = next((r for r in p["results"] if r["id"] == 13), None)
check("id13 present", r13 is not None)
if r13 is not None:
check("id13 archive_fix/approved", r13["category"] == "archive_fix" and r13["decision"] == "approved",
f"{r13['category']}/{r13['decision']}")
# evidence present for every item
for r in p.get("results", []):
check(f"id{r['id']} evidence", bool((r.get("evidence") or "").strip()), "empty")
# human-readable report non-empty
check("report exists+nonempty", os.path.exists(RPT) and os.path.getsize(RPT) > 100)
if errors:
print("CHECK FAILED")
for e in errors:
print(" -", e)
sys.exit(1)
print("CHECK OK: total=13 counts=%s" % json.dumps(p["counts"]))
sys.exit(0)