diff --git a/research/r2-mutation-path-copy/BENCHMARK.json b/research/r2-mutation-path-copy/BENCHMARK.json new file mode 100644 index 0000000000..f7c881bcf0 --- /dev/null +++ b/research/r2-mutation-path-copy/BENCHMARK.json @@ -0,0 +1,529 @@ +{ + "medians": { + "deepcopy": { + "copy_seconds": 25.60302174699973, + "peak_rss_bytes": 145297408, + "process_wall_seconds": 32.72503985499861, + "wall_seconds": 32.64346357699833 + }, + "marshal": { + "copy_seconds": 2.9076751109969337, + "peak_rss_bytes": 149024768, + "process_wall_seconds": 10.362188835002598, + "wall_seconds": 10.289205339999171 + }, + "paths": { + "copy_seconds": 0.060811052990175085, + "peak_rss_bytes": 141721600, + "process_wall_seconds": 6.15445384800114, + "wall_seconds": 6.084435974000371 + } + }, + "method": "Fresh sequential processes, alternating order; OS caches not flushed; shared host; all modes include identical provider-immutability guards", + "platform": "Linux-7.2.8-200.fc44.x86_64-x86_64-with-glibc2.43", + "python": "3.12.14 (main, Sep 1 2026, 14:16:52) [Clang 22.1.3 ]", + "ratios_over_paths": { + "deepcopy": { + "copy_seconds": 421.02579199107555, + "peak_rss_bytes": 1.0252312138728323, + "process_wall_seconds": 5.31729389206926, + "wall_seconds": 5.365076354897697 + }, + "marshal": { + "copy_seconds": 47.81491140215433, + "peak_rss_bytes": 1.0515317919075144, + "process_wall_seconds": 1.6836894208521944, + "wall_seconds": 1.6910697037435114 + } + }, + "rounds": 3, + "samples": [ + { + "copy_seconds": 25.730824466994818, + "mode": "deepcopy", + "peak_rss_bytes": 144760832, + "process_wall_seconds": 32.94600622099824, + "round": 0, + "wall_seconds": 32.87209109399919 + }, + { + "copy_seconds": 2.912796247004735, + "mode": "marshal", + "peak_rss_bytes": 148713472, + "process_wall_seconds": 10.41908028999751, + "round": 0, + "wall_seconds": 10.342444756999612 + }, + { + "copy_seconds": 0.059031542998127406, + "mode": "paths", + "peak_rss_bytes": 141828096, + "process_wall_seconds": 6.180534723000164, + "round": 0, + "wall_seconds": 6.111956741999165 + }, + { + "copy_seconds": 0.060811052990175085, + "mode": "paths", + "peak_rss_bytes": 141328384, + "process_wall_seconds": 6.092865478996828, + "round": 1, + "wall_seconds": 6.03050831499786 + }, + { + "copy_seconds": 2.907188296008826, + "mode": "marshal", + "peak_rss_bytes": 149024768, + "process_wall_seconds": 10.303831997996895, + "round": 1, + "wall_seconds": 10.234093772000051 + }, + { + "copy_seconds": 25.200280708995706, + "mode": "deepcopy", + "peak_rss_bytes": 145367040, + "process_wall_seconds": 32.26522838300298, + "round": 1, + "wall_seconds": 32.187639046002005 + }, + { + "copy_seconds": 2.9076751109969337, + "mode": "marshal", + "peak_rss_bytes": 149438464, + "process_wall_seconds": 10.362188835002598, + "round": 2, + "wall_seconds": 10.289205339999171 + }, + { + "copy_seconds": 0.06454552500144928, + "mode": "paths", + "peak_rss_bytes": 141721600, + "process_wall_seconds": 6.15445384800114, + "round": 2, + "wall_seconds": 6.084435974000371 + }, + { + "copy_seconds": 25.60302174699973, + "mode": "deepcopy", + "peak_rss_bytes": 145297408, + "process_wall_seconds": 32.72503985499861, + "round": 2, + "wall_seconds": 32.64346357699833 + } + ], + "scope": "Complete retained PR3218/PR3202 R2 audit, including all 32 mutants; producer generation excluded", + "semantic_identity": { + "adapter_sha256": "f72c7b24ff72c0a39eb1d849ae41d20f4e67471cc5cd1dd3183257008bc86169", + "call_multiset_sha256": "e39f695f2e4f1ca106fb3479417b795d691b8488dc2b37edd087e0ab8e54811f", + "decisions": { + "accepted": 244, + "calls": 253, + "rejected": 9 + }, + "executed_audit_sha256": "f7807c29ca4276603a2d3278eb7bf781345e10d3c7bac442a8c4755fa5bf1702", + "executed_replay_sha256": "0eac322c453937a366666d5837405fb67c6bea8a174ad6f5948d8f2444ec0aef", + "providers": { + "base": { + "mutants": [ + "forward fan-in sign", + "dual fan-in sign", + "rank-two child undercharge", + "tail phase substitution", + "wrapper side", + "dual wrapper owner", + "post wrappers before cleanup", + "source exit frame", + "missing dirty restoration", + "extra fan-in observer", + "prefix wrong source frame", + "native global phase", + "native translation", + "native child rank", + "residual global phase", + "residual translation" + ], + "original_unchanged": true, + "write_footprints": [ + { + "deep_leaf": true, + "name": "forward fan-in sign", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 16137 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "dual fan-in sign", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "backward", + 16137 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "rank-two child undercharge", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 15950 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "tail phase substitution", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 15864 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "wrapper side", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 22552 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "dual wrapper owner", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "backward", + 6264 + ], + "root": "data" + }, + { + "deep_leaf": false, + "name": "post wrappers before cleanup", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward" + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "source exit frame", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 16660 + ], + "root": "data" + }, + { + "deep_leaf": false, + "name": "missing dirty restoration", + "path": [ + "restore" + ], + "root": "word" + }, + { + "deep_leaf": true, + "name": "extra fan-in observer", + "path": [ + "restore", + 180 + ], + "root": "word" + }, + { + "deep_leaf": true, + "name": "prefix wrong source frame", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 8504 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native global phase", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native translation", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native child rank", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "residual global phase", + "path": [ + "RESIDUAL-ADAPTERS.json", + "recipes", + "0:250" + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "residual translation", + "path": [ + "RESIDUAL-ADAPTERS.json", + "recipes", + "0:250" + ], + "root": "data" + } + ] + }, + "extra": { + "mutants": [ + "forward fan-in sign", + "dual fan-in sign", + "rank-two child undercharge", + "tail phase substitution", + "wrapper side", + "dual wrapper owner", + "post wrappers before cleanup", + "source exit frame", + "missing dirty restoration", + "extra fan-in observer", + "prefix wrong source frame", + "native global phase", + "native translation", + "native child rank", + "residual global phase", + "residual translation" + ], + "original_unchanged": true, + "write_footprints": [ + { + "deep_leaf": true, + "name": "forward fan-in sign", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 16137 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "dual fan-in sign", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "backward", + 16137 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "rank-two child undercharge", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 15950 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "tail phase substitution", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 15864 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "wrapper side", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 22552 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "dual wrapper owner", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "backward", + 6264 + ], + "root": "data" + }, + { + "deep_leaf": false, + "name": "post wrappers before cleanup", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward" + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "source exit frame", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 16660 + ], + "root": "data" + }, + { + "deep_leaf": false, + "name": "missing dirty restoration", + "path": [ + "restore" + ], + "root": "word" + }, + { + "deep_leaf": true, + "name": "extra fan-in observer", + "path": [ + "restore", + 180 + ], + "root": "word" + }, + { + "deep_leaf": true, + "name": "prefix wrong source frame", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 8504 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native global phase", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native translation", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native child rank", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "residual global phase", + "path": [ + "RESIDUAL-ADAPTERS.json", + "recipes", + "0:250" + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "residual translation", + "path": [ + "RESIDUAL-ADAPTERS.json", + "recipes", + "0:250" + ], + "root": "data" + } + ] + } + }, + "reference_result_sha256": "e059aa7e91a658e4bbf4d0b15be0bde7e3896c99aefb162e06e1003c1d220eb2", + "source_sha256": { + "research/clifford-state-performance/fast_state.py": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5", + "research/frontier1094-recipes-exact-seed76/clifford.py": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb", + "research/packed-clifford-gate-tables/adapter.py": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599", + "research/r2-mutation-path-copy/vendor/pr1939/fast_copy.py": "311ac249835bd96fce5409b4397c7c7021db894b06f6509ccd2c85fb76fb1ca4", + "research/r2-mutation-path-copy/vendor/pr3218/BENCHMARK.json": "90ae0715021df52c7c716ef2ffb74386b1e70acded5f2abc81a45e4072d81d84", + "research/r2-mutation-path-copy/vendor/pr3218/NOTICE.md": "33c4a32374a1cb2ca216a7a769204e858c59f0bc0771dcfc16448fdcd7ec183c", + "research/r2-mutation-path-copy/vendor/pr3218/PROOF.md": "2c13a9f072f4d6b7d438fa6f8b19953bab5dee038b4d6f1bf4f8cc385af92030", + "research/r2-mutation-path-copy/vendor/pr3218/README.md": "2ae64f8138fc245e92eb4a561893c0175bfd5c85fcef35c5f09c2e30070a9119", + "research/r2-mutation-path-copy/vendor/pr3218/RESULT.json": "455e4745548ad70a261e0b20cf097d2a7be26fa7cb6840a7e2cd028a438d1f55", + "research/r2-mutation-path-copy/vendor/pr3218/SOURCES.json": "5eb09e1a5865c7d408dec6f071c69323418a80a9b499a4c446c67d07bc179076", + "research/r2-mutation-path-copy/vendor/pr3218/TASK.json": "1856eb1949392e2da352fcde4587ee280fd495052d9af77f3f74b3e4c2b8f9b5", + "research/r2-mutation-path-copy/vendor/pr3218/VERIFY.json": "ee52aff937c87194d34e7075460f3240d05210648966cf71420b61509999b0ab", + "research/r2-mutation-path-copy/vendor/pr3218/benchmark.py": "132c2e7d7244b40528937a6506d1e5cdcae8809416a25457f888f97c5ac0a431", + "research/r2-mutation-path-copy/vendor/pr3218/controls.py": "a12f5521e2ad5a496440eebc10bcfdef289b9ea2112823fe8549e642d266085c", + "research/r2-mutation-path-copy/vendor/pr3218/engine.py": "5f57804b7b7c3b1d8d2ceeefc41e199504f4d60c39e84df887fa6b3cd66b8b71", + "research/r2-mutation-path-copy/vendor/pr3218/replay.py": "aa7911d8b36add5c803c299ae3709bb15ba26142707dabca909a5f96796928df", + "research/r2-mutation-path-copy/vendor/pr3218/test_package.py": "d1bfb4917c03397157d07e6a1b2321bc2bb110454b0ccb256bd0937bb9451db4", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/README.md": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/RESULT.json": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/SOURCES.json": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CANONICAL-WORD.json.gz": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/verify.py": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "research/r2-mutation-path-copy/vendor/pr3218/verify.py": "74f86e4ccbf6246b004ffc001f750aa8b2755cda249d344552289bd5aca7564b", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + } + } +} diff --git a/research/r2-mutation-path-copy/NOTICE.md b/research/r2-mutation-path-copy/NOTICE.md new file mode 100644 index 0000000000..6ab7627c4f --- /dev/null +++ b/research/r2-mutation-path-copy/NOTICE.md @@ -0,0 +1,32 @@ +# Attribution and retained sources + +New source-specific copier, integration, differential controls, benchmarks and +proof note: Tekalign (@tekuuu), with substantial OpenAI Codex assistance in +profiling, implementation, verification, measurements and writing. Apache-2.0. + +The complete 26-file PR3218 package is retained verbatim under `vendor/pr3218/` +at `a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b`. Its original notices, source +manifest, exact comparator, measurements and nested predecessor remain intact. +RETAINED.json records each original path, source commit, Git blob and SHA256. + +Credit 24kHandsome1201's PR3202 R2 audit and original sixteen mutation functions, +retained within PR3218 at `259043321323717b7e816d6be38ad5e1f0b69b4c`. +Sagar Thakrar/#1781 supplies the packed oracle and conventions; ywz65/#2638 and +Charles Bethin/#662 supply the existing table baseline and recurrences; the +original Clifford/native lineage supplies the established tableau/anchor +criterion. The exact comparator is unchanged from PR3218. + +jackmgaller/#1939 supplies the checked marshal deepcopy function, retained +verbatim in `vendor/pr1939/fast_copy.py` from main +`463113d675af7410ac91d53a4fed51ec6494eb9a`. Its credited function body is +executed unchanged as the stronger copy baseline. Its original disclosure of +Claude Code assistance is preserved. This package does not claim a new marshal +copying technique or priority for path copying and structural sharing. + +The construction retains Nick Petalas/#3044, Jeremy Kothe, Marius-Paul Dumitrean, +Hiroki Kumazaki, Cinna Davis, Ali Romman and the full native/geometry/ownership +lineage credited in the nested notices and README. Concurrent PR3208's R2 +cleanup and PR3209's T16 reader cache are complementary, not imported results. + +No independent human or proof-assistant review is claimed. Source packages and +new contributions retain the repository's Apache-2.0 license. diff --git a/research/r2-mutation-path-copy/PROFILE.json b/research/r2-mutation-path-copy/PROFILE.json new file mode 100644 index 0000000000..be38174f6d --- /dev/null +++ b/research/r2-mutation-path-copy/PROFILE.json @@ -0,0 +1,128 @@ +{ + "scope": "cProfile diagnostic runs, not speedup measurements; substantial instrumentation overhead", + "before_source": "PR3218 a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b, mode anchor", + "after_source": "adapter.py with path copies and unchanged current comparator", + "profiles": { + "before": { + "total_seconds": 109.39922301800003, + "function_calls": 256951720, + "selected_functions": [ + { + "file": "verify.py", + "line": 449, + "function": "compute", + "primitive_calls": 1, + "calls": 1, + "self_seconds": 0.020029737000000002, + "cumulative_seconds": 109.39185010700001 + }, + { + "file": "verify.py", + "line": 372, + "function": "failure_controls", + "primitive_calls": 2, + "calls": 2, + "self_seconds": 0.56227939, + "cumulative_seconds": 106.909299473 + }, + { + "file": "copy.py", + "line": 118, + "function": "deepcopy", + "primitive_calls": 254, + "calls": 36504144, + "self_seconds": 47.456459573000004, + "cumulative_seconds": 99.61880939800001 + }, + { + "file": "verify.py", + "line": 181, + "function": "bind_events", + "primitive_calls": 20, + "calls": 20, + "self_seconds": 1.369627767, + "cumulative_seconds": 6.574994988 + }, + { + "file": "verify.py", + "line": 78, + "function": "span", + "primitive_calls": 372952, + "calls": 372952, + "self_seconds": 2.9129395700000003, + "cumulative_seconds": 3.010841177 + } + ] + }, + "after": { + "total_seconds": 9.324821739999997, + "function_calls": 10868858, + "adapter_sha256": "f72c7b24ff72c0a39eb1d849ae41d20f4e67471cc5cd1dd3183257008bc86169", + "selected_functions": [ + { + "file": "verify.py", + "line": 450, + "function": "compute", + "primitive_calls": 1, + "calls": 1, + "self_seconds": 0.021441498, + "cumulative_seconds": 9.276306046 + }, + { + "file": "verify.py", + "line": 181, + "function": "bind_events", + "primitive_calls": 20, + "calls": 20, + "self_seconds": 1.2722759160000001, + "cumulative_seconds": 6.616102567 + }, + { + "file": "verify.py", + "line": 372, + "function": "failure_controls", + "primitive_calls": 2, + "calls": 2, + "self_seconds": 0.0038014010000000003, + "cumulative_seconds": 6.242023634000001 + }, + { + "file": "verify.py", + "line": 78, + "function": "span", + "primitive_calls": 372952, + "calls": 372952, + "self_seconds": 2.961353962, + "cumulative_seconds": 3.0591000740000003 + }, + { + "file": "adapter.py", + "line": 26, + "function": "fixture_guard", + "primitive_calls": 4, + "calls": 4, + "self_seconds": 4.2881000000000005e-05, + "cumulative_seconds": 0.423341866 + }, + { + "file": "adapter.py", + "line": 109, + "function": "copy", + "primitive_calls": 32, + "calls": 32, + "self_seconds": 0.000651441, + "cumulative_seconds": 0.11414694900000001 + }, + { + "file": "copy.py", + "line": 118, + "function": "deepcopy", + "primitive_calls": 218, + "calls": 30008, + "self_seconds": 0.035153880000000005, + "cumulative_seconds": 0.07746348700000001 + } + ] + } + } +} diff --git a/research/r2-mutation-path-copy/PROOF.md b/research/r2-mutation-path-copy/PROOF.md new file mode 100644 index 0000000000..314873ecd3 --- /dev/null +++ b/research/r2-mutation-path-copy/PROOF.md @@ -0,0 +1,148 @@ +# Mutation isolation for the exact retained R2 caller + +This package changes the construction of mutable fault-injection fixtures in +24kHandsome1201's PR3202 audit, as retained by Tekalign's PR3218 comparator +adapter. It does not change a mathematical predicate, native operator or +mutation function. Path copying and structural sharing are established +programming techniques; their discovery is not claimed here. + +## Precise domain + +The source pins are PR3218 `a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b` +and its retained PR3202 `259043321323717b7e816d6be38ad5e1f0b69b4c`. +Every retained file and live dependency is authenticated before execution in a +private snapshot. The original strict JSON parser constructs the fixtures. +Lists and dictionaries therefore form trees: there are no cycles or repeated +mutable container references. Immutable numbers, strings and keys may repeat. +This is a contract of these actual fixtures, not of arbitrary Python objects. + +The original `reject` helper copies the complete word and data, calls one of +sixteen mutation functions, requires a nonvacuous change, and runs its original +predicate. It accepts the control only when that predicate raises the exact +specified `ValueError` message. Both providers execute all sixteen controls. + +## Write-footprint table + +`adapter.plan` selects the same first matching record as each literal original +mutation. Actual selected indices and keys are recorded for both providers in +RESULT.json. No optimizer-selected replacement mutation is substituted. + +| Original mutation | Isolated object | Required copy at that object | +|---|---|---| +| forward fan-in sign | first matching forward scalar event | entire event subtree | +| dual fan-in sign | first matching backward scalar event | entire event subtree | +| rank-two child undercharge | first matching forward cleanup climb | entire event subtree | +| tail phase substitution | forward cleanup-tail phase event | entire event subtree | +| wrapper side | first forward post-wrapper event | entire event subtree | +| dual wrapper owner | first backward pre-wrapper event | entire event subtree | +| post wrappers before cleanup | forward event list | outer list only | +| source exit frame | forward source-40 exit adapter event | entire event subtree | +| missing dirty restoration | word's restore list | outer list only | +| extra fan-in observer | restore gate 180 | entire gate subtree | +| prefix wrong source frame | first forward climb with nonzero old frame | entire event subtree | +| native global phase | selected W-to-FULL child record | entire record subtree | +| native translation | same child record | entire record subtree | +| native child rank | same child record | entire record subtree | +| residual global phase | first sorted residual recipe | entire record subtree | +| residual translation | same residual recipe | entire record subtree | + +The post-wrapper mutation extracts a slice, deletes that slice and inserts it +earlier in the same list. It never edits the event cells. The missing-restore +mutation only pops the outer list. Both may therefore share their untouched +children with the original fixture. All other selected subtrees are fully +deep-copied, including the nested scalar operands or monomial fields. + +## Path-copy lemma + +Let T be a finite tree of plain lists, dictionaries and immutable scalars. +Choose one container at path p. Copy each ancestor container shallowly and +replace its selected child with the recursively copied child. At p, either +deep-copy the entire subtree, or shallow-copy only that container when the +mutation changes its slots without changing any descendant. + +Before mutation, the resulting value equals T. Every container the mutation +can write is fresh, and all shared containers are outside the write footprint. +Applying the same mutation to this value and to a complete deepcopy produces +equal complete values and leaves T unchanged. This follows by induction along +p: the selected child is replaced in a fresh ancestor, and every other child +retains its original value. At the leaf, deep isolation or the restricted +outer-container write contract gives the required disjointness. + +This lemma does not hold for arbitrary aliased object graphs. An alias outside +p could refer to the modified leaf, and a general deepcopy would preserve that +alias inside its copy. This package does not expose a general deepcopy adapter. +Unknown mutation names fail; extending the sixteen-source-function contract +requires new pins, write-footprint review and complete differential checks. + +## Why the original decisions are preserved + +The pinned predicates use the fixtures' values and builtin types, not container +identity. `frame_boundaries`, `bind_events` and `expected_tail` build their own +state, cursors, sections and outputs. `restore_control` retains its own original +small deepcopy before reconstructing the old gate sequence. Native checking +constructs circuits and uses the unchanged PR3218 exact comparator; it does not +write the input records. These are source-specific read-only obligations, not a +claim about all future audit functions. + +Consequently the path-copy lemma supplies the same nonvacuity comparison and +the same predicate input values as full deepcopy. The exact original predicate +and named-error check still execute. All 32 actual optimized mutant payloads +are additionally compared with the original mutation applied to a complete +deepcopy. This comparison examines the entire word and data with Python value +equality, not just the changed field or a receipt digest. The differential mode +is intentionally slower and is part of the registered verification command. + +Every complete execution also serializes each original fixture before its +audit and after all its controls, comparing the complete bytes exactly. This +uses pickle protocol 5 only on trusted in-memory JSON trees; no pickle is loaded. +The comparison is within one process, not a cross-version certificate or hash +acceptance test. A persistent unplanned write into a shared original cell fails +this guard. The written footprint argument supplies isolation; the guard is a +second failure detector, not a proof for arbitrary future mutation code. + +## Source-bound integration and measurements + +The new wrapper retains PR3218 byte-for-byte and installs four unique hooks in +its private PR3202 verifier: replace the two whole-fixture copies; observe the +mutated payload; begin an original-fixture guard; end that guard. It also adds +the callback bindings in a private copy of PR3218's wrapper. Mutation bodies, +predicates, complete receipt comparison, native comparator and source bindings +are unchanged. Each hook must occur exactly once. Executed source hashes are +recorded separately from the retained originals. + +All three timing modes execute these same hooks and guards. The only copy +choice is original deepcopy, jackmgaller/#1939's unchanged checked-marshal +function, or the new path copier. The credited function is extracted by AST +from its authenticated source; its CLI monkeypatch and assertion requirement +are not invoked. No process-global `copy.deepcopy` replacement occurs. + +BENCHMARK.json compares complete results, original-fixture return, every +mutation name/write footprint, and all actual circuit-pair decisions. It uses +nine fresh serial processes in alternating order. Peak RSS covers each whole +process. Timings are local observations without a CI threshold. All modes +exclude native artifact generation and include source authentication, snapshots +and the added fixture guards. They do not measure integer multiplication. + +Full deepcopy visits every mutable fixture descendant for each mutation. Path +copying visits ancestor containers and the selected leaf, plus the original +record-selection scan. It still copies an event list's outer pointer array; +this is not a constant-time persistent-array implementation. All original +event/frame calculations remain. No predicate result or acceptance is cached. + +## Verification boundary + +The executable controls cover 100 deterministic generated tree/path cases +(seed 21), whole-list splicing, the credited full copier's alias preservation, +shallow nested-write leakage, an out-of-footprint write, a wrong complete mutant, +an unknown mutation, invalid leaf type and three corrupted hook locations. +Separate source-corruption tests change the retained checker, exact comparator +and live packed kernel. Optimized Git-free exports exercise the complete audit. + +The tree lemma is a written argument; the complete 32-case differential replay +is finite evidence for this source integration. Neither is a proof-kernel +verification of the multiplication theorem. PR3202/3218's full native-prefix, +physical-owner, precision/tape, recursive implementation and supplier/outer +obligations remain outside this package. Concurrent PR3208 separately audits +R2 cleanup; no coverage or speedup for that caller is claimed here. + +Tekalign (@tekuuu), with substantial OpenAI Codex assistance. Apache-2.0. diff --git a/research/r2-mutation-path-copy/README.md b/research/r2-mutation-path-copy/README.md new file mode 100644 index 0000000000..83bd14c9e0 --- /dev/null +++ b/research/r2-mutation-path-copy/README.md @@ -0,0 +1,146 @@ +# Faster complete R2 verification through mutation-path isolation + +The retained R2 audit spends most of its remaining time copying entire fixtures +for tests that modify a single event, recipe or gate. This opt-in adapter +reduces complete-audit median runtime from **32.643 to 6.084 seconds (5.37x)** +while running every original mutation and rejection predicate. Against +jackmgaller/#1939's existing checked-marshal copier on the same workload, +the improvement is **10.289 to 6.084 seconds (1.69x)**. + +This is verification tooling. It does not improve kappa, change a native +operator, certify a supplier or implement recursive integer multiplication. +Path copying is an established technique; the contribution is its source-bound +integration, isolation argument and complete differential verification for this +current caller. + +## Measured bottleneck and result + +After PR3218's exact-comparator improvement, cProfile attributes 99.6 of 109.4 +profiled seconds to deepcopy. Those figures include profiling overhead and are +used only to locate the bottleneck. [PROFILE.json](PROFILE.json) records that +diagnosis and the remaining source/event work. + +The following measurements are unprofiled, with three fresh serial CPython +3.12.14 processes per mode, alternating order on the same Linux host: + +| Copy mode | Mutation-copy median | Complete-audit median | Peak RSS median | +|---|---:|---:|---:| +| Original deepcopy | 25.603 s | 32.643 s | 138.57 MiB | +| Credited checked marshal | 2.908 s | 10.289 s | 142.12 MiB | +| Mutation paths | **0.061 s** | **6.084 s** | **135.16 MiB** | + +Whole-audit runtime falls by about **81%** versus deepcopy and **41%** versus +checked marshal. The roughly 421x improvement in the copy interval is not a +whole-audit speedup. Memory differences are modest local observations. + +[BENCHMARK.json](BENCHMARK.json) retains all nine raw samples, full-process +timings/RSS, exact source and adapter hashes, the complete original result's digest, +mutation footprints and circuit-decision digests. All modes include identical +snapshot authentication and original-fixture guards. OS caches were not +flushed; the host was shared; no timing threshold is imposed by CI. + +All runs execute **32 semantic mutants** and the same **253 operator decisions +(244 accepted, 9 rejected)**. Native artifact generation is excluded. The +current PR3218 exact comparator and all original event/frame calculations are +unchanged. No acceptance result or predicate outcome is cached. + +## What changes, and why the checks remain meaningful + +For each literal mutation, the adapter copies the containers leading to the +affected event, recipe or gate, then deep-copies that small subtree. The two +mutations that only splice/pop an outer list copy just that list and its +ancestors. Other cells remain read-only and shared. This avoids repeatedly +walking millions of unrelated descendant objects. + +The [proof](PROOF.md) lists all sixteen write footprints and derives the +tree-copy equivalence. This applies to the original strict-JSON fixtures and +pinned read-only predicates; it is not a generic deepcopy replacement for +arbitrary aliased graphs. Unknown mutation names and changed hook locations +fail explicitly. Every complete run compares the original fixture's full +serialized bytes before and after its audit and mutation tests. + +The registered verifier additionally applies each original mutation to a +complete deepcopy and compares the **entire resulting word and data** with +the optimized mutant. It checks all 32 actual cases, not just changed fields +or rejection counts. The original mutation bodies, nonvacuity check, predicate +and exact rejection-message check remain executable. This differential check +deliberately pays for full copying and is slower than normal accelerated use. + +The new controls also cover 100 generated tree/path equivalences (seed 21), +outer-list splicing, nested-write leakage, an unexpected write outside the +footprint, incorrect complete payloads, unknown mutations and malformed source +hooks. Three source-corruption controls and optimized Git-free replay check +the export/invalidation boundary. These are finite implementation checks, +not formal verification of the full multiplication theorem. + +## Reproduce + +From the repository root, with Python 3.12 and the standard library: + +```sh +python3.12 -B scripts/research_package.py --package research/r2-mutation-path-copy +``` + +Expected: `PASS_R2_PATH_COPY mutants=32 complete_deepcopy_equivalence=32 decisions=253`, +`PASS_R2_PATH_COPY_EXPORT`, and `PASS_REGISTERED_RESEARCH_PACKAGE ... outcome=completed`. +The registered command includes the intentionally expensive differential check. + +Normal accelerated complete audit, without regenerating any artifact: + +```sh +python3 -I -B research/r2-mutation-path-copy/replay.py +``` + +Use `--mode deepcopy` or `--mode marshal` for the comparison modes; +`--differential` adds complete actual-mutant comparison. An optional +`--output FRESH.json` writes a full receipt. To repeat the benchmark: + +```sh +python3.12 -I -B research/r2-mutation-path-copy/benchmark.py \ + --rounds 3 --output /tmp/r2-mutation-benchmark-fresh.json +``` + +Measured replay and RSS support Linux/macOS. Pickle protocol 5 is used only to +serialize trusted in-memory fixtures for exact within-process comparison; no +pickle data is loaded and no cross-version pickle certificate is required. + +## Source boundary, related work and next steps + +Base: `463113d675af7410ac91d53a4fed51ec6494eb9a`, priority revision 6. +Pending PR3218: `a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b`. +Its nested PR3202: `259043321323717b7e816d6be38ad5e1f0b69b4c`. +The entire predecessor package and checked-marshal source are retained verbatim. +[RETAINED.json](RETAINED.json) records all 27 original paths, commits, blobs and +hashes; [SOURCES.json](SOURCES.json) pins thirteen live inputs and historical +orientation records. All 40 retained/live files are authenticated before use. +Replay works without Git or pending foreign commit objects. + +The private source transformations replace only mutation-copy construction and +add observation/immutability callbacks. Executed source hashes are recorded +separately from the historical kernel field in the unchanged nested result. +The generic package checker validates main-history pins; the package's own +capture validates retained pending sources. Frozen/default commands and the +selected frontier remain unchanged. + +PR3208's separate R2 cleanup audit, PR3209's T16 reader cache and independent +host replication, and PR3219's Fano row-table work are complementary. This +package claims no coverage or timing result for those callers. Full native +prefix, physical ownership, precision/tape, efficient recursion and supplier/ +outer admission remain inherited or unestablished here. + +## Open next questions + +Profile another named audit before reusing this +approach; derive its actual write footprints and compare every mutant against +full deepcopy. In this R2 caller, unchanged source/frame/event reconstruction +now dominates. Any future reuse must retain type/rank checks and explicit +invalidation. [TASK.json](TASK.json) gives first steps and blockers. + +Credit 24kHandsome1201/#3202 for the audit, Tekalign/#3218 for the unchanged +comparator integration, jackmgaller/#1939 for the stronger copy baseline, +Sagar Thakrar/#1781, ywz65/#2638, Charles Bethin/#662 and the full retained +construction/native lineage in [NOTICE.md](NOTICE.md). New work by Tekalign +(@tekuuu), with substantial OpenAI Codex assistance. Apache-2.0; no independent +human or proof-kernel review is claimed. + +[Canonical investigation](https://github.com/CrocSwap/integer-mult-bounds/discussions/2612#discussioncomment-19002641). diff --git a/research/r2-mutation-path-copy/RESULT.json b/research/r2-mutation-path-copy/RESULT.json new file mode 100644 index 0000000000..9ba3e76238 --- /dev/null +++ b/research/r2-mutation-path-copy/RESULT.json @@ -0,0 +1,426 @@ +{ + "call_multiset_sha256": "e39f695f2e4f1ca106fb3479417b795d691b8488dc2b37edd087e0ab8e54811f", + "complete_mutants_compared_to_deepcopy": 32, + "controls": { + "credited_marshal_alias_isolation": true, + "generated_full_copy_equivalences": 100, + "leaked_nested_write_rejected": true, + "noncontainer_path_rejected": true, + "out_of_footprint_write_rejected": true, + "outer_list_splice": true, + "seed": 21, + "source_hook_mutants_rejected": 3, + "unknown_mutation_rejected": true, + "wrong_full_mutant_rejected": true + }, + "decisions": { + "accepted": 244, + "calls": 253, + "rejected": 9 + }, + "new_kappa": false, + "providers": { + "base": { + "mutants": [ + "forward fan-in sign", + "dual fan-in sign", + "rank-two child undercharge", + "tail phase substitution", + "wrapper side", + "dual wrapper owner", + "post wrappers before cleanup", + "source exit frame", + "missing dirty restoration", + "extra fan-in observer", + "prefix wrong source frame", + "native global phase", + "native translation", + "native child rank", + "residual global phase", + "residual translation" + ], + "original_unchanged": true, + "write_footprints": [ + { + "deep_leaf": true, + "name": "forward fan-in sign", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 16137 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "dual fan-in sign", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "backward", + 16137 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "rank-two child undercharge", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 15950 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "tail phase substitution", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 15864 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "wrapper side", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 22552 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "dual wrapper owner", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "backward", + 6264 + ], + "root": "data" + }, + { + "deep_leaf": false, + "name": "post wrappers before cleanup", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward" + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "source exit frame", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 16660 + ], + "root": "data" + }, + { + "deep_leaf": false, + "name": "missing dirty restoration", + "path": [ + "restore" + ], + "root": "word" + }, + { + "deep_leaf": true, + "name": "extra fan-in observer", + "path": [ + "restore", + 180 + ], + "root": "word" + }, + { + "deep_leaf": true, + "name": "prefix wrong source frame", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 8504 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native global phase", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native translation", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native child rank", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "residual global phase", + "path": [ + "RESIDUAL-ADAPTERS.json", + "recipes", + "0:250" + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "residual translation", + "path": [ + "RESIDUAL-ADAPTERS.json", + "recipes", + "0:250" + ], + "root": "data" + } + ] + }, + "extra": { + "mutants": [ + "forward fan-in sign", + "dual fan-in sign", + "rank-two child undercharge", + "tail phase substitution", + "wrapper side", + "dual wrapper owner", + "post wrappers before cleanup", + "source exit frame", + "missing dirty restoration", + "extra fan-in observer", + "prefix wrong source frame", + "native global phase", + "native translation", + "native child rank", + "residual global phase", + "residual translation" + ], + "original_unchanged": true, + "write_footprints": [ + { + "deep_leaf": true, + "name": "forward fan-in sign", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 16137 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "dual fan-in sign", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "backward", + 16137 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "rank-two child undercharge", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 15950 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "tail phase substitution", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 15864 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "wrapper side", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 22552 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "dual wrapper owner", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "backward", + 6264 + ], + "root": "data" + }, + { + "deep_leaf": false, + "name": "post wrappers before cleanup", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward" + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "source exit frame", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 16660 + ], + "root": "data" + }, + { + "deep_leaf": false, + "name": "missing dirty restoration", + "path": [ + "restore" + ], + "root": "word" + }, + { + "deep_leaf": true, + "name": "extra fan-in observer", + "path": [ + "restore", + 180 + ], + "root": "word" + }, + { + "deep_leaf": true, + "name": "prefix wrong source frame", + "path": [ + "LOCAL-PROGRAMS.json.gz", + "forward", + 8504 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native global phase", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native translation", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "native child rank", + "path": [ + "CLIFFORD-RECIPES.json", + "children", + 835 + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "residual global phase", + "path": [ + "RESIDUAL-ADAPTERS.json", + "recipes", + "0:250" + ], + "root": "data" + }, + { + "deep_leaf": true, + "name": "residual translation", + "path": [ + "RESIDUAL-ADAPTERS.json", + "recipes", + "0:250" + ], + "root": "data" + } + ] + } + }, + "reference_result_sha256": "e059aa7e91a658e4bbf4d0b15be0bde7e3896c99aefb162e06e1003c1d220eb2", + "source_sha256": { + "research/clifford-state-performance/fast_state.py": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5", + "research/frontier1094-recipes-exact-seed76/clifford.py": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb", + "research/packed-clifford-gate-tables/adapter.py": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599", + "research/r2-mutation-path-copy/vendor/pr1939/fast_copy.py": "311ac249835bd96fce5409b4397c7c7021db894b06f6509ccd2c85fb76fb1ca4", + "research/r2-mutation-path-copy/vendor/pr3218/BENCHMARK.json": "90ae0715021df52c7c716ef2ffb74386b1e70acded5f2abc81a45e4072d81d84", + "research/r2-mutation-path-copy/vendor/pr3218/NOTICE.md": "33c4a32374a1cb2ca216a7a769204e858c59f0bc0771dcfc16448fdcd7ec183c", + "research/r2-mutation-path-copy/vendor/pr3218/PROOF.md": "2c13a9f072f4d6b7d438fa6f8b19953bab5dee038b4d6f1bf4f8cc385af92030", + "research/r2-mutation-path-copy/vendor/pr3218/README.md": "2ae64f8138fc245e92eb4a561893c0175bfd5c85fcef35c5f09c2e30070a9119", + "research/r2-mutation-path-copy/vendor/pr3218/RESULT.json": "455e4745548ad70a261e0b20cf097d2a7be26fa7cb6840a7e2cd028a438d1f55", + "research/r2-mutation-path-copy/vendor/pr3218/SOURCES.json": "5eb09e1a5865c7d408dec6f071c69323418a80a9b499a4c446c67d07bc179076", + "research/r2-mutation-path-copy/vendor/pr3218/TASK.json": "1856eb1949392e2da352fcde4587ee280fd495052d9af77f3f74b3e4c2b8f9b5", + "research/r2-mutation-path-copy/vendor/pr3218/VERIFY.json": "ee52aff937c87194d34e7075460f3240d05210648966cf71420b61509999b0ab", + "research/r2-mutation-path-copy/vendor/pr3218/benchmark.py": "132c2e7d7244b40528937a6506d1e5cdcae8809416a25457f888f97c5ac0a431", + "research/r2-mutation-path-copy/vendor/pr3218/controls.py": "a12f5521e2ad5a496440eebc10bcfdef289b9ea2112823fe8549e642d266085c", + "research/r2-mutation-path-copy/vendor/pr3218/engine.py": "5f57804b7b7c3b1d8d2ceeefc41e199504f4d60c39e84df887fa6b3cd66b8b71", + "research/r2-mutation-path-copy/vendor/pr3218/replay.py": "aa7911d8b36add5c803c299ae3709bb15ba26142707dabca909a5f96796928df", + "research/r2-mutation-path-copy/vendor/pr3218/test_package.py": "d1bfb4917c03397157d07e6a1b2321bc2bb110454b0ccb256bd0937bb9451db4", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/README.md": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/RESULT.json": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/SOURCES.json": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CANONICAL-WORD.json.gz": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/verify.py": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "research/r2-mutation-path-copy/vendor/pr3218/verify.py": "74f86e4ccbf6246b004ffc001f750aa8b2755cda249d344552289bd5aca7564b", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + "status": "PASS_R2_PATH_COPY" +} diff --git a/research/r2-mutation-path-copy/RETAINED.json b/research/r2-mutation-path-copy/RETAINED.json new file mode 100644 index 0000000000..e84052627f --- /dev/null +++ b/research/r2-mutation-path-copy/RETAINED.json @@ -0,0 +1,193 @@ +{ + "files": [ + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/BENCHMARK.json", + "sha256": "90ae0715021df52c7c716ef2ffb74386b1e70acded5f2abc81a45e4072d81d84", + "git_blob": "dcb0857727c3af4ab0d35cc34338e78fa5c52eb4", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/BENCHMARK.json" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/NOTICE.md", + "sha256": "33c4a32374a1cb2ca216a7a769204e858c59f0bc0771dcfc16448fdcd7ec183c", + "git_blob": "19f1706604315c59f47160a3512ce871e55c0638", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/NOTICE.md" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/PROOF.md", + "sha256": "2c13a9f072f4d6b7d438fa6f8b19953bab5dee038b4d6f1bf4f8cc385af92030", + "git_blob": "cb71e12328dd00c77f1e9d8be809b48c35e116c5", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/PROOF.md" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/README.md", + "sha256": "2ae64f8138fc245e92eb4a561893c0175bfd5c85fcef35c5f09c2e30070a9119", + "git_blob": "645731637c75898f2add5946ae278f028bb1390d", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/README.md" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/RESULT.json", + "sha256": "455e4745548ad70a261e0b20cf097d2a7be26fa7cb6840a7e2cd028a438d1f55", + "git_blob": "33c1d5bbf5a0054c7875e8ca755d02327ec5ee71", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/RESULT.json" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/SOURCES.json", + "sha256": "5eb09e1a5865c7d408dec6f071c69323418a80a9b499a4c446c67d07bc179076", + "git_blob": "4bb592d91e7887d6ee0f63a7548102c48e3f7a43", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/SOURCES.json" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/TASK.json", + "sha256": "1856eb1949392e2da352fcde4587ee280fd495052d9af77f3f74b3e4c2b8f9b5", + "git_blob": "aac896c2bc445a8d22419564e16b019b1776f5a8", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/TASK.json" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/VERIFY.json", + "sha256": "ee52aff937c87194d34e7075460f3240d05210648966cf71420b61509999b0ab", + "git_blob": "ddcd3a48c6e8f47caf0b564ff702e32103973ac3", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/VERIFY.json" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/benchmark.py", + "sha256": "132c2e7d7244b40528937a6506d1e5cdcae8809416a25457f888f97c5ac0a431", + "git_blob": "db469190bbb85eb2a7ac8806bb6e0a79be287bc9", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/benchmark.py" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/controls.py", + "sha256": "a12f5521e2ad5a496440eebc10bcfdef289b9ea2112823fe8549e642d266085c", + "git_blob": "be69a270f040f6ea57656a493b793a753210a369", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/controls.py" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/engine.py", + "sha256": "5f57804b7b7c3b1d8d2ceeefc41e199504f4d60c39e84df887fa6b3cd66b8b71", + "git_blob": "a34243c16b49f40f8db35b6389d05028ae7c99c4", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/engine.py" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/replay.py", + "sha256": "aa7911d8b36add5c803c299ae3709bb15ba26142707dabca909a5f96796928df", + "git_blob": "c1c31353fd7186ff27d06c8d07e2f3973080235f", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/replay.py" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/test_package.py", + "sha256": "d1bfb4917c03397157d07e6a1b2321bc2bb110454b0ccb256bd0937bb9451db4", + "git_blob": "d5722a70861b3e447e17346fcf372af295391f44", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/test_package.py" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/README.md", + "sha256": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "git_blob": "b05efddf13cb67c7db7b0612ac18b537811872c7", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/README.md" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/RESULT.json", + "sha256": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "git_blob": "87f87bc4bbc549611889a956f53a01c2dbd29d39", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/RESULT.json" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/SOURCES.json", + "sha256": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "git_blob": "71f2c61df0340a3e71d918fb371bc5e88eab3f13", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/SOURCES.json" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CANONICAL-WORD.json.gz", + "sha256": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "git_blob": "3958b8cf77b86b98d7a35ed0f4d2590f7de2b27f", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/CANONICAL-WORD.json.gz" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz", + "sha256": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "git_blob": "0591c6af1b744520e7f6a07303420c055ee9ae0e", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz", + "sha256": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "git_blob": "9ad65235dc846be16cddab2cf1839d24229de663", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz", + "sha256": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "git_blob": "3e154660a1ca7904703447280214a5c14957568f", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz", + "sha256": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "git_blob": "c2c7a69938dcb2b2cbd390739bc027447ed6cb4c", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz", + "sha256": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "git_blob": "887f5bfc36d382e81e2f945f5dcc5c1bf2be7233", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz", + "sha256": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "git_blob": "9ad65235dc846be16cddab2cf1839d24229de663", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz", + "sha256": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "git_blob": "3cb1e2927f406b18a635c6170ab73078b24b36e1", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/verify.py", + "sha256": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "git_blob": "0ed4963416541b4da6f1b726cba18dc737c66412", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/vendor/pr3202/verify.py" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr3218/verify.py", + "sha256": "74f86e4ccbf6246b004ffc001f750aa8b2755cda249d344552289bd5aca7564b", + "git_blob": "b4844357c0b36034cdf39104b367d95e0124a70e", + "source_commit": "a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b", + "source_path": "research/clifford-pauli-anchor/verify.py" + }, + { + "path": "research/r2-mutation-path-copy/vendor/pr1939/fast_copy.py", + "sha256": "311ac249835bd96fce5409b4397c7c7021db894b06f6509ccd2c85fb76fb1ca4", + "git_blob": "7f28c4e3076bf0d448ddbd7bd365560a21758fa1", + "source_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "source_path": "research/audit-allcold-fast-copy/fast_copy.py" + } + ] +} diff --git a/research/r2-mutation-path-copy/SOURCES.json b/research/r2-mutation-path-copy/SOURCES.json new file mode 100644 index 0000000000..2863575ac6 --- /dev/null +++ b/research/r2-mutation-path-copy/SOURCES.json @@ -0,0 +1,97 @@ +{ + "schema_version": 1, + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/clifford-state-performance/fast_state.py", + "usage": "input", + "git_blob": "5d546d8a05f6025d58a5133fa0d67ce134993013", + "sha256": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5" + }, + { + "path": "research/frontier1094-recipes-exact-seed76/clifford.py", + "usage": "input", + "git_blob": "6f1e6a38febde7eb7a7341d317522e6650d84408", + "sha256": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb" + }, + { + "path": "research/packed-clifford-gate-tables/adapter.py", + "usage": "input", + "git_blob": "b99342ac6e4853048a87cc9fa7d31caf998f9af0", + "sha256": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json", + "usage": "input", + "git_blob": "9b7c498ed6f92be5f1c4a85a1f25427788647fc1", + "sha256": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json", + "usage": "input", + "git_blob": "ff42fd06f9ede0e1a717766232e283005336f935", + "sha256": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz", + "usage": "input", + "git_blob": "51b0b3c912565b7e12b3a2f8a3c0ccd37290206b", + "sha256": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz", + "usage": "input", + "git_blob": "23915f0bec7533ce0658cac8c7ae2069873efe4b", + "sha256": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py", + "usage": "input", + "git_blob": "08248542b18864c94a5ac050c8669f68519838e1", + "sha256": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py", + "usage": "input", + "git_blob": "6d47f63ab7a533941b3881bbfd3ae4dac5f76932", + "sha256": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py", + "usage": "input", + "git_blob": "99f351785ebca5fbf3336bedcd7b48bac9c255e5", + "sha256": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py", + "usage": "input", + "git_blob": "82beaa9c1d13bcd5f79d0a5e10e8a10733eac347", + "sha256": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py", + "usage": "input", + "git_blob": "1ff29dfb244e2114de8e586a450ae9fb70308d58", + "sha256": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py", + "usage": "input", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + } + ], + "retained_manifest": "RETAINED.json" +} diff --git a/research/r2-mutation-path-copy/TASK.json b/research/r2-mutation-path-copy/TASK.json new file mode 100644 index 0000000000..03e1643071 --- /dev/null +++ b/research/r2-mutation-path-copy/TASK.json @@ -0,0 +1,122 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "priority_revision": 6, + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "original_card": { + "id": "replay-runtime", + "question": "Can one measured replay bottleneck be sped up without dropping coverage?", + "starting_points": [ + "scripts/run_isolated_tests.py", + "scripts/verify_replay_coverage.py", + "certificates/selected-result.json" + ], + "methods": [ + "Profile one isolated replay and optimize the measured bottleneck.", + "Design source-bound reuse with explicit dependency invalidation and negative controls." + ], + "acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the selected reproduction command and choose a single replay stage for profiling.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "allowed_variations": [ + "Profile one stage or design one source-bound cache boundary." + ], + "scope_change_triggers": [ + "Skipping coverage or comparing different fixtures to claim speedup." + ], + "overlap_terms": [ + "replay runtime", + "cache invalidation", + "isolated tests" + ] + }, + "scope_status": "refined", + "actual_scope": "Eliminate the measured whole-fixture deepcopy bottleneck in all 32 retained R2 semantic mutation tests with source-specific path copies; compare with unchanged deepcopy and the credited checked-marshal baseline.", + "scope_change_reason": "Explicit user optimization assignment follows PR3218 remaining-cost handoff. Profiling identified whole-fixture mutation copying as the dominant cost; the task does not change mathematical predicates or the comparator.", + "bottleneck_link": "Faster complete audits make the existing source/event/native failure checks cheaper to run and review without dropping mutants.", + "budget_minutes": 60, + "stop_rule": "Session 2026-10-17T18:23:43Z to 19:23:43Z; final 15 minutes for verification and handoff. Stop on any full-mutant, named-rejection, original-fixture-isolation or source-binding discrepancy. One exact two-provider caller only.", + "outcome": "completed", + "evidence": "BENCHMARK.json records nine fresh serial runs: 5.365x complete-audit speedup over deepcopy and 1.691x over the credited checked-marshal baseline. RESULT.json records all 32 complete mutant/deepcopy equalities, all original named rejections and 253 identical operator decisions. PROOF.md gives the source-specific write-footprint argument.", + "author": "Tekalign (@tekuuu)", + "ai_assistance": "Substantial OpenAI Codex assistance in profiling, implementation, proof, tests, benchmarking and writing; no independent human/proof-kernel review.", + "open_questions": [ + { + "question": "Can another current audit prove a similarly narrow mutation write footprint?", + "why_it_matters": "Large mutable fixtures can make fault injection more expensive than the actual predicates.", + "first_step": "Profile a named source-pinned caller, list actual mutation writes, compare every complete optimized mutant with original deepcopy, and benchmark against checked marshal.", + "blocked_by": "No generic alias-safe deepcopy replacement or other-caller speedup is established." + }, + { + "question": "Can the remaining R2 frame/event replay be accelerated without caching acceptance?", + "why_it_matters": "After eliminating fixture copies, repeated source/event reconstruction becomes the main cost.", + "first_step": "Profile the unchanged predicates, then prove any frame-value reuse preserves type/rank checks and complete invalidation.", + "blocked_by": "This package intentionally changes only mutation isolation; no event acceptance or frame cache is introduced." + } + ], + "assignment": { + "seed": 21, + "randomness": "operating-system CSPRNG via secrets.randbelow(100)", + "track": "verification engineering", + "override": "Explicit user request for substantial runtime optimization takes precedence over random track allocation." + }, + "candidates_considered": [ + { + "object": "R2 mutation fixture copying", + "decision": "chosen: 99.6 of 109.4 profiled seconds in deepcopy after PR3218" + }, + { + "object": "repeated binary spans", + "decision": "deferred: much smaller measured cost" + }, + { + "object": "larger PR3038 native-cone caller", + "decision": "deferred: preserve one completed current-fixture contribution" + } + ], + "coordination": { + "claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2612#discussioncomment-19002641", + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "priority_revision": 6, + "overlap": "Current PR3218 and PR3202 heads unchanged; #3209 reader cache and its macOS replication, #3219 Fano table work, and #3208 cleanup audit are distinct. #1939 checked marshal copy is incorporated as the stronger baseline. Initial all-PR/Discussion metadata used the prior dated complete snapshots plus fresh top-30 open PRs, open issues and last 12 central claims/handoffs; metadata scope is not a novelty certificate.", + "submission_refresh": { + "main": "463113d675af7410ac91d53a4fed51ec6494eb9a (unchanged after successful submission fetch; confirmed by 19:01 UTC)", + "coverage": { + "open_prs": { + "fetched_at": "2026-10-17T18:59:00.566426+00:00", + "complete_pagination": true, + "records": 284 + }, + "discussions": { + "fetched_at": "2026-10-17T19:00:51.622339+00:00", + "complete_pagination": true, + "records": 2059 + }, + "closed_prs": { + "fetched_at": "2026-10-17T19:01:49.491313+00:00", + "complete_pagination": true, + "records": 2630 + } + }, + "warnings": [], + "dependency_heads": "PR3218 a93c4f0bfcac21bf9c62c79728c8936e35ebbc3b and PR3202 259043321323717b7e816d6be38ad5e1f0b69b4c remain open, unchanged and without review/comments at refresh.", + "limits": "Complete pagination of PR titles/bodies and Discussion metadata; focused semantic inspection, not all code diffs or unpublished work." + } + }, + "validation": { + "registered_python312": "Both registered commands passed on CPython 3.12.14, including complete 32-case differential replay, original predicates, isolation controls and source-corruption/Git-free optimized replay.", + "python314": "CPython 3.14.7 Git-free optimized replay and controls passed; complete differential verification also passed with -I -O -B.", + "retained_sources": "All 27 retained files match exact git-show source bytes. BENCHMARK matches RESULT on all 40 input hashes, complete-result/circuit-decision digests, mutation names and footprints; measured adapter hash matches final code.", + "scope": "No native producer regeneration, new supplier/outer or selected cold replay; no new kappa. Benchmark is one shared Linux host." + } +} diff --git a/research/r2-mutation-path-copy/VERIFY.json b/research/r2-mutation-path-copy/VERIFY.json new file mode 100644 index 0000000000..8fca85056b --- /dev/null +++ b/research/r2-mutation-path-copy/VERIFY.json @@ -0,0 +1,43 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/clifford-state-performance/fast_state.py", + "research/frontier1094-recipes-exact-seed76/clifford.py", + "research/packed-clifford-gate-tables/adapter.py", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Complete original audit and all 32 actual mutant payloads compared with original deepcopy; exact receipts and 100 generated isolation checks plus failure controls." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 120, + "checks": "Three executable-source corruption controls and optimized complete audit/controls in a Git-free export with spaces." + } + ] +} diff --git a/research/r2-mutation-path-copy/adapter.py b/research/r2-mutation-path-copy/adapter.py new file mode 100644 index 0000000000..71cb1bb666 --- /dev/null +++ b/research/r2-mutation-path-copy/adapter.py @@ -0,0 +1,170 @@ +#!/usr/bin/env python3 +"""Source-specific mutation isolation for the retained PR3202 R2 audit. + +Tekalign (@tekuuu), substantial OpenAI Codex assistance, Apache-2.0. +Original controls: 24kHandsome1201. Checked marshal baseline: jackmgaller/#1939. +This is not a general replacement for deepcopy. +""" +import ast +import copy +import marshal +import pickle +import time + +CANON = 'CANONICAL-WORD.json.gz' +PROGRAM = 'LOCAL-PROGRAMS.json.gz' +RECIPES = 'CLIFFORD-RECIPES.json' +ADAPTERS = 'RESIDUAL-ADAPTERS.json' +W = [256, 128, 64, 34, 17, 11, 4] + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def fixture_guard(value): + # Trusted in-memory JSON trees only. No pickle data is ever loaded. + # Compare complete bytes within one process: no hash acceptance or portable + # pickle certificate is involved. All actual payload comparisons use ==. + return pickle.dumps(value, protocol=5) + + +def fork_path(value, path, deep_leaf=True): + """Copy ancestors of one write footprint; leave all other cells shared.""" + need(type(value) in (list, dict), 'path container') + if not path: + return copy.deepcopy(value) if deep_leaf else value.copy() + key, *rest = path + result = value.copy() + result[key] = fork_path(value[key], rest, deep_leaf) + return result + + +def plan(name, word, data): + """Literal write footprints of the pinned sixteen mutation functions.""" + if name == 'missing dirty restoration': + return 'word', ['restore'], False + if name == 'extra fan-in observer': + return 'word', ['restore', 180], True + if name == 'post wrappers before cleanup': + # The original mutation splices the outer list, never edits its events. + return 'data', [PROGRAM, 'forward'], False + event_plans = { + 'forward fan-in sign': ('forward', lambda e: e[:1] == ['scalar'] and + e[1] == ['add', ['L', 40], ['L', 54], -2, 1]), + 'dual fan-in sign': ('backward', lambda e: e[:1] == ['scalar'] and + e[1] == ['add', ['L', 54], ['L', 40], 2, 1]), + 'rank-two child undercharge': ('forward', lambda e: + e[:3] == ['climb', 'cleanup_tail', 54] and e[-1] == 2), + 'tail phase substitution': ('forward', lambda e: e == ['phase', 'cleanup_tail']), + 'wrapper side': ('forward', lambda e: e[:2] == ['residual_adapter', 'post']), + 'dual wrapper owner': ('backward', lambda e: e[:2] == ['residual_adapter', 'pre']), + 'source exit frame': ('forward', lambda e: e[:3] == ['adapter', 'new_to_old', 40]), + 'prefix wrong source frame': ('forward', lambda e: e[0] == 'climb' and e[3] != 0), + } + if name in event_plans: + orientation, select = event_plans[name] + index = next(i for i, event in enumerate(data[PROGRAM][orientation]) if select(event)) + return 'data', [PROGRAM, orientation, index], True + if name in ('native global phase', 'native translation', 'native child rank'): + wid = data[CANON]['frames'].index(W) + index = next(i for i, rec in enumerate(data[RECIPES]['children']) + if (rec['old'], rec['new']) == (wid, 1)) + return 'data', [RECIPES, 'children', index], True + if name in ('residual global phase', 'residual translation'): + key = sorted(data[ADAPTERS]['recipes'])[0] + return 'data', [ADAPTERS, 'recipes', key], True + raise ValueError('unrecognized pinned mutation: ' + name) + + +def checked_marshal_function(raw): + """Execute the unchanged credited function, without its CLI monkeypatch.""" + tree = ast.parse(raw) + nodes = [node for node in tree.body if isinstance(node, ast.FunctionDef) + and node.name == 'checked_deepcopy'] + need(len(nodes) == 1, 'unique credited marshal function') + namespace = {'marshal': marshal, '_original_deepcopy': copy.deepcopy, + 'STATS': {'marshal': 0, 'fallback': 0}} + exec(compile(ast.Module(body=nodes, type_ignores=[]), 'PR1939/checked_deepcopy', 'exec'), namespace) + return namespace['checked_deepcopy'], namespace['STATS'] + + +class Harness: + def __init__(self, mode, marshal_source, differential=False): + need(mode in ('deepcopy', 'marshal', 'paths'), 'copy mode') + self.mode, self.differential = mode, differential + self.marshal_copy, self.marshal_stats = checked_marshal_function(marshal_source) + self.copy_seconds = 0.0 + self.providers = {} + self.current = None + self._original_guard = None + + def begin(self, tag, word, data): + need(self.current is None and tag not in self.providers, 'provider lifecycle') + self.current = tag + self._original_guard = fixture_guard([word, data]) + self.providers[tag] = {'mutants': [], 'write_footprints': [], 'original_unchanged': False} + + def copy(self, name, word, data): + start = time.perf_counter() + root, path, deep = plan(name, word, data) + self.providers[self.current]['write_footprints'].append( + {'name': name, 'root': root, 'path': path, 'deep_leaf': deep}) + if self.mode == 'paths': + result = ((fork_path(word, path, deep), data) if root == 'word' + else (word, fork_path(data, path, deep))) + else: + copier = copy.deepcopy if self.mode == 'deepcopy' else self.marshal_copy + result = copier(word), copier(data) + self.copy_seconds += time.perf_counter() - start + return result + + def observe(self, name, mutate, w, d, word, data): + need(self.current is not None, 'mutant outside provider') + if self.differential: + # Original mutation callable, complete original deepcopy, full equality. + expected_w, expected_d = copy.deepcopy(word), copy.deepcopy(data) + mutate(expected_w, expected_d) + need(w == expected_w and d == expected_d, 'complete mutant differs: ' + name) + self.providers[self.current]['mutants'].append(name) + + def end(self, tag, word, data): + need(self.current == tag, 'provider end order') + row = self.providers[tag] + need(fixture_guard([word, data]) == self._original_guard, 'original fixture mutated') + need(len(row['mutants']) == 16 and len(set(row['mutants'])) == 16, 'complete mutant inventory') + row['original_unchanged'] = True + self.current = None + self._original_guard = None + + +def replace_once(text, old, new): + need(text.count(old) == 1, 'unique source hook: ' + old[:60]) + return text.replace(old, new) + + +def transform_audit(raw): + text = raw.decode() + text = replace_once(text, ' w, d = copy.deepcopy(word), copy.deepcopy(data)', + ' w, d = _copy_mutant(name, word, data)') + text = replace_once(text, ' mutate(w, d)', + ' mutate(w, d)\n _observe_mutant(name, mutate, w, d, word, data)') + text = replace_once(text, ' data = artifacts(blobs, tag, data_path)', + ' data = artifacts(blobs, tag, data_path)\n _begin_provider(tag, word, data)') + text = replace_once(text, " providers[tag]['rejected_controls'] = failure_controls(kernel, word, data)", + " providers[tag]['rejected_controls'] = failure_controls(kernel, word, data)\n" + ' _end_provider(tag, word, data)') + return text.encode() + + +def transform_replay(raw): + text = raw.decode() + point = " changed = text.replace(anchor, anchor + '\\n _install_comparator(kernel)').encode()" + text = replace_once(text, point, point + '\n changed = _transform_audit(changed)') + point = ' verifier._install_comparator = install' + text = replace_once(text, point, point + '\n verifier._copy_mutant = _harness.copy' + '\n verifier._observe_mutant = _harness.observe' + '\n verifier._begin_provider = _harness.begin' + '\n verifier._end_provider = _harness.end') + return text.encode() diff --git a/research/r2-mutation-path-copy/benchmark.py b/research/r2-mutation-path-copy/benchmark.py new file mode 100644 index 0000000000..e1d5e68bfe --- /dev/null +++ b/research/r2-mutation-path-copy/benchmark.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +"""Fresh serial same-fixture time and peak-RSS measurements; no timing gate. +Tekalign / OpenAI Codex, Apache-2.0. +""" +import argparse +import json +from pathlib import Path +import platform +import statistics +import subprocess +import sys +import tempfile +import time + +PACKAGE = Path(__file__).resolve().parent + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--rounds', type=int, default=3) + parser.add_argument('--output', type=Path, required=True) + args = parser.parse_args() + if args.output.exists() or not 1 <= args.rounds <= 9: + raise ValueError('fresh output and 1..9 rounds required') + samples, reference = [], None + orders = [('deepcopy', 'marshal', 'paths'), ('paths', 'marshal', 'deepcopy'), + ('marshal', 'paths', 'deepcopy')] + with tempfile.TemporaryDirectory(prefix='r2 mutation benchmark ') as directory: + for trial in range(args.rounds): + for mode in orders[trial % len(orders)]: + target = Path(directory) / f'{trial}-{mode}.json' + command = [sys.executable, '-I', '-B', str(PACKAGE / 'replay.py'), + '--mode', mode, '--output', str(target)] + start = time.perf_counter() + process = subprocess.run(command, capture_output=True, text=True, timeout=180) + wall = time.perf_counter() - start + if process.returncode: + raise ValueError(process.stdout + process.stderr) + result = json.loads(target.read_bytes()) + semantic = {k: result[k] for k in ('reference_result_sha256', 'call_multiset_sha256', + 'decisions', 'providers', 'source_sha256', 'adapter_sha256', + 'executed_replay_sha256', 'executed_audit_sha256')} + if reference is None: + reference = semantic + elif semantic != reference: + raise ValueError('different input, mutant footprints, decisions or complete receipt') + samples.append({'round': trial, 'mode': mode, 'process_wall_seconds': wall, + **{k: result[k] for k in ('wall_seconds', 'copy_seconds', 'peak_rss_bytes')}}) + print(process.stdout.strip(), flush=True) + fields = ('process_wall_seconds', 'wall_seconds', 'copy_seconds', 'peak_rss_bytes') + medians = {m: {k: statistics.median(r[k] for r in samples if r['mode'] == m) for k in fields} + for m in orders[0]} + result = {'python': sys.version, 'platform': platform.platform(), 'rounds': args.rounds, + 'scope': 'Complete retained PR3218/PR3202 R2 audit, including all 32 mutants; producer generation excluded', + 'method': 'Fresh sequential processes, alternating order; OS caches not flushed; shared host; all modes include identical provider-immutability guards', + 'semantic_identity': reference, 'samples': samples, 'medians': medians, + 'ratios_over_paths': {m: {k: medians[m][k] / medians['paths'][k] for k in fields} + for m in ('deepcopy', 'marshal')}} + with args.output.open('x') as stream: + json.dump(result, stream, indent=2, sort_keys=True) + stream.write('\n') + print('PASS_R2_MUTATION_BENCHMARK', json.dumps(result['ratios_over_paths'], sort_keys=True)) + + +if __name__ == '__main__': + main() diff --git a/research/r2-mutation-path-copy/controls.py b/research/r2-mutation-path-copy/controls.py new file mode 100644 index 0000000000..861efb760d --- /dev/null +++ b/research/r2-mutation-path-copy/controls.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +"""Path isolation, actual failure modes and source-hook controls. +Tekalign / OpenAI Codex, Apache-2.0. +""" +import copy +import json +from pathlib import Path +import random +import types + +PACKAGE = Path(__file__).resolve().parent + + +def load(name): + path = PACKAGE / (name + '.py') + module = types.ModuleType('path_copy_' + name) + module.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), module.__dict__) + return module + + +def check(): + A = load('adapter') + rng = random.Random(21) + def rejected(action, text): + try: + action() + except ValueError as error: + A.need(text in str(error), 'wrong control rejection: ' + str(error)) + else: + raise ValueError('control accepted: ' + text) + + for _ in range(100): + tree, path = {'payload': [[rng.randrange(-1000, 1001)], ['unicode \u03ba', 2 ** 90]]}, [] + for _ in range(rng.randrange(1, 6)): + if rng.randrange(2): + tree, path = {'target': tree, 'unchanged': [[7]]}, ['target'] + path + else: + tree, path = [tree, [[7]]], [0] + path + before = A.fixture_guard(tree) + expected, forked = copy.deepcopy(tree), A.fork_path(tree, path) + a, b = expected, forked + for key in path: + a, b = a[key], b[key] + a['payload'][0].append(42) + b['payload'][0].append(42) + A.need(forked == expected, 'nested full-copy equivalence') + A.need(A.fixture_guard(tree) == before, 'nested original changed') + + # Outer-list splice needs no mutable-event copy, but the event cells stay read-only. + original = {'stream': [[i, [i * i]] for i in range(7)]} + before = A.fixture_guard(original) + forked = A.fork_path(original, ['stream'], False) + expected = copy.deepcopy(original) + for value in (forked, expected): + block = value['stream'][3:-1] + del value['stream'][3:-1] + value['stream'][1:1] = block + A.need(forked == expected and A.fixture_guard(original) == before, 'splice isolation') + A.need(forked['stream'][0] is original['stream'][0], 'read-only sharing not exercised') + + marshal_raw = (PACKAGE / 'vendor/pr1939/fast_copy.py').read_bytes() + copier, counts = A.checked_marshal_function(marshal_raw) + shared = [] + source = [shared, shared] + copied = copier(source) + A.need(copied == source and copied[0] is copied[1] and copied[0] is not shared, + 'credited full-copy alias isolation') + A.need(counts['marshal'] == 1, 'credited marshal baseline executed') + + # A shallow event copy would leak its nested scalar write to the original. + word = {'restore': []} + data = {A.PROGRAM: {'forward': [['scalar', ['add', ['L', 40], ['L', 54], -2, 1]]]}} + H = A.Harness('paths', marshal_raw) + H.begin('control', word, data) + wrong = A.fork_path(data, [A.PROGRAM, 'forward', 0], False) + wrong[A.PROGRAM]['forward'][0][1][3] = 2 + rejected(lambda: H.end('control', word, data), 'original fixture mutated') + + # A future mutation outside the pinned footprint must fail the end guard. + word, data = {'restore': [], 'outside': [0]}, {A.PROGRAM: {'forward': [ + ['scalar', ['add', ['L', 40], ['L', 54], -2, 1]]]}} + H = A.Harness('paths', marshal_raw) + H.begin('control', word, data) + w, d = H.copy('forward fan-in sign', word, data) + w['outside'][0] = 1 + rejected(lambda: H.end('control', word, data), 'original fixture mutated') + + # An incorrect replacement payload must fail complete differential comparison. + word, data = {}, {'x': [0]} + H = A.Harness('paths', marshal_raw, differential=True) + H.begin('control', word, data) + def mutate(w, d): + d['x'][0] = 1 + rejected(lambda: H.observe('wrong payload', mutate, {}, {'x': [2]}, word, data), + 'complete mutant differs') + rejected(lambda: A.plan('future unknown mutation', {}, {}), 'unrecognized pinned mutation') + rejected(lambda: A.fork_path({'a': 1}, ['a']), 'path container') + + raw = (PACKAGE / 'vendor/pr3218/vendor/pr3202/verify.py').read_bytes() + point = b' w, d = copy.deepcopy(word), copy.deepcopy(data)' + rejected(lambda: A.transform_audit(raw.replace(point, b' w, d = word, data')), + 'unique source hook') + rejected(lambda: A.transform_audit(raw + b'\n' + point), 'unique source hook') + replay = (PACKAGE / 'vendor/pr3218/replay.py').read_bytes() + point = b' verifier._install_comparator = install' + rejected(lambda: A.transform_replay(replay.replace(point, b' pass')), 'unique source hook') + return {'seed': 21, 'generated_full_copy_equivalences': 100, + 'outer_list_splice': True, 'credited_marshal_alias_isolation': True, + 'leaked_nested_write_rejected': True, 'out_of_footprint_write_rejected': True, + 'wrong_full_mutant_rejected': True, 'unknown_mutation_rejected': True, + 'noncontainer_path_rejected': True, 'source_hook_mutants_rejected': 3} + + +if __name__ == '__main__': + print('PASS_PATH_COPY_CONTROLS', json.dumps(check(), sort_keys=True)) diff --git a/research/r2-mutation-path-copy/replay.py b/research/r2-mutation-path-copy/replay.py new file mode 100644 index 0000000000..5467d0cc29 --- /dev/null +++ b/research/r2-mutation-path-copy/replay.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +"""Complete PR3218 R2 replay with source-specific mutation-path copies. +Tekalign / OpenAI Codex, Apache-2.0. See NOTICE.md for retained-source credit. +""" +import argparse +import hashlib +import json +from pathlib import Path +import resource +import sys +import tempfile +import time +import types + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] +PRIOR = 'research/clifford-pauli-anchor/' +VENDOR = 'research/r2-mutation-path-copy/vendor/pr3218/' + + +def need(ok, message): + if not ok: + raise ValueError(message) + + +def digest(raw): + return hashlib.sha256(raw).hexdigest() + + +def load(raw, name, path, extra=None): + module = types.ModuleType(name) + module.__file__ = str(path) + module.__dict__.update(extra or {}) + exec(compile(raw, str(path), 'exec'), module.__dict__) + return module + + +def capture(root=ROOT): + retained = json.loads((PACKAGE / 'RETAINED.json').read_bytes())['files'] + source = json.loads((PACKAGE / 'SOURCES.json').read_bytes())['files'] + captured = {} + for row in retained + [r for r in source if r['usage'] == 'input']: + raw = (root / row['path']).read_bytes() + need(digest(raw) == row['sha256'], 'source drift: ' + row['path']) + blob = b'blob ' + str(len(raw)).encode() + b'\0' + raw + need(hashlib.sha1(blob, usedforsecurity=False).hexdigest() == row['git_blob'], 'source blob') + need(row['path'] not in captured, 'duplicate captured path') + captured[row['path']] = raw + need(len(captured) == 40, 'complete source inventory') + return captured + + +def run(mode='paths', differential=False): + start = time.perf_counter() + captured = capture() + adapter_raw = (PACKAGE / 'adapter.py').read_bytes() + A = load(adapter_raw, 'mutation_adapter', PACKAGE / 'adapter.py') + H = A.Harness(mode, captured['research/r2-mutation-path-copy/vendor/pr1939/fast_copy.py'], differential) + changed = A.transform_replay(captured[VENDOR + 'replay.py']) + with tempfile.TemporaryDirectory(prefix='r2 mutation snapshot ') as directory: + snapshot = Path(directory) + for name, raw in captured.items(): + target = snapshot / (PRIOR + name[len(VENDOR):] if name.startswith(VENDOR) else name) + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(raw) + R = load(changed, 'retained_anchor_replay', snapshot / PRIOR / 'replay.py', + {'_harness': H, '_transform_audit': A.transform_audit}) + result = R.run('anchor') + for tag, row in H.providers.items(): + need(row['mutants'] == result['reference_result']['providers'][tag]['rejected_controls'], + 'original rejection inventory') + need(H.current is None and set(H.providers) == {'base', 'extra'}, 'complete providers') + for name, raw in captured.items(): + path = snapshot / (PRIOR + name[len(VENDOR):] if name.startswith(VENDOR) else name) + need(path.read_bytes() == raw, 'snapshot file mutation') + peak = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss + return {'mode': mode, 'differential': differential, 'reference_result': result['reference_result'], + 'reference_result_sha256': result['reference_result_sha256'], + 'call_multiset_sha256': result['call_multiset_sha256'], 'decisions': result['calls'], + 'providers': H.providers, 'copy_seconds': H.copy_seconds, + 'wall_seconds': time.perf_counter() - start, + 'peak_rss_bytes': peak if sys.platform == 'darwin' else peak * 1024, + 'marshal_stats': H.marshal_stats, 'adapter_sha256': digest(adapter_raw), + 'executed_replay_sha256': digest(changed), + 'executed_audit_sha256': result['executed_verifier_sha256'], + 'source_sha256': {p: digest(b) for p, b in sorted(captured.items())}} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--mode', choices=('paths', 'deepcopy', 'marshal'), default='paths') + parser.add_argument('--differential', action='store_true') + parser.add_argument('--output', type=Path) + args = parser.parse_args() + need(args.output is None or not args.output.exists(), 'fresh output required') + result = run(args.mode, args.differential) + if args.output: + with args.output.open('x') as stream: + json.dump(result, stream, sort_keys=True, indent=2) + stream.write('\n') + print('PASS_R2_MUTATION_COPY', args.mode, 'differential=' + str(args.differential), + 'mutants=32', 'wall_seconds=' + str(round(result['wall_seconds'], 3))) + + +if __name__ == '__main__': + main() diff --git a/research/r2-mutation-path-copy/test_package.py b/research/r2-mutation-path-copy/test_package.py new file mode 100644 index 0000000000..4e0457361f --- /dev/null +++ b/research/r2-mutation-path-copy/test_package.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +"""Source corruption and Git-free optimized complete replay. +Tekalign / OpenAI Codex, Apache-2.0. +""" +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import types + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] + + +def main(): + manifest = json.loads((PACKAGE / 'SOURCES.json').read_bytes()) + with tempfile.TemporaryDirectory(prefix='r2 mutation export ') as directory: + root = Path(directory) + target = root / PACKAGE.relative_to(ROOT) + shutil.copytree(PACKAGE, target, ignore=shutil.ignore_patterns('__pycache__')) + for row in manifest['files']: + if row['usage'] == 'input': + path = root / row['path'] + path.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / row['path'], path) + R = types.ModuleType('exported_path_replay') + R.__file__ = str(target / 'replay.py') + exec(compile((target / 'replay.py').read_bytes(), R.__file__, 'exec'), R.__dict__) + original = R.capture() + for file in (target / 'vendor/pr3218/vendor/pr3202/verify.py', + target / 'vendor/pr3218/engine.py', + root / 'research/frontier1094-recipes-exact-seed76/clifford.py'): + raw = file.read_bytes() + file.write_bytes(raw + b'\n') + try: + R.capture() + except ValueError as error: + if 'source drift:' not in str(error): + raise + else: + raise ValueError('source corruption accepted') + file.write_bytes(raw) + if R.capture() != original or (root / '.git').exists(): + raise ValueError('clean restored export') + output = root / 'fresh.json' + commands = [ + [sys.executable, '-I', '-O', '-B', str(target / 'replay.py'), '--output', str(output)], + [sys.executable, '-I', '-O', '-B', str(target / 'controls.py')], + ] + for command in commands: + process = subprocess.run(command, cwd=root, capture_output=True, text=True, timeout=120) + if process.returncode: + raise ValueError(process.stdout + process.stderr) + actual, expected = json.loads(output.read_bytes()), json.loads((target / 'RESULT.json').read_bytes()) + for key in ('reference_result_sha256', 'call_multiset_sha256', 'decisions', 'providers', 'source_sha256'): + if actual[key] != expected[key]: + raise ValueError('optimized export result mismatch: ' + key) + print('PASS_R2_PATH_COPY_EXPORT source_corruptions=3 optimized_full_replay=1') + + +if __name__ == '__main__': + main() diff --git a/research/r2-mutation-path-copy/vendor/pr1939/fast_copy.py b/research/r2-mutation-path-copy/vendor/pr1939/fast_copy.py new file mode 100644 index 0000000000..7f28c4e307 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr1939/fast_copy.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +"""Opt-in launcher: run a pinned retained verifier with a checked C-level deepcopy. + +Usage (drop-in for `python3 -B RUN_PORTABLE SCRIPT ARGS...`): + + python3 -B fast_copy.py RUN_PORTABLE SCRIPT ARGS... + +Both RUN_PORTABLE and SCRIPT must match the SHA-256 allow-list below. The +pinned `run_portable.py` then runs SCRIPT exactly as it would without this +launcher. The only process change is `copy.deepcopy`: for a top-level dict or +list, the copy is `marshal.loads(marshal.dumps(x))`, accepted only if marshal +serializes the value (it refuses anything but core builtin types, including +dict/list subclasses) and the copy has the same type and compares equal. +Otherwise, and for every call with a `memo`, the original `copy.deepcopy` +runs. marshal (format 4) records repeated objects as back-references, so +aliasing inside the value is kept, as it is by deepcopy; every dict and list in +the copy is a new object. + +No verifier source is edited, no check or mutation control is skipped, and no +result is cached. Set FAST_COPY_STATS=PATH to write call counts as JSON +(stdout and stderr stay untouched, so stage logs remain byte-identical). + +jackmgaller with Claude Code (Claude Opus 5.5) assistance. Apache-2.0. +""" +import copy +import hashlib +import json +import marshal +import os +import runpy +import sys +from pathlib import Path + +if not __debug__: + raise RuntimeError('Assertions must remain enabled') + +# run_portable.py retained by research/complex-k492-owner-repair/vendor/multicold. +RUN_PORTABLE = {'322d29d43dbee8130cde15d4bf05396698b5e3dfe3735813899db91cc0ba7955'} +# audit_allcold.py of the selected PR1087 T16 replay (upstream1087.tar.gz code/) +# and of research/gauge44-slots-t16/code/ (the cold baseline1042 `t16` stage). +SCRIPTS = {'1467a2acb654e62552c69fb9a7c4c85f70a02120881d222313865058ab71a6cc'} + +_original_deepcopy = copy.deepcopy +STATS = {'marshal': 0, 'fallback': 0} + + +def checked_deepcopy(x, memo=None, _nil=[]): + if memo is None and type(x) in (dict, list): + try: + y = marshal.loads(marshal.dumps(x)) + ok = type(y) is type(x) and y == x + except (ValueError, RecursionError): # unmarshallable, too deep or cyclic + ok = False + if ok: + STATS['marshal'] += 1 + return y + STATS['fallback'] += 1 + return _original_deepcopy(x) if memo is None else _original_deepcopy(x, memo, _nil) + + +def sha(path): + return hashlib.sha256(Path(path).read_bytes()).hexdigest() + + +def main(argv, copier=checked_deepcopy): + if len(argv) < 2: + raise SystemExit('usage: fast_copy.py RUN_PORTABLE SCRIPT ARGS...') + launcher, script = Path(argv[0]).resolve(), Path(argv[1]).resolve() + if sha(launcher) not in RUN_PORTABLE: + raise SystemExit('fast_copy: run_portable.py is not on the allow-list: ' + str(launcher)) + if sha(script) not in SCRIPTS: + raise SystemExit('fast_copy: script is not on the allow-list: ' + str(script)) + copy.deepcopy = copier + sys.argv = [str(launcher), *argv[1:]] + try: + runpy.run_path(str(launcher), run_name='__main__') + finally: + copy.deepcopy = _original_deepcopy + out = os.environ.get('FAST_COPY_STATS') + if out: + Path(out).write_text(json.dumps(STATS, sort_keys=True) + '\n') + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/research/r2-mutation-path-copy/vendor/pr3218/BENCHMARK.json b/research/r2-mutation-path-copy/vendor/pr3218/BENCHMARK.json new file mode 100644 index 0000000000..dcb0857727 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/BENCHMARK.json @@ -0,0 +1,138 @@ +{ + "medians": { + "anchor": { + "audit_wall_seconds": 31.100221754000813, + "equality_engine_seconds": 0.32612274498751503, + "process_wall_seconds": 31.162376325000878 + }, + "cached": { + "audit_wall_seconds": 37.46667832699859, + "equality_engine_seconds": 6.721224512994013, + "process_wall_seconds": 37.53124580500116 + }, + "packed": { + "audit_wall_seconds": 39.74438383100096, + "equality_engine_seconds": 9.774096749983073, + "process_wall_seconds": 39.808734207999805 + } + }, + "platform": "Linux-7.2.8-200.fc44.x86_64-x86_64-with-glibc2.43", + "processes": "fresh, sequential; alternating orders; OS caches not flushed; shared host", + "python": "3.12.14 (main, Sep 1 2026, 14:16:52) [Clang 22.1.3 ]", + "rounds": 3, + "samples": [ + { + "audit_wall_seconds": 41.48234724699978, + "equality_engine_seconds": 10.138834029015925, + "mode": "packed", + "process_wall_seconds": 41.551688278001166, + "round": 0 + }, + { + "audit_wall_seconds": 37.985246696000104, + "equality_engine_seconds": 6.860120718009057, + "mode": "cached", + "process_wall_seconds": 38.04833538599996, + "round": 0 + }, + { + "audit_wall_seconds": 32.14846472099998, + "equality_engine_seconds": 0.32612274498751503, + "mode": "anchor", + "process_wall_seconds": 32.21189399399918, + "round": 0 + }, + { + "audit_wall_seconds": 31.100221754000813, + "equality_engine_seconds": 0.3309641259984346, + "mode": "anchor", + "process_wall_seconds": 31.162376325000878, + "round": 1 + }, + { + "audit_wall_seconds": 37.46667832699859, + "equality_engine_seconds": 6.6524566870321, + "mode": "cached", + "process_wall_seconds": 37.53124580500116, + "round": 1 + }, + { + "audit_wall_seconds": 39.636854862999826, + "equality_engine_seconds": 9.752910248998887, + "mode": "packed", + "process_wall_seconds": 39.700494374999835, + "round": 1 + }, + { + "audit_wall_seconds": 36.88609559100041, + "equality_engine_seconds": 6.721224512994013, + "mode": "cached", + "process_wall_seconds": 36.94726072999947, + "round": 2 + }, + { + "audit_wall_seconds": 30.54571194900018, + "equality_engine_seconds": 0.3232460919844016, + "mode": "anchor", + "process_wall_seconds": 30.610115636000046, + "round": 2 + }, + { + "audit_wall_seconds": 39.74438383100096, + "equality_engine_seconds": 9.774096749983073, + "mode": "packed", + "process_wall_seconds": 39.808734207999805, + "round": 2 + } + ], + "scope": "Complete retained PR3202 two-provider audit; native generation and full supplier admission excluded", + "semantic_identity": { + "anchor_engine_sha256": "5f57804b7b7c3b1d8d2ceeefc41e199504f4d60c39e84df887fa6b3cd66b8b71", + "call_multiset_sha256": "e39f695f2e4f1ca106fb3479417b795d691b8488dc2b37edd087e0ab8e54811f", + "calls": { + "accepted": 244, + "calls": 253, + "rejected": 9 + }, + "reference_result_sha256": "e059aa7e91a658e4bbf4d0b15be0bde7e3896c99aefb162e06e1003c1d220eb2", + "source_sha256": { + "research/clifford-state-performance/fast_state.py": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5", + "research/frontier1094-recipes-exact-seed76/clifford.py": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb", + "research/packed-clifford-gate-tables/adapter.py": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599", + "research/pr3044-r2-native-slice/README.md": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "research/pr3044-r2-native-slice/RESULT.json": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "research/pr3044-r2-native-slice/SOURCES.json": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "research/pr3044-r2-native-slice/data/base/CANONICAL-WORD.json.gz": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "research/pr3044-r2-native-slice/data/base/CLIFFORD-RECIPES.json.gz": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "research/pr3044-r2-native-slice/data/base/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/pr3044-r2-native-slice/data/base/RESIDUAL-ADAPTERS.json.gz": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "research/pr3044-r2-native-slice/data/extra/CANONICAL-WORD.json.gz": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "research/pr3044-r2-native-slice/data/extra/CLIFFORD-RECIPES.json.gz": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "research/pr3044-r2-native-slice/data/extra/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/pr3044-r2-native-slice/data/extra/RESIDUAL-ADAPTERS.json.gz": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "research/pr3044-r2-native-slice/verify.py": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + } + }, + "speedup_over": { + "cached": { + "audit_wall_seconds": 1.2047077549271423, + "equality_engine_seconds": 20.609493254606704, + "process_wall_seconds": 1.2043768874869367 + }, + "packed": { + "audit_wall_seconds": 1.2779453518169253, + "equality_engine_seconds": 29.970607386974052, + "process_wall_seconds": 1.277461442376015 + } + } +} diff --git a/research/r2-mutation-path-copy/vendor/pr3218/NOTICE.md b/research/r2-mutation-path-copy/vendor/pr3218/NOTICE.md new file mode 100644 index 0000000000..19f1706604 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/NOTICE.md @@ -0,0 +1,34 @@ +# Attribution and retained sources + +New comparator, integration, controls, benchmark and documentation: Tekalign +(@tekuuu), with substantial OpenAI Codex assistance. Apache-2.0. + +`vendor/pr3202/` retains twelve files verbatim from 24kHandsome1201's +PR3202, commit `259043321323717b7e816d6be38ad5e1f0b69b4c`. Its original README, +code attribution, native receipts and source manifest are unchanged. These +files are necessary to replay the current R2 caller and its exact artifacts; +they are not newly generated native evidence. See `SOURCES.json` for every +source path, blob and SHA256 digest. The upstream repository's Apache-2.0 +license applies. + +Sagar Thakrar (@thakrarsagar), PR1781, supplies the separate packed exact +Clifford kernel and its gate conventions. The default packed oracle remains +unchanged. The comparator criterion (signed Pauli tableau plus one exact +column) is established Clifford algebra, also used by the retained native +producer; its discovery is not claimed here. Credit icekylinx, Jeremy Kothe, +Mason Hale and the original Clifford/native implementation lineage. + +ywz65, PR2638, supplies the existing opt-in cached-table packed comparator used +as a stronger benchmark baseline. Charles Bethin (@cbethin), PR662, supplies +its table recurrences. The new engine's bounded immutable table implementation +uses the same known binary recurrences, independently coded for this engine. +Ali Romman/#1029 and Tekalign/#2768 are predecessors for sparse exact state +evaluation and current native replay tooling, respectively. + +The R2 construction and its audits retain Nick Petalas/#3044, Jeremy Kothe, +Marius-Paul Dumitrean/#2979, Hiroki Kumazaki/#3146, Cinna Davis and the full +geometry, extraction, ownership and native lineage listed in the retained +README. This package does not assume independent approval of those sources. + +Substantial AI assistance was used for algebra, implementation, testing and +writing. No independent human or proof-assistant review is claimed. diff --git a/research/r2-mutation-path-copy/vendor/pr3218/PROOF.md b/research/r2-mutation-path-copy/vendor/pr3218/PROOF.md new file mode 100644 index 0000000000..cb71e12328 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/PROOF.md @@ -0,0 +1,153 @@ +# Exact Clifford equality from signed Pauli action and one anchor + +The complete criterion below is established Clifford algebra, already used by +the retained native producer's tableau and zero-column check. This package +does not claim its discovery. It implements the criterion separately for +Sagar Thakrar's PR1781 gate grammar, then substitutes that comparator into +24kHandsome1201's source-bound PR3202 audit. The intended contribution is +measured verification engineering, with exact coverage preserved. + +## Domain and conventions + +Basis labels are `x in F_2^n`, bit zero first. The implementation accepts +`1 <= n <= 9`; its current caller uses `n=9`. Gates are chronological: + +- `P(G)|x> = |Gx>` for an invertible binary row matrix `G`. +- `X(b)|x> = |x+b>`. +- `D(Q,a)|x> = i^q(x)|x>`, where + `q(x)=sum_j a_j x_j + 2 sum_{j = i^(p+2 z dot y)|y+x>`. +Its full phase modulo four is stored. Discarding that phase is unsound. + +## Signed conjugation rules + +The initial list consists of `X(e_j)` and `Z(e_j)` for every coordinate. +For each gate `A` replace every stored Pauli by `A W A^*`. Chronological +updates therefore produce the generator images under the complete word. + +| Gate | Updated `(p,x,z)` | +|---|---| +| `P(G)` | `(p, Gx, G^(-T)z)` | +| `X(b)` | `(p+2 z dot b, x, z)` | +| `PH(k)` | `(p,x,z)` | +| `D(Q,a)` | `(p+q(x), x, z+B x)` | +| `C(v,s)`, if `z dot v=0` | `(p,x,z)` | +| `C(v,s)`, if `z dot v=1` | `(p-s, x+v, z)` | + +Phases are reduced modulo four and binary coordinates modulo two. Here `B` +is symmetric with diagonal `a_j mod 2` and off-diagonal entries the strict +upper-triangle coefficients of `Q`, reflected across the diagonal. + +For the diagonal gate, direct expansion gives + +``` +q(y+x)-q(y) = q(x) + 2 (Bx) dot y (mod 4), +``` + +which proves the stated rule. For `C`, put `T=X(v)`. A Pauli either commutes +or anticommutes with `T`. The commuting case is unchanged. In the other case, +expanding `((1+s i)I+(1-s i)T) W ((1-s i)I+(1+s i)T)/4` +gives `-s i T W`, which is exactly the last row. These derivations determine +the signs; they are not inferred by ignoring global phases in a tableau. + +## Why the comparison covers every input + +Let `U,V` be two accepted words. Suppose their **signed** images of every +`X(e_j)` and `Z(e_j)` agree. Then `V^* U` commutes with all those generators. +Commuting with all `Z(e_j)` forces its matrix to be diagonal: distinct basis +labels have distinct joint sign eigenvalues. Commuting also with all +`X(e_j)` makes its diagonal entries equal along every edge of the binary +cube. That cube is connected, so `V^* U=lambda I` and `U=lambda V`. + +The additional equality `U|0>=V|0>` forces `lambda=1`, since `V|0>` is +nonzero. Thus the signed generator images plus **one exact anchor vector** +are a necessary and sufficient test of operator equality, including global +phase. At nine axes, this covers all 512 input basis columns and every complex +linear combination without constructing those 512 columns individually. + +This relies on the validated Clifford gate grammar. It is not a method for +checking arbitrary linear operators from 18 generators and one sample. +Nor is it a polynomial-time implementation claim: the anchor representation +can contain `2^n` amplitudes. The implemented domain is bounded at nine axes. + +## Exact anchor arithmetic and table reuse + +`anchor` starts with `{0: (1,0)}`. Its state is a sparse Gaussian-integer +numerator vector with common denominator `2^k`, where `k` is the number of +`C` gates already applied. Permutations, translations and fourth-root phases +preserve that denominator. Each `C` applies its literal numerator formula +and increments `k`; exact zeros are removed. No rounding, floating point, +norm tolerance or projective normalization occurs. + +Two anchors are compared after multiplication to the common denominator +`2^max(k,l)`. Python integers do not overflow. Equality tests retain every +nonzero coordinate, including the possibility that coordinate zero itself +vanishes; testing just the scalar amplitude at coordinate zero would not +suffice. + +The bounded 64-entry cache contains only immutable gate tables. For a binary +permutation, `Gx=G(x-e_j)+G e_j` at the least set bit `j`. For a quadratic +phase, `q(x)=q(x-e_j)+a_j+2 sum_{k != j} B_jk x_k`. These are the known +binary recurrences used by Charles Bethin/#662 and ywz65/#2638, coded here +for the comparator's gate representation. Keys include dimension and every +operand. Caller-owned lists are frozen before use. No new acceptance-result +or state-vector cache is introduced. The retained audit's own full-circuit +deduplication is unchanged. + +## Current-caller integration and limitations + +`replay.py` authenticates all 25 source/input files before running any retained +code, copies the captured bytes into a fresh private snapshot, and loads the +unchanged PR3202 verifier with one explicit installation statement immediately +after its kernel initialization. The source anchor must occur exactly once. +The hook substitutes only `same_operator`; all source/event binding, canonical +frame construction, both orientations, the scalar restoration control, recipe +coverage, wrapper chronology and sixteen semantic mutants per provider remain. + +Three modes run that identical caller: original packed kernel; the existing +#2638 table-cached packed kernel; and the new comparator. Every mode must +reproduce the entire original result. The benchmark also matches the multiset +of actual circuit pairs and Boolean decisions, with multiplicity. It uses +fresh serial processes and alternates order. Timing has no acceptance threshold. + +The nested predecessor result retains its historical kernel hash; the enclosing +receipt separately identifies the actual mode, new engine, transformed verifier +and all captured source hashes. Its inherited `512`-column fields describe +the operator domain covered, not an assertion that the new engine explicitly +simulated 512 input columns. Native generation is outside this retained-artifact +benchmark; the source artifacts are authenticated on every replay. + +This does not expand PR3202's scientific coverage, implement a fast recursive +multiplier, certify a supplier, or establish a new kappa. Native operations +outside the slice, physical ownership, complete cleanup, precision/tape and +outer/all-size obligations remain as in the predecessor. + +## Executed failure and differential checks + +`controls.py` uses the unchanged packed matrix implementation as an oracle +on 96 deterministic circuits (seed 86), dimensions one through four. It checks +`U P = image(P) U` for all generators on every input column: 480 signed Pauli +images and 4,704 matrix-column relations. It separately checks each complete +anchor vector and 480 comparator decisions, including adjoints and faults. +The small-dimensional computations are finite evidence for the implementation; +the preceding argument supplies the all-input implication for valid words. + +Two controls expose the respective blind spots. `PH(1)` has identity Pauli +action but a different anchor. A nontrivial diagonal character fixes `|0>` +but changes a signed Pauli image. Its unsigned Pauli labels are unchanged, +so the latter control also detects dropping signs. Invalid gate, singular +matrix and mutable-cache-key controls fail explicitly under optimized Python. + +Tekalign (@tekuuu), with substantial OpenAI Codex assistance. Apache-2.0. +No independent human or proof-kernel review is claimed. diff --git a/research/r2-mutation-path-copy/vendor/pr3218/README.md b/research/r2-mutation-path-copy/vendor/pr3218/README.md new file mode 100644 index 0000000000..645731637c --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/README.md @@ -0,0 +1,147 @@ +# Faster exact Clifford comparisons in the current R2 audit + +**Verification tooling; no new kappa or supplier admission.** The new +comparator accelerates the exact equality stage of PR3202's complete retained +two-provider native-slice audit by **29.97x** over its original packed kernel +and **20.61x** over the existing table-cached kernel. The entire audit improves +by **1.28x / 1.20x**, respectively; its other checks are unchanged. + +The insight is to use a complete algebraic description instead of constructing +every matrix column. For these Clifford operators, signed action on the 18 +Pauli generators determines the operator up to a scalar. One whole exact +anchor column fixes that scalar, including global phase. This criterion is +already used by the native producer and is not a new theorem here. The +contribution is a separate exact implementation, its source-bound integration +into the current independent audit, and measured coverage-preserving gains. + +## Same-input measurements + +Three samples per engine, each in a fresh serial Python 3.12.14 process, +alternating order on the same shared Linux host: + +| Engine | Equality-stage median | Complete audit median | +|---|---:|---:| +| Original PR1781 packed kernel | 9.774 s | 39.744 s | +| PR2638 cached-table packed kernel | 6.721 s | 37.467 s | +| Signed Pauli action + exact anchor | **0.326 s** | **31.100 s** | + +All nine runs reproduce the **entire predecessor result** and the same +multiset of **253 circuit-pair decisions: 244 acceptances and 9 rejections**. +Every source binding, both orientations, scalar restoration control, wrapper +chronology check and all sixteen semantic mutants per provider remain enabled. +The source audit's existing full-circuit deduplication is unchanged. + +[BENCHMARK.json](BENCHMARK.json) retains every sample, process-level timing, +source and engine hashes, complete-result digest and circuit/decision digest. +OS caches were not flushed; there is no timing threshold in CI. The whole-audit +measurements include authentication and isolated snapshot setup. They exclude +native artifact generation, full supplier replay and integer multiplication. +The 30x number describes the equality stage, not the complete audit. + +## What remains exact + +[engine.py](engine.py) validates the complete gate words, propagates signed +Pauli images and evaluates `U|0>` with sparse Gaussian integers over powers +of two. It uses no floating-point tolerance, random probes or projective +phase normalization. The [proof](PROOF.md) derives each gate rule and the +complete comparison criterion. The API supports one through nine axes; +the actual caller uses nine, hence a 512-dimensional input space. + +[controls.py](controls.py) checks the new representation against the original +packed matrix engine on 96 deterministic circuits in dimensions one through +four. It verifies all 480 signed generator images through 4,704 full matrix +column relations, every anchor, and 480 comparison decisions. Two explicit +controls show that Pauli action alone misses global phase and the zero-input +column alone misses a nontrivial character. Invalid gates and singular matrices +are rejected; mutating a cached operand changes the comparison result. These +controls also run under optimized Python. + +Only immutable gate tables are cached, at most 64 entries. No new result or +state-vector cache is introduced. A small differential corpus is evidence for +the implementation; the written Clifford argument supplies all-input coverage. +It is not a proof-kernel verification or an independent human review. + +## Reproduce and use + +From the repository root, Python 3.12 and the standard library: + +```sh +python3.12 -B scripts/research_package.py --package research/clifford-pauli-anchor +``` + +Expected markers are `PASS_CLIFFORD_PAULI_ANCHOR`, `PASS_ANCHOR_EXPORT` and +`PASS_REGISTERED_RESEARCH_PACKAGE ... outcome=completed`. The registered +checks also run a complete optimized replay from a Git-free export in a path +with spaces, and reject changes to a live kernel, retained recipe and verifier. + +Direct opt-in replay of the complete unchanged R2 audit: + +```sh +python3 -I -B research/clifford-pauli-anchor/replay.py --mode anchor +``` + +Use `--mode packed` or `--mode cached` for the two reference engines. +An optional `--output FRESH.json` saves the full companion receipt. +Normal commands do not regenerate or modify any source artifact. + +To repeat the same-input benchmark (about six minutes on this host): + +```sh +python3.12 -I -B research/clifford-pauli-anchor/benchmark.py \ + --rounds 3 --output /tmp/anchor-benchmark-fresh.json +``` + +For another caller, the drop-in function is `engine.same_operator(a,b,n=9)`. +Before adoption, pin its gate grammar and replay its complete existing +controls. The frozen/default project engines are unchanged. + +## Source and scope boundary + +Base: `463113d675af7410ac91d53a4fed51ec6494eb9a`, priority revision 6. +Pending dependency PR3202: +`259043321323717b7e816d6be38ad5e1f0b69b4c`. Twelve necessary files from that +package are retained verbatim under `vendor/pr3202/`, including its README. +Their original paths, commit, Git blob IDs and SHA256 digests are recorded in +`SOURCES.json`'s `vendored_files` and checked before execution. The generic +runner checks the main-history pins; it does not require the pending PR's +Git objects to exist in a fresh checkout. Direct replay needs no Git/network. + +All thirteen live input paths are declared for CI invalidation. `replay.py` +captures and authenticates those plus the twelve retained files before any +predecessor code executes. It installs exactly one comparator hook in a +private copy of the verifier; source/event reconstruction and all its failure +predicates stay unchanged. The complete result and snapshot immutability are +checked afterward. Changes to captured scientific inputs or predecessor +executable sources require an explicit pin update and revalidation; hashes are not a security +boundary against changing both evidence and its pins. + +The companion receipt distinguishes the executed comparator from the +historical kernel hash inside the retained result. Its inherited 512-column +fields denote the covered operator domain, not 512 individually simulated +columns in the new engine. The comparison covers every complex input under +the validated gate grammar. + +This does not extend PR3202's scientific scope. Full cleanup, other native +operations, physical ownership, precision/tape, the all-size compiler and +supplier/outer admission are not established here. Concurrent PR3208 +(`87d63a82defff1ffeea173743106fb97903cbbd6`) supplies a separate R2 cleanup +audit; it is not included in these measurements or certified by this package. +PR3209 optimizes JSON parsing in a different T16 caller. Both are complementary +work. The selected certificate and frozen predecessors are unchanged. + +## Open next questions and credit + +The [structured handoff](TASK.json) suggests testing a larger native cone +against its existing fastest engine, and profiling the R2 audit's remaining +source/event and mutant-copy costs. No larger-caller speedup is claimed here. +[Canonical claim](https://github.com/CrocSwap/integer-mult-bounds/discussions/2612#discussioncomment-19002067). + +Credit Sagar Thakrar/#1781 for the independent packed oracle and conventions; +ywz65/#2638 and Charles Bethin/#662 for the cached baseline and table recurrences; +24kHandsome1201/#3202 for the current audit; the original native producer for +the complete tableau/column criterion; and Nick Petalas, Jeremy Kothe, +Marius-Paul Dumitrean, Hiroki Kumazaki and the retained construction lineage. +[NOTICE.md](NOTICE.md) and the retained README give the fuller attribution. + +New work is by Tekalign (@tekuuu), with substantial OpenAI Codex assistance +in algebra, implementation, measurement, checking and writing. Apache-2.0. diff --git a/research/r2-mutation-path-copy/vendor/pr3218/RESULT.json b/research/r2-mutation-path-copy/vendor/pr3218/RESULT.json new file mode 100644 index 0000000000..33c1d5bbf5 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/RESULT.json @@ -0,0 +1,52 @@ +{ + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "call_multiset_sha256": "e39f695f2e4f1ca106fb3479417b795d691b8488dc2b37edd087e0ab8e54811f", + "controls": { + "cache_operand_mutation_rejected": true, + "circuits": 96, + "differential_comparisons": 480, + "invalid_gates_rejected": 8, + "matrix_column_relations": 4704, + "phase_only_and_column_only_blindness_controls": 2, + "seed": 86, + "signed_pauli_images": 480 + }, + "coverage": "Exact equality on the 512-dimensional operator domain, via signed Pauli action and one whole anchor column; not 512 explicitly simulated input columns.", + "decisions": { + "accepted": 244, + "calls": 253, + "rejected": 9 + }, + "dependency_pr3202": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "formal_kernel_proof": false, + "new_kappa": false, + "reference_result_sha256": "e059aa7e91a658e4bbf4d0b15be0bde7e3896c99aefb162e06e1003c1d220eb2", + "source_sha256": { + "research/clifford-state-performance/fast_state.py": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5", + "research/frontier1094-recipes-exact-seed76/clifford.py": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb", + "research/packed-clifford-gate-tables/adapter.py": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599", + "research/pr3044-r2-native-slice/README.md": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "research/pr3044-r2-native-slice/RESULT.json": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "research/pr3044-r2-native-slice/SOURCES.json": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "research/pr3044-r2-native-slice/data/base/CANONICAL-WORD.json.gz": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "research/pr3044-r2-native-slice/data/base/CLIFFORD-RECIPES.json.gz": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "research/pr3044-r2-native-slice/data/base/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/pr3044-r2-native-slice/data/base/RESIDUAL-ADAPTERS.json.gz": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "research/pr3044-r2-native-slice/data/extra/CANONICAL-WORD.json.gz": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "research/pr3044-r2-native-slice/data/extra/CLIFFORD-RECIPES.json.gz": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "research/pr3044-r2-native-slice/data/extra/LOCAL-PROGRAMS.json.gz": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "research/pr3044-r2-native-slice/data/extra/RESIDUAL-ADAPTERS.json.gz": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "research/pr3044-r2-native-slice/verify.py": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + "status": "PASS_CLIFFORD_PAULI_ANCHOR" +} diff --git a/research/r2-mutation-path-copy/vendor/pr3218/SOURCES.json b/research/r2-mutation-path-copy/vendor/pr3218/SOURCES.json new file mode 100644 index 0000000000..4bb592d91e --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/SOURCES.json @@ -0,0 +1,198 @@ +{ + "schema_version": 1, + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/clifford-state-performance/fast_state.py", + "usage": "input", + "git_blob": "5d546d8a05f6025d58a5133fa0d67ce134993013", + "sha256": "2fe087ba4558bd21ca49945dbedaa4047e4170e8fd4e2280701bb2f0481811b5" + }, + { + "path": "research/frontier1094-recipes-exact-seed76/clifford.py", + "usage": "input", + "git_blob": "6f1e6a38febde7eb7a7341d317522e6650d84408", + "sha256": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb" + }, + { + "path": "research/packed-clifford-gate-tables/adapter.py", + "usage": "input", + "git_blob": "b99342ac6e4853048a87cc9fa7d31caf998f9af0", + "sha256": "b0d9ad3183416e1c2780e69ea4bea57afba8c20da3979f61a6430731b4a42599" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json", + "usage": "input", + "git_blob": "9b7c498ed6f92be5f1c4a85a1f25427788647fc1", + "sha256": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json", + "usage": "input", + "git_blob": "ff42fd06f9ede0e1a717766232e283005336f935", + "sha256": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz", + "usage": "input", + "git_blob": "51b0b3c912565b7e12b3a2f8a3c0ccd37290206b", + "sha256": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz", + "usage": "input", + "git_blob": "23915f0bec7533ce0658cac8c7ae2069873efe4b", + "sha256": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py", + "usage": "input", + "git_blob": "08248542b18864c94a5ac050c8669f68519838e1", + "sha256": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py", + "usage": "input", + "git_blob": "6d47f63ab7a533941b3881bbfd3ae4dac5f76932", + "sha256": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py", + "usage": "input", + "git_blob": "99f351785ebca5fbf3336bedcd7b48bac9c255e5", + "sha256": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py", + "usage": "input", + "git_blob": "82beaa9c1d13bcd5f79d0a5e10e8a10733eac347", + "sha256": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py", + "usage": "input", + "git_blob": "1ff29dfb244e2114de8e586a450ae9fb70308d58", + "sha256": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py", + "usage": "input", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + } + ], + "dependency_heads": { + "PR3202": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "scientific_base": "463113d675af7410ac91d53a4fed51ec6494eb9a" + }, + "vendored_files": [ + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/verify.py", + "usage": "vendored", + "git_blob": "0ed4963416541b4da6f1b726cba18dc737c66412", + "sha256": "004a0bc6787cea330f401ab8b3f26bbe72499004e0ecb0ba09234ec6d2ada874", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/verify.py" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/SOURCES.json", + "usage": "vendored", + "git_blob": "71f2c61df0340a3e71d918fb371bc5e88eab3f13", + "sha256": "77da54e04b3d61cb436503ce8e9a6f7a0e11d0180fcc49d7eace65bb3e01f4f9", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/SOURCES.json" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/RESULT.json", + "usage": "vendored", + "git_blob": "87f87bc4bbc549611889a956f53a01c2dbd29d39", + "sha256": "289f8ce423d2fc60489bd0b3a7ee9d7ca68e3e23c93389f31eff4d938157ba7a", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/RESULT.json" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/README.md", + "usage": "vendored", + "git_blob": "b05efddf13cb67c7db7b0612ac18b537811872c7", + "sha256": "86af5efaf6dddf337fb80d4e1a5058633ed93d3247f0a00650f43f7b344e3175", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/README.md" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/CANONICAL-WORD.json.gz", + "usage": "vendored", + "git_blob": "3958b8cf77b86b98d7a35ed0f4d2590f7de2b27f", + "sha256": "682e7b76fa51dfbfd7b7962ce1382317c8091f2cf14ae131f6b557de6475a6c0", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/base/CANONICAL-WORD.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz", + "usage": "vendored", + "git_blob": "9ad65235dc846be16cddab2cf1839d24229de663", + "sha256": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/base/LOCAL-PROGRAMS.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz", + "usage": "vendored", + "git_blob": "0591c6af1b744520e7f6a07303420c055ee9ae0e", + "sha256": "708bf689bf80265991cbe4b5916cf8a60522e74c674eb576c32932903f0c8ad0", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/base/CLIFFORD-RECIPES.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz", + "usage": "vendored", + "git_blob": "3e154660a1ca7904703447280214a5c14957568f", + "sha256": "8faeab9752757c54ee0eef3df700a7c715c49d772d4c5dc545b11b80cecfd6b4", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/base/RESIDUAL-ADAPTERS.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz", + "usage": "vendored", + "git_blob": "c2c7a69938dcb2b2cbd390739bc027447ed6cb4c", + "sha256": "94e9a36aa0068024ccfceae4f6cb166ad33c5d460921e3e8e5df511eca0e6295", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/extra/CANONICAL-WORD.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz", + "usage": "vendored", + "git_blob": "9ad65235dc846be16cddab2cf1839d24229de663", + "sha256": "c57a0999b9d89e90a49096ea0e25817d1986b015726f711c3059a8aa875e5c24", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/extra/LOCAL-PROGRAMS.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz", + "usage": "vendored", + "git_blob": "887f5bfc36d382e81e2f945f5dcc5c1bf2be7233", + "sha256": "bff42748de313838c5dd82772c56a8154750db3e3746d4c792e875c15f38ca08", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/extra/CLIFFORD-RECIPES.json.gz" + }, + { + "path": "research/clifford-pauli-anchor/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz", + "usage": "vendored", + "git_blob": "3cb1e2927f406b18a635c6170ab73078b24b36e1", + "sha256": "da4f5fe1bdd515d29674cd098f6773c34a63061a49dcd1946f393b8f881723dd", + "source_commit": "259043321323717b7e816d6be38ad5e1f0b69b4c", + "source_path": "research/pr3044-r2-native-slice/data/extra/RESIDUAL-ADAPTERS.json.gz" + } + ] +} diff --git a/research/r2-mutation-path-copy/vendor/pr3218/TASK.json b/research/r2-mutation-path-copy/vendor/pr3218/TASK.json new file mode 100644 index 0000000000..aac896c2bc --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/TASK.json @@ -0,0 +1,132 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "priority_revision": 6, + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "original_card": { + "id": "replay-runtime", + "question": "Can one measured replay bottleneck be sped up without dropping coverage?", + "starting_points": [ + "scripts/run_isolated_tests.py", + "scripts/verify_replay_coverage.py", + "certificates/selected-result.json" + ], + "methods": [ + "Profile one isolated replay and optimize the measured bottleneck.", + "Design source-bound reuse with explicit dependency invalidation and negative controls." + ], + "acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the selected reproduction command and choose a single replay stage for profiling.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "allowed_variations": [ + "Profile one stage or design one source-bound cache boundary." + ], + "scope_change_triggers": [ + "Skipping coverage or comparing different fixtures to claim speedup." + ], + "overlap_terms": [ + "replay runtime", + "cache invalidation", + "isolated tests" + ] + }, + "scope_status": "refined", + "actual_scope": "Accelerate the exact equality engine inside the complete retained PR3202 two-provider native-slice audit, using independently implemented signed Pauli action plus an exact anchor vector; compare the original and existing table-cached kernels on identical circuits.", + "scope_change_reason": "The runtime card is narrowed to the current R2 native equality stage. The established Clifford criterion and the existing producer are credited; no new semantic admission coverage is claimed.", + "bottleneck_link": "Independent native audits execute hundreds to thousands of complete phase-sensitive Clifford comparisons. A sound faster comparator makes those audits and negative controls cheaper while leaving their source/event/ownership boundaries explicit.", + "budget_minutes": 60, + "stop_rule": "Session 2026-10-17T17:39Z to 18:39Z; stop if full equality or meaningful measured wall-time gain fails. Reserve at least the final 15 minutes for verification and handoff. Benchmark only the existing retained two-provider slice; do not expand its missing cleanup or supplier obligations.", + "outcome": "completed", + "evidence": "PROOF.md gives the complete comparator criterion and literal gate rules. BENCHMARK.json records nine fresh serial runs over the same 253 comparisons and unchanged complete result. RESULT.json records exact input hashes, decisions and independent full-matrix controls.", + "author": "Tekalign (@tekuuu)", + "ai_assistance": "Substantial OpenAI Codex assistance in proof adaptation, independent comparator code, source integration, tests, measurements and writing. The criterion is predecessor mathematics; no independent human or proof-kernel review is claimed.", + "open_questions": [ + { + "question": "Should a caller with thousands of native classes adopt the same comparator after source-bound replay?", + "why_it_matters": "The R2 audit already spends most remaining time outside equality; larger native cones may benefit more from the measured 20.6x gain over the cached equality engine.", + "first_step": "Pin the exact PR3208 cleanup or PR3038 native-cone caller and gate grammar, install same_operator only in an isolated snapshot, compare every result/control and benchmark the whole caller against its fastest existing engine.", + "blocked_by": "No whole-cone or producer-generation speedup is measured here; caller-specific schema and cache invalidation must remain intact." + }, + { + "question": "What now dominates the unchanged R2 audit outside exact equality?", + "why_it_matters": "Its remaining source/event and semantic-control work limits the whole-audit gain to about 1.28x over the original, despite a 30x equality-stage improvement.", + "first_step": "Profile source/event binding and full mutant-copy work on the identical fixture, retaining every mutant and failure predicate.", + "blocked_by": "No optimization or timing attribution of those remaining components is claimed in this package." + } + ], + "assignment": { + "seed": 86, + "randomness": "operating-system CSPRNG via secrets.randbelow(100)", + "track": "verification engineering", + "task": "replay-runtime" + }, + "candidates_considered": [ + { + "object": "PR3202 R2 exact native comparison stage", + "decision": "chosen: current source-bound caller, slow packed equality; independently implement a complete compact criterion rather than only caching tables" + }, + { + "object": "T740 complete fill serialization/authentication", + "decision": "deferred: would improve IO and formatting cost rather than the shared native equality engine" + }, + { + "object": "selected full-checker gate tables", + "decision": "not repeated: ywz65/#2638 already covers the optimization and supplies the stronger baseline here" + } + ], + "coordination": { + "claim": "https://github.com/CrocSwap/integer-mult-bounds/discussions/2612#discussioncomment-19002067", + "base_commit": "463113d675af7410ac91d53a4fed51ec6494eb9a", + "priorities_revision": 6, + "metadata_coverage": { + "open_prs": 251, + "closed_prs": 2630, + "fresh_discussion_refresh": "TLS handshake timeout; used complete 2004-record snapshot from 17:30 UTC plus fresh last-eight comments in #2612 and last-twelve handoffs in #1166" + }, + "overlap": "PR3202 caller head is unchanged. Concurrent PR3208 (87d63a82defff1ffeea173743106fb97903cbbd6) now audits R2 full cleanup separately; that audit is not benchmarked here. PR3209 (8c62e5f52f1d172bb8c95e795449205015bb5143) optimizes JSON parsing in a different T16 audit. Other current claims audit mixed entrances and private frees. This package changes only the comparison engine for the retained PR3202 slice. #1781, #2638, #662, #1029 and #2768 are credited predecessors.", + "submission_refresh": { + "canonical_main": "463113d675af7410ac91d53a4fed51ec6494eb9a (unchanged, fetched at 18:07 UTC)", + "open_prs": { + "records": 262, + "complete_pagination": true, + "fetched_at": "2026-10-17T18:07:11Z" + }, + "closed_prs": { + "records": 2630, + "complete_pagination": true, + "fetched_at": "2026-10-17T17:42:50Z" + }, + "discussions": { + "records": 2004, + "complete_pagination": true, + "fetched_at": "2026-10-17T17:30:12Z" + }, + "targeted_refresh": "Fresh last-twelve comments each in #2612 and #1166 at 18:07 UTC; current PR3202/3208/3209 heads and bodies; open issues list contains #913 only.", + "limitations": "New whole-Discussion refresh failed with TLS handshake timeout; new whole closed-PR pagination timed out. Used the dated complete snapshots above and fresh targeted reads. Search covers metadata and available local notes, not all PR diffs or unpublished work; no novelty certificate." + } + }, + "verification_scope": { + "actual_operator_comparisons": 253, + "accepted": 244, + "rejected": 9, + "providers": 2, + "coverage": "All-input operator equality on dimension 512, inferred from complete signed Pauli images and one whole exact anchor column. This is not sparse random-column sampling. Existing native/source/event controls remain unchanged.", + "unresolved": "Not established by this package: native operations outside the retained slice, full cleanup, physical ownership, supplier, precision/tape, all-size/compiler and outer admission. Concurrent PR3208 separately audits R2 cleanup; its evidence is not incorporated here." + }, + "validation": { + "registered_replay": "PASS_REGISTERED_RESEARCH_PACKAGE on CPython 3.12.14, including both commands and optimized Git-free export; 2026-10-17T18:06Z", + "cross_version": "CPython 3.14.7 Git-free export, optimized complete replay and three source corruption controls passed; 2026-10-17T18:06Z", + "publication_source_check": "All 12 retained files equal git-show bytes at pinned PR3202 head. All 25 input digests, comparison decisions and full-result digests agree across RESULT and nine-run BENCHMARK; engine hash matches measured source.", + "orientation_limitation": "The optional selected research_baseline.py check could not run because the sparse checkout omitted research/complex-sw4-frame8. No selected cold replay or selected-baseline PASS is claimed. All three exact caller baselines and the required package checks ran successfully." + } +} diff --git a/research/r2-mutation-path-copy/vendor/pr3218/VERIFY.json b/research/r2-mutation-path-copy/vendor/pr3218/VERIFY.json new file mode 100644 index 0000000000..ddcd3a48c6 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/VERIFY.json @@ -0,0 +1,43 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/clifford-state-performance/fast_state.py", + "research/frontier1094-recipes-exact-seed76/clifford.py", + "research/packed-clifford-gate-tables/adapter.py", + "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json", + "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json", + "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz", + "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py", + "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Complete retained R2 audit with all original controls, exact result and call-multiset receipt; independent full-matrix Pauli/anchor checks and invalidation controls." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 180, + "checks": "Three source corruption controls and complete optimized replay from a Git-free export in a path with spaces." + } + ] +} diff --git a/research/r2-mutation-path-copy/vendor/pr3218/benchmark.py b/research/r2-mutation-path-copy/vendor/pr3218/benchmark.py new file mode 100644 index 0000000000..db469190bb --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/benchmark.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +"""Fresh serial process benchmarks of the identical complete R2 audit. +Tekalign / OpenAI Codex, Apache-2.0. No acceptance timing threshold. +""" +import argparse +import json +from pathlib import Path +import platform +import statistics +import subprocess +import sys +import tempfile +import time + +PACKAGE = Path(__file__).resolve().parent + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--rounds', type=int, default=3) + parser.add_argument('--output', type=Path, required=True) + args = parser.parse_args() + if args.output.exists() or not 1 <= args.rounds <= 9: + raise ValueError('fresh output and 1..9 rounds required') + rows = [] + reference = None + orders = [('packed', 'cached', 'anchor'), ('anchor', 'cached', 'packed'), + ('cached', 'anchor', 'packed')] + with tempfile.TemporaryDirectory(prefix='anchor-benchmark-') as directory: + for trial in range(args.rounds): + for mode in orders[trial % len(orders)]: + target = Path(directory) / f'{trial}-{mode}.json' + command = [sys.executable, '-I', '-B', str(PACKAGE / 'replay.py'), + '--mode', mode, '--output', str(target)] + start = time.perf_counter() + process = subprocess.run(command, capture_output=True, text=True, timeout=180) + elapsed = time.perf_counter() - start + if process.returncode: + raise ValueError(process.stdout + process.stderr) + result = json.loads(target.read_bytes()) + semantic = {k: result[k] for k in ('reference_result_sha256', 'call_multiset_sha256', + 'calls', 'source_sha256', 'anchor_engine_sha256')} + if reference is None: + reference = semantic + elif semantic != reference: + raise ValueError('benchmark inputs, decisions or complete audit differ') + rows.append({'round': trial, 'mode': mode, 'process_wall_seconds': elapsed, + 'audit_wall_seconds': result['wall_seconds'], + 'equality_engine_seconds': result['engine_seconds']}) + print(process.stdout.strip(), flush=True) + medians = {mode: {field: statistics.median(x[field] for x in rows if x['mode'] == mode) + for field in ('process_wall_seconds', 'audit_wall_seconds', 'equality_engine_seconds')} + for mode in orders[0]} + report = {'scope': 'Complete retained PR3202 two-provider audit; native generation and full supplier admission excluded', + 'python': sys.version, 'platform': platform.platform(), 'rounds': args.rounds, + 'processes': 'fresh, sequential; alternating orders; OS caches not flushed; shared host', + 'semantic_identity': reference, 'samples': rows, 'medians': medians, + 'speedup_over': {mode: {field: medians[mode][field] / medians['anchor'][field] + for field in medians[mode]} for mode in ('packed', 'cached')}} + with args.output.open('x') as stream: + json.dump(report, stream, sort_keys=True, indent=2) + stream.write('\n') + print('PASS_SAME_INPUT_R2_BENCHMARK', json.dumps(report['speedup_over'], sort_keys=True)) + + +if __name__ == '__main__': + main() diff --git a/research/r2-mutation-path-copy/vendor/pr3218/controls.py b/research/r2-mutation-path-copy/vendor/pr3218/controls.py new file mode 100644 index 0000000000..be69a270f0 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/controls.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 +"""Independent matrix checks of every signed Pauli image and anchor. +Tekalign / OpenAI Codex, Apache-2.0. Oracle: Sagar Thakrar's packed kernel. +""" +import json +from pathlib import Path +import random +import types + +PACKAGE = Path(__file__).resolve().parent + + +def load(path, name): + m = types.ModuleType(name) + m.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), m.__dict__) + return m + + +def check(): + R = load(PACKAGE / 'replay.py', 'source_replay') + E = load(PACKAGE / 'engine.py', 'anchor_controls_engine') + raw = R.capture()[R.KERNEL] + C = R.module(raw, 'packed_oracle', R.KERNEL) + rng = random.Random(86) + circuits = paulis = matrix_columns = comparisons = 0 + for n in range(1, 5): + C.N_AXES, C.DIM = n, 1 << n + for _ in range(24): + word = [] + for _ in range(12): + kind = rng.choice(('P', 'D', 'C', 'X', 'PH')) + if kind == 'P': + rows = [1 << j for j in range(n)] + if n > 1: + for _ in range(2 * n): + a, b = rng.sample(range(n), 2) + rows[a] ^= rows[b] + g = (kind, rows) + elif kind == 'D': + g = (kind, [rng.randrange(1 << n) for _ in range(n)], [rng.randrange(4) for _ in range(n)]) + elif kind == 'C': + g = (kind, rng.randrange(1, 1 << n), rng.choice((-1, 1))) + else: + g = (kind, rng.randrange(4 if kind == 'PH' else 1 << n)) + word.append(g) + frozen = E.freeze(word, n) + k = C.c_gates(word) + cols = C.columns(C.run(word, C.radix(k)), C.radix(k)) + state, denominator = E.anchor(frozen, n) + R.need(state == cols.get(0, {}) and denominator == k, 'anchor/full-matrix disagreement') + for index, (p, x, z) in enumerate(E.pauli_action(frozen, n)): + x0, z0 = (1 << index, 0) if index < n else (0, 1 << (index - n)) + for column in range(1 << n): + # Check U P = image(P) U directly on EVERY input column. + left = {y: E.rotate(v, 2 * ((column & z0).bit_count() % 2)) + for y, v in cols[column ^ x0].items()} + right = {y ^ x: E.rotate(v, p + 2 * ((y & z).bit_count() % 2)) + for y, v in cols[column].items()} + R.need(left == right, 'signed Pauli image disagrees with full matrix') + matrix_columns += 1 + paulis += 1 + before = json.dumps(word) + for other in (word, word + C.adjoint(word), [], word + [('PH', 1)], word + [('X', 1)]): + R.need(E.same_operator(word, other, n) == C.same_operator(word, other), 'differential comparator') + comparisons += 1 + R.need(json.dumps(word) == before, 'input mutation') + circuits += 1 + identity = E.freeze([], 2) + phase = E.freeze([('PH', 1)], 2) + character = E.freeze([('D', [0, 0], [2, 0])], 2) + R.need(E.pauli_action(identity, 2) == E.pauli_action(phase, 2) and + not E.same_operator([], [('PH', 1)], 2), 'Pauli-only phase blindness control') + R.need(E.anchor(identity, 2) == E.anchor(character, 2) and + not E.same_operator([], [('D', [0, 0], [2, 0])], 2), 'zero-column-only blindness control') + bad = [('T', 0), ('C', 0, 1), ('C', 1, 0), ('PH', True), ('X', 4), + ('P', [1, 1]), ('D', [0, 0], [0, 4]), ('PH', 1, 2)] + for gate in bad: + try: + E.same_operator([('X', 1), gate], [], 2) + except ValueError: + pass + else: + raise ValueError('invalid gate accepted: ' + repr(gate)) + # Cache keys include full immutable operands; caller mutation cannot reuse an old gate. + mutable = [('D', [0, 0], [0, 0])] + R.need(E.same_operator(mutable, [], 2), 'cache positive') + mutable[0][2][0] = 2 + R.need(not E.same_operator(mutable, [], 2), 'cache operand mutation') + R.need(E.tables.cache_info().currsize <= 64, 'bounded gate cache') + return {'seed': 86, 'circuits': circuits, 'signed_pauli_images': paulis, + 'matrix_column_relations': matrix_columns, 'differential_comparisons': comparisons, + 'invalid_gates_rejected': len(bad), 'phase_only_and_column_only_blindness_controls': 2, + 'cache_operand_mutation_rejected': True} + + +if __name__ == '__main__': + print(json.dumps(check(), sort_keys=True)) diff --git a/research/r2-mutation-path-copy/vendor/pr3218/engine.py b/research/r2-mutation-path-copy/vendor/pr3218/engine.py new file mode 100644 index 0000000000..a34243c16b --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/engine.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python3 +"""Exact signed-Pauli action and an absolute phase anchor, for 1..9 axes. + +Tekalign (@tekuuu), substantial OpenAI Codex assistance, Apache-2.0. +The complete tableau-plus-column criterion predates this implementation. +Gate conventions follow Sagar Thakrar's PR1781 kernel; bounded binary table +recurrences follow the credited PR662/2638 approach, independently coded here. +""" +from functools import lru_cache + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def parity(x): + return x.bit_count() & 1 + + +def inverse(rows): + n = len(rows) + a = [r | 1 << (n + j) for j, r in enumerate(rows)] + for j in range(n): + k = next((k for k in range(j, n) if a[k] >> j & 1), None) + require(k is not None, 'singular P gate') + a[k], a[j] = a[j], a[k] + for k in range(n): + if k != j and a[k] >> j & 1: + a[k] ^= a[j] + return tuple(r >> n for r in a) + + +def apply(rows, x): + return sum(parity(r & x) << j for j, r in enumerate(rows)) + + +def freeze(circuit, n): + require(type(n) is int and 1 <= n <= 9, 'axis domain 1..9') + require(isinstance(circuit, (list, tuple)), 'circuit sequence') + out = [] + for g in circuit: + require(isinstance(g, (list, tuple)) and len(g) > 0, 'gate sequence') + kind = g[0] + require(type(kind) is str and kind in ('P', 'D', 'C', 'X', 'PH'), 'unsupported gate') + require(len(g) == (3 if kind in ('D', 'C') else 2), 'gate arity') + if kind in ('P', 'D'): + require(isinstance(g[1], (list, tuple)) and len(g[1]) == n and + all(type(r) is int and 0 <= r < 1 << n for r in g[1]), 'binary rows') + if kind == 'P': + out.append((kind, tuple(g[1]))) + else: + require(isinstance(g[2], (list, tuple)) and len(g[2]) == n and + all(type(a) is int and 0 <= a < 4 for a in g[2]), 'Z4 linear coefficients') + out.append((kind, tuple(g[1]), tuple(g[2]))) + elif kind == 'C': + require(type(g[1]) is int and 0 < g[1] < 1 << n and + type(g[2]) is int and g[2] in (-1, 1), 'C gate domain') + out.append(tuple(g)) + else: + require(type(g[1]) is int and 0 <= g[1] < (4 if kind == 'PH' else 1 << n), 'offset/phase domain') + out.append(tuple(g)) + # Validate both complete words even if their early tableaus will differ. + for g in out: + tables(g, n) + return tuple(out) + + +@lru_cache(maxsize=64) +def tables(g, n): + """Immutable gate tables only; never cache states or equality decisions.""" + kind = g[0] + if kind == 'P': + inv = inverse(g[1]) + inv_transpose = tuple(sum(((inv[j] >> i) & 1) << j for j in range(n)) for i in range(n)) + cols = [apply(g[1], 1 << j) for j in range(n)] + table = [0] * (1 << n) + for x in range(1, 1 << n): + j = (x & -x).bit_length() - 1 + table[x] = table[x ^ (1 << j)] ^ cols[j] + return tuple(table), inv_transpose + if kind == 'D': + q, a = g[1:] + # The legacy semantics read only the strict upper triangle of Q. + cross = tuple((q[j] & ~((1 << (j + 1)) - 1)) | + sum(((q[i] >> j) & 1) << i for i in range(j)) for j in range(n)) + derivative = tuple(cross[j] | ((a[j] & 1) << j) for j in range(n)) + table = [0] * (1 << n) + for x in range(1, 1 << n): + bit = x & -x + j, y = bit.bit_length() - 1, x ^ bit + table[x] = (table[y] + a[j] + 2 * parity(cross[j] & y)) % 4 + return tuple(table), derivative + return () + + +def pauli_action(word, n): + """Images of X_j then Z_j, in the convention i^p X^x Z^z.""" + images = [(0, 1 << j, 0) for j in range(n)] + [(0, 0, 1 << j) for j in range(n)] + for g in word: + kind = g[0] + updated = [] + for p, x, z in images: + if kind == 'P': + permutation, inv_t = tables(g, n) + x, z = permutation[x], apply(inv_t, z) + elif kind == 'D': + phases, derivative = tables(g, n) + p, z = p + phases[x], z ^ apply(derivative, x) + elif kind == 'X': + p += 2 * parity(z & g[1]) + elif kind == 'C' and parity(z & g[1]): + p, x = p - g[2], x ^ g[1] + updated.append((p % 4, x, z)) + images = updated + return tuple(images) + + +def rotate(value, k): + a, b = value + return ((a, b), (-b, a), (-a, -b), (b, -a))[k % 4] + + +def anchor(word, n): + """U|0>, as a sparse Gaussian-integer vector divided by 2^k.""" + state, k = {0: (1, 0)}, 0 + for g in word: + kind = g[0] + if kind == 'P': + perm = tables(g, n)[0] + state = {perm[x]: v for x, v in state.items()} + elif kind == 'X': + state = {x ^ g[1]: v for x, v in state.items()} + elif kind in ('D', 'PH'): + phases = tables(g, n)[0] if kind == 'D' else None + state = {x: rotate(v, phases[x] if phases is not None else g[1]) for x, v in state.items()} + else: + q, s = g[1:] + out = {} + for x in state.keys() | {x ^ q for x in state}: + a, b = state.get(x, (0, 0)) + c, d = state.get(x ^ q, (0, 0)) + v = (a - s * b + c + s * d, s * a + b - s * c + d) + if v != (0, 0): + out[x] = v + state, k = out, k + 1 + return state, k + + +def same_operator(first, second, n=9): + """Exact operator equality, including global phase; no sampling.""" + a, b = freeze(first, n), freeze(second, n) + if pauli_action(a, n) != pauli_action(b, n): + return False + (v, k), (w, ell) = anchor(a, n), anchor(b, n) + if v.keys() != w.keys(): + return False + K = max(k, ell) + return all((v[x][0] << (K - k), v[x][1] << (K - k)) == + (w[x][0] << (K - ell), w[x][1] << (K - ell)) for x in v) diff --git a/research/r2-mutation-path-copy/vendor/pr3218/replay.py b/research/r2-mutation-path-copy/vendor/pr3218/replay.py new file mode 100644 index 0000000000..c1c31353fd --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/replay.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python3 +"""Opt-in replay of the unchanged PR3202 audit with one comparator substitution. + +Tekalign / OpenAI Codex, Apache-2.0. Original audit: 24kHandsome1201. +Packed kernel: Sagar Thakrar. Cached baseline: ywz65 and Charles Bethin. +""" +import argparse +import hashlib +import json +from pathlib import Path +import tempfile +import time +import types + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] +ORIGINAL = 'research/pr3044-r2-native-slice/' +KERNEL = 'research/frontier1094-recipes-exact-seed76/clifford.py' +CACHED = 'research/packed-clifford-gate-tables/adapter.py' +TABLES = 'research/clifford-state-performance/fast_state.py' +VENDOR = 'research/clifford-pauli-anchor/vendor/pr3202/' + + +def need(ok, reason): + if not ok: + raise ValueError(reason) + + +def canonical(value): + return json.dumps(value, sort_keys=True, separators=(',', ':')).encode() + + +def digest(raw): + return hashlib.sha256(raw).hexdigest() + + +def capture(root=ROOT): + manifest = json.loads((PACKAGE / 'SOURCES.json').read_bytes()) + found = {} + for row in manifest['files'] + manifest['vendored_files']: + path = row['path'] + if row['usage'] != 'input' and not path.startswith(VENDOR): + continue + raw = (root / path).read_bytes() + need(digest(raw) == row['sha256'], 'source drift: ' + path) + blob = b'blob ' + str(len(raw)).encode() + b'\0' + raw + need(hashlib.sha1(blob, usedforsecurity=False).hexdigest() == row['git_blob'], 'source blob') + target = ORIGINAL + path[len(VENDOR):] if path.startswith(VENDOR) else path + need(target not in found, 'duplicate snapshot destination') + found[target] = raw + need(len(found) == 25, 'complete snapshot inventory') + return found + + +def module(raw, name, path): + obj = types.ModuleType(name) + obj.__file__ = str(path) + exec(compile(raw, str(path), 'exec'), obj.__dict__) + return obj + + +def run(mode='anchor'): + need(mode in ('packed', 'cached', 'anchor'), 'engine mode') + start = time.perf_counter() + sources = capture() + new_engine_raw = (PACKAGE / 'engine.py').read_bytes() + new_engine = module(new_engine_raw, 'pauli_anchor_engine', PACKAGE / 'engine.py') + cached = module(sources[CACHED], 'credited_cached_adapter', ROOT / CACHED) + counts = {'calls': 0, 'accepted': 0, 'rejected': 0} + call_inputs = [] + engine_seconds = 0.0 + def install(kernel): + if mode == 'cached': + p, d = cached.table_functions(sources[TABLES]) + kernel._permutation_table, kernel._phase_table = p, d + exec(compile(cached.transform(sources[KERNEL]), KERNEL, 'exec'), kernel.__dict__) + compare = new_engine.same_operator if mode == 'anchor' else kernel.same_operator + def checked(a, b): + nonlocal engine_seconds + before = time.perf_counter() + result = compare(a, b) + engine_seconds += time.perf_counter() - before + call_inputs.append(digest(canonical([a, b, result]))) + counts['calls'] += 1 + counts['accepted' if result else 'rejected'] += 1 + return result + kernel.same_operator = checked + with tempfile.TemporaryDirectory(prefix='pauli-anchor-') as directory: + snapshot = Path(directory) + for path, raw in sources.items(): + target = snapshot / path + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(raw) + raw = sources[ORIGINAL + 'verify.py'] + anchor = " exec(compile(blobs[KERNEL], KERNEL, 'exec'), kernel.__dict__)" + text = raw.decode() + need(text.count(anchor) == 1, 'unique comparator installation anchor') + changed = text.replace(anchor, anchor + '\n _install_comparator(kernel)').encode() + verifier = types.ModuleType('source_bound_r2_audit') + verifier.__file__ = str(snapshot / ORIGINAL / 'verify.py') + verifier._install_comparator = install + exec(compile(changed, verifier.__file__, 'exec'), verifier.__dict__) + result = verifier.compute(snapshot / ORIGINAL / 'data') + expected = json.loads(sources[ORIGINAL + 'RESULT.json']) + need(canonical(result) == canonical(expected), 'complete predecessor result mismatch') + for path, raw in sources.items(): + need((snapshot / path).read_bytes() == raw, 'snapshot mutation') + return {'mode': mode, 'reference_result': result, 'reference_result_sha256': digest(canonical(result)), + 'calls': counts, 'executed_verifier_sha256': digest(changed), + 'call_multiset_sha256': digest(canonical(sorted(call_inputs))), + 'anchor_engine_sha256': digest(new_engine_raw), + 'source_sha256': {p: digest(b) for p, b in sorted(sources.items())}, + 'engine_seconds': engine_seconds, 'wall_seconds': time.perf_counter() - start, + 'reference_kernel_field': 'The unchanged nested result names the loaded source kernel; execution mode and comparator source are recorded separately here.'} + + +def main(): + ap = argparse.ArgumentParser(description=__doc__) + ap.add_argument('--mode', choices=('packed', 'cached', 'anchor'), default='anchor') + ap.add_argument('--output', type=Path) + args = ap.parse_args() + need(args.output is None or not args.output.exists(), 'output already exists') + result = run(args.mode) + if args.output: + with args.output.open('x') as f: + json.dump(result, f, sort_keys=True, indent=2) + f.write('\n') + print('PASS_R2_EXACT_COMPARATOR', args.mode, 'calls=' + str(result['calls']), + 'wall_seconds=' + str(round(result['wall_seconds'], 3))) + + +if __name__ == '__main__': + main() diff --git a/research/r2-mutation-path-copy/vendor/pr3218/test_package.py b/research/r2-mutation-path-copy/vendor/pr3218/test_package.py new file mode 100644 index 0000000000..d5722a7086 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/test_package.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Source corruption and clean export controls; no Git/network needed. +Tekalign / OpenAI Codex, Apache-2.0. +""" +import json +from pathlib import Path +import shutil +import subprocess +import sys +import tempfile +import types + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] + + +def load_replay(path): + module = types.ModuleType('exported_anchor_replay') + module.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), module.__dict__) + return module + + +def main(): + manifest = json.loads((PACKAGE / 'SOURCES.json').read_bytes()) + with tempfile.TemporaryDirectory(prefix='anchor export ') as directory: + root = Path(directory) + target = root / PACKAGE.relative_to(ROOT) + shutil.copytree(PACKAGE, target, ignore=shutil.ignore_patterns('__pycache__')) + for row in manifest['files']: + if row['usage'] == 'input': + destination = root / row['path'] + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / row['path'], destination) + replay = load_replay(target / 'replay.py') + captured = replay.capture() + if len(captured) != 25 or (root / '.git').exists(): + raise ValueError('clean complete source export') + # Mutate a live engine, a retained recipe and retained checker independently. + mutants = [root / replay.KERNEL, target / 'vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz', + target / 'vendor/pr3202/verify.py'] + for file in mutants: + original = file.read_bytes() + file.write_bytes(original + b'\n') + try: + replay.capture() + except ValueError as error: + if 'source drift:' not in str(error): + raise + else: + raise ValueError('source corruption accepted') + file.write_bytes(original) + if replay.capture() != captured: + raise ValueError('export restoration') + command = [sys.executable, '-I', '-O', '-B', str(target / 'verify.py')] + process = subprocess.run(command, cwd=root, text=True, capture_output=True, timeout=120) + if process.returncode or 'PASS_CLIFFORD_PAULI_ANCHOR' not in process.stdout: + raise ValueError(process.stdout + process.stderr) + print('PASS_ANCHOR_EXPORT source_mutants=3 optimized_full_replay=1') + + +if __name__ == '__main__': + main() diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/README.md b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/README.md new file mode 100644 index 0000000000..b05efddf13 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/README.md @@ -0,0 +1,151 @@ +# PR3044 R2: independent native slice and residual wrappers + +This package follows [PR3146's released next question](https://github.com/CrocSwap/integer-mult-bounds/pull/3146): +independently interpret the native phase/residual-adapter boundary of Nick +Petalas's R2 shared restore. It checks the actual **base and extra** providers +of [PR3044](https://github.com/CrocSwap/integer-mult-bounds/pull/3044), head +`1f922b25abff2d7fd87fa5b29619160862a06b59`, as archived at canonical main +`997e6a9ca7b4f95d50e366f61412fd640d72a88a`. + +**Result:** the three changed native child recipes, four ordinary source +endpoint adapters, and all **54 used residual recipes per provider** satisfy +their exact operator identities on all 512 complex coordinates, including +global phase, in both orientations. The emitted tail and final steps and every +residual wrapper's owner, side and phase agree with independently reconstructed +source boundaries. This is a finite, scoped verification result. It supplies +no new construction, kappa, physical realization or supplier admission. + +## Missing coverage and independence + +PR3044 already checks rational R1/R2 equality, frame charges and a complete +release using its native engine. Hiroki Kumazaki's PR3146 independently runs +that release and adds separate local/binding checks, while explicitly leaving +native semantics dependent on the inherited engine. + +The new `verify.py` does not import the producer, lowering compiler, original +R2 evaluator or frame tracer. Its new source/event binding uses explicit finite +binary spans and sparse rational rows. For native arithmetic it **reuses**, with +an exact source pin, Sagar Thakrar's separately implemented +[`clifford.py`](../frontier1094-recipes-exact-seed76/clifford.py). That established +stdlib kernel interprets primitive circuits as packed Gaussian-integer matrices +with a proved non-aliasing radix. This package does not claim a new kernel or +independence from that auditor. Hand calibrations cover C squared, inverse and +global-phase sensitivity. New fault controls test the changed boundary. + +The eight retained native artifacts were freshly regenerated using the original +six source-bound engine files. All eight raw artifact hashes matched PR3044's +published native receipt in the recorded environment. Generation and checking +are distinct: producer PASS messages establish no independent native identity. +The default verifier authenticates the complete artifacts, then interprets +their selected semantic payloads itself. JSON artifacts are gzip-compressed for +storage; their uncompressed original bytes are authenticated. Existing `.gz` +artifacts retain their original bytes. + +## Exact scope and argument + +Write W = span(256,128,64,34,17,11,4), E = +span(256,128,64,34,16,10,4,1), and F for the full nine-dimensional frame. +R2 forms X40 − 2 X54 at W, serves the X18 and X22 consumers at E, then +restores X40 at F. The changed native trace, using zero-based restore indices, +is: + +| Restore index | Register | Transition | Charged rank | +|---|---|---|---| +| 163 | X40 | W → E | 1 | +| 203 | X40 | E → F | 1 | +| 203 | X54 | W → F | 2 | + +For each serialized child, the checker proves `L F_r R = T_new T_old^-1` +with every phase retained, and proves that composing the two rank-one recipes +equals the rank-two recipe. A componentwise rational scalar commutes with the +common frame operator. Provided the unchanged native operations realize their +declared frame maps, these identities validate the changed R2 lowering in +physical coordinates. The full 204-gate scalar tail is compared with the +reconstructed R1 control on all 632 arbitrary input columns in both orientations. +This corroborates the earlier scalar check and connects it to the native slice. + +The four named registers are ordinary sources, with source endpoint adapters +and FULL exits, **not residual-wrapped helpers**. Their source endpoint identities +are separately checked. The current source maps also determine every wrapped +helper. For each of the 54 used residual recipes the checker proves +`L^-1 T_terminal T_entrance^-1 R^-1 = F_width`; the inverse-transpose orientation +uses complex conjugation of these unitary frame operators. All emitted pre/post +wrapper occurrences must have the correct helper, side, entrance/terminal IDs +and phase. This validates wrapper identities and placement; it does not prove +that every intervening native operation realizes its declared reference map. + +The source A/B frame trace is reconstructed from word data. A separate scan of +the emitted prefix checks frame transition chronology and its tail entrance. +Prefix native phase semantics are an explicit premise. No end-to-end physical +executor or all-register native theorem is inferred from these checks. + +## Reproduction + +From the repository root, Python 3.12, standard library only: + +```sh +python3 -B scripts/research_package.py --package research/pr3044-r2-native-slice +python3 -I -O -B research/pr3044-r2-native-slice/verify.py +``` + +The registered command reads source-bound saved artifacts; it does not generate +them. Its semantic controls operate **after authentication**, requiring each +mutant to fail the named semantic predicate. They cover both fan-in signs, +the rank-two charge, phase order, source frame chronology, dirty restoration, +an extra observer, ordinary source exits, wrapper side/owner and post-cleanup ordering, child phase/rank/ +translation and residual phase/translation. `RESULT.json` records exact counts. + +Optional producer regeneration requires NumPy (the recorded run used 2.3.5): + +```sh +python3 -B research/pr3044-r2-native-slice/reproduce.py --output /tmp/r2-native-fresh +``` + +Use a new output directory. This runs four inherited stages sequentially for +each provider, then compares every proof-relevant JSON field with the +authenticated retained artifacts. Container bytes may differ with Python/zlib; +payload equality is the portable regeneration gate. The full PR3044/3146 +13-stage source/admission/outer replay was not repeated here. See +`ENVIRONMENT.json` and `evidence/` for this session's exact generation evidence. + +## Limits + +Other native child recipes, warp semantics, full-frame cleanup semantics, +physical owner geometry/stock, precision/tape, caller contracts, all-size +compilation, analytic transfer and universal block-energy obligations remain. +The earlier all-input and complete-release results retain their original +evidence status. No selected-frontier record or predecessor file is changed. + +## Open next questions + +1. Extend the native interpretation to the remaining R2 dependency cone, + especially the full-frame inverse cleanup and its private buffers. Begin + with the authenticated `LOCAL-PROGRAMS` and the source restore-to-cleanup + mapping. The gap is the complete physical map, not artifact availability. +2. Independently check the physical executor's use of the serialized native + records and their actual owner locations. Begin with these three child events + and the current hosted template. Exact recipe identities alone do not + discharge executor, routing or ownership contracts. + +Structured scope, original card, overlap coverage and next steps are in +`TASK.json`. This answers a specific historical handoff; it makes no claim to +the newest unreviewed candidate or exclusive novelty. Metadata/discussion +coverage does not include unpublished work or every historical diff. + +## Credit + +24kHandsome1201 with substantial OpenAI Codex assistance for analysis, code, +execution and writing. No independent human or proof-kernel review is claimed. +Nick Petalas contributed R2, its finite checks and original release; Jeremy +Kothe contributed R1 and the literal rewrite/cleanup machinery; Marius-Paul +Dumitrean contributed the joint rank-7 words/allocation; Hiroki Kumazaki supplied +the external cold replay and this handoff. Sagar Thakrar supplied the reused +independent exact kernel. The earlier V45 event-binding audit is credited for +the source-to-native audit approach; its checker is not imported. + +Credit also Cinna Davis, DreamingOfClouds, icekylinx, chafreaky, Mason Hale, +Jeremy Diviney, Yiyang Lu, Tekalign, Ross Richardson and the retained native, +geometry and owner lineage. Existing notices remain in their source packages, +including [PR3015 credits](../rank7-shared-restore-fanin/vendor/PR3015-CREDITS.md) +and [notice](../rank7-shared-restore-fanin/vendor/PR3015-NOTICE). +Code and generated data retain Apache-2.0 licensing. diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/RESULT.json b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/RESULT.json new file mode 100644 index 0000000000..87f87bc4bb --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/RESULT.json @@ -0,0 +1,239 @@ +{ + "kernel_sha256": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb", + "providers": { + "base": { + "events": { + "backward": { + "changed_climbs": [ + [ + 163, + [ + "climb", + "cleanup_tail", + 40, + 254, + 250, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 40, + 250, + 1, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 54, + 254, + 1, + 2 + ] + ] + ], + "events": 22748, + "final_events": 425, + "tail_events": 328, + "wrapper_occurrences": 390 + }, + "forward": { + "changed_climbs": [ + [ + 163, + [ + "climb", + "cleanup_tail", + 40, + 254, + 250, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 40, + 250, + 1, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 54, + 254, + 1, + 2 + ] + ] + ], + "events": 22748, + "final_events": 425, + "tail_events": 328, + "wrapper_occurrences": 390 + } + }, + "native": { + "changed_child_recipes": 3, + "native_columns_each": 512, + "orientations": 2, + "phase_included": true, + "residual_recipes": 54, + "source_endpoint_recipes": 4 + }, + "rejected_controls": [ + "forward fan-in sign", + "dual fan-in sign", + "rank-two child undercharge", + "tail phase substitution", + "wrapper side", + "dual wrapper owner", + "post wrappers before cleanup", + "source exit frame", + "missing dirty restoration", + "extra fan-in observer", + "prefix wrong source frame", + "native global phase", + "native translation", + "native child rank", + "residual global phase", + "residual translation" + ], + "scalar_control": { + "columns_per_orientation": 632, + "restore_gates": 204 + } + }, + "extra": { + "events": { + "backward": { + "changed_climbs": [ + [ + 163, + [ + "climb", + "cleanup_tail", + 40, + 254, + 250, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 40, + 250, + 1, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 54, + 254, + 1, + 2 + ] + ] + ], + "events": 22748, + "final_events": 425, + "tail_events": 328, + "wrapper_occurrences": 390 + }, + "forward": { + "changed_climbs": [ + [ + 163, + [ + "climb", + "cleanup_tail", + 40, + 254, + 250, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 40, + 250, + 1, + 1 + ] + ], + [ + 203, + [ + "climb", + "cleanup_tail", + 54, + 254, + 1, + 2 + ] + ] + ], + "events": 22748, + "final_events": 425, + "tail_events": 328, + "wrapper_occurrences": 390 + } + }, + "native": { + "changed_child_recipes": 3, + "native_columns_each": 512, + "orientations": 2, + "phase_included": true, + "residual_recipes": 54, + "source_endpoint_recipes": 4 + }, + "rejected_controls": [ + "forward fan-in sign", + "dual fan-in sign", + "rank-two child undercharge", + "tail phase substitution", + "wrapper side", + "dual wrapper owner", + "post wrappers before cleanup", + "source exit frame", + "missing dirty restoration", + "extra fan-in observer", + "prefix wrong source frame", + "native global phase", + "native translation", + "native child rank", + "residual global phase", + "residual translation" + ], + "scalar_control": { + "columns_per_orientation": 632, + "restore_gates": 204 + } + } + }, + "scope": "R2 tail/final binding, three native children, four source endpoints, all used residual recipes and placement. Other native phases, physical owners, full cleanup semantics and supplier/outer theorem remain outside this audit.", + "status": "PASS_PR3044_R2_NATIVE_SLICE" +} diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/SOURCES.json b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/SOURCES.json new file mode 100644 index 0000000000..71f2c61df0 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/SOURCES.json @@ -0,0 +1,84 @@ +{ + "schema_version": 1, + "base_commit": "997e6a9ca7b4f95d50e366f61412fd640d72a88a", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/frontier1094-recipes-exact-seed76/clifford.py", + "usage": "input", + "git_blob": "6f1e6a38febde7eb7a7341d317522e6650d84408", + "sha256": "d5e42ddabd141b7bfbd70fe13908f3c3a06aeccebeab90623596bfb1988b97fb" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/NATIVE-RECEIPT.json", + "usage": "input", + "git_blob": "9b7c498ed6f92be5f1c4a85a1f25427788647fc1", + "sha256": "3dce85d535c34dd5755b7a7828b9706cd38198aa99e849dc0f166ac4e7ea47df" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/SOURCE-MANIFEST.json", + "usage": "input", + "git_blob": "ff42fd06f9ede0e1a717766232e283005336f935", + "sha256": "4f52f55eb311319a7e8ac7de7f4e9cc45e36166270db42c21c955c96a2e0639c" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-base.json.gz", + "usage": "input", + "git_blob": "51b0b3c912565b7e12b3a2f8a3c0ccd37290206b", + "sha256": "08e7e10e49053b97b7ae8a7e93f085ade519f3d270ed54b9c0c3a19236a4d267" + }, + { + "path": "research/rank7-shared-restore-fanin/evidence/WORD-extra.json.gz", + "usage": "input", + "git_blob": "23915f0bec7533ce0658cac8c7ae2069873efe4b", + "sha256": "9c625893f09e46688fc650e1d65d05a416b504e2dcffe5fefdc4181c6de22479" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_transport.py", + "usage": "input", + "git_blob": "08248542b18864c94a5ac050c8669f68519838e1", + "sha256": "9818e08b819310b40f1441b89be8c4369584a5b3fa5dfe9b86b1df9a7f5d6a76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_emit.py", + "usage": "input", + "git_blob": "6d47f63ab7a533941b3881bbfd3ae4dac5f76932", + "sha256": "99b59a6fa3feda86785e4225157dcb1a6169d256cec4f5e0acc9cea7a701df76" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_phases.py", + "usage": "input", + "git_blob": "99f351785ebca5fbf3336bedcd7b48bac9c255e5", + "sha256": "9d1a620e26715f4c42fd0347ecc14ef5a4a9031867869b64e8bae4d8526a821e" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_adapters.py", + "usage": "input", + "git_blob": "82beaa9c1d13bcd5f79d0a5e10e8a10733eac347", + "sha256": "c5907050a9a7fa36d4fcba3ad4fe440d1bec2063360c095013891785ba65c3ce" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/bw_gauss.py", + "usage": "input", + "git_blob": "1ff29dfb244e2114de8e586a450ae9fb70308d58", + "sha256": "0884b14d6d77cde419a3c773ad9b21d0d18de1e6e20e6b6d5add458ed32ba4cb" + }, + { + "path": "research/two-sided-helper-extraction/vendor/fastnative/vendor/native/new/code/borrow/vendor/clifford/clifford_exact.py", + "usage": "input", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + } + ] +} diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CANONICAL-WORD.json.gz b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CANONICAL-WORD.json.gz new file mode 100644 index 0000000000..3958b8cf77 Binary files /dev/null and b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CANONICAL-WORD.json.gz differ diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz new file mode 100644 index 0000000000..0591c6af1b Binary files /dev/null and b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/CLIFFORD-RECIPES.json.gz differ diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz new file mode 100644 index 0000000000..9ad65235dc Binary files /dev/null and b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/LOCAL-PROGRAMS.json.gz differ diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz new file mode 100644 index 0000000000..3e154660a1 Binary files /dev/null and b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/base/RESIDUAL-ADAPTERS.json.gz differ diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz new file mode 100644 index 0000000000..c2c7a69938 Binary files /dev/null and b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CANONICAL-WORD.json.gz differ diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz new file mode 100644 index 0000000000..887f5bfc36 Binary files /dev/null and b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/CLIFFORD-RECIPES.json.gz differ diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz new file mode 100644 index 0000000000..9ad65235dc Binary files /dev/null and b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/LOCAL-PROGRAMS.json.gz differ diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz new file mode 100644 index 0000000000..3cb1e2927f Binary files /dev/null and b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/data/extra/RESIDUAL-ADAPTERS.json.gz differ diff --git a/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/verify.py b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/verify.py new file mode 100644 index 0000000000..0ed4963416 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/vendor/pr3202/verify.py @@ -0,0 +1,487 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Source-bound R2 native slice; no native producer code is imported.""" +import argparse +import copy +from fractions import Fraction +import gzip +import hashlib +import json +from pathlib import Path +import types + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parents[1] +SOURCE = 'research/rank7-shared-restore-fanin/evidence/' +KERNEL = 'research/frontier1094-recipes-exact-seed76/clifford.py' +W = [256, 128, 64, 34, 17, 11, 4] +E = [256, 128, 64, 34, 16, 10, 4, 1] +FULL = [256, 128, 64, 32, 16, 8, 4, 2, 1] +PHASES = ['zero_frame_precondition', 'entry_adapters', 'A', 'centers', 'B', + 'cleanup_tail', 'final', 'exit_adapters', 'full_frame_cleanup', 'done'] +FILES = ('CANONICAL-WORD.json.gz', 'LOCAL-PROGRAMS.json.gz', + 'CLIFFORD-RECIPES.json', 'RESIDUAL-ADAPTERS.json') + + +def need(ok, reason): + if not ok: + raise ValueError(reason) + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def unique(pairs): + out = dict(pairs) + need(len(out) == len(pairs), 'duplicate JSON key') + return out + + +def parse(raw): + need(len(raw) <= 16 * 1024 * 1024, 'artifact capacity') + return json.loads(raw, object_pairs_hook=unique) + + +def read(path): + raw = path.read_bytes() + return parse(gzip.decompress(raw) if path.suffix == '.gz' else raw) + + +def pin_inputs(): + blobs = {} + for row in read(PACKAGE / 'SOURCES.json')['files']: + if row['usage'] == 'input': + raw = (ROOT / row['path']).read_bytes() + need(sha(raw) == row['sha256'], 'source pin: ' + row['path']) + blobs[row['path']] = raw + required = {KERNEL, SOURCE + 'NATIVE-RECEIPT.json', SOURCE + 'SOURCE-MANIFEST.json', + SOURCE + 'WORD-base.json.gz', SOURCE + 'WORD-extra.json.gz'} + need(required <= set(blobs), 'required source inventory') + return blobs + + +def artifacts(blobs, tag, data): + receipt = parse(blobs[SOURCE + 'NATIVE-RECEIPT.json'])['providers'][tag] + need(sha(blobs[SOURCE + f'WORD-{tag}.json.gz']) == receipt['word_sha256'], 'provider word binding') + out = {} + for name in FILES: + path = data / tag / (name if name.endswith('.gz') else name + '.gz') + raw = path.read_bytes() + original = raw if name.endswith('.gz') else gzip.decompress(raw) + need(sha(original) == receipt['complete_native_files']['local/' + name], + 'native artifact binding: ' + tag + '/' + name) + out[name] = parse(gzip.decompress(original) if name.endswith('.gz') else original) + return out + + +def span(rows): + out = {0} + for x in rows: + need(type(x) is int and 0 < x < 512 and x not in out, 'independent binary frame') + out |= {y ^ x for y in out} + return frozenset(out) + + +def regs(g): + need(g[0] in ('add', 'scale'), 'restore gate kind') + need(len(g) == (6 if g[0] == 'add' else 5), 'restore gate schema') + return g[1:3] if g[0] == 'add' else g[1:2] + + +def frame_boundaries(word, canonical): + """Read source frame labels, independently of the emitted prefix.""" + need((word['report']['h'], word['report']['v'], word['report']['R']) == (9, 112, 480), 'source domain') + need((canonical['h'], canonical['v'], canonical['R']) == (9, 112, 408) + and canonical['ports'] == word['ports'], 'canonical domain and source ports') + kept = [r for r in range(704) if r not in word['removed']] + need(len(kept) == 632 and kept[224:] == canonical['helper_origin'], 'compact map') + frames = canonical['frames'] + spaces = [span(f) for f in frames] + need(len(set(spaces)) == len(spaces), 'unique canonical frames') + ids = {s: i for i, s in enumerate(spaces)} + starts = {r: [word['ports'][r]] if r < 112 else [] for r in kept} + starts.update({int(r): f for r, f in word['start_extra'].items()}) + need([ids[span(starts[r])] for r in kept] == canonical['start'], 'source entrances') + finals = {r: FULL for r in kept} + for r in range(112, 224): + p = word['ports'][r - 112] + need(spaces[canonical['final'][r]] == frozenset(x for x in range(512) if (x & p).bit_count() % 2 == 0), + 'target terminal frame') + finals[r] = frames[canonical['final'][r]] + finals.update({int(r): f for r, f in word['helper_final'].items()}) + need([ids[span(finals[r])] for r in kept] == canonical['final'], 'source terminals') + state = {r: ids[span(starts[r])] for r in kept} + + def move(r, target): + f = ids[span(target)] + need(spaces[state[r]] <= spaces[f], 'source monotone frame') + state[r] = f + + for g in word['A']: + if g[0] == 'warp': + need(state[g[1]] == ids[span(g[3])], 'A warp boundary') + state[g[1]] = ids[span(g[4])] + else: + for r in regs(g): + move(r, g[-1]) + warps = {} + for pos, r, _columns, old, new in word['warps']: + warps.setdefault(pos, []).append((r, old, new)) + for i in range(len(word['B']) + 1): + for r, old, new in warps.get(i, []): + need(state[r] == ids[span(old)], 'B warp boundary') + state[r] = ids[span(new)] + if i < len(word['B']): + for r in regs(word['B'][i]): + move(r, word['B'][i][-1]) + return kept, ids, [state[r] for r in kept] + + +def scalar(g, mapping, backward): + operands = [['L', mapping[r]] for r in regs(g)] + a, b = g[-3:-1] + need(type(a) is int and type(b) is int and a and b, 'nonzero rational scalar') + if backward and g[0] == 'add': + operands.reverse() + a = -a + elif backward: + a, b = b, a + return [g[0], *operands, a, b] + + +def expected_tail(word, canonical, kept, ids, boundary, backward): + state = boundary.copy() + mapping = {r: i for i, r in enumerate(kept)} + frames = canonical['frames'] + spaces = [span(f) for f in frames] + out, touched = [], [] + for i, g in enumerate(word['restore']): + f = ids[span(g[-1])] + for old_r in regs(g): + r = mapping[old_r] + old = state[r] + need(spaces[old] <= spaces[f], 'tail monotone frame') + if old != f: + event = ['climb', 'cleanup_tail', r, old, f, len(frames[f]) - len(frames[old])] + out.append(event) + if old_r in (40, 54) and i >= 162: + touched.append([i, event]) + state[r] = f + out.append(['scalar', scalar(g, mapping, backward), f]) + final = [] + for r, f in enumerate(canonical['final']): + old = state[r] + need(spaces[old] <= spaces[f], 'final monotone frame') + if old != f: + final.append(['climb', 'final', r, old, f, len(frames[f]) - len(frames[old])]) + return out, final, touched + + +def bind_events(word, canonical, programs): + kept, ids, boundary = frame_boundaries(word, canonical) + frames = canonical['frames'] + wrapped = [r for r in range(224, len(kept)) if canonical['start'][r] != 0 or canonical['final'][r] != 1] + keys = [str(canonical['start'][r]) if canonical['final'][r] == 1 else + f"{canonical['start'][r]}:{canonical['final'][r]}" for r in wrapped] + need(set(programs) == {'forward', 'backward'}, 'both emitted orientations') + report = {} + for orientation, stream in programs.items(): + need(len(stream) <= 50000, 'event capacity') + phases, sections = [], {} + cursor = canonical['start'].copy() + spaces = [span(f) for f in frames] + for event in stream: + need(type(event) is list and event, 'event schema') + if event[0] == 'phase': + phases.append(event[1]) + need(phases == PHASES[:len(phases)], 'phase order') + sections[event[1]] = [] + if event[1] == 'cleanup_tail': + need(cursor == boundary, 'emitted/source tail entrance') + else: + need(phases, 'event before phase') + sections[phases[-1]].append(event) + if phases[-1] in PHASES[:5]: + if event[0] == 'climb': + _, phase, r, old, new, rank = event + need(phase == phases[-1] and cursor[r] == old and spaces[old] < spaces[new] + and rank == len(frames[new]) - len(frames[old]), 'prefix climb chronology') + cursor[r] = new + elif event[0] == 'warp': + _, role, _op, old, new = event + need(role[0] == 'L' and cursor[role[1]] == old, 'prefix warp chronology') + cursor[role[1]] = new + need(phases == PHASES, 'complete phases') + tail, final, touched = expected_tail(word, canonical, kept, ids, boundary, orientation == 'backward') + need(sections['cleanup_tail'] == tail, 'exact source tail event sequence') + need(sections['final'] == final, 'exact final event sequence') + expected_wrappers = [] + for side in ('pre', 'post'): + for r in wrapped: + a, b = canonical['start'][r], canonical['final'][r] + expected_wrappers.append(['entry_adapters' if side == 'pre' else 'full_frame_cleanup', + ['residual_adapter', side, r, a] + ([b] if b != 1 else [])]) + actual = [[phase, e] for phase in PHASES for e in sections[phase] if e[0] == 'residual_adapter'] + need(actual == expected_wrappers, 'residual wrapper owner/side/phase binding') + post = [e for phase, e in expected_wrappers if phase == 'full_frame_cleanup'] + need(sections['full_frame_cleanup'][-len(post):] == post, 'post wrappers after complete cleanup') + entry_all = [] + for r, a in enumerate(canonical['start']): + b = canonical['final'][r] + entry_all.append(['residual_adapter', 'pre', r, a] + ([b] if b != 1 else []) + if r in wrapped else ['adapter', 'old_to_new', r, a]) + need(sections['entry_adapters'] == entry_all, 'complete entry adapter phase') + for r in (18, 22, 40, 54): + need(r not in wrapped and canonical['final'][r] == 1, 'R2 ordinary source boundary') + entry = [e for e in sections['entry_adapters'] if e[0] == 'adapter' and e[2] == r] + exit_ = [e for e in sections['exit_adapters'] if e[0] == 'adapter' and e[2] == r] + need(entry == [['adapter', 'old_to_new', r, canonical['start'][r]]] and + exit_ == [['adapter', 'new_to_old', r, 1]], 'ordinary source adapter binding') + need([(i, e[2], frames[e[3]], frames[e[4]], e[5]) for i, e in touched] == + [(163, 40, W, E, 1), (203, 40, E, FULL, 1), (203, 54, W, FULL, 2)], + 'exact changed native climbs') + report[orientation] = {'events': len(stream), 'tail_events': len(tail), + 'final_events': len(final), 'changed_climbs': touched, 'wrapper_occurrences': len(actual)} + return report, sorted(set(keys)), ids + + +def restore_control(word): + gates = word['restore'] + need(len(gates) == 204, 'R2 restore length') + literals = {162: ['add', 40, 54, -2, 1, W], 163: ['add', 18, 40, 1, 1, E], + 175: ['add', 22, 40, 1, 1, E], 176: ['add', 22, 45, -1, 1, E], + 203: ['add', 40, 54, 2, 1, FULL]} + need(all(gates[i] == g for i, g in literals.items()), 'R2 literal boundaries') + need([i for i, g in enumerate(gates) if i >= 162 and set(regs(g)) & {40, 54}] == + [162, 163, 175, 203], 'exclusive fan-in source contacts') + old = copy.deepcopy(gates[:162] + gates[163:203]) + old.insert(163, ['add', 18, 54, -2, 1, E]) + old.insert(177, ['add', 22, 54, -2, 1, E]) + kept = [r for r in range(704) if r not in word['removed']] + + def matrix(gs, backward): + rows = {r: {r: Fraction(1)} for r in kept} + for g in gs: + if g[0] == 'scale': + q = Fraction(g[2], g[3]) + q = 1 / q if backward else q + rows[g[1]] = {j: q * x for j, x in rows[g[1]].items()} + else: + dst, src = g[1:3] + q = Fraction(g[3], g[4]) + if backward: + dst, src, q = src, dst, -q + for j, x in list(rows[src].items()): + value = rows[dst].get(j, 0) + q * x + if value: + rows[dst][j] = value + else: + rows[dst].pop(j, None) + return rows + for backward in (False, True): + need(matrix(gates, backward) == matrix(old, backward), 'R1/R2 arbitrary-input equality') + return {'columns_per_orientation': len(kept), 'restore_gates': len(gates)} + + +def dual(circuit): + result = copy.deepcopy(circuit) + for i, g in enumerate(result): + if g[0] == 'C': + result[i] = (g[0], g[1], -g[2]) + elif g[0] == 'D': + result[i] = (g[0], g[1], [(-a) % 4 for a in g[2]]) + elif g[0] == 'PH': + result[i] = (g[0], -g[1] % 4) + else: + need(g[0] in ('P', 'X'), 'dual native gate') + return result + + +def decode(kernel, rec): + need(type(rec['rank']) is int and 0 <= rec['rank'] <= 9, 'native rank domain') + need(kernel.well_formed(rec['left']), 'left monomial schema') + if rec['rank'] == 0: + need(rec['right'] is None, 'rank-zero right factor') + return kernel.monomial(rec['left']) + need(kernel.well_formed(rec['right']), 'right monomial schema') + return kernel.monomial(rec['right']) + kernel.fourier(rec['rank']) + kernel.monomial(rec['left']) + + +def check_recipe(kernel, rec, old, new, cache): + need(rec['rank'] == len(new) - len(old), 'recipe rank difference') + key = json.dumps([rec, old, new], sort_keys=True) + actual = decode(kernel, rec) + if key not in cache: + expected = kernel.adjoint(kernel.canonical_frame(old)) + kernel.canonical_frame(new) + need(kernel.same_operator(actual, expected), 'native phase-exact operator') + need(kernel.same_operator(dual(actual), dual(expected)), 'dual phase-exact operator') + cache.add(key) + return actual + + +def semantics(kernel, canonical, recipes, adapters, keys, ids, cache): + frames = canonical['frames'] + children = {(r['old'], r['new']): r for r in recipes['children']} + need(len(children) == len(recipes['children']), 'unique child recipe keys') + circuits = [] + for old, new in ((W, E), (E, FULL), (W, FULL)): + key = (ids[span(old)], ids[span(new)]) + need(key in children, 'changed child recipe coverage') + circuits.append(check_recipe(kernel, children[key], old, new, cache)) + need(kernel.same_operator(circuits[0] + circuits[1], circuits[2]), 'split/fused native equality') + need(kernel.same_operator(dual(circuits[0] + circuits[1]), dual(circuits[2])), 'dual split/fused equality') + need(set(adapters['recipes']) == set(keys), 'exact used residual recipe inventory') + for key in keys: + rec = adapters['recipes'][key] + a, b = rec['frame'], rec.get('terminal', 1) + need(key == (str(a) if b == 1 else f'{a}:{b}'), 'residual recipe key') + need(rec['vectors'] == frames[a] and rec['entrance_rank'] == len(frames[a]), 'residual entrance metadata') + if b != 1: + need(rec['terminal_vectors'] == frames[b] and rec['terminal_rank'] == len(frames[b]), + 'residual terminal metadata') + check_recipe(kernel, rec, frames[a], frames[b], cache) + wrapped_key = 'wrapped:' + json.dumps([rec, frames[a], frames[b]], sort_keys=True) + if wrapped_key not in cache: + sequence = (kernel.adjoint(kernel.monomial(rec['right'])) + + kernel.adjoint(kernel.canonical_frame(frames[a])) + kernel.canonical_frame(frames[b]) + + kernel.adjoint(kernel.monomial(rec['left']))) + need(kernel.same_operator(sequence, kernel.fourier(rec['rank'])), 'inverse residual wrapper order') + need(kernel.same_operator(dual(sequence), kernel.fourier(rec['rank'], -1)), 'dual residual wrapper order') + cache.add(wrapped_key) + for r in (18, 22, 40, 54): + matches = [x for x in recipes['endpoint_adapters'] if x['role'] == 'source' and x['port'] == r] + need(len(matches) == 1, 'source endpoint recipe coverage') + rec = matches[0] + need(rec['rank'] == 0 and rec['frame'] == canonical['start'][r], 'source endpoint rank/frame') + reference = [('C', canonical['ports'][r], -1)] + kernel.canonical_frame(frames[rec['frame']]) + actual = decode(kernel, rec) + need(kernel.same_operator(actual, reference), 'source endpoint phase') + need(kernel.same_operator(dual(actual), dual(reference)), 'dual source endpoint phase') + return {'changed_child_recipes': 3, 'residual_recipes': len(keys), 'source_endpoint_recipes': 4, + 'native_columns_each': 512, 'orientations': 2, 'phase_included': True} + + +def audit(kernel, word, data, cache): + canonical, programs, recipes, adapters = (data[n] for n in FILES) + events, keys, ids = bind_events(word, canonical, programs) + return {'events': events, 'scalar_control': restore_control(word), + 'native': semantics(kernel, canonical, recipes, adapters, keys, ids, cache)} + + +def failure_controls(kernel, word, data): + """Mutate semantic payloads after authentication, so hash checks cannot mask bugs.""" + rejected = [] + + def reject(name, mutate, predicate, reason): + w, d = copy.deepcopy(word), copy.deepcopy(data) + mutate(w, d) + need(w != word or d != data, 'nonvacuous mutant: ' + name) + try: + predicate(w, d) + except ValueError as exc: + need(str(exc) == reason, 'wrong rejection for ' + name + ': ' + str(exc)) + rejected.append(name) + else: + raise ValueError('semantic mutant accepted: ' + name) + + event_check = lambda w, d: bind_events(w, d[FILES[0]], d[FILES[1]]) + def event(d, orientation, predicate): + return next(e for e in d[FILES[1]][orientation] if predicate(e)) + + reject('forward fan-in sign', lambda w, d: event(d, 'forward', lambda e: e[:1] == ['scalar'] and + e[1] == ['add', ['L', 40], ['L', 54], -2, 1])[1].__setitem__(3, 2), + event_check, 'exact source tail event sequence') + reject('dual fan-in sign', lambda w, d: event(d, 'backward', lambda e: e[:1] == ['scalar'] and + e[1] == ['add', ['L', 54], ['L', 40], 2, 1])[1].__setitem__(3, -2), + event_check, 'exact source tail event sequence') + reject('rank-two child undercharge', lambda w, d: event(d, 'forward', lambda e: + e[:3] == ['climb', 'cleanup_tail', 54] and e[-1] == 2).__setitem__(5, 1), + event_check, 'exact source tail event sequence') + reject('tail phase substitution', lambda w, d: event(d, 'forward', lambda e: + e == ['phase', 'cleanup_tail']).__setitem__(1, 'final'), event_check, 'phase order') + reject('wrapper side', lambda w, d: event(d, 'forward', lambda e: + e[:2] == ['residual_adapter', 'post']).__setitem__(1, 'pre'), + event_check, 'residual wrapper owner/side/phase binding') + reject('dual wrapper owner', lambda w, d: event(d, 'backward', lambda e: + e[:2] == ['residual_adapter', 'pre']).__setitem__(2, 40), + event_check, 'residual wrapper owner/side/phase binding') + def early_post(w, d): + stream = d[FILES[1]]['forward'] + i = next(i for i, e in enumerate(stream) if e[:2] == ['residual_adapter', 'post']) + j = next(i for i, e in enumerate(stream) if e == ['phase', 'full_frame_cleanup']) + block = stream[i:-1] + del stream[i:-1] + stream[j + 1:j + 1] = block + reject('post wrappers before cleanup', early_post, event_check, 'post wrappers after complete cleanup') + reject('source exit frame', lambda w, d: event(d, 'forward', lambda e: + e[:3] == ['adapter', 'new_to_old', 40]).__setitem__(3, 0), + event_check, 'ordinary source adapter binding') + reject('missing dirty restoration', lambda w, d: w['restore'].pop(), + lambda w, d: restore_control(w), 'R2 restore length') + reject('extra fan-in observer', lambda w, d: w['restore'][180].__setitem__(2, 54), + lambda w, d: restore_control(w), 'exclusive fan-in source contacts') + reject('prefix wrong source frame', lambda w, d: event(d, 'forward', lambda e: + e[0] == 'climb' and e[3] != 0).__setitem__(3, 0), event_check, 'prefix climb chronology') + + wid = data[FILES[0]]['frames'].index(W) + def child(d): + return next(x for x in d[FILES[2]]['children'] if (x['old'], x['new']) == (wid, 1)) + def phase(rec): + rec['left']['phase'] = (rec['left']['phase'] + 1) % 4 + child_check = lambda w, d: check_recipe(kernel, child(d), W, FULL, set()) + reject('native global phase', lambda w, d: phase(child(d)), child_check, 'native phase-exact operator') + reject('native translation', lambda w, d: child(d)['left'].__setitem__('offset', child(d)['left']['offset'] ^ 1), + child_check, 'native phase-exact operator') + reject('native child rank', lambda w, d: child(d).__setitem__('rank', 1), child_check, 'recipe rank difference') + key = sorted(data[FILES[3]]['recipes'])[0] + def residual_check(w, d): + rec = d[FILES[3]]['recipes'][key] + frames = d[FILES[0]]['frames'] + check_recipe(kernel, rec, frames[rec['frame']], frames[rec.get('terminal', 1)], set()) + reject('residual global phase', lambda w, d: phase(d[FILES[3]]['recipes'][key]), + residual_check, 'native phase-exact operator') + reject('residual translation', lambda w, d: d[FILES[3]]['recipes'][key]['right'].__setitem__('offset', + d[FILES[3]]['recipes'][key]['right']['offset'] ^ 1), residual_check, 'native phase-exact operator') + return rejected + + +def compute(data_path): + blobs = pin_inputs() + kernel = types.ModuleType('r2_independent_clifford') + exec(compile(blobs[KERNEL], KERNEL, 'exec'), kernel.__dict__) + need(kernel.same_operator([('C', 1, 1), ('C', 1, 1)], [('X', 1)]), 'hand C squared calibration') + need(kernel.same_operator([('C', 3, 1), ('C', 3, -1)], []), 'hand inverse calibration') + need(not kernel.same_operator([('PH', 1)], []), 'global phase sensitivity calibration') + cache, providers = set(), {} + for tag in ('base', 'extra'): + word = parse(gzip.decompress(blobs[SOURCE + f'WORD-{tag}.json.gz'])) + data = artifacts(blobs, tag, data_path) + providers[tag] = audit(kernel, word, data, cache) + providers[tag]['rejected_controls'] = failure_controls(kernel, word, data) + need(pin_inputs() == blobs, 'source changed during check') + return {'status': 'PASS_PR3044_R2_NATIVE_SLICE', 'providers': providers, + 'kernel_sha256': sha(blobs[KERNEL]), + 'scope': 'R2 tail/final binding, three native children, four source endpoints, all used residual ' + 'recipes and placement. Other native phases, physical owners, full cleanup semantics ' + 'and supplier/outer theorem remain outside this audit.'} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--emit', action='store_true') + parser.add_argument('--data', type=Path, default=PACKAGE / 'data') + args = parser.parse_args() + result = compute(args.data) + if args.emit: + print(json.dumps(result, indent=2, sort_keys=True)) + else: + need(result == read(PACKAGE / 'RESULT.json'), 'saved result differs') + print(result['status']) + + +if __name__ == '__main__': + try: + main() + except (ValueError, KeyError, TypeError, IndexError, OSError) as exc: + raise SystemExit('FAIL: ' + str(exc)) from None diff --git a/research/r2-mutation-path-copy/vendor/pr3218/verify.py b/research/r2-mutation-path-copy/vendor/pr3218/verify.py new file mode 100644 index 0000000000..b4844357c0 --- /dev/null +++ b/research/r2-mutation-path-copy/vendor/pr3218/verify.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +"""Full opt-in replay, independent controls and exact receipt comparison. +Tekalign / OpenAI Codex, Apache-2.0. +""" +import argparse +import json +from pathlib import Path +import types + +PACKAGE = Path(__file__).resolve().parent + + +def load(name): + path = PACKAGE / (name + '.py') + obj = types.ModuleType('anchor_' + name) + obj.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), obj.__dict__) + return obj + + +def calculate(): + replay = load('replay') + result = replay.run('anchor') + checks = load('controls').check() + return {'status': 'PASS_CLIFFORD_PAULI_ANCHOR', + 'base_commit': '463113d675af7410ac91d53a4fed51ec6494eb9a', + 'dependency_pr3202': '259043321323717b7e816d6be38ad5e1f0b69b4c', + 'reference_result_sha256': result['reference_result_sha256'], + 'call_multiset_sha256': result['call_multiset_sha256'], 'decisions': result['calls'], + 'source_sha256': result['source_sha256'], 'controls': checks, + 'coverage': 'Exact equality on the 512-dimensional operator domain, via signed Pauli action and one whole anchor column; not 512 explicitly simulated input columns.', + 'new_kappa': False, 'formal_kernel_proof': False} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--emit-result', action='store_true') + args = parser.parse_args() + result = calculate() + if args.emit_result: + print(json.dumps(result, indent=2, sort_keys=True)) + else: + expected = json.loads((PACKAGE / 'RESULT.json').read_bytes()) + if json.dumps(result, sort_keys=True) != json.dumps(expected, sort_keys=True): + raise ValueError('stored result mismatch') + print('PASS_CLIFFORD_PAULI_ANCHOR calls=253 accepted=244 rejected=9 matrix_controls=4704') + + +if __name__ == '__main__': + main() diff --git a/research/r2-mutation-path-copy/verify.py b/research/r2-mutation-path-copy/verify.py new file mode 100644 index 0000000000..7e43f917db --- /dev/null +++ b/research/r2-mutation-path-copy/verify.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +"""Complete replay, full-deepcopy differential mutants and isolation controls. +Tekalign / OpenAI Codex, Apache-2.0. +""" +import argparse +import json +from pathlib import Path +import types + +PACKAGE = Path(__file__).resolve().parent + + +def load(name): + path = PACKAGE / (name + '.py') + module = types.ModuleType('path_verify_' + name) + module.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), 'exec'), module.__dict__) + return module + + +def calculate(): + result = load('replay').run('paths', differential=True) + return {'status': 'PASS_R2_PATH_COPY', 'complete_mutants_compared_to_deepcopy': 32, + **{k: result[k] for k in ('reference_result_sha256', 'call_multiset_sha256', + 'decisions', 'providers', 'source_sha256')}, + 'controls': load('controls').check(), 'new_kappa': False} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--emit-result', action='store_true') + args = parser.parse_args() + result = calculate() + if args.emit_result: + print(json.dumps(result, sort_keys=True, indent=2)) + else: + if result != json.loads((PACKAGE / 'RESULT.json').read_bytes()): + raise ValueError('stored full result differs') + print('PASS_R2_PATH_COPY mutants=32 complete_deepcopy_equivalence=32 decisions=253') + + +if __name__ == '__main__': + main()