#!/usr/bin/env python3 """Extension pass for job #2849: the WIDER class the pre-registration deliberately did not score. `checker-census.py` scores the pre-registered class only -- a module-level binding `NAME = "<64hex>"`. Re-running the route's own worked example showed that class is too narrow to see it: in `freshness-triager.py` the four constants are entries of a module-level container (lines 68-74), not bindings. This script counts, for the same 807 checkers, every 64-hex string literal that is *syntactically a literal* (quoted, anywhere), and resolves each against the same two cheap records: the store object at that sha, and whether another return declares it as a file. It is reported as a second class with its own numbers, never merged with the pre-registered one. python literal-census.py --out literal-census.json """ import argparse import hashlib import json import os import re import sys EV = "evidence/2849" BASE = "https://solveathome.org" HEX64 = re.compile(r"['\"]([0-9a-f]{64})['\"]") def sha(b): return hashlib.sha256(b).hexdigest() def main(): ap = argparse.ArgumentParser() ap.add_argument("--out", default="literal-census.json") a = ap.parse_args() import urllib.request import urllib.error def get(path, timeout=60): req = urllib.request.Request(BASE + path, headers={"User-Agent": "t1-2026-09-23/2849 (extension)"}) try: with urllib.request.urlopen(req, timeout=timeout) as r: return r.status, r.read() except urllib.error.HTTPError as e: return e.code, e.read() except Exception as e: return None, repr(e).encode() pre = json.load(open("work2849/checker-census.json", encoding="utf-8")) pre_bound = {(r["checker"], r["value"]) for r in pre["constant_rows"]} declared = {} for line in open(EV + "/return-digest.jsonl", encoding="utf-8"): if not line.strip(): continue rec = json.loads(line) for f in rec.get("files") or []: if f.get("sha256"): declared.setdefault(f["sha256"], set()).add(rec["id"]) rows, per_checker = [], {} for h in sorted(os.listdir(EV + "/checkers")): raw = open(EV + "/checkers/" + h, "rb").read() text = raw.decode("utf-8", "replace") found = [] for i, ln in enumerate(text.split("\n"), 1): for m in HEX64.finditer(ln): found.append({"value": m.group(1).lower(), "line": i, "quoting_line": ln.strip()[:200]}) if not found: continue vals = {f["value"] for f in found} per_checker[h] = {"declared_name": (pre["checkers"].get(h) or {}).get("declared_name"), "returns": sorted({s["return"] for s in (pre["checkers"].get(h) or {}).get("sites", [])}), "literals": sorted(vals), "lines": found} for f in found: f["checker"] = h f["module_level_binding"] = (h, f["value"]) in pre_bound f["returns"] = per_checker[h]["returns"] if f["returns"]: others = sorted(declared.get(f["value"], set()) - set(f["returns"])) else: others = sorted(declared.get(f["value"], set())) f["declared_by_other_returns"] = others st, body = get("/files/" + f["value"]) f["store_object"] = bool(st == 200 and sha(body) == f["value"]) f["resolves"] = bool(f["store_object"] or others) rows.append(f) unresolved = [r for r in rows if not r["resolves"]] out = { "instrument": os.path.basename(__file__), "class": "in-container 64-hex string literals (quoted), wider than the pre-registered class", "checkers_scanned": len([f for f in os.listdir(EV + "/checkers")]), "checkers_with_literals": len(per_checker), "literal_rows": len(rows), "distinct_literals": len({r["value"] for r in rows}), "module_level_binding_rows": sum(1 for r in rows if r["module_level_binding"]), "resolved_by_store_object": sum(1 for r in rows if r["store_object"]), "resolved_by_another_return": sum(1 for r in rows if r["declared_by_other_returns"]), "unresolved": [{"checker": r["checker"], "checker_name": per_checker[r["checker"]]["declared_name"], "returns": r["returns"], "value": r["value"], "line": r["line"], "quoting_line": r["quoting_line"]} for r in unresolved], "worked_example": per_checker.get("b91f88a8db355c4114205a7f157ea2d99a49ae8cf007fbf5e2a8f4df0c6bf9da"), "per_checker": {h: {"declared_name": v["declared_name"], "returns": v["returns"], "literals": v["literals"]} for h, v in per_checker.items()}, } with open(a.out, "w", encoding="utf-8", newline="\n") as fh: json.dump(out, fh, indent=1, sort_keys=True) fh.write("\n") print(json.dumps({k: v for k, v in out.items() if k not in ("per_checker", "worked_example")}, indent=1)[:2500]) return 0 if __name__ == "__main__": sys.exit(main())