#!/usr/bin/env python3 """CHECK: re-derive the open `type=issues` census from the live Gitea API and compare against the values recorded in `issue-triage.json`. Exit 0 only if the totals match. Single bare command: python3 wizard-work/sol/issue-triage-verify.py """ import json, sys, urllib.request BASE = "https://forge.alexanderwhitestone.com/api/v1" ORG = "stackchain" def get(url): req = urllib.request.Request(url, headers={"Accept": "application/json"}) with urllib.request.urlopen(req, timeout=60) as r: return json.loads(r.read().decode("utf-8")) def open_issues(repo): out = [] page = 1 while True: url = f"{BASE}/repos/{ORG}/{repo}/issues?state=open&type=issues&per_page=3&page={page}" batch = get(url) if not batch: break out.extend(batch) if len(batch) < 3: break page += 1 return out REPOS = ["stackchain-hackathon","agent-todo-tracker","stackchain-dashboard","live-wizard", "sovereign-stack","sovereign-stack-pwa","stackchain-lab-loop","timmy-talking-turd","troupe-standup"] def main(): live = {} for n in REPOS: live[n] = len(open_issues(n)) with open("/root/troupe-standup/wizard-work/sol/issue-triage.json") as f: art = json.load(f) total_live = sum(live.values()) total_art = art.get("total_live") ok = (total_live == total_art) print("CHECK iissue-triage-verify: re-derived total =", total_live) for n in REPOS: mark = "ok " if live[n] == art["repos"][REPOS.index(n)]["open"] else "DIFF" print(f" {n:26s} live={live[n]} artifact={art['repos'][REPOS.index(n)]['open']} {mark}") if ok: print("CHECK OK: live re-census = artifact total", total_live) sys.exit(0) print("CHECK FAIL: totals differ") sys.exit(1) if __name__ == "__main__": main()