#!/usr/bin/env python3 """Build the #1459-audit return's verification plan and its fingerprint. Field set note, learned the hard way in this run (see #1459): the server normalises a submitted plan to the plan schema's own field set before hashing it, and the observed canonical set across three accepted returns is exactly assumptions, availability, checker, claim, command, comparison, cost, coverage, coverage_md, environment, expected, inputs, manifest, schema_version, scope, supports, targets, tools so this builder emits exactly those keys and nothing else. `method` and `target_sha256` are NOT plan fields; carrying them made a correct implementation of the published fingerprint rule disagree with the recorded value. Fingerprint rule (protocol v1): sha256("solveathome-verification-v1" + "\\n" + compact JSON, recursively sorted object keys, array order preserved, `cost` excluded). """ import hashlib import json import os HERE = os.path.dirname(os.path.abspath(__file__)) RUN = os.path.dirname(HERE) ART = os.path.join(RUN, "artifacts", "job2818c") def sha(p): h = hashlib.sha256() with open(p, "rb") as f: for chunk in iter(lambda: f.read(1 << 20), b""): h.update(chunk) return h.hexdigest() def fingerprint(plan): body = {k: v for k, v in plan.items() if k != "cost"} def sort(o): if isinstance(o, dict): return {k: sort(o[k]) for k in sorted(o)} if isinstance(o, list): return [sort(x) for x in o] return o s = json.dumps(sort(body), separators=(",", ":"), ensure_ascii=False) return hashlib.sha256(("solveathome-verification-v1\n" + s).encode()).hexdigest() FILES = [ (os.path.join(HERE, "verify-2818c.py"), "verify-2818c.py", "checker"), (os.path.join(HERE, "verify-2818c.json"), "verify-2818c.json", "target"), (os.path.join(HERE, "check-1459-repro.py"), "check-1459-repro.py", "dependency"), (os.path.join(HERE, "check-1459-repro.json"), "check-1459-repro.json", "dependency"), (os.path.join(ART, "report.md"), "report.md", "input"), (os.path.join(ART, "recipe.md"), "recipe.md", "input"), (os.path.join(ART, "research.json"), "research.json", "input"), ] manifest = [{"path": name, "role": role, "sha256": sha(path)} for path, name, role in FILES] checker = next(m["sha256"] for m in manifest if m["role"] == "checker") TARGET = next(m for m in manifest if m["role"] == "target") plan = { "schema_version": 1, "claim": ( "Return #1459's record is auditable from served bytes alone, and its primary gap is located: " "(1) the plan's target reproduces BYTE-EXACTLY from the plan's own manifest -- 25 files " "fetched by pinned sha, the plan's checker exits 0 and emits 5002 raw bytes hashing to " "504cb9e1a5fa62a299060bbe896f157f99067c01bc869b4dd160cb4f6720cf2d, which is the sha the " "return records for check-2818b.json, with verdict ok true and failed_claims []; (2) exactly " "one file NAME in the return carries two revisions, reps-reflect.jsonl as bc5d0fb1... " "(9000 B, the manifest's) and e882ed95... (9342 B, the served one), and the pinned blob is a " "strict byte prefix of the other, the single added row being n=12, R=528, seed 2, sym " "reflect, kInfeasible, 11573 nodes, 46.241 s; (3) reading the file list by name instead of " "from the plan changes the target to 5030 bytes / 5fa033d8... and FAILS the byte-exact " "comparison while the verdict is unchanged, so the pin is reading-dependent in its digest " "but not in its claims; (4) the filed analysis artifact analysis-reps.json is not derivable " "from the record at all -- recorded f93bc231... (20310 B), rebuilt as 5b44fa4b... (20497 B) " "under the plan manifest and the file-list-first reading and d76f31e8... (20819 B) under the " "file-list-last reading, because the log file grew twice after the analyzer ran and the " "record holds only the last two states; (5) the pinned target digest is CRLF-specific " "(4754 bytes and c7bac388... with LF endings), so a POSIX worker cannot reproduce the pin " "from identical output; and (6) #1459's own fingerprint disclosure is withdrawn as wrong -- " "the published rule applied to the SERVED plan reproduces 0543d324... exactly, and the " "disagreement came from two non-schema fields (`method`, `target_sha256`) the server drops." ), "scope": ( "One return's record: #1459, its verification_plan, its 28-entry files array and its " "content-addressed blobs in this project's store, read during this run. Nothing is asserted " "about the mathematical content of the route-144 proposal, about other returns, or about " "whether the audited package's claims are true beyond what its own checker recomputes." ), # TYPE, learned from a validation refusal on the first filing of this plan: # HTTP 400 "verification_plan.assumptions must be nonempty text, at most 4000 characters" # `assumptions` is TEXT, not a list of strings. Both accepted plans this run has read carry it # as a single string (plan-132.json 363 chars, plan-2818b.json 723 chars), which is what the # schema's own examples show; a three-element array is a plausible-looking shape the server # rejects. The three assumptions are therefore one paragraph. "assumptions": ( "GET /return/1459 and GET /files/ return this project's authoritative record and " "blobs; a download whose bytes do not hash to the requested sha is treated as unfetchable. " "The audited return is immutable while this audit runs, so its digests are stable. " "An interpreter with highspy is available for the audited plan's checker; the audit declares " "this requirement and refuses with exit 2 rather than reporting a false result without it." ), "manifest": manifest, "checker": checker, "inputs": [m["sha256"] for m in manifest if m["role"] != "target"], "environment": ( "Audited plan's checker: python3 with highspy (HiGHS 1.15.1) -- declared, because " "verify-2818b.py imports it. The checker verify-2818c.py itself is stdlib-only and takes " "--python naming that interpreter. Store access over HTTPS. No solver time is spent: the " "audited plan's checker re-solves two small LPs, which is its own cost, not this one's." ), "command": ( "python3 verify-2818c.py --python # writes verify-2818c.json" ), "expected": ( "Exit 0 and a verify-2818c.json byte-identical to sha256 " "35908dae3f7023555124c1c28ca72c19572473c9d00949ec448c33a16123dc66 (4422 bytes) with " "ok true and failed_claims []. Inside it: C1 the 25 manifest files fetched by pin, checker " "exit 0, target raw 5002 bytes at 504cb9e1... reproducing the recorded target, verdict ok " "true with no failed claims; C2 exactly one name carrying two revisions, one a strict byte " "prefix of the other, the prefix being the pinned one; C3 exactly one extra row, at n = 12; " "C4 none of the three readings reproducing the recorded analysis artifact, and the recorded " "artifact differing from the file-list-last reading; C5 the pinned digest differing from the " "LF-normalized digest of the same content, with 248 CRLFs counted; C6 the published rule " "reproducing the recorded fingerprint on the served plan, a stray key changing the digest, " "and both non-schema keys absent from the served plan. Runtime about 2 min." ), "supports": ( "It establishes that this record's primary gate is reproducible from the record itself, that " "one file name in it is ambiguous between two revisions, that the analysis artifact it files " "cannot be regenerated from anything it contains, and that its pinned target digest is " "newline-convention-specific. It does NOT establish that the route-144 proposal is wrong, " "that any number in the report is false, or that the audited package's six claims fail -- " "they recompute cleanly. It is not a check receipt on #1459's package." ), "coverage": "decisive", "coverage_md": ( "All 25 manifest entries of #1459 fetched and hash-verified (25/25, no skips). All three " "readings of the file set executed: plan manifest, file list by first revision per name, " "file list by last revision per name. Both of the return's own instruments run in each " "reading where they apply, with binary captures. The two revisions of the one duplicated " "name both downloaded and compared byte-wise. The nine differences between the filed " "analysis artifact and the plan-manifest rebuild enumerated in full. Claim 6's verdict, the " "report's n = 12 reflection block and the recorded fingerprint each checked against every " "reading, not a sample. Exclusions: no attempt is made to infer the analysis-time snapshot " "of the log set, which the record does not contain; no other return is audited." ), "comparison": ( "Exact byte equality for every digest, with no tolerance: sha256 of fetched and rebuilt " "bytes against the shas the record itself records. The one place a tolerance is not " "applicable is stated rather than assumed -- the target pin is compared in raw bytes AND in " "LF-normalized bytes, and both values are reported, because the pin is CRLF-specific and a " "POSIX worker legitimately computes the other one." ), "availability": { "status": "complete", "details": "All required files are in the manifest; the audited record's 28 blobs are in the " "project store and were fetched here. The audit needs network access to the store.", "required_sources": [], "network": True, }, "targets": [TARGET["path"]], "tools": ["python3", "highspy"], "cost": {"minutes": 2, "judgment_minutes": 20, "cpu_hours": 0.05, "ram_gb": 2, "disk_gb": 1}, } fp = fingerprint(plan) print("plan keys:", len(plan), sorted(plan)) print("plan fingerprint:", fp) with open(os.path.join(ART, "plan-2818c.json"), "w", encoding="utf-8", newline="\n") as fh: json.dump(plan, fh, indent=1, sort_keys=True, ensure_ascii=False) fh.write("\n") print("wrote artifacts/job2818c/plan-2818c.json")