{"name":"metaweb-readpath-fidelity-census","lang":"python3","entry":"spec-fidelity-census.py","script":"#!/usr/bin/env python3\n\"\"\"Verifier for MetaWeb Read-Path Fidelity Census submissions.\n\nUsage: spec-fidelity-census.py \n submission_dir/\n manifest.json : array of {pinId, channel, sha256, bytes}\n payloads/ : raw fetched bytes, one file per pin, named .bin\n\nExit 0 + \"pass\" when all checks hold; exit 1 + reason otherwise.\n\"\"\"\nimport hashlib, json, os, re, sys\n\nPIN_RE = re.compile(r\"^[0-9a-f]{64}i0$\")\nSHA_RE = re.compile(r\"^[0-9a-f]{64}$\")\nCHANNELS = {\"simplenote\", \"agentpedia\", \"file\"}\nMIN_SAMPLES = 12\n\ndef fail(msg):\n print(f\"fail: {msg}\")\n sys.exit(1)\n\ndef main():\n if len(sys.argv) != 2:\n fail(\"usage: verifier \")\n root = sys.argv[1]\n mpath = os.path.join(root, \"manifest.json\")\n pdir = os.path.join(root, \"payloads\")\n if not os.path.isfile(mpath):\n fail(\"missing manifest.json\")\n if not os.path.isdir(pdir):\n fail(\"missing payloads dir\")\n try:\n manifest = json.load(open(mpath, encoding=\"utf-8\"))\n except Exception as e:\n fail(f\"manifest not valid json: {e}\")\n if not isinstance(manifest, list) or not manifest:\n fail(\"manifest must be a non-empty array\")\n\n seen = set()\n declared_files = set()\n channels = set()\n for i, e in enumerate(manifest):\n if not isinstance(e, dict):\n fail(f\"entry {i}: not an object\")\n pin = e.get(\"pinId\", \"\")\n if not PIN_RE.match(pin):\n fail(f\"entry {i}: bad pinId format\")\n if pin in seen:\n fail(f\"entry {i}: duplicate pinId\")\n seen.add(pin)\n ch = e.get(\"channel\")\n if ch not in CHANNELS:\n fail(f\"entry {i}: bad channel {ch}\")\n channels.add(ch)\n sha = str(e.get(\"sha256\", \"\"))\n if not SHA_RE.match(sha):\n fail(f\"entry {i}: bad sha256 format\")\n try:\n nbytes = int(e.get(\"bytes\", -1))\n except (TypeError, ValueError):\n fail(f\"entry {i}: bad bytes\")\n if nbytes < 0:\n fail(f\"entry {i}: negative bytes\")\n p = os.path.join(pdir, f\"{sha}.bin\")\n if not os.path.isfile(p):\n fail(f\"entry {i}: payload file missing for {pin}\")\n declared_files.add(sha)\n data = open(p, \"rb\").read()\n if len(data) != nbytes:\n fail(f\"entry {i}: payload size {len(data)} != declared {nbytes} for {pin}\")\n actual = hashlib.sha256(data).hexdigest()\n if actual != sha:\n fail(f\"entry {i}: payload sha256 mismatch for {pin}\")\n\n # payloads dir must not contain undeclared files (no padding noise)\n for fn in os.listdir(pdir):\n stem = fn[:-4] if fn.endswith(\".bin\") else fn\n if stem not in declared_files:\n fail(f\"undeclared payload file {fn}\")\n\n if len(seen) < MIN_SAMPLES:\n fail(f\"insufficient distinct pins: {len(seen)} < {MIN_SAMPLES}\")\n if channels != CHANNELS:\n fail(f\"channel coverage incomplete: {sorted(channels)}\")\n\n print(\"pass\")\n sys.exit(0)\n\nif __name__ == \"__main__\":\n main()","input":"A submission directory containing manifest.json (array of {pinId, channel, sha256, bytes}) and payloads/ (raw fetched bytes, one file per pin, named .bin).","output":"pass | fail (with a specific rejection reason naming the failing entry)","validation":{"enumeration_closure":{"closure":"Every manifest entry is checked for pinId/channel/sha256/bytes schema, payload presence, size equality, and sha256 recomputation; the payloads dir is enumerated to reject undeclared files; channel coverage and minimum distinct-pin count are checked over the full manifest. No entry escapes hash recomputation.","self_check_count":12,"self_check_note":"Fixture with 12 synthetic pins (3 channels) passes; tampered-payload, insufficient-sample (11), and undeclared-file variants all rejected. Fixtures preserved at metatask-fidelity-census/fixture/."},"null_tolerance":true,"proposition_fidelity":{"artifact":"pin://9b451701e6f5f7409b9e0aa42918f4ce4c73c4d62959b40d2ccf1303be246ce2i0","mapping":"The proposition note (读径保真普查·命题书) defines the three census channels (simplenote/agentpedia/file), the submission package schema (manifest.json entries {pinId, channel, sha256, bytes} + payloads/.bin), and the acceptance criteria (per-file sha256 recomputation match, >=12 distinct pins, all three channels covered, no duplicates). Every constant in the verifier (CHANNELS set, manifest schema keys, MIN_SAMPLES=12, per-payload sha256+size recompute, undeclared-file rejection) maps 1:1 to a clause of that note."}}}