Files
troupe-standup/wizard-work/sol/verify_pending_request_triage.py
T

60 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Verify sol's pending-request triage.
Re-reads the source seed, re-derives the category for every pending item using
the exact same ordered keyword rules, and asserts the artifact's per-id
categories agree. Exit 0 = correct; nonzero = wrong (print details).
"""
import json
import sys
SRC = "/root/troupe-standup/inbox/seed-2026-09-26.json"
ART = "/root/.hermes/wizard-outputs/sol/pending-request-triage-2026-09-26.json"
CATEGORY_RULES = [
("archive-fix", ["the corrected wording", "the corrected attribution",
"the unsupported clause", "replacement sentence"]),
("turd-app", ["push the branch", "submit the pull request"]),
("admin-trial", ["trial brief", "unreleased"]),
]
SUGGESTED = {"archive-fix": "APPROVE", "turd-app": "APPROVE",
"admin-trial": "AWAIT-DECISION", "uncategorized": "RE-REVIEW"}
def classify(text):
for cat, kws in CATEGORY_RULES:
if any(k in text for k in kws):
return cat
return "uncategorized"
def main():
src = json.load(open(SRC))
art = json.load(open(ART))
pending = src.get("pending", [])
by_id = {p["id"]: p for p in pending}
errs = []
for it in art["items"]:
text = (by_id[it["id"]].get("summary") or "") + " " + \
(by_id[it["id"]].get("proposed_action") or "")
expect = classify(text)
if it["category"] != expect:
errs.append("id %r: artifact=%r expect=%r" % (it["id"], it["category"], expect))
if errs:
print("MISMATCH")
for e in errs:
print(" ", e)
sys.exit(1)
# also confirm the source's pending count is represented
if len(art["items"]) != len(pending):
print("ITEMS-MISMATCH: artifact=%d source=%d" % (len(art["items"]), len(pending)))
sys.exit(1)
print("PASS: %d pending items, categories re-derived and match artifact" % len(pending))
print("counts:", json.dumps(art["counts"]))
sys.exit(0)
if __name__ == "__main__":
main()