#!/usr/bin/env python3 """Route 131's open falsifier, cheap because the version lists are already cached: is the 2026-09-16 cut ONE batch overwrite (which would make "the registry has a second regeneration" a single event), or a per-document reversion? Return #1421 read an axis #1413/#1402 did not: the attribution fields of each version. This script runs #1421's own falsifier over all ten documents rather than the four its brief named, and reports every counterexample instead of a verdict word: signature (a) v3.content_sha == v1.content_sha -- the content came back signature (b) v3.return_id is null -- no return produced it signature (c) the v3 created_at instants coincide across trees -- one batch, one instant signature (d) publications[].sha == v1.content_sha -- the published object is the old one Any v3 with a non-null return_id, a distinct created_at, or a content_sha differing from v1 refutes the single-batch reading. Reads only; writes batch-signature.json. """ import json import os import sys sys.stdout.reconfigure(encoding="utf-8", errors="replace") HERE = os.path.dirname(os.path.abspath(__file__)) JOB128 = os.path.join(os.path.dirname(HERE), "job128") sys.path.insert(0, JOB128) sys.path.insert(0, HERE) import route128_next as R # noqa: E402 def main(): sweep = json.load(open(os.path.join(JOB128, "sweep.json"), encoding="utf-8")) docs, out = [r["path"] for r in sweep["reverted"]], {"docs": [], "requests": 0} for path in docs: c, txt = R.get(R.PROJECT + "/history/" + path) out["requests"] += 1 if c != 200: out["docs"].append({"path": path, "error": c}) continue d = json.loads(txt) vs = d.get("versions", []) pubs = d.get("publications", []) or [] e = {"path": path, "versions": len(vs), "chain": [{"version": v.get("version"), "sha": (R.sha_of(v) or "")[:12], "return_id": v.get("return_id"), "author": v.get("author"), "verified_by": v.get("verified_by"), "created_at": v.get("created_at")} for v in vs]} if len(vs) >= 2: v1, vlast = vs[0], vs[-1] e["a_sha_returned"] = R.sha_of(vlast) == R.sha_of(v1) e["b_v3_no_return"] = vlast.get("return_id") in (None, "", 0) e["c_created_at"] = vlast.get("created_at") e["c_distinct_from_v1"] = vlast.get("created_at") != v1.get("created_at") # the publication entry carries `sha256`, NOT `sha` -- reading the wrong key made this test # report False for all ten on the first run, a false negative on the very axis under test e["publications"] = [{"id": p.get("id"), "sha": (p.get("sha256") or "")[:12], "prepared_at": p.get("prepared_at"), "recorded_at": p.get("recorded_at")} for p in pubs] e["d_publication_sha_is_v1"] = bool(pubs) and all( (p.get("sha256") or "") == (R.sha_of(v1) or "") for p in pubs) # do the publication instants straddle the cut instant? (the publisher is the cut's agent) e["publication_prepared_before_cut"] = [p.get("prepared_at") for p in pubs] e["publication_recorded_after_cut"] = [p.get("recorded_at") for p in pubs] e["refutes_single_batch"] = (not e["a_sha_returned"]) or (not e["b_v3_no_return"]) out["docs"].append(e) cand = [d for d in out["docs"] if d.get("versions", 0) >= 2] instants = sorted({d.get("c_created_at") for d in cand}) cut = instants[0] if instants else None out["summary"] = { "documents": len(out["docs"]), "with_history": len(cand), "a_all_returned": all(d.get("a_sha_returned") for d in cand), "b_all_v3_without_return": all(d.get("b_v3_no_return") for d in cand), "c_distinct_v3_instants": instants, "c_is_one_instant": len(instants) == 1, "d_all_publications_pin_v1": all(d.get("d_publication_sha_is_v1") for d in cand), "refutations": [d["path"] for d in cand if d.get("refutes_single_batch")], "cut_instant": cut, # every publication whose recorded_at is within a minute after the cut instant, and whose # prepared_at is before it: that publication job is the cut's own writer "publications_spanning_the_cut": [d["path"] for d in cand if any( p.get("recorded_at") and cut and p["prepared_at"] and p["prepared_at"] < cut < p["recorded_at"] for p in d.get("publications", []))], } json.dump(out, open(os.path.join(HERE, "batch-signature.json"), "w", encoding="utf-8"), indent=1, ensure_ascii=False) s = out["summary"] print("documents %d, with history %d" % (s["documents"], s["with_history"])) print("a) v3 content == v1 content for all: %s" % s["a_all_returned"]) print("b) v3 has no return_id for all: %s" % s["b_all_v3_without_return"]) print("c) distinct v3 instants: %d %s (one batch? %s)" % (len(s["c_distinct_v3_instants"]), s["c_distinct_v3_instants"], s["c_is_one_instant"])) print("d) every publication pins the v1 sha: %s" % s["d_all_publications_pin_v1"]) print("refutations of the single-batch reading: %s" % (s["refutations"] or "none")) print("publication records straddling the cut instant: %d of %d" % (len(s["publications_spanning_the_cut"]), len(cand))) for d in cand: print(" %-58s v3 %s ret=%s pub=%s" % (d["path"], d["chain"][-1]["sha"], d["chain"][-1]["return_id"], [p["sha"] for p in d["publications"]])) return 0 if __name__ == "__main__": sys.exit(main())