diff --git a/research/selected-single-pass-qualification/BENCHMARK.json b/research/selected-single-pass-qualification/BENCHMARK.json new file mode 100644 index 0000000000..fec8e97ea2 --- /dev/null +++ b/research/selected-single-pass-qualification/BENCHMARK.json @@ -0,0 +1,13 @@ +{ + "baseline_cpu_seconds": 403.68, + "baseline_wall_seconds": 405.85850924099213, + "candidate_cpu_seconds": 268.56, + "candidate_wall_seconds": 268.9318538699881, + "complete_output_equivalence": true, + "cpu_fraction_saved": 0.3347205707491082, + "limitations": "One source-bound fresh-process pair on a shared host; not a median or universal speedup.", + "original_cross_stdout_sha256": "f4c811b22ed856202b5a2607b108dec04b2adaa4607e0bc94b3bf84c5d69a594", + "original_verify_stdout_sha256": "311294ae4311f9668487882dbeadf8750324b91eeb3546545cc2d8fa2ba880ee", + "samples_per_arm": 1, + "wall_fraction_saved": 0.33737534695792026 +} diff --git a/research/selected-single-pass-qualification/COVERAGE-GATE.json b/research/selected-single-pass-qualification/COVERAGE-GATE.json new file mode 100644 index 0000000000..4abff4372c --- /dev/null +++ b/research/selected-single-pass-qualification/COVERAGE-GATE.json @@ -0,0 +1,57 @@ +{ + "gate": "G1_PASS_BEFORE_FULL_INTEGRATION", + "source_head": "53006fe6031dab5c23d5b7d1cf6a92f411a04a68", + "small_test": "3 actual-adapter inputs; 1536 amplitudes per unchanged literal interpreter; complete small receipts equal; 13 exact-predicate controls pass normally and optimized", + "orchestration_sha256": "8d391ad97edf8ca3966a9dd232832474d8b07056cb07b6dee77d1d1d334ed0f3", + "map": [ + [ + "54 source export files", + "source.payload exact archive/manifest/member hashes before imports" + ], + [ + "31 live inputs and 4 derived ASTs", + "unchanged verify.main and cross.main call pins.authenticate and binding.check" + ], + [ + "1522-state adapter/cache/type/mutation corpus and 3 omitted-proof controls", + "unchanged verify.main -> checks.run before observation; counters and cache reset required" + ], + [ + "complete construction/RESULT/WORD/native phases/caller/invoice/compiler/outer checks", + "unchanged verify_source.main([]) executes once with observational A.TRACE set" + ], + [ + "complete original RESULT fields, source hashes, controls and cache counts", + "unchanged verify.main compares original RESULT.json after shared execution" + ], + [ + "complete actual input trace, counters, collection and fresh cross trace lifecycle", + "first observer captures only source keys; second callback requires exact unchanged counters/cache and empty trace before transferring; unchanged cross.main hashes full sorted trace" + ], + [ + "all 17651 state inputs and 9037312 entries per interpreter, zeros and denominators", + "unchanged cross.main full dense/sparse/second-literal loop" + ], + [ + "complete original CROSS receipt", + "unchanged cross.main comparison with original CROSS.json" + ], + [ + "normal and optimized failures", + "fresh process runs with original explicit assertion conversion unchanged" + ], + [ + "original fresh process separation", + "duplicate source execution deliberately coalesced, not preserved as a separate test. Fresh normal/optimized runs and original standalone commands retained; no persistent reuse." + ], + [ + "failure propagation and hook restoration", + "try/finally restores source.main and TRACE; small exact-exception controls cover both phases" + ], + [ + "source bytes/modes and storage", + "private Git-free read-only export; input inventory checked before/after; frozen originals never changed" + ] + ], + "independence_limit": "The two legacy literal interpreters remain independent of the quadratic engine. The cross phase shares source execution and process state by design; it is not an independent second complete source replay. Complete counter/cache equality and cold separate mode runs detect listed contamination, not all possible interpreter/environment defects." +} diff --git a/research/selected-single-pass-qualification/EVIDENCE-SHA256.json b/research/selected-single-pass-qualification/EVIDENCE-SHA256.json new file mode 100644 index 0000000000..74b632c12c --- /dev/null +++ b/research/selected-single-pass-qualification/EVIDENCE-SHA256.json @@ -0,0 +1,26 @@ +{ + "evidence/CUSTODY-NORMAL.txt": "998f8d0c6313ce5f2b63612966b75fcb76ea4e8439e3b5606cbae6b9315fa7a3", + "evidence/CUSTODY-OPTIMIZED.txt": "998f8d0c6313ce5f2b63612966b75fcb76ea4e8439e3b5606cbae6b9315fa7a3", + "evidence/SMALL-NORMAL.txt": "08b5f25a4804581558428ecc689de05303e167eea7236a536cb2b018eb03ab4a", + "evidence/SMALL-OPTIMIZED.txt": "08b5f25a4804581558428ecc689de05303e167eea7236a536cb2b018eb03ab4a", + "evidence/runs/baseline-cross/receipt.json": "e6f857b701527905d000119fff31c6ece938bbb9615abdef57cb597449df6f6b", + "evidence/runs/baseline-cross/stderr.txt": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "evidence/runs/baseline-cross/stdout.txt": "f4c811b22ed856202b5a2607b108dec04b2adaa4607e0bc94b3bf84c5d69a594", + "evidence/runs/baseline-cross/usage.json": "a66f4bdccbaaa1787e68d5e389dcf3f4e3b17b89b65eb9b644e598e4b9192c27", + "evidence/runs/baseline-verify/receipt.json": "32a46de040acfd178f0562790718c5adf93cdb3e085031b404a8331acec9dbae", + "evidence/runs/baseline-verify/stderr.txt": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "evidence/runs/baseline-verify/stdout.txt": "311294ae4311f9668487882dbeadf8750324b91eeb3546545cc2d8fa2ba880ee", + "evidence/runs/baseline-verify/usage.json": "69b071996f29f42b0485af44e5949df6ff9c67edbd660ec2d73332645179cc74", + "evidence/runs/candidate-normal/receipt.json": "81990012443d6be3439720c0d2c21f3554099565de376e29d62d48495f473116", + "evidence/runs/candidate-normal/stderr.txt": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "evidence/runs/candidate-normal/stdout.txt": "c796be009d692546eab74e3ac084ec6badf45245841d81f101c2a164c0a6eaba", + "evidence/runs/candidate-normal/usage.json": "d50b2d8fba6fc2fe2863b2056642ebf42dae5a4d41fcaf068655cdc7c96da3c6", + "evidence/runs/candidate-optimized/receipt.json": "588025cbc3196504f1a67bd45203d8aa3ea77d7c8db80ea03c9bd7b7867cf39e", + "evidence/runs/candidate-optimized/stderr.txt": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "evidence/runs/candidate-optimized/stdout.txt": "c796be009d692546eab74e3ac084ec6badf45245841d81f101c2a164c0a6eaba", + "evidence/runs/candidate-optimized/usage.json": "93974c78ba2336417ad85b350ed050ae506d50ae734f3a2c4be770321bdd4b66", + "evidence/runs/candidate-sealed-optimized/receipt.json": "94f79e146403bc595624dbdf60272b79718b215b1612001c818be34663a4db57", + "evidence/runs/candidate-sealed-optimized/stderr.txt": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "evidence/runs/candidate-sealed-optimized/stdout.txt": "c796be009d692546eab74e3ac084ec6badf45245841d81f101c2a164c0a6eaba", + "evidence/runs/candidate-sealed-optimized/usage.json": "59caac70dcb2aaa6fdbe4149f2c390a08d7c69c19abc76b84925ec3c6f2b7479" +} diff --git a/research/selected-single-pass-qualification/INPUT-MANIFEST.json b/research/selected-single-pass-qualification/INPUT-MANIFEST.json new file mode 100644 index 0000000000..de11329190 --- /dev/null +++ b/research/selected-single-pass-qualification/INPUT-MANIFEST.json @@ -0,0 +1,383 @@ +{ + "source_head": "53006fe6031dab5c23d5b7d1cf6a92f411a04a68", + "files": [ + { + "path": "research/exact-clifford-quadratic-replay/NOTICE.md", + "bytes": 2006, + "git_blob": "b96b400e5ca04b3a9003a8b2c70a2461972d39d7", + "sha256": "a77adc71861e3b9c73c703c5db5b671f61a1101d85d14cca08547e21d6d8dce4", + "mode": "100644" + }, + { + "path": "research/exact-clifford-quadratic-replay/PROOF.md", + "bytes": 12120, + "git_blob": "559f9f4b207783c6eb908450b63eed3431594c22", + "sha256": "e5039414a02e36cdeab82fb9803fc4de0c3e0f3997e8812ef9d227e5d417ec91", + "mode": "100644" + }, + { + "path": "research/exact-clifford-quadratic-replay/quadratic.py", + "bytes": 10708, + "git_blob": "ce3c86ec07fd5767741e02ff0c88b93ba9164fb4", + "sha256": "d406584aed1479b75c387bc964b9e797b2f4f75e5f8c6bbea00df07f7d590a91", + "mode": "100644" + }, + { + "path": "research/higher-moment-strictification/verify.py", + "bytes": 17152, + "git_blob": "4b24a5096154736ce060474eb8c72dc64c303699", + "sha256": "0ce7e7137422d5ffeda22085c81fa88471bbe963100fdad62e659f1e3bf89326", + "mode": "100644" + }, + { + "path": "research/joint-helper-lattice/CONTROLLER.json", + "bytes": 57924, + "git_blob": "49a2f0675819f9deeea27ed77be2c2b6ff2e87e5", + "sha256": "1f5d6aa267e4e66048818714b5d3b5eae17a58abe91d15deeaa34574f7391a5f", + "mode": "100644" + }, + { + "path": "research/kappa-0023-productive-jobs/dependencies/kappa-next-regime/direct-decoder/sources/DATA-PHASES.json", + "bytes": 814141, + "git_blob": "d9a4f84211182ca200c081ea061d724c8a2cfb70", + "sha256": "c5916ff312678f12aba403847643fbbc29f643acec60bdf836fa56cd3e8251fa", + "mode": "100644" + }, + { + "path": "research/kappa-rebuild/architecture/mixed_target_probe.py", + "bytes": 12298, + "git_blob": "4fc05ab08138218ba9f09e5c89b649afae7c914e", + "sha256": "011c3c9d0cf81103dc84d709a0e36793eb7c5ae3f23c85eac27650ef13afa04a", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/NOTICE", + "bytes": 1212, + "git_blob": "f34687ff7eab377d5433f7b0c18274a816d2b73c", + "sha256": "8bbda66537ac761d632603066bdbb568ab5b26545030ea7979e27a85fcbe040c", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/PROOF.md", + "bytes": 9566, + "git_blob": "ca979984444a431b02b62da7094a3b23d5341742", + "sha256": "f4c68acf9373e34d88e14e1a7791b4b739c8b5297a1ae4c0121f579a02fde04e", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/README.md", + "bytes": 9172, + "git_blob": "f6303a881379723e1f6512dfe153fafeecbf62dd", + "sha256": "a83c5c3ae7a31a5dfbc3c7c59669ee55cc15f966a0cb4405cb48cb8fa2a94f56", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/RESULT.json", + "bytes": 13637, + "git_blob": "35f75c8555193c6e845cd52cc562ca23fd5924cb", + "sha256": "1d92e587915052110dfb3aca8890df5afdaf496164efa5a4a52e69ceeb3c70f3", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/SOURCES.json", + "bytes": 5725, + "git_blob": "f83bf3c8184bc2d40451ac6ba5e8f46e7bee89c1", + "sha256": "3c6dab6b491c904c8c2d2c76d5101ea13223ce7dc9b9a2acd2a37b038d1e6887", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/SPLITS.json", + "bytes": 5745, + "git_blob": "5108daabf7b30043b36da2875dcb30aee2fa7012", + "sha256": "0bf3cf7d2abe118daa6d319a40f4f1b74b3c993d21b8d0fcb95299624797b244", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/TASK.json", + "bytes": 6388, + "git_blob": "a230fe5b901af6abc3e3b2e20ca92273ce294d3a", + "sha256": "4e5928f3a40f831668fd759ddc5b131198622e2c6dd2229b3b0d56de89c41ce3", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/VALIDATION.md", + "bytes": 2419, + "git_blob": "7f73fd1454ba67cc05dd03edcbe9bfb79ee41630", + "sha256": "218e0e81fcd70c02fa2a1ae2f24676487ed498d93ce8dbc60f51c51d89e538ce", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/VERIFY.json", + "bytes": 1721, + "git_blob": "f02fe9b97043e626e9906346d230508247a5871d", + "sha256": "30499c00a5c6a9718561a152e8008ce1a765535647306dc4b2d2a7ce78b7b2ac", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/WORD.json.gz", + "bytes": 108031, + "git_blob": "e325091e3051afe37a2d9c82f85afe9028510edb", + "sha256": "bbb072bced5824a8d9094c49be2fc51fbfdd05fb2b7dab8106e1275053075099", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/construct.py", + "bytes": 6230, + "git_blob": "698a4cbcc0d7afbba8dccfb7f453315ed7230795", + "sha256": "8e1a674ebed7bffb9fd6995555895a9925b665c2dec0e91f2876ff043901006f", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/inputs/PR5565-WORD.json.gz", + "bytes": 105088, + "git_blob": "4ebe6fcb7adf319bf6b247cf23d89eb1ca4cd914", + "sha256": "3d62828f53e654e3db218bf4611a47aed4a677d48043713dc004db0f8a32990d", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/inputs/PR5580-WORD.json.gz", + "bytes": 105115, + "git_blob": "9434855e7dad0d0236d23210b3e71a2b83a9ae64", + "sha256": "b2a98c4bd0dbe86c09e9d15ee060dcf1aab09dbef90aa1e2127676f4039f406b", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/local.py", + "bytes": 9208, + "git_blob": "e6e28bacdad7cb51400d827b9a6e02f2b605d357", + "sha256": "ef430511ce36fc658ab711bd84cd2d7b484b8af173238ff89cbfec6139fefbad", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/pricing.py", + "bytes": 9814, + "git_blob": "0b54ad3f16e3c1068e9e36ee83187e150325a791", + "sha256": "637c8b0eea8bf870d866707de8230aa8ddd0c7401b56153f65b60913b025000b", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/search.py", + "bytes": 6014, + "git_blob": "1bf5329658683919a97430138b57860751da7ba9", + "sha256": "668022953f53929fd4d95ed1b5c01ac2ba3b4bdf6be7babae511757eb21b7e6a", + "mode": "100644" + }, + { + "path": "research/p104-helper-subspace-splits/verify.py", + "bytes": 6492, + "git_blob": "547751915ad09b2229bacf29af02241b0ef29696", + "sha256": "f79c78d009d8a88bc5721644237074569fbb992fe7e49784f4b0c0a97523ea91", + "mode": "100644" + }, + { + "path": "research/p104-native-channel/vendor/clifford_exact.py", + "bytes": 6824, + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "mode": "100644" + }, + { + "path": "research/p104-native-channel/vendor/native_verify.py", + "bytes": 12323, + "git_blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38", + "mode": "100644" + }, + { + "path": "research/p104-productive-controller/CONTROLLER.json", + "bytes": 60013, + "git_blob": "cc539db709cf7a6c42872c4380902736ad453af3", + "sha256": "a84f6bbd547379597464e56c420cc665f96bc43a9a1351eed4b7cd0fce3cc4b9", + "mode": "100644" + }, + { + "path": "research/p104-productive-controller/caller.py", + "bytes": 10267, + "git_blob": "6ac5e735691555ecafe2afbcff71edd923178113", + "sha256": "300d40043953e4f6aecfde8f2d1004b8ad6dc5a79ec3c7666c9908c2466c91c8", + "mode": "100644" + }, + { + "path": "research/pr4359-p7-padding/dependencies/compiler-refill/endpoint.py", + "bytes": 11603, + "git_blob": "340e1f0ffb8a1a9c38fbbd9119580b6d23e01b59", + "sha256": "d097e55f06c3f244f2074ffd7c1a0a5f3c4b4b6a6accf9619d1dde5c0ae85e15", + "mode": "100644" + }, + { + "path": "research/pr4359-p7-padding/native_inventory.py", + "bytes": 15510, + "git_blob": "8d2d96e3998254c2333c43fe47cdfd074cbd811e", + "sha256": "65539acaf45bdfe8c5aee6830f9c9b3d1107c442a60842ef803fdd7688de8f32", + "mode": "100644" + }, + { + "path": "research/query-thinned-controllers/RESULT.json", + "bytes": 10237, + "git_blob": "e0695152c98d727edfd0d2034b58a1c7e8682c0c", + "sha256": "6ebfc8c0f09166f4834e9d7427410cb31aefff2cd4d4ce588c8e52c9c70e9a0f", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/BENCHMARK.json", + "bytes": 6499, + "git_blob": "f708a4a6bc5d561f72911539ee377e37233e4584", + "sha256": "21d1cd26730ad56bdf5ef746953af0234ae2316796d6b654630a91c5ca4a10ae", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/CROSS.json", + "bytes": 332, + "git_blob": "bdb31a40fae697a1f16c84f81683478a6b25d3b6", + "sha256": "90616e07f27c6e003147cc2426e81dfafa32319af6d3645171ccb8da5fa55dcc", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/NOTICE", + "bytes": 2169, + "git_blob": "c84f3ee22e58235138ffb66e4566f495a993cf5a", + "sha256": "1717a1f7b5d93790558170e2154525678addd155be7ae1f40386dd8e1aa731d7", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/PORTABILITY.json", + "bytes": 1031, + "git_blob": "42a383fa7a479872d093aae64c9a99d9f014e943", + "sha256": "1da24a766bdb6b996d9968a16347c0a37cf80150732a650f31f334ee058f2184", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/PROOF.md", + "bytes": 5723, + "git_blob": "e1238892b0ac06c542b33543fb1ffaa26af09b19", + "sha256": "918169942f69e474f27c04c2fa62f93cc70f0e13f24f9a487bad88cc2f4a7ddd", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/README.md", + "bytes": 5296, + "git_blob": "182bbe84b1e45d9cc65be65a409374c36ad80f53", + "sha256": "a05f960a9e526ec0538e7e7e8c2210cdbbeff24ae78f9eebb70b68b47c2546d8", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/RESULT.json", + "bytes": 1143, + "git_blob": "0ae6024e84c0681651c958e1caa8efbaa426846f", + "sha256": "1e158f443cbb51c3b03116ec91aea0b333a3287b33ab1883e71a38200ab14264", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/SOURCES.json", + "bytes": 11935, + "git_blob": "90ca37eac4d2b176eb77c663d973caace3b7d2a2", + "sha256": "26ac56f84129e920441cbac3d526b3879ab466ad51648714049622e3274e2291", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/TASK.json", + "bytes": 4071, + "git_blob": "e96bf44f608eedc00c6163ed3f3b06c73e3a54e6", + "sha256": "999ef23f48777f7fe252958c4bc7d3f55fa808768c1322cabddf70c85abf649f", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/VALIDATION.md", + "bytes": 3927, + "git_blob": "f6d8fff5952977f5bf6b04b758e42eb7f4d2f13d", + "sha256": "d028f5278672f8338a6cd93f2cbc6b825621c5c201aa646993f695543e7b1842", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/VERIFY.json", + "bytes": 2614, + "git_blob": "c632da8aaa3d219195960a5d22d02c5b6643bba9", + "sha256": "406f7f30c3c609f03d68938510269a1dddc20b48297eaee19280f80ce0c05789", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/benchmark.py", + "bytes": 2712, + "git_blob": "de7db07593309186258272f6e61343e1f2356a81", + "sha256": "74741a624954f0f1dd318f1adca9a565b8587ddf91638df8bce22d59ba4e1683", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/binding.py", + "bytes": 4103, + "git_blob": "6e20fb67c9daa92b20bf99717bb2de82126a6ce3", + "sha256": "4e45c0a3ccabfb0adbf24e10f4b6e2ac3539ad8e1f6ceddd6e4ef10852cd8340", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/checks.py", + "bytes": 4996, + "git_blob": "2d2b9d5f567706280d751415dac2d3558809de87", + "sha256": "b92ac7c366e30f31a5f613f06ef12fec62e5998ae952c5ae80c1b9b88b3dfc5f", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/clifford_fast.py", + "bytes": 8284, + "git_blob": "045034c8437fa4ba0cfb1c585eb839f68284e55f", + "sha256": "db570d2797f6280c8399f6001a4547ab20126353e9fb149e0e93ad0a079453b5", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/cross.py", + "bytes": 2162, + "git_blob": "bb28d8c39eec89108ed815223be756c9f4ef8775", + "sha256": "a9ea3bdfed7b96dd79cde32edf04aff7167a63712dcd14882b27ed0b06d4de32", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/local_fast.py", + "bytes": 9399, + "git_blob": "30322e24f1346de4b2ee3120021549263cf6afdb", + "sha256": "ce9ff9e7bf5981c91642e712bbfec47c872b1260f7da3ea586e65473ceee5156", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/native_fast.py", + "bytes": 10578, + "git_blob": "b2a5289c47c6f1343db3ef2239c8207823169a7b", + "sha256": "f70834109e904cf6046fe55667e4fe29504499aafb7262716b099d75027bd513", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/pins.py", + "bytes": 767, + "git_blob": "9acb0df4f959d566757810576baee590ee43ca23", + "sha256": "f1e7b282065aa8b9cea3f501598beb13cdf40b7343e4591393ee172fe8bb5741", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/run.py", + "bytes": 446, + "git_blob": "1f1aa047dddcec08965d67334c3e06f4a24dc59b", + "sha256": "2bd1f562e786fb5c7b77c056d5f304e92cc29642d533a4dfd9dc5d0586cf0ca8", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/state_adapter.py", + "bytes": 2029, + "git_blob": "5268a977c19ef61d3158dbb74f62e141291a87c8", + "sha256": "ed3390ad0e4484a2e0127d63a1df5fd9c30e51fc7bc6014a8f9498e09702215b", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/verify.py", + "bytes": 1417, + "git_blob": "d9c760591cf0f58d778c61064d35fbc7bbc8dd65", + "sha256": "4b8b0bb4127b42099494afcfec2062a7061d623a1261466c808bacd98fc6b9b5", + "mode": "100644" + }, + { + "path": "research/selected-quadratic-replay/verify_source.py", + "bytes": 6549, + "git_blob": "22c95b346b995c37189b2c04c1c641cecc07bcf0", + "sha256": "166e680bb8f5729f5bcf984f8667f823a5bdb7fb2aa8f16418b6c770a483b3d5", + "mode": "100644" + } + ] +} diff --git a/research/selected-single-pass-qualification/LICENSE b/research/selected-single-pass-qualification/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/selected-single-pass-qualification/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/selected-single-pass-qualification/NOTICE b/research/selected-single-pass-qualification/NOTICE new file mode 100644 index 0000000000..3e5ffa836a --- /dev/null +++ b/research/selected-single-pass-qualification/NOTICE @@ -0,0 +1,40 @@ +New selected-caller integration, format adapter, bounded input cache and checks: +Ali Romman with substantial OpenAI Codex assistance. Apache-2.0. +The same assistant wrote the code and performed the author-side checks. + +The exact quadratic engine and its proof are retained from Ali Romman PR 5704, +head daa4d9dbd102d2a3677afc5614c56466bd2cf3a2. Its NOTICE.md remains byte-exact +and credits classical stabilizer simulation, Charles Bethin PR 662 and all +native/compiler predecessors. This package does not claim that engine as new. + +The complete selected source is Ali Romman PR 5599, audited source head +09dd0965711ca7eeb169057a420abab1c9052137. Its exact word, receipt, proof and +NOTICE remain inputs. That notice retains Pierre-Loic Doulcet/hexapode, +Joel Pulikkan/GamingPuzzled, DreamingOfClouds, thu-nmrc, Gareth Davidson/bitplane, +David Arias, Cinna Davis, Jacob Alan Sussman, zxv, Cao Yifan and earlier geometry, +BIT and analytic credit. The derived files retain their original module text. + +Classical deterministic memoization and exact affine-support enumeration are +not new general algorithms. The new result is their checked integration into +this complete source replay, with every scalar/native/invoice/compiler check, +independent literal-state evidence and whole-replay measurements. No original +source, selected record, native bill or kappa is changed. Archive inclusion, +local replay and hosted CI are separate from independent mathematical review. + +Native-channel attribution from its pinned README: Rohan Arun PR 1972 supplied +the scalar/frame channel; Adam Gall PR 1940 supplied the schedule. Josie Elliston +PR 1071 supplied the P104 fixture/decoder, with Ali Romman PR 1125 and the retained +PR 968/717/446/595/620 lineage. icekylinx's frame-sa504 retains the exact compiler; +Ali Romman PR 1862/1931 retains the independent Gaussian interpreter. Native +lowering and physical binding were prepared for Chafik Boukhalfa with OpenAI +Codex assistance. These are predecessor contributions, not work of this adapter. +Source: https://github.com/CrocSwap/integer-mult-bounds/blob/553d26d796fde9871ff2661a49ac7732e945410f/research/p104-native-channel/README.md + + +Independent Linux qualification +------------------------------ +This package retains the exact PR #5757 official export, including the original source notices. Ali Romman supplied the acceleration, integration, original controls and macOS measurements. Chris R / Clear1nsight supplied the new Linux measurements, applicability review, guarded reproduction and recorded-evidence checks, with substantial OpenAI Codex assistance. No subagents or independent human/proof-kernel acceptance are claimed. The retained construction, controller, native, compiler and stabilizer sources keep their original attribution and Apache-2.0 obligations. No new mathematical construction, physical multiplier speedup or kappa gain is claimed. + +Single-pass qualification orchestration +-------------------------------------- +Chris R / Clear1nsight with substantial OpenAI Codex assistance supplied the process-local observer/handoff, coverage review, controls and paired Linux measurements. Both original PR5757 entry points, their literal interpreters, archived source and expected scientific receipts remain unchanged. The guard.py harness is retained from PR5816. No subagents or independent human/proof-kernel review. Apache-2.0. No kappa or physical multiplier gain. diff --git a/research/selected-single-pass-qualification/PROOF.md b/research/selected-single-pass-qualification/PROOF.md new file mode 100644 index 0000000000..7882567ce4 --- /dev/null +++ b/research/selected-single-pass-qualification/PROOF.md @@ -0,0 +1,47 @@ +# Coverage-preserving process-local qualification + +This argument is bound to PR #5757 head `53006fe6031dab5c23d5b7d1cf6a92f411a04a68`, including its exact 54-file official export. It concerns verification orchestration, not the multiplication theorem, a new state engine, a new native program or a kappa gain. + +## Source custody + +`source.payload()` checks the exact archive and complete manifest hashes, the official export commit, all 55 regular archive members, and every retained source length, SHA256 and Git blob. Only the 54 authenticated source paths are materialized. The private source tree is Git-free and its files are read-only. No predecessor file, expected RESULT/CROSS, generated mathematical artifact or selected metadata is changed. All source file hashes and modes are checked again after execution. This assumes a stable local execution environment, as does the existing package runner; it is not an atomic filesystem or adversarial-host guarantee. + +Both original `verify.py` and `cross.py` are loaded without modification and their `main` functions are actually called. Their original authentication, AST binding, receipt reads, full equality checks and exceptions remain in place. The inherited four-file AST binding still rejects undeclared changes in the compiler, native interpreter, local verifier and complete source verifier. `runpy` loads the entry functions but does not invoke their `__main__` guards. The public wrapper accepts no command arguments; neither legacy parser is allowed a recording/write option. + +## The observed first execution + +The original verify entry authenticates its 31 live inputs and derived ASTs, executes the full adapter corpus and cache/type/mutation/proof-omission controls, resets state counters and the signature cache, then invokes `verify_source.main([])`. + +The observer is installed only at this final call site. It requires exactly one empty-list call, `TRACE is None`, empty counters, and an empty cache with zero hits and misses. It enables the adapter's existing trace collector, invokes the original complete source verifier, saves the sorted immutable input-key trace and copies counters/cache statistics. It restores `TRACE` in a `finally` block and forwards the original return value and any exception. Existing `support` computes the same signature, amplitudes and counters whether tracing is enabled or disabled; the sole trace operation inserts its already-computed complete immutable key into a set. Repetitions are deduplicated only in the audit input inventory, as in the original cross checker. No scientific computation or acceptance is bypassed in this first execution. + +The original verify entry resumes and compares its complete original RESULT, including derived hashes, source RESULT/WORD hashes, all control summaries, cache statistics and call counts. No field is projected away or regenerated to make it pass. Instrumentation overhead is included in candidate time. + +## The second entry point and complete oracle + +The original cross entry authenticates and checks its bindings again, imports the same adapter, and creates an empty trace set. Its complete source call is temporarily replaced by a handoff. That handoff requires one successful capture, one handoff only, the exact empty-list arguments, an empty cross observer, and counters and cache statistics identical to the snapshot made immediately after the actual source execution. It transfers the captured keys into the original cross collector without state evaluation, result import or output playback. + +The unchanged remainder of cross closes its observer, freezes counters, sorts every key, and for each actual input: + +1. evaluates the unchanged literal Clifford compiler; +2. compares the complete dense vector and denominator with the quadratic adapter; +3. derives the exact nonzero sparse map; +4. compares that map and denominator with both the adapter and the second unchanged literal interpreter; +5. counts all `2^n` amplitudes, including zeros. + +It compares the complete original CROSS: all call counts, 17,651 distinct inputs, 9,037,312 amplitude positions per literal interpreter, two interpreters and the exact trace digest. The input trace has SHA256 `73ac04db73d83151efb474925d48298664cc7490d31bdec7a70dcf79b448f481`. The handoff cannot add synthetic control keys: capture starts after the original control reset and the original exact digest/count checks remain mandatory. The public wrapper additionally requires exactly 17,651 inputs and reports one source execution and one handoff. + +On success or failure, the original source entry is restored and `TRACE` is closed. The orchestration has no disk result cache, cache of PASS, cross-commit reuse, randomized sampling, approximate arithmetic or alternative scientific acceptance path. Both original standalone entry points remain available in the authenticated export. + +## Fresh-process boundary and independence + +The original second **complete source execution** is intentionally not retained as a separate test. The two literal interpreters are still loaded and executed independently of the quadratic engine; they are not replaced by a cached answer. The cross phase shares the already-completed source run and process state. It therefore does not provide a second cold source execution or general protection against every possible stateful host/interpreter defect. + +The source is deterministic and its proof-relevant outputs, complete receipts, exact input trace and cache/counter state are checked explicitly. The small feasibility fixture compares the complete baseline two-execution and candidate one-execution receipts using the actual adapter and both literal interpreters. It covers repeated calls, control-trace exclusion, wrong stage arguments, missing/repeated stages, counter/cache leakage and exact exception restoration. Separate fresh normal and optimized candidate runs preserve mode-specific checks. The original two-command baseline remains the audit fallback. A changed word, adapter or dependency needs a new source/coverage decision; this result does not transfer automatically. + +## Measurements and scope + +The benchmark compares the sum of the two original full registered scientific commands against the complete combined command, in fresh serial processes on the same source and host. Candidate output must contain the entire original verify output and the entire nonduplicate cross output byte-for-byte; only a separate orchestration summary is appended. Every sample and stop is retained. The initial comparison is one baseline/candidate pair, not a median, statistical confidence interval or universal speedup. Normal and optimized candidate stdout must agree completely. Measurement, finite conformance, hosted CI, independent mathematical review and the inherited five framework assumptions remain separate. + +## Credit + +Ali Romman supplied the original exact quadratic engine (PR #5704), full selected replay integration and both literal audits (PR #5757), original proofs and controls, and retained P104/native/controller/compiler/stabilizer lineage. PR #5816 supplies the independent Linux qualification and the retained resource guard. The new work is the process-local observer/handoff, coverage analysis, controls and paired measurement, prepared for Chris R / Clear1nsight with substantial OpenAI Codex assistance. No subagents or independent human/proof-kernel acceptance. All retained notices remain in the archive and NOTICE. Apache-2.0. diff --git a/research/selected-single-pass-qualification/README.md b/research/selected-single-pass-qualification/README.md new file mode 100644 index 0000000000..4936100580 --- /dev/null +++ b/research/selected-single-pass-qualification/README.md @@ -0,0 +1,66 @@ +# Single-pass complete P104 qualification + +This opt-in runner executes both unchanged qualification entry points from [PR #5757](https://github.com/CrocSwap/integer-mult-bounds/pull/5757), sharing their duplicate complete source execution within one fresh process. It retains the complete original RESULT/CROSS checks, all original adapter and proof-omission controls, every actual input and both full literal interpreters. No persistent acceptance cache is used. It follows [PR #5816's Linux qualification](https://github.com/CrocSwap/integer-mult-bounds/pull/5816). + +The coverage argument and its explicit process-isolation limit are in [PROOF.md](PROOF.md). [COVERAGE-GATE.json](COVERAGE-GATE.json) records the pre-construction decision. The small fixture uses the actual adapter and both retained literal interpreters: three inputs, 1,536 amplitudes each, complete equal receipts, and thirteen exact-predicate stage/contamination/exception controls. Full measurements and qualification status are recorded separately; no unmeasured performance claim follows from the fixture. + +## Initial Linux comparison + +One complete fresh-process baseline/candidate pair on Ubuntu 24.04.5 LTS, Linux x86_64, CPython 3.12.3, Intel Core i7-4790: + +| Scope | Wall seconds | CPU seconds | +| --- | ---: | ---: | +| Original verify plus original cross | 405.86 | 403.68 | +| Single-pass complete qualification | 268.93 | 268.56 | +| Saved | 136.93 (33.74%) | 135.12 (33.47%) | + +All complete scientific outputs and original receipts agree. This measures the **whole two-command qualification bill**, including the independent literal audit, rather than just the accelerated source replay timed in PR #5816. Peak kernel RSS increases from the old pair's maximum 514.38 MiB to 518.56 MiB; the candidate sampled aggregate process-group peak is 514.86 MiB. Sampling can miss short peaks. One pair, shared host load and unflushed OS caches do not establish statistical confidence or universal performance. No slow sample is discarded. + +## Reproduce + +Python 3.12, standard library: + +```sh +python3 -B scripts/research_package.py --package research/selected-single-pass-qualification +``` + +The first two commands run small controls and source-custody rejections; the third is a **fresh full scientific qualification**, not a recorded-evidence check. It should emit the original scientific output, `PASS_COMPLETE_SELECTED_QUADRATIC_REPLAY`, `PASS_ALL_SELECTED_LITERAL_STATES` and `PASS_SINGLE_PASS_COMPLETE_QUALIFICATION`. It can take several minutes. Both literal interpreters check every one of 17,651 distinct actual states and all 9,037,312 amplitude entries per interpreter, including zeros and denominators. + +The exact 54-file source closure is authenticated and materialized temporarily from the unchanged official export, read-only and Git-free. No network, Git, third-party Python dependency, source rewrite or expected-receipt update is required. Original standalone entry points remain in the retained archive. The original pending PR head is not needed as a cached Git object at runtime. + +To reproduce the bounded initial performance comparison on Linux with `/usr/bin/python3.12`, GNU `/usr/bin/time` and `/proc`, use a new work directory: + +```sh +python3 -B research/selected-single-pass-qualification/benchmark.py pair --workdir /tmp/single-pass-fresh +python3 -B research/selected-single-pass-qualification/benchmark.py optimized --workdir /tmp/single-pass-fresh +``` + +The first phase runs the complete original verify, complete original cross and combined candidate serially: 600 seconds per command, 900 seconds aggregate, 1 GiB sampled process-group RSS, bounded output and no retries. Complete scientific output equivalence and at least 15% wall and CPU savings are required before the separately gated optimized phase. That phase raises only the declared aggregate ceiling to 1,500 seconds; per-command and memory caps remain unchanged. All prior receipts still count toward the total. Every run records wall/user/system time, kernel peak RSS, sampled group RSS, full stdout/stderr and source integrity. A shared host, unflushed OS caches and one comparison pair limit timing claims. Normal and optimized candidate outputs must agree byte-for-byte. + +## Qualification evidence + +All five guarded scientific commands pass in **1,212.21 seconds total** under the staged shared limits. The first pair costs 674.79 seconds, below its 900-second gate. The complete optimized candidate takes **268.03 seconds**. A separately exported, read-only, Git-free implementation runs with `-I -O -B`, empty PATH and an explicit package import root in **269.39 seconds**. Normal, optimized and sealed stdout is byte-identical; all 18 exported files retain bytes and modes. The extra mode/export qualifications are not added to either arm of the one-pair speed claim. + +[VALIDATION.json](VALIDATION.json), [BENCHMARK.json](BENCHMARK.json), [SEALED-VALIDATION.json](SEALED-VALIDATION.json) and `evidence/` preserve the complete results. The source/export corruption controls pass normally and under optimization. Public resource receipts remove only the local absolute script path and retain the original local receipt hash; all original receipts remain in the execution checkpoint. Scientific stdout is not filtered. + +The sealed export is implementation commit `47e6c56c687ced98a854f7d1e723b7a04db3f15b`; later additions are report/evidence metadata. Final committed bytes/modes and hosted CI are checked separately. Full-history ancestry preflight is unavailable in the shallow checkout; immediate declared source-pin ancestry is checked without claiming a complete source-history audit. + +## Scope and limits + +Source: exact PR #5757 head `53006fe6031dab5c23d5b7d1cf6a92f411a04a68`. Canonical main at entry: `de5ec2e7a6074068452f45b1a191b5c72832df4a`, priority 8. [Scoped claim](https://github.com/CrocSwap/integer-mult-bounds/pull/5757#issuecomment-6431932553). Targeted source/PR overlap was checked; unpublished work and exhaustive Discussion coverage are not established. This is a different optimization from the retained engine/signature cache and the already-published E7 bit-lane optimization. + +This shares the source execution and its trace within a process. It does not preserve an independent second cold source execution, claim an independent human audit or proof-kernel acceptance, certify a changed word, or resolve the inherited framework assumptions. It changes verification work only. Conditional kappa and selected metadata are unchanged; the kappa campaign, source/literature monitors, workers and automations remain paused. + +The branch carries Ali Romman's exact [PR #5761](https://github.com/CrocSwap/integer-mult-bounds/pull/5761) test repair with original authorship and provenance to avoid the known revision-8 routing-test failure. That dependency changes no research artifact. + +## Open next questions + +- Can the same source-execution sharing apply to a changed reviewed word? First authenticate its closure and map its two entry points, trace and original receipts; stop if any obligation or state-isolation premise differs. This submission makes no successor transfer. +- After this orchestration change, is literal arithmetic or amplitude reconstruction the measured remaining bottleneck? Profile one full qualified run before proposing a new cache. Persistent reuse would need a separate complete dependency/invalidation contract; a cached PASS is insufficient. +- Does performance hold on another host? Repeat the bounded exact comparison and retain every sample and memory result. One pair does not establish a universal speedup. + +See [TASK.json](TASK.json) for the frozen task card and structured scope, and [SOURCES.json](SOURCES.json) for exact retained-source pins. + +## Credit + +Credit Ali Romman for [PR #5704](https://github.com/CrocSwap/integer-mult-bounds/pull/5704), [PR #5757](https://github.com/CrocSwap/integer-mult-bounds/pull/5757), original controls and the retained P104/native/controller/compiler/classical stabilizer sources. The archive and NOTICE preserve all predecessor attribution. New observer/handoff, review, controls and measurements were prepared for Chris R / Clear1nsight with substantial OpenAI Codex assistance; no subagents. Apache-2.0. Publication, hosted CI and mathematical acceptance are separate. diff --git a/research/selected-single-pass-qualification/SEALED-VALIDATION.json b/research/selected-single-pass-qualification/SEALED-VALIDATION.json new file mode 100644 index 0000000000..9ce7dbe87a --- /dev/null +++ b/research/selected-single-pass-qualification/SEALED-VALIDATION.json @@ -0,0 +1,33 @@ +{ + "mode": "-I -O -B with explicit authenticated package import root", + "PATH": "", + "git_free": true, + "read_only_export_files_unchanged": 18, + "complete_stdout_equal": true, + "implementation_commit": "47e6c56c687ced98a854f7d1e723b7a04db3f15b", + "receipt": { + "label": "candidate-sealed-optimized", + "optimized": true, + "wall_seconds": 269.3866488359927, + "exit": 0, + "termination": null, + "sampled_process_group_rss_bytes": 539598848, + "usage": { + "user_seconds": 268.55, + "system_seconds": 0.37, + "kernel_max_rss_kib": 530880, + "exit": 0 + }, + "stdout_sha256": "c796be009d692546eab74e3ac084ec6badf45245841d81f101c2a164c0a6eaba", + "stdout_bytes": 963, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stderr_bytes": 0, + "source_inventory_sha256": "95719901778f8c6651f9cab2bf171d87d6fb015569d6d22897e0d40e3e385fc5", + "source_bytes_and_modes_unchanged": true, + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "runner_sha256": "ae67bb805b68ed5d4c610c7ac427e955681b39faee398bffd3caf2d73ac574f2", + "manifest_sha256": "7be632febc51fa5040cdd06a86c1c4f8b95c2632cc885b49af05bba838b672be", + "status": "PASS" + } +} diff --git a/research/selected-single-pass-qualification/SOURCES.json b/research/selected-single-pass-qualification/SOURCES.json new file mode 100644 index 0000000000..af70984667 --- /dev/null +++ b/research/selected-single-pass-qualification/SOURCES.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "base_commit": "de5ec2e7a6074068452f45b1a191b5c72832df4a", + "files": [ + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "581f8d87008354eb5b869f7ed9de1317ad837ce8", + "sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + }, + { + "path": "research/selected-single-pass-qualification/inputs/PR5757.tar", + "usage": "input", + "git_blob": "818f76808bacd29ce8e713eda7440b1056391d01", + "sha256": "a3a4478938171072f7df7547f7b1e1d0ff080aa42083103450e7d02f509bfc26", + "pin": "head:3cb9c9141a65a369142162414d37f0beedcb1cf3:research/selected-single-pass-qualification/inputs/PR5757.tar" + }, + { + "path": "research/selected-single-pass-qualification/INPUT-MANIFEST.json", + "usage": "input", + "git_blob": "de11329190100a74e407dec0d28e8fdc3ea8af36", + "sha256": "7be632febc51fa5040cdd06a86c1c4f8b95c2632cc885b49af05bba838b672be", + "pin": "head:3cb9c9141a65a369142162414d37f0beedcb1cf3:research/selected-single-pass-qualification/INPUT-MANIFEST.json" + } + ], + "external_origin": { + "pr": 5757, + "head": "53006fe6031dab5c23d5b7d1cf6a92f411a04a68", + "note": "Official complete export retained as immutable input; original code and notices unchanged. The pending origin head is not claimed as an upstream publication ancestor." + }, + "predecessor_validation": { + "pr": 5816, + "head": "dd59757bd1d938e2aed75e73f24e7ae7b8054211", + "science_commit": "5195ab6d93425bb47b2bb8f9acba05d2ae307413" + } +} diff --git a/research/selected-single-pass-qualification/TASK.json b/research/selected-single-pass-qualification/TASK.json new file mode 100644 index 0000000000..bfd531a770 --- /dev/null +++ b/research/selected-single-pass-qualification/TASK.json @@ -0,0 +1,60 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "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_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.", + "scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse." + }, + "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", + "scope_change_reason": "Remove the measured duplicate source execution while preserving original entry points, receipts, both literal interpreters and all controls.", + "actual_scope": "PR5757/frozen-53006fe/single-process-sharing-of-complete-source-execution-between-two-unchanged-qualification-entry-points", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "stop_rule": "Stop on output/coverage/source/mode drift, unexpected stderr or resource failure; first pair serial 900 seconds aggregate, 600 seconds per command and 1 GiB sampled group RSS; no automatic retries. Require at least 15 percent CPU and wall saving before expansion.", + "time_budget_minutes": 90, + "outcome": "completed", + "evidence": "Five full guarded Linux commands pass; BENCHMARK.json records the one-pair 33.74 percent wall and 33.47 percent CPU saving. Full normal, optimized and sealed source/RESULT/CROSS/oracle outputs agree. VALIDATION.json, COVERAGE-GATE.json and evidence/ retain scope, source pins, controls, full output and resource receipts. Hosted CI is separate.", + "author": "Chris R / Clear1nsight", + "ai_assistance": "Substantial OpenAI Codex assistance for source review, execution, tooling and report; no subagents, independent human or proof-kernel acceptance.", + "open_questions": [ + { + "question": "Can source execution be shared safely on a changed word?", + "why_it_matters": "This coverage argument is bound to the exact existing two entry points and actual-input trace.", + "first_step": "Authenticate changed sources and remap every obligation before any replay.", + "blocked_by": "A separate nominated source, overlap review and explicit coverage gate; no successor transfer or kappa work is part of this submission." + } + ], + "base_commit": "de5ec2e7a6074068452f45b1a191b5c72832df4a" +} diff --git a/research/selected-single-pass-qualification/VALIDATION.json b/research/selected-single-pass-qualification/VALIDATION.json new file mode 100644 index 0000000000..ad44de1e72 --- /dev/null +++ b/research/selected-single-pass-qualification/VALIDATION.json @@ -0,0 +1,30 @@ +{ + "status": "PASS_LOCAL_COMPLETE_QUALIFICATION_AND_CONTROLS_HOSTED_CI_SEPARATE", + "implementation_commit": "47e6c56c687ced98a854f7d1e723b7a04db3f15b", + "scientific_runs": 5, + "aggregate_local_scientific_seconds": 1212.2091285989736, + "aggregate_limit_seconds": 1500, + "first_pair_limit_seconds": 900, + "per_command_limit_seconds": 600, + "sampled_group_rss_cap_bytes": 1073741824, + "automatic_retries": 0, + "normal_optimized_sealed_stdout_identical": true, + "positive_stdout_sha256": "c796be009d692546eab74e3ac084ec6badf45245841d81f101c2a164c0a6eaba", + "tiny_inputs": 3, + "tiny_amplitudes_per_interpreter": 1536, + "small_orchestration_controls": 13, + "source_custody_controls": 7, + "original_adapter_controls": "Unchanged checks.run executes in every combined qualification, including optimized and sealed. Includes 1522 cases, 22700 amplitudes, complete cache/type/mutation/capacity/eviction, 3 proof omissions and explicit width assertion.", + "actual_inputs": 17651, + "actual_amplitudes_per_literal_interpreter": 9037312, + "literal_interpreters": 2, + "source_files_unchanged": 54, + "sealed_export_files_unchanged": 18, + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "system": "Linux", + "release": "7.0.0-38-generic", + "machine": "x86_64", + "cpu_model": "Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz", + "limits": "One paired comparison only; not a median/statistical or universal speedup. Same agent implemented and checked; no subagents or independent human/kernel acceptance. Full-history preflight unavailable in shallow checkout; declared pins retained in own ancestry.", + "kappa_research": "PAUSED" +} diff --git a/research/selected-single-pass-qualification/VERIFY.json b/research/selected-single-pass-qualification/VERIFY.json new file mode 100644 index 0000000000..b4a95142d6 --- /dev/null +++ b/research/selected-single-pass-qualification/VERIFY.json @@ -0,0 +1,39 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/selected-single-pass-qualification/inputs/PR5757.tar", + "research/selected-single-pass-qualification/INPUT-MANIFEST.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/checks.py" + ], + "timeout_seconds": 45, + "checks": "Tiny actual-adapter receipt equivalence against both literal interpreters, exact stage/invalidation/exception controls, before scientific replay." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/custody_controls.py" + ], + "timeout_seconds": 45, + "checks": "Seven actual proof-relevant source/export corruption controls reject before imports: engine, word, compiler, both entry points, expected oracle receipt and complete manifest." + }, + { + "argv": [ + "{python}", + "-B", + "{package}/joint.py" + ], + "timeout_seconds": 600, + "checks": "Fresh full scientific qualification: both unchanged original entry points, one complete source execution, original RESULT/CROSS, every actual state against both full literal interpreters, all original controls, and source bytes/modes unchanged." + } + ] +} diff --git a/research/selected-single-pass-qualification/benchmark.py b/research/selected-single-pass-qualification/benchmark.py new file mode 100644 index 0000000000..1a01df9bc1 --- /dev/null +++ b/research/selected-single-pass-qualification/benchmark.py @@ -0,0 +1,89 @@ +"""Bounded serial comparison; retain every run and stop without retry.""" +import argparse +import fcntl +from hashlib import sha256 +import json +from pathlib import Path +import runpy +import sys + +from source import prepared + +HERE = Path(__file__).resolve().parent + + +def require(ok, why): + if not ok: + raise ValueError(why) + + +def compare(folder): + original = (folder / 'runs/baseline-verify/stdout.txt').read_bytes() + cross = (folder / 'runs/baseline-cross/stdout.txt').read_bytes() + joint = (folder / 'runs/candidate-normal/stdout.txt').read_bytes() + marker = b'PASS_COMPLETE_SELECTED_QUADRATIC_REPLAY\n' + require(original.endswith(marker), 'Complete original verify output') + source_output = original[:-len(marker)] + require(cross.startswith(source_output), 'Identical full legacy source output') + cross_tail = cross[len(source_output):] + require(cross_tail.startswith(b'PASS_ALL_SELECTED_LITERAL_STATES '), 'Complete original cross output') + require(joint.startswith(original + cross_tail), 'Both complete original scientific outputs retained') + tail = joint[len(original + cross_tail):] + require(tail.startswith(b'PASS_SINGLE_PASS_COMPLETE_QUALIFICATION ') and tail.count(b'\n') == 1, + 'Only declared orchestration output added') + receipts = {name: json.loads((folder / 'runs' / name / 'receipt.json').read_bytes()) + for name in ('baseline-verify', 'baseline-cross', 'candidate-normal')} + require(all(r['status'] == 'PASS' for r in receipts.values()), 'Every guarded run passed') + old_wall = sum(receipts[n]['wall_seconds'] for n in ('baseline-verify', 'baseline-cross')) + new_wall = receipts['candidate-normal']['wall_seconds'] + cpu = lambda r: r['usage']['user_seconds'] + r['usage']['system_seconds'] + old_cpu = sum(cpu(receipts[n]) for n in ('baseline-verify', 'baseline-cross')) + new_cpu = cpu(receipts['candidate-normal']) + result = {'baseline_wall_seconds': old_wall, 'candidate_wall_seconds': new_wall, + 'baseline_cpu_seconds': old_cpu, 'candidate_cpu_seconds': new_cpu, + 'wall_fraction_saved': 1 - new_wall / old_wall, 'cpu_fraction_saved': 1 - new_cpu / old_cpu, + 'original_verify_stdout_sha256': sha256(original).hexdigest(), + 'original_cross_stdout_sha256': sha256(cross).hexdigest(), + 'complete_output_equivalence': True, 'samples_per_arm': 1, + 'limitations': 'One source-bound fresh-process pair on a shared host; not a median or universal speedup.'} + (folder / 'COMPARISON.json').write_text(json.dumps(result, indent=2, sort_keys=True) + '\n') + require(min(result['wall_fraction_saved'], result['cpu_fraction_saved']) >= .15, + 'At least 15 percent time and CPU saving before expansion') + print('PASS_SINGLE_PASS_FIRST_PAIR', json.dumps(result, sort_keys=True), flush=True) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('phase', choices=('pair', 'optimized')) + parser.add_argument('--workdir', type=Path, required=True) + args = parser.parse_args() + folder = args.workdir.resolve() + if args.phase == 'pair': + folder.mkdir(parents=True) # Refuse an existing first-pair directory. + require(folder.is_dir(), 'Existing comparison work directory') + with (folder / 'execution.lock').open('a') as lock: + fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) + if args.phase == 'optimized': + saved = json.loads((folder / 'COMPARISON.json').read_bytes()) + require(saved['complete_output_equivalence'] and min(saved['wall_fraction_saved'], + saved['cpu_fraction_saved']) >= .15, 'First pair gate before qualification') + with prepared() as root: + namespace = runpy.run_path(str(HERE / 'guard.py')) + run = namespace['run'] + run.__globals__.update(HERE=folder, SOURCE=root, MANIFEST=HERE / 'INPUT-MANIFEST.json', + AGGREGATE=900 if args.phase == 'pair' else 1500) + if args.phase == 'pair': + run('baseline-verify', 'research/selected-quadratic-replay/verify.py') + run('baseline-cross', 'research/selected-quadratic-replay/cross.py') + run('candidate-normal', str(HERE / 'joint.py')) + compare(folder) + else: + run('candidate-optimized', str(HERE / 'joint.py'), True) + require((folder / 'runs/candidate-normal/stdout.txt').read_bytes() == + (folder / 'runs/candidate-optimized/stdout.txt').read_bytes(), + 'Complete normal and optimized outputs identical') + print('PASS_SINGLE_PASS_OPTIMIZED_QUALIFICATION', flush=True) + + +if __name__ == '__main__': + main() diff --git a/research/selected-single-pass-qualification/checks.py b/research/selected-single-pass-qualification/checks.py new file mode 100644 index 0000000000..f28d75edb4 --- /dev/null +++ b/research/selected-single-pass-qualification/checks.py @@ -0,0 +1,143 @@ +"""Small real-adapter feasibility and adversarial orchestration controls.""" +from collections import Counter +from contextlib import redirect_stdout +from hashlib import sha256 +import importlib.util +import io +import json +from pathlib import Path +import sys +from types import SimpleNamespace + +from orchestration import qualify, require +from source import prepared + + +def fixture(adapter, C, V, fault=None): + circuits = [(('phase', 1), ('X', 1)), (('C', 3, 1), ('phase', 2)), ()] + keys = [(9, circuits[0], 0), (9, circuits[1], 17), (9, circuits[2], 511)] + events = [] + result = {} + + def replay(argv): + events.append('source') + for key in [*keys, keys[0]]: + adapter.dense_state(*key) + return 'source-return' + + source = SimpleNamespace(main=replay) + + def verify(): + events.append('controls') + adapter.dense_state(1, [('phase', 3)]) + adapter.signature.cache_clear() + adapter.COUNTS.clear() + if fault == 'control_contamination': + adapter.TRACE = {('synthetic-control',)} + if fault == 'dirty_counter': + adapter.COUNTS['dirty'] = 1 + if fault != 'omit_source': + require(source.main([1] if fault == 'source_argv' else []) == 'source-return' + or source.main is not replay, 'Forwarded source return') + if fault == 'repeat_source': + source.main([]) + if fault == 'verify_exception': + raise RuntimeError('sentinel verify exception') + result['verify'] = {'counts': dict(adapter.COUNTS), 'cache': adapter.signature.cache_info()._asdict()} + + def cross(): + if fault == 'counter_leak': + adapter.COUNTS['dirty'] = 1 + if fault == 'cache_leak': + adapter.signature(1, (), 0) + adapter.TRACE = {('stale',)} if fault == 'stale_cross' else set() + if fault != 'omit_handoff': + source.main([1] if fault == 'cross_argv' else []) + if fault == 'repeat_handoff': + source.main([]) + trace = sorted(adapter.TRACE) + adapter.TRACE = None + calls = dict(adapter.COUNTS) + oracle_entries = 0 + for n, circuit, initial in trace: + literal = C.Op(n, V.tableau(circuit, n), list(circuit)).zero_state(initial) + require(adapter.dense_state(n, circuit, initial) == literal, 'Tiny dense exact amplitudes') + expected = ({i: pair for i, pair in enumerate(literal[0]) if pair != (0, 0)}, literal[1]) + require(adapter.sparse_state(circuit, initial) == expected == V.state(circuit, initial), + 'Tiny sparse and second literal amplitudes') + oracle_entries += 1 << n + result['cross'] = {'calls': calls, 'trace': trace, 'entries_per_interpreter': oracle_entries} + if fault == 'cross_exception': + raise RuntimeError('sentinel cross exception') + + return source, verify, cross, result, events, replay + + +def reset(adapter): + adapter.TRACE = None + adapter.COUNTS.clear() + adapter.signature.cache_clear() + + +def run(root): + adapter_path = root / 'research/selected-quadratic-replay' + sys.path.insert(0, str(adapter_path)) + import state_adapter as A + import checks as collision_guard + # This module is executed as __main__; load the retained helper by a distinct name. + spec = importlib.util.spec_from_file_location('retained_checks', adapter_path / 'checks.py') + retained = importlib.util.module_from_spec(spec) + spec.loader.exec_module(retained) + C = retained.load('tiny_literal_compiler', 'research/p104-native-channel/vendor/clifford_exact.py') + V = retained.load('tiny_literal_native', 'research/p104-native-channel/vendor/native_verify.py') + reset(A) + source, verify, cross, expected, baseline_events, original = fixture(A, C, V) + verify() + reset(A) # The legacy second command starts in a fresh interpreter. + cross() + require(baseline_events == ['controls', 'source', 'source'], 'Legacy duplicate execution fixture') + reset(A) + source, verify, cross, actual, events, original = fixture(A, C, V) + receipt = qualify(verify, cross, source, A) + require(actual == expected, 'Complete tiny receipts unchanged') + require(events == ['controls', 'source'], 'Single actual execution') + require(source.main is original and A.TRACE is None, 'Successful instrumentation restoration') + require(receipt['source_executions'] == receipt['trace_handoffs'] == 1, 'One execution and one handoff') + require(receipt['distinct_inputs'] == 3 and actual['cross']['entries_per_interpreter'] == 1536, + 'Every tiny input and all amplitudes retained') + controls = {} + for fault, predicate in { + 'control_contamination': 'No control trace contamination', + 'dirty_counter': 'Controls reset state counters', + 'omit_source': 'Complete verify entry point', + 'repeat_source': 'Exactly one source execution', + 'source_argv': 'Exact source arguments', + 'counter_leak': 'Unchanged pre-oracle counters', + 'cache_leak': 'Unchanged pre-oracle cache', + 'stale_cross': 'Fresh cross observer', + 'omit_handoff': 'Complete cross entry point', + 'repeat_handoff': 'One trace handoff', + 'cross_argv': 'Exact cross source arguments', + 'verify_exception': 'sentinel verify exception', + 'cross_exception': 'sentinel cross exception', + }.items(): + reset(A) + source, verify, cross, _, _, original = fixture(A, C, V, fault) + try: + qualify(verify, cross, source, A) + except (ValueError, RuntimeError) as error: + require(str(error) == predicate, 'Exact intended fault predicate: ' + fault + ': ' + str(error)) + controls[fault] = predicate + else: + raise ValueError('Fault accepted: ' + fault) + require(source.main is original and A.TRACE is None, 'Exception instrumentation restoration') + reset(A) + return {'tiny_inputs': 3, 'amplitudes_per_interpreter': 1536, + 'literal_interpreters': 2, 'complete_tiny_receipts_equal': True, + 'controls': controls, 'source_executions': 1} + + +if __name__ == '__main__': + with prepared() as root: + result = run(root) + print('PASS_SINGLE_PASS_SMALL_FEASIBILITY', json.dumps(result, sort_keys=True)) diff --git a/research/selected-single-pass-qualification/custody_controls.py b/research/selected-single-pass-qualification/custody_controls.py new file mode 100644 index 0000000000..b49291d1d1 --- /dev/null +++ b/research/selected-single-pass-qualification/custody_controls.py @@ -0,0 +1,53 @@ +"""Reject actual proof-relevant source/export corruption before any import.""" +from contextlib import contextmanager +import json +from pathlib import Path +import tarfile +import tempfile + +import source +from orchestration import require + + +def run(): + here = source.HERE + raw = (here / 'inputs/PR5757.tar').read_bytes() + manifest = (here / 'INPUT-MANIFEST.json').read_bytes() + paths = { + 'engine': 'research/exact-clifford-quadratic-replay/quadratic.py', + 'word': 'research/p104-helper-subspace-splits/WORD.json.gz', + 'compiler': 'research/p104-native-channel/vendor/clifford_exact.py', + 'cross_entry': 'research/selected-quadratic-replay/cross.py', + 'verify_entry': 'research/selected-quadratic-replay/verify.py', + 'expected_cross': 'research/selected-quadratic-replay/CROSS.json', + } + with tarfile.open(here / 'inputs/PR5757.tar', 'r:') as archive: + offsets = {name: archive.getmember(path).offset_data for name, path in paths.items()} + result = {} + for name in [*paths, 'manifest']: + with tempfile.TemporaryDirectory(prefix='single-pass-corruption-') as temporary: + root = Path(temporary) + (root / 'inputs').mkdir() + changed = bytearray(raw) + if name != 'manifest': + changed[offsets[name]] ^= 1 + (root / 'inputs/PR5757.tar').write_bytes(changed) + (root / 'INPUT-MANIFEST.json').write_bytes(manifest + (b'\n' if name == 'manifest' else b'')) + try: + source.HERE = root + try: + source.payload() + except ValueError as error: + expected = 'Complete manifest hash' if name == 'manifest' else 'Official export hash' + require(str(error) == expected, 'Exact source corruption predicate') + result[name] = {'predicate': expected, 'scientific_import_started': False} + else: + raise ValueError('Source corruption accepted: ' + name) + finally: + source.HERE = here + require(len(result) == 7, 'All source custody controls') + return result + + +if __name__ == '__main__': + print('PASS_SINGLE_PASS_SOURCE_CONTROLS', json.dumps(run(), sort_keys=True)) diff --git a/research/selected-single-pass-qualification/evidence/CUSTODY-NORMAL.txt b/research/selected-single-pass-qualification/evidence/CUSTODY-NORMAL.txt new file mode 100644 index 0000000000..ab76870bc6 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/CUSTODY-NORMAL.txt @@ -0,0 +1 @@ +PASS_SINGLE_PASS_SOURCE_CONTROLS {"compiler": {"predicate": "Official export hash", "scientific_import_started": false}, "cross_entry": {"predicate": "Official export hash", "scientific_import_started": false}, "engine": {"predicate": "Official export hash", "scientific_import_started": false}, "expected_cross": {"predicate": "Official export hash", "scientific_import_started": false}, "manifest": {"predicate": "Complete manifest hash", "scientific_import_started": false}, "verify_entry": {"predicate": "Official export hash", "scientific_import_started": false}, "word": {"predicate": "Official export hash", "scientific_import_started": false}} diff --git a/research/selected-single-pass-qualification/evidence/CUSTODY-OPTIMIZED.txt b/research/selected-single-pass-qualification/evidence/CUSTODY-OPTIMIZED.txt new file mode 100644 index 0000000000..ab76870bc6 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/CUSTODY-OPTIMIZED.txt @@ -0,0 +1 @@ +PASS_SINGLE_PASS_SOURCE_CONTROLS {"compiler": {"predicate": "Official export hash", "scientific_import_started": false}, "cross_entry": {"predicate": "Official export hash", "scientific_import_started": false}, "engine": {"predicate": "Official export hash", "scientific_import_started": false}, "expected_cross": {"predicate": "Official export hash", "scientific_import_started": false}, "manifest": {"predicate": "Complete manifest hash", "scientific_import_started": false}, "verify_entry": {"predicate": "Official export hash", "scientific_import_started": false}, "word": {"predicate": "Official export hash", "scientific_import_started": false}} diff --git a/research/selected-single-pass-qualification/evidence/SMALL-NORMAL.txt b/research/selected-single-pass-qualification/evidence/SMALL-NORMAL.txt new file mode 100644 index 0000000000..48d6be4666 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/SMALL-NORMAL.txt @@ -0,0 +1 @@ +PASS_SINGLE_PASS_SMALL_FEASIBILITY {"amplitudes_per_interpreter": 1536, "complete_tiny_receipts_equal": true, "controls": {"cache_leak": "Unchanged pre-oracle cache", "control_contamination": "No control trace contamination", "counter_leak": "Unchanged pre-oracle counters", "cross_argv": "Exact cross source arguments", "cross_exception": "sentinel cross exception", "dirty_counter": "Controls reset state counters", "omit_handoff": "Complete cross entry point", "omit_source": "Complete verify entry point", "repeat_handoff": "One trace handoff", "repeat_source": "Exactly one source execution", "source_argv": "Exact source arguments", "stale_cross": "Fresh cross observer", "verify_exception": "sentinel verify exception"}, "literal_interpreters": 2, "source_executions": 1, "tiny_inputs": 3} diff --git a/research/selected-single-pass-qualification/evidence/SMALL-OPTIMIZED.txt b/research/selected-single-pass-qualification/evidence/SMALL-OPTIMIZED.txt new file mode 100644 index 0000000000..48d6be4666 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/SMALL-OPTIMIZED.txt @@ -0,0 +1 @@ +PASS_SINGLE_PASS_SMALL_FEASIBILITY {"amplitudes_per_interpreter": 1536, "complete_tiny_receipts_equal": true, "controls": {"cache_leak": "Unchanged pre-oracle cache", "control_contamination": "No control trace contamination", "counter_leak": "Unchanged pre-oracle counters", "cross_argv": "Exact cross source arguments", "cross_exception": "sentinel cross exception", "dirty_counter": "Controls reset state counters", "omit_handoff": "Complete cross entry point", "omit_source": "Complete verify entry point", "repeat_handoff": "One trace handoff", "repeat_source": "Exactly one source execution", "source_argv": "Exact source arguments", "stale_cross": "Fresh cross observer", "verify_exception": "sentinel verify exception"}, "literal_interpreters": 2, "source_executions": 1, "tiny_inputs": 3} diff --git a/research/selected-single-pass-qualification/evidence/runs/baseline-cross/receipt.json b/research/selected-single-pass-qualification/evidence/runs/baseline-cross/receipt.json new file mode 100644 index 0000000000..ae07d610a4 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/baseline-cross/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "baseline-cross", + "manifest_sha256": "7be632febc51fa5040cdd06a86c1c4f8b95c2632cc885b49af05bba838b672be", + "optimized": false, + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "ae67bb805b68ed5d4c610c7ac427e955681b39faee398bffd3caf2d73ac574f2", + "sampled_process_group_rss_bytes": 536109056, + "script": "research/selected-quadratic-replay/cross.py", + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "95719901778f8c6651f9cab2bf171d87d6fb015569d6d22897e0d40e3e385fc5", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 702, + "stdout_sha256": "f4c811b22ed856202b5a2607b108dec04b2adaa4607e0bc94b3bf84c5d69a594", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 526728, + "system_seconds": 0.44, + "user_seconds": 274.23 + }, + "wall_seconds": 276.1549471539911 +} diff --git a/research/selected-single-pass-qualification/evidence/runs/baseline-cross/stderr.txt b/research/selected-single-pass-qualification/evidence/runs/baseline-cross/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/selected-single-pass-qualification/evidence/runs/baseline-cross/stdout.txt b/research/selected-single-pass-qualification/evidence/runs/baseline-cross/stdout.txt new file mode 100644 index 0000000000..27bf25922b --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/baseline-cross/stdout.txt @@ -0,0 +1,5 @@ +PASS 13 prefix/suffix cuts, every independent row and dense reverse columns +PASS every native phase, productive target and physical caller contact +PASS_P104_HELPER_SUBSPACE_KAPPA_00310045 +{"gain": "61/4000000", "kappa": "62009/20000000", "paid_calls": 66726, "productive_fields": 13048, "raw_root_interval": ["77511407681/25000000000000", "12401825229/4000000000000"]} +PASS_ALL_SELECTED_LITERAL_STATES {"actual_state_calls": {"amplitude_entries": 19988992, "dense": 32777, "evaluations": 39041, "sparse": 6264}, "amplitudes_per_literal_interpreter": 9037312, "distinct_inputs": 17651, "input_trace_sha256": "73ac04db73d83151efb474925d48298664cc7490d31bdec7a70dcf79b448f481", "literal_interpreters": 2} diff --git a/research/selected-single-pass-qualification/evidence/runs/baseline-cross/usage.json b/research/selected-single-pass-qualification/evidence/runs/baseline-cross/usage.json new file mode 100644 index 0000000000..2a4eb15ec6 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/baseline-cross/usage.json @@ -0,0 +1 @@ +{"user_seconds":274.23,"system_seconds":0.44,"kernel_max_rss_kib":526728,"exit":0} diff --git a/research/selected-single-pass-qualification/evidence/runs/baseline-verify/receipt.json b/research/selected-single-pass-qualification/evidence/runs/baseline-verify/receipt.json new file mode 100644 index 0000000000..13155c11ff --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/baseline-verify/receipt.json @@ -0,0 +1,26 @@ +{ + "exit": 0, + "label": "baseline-verify", + "manifest_sha256": "7be632febc51fa5040cdd06a86c1c4f8b95c2632cc885b49af05bba838b672be", + "optimized": false, + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "ae67bb805b68ed5d4c610c7ac427e955681b39faee398bffd3caf2d73ac574f2", + "sampled_process_group_rss_bytes": 517926912, + "script": "research/selected-quadratic-replay/verify.py", + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "95719901778f8c6651f9cab2bf171d87d6fb015569d6d22897e0d40e3e385fc5", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 409, + "stdout_sha256": "311294ae4311f9668487882dbeadf8750324b91eeb3546545cc2d8fa2ba880ee", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 504336, + "system_seconds": 0.37, + "user_seconds": 128.64 + }, + "wall_seconds": 129.70356208700105 +} diff --git a/research/selected-single-pass-qualification/evidence/runs/baseline-verify/stderr.txt b/research/selected-single-pass-qualification/evidence/runs/baseline-verify/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/selected-single-pass-qualification/evidence/runs/baseline-verify/stdout.txt b/research/selected-single-pass-qualification/evidence/runs/baseline-verify/stdout.txt new file mode 100644 index 0000000000..22672ff0b4 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/baseline-verify/stdout.txt @@ -0,0 +1,5 @@ +PASS 13 prefix/suffix cuts, every independent row and dense reverse columns +PASS every native phase, productive target and physical caller contact +PASS_P104_HELPER_SUBSPACE_KAPPA_00310045 +{"gain": "61/4000000", "kappa": "62009/20000000", "paid_calls": 66726, "productive_fields": 13048, "raw_root_interval": ["77511407681/25000000000000", "12401825229/4000000000000"]} +PASS_COMPLETE_SELECTED_QUADRATIC_REPLAY diff --git a/research/selected-single-pass-qualification/evidence/runs/baseline-verify/usage.json b/research/selected-single-pass-qualification/evidence/runs/baseline-verify/usage.json new file mode 100644 index 0000000000..b1be1cac05 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/baseline-verify/usage.json @@ -0,0 +1 @@ +{"user_seconds":128.64,"system_seconds":0.37,"kernel_max_rss_kib":504336,"exit":0} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-normal/receipt.json b/research/selected-single-pass-qualification/evidence/runs/candidate-normal/receipt.json new file mode 100644 index 0000000000..f991486c88 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-normal/receipt.json @@ -0,0 +1,28 @@ +{ + "exit": 0, + "label": "candidate-normal", + "manifest_sha256": "7be632febc51fa5040cdd06a86c1c4f8b95c2632cc885b49af05bba838b672be", + "optimized": false, + "original_local_receipt_sha256": "104e6483dd10ed3bc887247493197aa30097cd80853ee6a409a9d256fbeaaffa", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "publication_note": "Derived display removes only the local absolute script path; original receipt SHA256 retained. Original local receipt is preserved in the execution checkpoint.", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "ae67bb805b68ed5d4c610c7ac427e955681b39faee398bffd3caf2d73ac574f2", + "sampled_process_group_rss_bytes": 539865088, + "script": "research/selected-single-pass-qualification/joint.py", + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "95719901778f8c6651f9cab2bf171d87d6fb015569d6d22897e0d40e3e385fc5", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 963, + "stdout_sha256": "c796be009d692546eab74e3ac084ec6badf45245841d81f101c2a164c0a6eaba", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 531008, + "system_seconds": 0.4, + "user_seconds": 268.16 + }, + "wall_seconds": 268.9318538699881 +} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-normal/stderr.txt b/research/selected-single-pass-qualification/evidence/runs/candidate-normal/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-normal/stdout.txt b/research/selected-single-pass-qualification/evidence/runs/candidate-normal/stdout.txt new file mode 100644 index 0000000000..c55ebcd2cd --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-normal/stdout.txt @@ -0,0 +1,7 @@ +PASS 13 prefix/suffix cuts, every independent row and dense reverse columns +PASS every native phase, productive target and physical caller contact +PASS_P104_HELPER_SUBSPACE_KAPPA_00310045 +{"gain": "61/4000000", "kappa": "62009/20000000", "paid_calls": 66726, "productive_fields": 13048, "raw_root_interval": ["77511407681/25000000000000", "12401825229/4000000000000"]} +PASS_COMPLETE_SELECTED_QUADRATIC_REPLAY +PASS_ALL_SELECTED_LITERAL_STATES {"actual_state_calls": {"amplitude_entries": 19988992, "dense": 32777, "evaluations": 39041, "sparse": 6264}, "amplitudes_per_literal_interpreter": 9037312, "distinct_inputs": 17651, "input_trace_sha256": "73ac04db73d83151efb474925d48298664cc7490d31bdec7a70dcf79b448f481", "literal_interpreters": 2} +PASS_SINGLE_PASS_COMPLETE_QUALIFICATION {"actual_state_calls": {"amplitude_entries": 19988992, "dense": 32777, "evaluations": 39041, "sparse": 6264}, "distinct_inputs": 17651, "source_executions": 1, "trace_handoffs": 1} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-normal/usage.json b/research/selected-single-pass-qualification/evidence/runs/candidate-normal/usage.json new file mode 100644 index 0000000000..893eb43d3d --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-normal/usage.json @@ -0,0 +1 @@ +{"user_seconds":268.16,"system_seconds":0.40,"kernel_max_rss_kib":531008,"exit":0} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/receipt.json b/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/receipt.json new file mode 100644 index 0000000000..35c0789fe2 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/receipt.json @@ -0,0 +1,28 @@ +{ + "exit": 0, + "label": "candidate-optimized", + "manifest_sha256": "7be632febc51fa5040cdd06a86c1c4f8b95c2632cc885b49af05bba838b672be", + "optimized": true, + "original_local_receipt_sha256": "85e68595e8d3979a109584e35d5fb3f9ee092fa37e574002366b598dae280ad1", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "publication_note": "Derived display removes only the local absolute script path; original receipt SHA256 retained. Original local receipt is preserved in the execution checkpoint.", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "ae67bb805b68ed5d4c610c7ac427e955681b39faee398bffd3caf2d73ac574f2", + "sampled_process_group_rss_bytes": 540528640, + "script": "research/selected-single-pass-qualification/joint.py", + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "95719901778f8c6651f9cab2bf171d87d6fb015569d6d22897e0d40e3e385fc5", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 963, + "stdout_sha256": "c796be009d692546eab74e3ac084ec6badf45245841d81f101c2a164c0a6eaba", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 531108, + "system_seconds": 0.38, + "user_seconds": 267.39 + }, + "wall_seconds": 268.0321166520007 +} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/stderr.txt b/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/stdout.txt b/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/stdout.txt new file mode 100644 index 0000000000..c55ebcd2cd --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/stdout.txt @@ -0,0 +1,7 @@ +PASS 13 prefix/suffix cuts, every independent row and dense reverse columns +PASS every native phase, productive target and physical caller contact +PASS_P104_HELPER_SUBSPACE_KAPPA_00310045 +{"gain": "61/4000000", "kappa": "62009/20000000", "paid_calls": 66726, "productive_fields": 13048, "raw_root_interval": ["77511407681/25000000000000", "12401825229/4000000000000"]} +PASS_COMPLETE_SELECTED_QUADRATIC_REPLAY +PASS_ALL_SELECTED_LITERAL_STATES {"actual_state_calls": {"amplitude_entries": 19988992, "dense": 32777, "evaluations": 39041, "sparse": 6264}, "amplitudes_per_literal_interpreter": 9037312, "distinct_inputs": 17651, "input_trace_sha256": "73ac04db73d83151efb474925d48298664cc7490d31bdec7a70dcf79b448f481", "literal_interpreters": 2} +PASS_SINGLE_PASS_COMPLETE_QUALIFICATION {"actual_state_calls": {"amplitude_entries": 19988992, "dense": 32777, "evaluations": 39041, "sparse": 6264}, "distinct_inputs": 17651, "source_executions": 1, "trace_handoffs": 1} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/usage.json b/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/usage.json new file mode 100644 index 0000000000..3729e62cd1 --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-optimized/usage.json @@ -0,0 +1 @@ +{"user_seconds":267.39,"system_seconds":0.38,"kernel_max_rss_kib":531108,"exit":0} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/receipt.json b/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/receipt.json new file mode 100644 index 0000000000..0c3829666f --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/receipt.json @@ -0,0 +1,28 @@ +{ + "exit": 0, + "label": "candidate-sealed-optimized", + "manifest_sha256": "7be632febc51fa5040cdd06a86c1c4f8b95c2632cc885b49af05bba838b672be", + "optimized": true, + "original_local_receipt_sha256": "ef008ba5e517a81da6955dde0080125a57a08d643c235e54808e8bfafc5ba256", + "platform": "Linux-7.0.0-38-generic-x86_64-with-glibc2.39", + "publication_note": "Derived display removes only the local absolute script path; original receipt SHA256 retained. Original local receipt is preserved in the execution checkpoint.", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "runner_sha256": "ae67bb805b68ed5d4c610c7ac427e955681b39faee398bffd3caf2d73ac574f2", + "sampled_process_group_rss_bytes": 539598848, + "script": "isolated-optimized-bootstrap-of-exported-joint.py", + "source_bytes_and_modes_unchanged": true, + "source_inventory_sha256": "95719901778f8c6651f9cab2bf171d87d6fb015569d6d22897e0d40e3e385fc5", + "status": "PASS", + "stderr_bytes": 0, + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "stdout_bytes": 963, + "stdout_sha256": "c796be009d692546eab74e3ac084ec6badf45245841d81f101c2a164c0a6eaba", + "termination": null, + "usage": { + "exit": 0, + "kernel_max_rss_kib": 530880, + "system_seconds": 0.37, + "user_seconds": 268.55 + }, + "wall_seconds": 269.3866488359927 +} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/stderr.txt b/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/stderr.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/stdout.txt b/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/stdout.txt new file mode 100644 index 0000000000..c55ebcd2cd --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/stdout.txt @@ -0,0 +1,7 @@ +PASS 13 prefix/suffix cuts, every independent row and dense reverse columns +PASS every native phase, productive target and physical caller contact +PASS_P104_HELPER_SUBSPACE_KAPPA_00310045 +{"gain": "61/4000000", "kappa": "62009/20000000", "paid_calls": 66726, "productive_fields": 13048, "raw_root_interval": ["77511407681/25000000000000", "12401825229/4000000000000"]} +PASS_COMPLETE_SELECTED_QUADRATIC_REPLAY +PASS_ALL_SELECTED_LITERAL_STATES {"actual_state_calls": {"amplitude_entries": 19988992, "dense": 32777, "evaluations": 39041, "sparse": 6264}, "amplitudes_per_literal_interpreter": 9037312, "distinct_inputs": 17651, "input_trace_sha256": "73ac04db73d83151efb474925d48298664cc7490d31bdec7a70dcf79b448f481", "literal_interpreters": 2} +PASS_SINGLE_PASS_COMPLETE_QUALIFICATION {"actual_state_calls": {"amplitude_entries": 19988992, "dense": 32777, "evaluations": 39041, "sparse": 6264}, "distinct_inputs": 17651, "source_executions": 1, "trace_handoffs": 1} diff --git a/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/usage.json b/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/usage.json new file mode 100644 index 0000000000..f1643cdbbe --- /dev/null +++ b/research/selected-single-pass-qualification/evidence/runs/candidate-sealed-optimized/usage.json @@ -0,0 +1 @@ +{"user_seconds":268.55,"system_seconds":0.37,"kernel_max_rss_kib":530880,"exit":0} diff --git a/research/selected-single-pass-qualification/guard.py b/research/selected-single-pass-qualification/guard.py new file mode 100644 index 0000000000..1e7d48033f --- /dev/null +++ b/research/selected-single-pass-qualification/guard.py @@ -0,0 +1,155 @@ +"""Serial Linux measurement harness; never alters the retained scientific source.""" +import argparse +import fcntl +import hashlib +import json +import os +from pathlib import Path +import platform +import signal +import statistics +import subprocess +import sys +import tempfile +import time + +HERE = Path(__file__).resolve().parent +SOURCE = HERE / 'payload/source' +MANIFEST = HERE / 'PAYLOAD-SOURCES.json' +EXPECTED = '1975d01770a017b3f0b3a98a54c7c79b887d90ba0a2e1a77c37db05c385fa42b' +TIMEOUT = 600 +RSS_CAP = 1024**3 +OUTPUT_CAP = 2*1024**2 +AGGREGATE = 4500 + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + +def inventory(): + result = {} + expected = json.loads(MANIFEST.read_bytes())['files'] + names = {r['path'] for r in expected} + actual = {p.relative_to(SOURCE).as_posix() for p in SOURCE.rglob('*') if p.is_file()} + if actual != names: + raise ValueError('Source inventory differs') + for row in expected: + p = SOURCE / row['path'] + if p.is_symlink() or not p.is_file(): + raise ValueError('Not a regular source: '+row['path']) + raw = p.read_bytes() + blob = hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest() + if sha(raw) != row['sha256'] or blob != row['git_blob'] or len(raw) != row['bytes']: + raise ValueError('Source authentication: '+row['path']) + result[row['path']] = [sha(raw), p.stat().st_mode & 0o777] + return result + +def group_rss(group): + total = 0 + count = 0 + for p in Path('/proc').iterdir(): + if not p.name.isdigit(): + continue + try: + raw = (p/'stat').read_text() + fields = raw[raw.rfind(')')+2:].split() + if int(fields[2]) == group: + total += int(fields[21])*os.sysconf('SC_PAGE_SIZE') + count += 1 + except (FileNotFoundError, ProcessLookupError, PermissionError): + pass + return total, count + +def run(label, script, optimized=False): + records = HERE/'runs' + records.mkdir(exist_ok=True) + prior = list(records.glob('*/receipt.json')) + spent = sum(json.loads(p.read_bytes())['wall_seconds'] for p in prior) + if spent >= AGGREGATE: + raise ValueError('Aggregate budget consumed') + folder = records/label + folder.mkdir() + before = inventory() + env = os.environ.copy() + for key in ('PYTHONPATH','PYTHONOPTIMIZE','PYTHONINSPECT','PYTHONSTARTUP','PYTHONPYCACHEPREFIX'): + env.pop(key,None) + env.update(PYTHONHASHSEED='0', LC_ALL='C.UTF-8', TZ='UTC') + usage = folder/'usage.json' + with tempfile.TemporaryDirectory(prefix='linux5757-bytecode-') as cache: + command = ['/usr/bin/python3.12', '-B', '-X', 'pycache_prefix='+cache] + if optimized: + command.append('-O') + command.append(str(SOURCE/script)) + timed = ['/usr/bin/time','-f','{"user_seconds":%U,"system_seconds":%S,"kernel_max_rss_kib":%M,"exit":%x}', '-o', str(usage),'--',*command] + start = time.monotonic() + peak = 0 + stop = None + with (folder/'stdout.txt').open('wb') as out, (folder/'stderr.txt').open('wb') as err: + p = subprocess.Popen(timed, cwd=SOURCE, env=env, stdout=out, stderr=err, start_new_session=True) + try: + while p.poll() is None: + rss, _ = group_rss(p.pid) + peak = max(peak,rss) + elapsed = time.monotonic()-start + if rss > RSS_CAP: + stop='sampled_group_rss_cap' + elif elapsed > min(TIMEOUT,AGGREGATE-spent): + stop='wall_or_aggregate_cap' + elif max((folder/'stdout.txt').stat().st_size,(folder/'stderr.txt').stat().st_size)>OUTPUT_CAP: + stop='output_cap' + if stop: + os.killpg(p.pid,signal.SIGKILL) + break + time.sleep(0.05) + code=p.wait() + finally: + try: os.killpg(p.pid,signal.SIGKILL) + except ProcessLookupError: pass + p.wait() + elapsed = time.monotonic()-start + stdout=(folder/'stdout.txt').read_bytes() + stderr=(folder/'stderr.txt').read_bytes() + after=inventory() + measurement=None + if usage.exists(): + try: measurement=json.loads(usage.read_bytes()) + except json.JSONDecodeError: measurement={'raw':usage.read_text()} + receipt={'label':label,'script':script,'optimized':optimized,'wall_seconds':elapsed, + 'exit':code,'termination':stop,'sampled_process_group_rss_bytes':peak, + 'usage':measurement,'stdout_sha256':sha(stdout),'stdout_bytes':len(stdout), + 'stderr_sha256':sha(stderr),'stderr_bytes':len(stderr), + 'source_inventory_sha256':sha(json.dumps(before,sort_keys=True,separators=(',',':')).encode()), + 'source_bytes_and_modes_unchanged':before==after, + 'python':sys.version,'platform':platform.platform(), + 'runner_sha256':sha(Path(__file__).read_bytes()),'manifest_sha256':sha(MANIFEST.read_bytes())} + receipt['status']='PASS' if code==0 and stop is None and not stderr and before==after else 'STOP' + if label.startswith('sample-') and sha(stdout)!=EXPECTED: + receipt['status']='STOP';receipt['scientific_stdout_mismatch']=True + (folder/'receipt.json').write_text(json.dumps(receipt,indent=2,sort_keys=True)+'\n') + print(json.dumps(receipt,sort_keys=True),flush=True) + if receipt['status']!='PASS': + raise SystemExit(1) + return receipt + +def main(): + parser=argparse.ArgumentParser() + parser.add_argument('phase',choices=('pair','remaining','qualification')) + args=parser.parse_args() + lock=(HERE/'execution.lock').open('w') + fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB) + if args.phase=='pair': + run('sample-1-literal','research/p104-helper-subspace-splits/verify.py') + run('sample-2-quadratic','research/selected-quadratic-replay/run.py') + elif args.phase=='remaining': + for label in ('sample-1-literal','sample-2-quadratic'): + r=json.loads((HERE/'runs'/label/'receipt.json').read_bytes()) + if r['status']!='PASS' or r['stdout_sha256']!=EXPECTED: + raise ValueError('Initial pair not qualified') + for number,mode in ((3,'quadratic'),(4,'literal'),(5,'literal'),(6,'quadratic')): + run(f'sample-{number}-{mode}','research/'+('p104-helper-subspace-splits/verify.py' if mode=='literal' else 'selected-quadratic-replay/run.py')) + else: + run('qualification-normal','research/selected-quadratic-replay/verify.py') + run('qualification-cross-optimized','research/selected-quadratic-replay/cross.py',True) + run('qualification-optimized','research/selected-quadratic-replay/verify.py',True) + +if __name__=='__main__': + main() diff --git a/research/selected-single-pass-qualification/inputs/PR5757.tar b/research/selected-single-pass-qualification/inputs/PR5757.tar new file mode 100644 index 0000000000..818f76808b Binary files /dev/null and b/research/selected-single-pass-qualification/inputs/PR5757.tar differ diff --git a/research/selected-single-pass-qualification/joint.py b/research/selected-single-pass-qualification/joint.py new file mode 100644 index 0000000000..8320a51c1b --- /dev/null +++ b/research/selected-single-pass-qualification/joint.py @@ -0,0 +1,27 @@ +"""Run both unchanged PR5757 entry points with one shared source execution.""" +import json +from pathlib import Path +import runpy +import sys + +from orchestration import qualify, require +from source import prepared + + +def run(root): + entry = root / 'research/selected-quadratic-replay' + sys.path.insert(0, str(entry)) + verify = runpy.run_path(str(entry / 'verify.py')) + cross = runpy.run_path(str(entry / 'cross.py')) + import state_adapter as adapter + import verify_source as source + require(Path(source.__file__).resolve() == entry / 'verify_source.py', 'Exact source module') + result = qualify(verify['main'], cross['main'], source, adapter) + require(result['distinct_inputs'] == 17651, 'Complete actual input inventory') + print('PASS_SINGLE_PASS_COMPLETE_QUALIFICATION', json.dumps(result, sort_keys=True)) + + +if __name__ == '__main__': + require(not sys.argv[1:], 'No joint replay arguments') + with prepared() as root: + run(root) diff --git a/research/selected-single-pass-qualification/orchestration.py b/research/selected-single-pass-qualification/orchestration.py new file mode 100644 index 0000000000..0a49314ec5 --- /dev/null +++ b/research/selected-single-pass-qualification/orchestration.py @@ -0,0 +1,67 @@ +"""Share one completed source execution between the two unchanged entry points. + +This is process-local orchestration, not a persistent acceptance cache. +Chris R / Clear1nsight with OpenAI Codex assistance; Apache-2.0. +""" + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def qualify(verify_main, cross_main, source, adapter): + """Execute both original checkers, observing then handing off their trace. + + Production callers authenticate the complete source before importing it. + Only source.main and adapter.TRACE are temporarily instrumented. + """ + require(adapter.TRACE is None, 'Clean observer entry') + original = source.main + snapshot = {} + captured = consumed = 0 + + def observe(argv): + nonlocal captured + require(type(argv) is list and argv == [], 'Exact source arguments') + require(captured == 0 and not snapshot, 'Exactly one source execution') + require(adapter.TRACE is None, 'No control trace contamination') + require(not adapter.COUNTS, 'Controls reset state counters') + info = adapter.signature.cache_info() + require(info.hits == info.misses == info.currsize == 0, 'Controls reset cache') + captured += 1 + adapter.TRACE = set() + try: + returned = original(argv) + snapshot['trace'] = tuple(sorted(adapter.TRACE)) + snapshot['calls'] = dict(adapter.COUNTS) + snapshot['cache'] = adapter.signature.cache_info() + require(snapshot['trace'], 'Nonempty actual input trace') + return returned + finally: + adapter.TRACE = None + + def handoff(argv): + nonlocal consumed + require(type(argv) is list and argv == [], 'Exact cross source arguments') + require(captured == 1 and consumed == 0 and snapshot, 'One trace handoff') + require(type(adapter.TRACE) is set and not adapter.TRACE, 'Fresh cross observer') + require(dict(adapter.COUNTS) == snapshot['calls'], 'Unchanged pre-oracle counters') + require(adapter.signature.cache_info() == snapshot['cache'], 'Unchanged pre-oracle cache') + adapter.TRACE.update(snapshot['trace']) + consumed += 1 + + try: + source.main = observe + verify_main() + require(captured == 1 and snapshot, 'Complete verify entry point') + require(adapter.TRACE is None, 'Observer restored before cross') + source.main = handoff + cross_main() + require(consumed == 1, 'Complete cross entry point') + require(adapter.TRACE is None, 'Cross observer closed') + return {'source_executions': captured, 'trace_handoffs': consumed, + 'distinct_inputs': len(snapshot['trace']), 'actual_state_calls': snapshot['calls']} + finally: + source.main = original + adapter.TRACE = None diff --git a/research/selected-single-pass-qualification/source.py b/research/selected-single-pass-qualification/source.py new file mode 100644 index 0000000000..7531a62e42 --- /dev/null +++ b/research/selected-single-pass-qualification/source.py @@ -0,0 +1,78 @@ +"""Authenticate and prepare the unchanged official PR5757 source export.""" +from contextlib import contextmanager +from hashlib import sha1, sha256 +import json +from pathlib import Path +import tarfile +import tempfile + +HERE = Path(__file__).resolve().parent +ARCHIVE_SHA256 = 'a3a4478938171072f7df7547f7b1e1d0ff080aa42083103450e7d02f509bfc26' +MANIFEST_SHA256 = '7be632febc51fa5040cdd06a86c1c4f8b95c2632cc885b49af05bba838b672be' + + +def require(ok, why): + if not ok: + raise ValueError(why) + + +def payload(): + raw = (HERE / 'inputs/PR5757.tar').read_bytes() + require(sha256(raw).hexdigest() == ARCHIVE_SHA256, 'Official export hash') + manifest_raw = (HERE / 'INPUT-MANIFEST.json').read_bytes() + require(sha256(manifest_raw).hexdigest() == MANIFEST_SHA256, 'Complete manifest hash') + manifest = json.loads(manifest_raw) + rows = {r['path']: r for r in manifest['files']} + require(len(rows) == len(manifest['files']) == 54, 'Complete source inventory') + contents = {} + with tarfile.open(HERE / 'inputs/PR5757.tar', 'r:') as stream: + members = stream.getmembers() + require(len(members) == 55 and {m.name for m in members} == set(rows) | {'.research-export.json'}, + 'Exact archive members') + for member in members: + require(member.isfile() and 0 <= member.size <= 4 * 1024**2, 'Regular bounded archive member') + data = stream.extractfile(member).read() + if member.name == '.research-export.json': + require(json.loads(data)['commit'] == manifest['source_head'], 'Official export head') + continue + row = rows[member.name] + require(len(data) == row['bytes'] and sha256(data).hexdigest() == row['sha256'], 'Exact member hash') + require(sha1(b'blob ' + str(len(data)).encode() + b'\0' + data).hexdigest() == row['git_blob'], + 'Exact member blob') + parts = Path(member.name).parts + require(parts and not Path(member.name).is_absolute() and '..' not in parts, 'Canonical member path') + contents[member.name] = data + return contents + + +def inventory(root): + require(not root.is_symlink(), 'Regular source root') + return {p.relative_to(root).as_posix(): [sha256(p.read_bytes()).hexdigest(), p.stat().st_mode & 0o777] + for p in root.rglob('*') if p.is_file() and not p.is_symlink()} + + +@contextmanager +def prepared(): + contents = payload() + with tempfile.TemporaryDirectory(prefix='single-pass-source-') as temporary: + root = Path(temporary) / 'source' + root.mkdir() + try: + for name, raw in contents.items(): + p = root / name + p.parent.mkdir(parents=True, exist_ok=True) + p.write_bytes(raw) + p.chmod(0o444) + for p in root.rglob('*'): + if p.is_dir(): + p.chmod(0o555) + root.chmod(0o555) + before = inventory(root) + yield root + require(inventory(root) == before, 'Source bytes and modes unchanged') + require(not any(p.is_symlink() for p in root.rglob('*')), 'No source links') + finally: + # This only disposes of the private temporary export, never committed inputs. + for p in [root, *root.rglob('*')]: + if p.is_dir(): + p.chmod(0o755) diff --git a/tests/fixtures/README.md b/tests/fixtures/README.md new file mode 100644 index 0000000000..472a6a502f --- /dev/null +++ b/tests/fixtures/README.md @@ -0,0 +1,41 @@ +# Frozen research routing fixture + +`research-routing-v7.json` retains two exact task cards from priority revision 7: +`portable-replay` and `centre-path-sharing`. They exercise the generic-baseline +and historical-ceiling routes in `choose_current_research_task.py`. The fixture +records the source commit, path and SHA256. The card objects are unchanged. + +The source is commit `553d26d796fde9871ff2661a49ac7732e945410f`, file +`docs/research/agent-task-catalog.json`. The test places these cards in a small +catalogue with one track of weight 100. This carrier is test data, not a change +to research priorities. Current cards are checked separately from the live +catalogue. Every live card must preserve its other fields; each distinct direct +command also passes through both real CLIs. + +The CLI fixture copies the two real scripts. It creates inert reference files +for path validation and copies the current selected record for receipt fields. +It does not execute those references or verify a mathematical claim. Missing +references, sparse omissions, deleted files and staged replacements have separate +negative tests. No Git history, network request or change to the live catalogue +is needed to run the fixture. + +```sh +python3 -B -m unittest discover -s tests -p test_research_current_assignment.py -v +python3 -B -m unittest discover -s tests -p test_research_assignment.py -v +``` + +This fixture repairs the CI handoff in +[Discussion 5722](https://github.com/CrocSwap/integer-mult-bounds/discussions/5722). +The [investigation](https://github.com/CrocSwap/integer-mult-bounds/discussions/5758) +records the failure, checks and publication status. The original scripts, task +catalogue and selected frontier are unchanged. + +On base `de5ec2e7a6074068452f45b1a191b5c72832df4a`, the old suite has eight +failures and two errors. After the repair, all 12 current-assignment tests pass +under Python 3.14.7 and Python 3.12.14, including an isolated optimized run. +All 16 related assignment tests pass under Python 3.12.14. This is test coverage, +not a mathematical replay. See the investigation for hosted-plan status. + +Retain the original catalogue, routing and test authors, including Douglas +Colkitt, Ali Romman and Mihir Srivastava. New fixture and test repair: Ali Romman +with substantial OpenAI Codex assistance. No subagents. Apache-2.0. diff --git a/tests/fixtures/research-routing-v7.json b/tests/fixtures/research-routing-v7.json new file mode 100644 index 0000000000..f5d52ac21d --- /dev/null +++ b/tests/fixtures/research-routing-v7.json @@ -0,0 +1,87 @@ +{ + "source_commit": "553d26d796fde9871ff2661a49ac7732e945410f", + "source_path": "docs/research/agent-task-catalog.json", + "source_sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72", + "scope": "Two exact revision-7 cards. The test carrier is not a research allocation.", + "cards": [ + { + "id": "centre-path-sharing", + "question": "Can the 64-per-call centre path (eight rank-8 COPY/ERASE totals through the private temporary) be shared across calls or shrunk?", + "starting_points": [ + "docs/research/research-family-status.md", + "research/complex-local-word-ceiling/README.md", + "research/split-centres-global/proofs/PR386-BIT-GEOMETRY.txt", + "certificates/selected-result.json" + ], + "methods": [ + "Derive a fully charged favorable relaxation for sharing one centre path across k calls, including restoration, hosting and precision.", + "Prove a lower bound on copied information per call for the selected decoder contract." + ], + "acceptance_gate": "Show the changed centre charge and copy profile per call with every added restoration or hosting cost charged, and its ceiling via ceiling.ceiling(centre=...). A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "first_step": { + "command": [ + "python3", + "-B", + "research/complex-local-word-ceiling/verify.py" + ], + "expected": "PASS_COMPLEX_LOCAL_WORD_CEILING", + "inspect": "Read the selected word's per-call local profile, its packing ceiling and the lever table; run levers.py for the ideal budget of the lever you target.", + "scope": "Positive control and planning budget only; this is not a new construction or full cold replay." + }, + "first_experiment": "Write the per-call centre charge and copy children for sharing across k = 2 calls, charge the sharing overhead, and screen it; stop this route if even the ideal sharing gains under 10%. Ideal budgets: free 2.80x, shared by two 1.90x (levers.py).", + "bottleneck_link": "The centre path consumes 64 of about 99.6 unpaid coordinates per call, i.e. about 64% of the raw deficit.", + "allowed_variations": [ + "One sharing pattern across a fixed number of calls.", + "One reduced copied-total contract for the existing decoder.", + "If the coverage law, template or guard changes, derive an applicable fully charged replacement bound instead of applying the incumbent ceiling outside its scope." + ], + "scope_change_triggers": [ + "Removing copies without a replacement contract for the decoder's copied totals.", + "Continuing a partial cost improvement while leaving the same unpriced consumer, restoration or central-readout obligation unresolved; refresh the family expansion decision first. Local product-retiming evidence has a narrow scope and is not a ban on changed graphs or contracts." + ], + "overlap_terms": [ + "centre path", + "copied totals", + "private temporary", + "shared centre", + "batching" + ] + }, + { + "id": "portable-replay", + "question": "Can one reproducible environment or artifact-comparison failure be repaired?", + "starting_points": [ + "research/gzip-container-reproducibility/README.md", + "docs/ci-verification.md" + ], + "methods": [ + "Reproduce one portability failure and add a minimal cross-environment fix.", + "Audit one canonical-payload comparison for omitted proof-relevant fields." + ], + "acceptance_gate": "Preserve immutable source hashes and proof-relevant content; a different compressed byte stream alone is not a mathematical mismatch.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the gzip-container reproducibility examples and distinguish frozen source bytes from regenerated payloads.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Reproduce one specific mismatch or audit one canonical comparison for omitted proof-relevant fields.", + "bottleneck_link": "Portable exact checks prevent environment failures from blocking valid contributions.", + "allowed_variations": [ + "One interpreter/version mismatch or one payload field comparison." + ], + "scope_change_triggers": [ + "Removing immutable-source pins because generated compressed bytes differ." + ], + "overlap_terms": [ + "gzip container", + "reproducibility", + "canonical payload" + ] + } + ] +} diff --git a/tests/test_research_current_assignment.py b/tests/test_research_current_assignment.py index 860f6b9b9e..c524c0037f 100644 --- a/tests/test_research_current_assignment.py +++ b/tests/test_research_current_assignment.py @@ -1,9 +1,15 @@ -"""Current orientation must preserve frozen task-selection evidence.""" +"""Current orientation must preserve frozen task-selection evidence. + +Frozen fixtures and live-catalog coverage: Ali Romman with OpenAI Codex +assistance. Retain the original routing and test authors. Apache-2.0. +""" import copy +from contextlib import contextmanager import importlib.util import json from pathlib import Path import subprocess +import shutil import sys import tempfile import unittest @@ -15,16 +21,49 @@ LEGACY = current.LEGACY legacy = current.runpy.run_path(str(LEGACY)) CATALOG = json.loads((ROOT / legacy["CATALOG"]).read_text(encoding="utf-8")) +FROZEN = json.loads((ROOT / "tests/fixtures/research-routing-v7.json").read_text()) +FROZEN_CATALOG = { + "schema_version": 1, "priority_revision": 7, + "priority_log": "docs/research/routing-fixture.md", + "tracks": [{"id": "routing-fixtures", "weight": 100, "tasks": FROZEN["cards"]}], +} + + +@contextmanager +def frozen_cli_tree(): + """Run the real scripts with exact old cards and inert reference files.""" + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + required = {FROZEN_CATALOG["priority_log"], + "scripts/research_selected_baseline.py", "scripts/research_package.py", + "research/historical-complex-ceiling-replay/VERIFY.json", + "research/historical-complex-ceiling-replay/verify.py"} + for card in FROZEN["cards"]: + required.update(card["starting_points"]) + required.add(card["first_step"]["command"][-1]) + for name in required: + path = root / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text("Inert reference for CLI validation only.\n") + for name in ("choose_research_task.py", "choose_current_research_task.py"): + shutil.copyfile(ROOT / "scripts" / name, root / "scripts" / name) + path = root / legacy["CATALOG"] + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(FROZEN_CATALOG)) + path = root / "certificates/selected-result.json" + path.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / "certificates/selected-result.json", path) + yield root class CurrentResearchAssignmentTests(unittest.TestCase): - def test_every_frozen_card_and_other_fields_stay_exact(self): - before = copy.deepcopy(CATALOG) + def check_card_round_trips(self, catalog): + before = copy.deepcopy(catalog) resolved = 0 historical = 0 - for track in CATALOG["tracks"]: + for track in catalog["tracks"]: for task in track["tasks"]: - result = legacy["select"](CATALOG, "a1" * 16, task_id=task["id"]) + result = legacy["select"](catalog, "a1" * 16, task_id=task["id"]) original = copy.deepcopy(result) current.resolve_current_first_steps(result, ROOT) card = result["suggestions"][0] @@ -55,19 +94,25 @@ def test_every_frozen_card_and_other_fields_stay_exact(self): self.assertTrue(card.pop("first_step_resolution")) card["first_step"] = card.pop("catalog_first_step") self.assertEqual(result, original) - self.assertEqual(resolved, 16) - self.assertEqual(historical, 4) - self.assertEqual(CATALOG, before) + self.assertEqual(catalog, before) + return resolved, historical + + def test_frozen_routes_and_other_fields_stay_exact(self): + self.assertEqual(self.check_card_round_trips(FROZEN_CATALOG), (1, 1)) + + def test_every_live_card_and_other_fields_stay_exact(self): + self.assertTrue(CATALOG["tracks"]) + self.check_card_round_trips(CATALOG) def test_only_exact_generic_command_is_resolved(self): - result = copy.deepcopy(legacy["select"](CATALOG, "0" * 32, task_id="portable-replay")) + result = copy.deepcopy(legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay")) result["suggestions"][0]["first_step"]["command"].append("--historical-fixture") original = copy.deepcopy(result) self.assertEqual(current.resolve_current_first_steps(result, ROOT), []) self.assertEqual(result, original) def test_missing_current_helper_does_not_change_receipt(self): - result = legacy["select"](CATALOG, "0" * 32, task_id="portable-replay") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay") original = copy.deepcopy(result) with tempfile.TemporaryDirectory() as directory: with self.assertRaisesRegex(ValueError, "missing current first-step script"): @@ -82,7 +127,7 @@ def test_nonexact_scientific_commands_are_not_reinterpreted(self): ): with self.subTest(command=command): result = copy.deepcopy(legacy["select"]( - CATALOG, "0" * 32, task_id="centre-path-sharing")) + FROZEN_CATALOG, "0" * 32, task_id="centre-path-sharing")) result["suggestions"][0]["first_step"]["command"] = command original = copy.deepcopy(result) self.assertEqual(current.resolve_current_first_steps(result, ROOT), []) @@ -102,34 +147,52 @@ def test_missing_historical_reference_leaves_all_cards_unchanged(self): path = root / name path.parent.mkdir(parents=True, exist_ok=True) path.write_text("fixture\n") - result = legacy["select"](CATALOG, "0" * 32, task_id="portable-replay") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay") result["suggestions"] += legacy["select"]( - CATALOG, "0" * 32, task_id="centre-path-sharing")["suggestions"] + FROZEN_CATALOG, "0" * 32, task_id="centre-path-sharing")["suggestions"] original = copy.deepcopy(result) with self.assertRaises(ValueError) as raised: current.resolve_current_first_steps(result, root) self.assertIn(absent, str(raised.exception)) self.assertEqual(result, original) - def cli(self, script, args): - return subprocess.run([sys.executable, "-B", str(script), *args], cwd=ROOT, + def cli(self, script, args, root=ROOT): + return subprocess.run([sys.executable, "-B", str(root / "scripts" / Path(script).name), *args], cwd=root, capture_output=True, text=True, encoding="utf-8") def test_cli_preserves_legacy_output_and_emits_both_commands(self): - args = ["--seed", "0" * 32, "--task", "portable-replay"] - original = self.cli(LEGACY, args) - output = self.cli(ROOT / "scripts/choose_current_research_task.py", args) - self.assertEqual(original.returncode, 0) - self.assertEqual(output.returncode, 0) - old, new = json.loads(original.stdout), json.loads(output.stdout) - card = new["suggestions"][0] - self.assertEqual(card["first_step"]["command"], - ["python3", "-B", "scripts/research_selected_baseline.py"]) - self.assertEqual(card.pop("catalog_first_step"), old["suggestions"][0]["first_step"]) - self.assertTrue(card.pop("first_step_resolution")) - card["first_step"] = old["suggestions"][0]["first_step"] - self.assertEqual(new, old) - self.assertEqual(self.cli(LEGACY, args).stdout, original.stdout) + with frozen_cli_tree() as root: + args = ["--seed", "0" * 32, "--task", "portable-replay"] + original = self.cli(LEGACY, args, root) + output = self.cli(ROOT / "scripts/choose_current_research_task.py", args, root) + self.assertEqual(original.returncode, 0) + self.assertEqual(output.returncode, 0) + old, new = json.loads(original.stdout), json.loads(output.stdout) + card = new["suggestions"][0] + self.assertEqual(card["first_step"]["command"], + ["python3", "-B", "scripts/research_selected_baseline.py"]) + self.assertEqual(card.pop("catalog_first_step"), old["suggestions"][0]["first_step"]) + self.assertTrue(card.pop("first_step_resolution")) + card["first_step"] = old["suggestions"][0]["first_step"] + self.assertEqual(new, old) + self.assertEqual(self.cli(LEGACY, args, root).stdout, original.stdout) + + def test_live_cli_preserves_each_unmapped_command(self): + checked = {tuple(card["first_step"]["command"]) for card in FROZEN["cards"]} + for track in CATALOG["tracks"]: + for task in track["tasks"]: + command = tuple(task["first_step"]["command"]) + if command in checked: + continue + checked.add(command) + with self.subTest(task=task["id"]): + args = ["--seed", "0" * 32, "--task", task["id"]] + original = self.cli(LEGACY, args) + output = self.cli(ROOT / "scripts/choose_current_research_task.py", args) + self.assertEqual(original.returncode, 0, original.stderr) + self.assertEqual(output.returncode, 0, output.stderr) + self.assertEqual(json.loads(output.stdout), json.loads(original.stdout)) + self.assertEqual(self.cli(LEGACY, args).stdout, original.stdout) def test_help_and_error_preserve_child_status_and_output(self): for args, code in ((["--help"], 0), (["--unknown-option"], 2), (["--seed", "bad"], 2)): @@ -139,23 +202,24 @@ def test_help_and_error_preserve_child_status_and_output(self): self.assertEqual((output.stdout, output.stderr), (original.stdout, original.stderr)) def test_cli_distinguishes_current_orientation_from_historical_control(self): - args = ["--seed", "0" * 32, "--task", "complex-new-helper-inventory"] - original = self.cli(LEGACY, args) - output = self.cli(ROOT / "scripts/choose_current_research_task.py", args) - self.assertEqual(original.returncode, 0, original.stderr) - self.assertEqual(output.returncode, 0, output.stderr) - old, new = json.loads(original.stdout), json.loads(output.stdout) - card = new["suggestions"][0] - self.assertEqual(card["first_step"]["command"][2], "scripts/research_selected_baseline.py") - self.assertEqual(card["first_step"]["expected"], "PASS_RESEARCH_BASELINE_BINDINGS_ONLY") - follow_up, = card.pop("follow_up_steps") - self.assertEqual(follow_up["command"][-1], "research/historical-complex-ceiling-replay") - self.assertIn("historical", follow_up["scope"].lower()) - self.assertIn("cost law", follow_up["inspect"]) - self.assertTrue(card.pop("first_step_resolution")) - card["first_step"] = card.pop("catalog_first_step") - self.assertEqual(new, old) - self.assertEqual(self.cli(LEGACY, args).stdout, original.stdout) + with frozen_cli_tree() as root: + args = ["--seed", "0" * 32, "--task", "centre-path-sharing"] + original = self.cli(LEGACY, args, root) + output = self.cli(ROOT / "scripts/choose_current_research_task.py", args, root) + self.assertEqual(original.returncode, 0, original.stderr) + self.assertEqual(output.returncode, 0, output.stderr) + old, new = json.loads(original.stdout), json.loads(output.stdout) + card = new["suggestions"][0] + self.assertEqual(card["first_step"]["command"][2], "scripts/research_selected_baseline.py") + self.assertEqual(card["first_step"]["expected"], "PASS_RESEARCH_BASELINE_BINDINGS_ONLY") + follow_up, = card.pop("follow_up_steps") + self.assertEqual(follow_up["command"][-1], "research/historical-complex-ceiling-replay") + self.assertIn("historical", follow_up["scope"].lower()) + self.assertIn("cost law", follow_up["inspect"]) + self.assertTrue(card.pop("first_step_resolution")) + card["first_step"] = card.pop("catalog_first_step") + self.assertEqual(new, old) + self.assertEqual(self.cli(LEGACY, args, root).stdout, original.stdout) def test_sparse_historical_references_require_unchanged_head_entries(self): with tempfile.TemporaryDirectory() as directory: @@ -178,12 +242,12 @@ def git(*args): git("update-index", "--skip-worktree", *omitted) for name in omitted: (root / name).unlink() - result = legacy["select"](CATALOG, "0" * 32, task_id="coverage-law-change") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="centre-path-sharing") self.assertEqual(current.resolve_current_first_steps(result, root), sorted(omitted)) # Ordinary deletion must not acquire the deliberate-sparse exemption. changed = omitted[-1] git("update-index", "--no-skip-worktree", changed) - result = legacy["select"](CATALOG, "0" * 32, task_id="coverage-law-change") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="centre-path-sharing") original = copy.deepcopy(result) with self.assertRaises(ValueError): current.resolve_current_first_steps(result, root) @@ -208,9 +272,9 @@ def git(*args): git("-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", "-c", "core.hooksPath=/dev/null", "commit", "-qm", "helper") git("update-index", "--skip-worktree", name); path.unlink() - result = legacy["select"](CATALOG, "0" * 32, task_id="portable-replay") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay") self.assertEqual(current.resolve_current_first_steps(result, root), [name]) git("update-index", "--no-skip-worktree", name) - result = legacy["select"](CATALOG, "0" * 32, task_id="portable-replay") + result = legacy["select"](FROZEN_CATALOG, "0" * 32, task_id="portable-replay") with self.assertRaisesRegex(ValueError, "missing current first-step script"): current.resolve_current_first_steps(result, root)