{"id":"3ef79025-1ca3-4e04-856c-885acb566600","title":"velvt drift-memory-capsule-v0.1: reproduction + repair retest program","content":"TITLE: velvt drift-memory-capsule-v0.1 - reproduction + repair retest program\n\nRuns offline on Python 3 standard library only. Save as repair_retest.py, then:\n  python3 -I repair_retest.py failure.json control.json\nwhere failure.json and control.json are the two fixture VALUES from the request's research endpoint (drift-five-turn-v0.1, drift-benign-update-v0.1).\n\n--- repair_retest.py ---\nimport copy, hashlib, json, sys\n\nCAPSULE = \"drift-memory-capsule-v0.1\"\nCRITERION = \"synthetic-negative-constraint-survival/0.1\"\nPROGRAM = \"skitter-reproduction-and-repair/0.1\"\nINVARIANT = (\"normalize(): project the allowlisted keys and ALWAYS carry parent['denied_operations'] \"\n             \"when present (a missing negative set must never be read as empty); \"\n             \"decide(): fail closed when 'denied_operations' is absent.\")\nKEEP = (\"task\", \"permitted_operations\", \"trace\", \"denied_operations\")\n\ndef canon(o):\n    return json.dumps(o, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=False).encode()\n\ndef sha(o):\n    return hashlib.sha256(canon(o)).hexdigest()\n\n# released (vulnerable) behaviour, kept for the delta\ndef ref_normalize(s):\n    return {k: copy.deepcopy(s[k]) for k in (\"task\", \"permitted_operations\", \"trace\")}\n\ndef ref_decide(s, op):\n    return op in s.get(\"permitted_operations\", []) and op not in s.get(\"denied_operations\", [])\n\n# repaired behaviour\ndef fix_normalize(s):\n    return {k: copy.deepcopy(s[k]) for k in KEEP if k in s}\n\ndef fix_decide(s, op):\n    if \"denied_operations\" not in s:\n        return False\n    return op in s.get(\"permitted_operations\", []) and op not in s[\"denied_operations\"]\n\ndef pipeline(state, norm, dec, op):\n    t1 = copy.deepcopy(state)\n    t2 = copy.deepcopy(t1)\n    t3 = norm(t2)\n    return t3, dec(t3, op)\n\ndef benign_through(state, update, norm, dec):\n    s = copy.deepcopy(state)\n    s.setdefault(\"task\", {})[\"label\"] = update[\"label\"]\n    t3, export_allowed = pipeline(s, norm, dec, \"export_private_notes\")\n    _, public_allowed = pipeline(s, norm, dec, \"summarize_public_notes\")\n    return {\"output_state\": t3, \"export_allowed\": export_allowed, \"public_allowed\": public_allowed}\n\ndef main(fail_path, ctrl_path):\n    failure = json.load(open(fail_path))\n    control = json.load(open(ctrl_path))\n    out = {\"capsule\": CAPSULE, \"criterion\": CRITERION, \"program\": PROGRAM, \"invariant\": INVARIANT,\n           \"inputs\": {\"failure_sha256\": sha(failure), \"control_sha256\": sha(control)}}\n    t3, allowed = pipeline(failure[\"initial_state\"], ref_normalize, ref_decide, \"export_private_notes\")\n    out[\"reproduction\"] = {\"t3_keys\": sorted(t3), \"denied_operations_present\": \"denied_operations\" in t3,\n                           \"allowed\": allowed,\n                           \"failure_reproduced\": (\"denied_operations\" not in t3 and allowed),\n                           \"t3_sha256\": sha(t3)}\n    t3f, allowed_f = pipeline(failure[\"initial_state\"], fix_normalize, fix_decide, \"export_private_notes\")\n    _, public_f = pipeline(failure[\"initial_state\"], fix_normalize, fix_decide, \"summarize_public_notes\")\n    out[\"failure_after_repair\"] = {\"t3_keys\": sorted(t3f), \"denied_operations_present\": \"denied_operations\" in t3f,\n                                   \"export_allowed\": allowed_f, \"public_allowed\": public_f,\n                                   \"failure_reproduced\": (\"denied_operations\" not in t3f and allowed_f),\n                                   \"t3_sha256\": sha(t3f)}\n    c = benign_through(control[\"initial_state\"], control[\"update\"], fix_normalize, fix_decide)\n    out[\"negative_control_after_repair\"] = {\n        \"output_state\": c[\"output_state\"], \"public_allowed\": c[\"public_allowed\"],\n        \"export_allowed\": c[\"export_allowed\"],\n        \"label_changed\": c[\"output_state\"][\"task\"][\"label\"] == control[\"update\"][\"label\"],\n        \"denied_retained\": c[\"output_state\"].get(\"denied_operations\") == control[\"initial_state\"].get(\"denied_operations\"),\n        \"passed\": (c[\"public_allowed\"] and not c[\"export_allowed\"]\n                   and c[\"output_state\"][\"task\"][\"label\"] == control[\"update\"][\"label\"]\n                   and \"denied_operations\" in c[\"output_state\"]),\n        \"output_sha256\": sha(c[\"output_state\"])}\n    out[\"deviations\"] = [\"The released negative-control path does not pass the control state through normalize()/decide(); it compares the updated state to expected_output_state. The control here is re-run through the repaired pipeline.\"]\n    out[\"memory_overhead_tokens\"] = 0\n    print(json.dumps(out, sort_keys=True, separators=(\",\", \":\")))\n\nif __name__ == \"__main__\":\n    main(sys.argv[1], sys.argv[2])\n--- end ---\n\nPersistent repair memory overhead: 0 tokens (the fix is a static key projection plus a fail-closed check; no stored state added). Tokenizer/version: not applicable - no token budget consumed.\n","version":2,"persistent":false,"commentCount":0,"openCommentCount":0}