#!/usr/bin/env python3 # Job #609: every return's patch_status / revision_path / also_fix / target, filtered # to the owning notes and ids of rows 38-52. Finds drafted fixes a reviewer accepted. import json, os, re, urllib.request, urllib.error B = "https://solveathome.org/projects/twin-primes" H = {"Authorization": "Bearer " + os.environ["SAH"], "X-Model": "deepseek-v4.1-flash", "X-Session": "266d9746eb765060ee1faaa9", "Accept": "application/json"} NOTES = ["attack-0830-rec-cheapest", "recon-0904-sifting-limit-floor", "rho-exact-z31-01", "rho-maximal-law", "measure-0830-rho-sup-z41", "attack-0829n-rml-proof", "fekete-1d", "phase1-T3prep-decision-rule", "attack-hsub-01", "xchannel-at23", "xchan-at29", "item-x-offset", "engine-0830-at43-bigint", "comb-discrepancy-tight", "attack-0830-comb-tail", "attack-c2drift-01", "c2prime-refit-22"] PAT = re.compile("|".join(re.escape(n) for n in NOTES), re.I) IDS = ["Q-rec-cheapest-0830", "Q-recon-0904-sifting-limit-floor", "Q-rho-maximal-law", "Q-rho-sup-z41-0830", "Q-rml-proof-0829n", "Q-fekete-1d-defect47", "Q-g2-falls-decision-rule", "Q-hsub-reductions", "Q-xchannel-at23", "Q-xchannel-closedform", "Q-xchannel-offset", "Q-at43-bigint-0830", "Q-comb-discrepancy", "Q-comb-tail-0830", "Q-c2prime-drift"] PIDS = re.compile("|".join(re.escape(i) for i in IDS), re.I) out = [] for i in range(1, int(os.environ.get("N", "240")) + 1): try: d = json.loads(urllib.request.urlopen( urllib.request.Request(B + "/return/%d" % i, headers=H), timeout=25).read().decode("utf-8", "replace")) except Exception as e: continue blob = json.dumps({k: d.get(k) for k in ("revision_path", "also_fix", "target", "finding", "files")}, ensure_ascii=False) + str(d.get("patch") or "")[:200000] ps = str(d.get("patch_status") or "") names = bool(PAT.search(blob)) or bool(PIDS.search(blob)) if names and (d.get("patch") or d.get("also_fix") or d.get("revision_path")): out.append(dict(id=i, type=d.get("type"), status=d.get("status"), handle=d.get("handle"), rung=d.get("final_rung"), created=d.get("created_at"), patch_status=ps[:60], revision_path=d.get("revision_path"), also_fix=d.get("also_fix"))) print("#%-4d %-9s %-10s @%-16s %s rung=%s" % (i, d.get("type"), d.get("status"), d.get("handle"), d.get("created_at"), d.get("final_rung"))) print(" patch_status:", ps[:110]) print(" revision_path:", d.get("revision_path")) af = d.get("also_fix") if af: for a in (af if isinstance(af, list) else [af]): print(" also_fix ->", a.get("path"), "|", (a.get("note") or "")[:200]) json.dump(out, open("job609/fixes.json", "w", encoding="utf-8"), indent=1, ensure_ascii=False) print("\n", len(out), "returns carry a patch/fix naming one of the 17 notes")