From bdae70a49d50a2c10a133cb966723d99fc00a9f6 Mon Sep 17 00:00:00 2001 From: Wentao Li Date: Thu, 15 Oct 2026 07:20:52 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Tooling:=202.49=C3=97=20faster=20production?= =?UTF-8?q?=20HPE=20audit=20via=20integer=20rows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wire Wronskode's proved opt-in integer-row auditor (research/hpe-audit-fast-seed93, seed 93) into production research/complex-sw4-frame8/vendor/pr635/.../hpe_audit_and_transport.py with identical honest and fuzz receipts. Package research/hpe-audit-integer-production/ with baseline, verify, benchmark, and registered VERIFY. Demote dependent live pins to provenance; refresh frontier1042/layer-end production audit digests; vendor pairwise baseline inside the opt-in package. Pinned-CPU five-honest-word median 6.304→2.528 s (2.494×). No new kappa. Prepared by Wentao Li with substantial AI assistance. --- research/complex-sw4-frame8/MANIFEST.json | 2 +- .../provenance/SOURCE-FILES.json | 3 +- .../complex-571-cold14-st2/MANIFEST.json | 118 +++---- .../code/hpe_audit_and_transport.py | 137 ++++++-- research/frontier1042-lec-parallel/PINS.json | 3 +- .../frontier1042-lec-parallel/audit_worker.py | 2 +- research/hpe-audit-fast-seed93/README.md | 4 + research/hpe-audit-fast-seed93/baseline.py | 304 ++++++++++++++++++ research/hpe-audit-fast-seed93/run_lec.py | 5 +- research/hpe-audit-fast-seed93/verify.py | 4 +- .../hpe-audit-integer-production/NOTICE.md | 14 + .../hpe-audit-integer-production/README.md | 88 +++++ .../hpe-audit-integer-production/RESULT.json | 29 ++ .../hpe-audit-integer-production/SOURCES.json | 43 +++ .../hpe-audit-integer-production/TASK.json | 70 ++++ .../hpe-audit-integer-production/VERIFY.json | 36 +++ .../hpe-audit-integer-production/baseline.py | 304 ++++++++++++++++++ .../hpe-audit-integer-production/benchmark.py | 130 ++++++++ .../hpe-audit-integer-production/verify.py | 265 +++++++++++++++ research/k8-hpe450-binding/SOURCES.json | 5 +- research/k8-hpe450-binding/VERIFY.json | 1 - research/k8-hpe450-forward-audit/SOURCES.json | 5 +- research/k8-hpe450-forward-audit/VERIFY.json | 1 - research/k8-rank7-composition/SOURCES.json | 6 +- .../layer-end-controls-parallel/PINS.json | 3 +- .../audit_worker.py | 2 +- .../SOURCES.json | 5 +- .../VERIFY.json | 14 +- .../two-accumulator-saved-arms/SOURCES.json | 4 +- research/u8-e4-gap-fill/SOURCES.json | 6 +- research/u8-terminal-cone-census/SOURCES.json | 4 +- tests/test_hpe_audit_integer_production.py | 24 ++ 32 files changed, 1537 insertions(+), 104 deletions(-) create mode 100644 research/hpe-audit-fast-seed93/baseline.py create mode 100644 research/hpe-audit-integer-production/NOTICE.md create mode 100644 research/hpe-audit-integer-production/README.md create mode 100644 research/hpe-audit-integer-production/RESULT.json create mode 100644 research/hpe-audit-integer-production/SOURCES.json create mode 100644 research/hpe-audit-integer-production/TASK.json create mode 100644 research/hpe-audit-integer-production/VERIFY.json create mode 100644 research/hpe-audit-integer-production/baseline.py create mode 100755 research/hpe-audit-integer-production/benchmark.py create mode 100755 research/hpe-audit-integer-production/verify.py create mode 100644 tests/test_hpe_audit_integer_production.py diff --git a/research/complex-sw4-frame8/MANIFEST.json b/research/complex-sw4-frame8/MANIFEST.json index fddcb8d952..d4612c6a28 100644 --- a/research/complex-sw4-frame8/MANIFEST.json +++ b/research/complex-sw4-frame8/MANIFEST.json @@ -363,7 +363,7 @@ "vendor/pr635/research/complex-571-cold14-st2/code/generated_identity.py": "c8af22719c0f3097a991a3f6ccac8f090afd2faba554745733d9ea88f2c25708", "vendor/pr635/research/complex-571-cold14-st2/code/generated_identity_controls.py": "a7b93207a673575d1fddc3e579153349c145c8f08d4575ae0a5d1e3cffec01de", "vendor/pr635/research/complex-571-cold14-st2/code/hpe_adapters_local.py": "eb0b5c6c7161e18dc22168da3211448d321586edd15bcfb4b4741174d36993cf", - "vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py": "0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747", "vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_local.py": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810", "vendor/pr635/research/complex-571-cold14-st2/code/hpe_controls_atc.py": "63aa3909b5bfd3bf270c313bebb5c46e7789c67a8f2439f568bc4b2b4a35d17b", "vendor/pr635/research/complex-571-cold14-st2/code/hpe_emit_local.py": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805", diff --git a/research/complex-sw4-frame8/provenance/SOURCE-FILES.json b/research/complex-sw4-frame8/provenance/SOURCE-FILES.json index a796d827ae..71e9023346 100644 --- a/research/complex-sw4-frame8/provenance/SOURCE-FILES.json +++ b/research/complex-sw4-frame8/provenance/SOURCE-FILES.json @@ -1527,7 +1527,8 @@ "path": "vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", "upstream_path": "research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", "commit": "a6895a69f8ad98ab45777b03e9e6f48888c39f6f", - "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3" + "sha256": "0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747", + "note": "Integer-row production rewrite (research/hpe-audit-integer-production)." }, { "path": "vendor/pr635/research/complex-571-cold14-st2/code/build_hpe.py", diff --git a/research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/MANIFEST.json b/research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/MANIFEST.json index 1aba78802a..8d6c480706 100644 --- a/research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/MANIFEST.json +++ b/research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/MANIFEST.json @@ -1,61 +1,61 @@ { - "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", - "NOTICE.md": "a75967ebc34e3bf2ff2c25c08e6c7f1a61b0c0d171cfd1b62196ae2caaf2c610", - "PROOF-COMMUTING-PREFIX.md": "59899b2a1a76d88275e57f983c0aea391dc2c7f1d2d66c33b92429be0a1cf5e1", - "PROOF-NOTE-R.md": "22312bb347bdf159e6a01a45c47675e6170d33b258e2fd9ed52aee88fb92c0ed", - "PROOF-NOTE.md": "e79d0920228107083be166a6733186816a38a8fa68d99f2038f07b157ea5690e", - "README.md": "d74a9499a23a729d3470bde7b06b85c4cf8602d06d10af9bf9991aea2da8ed7e", - "code/assemble.py": "1b1a9024ac910dc9b9d9e30150684e1fa9cb228a4c1c275b75ab04b57fdef1dd", - "code/assembly_controls.py": "8a365b95c412d75d10db5bb59309d47cd56c5f8a77566f940a05977795130ce8", - "code/audit_allcold.py": "cea021ae79658ca7ca4d07f1e1a70bdb4947afaf95b362114c11032c0fef889a", - "code/bind_providers_portable.py": "2eb5c262bf481b3bec9ceaec654fa46ff6fc3a89b13d4906a29a55a89e35feea", - "code/build_cold_end.py": "864b4701dd73afd0c9d99761b7a749f3354c48985730f17054e18c052996a668", - "code/build_frame_regroup.py": "e2549ccc7a90008831be3b59aeb37b47db696640f5f5c2b72dd888b2f1e7e5c9", - "code/build_gate_moves.py": "08bf1c2652307aeefbab089fdaf02f82e2c396ca23a1eb68e294a67e74c44252", - "code/build_hpe.py": "ba2001695d8c7547a82260c3b016e01dac686e95a61757ca124eb9879078ea8e", - "code/build_port_stage.py": "beb0d30fde1b9a30db091880b38c4a8ec906da3f715c43de7db8bf7932526e72", - "code/cold_end_controls.py": "0c404f49e90457520f1788ee6741c9ac154a5814c54ad6cb83b59c44552ebc84", - "code/construct_k_triangle.py": "66fc460df8eb8067efe3d8a3f9e97a7244aacd7bf11650a6ce656e868ce053da", - "code/emit_allcold.py": "fe26f10fe5d30ed407a37540a45ef94f44576dd241d09e19aef5db1efb072746", - "code/generated_identity.py": "c8af22719c0f3097a991a3f6ccac8f090afd2faba554745733d9ea88f2c25708", - "code/generated_identity_controls.py": "a7b93207a673575d1fddc3e579153349c145c8f08d4575ae0a5d1e3cffec01de", - "code/hpe_adapters_local.py": "eb0b5c6c7161e18dc22168da3211448d321586edd15bcfb4b4741174d36993cf", - "code/hpe_audit_and_transport.py": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", - "code/hpe_audit_local.py": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810", - "code/hpe_controls_atc.py": "63aa3909b5bfd3bf270c313bebb5c46e7789c67a8f2439f568bc4b2b4a35d17b", - "code/hpe_emit_local.py": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805", - "code/invoice_allcold.py": "141bd2fd58bbfb5b8d0fc8f56f61c45586d5608a5af3487c6b883dd987f998ec", - "code/phase_timing_controls.py": "1692ccee3da4b1781408d126ee4999f3e31a505cd83c64823a404033da3a6339", - "code/witness.py": "00789c911a8f32cfe9d52207c7aa78305dc3fce4a8b6305ba402b7e74117103d", - "data/EXPECTED.json": "9eeb8b149bf7649a47b0d3266436b9bfe0ba155ffb9668fa66cfa21136f9b8ed", - "data/OWNERS.json.gz": "935ff1a6823c6625daba3349b28d74acf9a3d70a5947ae155aa66c7821804add", - "data/PLAN.json": "258a8b9baa245fa4096828671e2f1d1462b5af08d56890629622ef6125eaddda", - "data/SPEC.json": "f5473e3e6d76901bca57616efda78c3e23b3d30aa2c05acb656b6e87c38abbff", - "data/TRI-SCHEDULE.json": "94da9d5575f5b237097a77ac7dd09aff594322dd9c35138bfd34ffc5e1a7a51e", - "data/WITNESS.json": "05f7127910a846210d8c75d67c58185b7cd15b9861d71d0cfea955ae62414436", - "data/cand.json": "f1f42cb6f1f272ca3690e65fe604c18427dd9ac51241095c133bf97af21d32e3", - "data/recipes/atm3-step0-promote.json": "9a7cafdf9b600ba43985c83969b75151f665b98f454afc1494b9f9ef3dd3916f", - "data/recipes/atm3-step1-greedy_kernels.json": "c4bc67f329fc22e226f26bbbf7e67018a639823d99fccfc5a1e798a7a82db43f", - "data/recipes/atm3-step2-frame_coalesce.json": "e6d7ea259a542f2b43a857998f677db4d68f8f36335e98a030bc91ab38ce758c", - "data/recipes/atm3-step3-gate_move_coalesce.json": "3a6b8fec6c8b56a45bf8fae683083636fa295a8914ffa68d11b1f78ba3a2eb9d", - "data/recipes/ck-step0-greedy_kernels.json": "c839199d0e6f8e976978fe97bc0c5579a65ba69dfb6864585b448cccc1113056", - "data/recipes/ck-step1-frame_coalesce.json": "0c8e5991e1338f03b837814dd060d4dd598c324e3538ee510913e0444a384ee3", - "data/recipes/ck-step2-gate_move_coalesce.json": "1f5b62c76915b1b8bbcf63b42dcbd87a536c34d3721c4a9b68e651404717bf00", - "data/recipes/k492-atm3-cold_end.json.gz": "a25ccab0c024aa9512df822032fca11683def03d0886b58f375c42834264c47c", - "data/recipes/k492-atm3-frame_regroup.json": "8d880d3d8e795575a3a3428e0031b2c45831eea512dc32cb99f7eae9e6e49e5e", - "data/recipes/k492-atm3-hyperplane_end.json": "30504ae76a2387677f05450d23413c7373c08ae2d9d171b2f4597bb63e294631", - "data/recipes/k492-ck-cold_end.json.gz": "9f487a0c6e89f6f3aec38726c3a4e514ffe1248ce6cda3704676f2c86ad0866c", - "data/recipes/k492-ck-frame_regroup.json": "9894f9c93e931b61cf34b337c4b257a72bb1d06fbdc4e8b02368e6e29ab2b644", - "data/recipes/k492-ck-hyperplane_end.json": "c71c2b05550544c29ebb4696e63cffc44d6daa76f1bc25e9c7c97e994b2c7657", - "data/recipes/k492-jp8-cold_end.json.gz": "90952fde4666724f783191d92f132e9f6aa84cdc6163a42974774e9957cd6f35", - "data/recipes/k492-jp8-frame_regroup.json": "9bd347334de643f29865290be1ed37289f9cae6cd339547ac89b45fa7aaee65a", - "data/recipes/k492-jp8-hyperplane_end.json": "e4d4dfd83d0c64cb0a8ee8c8bbd95d0510ee68699859e568fe201cd6f8d250c1", - "data/search/DISPATCH.json": "34f233d4976e59455c3f0e1fa6edef8091d04bf63e4268aeb4a73810bfd5e338", - "data/search/LP-PATTERNS-AGG.json": "5a1e2c3f7784cff71d4577e29d7a598a41198dac20aa35d5c87bb345d12f3e03", - "data/search/LP-PATTERNS-EX.json": "08dd7090b5fda8b0a2c936c12982b279333c5765cfd090361a58e74d68b22e80", - "data/search/TEMPLATE-PLAN.json": "1879679a44b373006907cbca8261a9cd187c7b868472afab04e002bf95331d9e", - "data/search/WARM-OWNERS.json.gz": "56aac182713cba7627b7ebfbb497975b5a7c76b9da9f835a1cb63192fc6134a4", - "data/search/WARM-PLAN.json": "89539c2b5d24225613c0ceb571a03a2165bcaf0a0bea06986e212649cbfef9e1", - "verify.py": "4c8dea601fe9255bd9fbbf7840d3bfacc3dcf0b1deaf7ffab467e3c10648a3b7", - "verify.sh": "18cf93f64fa5b7301f837950df181cf08ee8c3efe1b3fb6803354549a7462618" + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE.md": "a75967ebc34e3bf2ff2c25c08e6c7f1a61b0c0d171cfd1b62196ae2caaf2c610", + "PROOF-COMMUTING-PREFIX.md": "59899b2a1a76d88275e57f983c0aea391dc2c7f1d2d66c33b92429be0a1cf5e1", + "PROOF-NOTE-R.md": "22312bb347bdf159e6a01a45c47675e6170d33b258e2fd9ed52aee88fb92c0ed", + "PROOF-NOTE.md": "e79d0920228107083be166a6733186816a38a8fa68d99f2038f07b157ea5690e", + "README.md": "d74a9499a23a729d3470bde7b06b85c4cf8602d06d10af9bf9991aea2da8ed7e", + "code/assemble.py": "1b1a9024ac910dc9b9d9e30150684e1fa9cb228a4c1c275b75ab04b57fdef1dd", + "code/assembly_controls.py": "8a365b95c412d75d10db5bb59309d47cd56c5f8a77566f940a05977795130ce8", + "code/audit_allcold.py": "cea021ae79658ca7ca4d07f1e1a70bdb4947afaf95b362114c11032c0fef889a", + "code/bind_providers_portable.py": "2eb5c262bf481b3bec9ceaec654fa46ff6fc3a89b13d4906a29a55a89e35feea", + "code/build_cold_end.py": "864b4701dd73afd0c9d99761b7a749f3354c48985730f17054e18c052996a668", + "code/build_frame_regroup.py": "e2549ccc7a90008831be3b59aeb37b47db696640f5f5c2b72dd888b2f1e7e5c9", + "code/build_gate_moves.py": "08bf1c2652307aeefbab089fdaf02f82e2c396ca23a1eb68e294a67e74c44252", + "code/build_hpe.py": "ba2001695d8c7547a82260c3b016e01dac686e95a61757ca124eb9879078ea8e", + "code/build_port_stage.py": "beb0d30fde1b9a30db091880b38c4a8ec906da3f715c43de7db8bf7932526e72", + "code/cold_end_controls.py": "0c404f49e90457520f1788ee6741c9ac154a5814c54ad6cb83b59c44552ebc84", + "code/construct_k_triangle.py": "66fc460df8eb8067efe3d8a3f9e97a7244aacd7bf11650a6ce656e868ce053da", + "code/emit_allcold.py": "fe26f10fe5d30ed407a37540a45ef94f44576dd241d09e19aef5db1efb072746", + "code/generated_identity.py": "c8af22719c0f3097a991a3f6ccac8f090afd2faba554745733d9ea88f2c25708", + "code/generated_identity_controls.py": "a7b93207a673575d1fddc3e579153349c145c8f08d4575ae0a5d1e3cffec01de", + "code/hpe_adapters_local.py": "eb0b5c6c7161e18dc22168da3211448d321586edd15bcfb4b4741174d36993cf", + "code/hpe_audit_and_transport.py": "0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747", + "code/hpe_audit_local.py": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810", + "code/hpe_controls_atc.py": "63aa3909b5bfd3bf270c313bebb5c46e7789c67a8f2439f568bc4b2b4a35d17b", + "code/hpe_emit_local.py": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805", + "code/invoice_allcold.py": "141bd2fd58bbfb5b8d0fc8f56f61c45586d5608a5af3487c6b883dd987f998ec", + "code/phase_timing_controls.py": "1692ccee3da4b1781408d126ee4999f3e31a505cd83c64823a404033da3a6339", + "code/witness.py": "00789c911a8f32cfe9d52207c7aa78305dc3fce4a8b6305ba402b7e74117103d", + "data/EXPECTED.json": "9eeb8b149bf7649a47b0d3266436b9bfe0ba155ffb9668fa66cfa21136f9b8ed", + "data/OWNERS.json.gz": "935ff1a6823c6625daba3349b28d74acf9a3d70a5947ae155aa66c7821804add", + "data/PLAN.json": "258a8b9baa245fa4096828671e2f1d1462b5af08d56890629622ef6125eaddda", + "data/SPEC.json": "f5473e3e6d76901bca57616efda78c3e23b3d30aa2c05acb656b6e87c38abbff", + "data/TRI-SCHEDULE.json": "94da9d5575f5b237097a77ac7dd09aff594322dd9c35138bfd34ffc5e1a7a51e", + "data/WITNESS.json": "05f7127910a846210d8c75d67c58185b7cd15b9861d71d0cfea955ae62414436", + "data/cand.json": "f1f42cb6f1f272ca3690e65fe604c18427dd9ac51241095c133bf97af21d32e3", + "data/recipes/atm3-step0-promote.json": "9a7cafdf9b600ba43985c83969b75151f665b98f454afc1494b9f9ef3dd3916f", + "data/recipes/atm3-step1-greedy_kernels.json": "c4bc67f329fc22e226f26bbbf7e67018a639823d99fccfc5a1e798a7a82db43f", + "data/recipes/atm3-step2-frame_coalesce.json": "e6d7ea259a542f2b43a857998f677db4d68f8f36335e98a030bc91ab38ce758c", + "data/recipes/atm3-step3-gate_move_coalesce.json": "3a6b8fec6c8b56a45bf8fae683083636fa295a8914ffa68d11b1f78ba3a2eb9d", + "data/recipes/ck-step0-greedy_kernels.json": "c839199d0e6f8e976978fe97bc0c5579a65ba69dfb6864585b448cccc1113056", + "data/recipes/ck-step1-frame_coalesce.json": "0c8e5991e1338f03b837814dd060d4dd598c324e3538ee510913e0444a384ee3", + "data/recipes/ck-step2-gate_move_coalesce.json": "1f5b62c76915b1b8bbcf63b42dcbd87a536c34d3721c4a9b68e651404717bf00", + "data/recipes/k492-atm3-cold_end.json.gz": "a25ccab0c024aa9512df822032fca11683def03d0886b58f375c42834264c47c", + "data/recipes/k492-atm3-frame_regroup.json": "8d880d3d8e795575a3a3428e0031b2c45831eea512dc32cb99f7eae9e6e49e5e", + "data/recipes/k492-atm3-hyperplane_end.json": "30504ae76a2387677f05450d23413c7373c08ae2d9d171b2f4597bb63e294631", + "data/recipes/k492-ck-cold_end.json.gz": "9f487a0c6e89f6f3aec38726c3a4e514ffe1248ce6cda3704676f2c86ad0866c", + "data/recipes/k492-ck-frame_regroup.json": "9894f9c93e931b61cf34b337c4b257a72bb1d06fbdc4e8b02368e6e29ab2b644", + "data/recipes/k492-ck-hyperplane_end.json": "c71c2b05550544c29ebb4696e63cffc44d6daa76f1bc25e9c7c97e994b2c7657", + "data/recipes/k492-jp8-cold_end.json.gz": "90952fde4666724f783191d92f132e9f6aa84cdc6163a42974774e9957cd6f35", + "data/recipes/k492-jp8-frame_regroup.json": "9bd347334de643f29865290be1ed37289f9cae6cd339547ac89b45fa7aaee65a", + "data/recipes/k492-jp8-hyperplane_end.json": "e4d4dfd83d0c64cb0a8ee8c8bbd95d0510ee68699859e568fe201cd6f8d250c1", + "data/search/DISPATCH.json": "34f233d4976e59455c3f0e1fa6edef8091d04bf63e4268aeb4a73810bfd5e338", + "data/search/LP-PATTERNS-AGG.json": "5a1e2c3f7784cff71d4577e29d7a598a41198dac20aa35d5c87bb345d12f3e03", + "data/search/LP-PATTERNS-EX.json": "08dd7090b5fda8b0a2c936c12982b279333c5765cfd090361a58e74d68b22e80", + "data/search/TEMPLATE-PLAN.json": "1879679a44b373006907cbca8261a9cd187c7b868472afab04e002bf95331d9e", + "data/search/WARM-OWNERS.json.gz": "56aac182713cba7627b7ebfbb497975b5a7c76b9da9f835a1cb63192fc6134a4", + "data/search/WARM-PLAN.json": "89539c2b5d24225613c0ceb571a03a2165bcaf0a0bea06986e212649cbfef9e1", + "verify.py": "4c8dea601fe9255bd9fbbf7840d3bfacc3dcf0b1deaf7ffab467e3c10648a3b7", + "verify.sh": "18cf93f64fa5b7301f837950df181cf08ee8c3efe1b3fb6803354549a7462618" } diff --git a/research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py b/research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py index d5d3509d90..6f355c4913 100644 --- a/research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py +++ b/research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py @@ -1,6 +1,13 @@ """Rebuild arbitrary-dirt compensation and transport a changed local word. -Prepared for icekylinx with GPT-6 Astra assistance. Apache-2.0. +Production integer-row acceleration from research/hpe-audit-fast-seed93 +(Wronskode, incorporated tooling). Control flow, assertions, messages and +outputs match the pairwise Fraction-dict auditor. Scalar rows use exact +integer numerators over one positive row denominator; gate copies are +structural (deepcopy fallback for non-JSON-scalar shapes). See +research/hpe-audit-integer-production/. + +Prepared for icekylinx with substantial AI assistance. Apache-2.0. Adapted from PR425/433 (icekylinx), PR484's audit_gk.py (DreamingOfClouds), and Round19's 112-port transport. This auditor does not import a constructor, a nominated compensation table, or a global price. @@ -14,6 +21,10 @@ import time from collections import Counter from fractions import Fraction as Q +from math import gcd + +_SCALAR = (int, str, type(None)) +_NORMALIZE_BITS = 128 from pathlib import Path @@ -27,7 +38,31 @@ def content_hash(path): return hashlib.sha256(gzip.decompress(data) if path.suffix == '.gz' else data).hexdigest() +_BASIS = {} +_Q = {} + + def basis(vs): + """Memoized for tuples of ints; any other input takes the pinned uncached path.""" + if type(vs) is tuple and all(type(x) is int for x in vs): + out = _BASIS.get(vs) + if out is None: + out = _BASIS[vs] = _basis(vs) + return out + return _basis(vs) + + +def coefficient(a, b): + """Q(a, b), shared for int pairs (Fractions are immutable); errors are raised by Q itself.""" + if type(a) is int and type(b) is int and b: + q = _Q.get((a, b)) + if q is None: + q = _Q[a, b] = Q(a, b) + return q + return Q(a, b) + + +def _basis(vs): pivots = {} for x in vs: for k in sorted(pivots, reverse=True): @@ -42,26 +77,88 @@ def basis(vs): return tuple(pivots[k] for k in sorted(pivots, reverse=True)) +def _copy(e): + """Value-equal copy of a gate; nested objects are never shared with the input.""" + if type(e) is not list: + return copy.deepcopy(e) + out = list(e) + for i, x in enumerate(out): + if type(x) is list: + if not all(type(y) is int for y in x): + return copy.deepcopy(e) + out[i] = list(x) + elif type(x) not in _SCALAR: + return copy.deepcopy(e) + return out + + +def rows_identity(n): + """Row r is [denominator, {column: numerator}] and represents {column: numerator/denominator}.""" + return [[1, {r: 1}] for r in range(n)] + + +def _normalize(row): + d, m = row + g = d + for x in m.values(): + g = gcd(g, x) + if g == 1: + return + row[0] = d // g + for j in m: + m[j] //= g + + +def row_fractions(row): + d, m = row + return {j: Q(x, d) for j, x in m.items()} + + def apply(e, rows): if e[0] == 'scale': _, target, a, b, *_ = e - q = Q(a, b) + q = coefficient(a, b) assert q - rows[target] = {j: q*x for j, x in rows[target].items()} + d, m = rows[target] + qn = q.numerator + rows[target] = row = [d*q.denominator, {j: qn*x for j, x in m.items()}] else: _, target, source, a, b, *_ = e assert target != source - q = Q(a, b) - for j, x in list(rows[source].items()): - value = rows[target].get(j, Q(0)) + q*x + q = coefficient(a, b) + td, tm = rows[target] + sd, sm = rows[source] + den = q.denominator*sd + g = gcd(td, den) + lcm = td//g*den + ft, fs = lcm//td, q.numerator*(lcm//den) + if ft != 1: + for j in tm: + tm[j] *= ft + for j, x in list(sm.items()): + value = tm.get(j, 0) + fs*x if value: - rows[target][j] = value + tm[j] = value else: - rows[target].pop(j, None) + tm.pop(j, None) + row = rows[target] + row[0] = lcm + if row[0].bit_length() > _NORMALIZE_BITS: + _normalize(row) + + +def rows_equal(rows, expected): + """rows (integer form) equals expected (dicts of Fractions), entry by entry.""" + if len(rows) != len(expected): + return False + for (d, m), x in zip(rows, expected): + if m.keys() != x.keys() or any(m[j] != x[j]*d for j in m): + return False + return True def inverse(e): - e = copy.deepcopy(e) + e = _copy(e) if e[0] == 'add': e[3] *= -1 else: @@ -78,10 +175,10 @@ def dual(e): def state_maps(prefix, n): """P = exact state map of the prefix (precondition + compensation + A + cut + B), and P^-1 (rows as sparse dicts).""" - P = [{r: Q(1)} for r in range(n)] + P = rows_identity(n) for e in prefix: apply(e, P) - Pinv = [{r: Q(1)} for r in range(n)] + Pinv = rows_identity(n) for e in reversed(prefix): apply(inverse(e), Pinv) return P, Pinv @@ -99,8 +196,8 @@ def cone_violations(P, Pinv, hpe, mapping, endB, final, frames): viol = [] for h in hpe: U = final[mapping[h]] - viol += [('row', h, g) for g, x in sorted(Pinv[h].items()) if x and not inside(endB[mapping[g]], U)] - viol += [('column', h, g) for g in range(len(P)) if g != h and P[g].get(h) and not inside(endB[mapping[g]], U)] + viol += [('row', h, g) for g, x in sorted(Pinv[h][1].items()) if x and not inside(endB[mapping[g]], U)] + viol += [('column', h, g) for g in range(len(P)) if g != h and P[g][1].get(h) and not inside(endB[mapping[g]], U)] return viol @@ -114,16 +211,16 @@ def run(raw_path, routing_path, out): main = word['A'] + word['cut'] + word['B'] assert all(not v <= e[2] < 2*v for e in word['A'] + word['B'] if e[0] == 'add' and not v <= e[1] < 2*v) - matrix = ident() + matrix = rows_identity(n) for e in main: apply(e, matrix) - dirty = [{} for _ in range(n)] + dirty = [[1, {}] for _ in range(n)] for r in range(v, 2*v): - dirty[r] = {j: x for j, x in matrix[r].items() if j >= 2*v} + dirty[r] = [matrix[r][0], {j: x for j, x in matrix[r][1].items() if j >= 2*v}] for e in word['precondition']: apply(e, dirty) compensation = [['add', r, j, -q.numerator, q.denominator, []] - for r in range(v, 2*v) for j, q in sorted(dirty[r].items())] + for r in range(v, 2*v) for j, q in sorted(row_fractions(dirty[r]).items())] entering = set(map(int, word.get('start_extra', {}))) assert all(e[2] not in entering for e in compensation), 'zero-frame compensation reads an entering helper' cleanup = [inverse(e) for e in reversed(word['A'] + word['B']) @@ -162,13 +259,13 @@ def run(raw_path, routing_path, out): rest = [e for i, e in enumerate(word['cleanup']) if i not in set(early_idx)] program = word['precondition'] + compensation + main + tail + rest for backward in (False, True): - actual = ident() + actual = rows_identity(n) for e in program: apply(dual(e) if backward else e, actual) expected = ident() for t in range(v): expected[t if backward else v+t][v+t if backward else t] = Q(-1 if backward else 1) - assert actual == expected, ('arbitrary-dirt endpoint', backward) + assert rows_equal(actual, expected), ('arbitrary-dirt endpoint', backward) # The native scalar compiler allows dyadic additions and signed binary scales. for e in program: q = Q(e[3], e[4]) if e[0] == 'add' else Q(e[2], e[3]) @@ -194,7 +291,7 @@ def fid(vectors): return frame_ids[frame] def transform(e): - e = copy.deepcopy(e) + e = _copy(e) e[1] = mapping[e[1]] if e[0] == 'add': e[2] = mapping[e[2]] diff --git a/research/frontier1042-lec-parallel/PINS.json b/research/frontier1042-lec-parallel/PINS.json index 476c032788..2c9899f41f 100644 --- a/research/frontier1042-lec-parallel/PINS.json +++ b/research/frontier1042-lec-parallel/PINS.json @@ -22,7 +22,8 @@ }, "pr635_code": { "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code", - "audit_sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3" + "audit_sha256": "0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747", + "note": "Updated for research/hpe-audit-integer-production integer-row production audit." }, "routing": { "path": "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz", diff --git a/research/frontier1042-lec-parallel/audit_worker.py b/research/frontier1042-lec-parallel/audit_worker.py index 3b6ee20648..eccdb6c500 100644 --- a/research/frontier1042-lec-parallel/audit_worker.py +++ b/research/frontier1042-lec-parallel/audit_worker.py @@ -12,7 +12,7 @@ import tempfile from pathlib import Path -AUDIT_SHA256 = 'c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3' +AUDIT_SHA256 = '0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747' AUDIT = None diff --git a/research/hpe-audit-fast-seed93/README.md b/research/hpe-audit-fast-seed93/README.md index 8c60894f10..d1792292f4 100644 --- a/research/hpe-audit-fast-seed93/README.md +++ b/research/hpe-audit-fast-seed93/README.md @@ -1,5 +1,9 @@ # Fast exact HPE transport audit for the layer-end controls + +**Production wiring:** `research/hpe-audit-integer-production/` promotes this adapter into the PR635 production path. Pairwise bytes are retained here as `baseline.py` for differential checks. + + **Status: tooling improvement (verification engineering). No new κ. No check is changed, removed or weakened; the selected result is unchanged.** - **Track and seed:** track 85–94 (verification engineering), assignment seed **93** from the OS CSPRNG (Python `secrets`). diff --git a/research/hpe-audit-fast-seed93/baseline.py b/research/hpe-audit-fast-seed93/baseline.py new file mode 100644 index 0000000000..d5d3509d90 --- /dev/null +++ b/research/hpe-audit-fast-seed93/baseline.py @@ -0,0 +1,304 @@ +"""Rebuild arbitrary-dirt compensation and transport a changed local word. + +Prepared for icekylinx with GPT-6 Astra assistance. Apache-2.0. +Adapted from PR425/433 (icekylinx), PR484's audit_gk.py +(DreamingOfClouds), and Round19's 112-port transport. This auditor does not +import a constructor, a nominated compensation table, or a global price. +Only the changed scalar word and its actual frame chains are checked here. +""" +import argparse +import copy +import gzip +import hashlib +import json +import time +from collections import Counter +from fractions import Fraction as Q +from pathlib import Path + + +def read(path): + data = path.read_bytes() + return json.loads(gzip.decompress(data) if path.suffix == '.gz' else data) + + +def content_hash(path): + data = path.read_bytes() + return hashlib.sha256(gzip.decompress(data) if path.suffix == '.gz' else data).hexdigest() + + +def basis(vs): + pivots = {} + for x in vs: + for k in sorted(pivots, reverse=True): + if x >> k & 1: + x ^= pivots[k] + if x: + k = x.bit_length() - 1 + for j in pivots: + if pivots[j] >> k & 1: + pivots[j] ^= x + pivots[k] = x + return tuple(pivots[k] for k in sorted(pivots, reverse=True)) + + +def apply(e, rows): + if e[0] == 'scale': + _, target, a, b, *_ = e + q = Q(a, b) + assert q + rows[target] = {j: q*x for j, x in rows[target].items()} + else: + _, target, source, a, b, *_ = e + assert target != source + q = Q(a, b) + for j, x in list(rows[source].items()): + value = rows[target].get(j, Q(0)) + q*x + if value: + rows[target][j] = value + else: + rows[target].pop(j, None) + + +def inverse(e): + e = copy.deepcopy(e) + if e[0] == 'add': + e[3] *= -1 + else: + e[2], e[3] = e[3], e[2] + return e + + +def dual(e): + e = inverse(e) + if e[0] == 'add': + e[1], e[2] = e[2], e[1] + return e + + +def state_maps(prefix, n): + """P = exact state map of the prefix (precondition + compensation + A + cut + B), and P^-1 (rows as sparse dicts).""" + P = [{r: Q(1)} for r in range(n)] + for e in prefix: + apply(e, P) + Pinv = [{r: Q(1)} for r in range(n)] + for e in reversed(prefix): + apply(inverse(e), Pinv) + return P, Pinv + + +def cone_violations(P, Pinv, hpe, mapping, endB, final, frames): + """COLD-HPE / CONE PRE-CHECK. Necessary conditions for helper h (raw index) to end at U = final[h] under ANY + monotone common-frame cleanup of the end-of-B state P (frames only climb, every gate at a common frame): + row (J26-H dependency bound): every g in supp(row h of P^-1) has end-of-B frame <= U -- h is rebuilt from them; + column (dirt-column lemma): every g != h with P[g][h] != 0 has end-of-B frame <= U -- the column of P at h, + restricted to rows whose frame is not <= U, changes only by invertible row operations unless h is read at a + frame not <= U, so it can reach e_h only if it is already zero there. + Both are implied by the exact endpoint replay plus the frame checks below; here they fail FAST, with the reason.""" + inside = lambda a, b: basis(frames[a] + frames[b]) == frames[b] + viol = [] + for h in hpe: + U = final[mapping[h]] + viol += [('row', h, g) for g, x in sorted(Pinv[h].items()) if x and not inside(endB[mapping[g]], U)] + viol += [('column', h, g) for g in range(len(P)) if g != h and P[g].get(h) and not inside(endB[mapping[g]], U)] + return viol + + +def run(raw_path, routing_path, out): + start_time = time.monotonic() + word, routing = read(raw_path), read(routing_path) + v, h, helpers = word['report']['v'], word['report']['h'], word['report']['R'] + assert h == 9 and v == 112 and routing['v'] == v + n = 2*v + helpers + ident = lambda: [{r: Q(1)} for r in range(n)] + main = word['A'] + word['cut'] + word['B'] + assert all(not v <= e[2] < 2*v for e in word['A'] + word['B'] + if e[0] == 'add' and not v <= e[1] < 2*v) + matrix = ident() + for e in main: + apply(e, matrix) + dirty = [{} for _ in range(n)] + for r in range(v, 2*v): + dirty[r] = {j: x for j, x in matrix[r].items() if j >= 2*v} + for e in word['precondition']: + apply(e, dirty) + compensation = [['add', r, j, -q.numerator, q.denominator, []] + for r in range(v, 2*v) for j, q in sorted(dirty[r].items())] + entering = set(map(int, word.get('start_extra', {}))) + assert all(e[2] not in entering for e in compensation), 'zero-frame compensation reads an entering helper' + cleanup = [inverse(e) for e in reversed(word['A'] + word['B']) + if not v <= e[1] < 2*v] + if 'refactored_cleanup' in word: + # REFACTORED CLEANUP (cold low-frame ends): the cleanup is not the literal reversed inverse of A+B but another exact + # factorisation of the same inverse. Nothing about it is trusted: it may only touch non-target registers (T rows + # stay the compensated data accumulators), every gate is dyadic (checked below), and the arbitrary-dirt endpoint + # replay below must be exact in BOTH orientations for the full reordered program. Inherited words keep the literal + # assertion (the else branch), so their outputs are unchanged. + assert all(not v <= r < 2*v for e in word['cleanup'] for r in ([e[1]] + ([e[2]] if e[0] == 'add' else []))), 'refactored cleanup touches a target' + assert all(e[0] in ('add', 'scale') for e in word['cleanup']) + cleanup = word['cleanup'] + else: + assert [e[:-1] for e in cleanup] == [e[:-1] for e in word['cleanup']], 'cleanup is not the literal reversed inverse of A+B' + # HPE: hyperplane-ended helpers. 'early_cleanup' = [[cleanup index, frame vectors], ...] are cleanup gates executed + # right after B (before the final climbs) at the given frame; 'helper_final' = {helper: frame vectors} replaces FULL as + # that helper's terminal frame. The scalar program is the reordered one and is replayed exactly below, so a move that + # does not commute with the skipped cleanup prefix is rejected by the arbitrary-dirt endpoint assertion. + early = [(int(i), f) for i, f in word.get('early_cleanup', [])] + helper_final = {int(r): f for r, f in word.get('helper_final', {}).items()} + early_idx = [i for i, _ in early] + assert len(set(early_idx)) == len(early_idx) and all(0 <= i < len(cleanup) for i in early_idx) + assert all(2*v <= r < n for r in helper_final) + # COLD-HPE: a COLD helper (not in start_extra, entrance frame 0 = bottom) may also end at a proper subspace U. + # It is the E = bottom instance of #593's theorems: its wrappers are the (0, U) recipes R_{0,U}, L_{0,U} (checked + # exactly by hpe_adapters_local), emitted as residual_adapter events like an entering helper's. + cold_hpe = sorted(r for r in helper_final if r not in entering) + # COLD-HPE wrapper order: R_{0,U}^-1 is emitted with the entry adapters, after the zero-frame precondition and + # compensation, so (exactly as for an entering helper, asserted above) nothing before it may touch a cold-ended helper. + assert all(r not in set(cold_hpe) for e in word['precondition'] + compensation for r in ([e[1]] + ([e[2]] if e[0] == 'add' else []))), 'zero-frame precondition/compensation touches a cold hyperplane-ended helper before its wrapper' + # ENTERING helpers (start frame E != 0): their wrapper R_E^-1 precedes every gate on them, so the zero-frame precondition + # and compensation may not touch them either (mirrors hpe_emit_local's start-frame-0 rule here, at the scalar audit). + assert all(r not in entering for e in word['precondition'] + compensation for r in ([e[1]] + ([e[2]] if e[0] == 'add' else []))), 'zero-frame precondition/compensation touches an entering helper' + tail =[word['cleanup'][i][:-1] + [f] for i, f in early] + rest = [e for i, e in enumerate(word['cleanup']) if i not in set(early_idx)] + program = word['precondition'] + compensation + main + tail + rest + for backward in (False, True): + actual = ident() + for e in program: + apply(dual(e) if backward else e, actual) + expected = ident() + for t in range(v): + expected[t if backward else v+t][v+t if backward else t] = Q(-1 if backward else 1) + assert actual == expected, ('arbitrary-dirt endpoint', backward) + # The native scalar compiler allows dyadic additions and signed binary scales. + for e in program: + q = Q(e[3], e[4]) if e[0] == 'add' else Q(e[2], e[3]) + assert q.denominator & (q.denominator-1) == 0 + if e[0] == 'scale': + a = abs(q.numerator) + assert a and a & (a-1) == 0 + + tau = lambda x: x ^ (43 if (x & 43).bit_count() % 2 else 0) + ports = routing['ports'] + assert len(set(ports)) == v and set(map(tau, word['ports'])) == set(ports) + mapping = {i: ports.index(tau(p)) for i, p in enumerate(word['ports'])} + mapping.update({v+i: v+mapping[i] for i in range(v)}) + mapping.update({r: r for r in range(2*v, n)}) + full = tuple(1 << i for i in range(h-1, -1, -1)) + frames, frame_ids = [(), full], {(): 0, full: 1} + + def fid(vectors): + frame = basis(vectors) + if frame not in frame_ids: + frame_ids[frame] = len(frames) + frames.append(frame) + return frame_ids[frame] + + def transform(e): + e = copy.deepcopy(e) + e[1] = mapping[e[1]] + if e[0] == 'add': + e[2] = mapping[e[2]] + if e[-1] is not None: + e[-1] = fid([tau(x) for x in e[-1]]) + return e + + canonical = {key: [transform(e) for e in word[key]] + for key in ('A', 'B', 'cut', 'cleanup', 'precondition')} + canonical['compensation'] = [transform(e) for e in compensation] + if tail: + canonical['tail'] = [transform(e) for e in tail] # HPE (absent for inherited words: identical output) + canonical['cleanup'] = [transform(e) for e in rest] # HPE (full cleanup minus the early gates) + canonical['start'] = [fid([p]) for p in ports] + [0]*(v+helpers) + for r, frame in word.get('start_extra', {}).items(): + assert 2*v <= int(r) < n + canonical['start'][int(r)] = fid([tau(x) for x in frame]) + canonical['final'] = ([1]*v + + [fid(x for x in range(1, 1 << h) if (x & p).bit_count() % 2 == 0) for p in ports] + + [1]*helpers) + for r, frame in helper_final.items(): # HPE + canonical['final'][r] = fid([tau(x) for x in frame]) + canonical.update(h=h, v=v, R=helpers, ports=ports, frames=frames, + centers=[mapping[r] for r in word['centers']], + center_frames=[fid(tau(x) for x in frame) for frame in word['center_frames']]) + levels = {mapping[v+int(t)]-v: fid(tau(x) for x in frame) + for t, frame in word.get('target_levels', {}).items()} + canonical['target_levels'] = {str(t): f for t, f in levels.items()} + current, paid, edges = canonical['start'].copy(), Counter(), set() + + def climb(r, f): + old = current[r] + assert basis(frames[old] + frames[f]) == frames[f], ('nonmonotone', r, old, f) + if old != f: + degree = len(frames[f]) - len(frames[old]) + assert degree > 0 + paid[degree] += 1 + edges.add((old, f)) + current[r] = f + + for part in ('A', 'B'): + if part == 'B': + assert all(current[r] == f for r, f in zip(canonical['centers'], canonical['center_frames'])) + assert all(current[v+t] == levels.get(t, 0) for t in range(v)) + for r, frame in zip(canonical['centers'], canonical['center_frames']): + served = {levels.get(e[1]-v, 0) for e in canonical['cut'] if e[2] == r} + old = frame + for f in sorted(served, key=lambda f: -len(frames[f])): + assert basis(frames[old] + frames[f]) == frames[old] + if old != f: + paid[len(frames[old])-len(frames[f])] += 1 + edges.add((old, f)) + edges.add((f, old)) + old = f + for e in canonical[part]: + for r in [e[1]] + ([e[2]] if e[0] == 'add' else []): + climb(r, e[-1]) + if helper_final: # COLD-HPE / CONE PRE-CHECK at the end-of-B frames + P, Pinv = state_maps(word['precondition'] + compensation + main, n) + cone = cone_violations(P, Pinv, sorted(helper_final), mapping, current.copy(), canonical['final'], frames) + assert not cone, ('hpe cone pre-check (row / column)', cone[:8]) + for e in canonical.get('tail', []): # HPE: early cleanup gates at their common frame + for r in [e[1]] + ([e[2]] if e[0] == 'add' else []): + climb(r, e[-1]) + for r, f in enumerate(canonical['final']): + climb(r, f) + # HPE: the remaining cleanup runs at FULL, so it may touch only registers whose terminal frame is FULL; a + # hyperplane-ended helper is touched by nothing after its tail gates. + for e in canonical['cleanup']: + assert all(canonical['final'][r] == 1 for r in [e[1]] + ([e[2]] if e[0] == 'add' else [])), ('cleanup on non-FULL end', e) + assert all(len(frames[canonical['final'][r]]) < h for r in helper_final) + assert dict(paid) == {int(r): count for r, count in word['report']['local_profile'].items()}, 'paid local profile differs from the reported local_profile' + canonical['local_profile'] = dict(sorted(paid.items())) + canonical['edges'] = sorted(edges) + out.mkdir(parents=True, exist_ok=False) + payload = json.dumps(canonical, sort_keys=True, separators=(',', ':')).encode() + (out/'CANONICAL-WORD.json.gz').write_bytes(gzip.compress(payload, mtime=0)) + (out/'FULL-WORD.json.gz').write_bytes(gzip.compress(json.dumps(word, sort_keys=True, separators=(',', ':')).encode(), mtime=0)) + receipt = dict(status='PASS_CHANGED_WORD_ALL_COLUMNS_AND_NATIVE_FRAMES', + input_content_sha256=content_hash(raw_path), routing_content_sha256=content_hash(routing_path), + canonical_content_sha256=hashlib.sha256(payload).hexdigest(), + live_columns_each_orientation=n, helpers=helpers, + compensation_additions=len(compensation), scalar_operations=len(program), + center_rank_sum=sum(map(len, word['center_frames'])), + local_profile=dict(sorted(paid.items())), local_rank_mass=sum(r*z for r, z in paid.items()), + widths=[len(frames[canonical['final'][r]])-len(frames[canonical['start'][r]]) for r in range(2*v, n)], + frames=len(frames), directed_edges=len(edges), + tau=43, target_port_order_matches_baseline=True, + seconds=time.monotonic()-start_time, + scope='Fresh exact forward and inverse-transpose scalar replay on every arbitrary input; all native frame chains and dyadic primitives. Phase lowering, wrappers, global owners and global assembly are separate.') + if tail or helper_final: + receipt.update(hyperplane_ended_helpers=sorted(helper_final), early_cleanup_gates=len(tail)) + if cold_hpe: # COLD-HPE (absent for words without cold ends) + receipt.update(cold_hyperplane_ended_helpers=cold_hpe) + if 'refactored_cleanup' in word: # REFACTORED CLEANUP (absent for inherited words) + receipt.update(refactored_cleanup_gates=len(word['cleanup']), refactored_cleanup=word['refactored_cleanup']) + (out/'SCALAR-FRAME-AUDIT.json').write_text(json.dumps(receipt, indent=2)+'\n') + print(json.dumps({k: value for k, value in receipt.items() if k != 'widths'}, indent=2), flush=True) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--raw', type=Path, required=True) + parser.add_argument('--routing', type=Path, required=True) + parser.add_argument('--out', type=Path, required=True) + args = parser.parse_args() + run(args.raw, args.routing, args.out) diff --git a/research/hpe-audit-fast-seed93/run_lec.py b/research/hpe-audit-fast-seed93/run_lec.py index 1ec35b98ae..ebfe9787de 100644 --- a/research/hpe-audit-fast-seed93/run_lec.py +++ b/research/hpe-audit-fast-seed93/run_lec.py @@ -30,7 +30,8 @@ CONTROLS: '4ba676f1ea326b739a64c3477f64eeb295f8151514f78fa7e62b71e4373a6206', MULTICOLD / 'code/run_portable.py': '322d29d43dbee8130cde15d4bf05396698b5e3dfe3735813899db91cc0ba7955', ROUTING: 'e070ae2c78b4a1b644b418774af62b40d8d16e6ba89602f0474afb557d507c37', - PR635_CODE / 'hpe_audit_and_transport.py': 'c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3', + PR635_CODE / 'hpe_audit_and_transport.py': '0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747', + HERE / 'baseline.py': 'c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3', LEAVER / 'LEC-REASON-PINS-k8.json': 'b07279e41ec9d8f89e8509081e1e7f2c8e8b062fd951b22608a03ac461982914', LEAVER / 'LEC-REASON-PINS-STACK-k8.json': 'd87ed7b5869bed4a3d266f0ce5fc784cbe88340a625d22ab9f580fa00872df19', } @@ -69,7 +70,7 @@ def main(): MULTICOLD_SOURCE=str(MULTICOLD), GAIN_PR564_SOURCE=str(MULTICOLD), LEC_REASON_PINS=str(pins), PR635_CODE=str(PR635_CODE if a.mode == 'reference' else HERE / 'shim'), HPE_AUDIT_MODE='fast' if a.mode == 'reference' else a.mode, - HPE_AUDIT_REFERENCE=str(PR635_CODE / 'hpe_audit_and_transport.py'), + HPE_AUDIT_REFERENCE=str(HERE / 'baseline.py'), # pairwise-era bytes for shim crosscheck HPE_AUDIT_CROSSCHECK_LOG=str(out.parent / (out.name + '.crosscheck.jsonl'))) for k in ('PYTHONOPTIMIZE', 'XPARAM', 'EXTRAH', 'PAIRING_RANKS', 'DIAG', 'HYBBUDGET', 'SW4_PIN'): env.pop(k, None) diff --git a/research/hpe-audit-fast-seed93/verify.py b/research/hpe-audit-fast-seed93/verify.py index a61254eb67..0da643849d 100644 --- a/research/hpe-audit-fast-seed93/verify.py +++ b/research/hpe-audit-fast-seed93/verify.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Differential check: fast exact HPE audit versus PR635's pinned reference. +"""Differential check: fast exact HPE audit versus the vendored pairwise PR635 baseline. Inputs are read from the committed selected PR1042 replay archive. For each of the five words whose layer-end controls the selected chain runs (p6n, promo, @@ -32,7 +32,7 @@ HERE = Path(__file__).resolve().parent ROOT = HERE.parents[1] ARCHIVE = ROOT / 'research/community-frontier1042-audit/selected-replay.tar.gz' -REFERENCE = ROOT / 'research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py' +REFERENCE = HERE / 'baseline.py' # pairwise-era PR635 audit (vendored; production path ships integer rows) ROUTING = ROOT / ('research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/' 'complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz') PINS = { diff --git a/research/hpe-audit-integer-production/NOTICE.md b/research/hpe-audit-integer-production/NOTICE.md new file mode 100644 index 0000000000..45ffb09b4a --- /dev/null +++ b/research/hpe-audit-integer-production/NOTICE.md @@ -0,0 +1,14 @@ +# Notice + +Package: `research/hpe-audit-integer-production/` + +Prepared by Wentao Li ([VictorLiwentao](https://github.com/VictorLiwentao), +[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance. + +Predecessor credit: +- icekylinx / PR635 `hpe_audit_and_transport.py` lineage and Round19 transport +- DreamingOfClouds (PR484 `audit_gk.py` lineage) +- Wronskode for the proved opt-in integer-row adapter + `research/hpe-audit-fast-seed93/` (seed 93) + +Apache-2.0. No independent human review is claimed. diff --git a/research/hpe-audit-integer-production/README.md b/research/hpe-audit-integer-production/README.md new file mode 100644 index 0000000000..d4d33b3943 --- /dev/null +++ b/research/hpe-audit-integer-production/README.md @@ -0,0 +1,88 @@ +# Production integer-row HPE audit and transport + +**Tooling improvement; no new kappa.** At base +`0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2`, +`research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py` +still stored every scalar row as a dictionary of `Fraction` values. Wronskode’s +opt-in adapter `research/hpe-audit-fast-seed93/` already proved shared-denominator +integer rows with identical layer-end control receipts. This package wires that +equivalent rewrite into the **production** PR635 auditor used by frontier1042 +layer-end controls. + +Other vendored `hpe_audit_and_transport.py` copies outside this PR635 path are +intentionally left pairwise. + +## Reproduce + +Python **3.12**, standard library only, from the repository root: + +```sh +python3.12 -I -B research/hpe-audit-integer-production/verify.py +python3.12 -I -O -B research/hpe-audit-integer-production/verify.py +python3.12 -B scripts/research_package.py --package research/hpe-audit-integer-production +taskset -c 0 python3.12 -I -B research/hpe-audit-integer-production/benchmark.py --rounds 5 --write-result +``` + +Expected: + +```text +PASS_HPE_AUDIT_INTEGER_PRODUCTION assertions=… honest=5 fuzz=40 corruption=… certs=0 no_new_kappa +PASS_REGISTERED_RESEARCH_PACKAGE research/hpe-audit-integer-production outcome=completed +PASS_IDENTICAL_HPE_AUDIT_INTEGER_PRODUCTION_RECEIPTS +``` + +Default verify is read-only. Temp-copy apply-noop foil rejects via outcome +divergence or runtime failure. Package gates under `-O` still launch asserting +checker paths. Full `make verify`, selected cold replay, Lean, and +multiplication-theorem obligations were not rerun for this isolated +historical-checker change. + +## Result + +On Linux / CPython 3.12.3 with `taskset -c 0`, five alternating fresh-process +pairs timing the five honest FULL-WORD audits gave median wall time **6.304 → 2.528 s (2.494×)**. Details are in +[`RESULT.json`](RESULT.json). Timing is host-descriptive and is not a +correctness gate. Every honest and seeded-fuzz outcome matches the pairwise +baseline fieldwise (elapsed `seconds` excluded). + +## Why the integer rows are equivalent + +Each row stores integer numerators over one positive shared denominator. +Scale and ADD updates keep the same zero-free sparse support and the same +`Fraction` endpoint equality checks. Structural gate copies never share nested +lists; non-JSON-scalar shapes fall back to `deepcopy`. Memoized `basis` and +shared immutable `Fraction` coefficient objects do not change values. See +`research/hpe-audit-fast-seed93/README.md`. + +## Overlap and credit + +Closest priors (different delivery): + +- `research/hpe-audit-fast-seed93/` — opt-in integer rows; this is the production wiring. +- `research/frontier1042-lec-parallel/` / `research/layer-end-controls-parallel/` — + parallel call scheduling without changing the audit kernel. +- `research/emitted-local-integer-production/` / [#2357](https://github.com/CrocSwap/integer-mult-bounds/pull/2357) — + integer rows for `hpe_audit_local.py` (different object). +- [CrocSwap/integer-mult-bounds#756](https://github.com/CrocSwap/integer-mult-bounds/pull/756) + — identical-receipt tooling quality bar. + +Leave-alone tooling on other objects was not reopened. + +Credit Wronskode, icekylinx, DreamingOfClouds, and the retained PR635 lineage. +Prepared by Wentao Li ([VictorLiwentao](https://github.com/VictorLiwentao), +[@Is__Victor](https://x.com/Is__Victor)) with substantial AI assistance, under +Apache-2.0. + +## Open next questions + +1. **Question:** Should other vendored `hpe_audit_and_transport.py` copies adopt + the same integer-row rewrite? + **Why it matters:** Historical trees still pin pairwise-era digests. + **First step:** Diff each copy against the production transform site. + **Blocked by:** One-object stop rule. + +2. **Question:** Should `make frontier1042-verify` document the production + integer-row auditor as the default LEC kernel? + **Why it matters:** Operators may still export `PR635_CODE` to pairwise trees. + **First step:** Grep driver docs for `PR635_CODE` overrides. + **Blocked by:** Maintainer doc preference. diff --git a/research/hpe-audit-integer-production/RESULT.json b/research/hpe-audit-integer-production/RESULT.json new file mode 100644 index 0000000000..9d99ff52ca --- /dev/null +++ b/research/hpe-audit-integer-production/RESULT.json @@ -0,0 +1,29 @@ +{ + "schema_version": 1, + "package": "research/hpe-audit-integer-production", + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "workload": "five honest FULL-WORD audits (p6n,promo,jx,hyb,frames)", + "rounds": 5, + "baseline_seconds": [ + 6.257164812999918, + 6.217206600000054, + 6.30388413899982, + 6.328096263000134, + 6.516061718999936 + ], + "production_seconds": [ + 2.5163843390000693, + 2.527955178999946, + 2.523174858999937, + 2.5419634219999807, + 2.679991151999957 + ], + "median_baseline_seconds": 6.30388413899982, + "median_production_seconds": 2.527955178999946, + "median_speedup": 2.493669267306244, + "baseline_sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "production_sha256": "0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]", + "platform": "Linux 6.12.94+", + "note": "Host-descriptive; not a correctness gate. Receipts identical each round." +} diff --git a/research/hpe-audit-integer-production/SOURCES.json b/research/hpe-audit-integer-production/SOURCES.json new file mode 100644 index 0000000000..b521c54334 --- /dev/null +++ b/research/hpe-audit-integer-production/SOURCES.json @@ -0,0 +1,43 @@ +{ + "schema_version": 1, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "sha256": "d46eb6d5b3e279428753d770653663fbdf1063e55c255ea073d768f344927ef7", + "git_blob": "e8870e5917057d59b730eb14721a778639eca050" + }, + { + "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", + "usage": "provenance", + "git_blob": "d5d3509d90c01fd91dd00b78743287614b532e48", + "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "note": "Pairwise-era digest retained as provenance; working production file ships integer rows (see OPTIMIZED digest in TASK/VERIFY)." + }, + { + "path": "research/community-frontier1042-audit/selected-replay.tar.gz", + "usage": "input", + "sha256": "22c3f4dce4b897a1d423d1388801933e288b6a6b1906cb15e1b16a5eb68db754", + "git_blob": "6f4dc6fe7631d8aacf8081fcaecf32197181685b" + }, + { + "path": "research/hpe-audit-fast-seed93/hpe_audit_fast.py", + "usage": "input", + "sha256": "cc265f0094f74a89155948ab1a7442d6be4a730142614f647c259ec0c8ef6321", + "git_blob": "baca651653ec476bd79a15499521ea5675accd25" + }, + { + "path": "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz", + "usage": "input", + "sha256": "e070ae2c78b4a1b644b418774af62b40d8d16e6ba89602f0474afb557d507c37", + "git_blob": "cbb49a627768c42e1ff752f43ccfcc56ffe2cb0b" + } + ] +} diff --git a/research/hpe-audit-integer-production/TASK.json b/research/hpe-audit-integer-production/TASK.json new file mode 100644 index 0000000000..c18fe2a31c --- /dev/null +++ b/research/hpe-audit-integer-production/TASK.json @@ -0,0 +1,70 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "priority_revision": 4, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "chooser_seed": "hpe-audit-integer-production-60b9", + "budget_minutes": 60, + "original_card": { + "id": "replay-runtime", + "question": "Can one measured replay bottleneck be sped up without dropping coverage?", + "starting_points": [ + "scripts/run_isolated_tests.py", + "scripts/verify_replay_coverage.py", + "certificates/selected-result.json" + ], + "methods": [ + "Profile one isolated replay and optimize the measured bottleneck.", + "Design source-bound reuse with explicit dependency invalidation and negative controls." + ], + "acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the selected reproduction command and choose a single replay stage for profiling.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "allowed_variations": [ + "Profile one stage or design one source-bound cache boundary." + ], + "scope_change_triggers": [ + "Skipping coverage or comparing different fixtures to claim speedup." + ], + "overlap_terms": [ + "replay runtime", + "cache invalidation", + "isolated tests" + ] + }, + "scope_status": "refined", + "actual_scope": "Can the production PR635 hpe_audit_and_transport.py used by frontier1042 layer-end controls adopt the proved exact integer-row auditor from research/hpe-audit-fast-seed93/ so that the shipped LEC path is faster while every receipt field stays identical, without editing other vendored pairwise copies?", + "scope_change_reason": "The catalogue card asks for one measured replay bottleneck with before/after wall time and retained checks. Expertise override selected verifier-engineering after profiling leave-alone production rewrites and remaining proved opt-in adapters. Leave-alone objects were skipped; HPE transport audit remained pairwise on the shipped PR635 path with a proved ~2.5\u00d7 opt-in adapter.", + "bottleneck_link": "Faster trustworthy layer-end HPE audits increase review throughput for the selected frontier1042 chain without changing kappa or check coverage.", + "stop_rule": "Stop after wiring one production object with identical-receipt evidence, pin-drift demotions, and a descriptive before/after wall-time sample; do not invent kappa or reopen leave-alone objects.", + "evidence": "PASS_HPE_AUDIT_INTEGER_PRODUCTION via research/hpe-audit-integer-production/verify.py (also under -O); PASS_REGISTERED_RESEARCH_PACKAGE; PASS_IDENTICAL_HPE_AUDIT_INTEGER_PRODUCTION_RECEIPTS via pinned-CPU benchmark.py --rounds 5 (median 6.304\u21922.528 s, 2.494\u00d7); demote live prod-path pins in k8-hpe450-binding, k8-hpe450-forward-audit, selected1094-extended-labels-seed65, u8-terminal-cone-census, k8-rank7-composition, u8-e4-gap-fill, two-accumulator-saved-arms; refresh frontier1042-lec-parallel and layer-end-controls-parallel production audit digests; vendor baseline.py inside hpe-audit-fast-seed93 and hpe-audit-integer-production.", + "author": "Wentao Li", + "email": "wentaol4@illinois.edu", + "github": "VictorLiwentao", + "ai_assistance": "Substantial AI assistance for orientation, overlap search, profiling, production wiring, packaging, benchmarking and writing. Not independent human peer review.", + "outcome": "completed", + "open_questions": [ + { + "question": "Should other vendored hpe_audit_and_transport.py copies adopt the same integer-row rewrite?", + "why_it_matters": "Historical trees still pin pairwise-era digests; a coordinated refresh would remove stale inventory digests without changing receipts.", + "first_step": "Diff each copy against the production transform site and list which SOURCE inventories would need provenance demotion.", + "blocked_by": "One-object stop rule." + }, + { + "question": "Should make frontier1042-verify document the production integer-row auditor as the default LEC kernel?", + "why_it_matters": "Operators may still export PR635_CODE to pairwise trees.", + "first_step": "Grep driver docs for PR635_CODE overrides.", + "blocked_by": "Maintainer doc preference." + } + ] +} diff --git a/research/hpe-audit-integer-production/VERIFY.json b/research/hpe-audit-integer-production/VERIFY.json new file mode 100644 index 0000000000..cead5a52f8 --- /dev/null +++ b/research/hpe-audit-integer-production/VERIFY.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/hpe-audit-integer-production/baseline.py", + "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", + "research/community-frontier1042-audit/selected-replay.tar.gz", + "research/hpe-audit-fast-seed93/hpe_audit_fast.py", + "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 300, + "checks": "Exact baseline copy of the base-commit PR635 audit; production equals the integer-row transform; identical honest+fuzz outcomes; temp-copy apply-noop corruption control; duplicate JSON-key check; read-only default verify." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 300, + "checks": "Same equivalence and pin discipline under -O (require() gates remain; audit asserts still fire in child imports unless -O clears them\u2014production package require() gates do not rely on -O)." + } + ] +} diff --git a/research/hpe-audit-integer-production/baseline.py b/research/hpe-audit-integer-production/baseline.py new file mode 100644 index 0000000000..d5d3509d90 --- /dev/null +++ b/research/hpe-audit-integer-production/baseline.py @@ -0,0 +1,304 @@ +"""Rebuild arbitrary-dirt compensation and transport a changed local word. + +Prepared for icekylinx with GPT-6 Astra assistance. Apache-2.0. +Adapted from PR425/433 (icekylinx), PR484's audit_gk.py +(DreamingOfClouds), and Round19's 112-port transport. This auditor does not +import a constructor, a nominated compensation table, or a global price. +Only the changed scalar word and its actual frame chains are checked here. +""" +import argparse +import copy +import gzip +import hashlib +import json +import time +from collections import Counter +from fractions import Fraction as Q +from pathlib import Path + + +def read(path): + data = path.read_bytes() + return json.loads(gzip.decompress(data) if path.suffix == '.gz' else data) + + +def content_hash(path): + data = path.read_bytes() + return hashlib.sha256(gzip.decompress(data) if path.suffix == '.gz' else data).hexdigest() + + +def basis(vs): + pivots = {} + for x in vs: + for k in sorted(pivots, reverse=True): + if x >> k & 1: + x ^= pivots[k] + if x: + k = x.bit_length() - 1 + for j in pivots: + if pivots[j] >> k & 1: + pivots[j] ^= x + pivots[k] = x + return tuple(pivots[k] for k in sorted(pivots, reverse=True)) + + +def apply(e, rows): + if e[0] == 'scale': + _, target, a, b, *_ = e + q = Q(a, b) + assert q + rows[target] = {j: q*x for j, x in rows[target].items()} + else: + _, target, source, a, b, *_ = e + assert target != source + q = Q(a, b) + for j, x in list(rows[source].items()): + value = rows[target].get(j, Q(0)) + q*x + if value: + rows[target][j] = value + else: + rows[target].pop(j, None) + + +def inverse(e): + e = copy.deepcopy(e) + if e[0] == 'add': + e[3] *= -1 + else: + e[2], e[3] = e[3], e[2] + return e + + +def dual(e): + e = inverse(e) + if e[0] == 'add': + e[1], e[2] = e[2], e[1] + return e + + +def state_maps(prefix, n): + """P = exact state map of the prefix (precondition + compensation + A + cut + B), and P^-1 (rows as sparse dicts).""" + P = [{r: Q(1)} for r in range(n)] + for e in prefix: + apply(e, P) + Pinv = [{r: Q(1)} for r in range(n)] + for e in reversed(prefix): + apply(inverse(e), Pinv) + return P, Pinv + + +def cone_violations(P, Pinv, hpe, mapping, endB, final, frames): + """COLD-HPE / CONE PRE-CHECK. Necessary conditions for helper h (raw index) to end at U = final[h] under ANY + monotone common-frame cleanup of the end-of-B state P (frames only climb, every gate at a common frame): + row (J26-H dependency bound): every g in supp(row h of P^-1) has end-of-B frame <= U -- h is rebuilt from them; + column (dirt-column lemma): every g != h with P[g][h] != 0 has end-of-B frame <= U -- the column of P at h, + restricted to rows whose frame is not <= U, changes only by invertible row operations unless h is read at a + frame not <= U, so it can reach e_h only if it is already zero there. + Both are implied by the exact endpoint replay plus the frame checks below; here they fail FAST, with the reason.""" + inside = lambda a, b: basis(frames[a] + frames[b]) == frames[b] + viol = [] + for h in hpe: + U = final[mapping[h]] + viol += [('row', h, g) for g, x in sorted(Pinv[h].items()) if x and not inside(endB[mapping[g]], U)] + viol += [('column', h, g) for g in range(len(P)) if g != h and P[g].get(h) and not inside(endB[mapping[g]], U)] + return viol + + +def run(raw_path, routing_path, out): + start_time = time.monotonic() + word, routing = read(raw_path), read(routing_path) + v, h, helpers = word['report']['v'], word['report']['h'], word['report']['R'] + assert h == 9 and v == 112 and routing['v'] == v + n = 2*v + helpers + ident = lambda: [{r: Q(1)} for r in range(n)] + main = word['A'] + word['cut'] + word['B'] + assert all(not v <= e[2] < 2*v for e in word['A'] + word['B'] + if e[0] == 'add' and not v <= e[1] < 2*v) + matrix = ident() + for e in main: + apply(e, matrix) + dirty = [{} for _ in range(n)] + for r in range(v, 2*v): + dirty[r] = {j: x for j, x in matrix[r].items() if j >= 2*v} + for e in word['precondition']: + apply(e, dirty) + compensation = [['add', r, j, -q.numerator, q.denominator, []] + for r in range(v, 2*v) for j, q in sorted(dirty[r].items())] + entering = set(map(int, word.get('start_extra', {}))) + assert all(e[2] not in entering for e in compensation), 'zero-frame compensation reads an entering helper' + cleanup = [inverse(e) for e in reversed(word['A'] + word['B']) + if not v <= e[1] < 2*v] + if 'refactored_cleanup' in word: + # REFACTORED CLEANUP (cold low-frame ends): the cleanup is not the literal reversed inverse of A+B but another exact + # factorisation of the same inverse. Nothing about it is trusted: it may only touch non-target registers (T rows + # stay the compensated data accumulators), every gate is dyadic (checked below), and the arbitrary-dirt endpoint + # replay below must be exact in BOTH orientations for the full reordered program. Inherited words keep the literal + # assertion (the else branch), so their outputs are unchanged. + assert all(not v <= r < 2*v for e in word['cleanup'] for r in ([e[1]] + ([e[2]] if e[0] == 'add' else []))), 'refactored cleanup touches a target' + assert all(e[0] in ('add', 'scale') for e in word['cleanup']) + cleanup = word['cleanup'] + else: + assert [e[:-1] for e in cleanup] == [e[:-1] for e in word['cleanup']], 'cleanup is not the literal reversed inverse of A+B' + # HPE: hyperplane-ended helpers. 'early_cleanup' = [[cleanup index, frame vectors], ...] are cleanup gates executed + # right after B (before the final climbs) at the given frame; 'helper_final' = {helper: frame vectors} replaces FULL as + # that helper's terminal frame. The scalar program is the reordered one and is replayed exactly below, so a move that + # does not commute with the skipped cleanup prefix is rejected by the arbitrary-dirt endpoint assertion. + early = [(int(i), f) for i, f in word.get('early_cleanup', [])] + helper_final = {int(r): f for r, f in word.get('helper_final', {}).items()} + early_idx = [i for i, _ in early] + assert len(set(early_idx)) == len(early_idx) and all(0 <= i < len(cleanup) for i in early_idx) + assert all(2*v <= r < n for r in helper_final) + # COLD-HPE: a COLD helper (not in start_extra, entrance frame 0 = bottom) may also end at a proper subspace U. + # It is the E = bottom instance of #593's theorems: its wrappers are the (0, U) recipes R_{0,U}, L_{0,U} (checked + # exactly by hpe_adapters_local), emitted as residual_adapter events like an entering helper's. + cold_hpe = sorted(r for r in helper_final if r not in entering) + # COLD-HPE wrapper order: R_{0,U}^-1 is emitted with the entry adapters, after the zero-frame precondition and + # compensation, so (exactly as for an entering helper, asserted above) nothing before it may touch a cold-ended helper. + assert all(r not in set(cold_hpe) for e in word['precondition'] + compensation for r in ([e[1]] + ([e[2]] if e[0] == 'add' else []))), 'zero-frame precondition/compensation touches a cold hyperplane-ended helper before its wrapper' + # ENTERING helpers (start frame E != 0): their wrapper R_E^-1 precedes every gate on them, so the zero-frame precondition + # and compensation may not touch them either (mirrors hpe_emit_local's start-frame-0 rule here, at the scalar audit). + assert all(r not in entering for e in word['precondition'] + compensation for r in ([e[1]] + ([e[2]] if e[0] == 'add' else []))), 'zero-frame precondition/compensation touches an entering helper' + tail =[word['cleanup'][i][:-1] + [f] for i, f in early] + rest = [e for i, e in enumerate(word['cleanup']) if i not in set(early_idx)] + program = word['precondition'] + compensation + main + tail + rest + for backward in (False, True): + actual = ident() + for e in program: + apply(dual(e) if backward else e, actual) + expected = ident() + for t in range(v): + expected[t if backward else v+t][v+t if backward else t] = Q(-1 if backward else 1) + assert actual == expected, ('arbitrary-dirt endpoint', backward) + # The native scalar compiler allows dyadic additions and signed binary scales. + for e in program: + q = Q(e[3], e[4]) if e[0] == 'add' else Q(e[2], e[3]) + assert q.denominator & (q.denominator-1) == 0 + if e[0] == 'scale': + a = abs(q.numerator) + assert a and a & (a-1) == 0 + + tau = lambda x: x ^ (43 if (x & 43).bit_count() % 2 else 0) + ports = routing['ports'] + assert len(set(ports)) == v and set(map(tau, word['ports'])) == set(ports) + mapping = {i: ports.index(tau(p)) for i, p in enumerate(word['ports'])} + mapping.update({v+i: v+mapping[i] for i in range(v)}) + mapping.update({r: r for r in range(2*v, n)}) + full = tuple(1 << i for i in range(h-1, -1, -1)) + frames, frame_ids = [(), full], {(): 0, full: 1} + + def fid(vectors): + frame = basis(vectors) + if frame not in frame_ids: + frame_ids[frame] = len(frames) + frames.append(frame) + return frame_ids[frame] + + def transform(e): + e = copy.deepcopy(e) + e[1] = mapping[e[1]] + if e[0] == 'add': + e[2] = mapping[e[2]] + if e[-1] is not None: + e[-1] = fid([tau(x) for x in e[-1]]) + return e + + canonical = {key: [transform(e) for e in word[key]] + for key in ('A', 'B', 'cut', 'cleanup', 'precondition')} + canonical['compensation'] = [transform(e) for e in compensation] + if tail: + canonical['tail'] = [transform(e) for e in tail] # HPE (absent for inherited words: identical output) + canonical['cleanup'] = [transform(e) for e in rest] # HPE (full cleanup minus the early gates) + canonical['start'] = [fid([p]) for p in ports] + [0]*(v+helpers) + for r, frame in word.get('start_extra', {}).items(): + assert 2*v <= int(r) < n + canonical['start'][int(r)] = fid([tau(x) for x in frame]) + canonical['final'] = ([1]*v + + [fid(x for x in range(1, 1 << h) if (x & p).bit_count() % 2 == 0) for p in ports] + + [1]*helpers) + for r, frame in helper_final.items(): # HPE + canonical['final'][r] = fid([tau(x) for x in frame]) + canonical.update(h=h, v=v, R=helpers, ports=ports, frames=frames, + centers=[mapping[r] for r in word['centers']], + center_frames=[fid(tau(x) for x in frame) for frame in word['center_frames']]) + levels = {mapping[v+int(t)]-v: fid(tau(x) for x in frame) + for t, frame in word.get('target_levels', {}).items()} + canonical['target_levels'] = {str(t): f for t, f in levels.items()} + current, paid, edges = canonical['start'].copy(), Counter(), set() + + def climb(r, f): + old = current[r] + assert basis(frames[old] + frames[f]) == frames[f], ('nonmonotone', r, old, f) + if old != f: + degree = len(frames[f]) - len(frames[old]) + assert degree > 0 + paid[degree] += 1 + edges.add((old, f)) + current[r] = f + + for part in ('A', 'B'): + if part == 'B': + assert all(current[r] == f for r, f in zip(canonical['centers'], canonical['center_frames'])) + assert all(current[v+t] == levels.get(t, 0) for t in range(v)) + for r, frame in zip(canonical['centers'], canonical['center_frames']): + served = {levels.get(e[1]-v, 0) for e in canonical['cut'] if e[2] == r} + old = frame + for f in sorted(served, key=lambda f: -len(frames[f])): + assert basis(frames[old] + frames[f]) == frames[old] + if old != f: + paid[len(frames[old])-len(frames[f])] += 1 + edges.add((old, f)) + edges.add((f, old)) + old = f + for e in canonical[part]: + for r in [e[1]] + ([e[2]] if e[0] == 'add' else []): + climb(r, e[-1]) + if helper_final: # COLD-HPE / CONE PRE-CHECK at the end-of-B frames + P, Pinv = state_maps(word['precondition'] + compensation + main, n) + cone = cone_violations(P, Pinv, sorted(helper_final), mapping, current.copy(), canonical['final'], frames) + assert not cone, ('hpe cone pre-check (row / column)', cone[:8]) + for e in canonical.get('tail', []): # HPE: early cleanup gates at their common frame + for r in [e[1]] + ([e[2]] if e[0] == 'add' else []): + climb(r, e[-1]) + for r, f in enumerate(canonical['final']): + climb(r, f) + # HPE: the remaining cleanup runs at FULL, so it may touch only registers whose terminal frame is FULL; a + # hyperplane-ended helper is touched by nothing after its tail gates. + for e in canonical['cleanup']: + assert all(canonical['final'][r] == 1 for r in [e[1]] + ([e[2]] if e[0] == 'add' else [])), ('cleanup on non-FULL end', e) + assert all(len(frames[canonical['final'][r]]) < h for r in helper_final) + assert dict(paid) == {int(r): count for r, count in word['report']['local_profile'].items()}, 'paid local profile differs from the reported local_profile' + canonical['local_profile'] = dict(sorted(paid.items())) + canonical['edges'] = sorted(edges) + out.mkdir(parents=True, exist_ok=False) + payload = json.dumps(canonical, sort_keys=True, separators=(',', ':')).encode() + (out/'CANONICAL-WORD.json.gz').write_bytes(gzip.compress(payload, mtime=0)) + (out/'FULL-WORD.json.gz').write_bytes(gzip.compress(json.dumps(word, sort_keys=True, separators=(',', ':')).encode(), mtime=0)) + receipt = dict(status='PASS_CHANGED_WORD_ALL_COLUMNS_AND_NATIVE_FRAMES', + input_content_sha256=content_hash(raw_path), routing_content_sha256=content_hash(routing_path), + canonical_content_sha256=hashlib.sha256(payload).hexdigest(), + live_columns_each_orientation=n, helpers=helpers, + compensation_additions=len(compensation), scalar_operations=len(program), + center_rank_sum=sum(map(len, word['center_frames'])), + local_profile=dict(sorted(paid.items())), local_rank_mass=sum(r*z for r, z in paid.items()), + widths=[len(frames[canonical['final'][r]])-len(frames[canonical['start'][r]]) for r in range(2*v, n)], + frames=len(frames), directed_edges=len(edges), + tau=43, target_port_order_matches_baseline=True, + seconds=time.monotonic()-start_time, + scope='Fresh exact forward and inverse-transpose scalar replay on every arbitrary input; all native frame chains and dyadic primitives. Phase lowering, wrappers, global owners and global assembly are separate.') + if tail or helper_final: + receipt.update(hyperplane_ended_helpers=sorted(helper_final), early_cleanup_gates=len(tail)) + if cold_hpe: # COLD-HPE (absent for words without cold ends) + receipt.update(cold_hyperplane_ended_helpers=cold_hpe) + if 'refactored_cleanup' in word: # REFACTORED CLEANUP (absent for inherited words) + receipt.update(refactored_cleanup_gates=len(word['cleanup']), refactored_cleanup=word['refactored_cleanup']) + (out/'SCALAR-FRAME-AUDIT.json').write_text(json.dumps(receipt, indent=2)+'\n') + print(json.dumps({k: value for k, value in receipt.items() if k != 'widths'}, indent=2), flush=True) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--raw', type=Path, required=True) + parser.add_argument('--routing', type=Path, required=True) + parser.add_argument('--out', type=Path, required=True) + args = parser.parse_args() + run(args.raw, args.routing, args.out) diff --git a/research/hpe-audit-integer-production/benchmark.py b/research/hpe-audit-integer-production/benchmark.py new file mode 100755 index 0000000000..f7d027ef65 --- /dev/null +++ b/research/hpe-audit-integer-production/benchmark.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 +"""Paired wall-time samples for production HPE integer-row audit. + +Descriptive only: timing is not a correctness gate. +""" +from __future__ import annotations + +import argparse +import gzip +import hashlib +import importlib.util +import io +import contextlib +import json +import os +from pathlib import Path +import statistics +import subprocess +import sys +import tarfile +import tempfile +import time + +ROOT = Path(__file__).resolve().parents[2] +PACKAGE = Path(__file__).resolve().parent +PRODUCTION = ROOT / ( + "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/" + "code/hpe_audit_and_transport.py" +) +BASELINE = PACKAGE / "baseline.py" +ARCHIVE = ROOT / "research/community-frontier1042-audit/selected-replay.tar.gz" +ROUTING = ROOT / ( + "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/" + "complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz" +) +WORDS = ("p6n", "promo", "jx", "hyb", "frames") + + +def load_module(name: str, path: Path): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + assert spec.loader is not None + spec.loader.exec_module(module) + return module + + +def run_five(module, words, tmp: Path) -> tuple[float, list]: + receipts = [] + start = time.perf_counter() + for name, data in words: + raw = tmp / f"{name}.json.gz" + raw.write_bytes(data) + out = tmp / f"out-{name}-{time.time_ns()}" + printed = io.StringIO() + with contextlib.redirect_stdout(printed): + module.run(raw, ROUTING, out) + receipt = json.loads((out / "SCALAR-FRAME-AUDIT.json").read_text()) + receipt.pop("seconds", None) + receipts.append(receipt) + return time.perf_counter() - start, receipts + + +def main(argv=None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--rounds", type=int, default=5) + parser.add_argument("--write-result", action="store_true") + args = parser.parse_args(argv) + + with tarfile.open(ARCHIVE) as archive: + words = [(name, archive.extractfile(f"chain/{name}/FULL-WORD.json.gz").read()) for name in WORDS] + + base_times = [] + prod_times = [] + with tempfile.TemporaryDirectory(prefix="hpe-audit-bench-") as tmp: + tmp_path = Path(tmp) + for i in range(args.rounds): + # Alternate order each round. + order = ("baseline", "production") if i % 2 == 0 else ("production", "baseline") + for engine in order: + path = BASELINE if engine == "baseline" else PRODUCTION + module = load_module(f"{engine}_{i}", path) + work = tmp_path / f"r{i}-{engine}" + work.mkdir(exist_ok=True) + dt, receipts = run_five(module, words, work) + if engine == "baseline": + base_times.append(dt) + base_receipts = receipts + else: + prod_times.append(dt) + prod_receipts = receipts + if base_receipts != prod_receipts: + raise SystemExit("PASS gate failed: receipts diverged during benchmark") + + base_med = statistics.median(base_times) + prod_med = statistics.median(prod_times) + ratio = base_med / prod_med if prod_med else float("inf") + result = { + "schema_version": 1, + "package": "research/hpe-audit-integer-production", + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "workload": "five honest FULL-WORD audits (p6n,promo,jx,hyb,frames)", + "rounds": args.rounds, + "baseline_seconds": base_times, + "production_seconds": prod_times, + "median_baseline_seconds": base_med, + "median_production_seconds": prod_med, + "median_speedup": ratio, + "baseline_sha256": hashlib.sha256(BASELINE.read_bytes()).hexdigest(), + "production_sha256": hashlib.sha256(PRODUCTION.read_bytes()).hexdigest(), + "python": sys.version, + "platform": os.uname().sysname + " " + os.uname().release, + "note": "Host-descriptive; not a correctness gate. Receipts identical each round.", + } + print(json.dumps({ + "median_baseline_seconds": base_med, + "median_production_seconds": prod_med, + "median_speedup": ratio, + }, indent=2), flush=True) + print( + f"PASS_IDENTICAL_HPE_AUDIT_INTEGER_PRODUCTION_RECEIPTS " + f"median {base_med:.3f}->{prod_med:.3f}s ({ratio:.3f}x)", + flush=True, + ) + if args.write_result: + (PACKAGE / "RESULT.json").write_text(json.dumps(result, indent=2) + "\n") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/hpe-audit-integer-production/verify.py b/research/hpe-audit-integer-production/verify.py new file mode 100755 index 0000000000..0c1018fc34 --- /dev/null +++ b/research/hpe-audit-integer-production/verify.py @@ -0,0 +1,265 @@ +#!/usr/bin/env python3 +"""Equivalence, pin and rejection controls for production HPE integer-row audit. + +Read-only by default. Timing is not a pass gate; see benchmark.py / RESULT.json. +""" +from __future__ import annotations + +import argparse +import ast +import contextlib +import copy +import gzip +import hashlib +import importlib.util +import io +import json +import os +from pathlib import Path +import random +import subprocess +import sys +import tarfile +import tempfile +import time + +ROOT = Path(__file__).resolve().parents[2] +PACKAGE = Path(__file__).resolve().parent +PRODUCTION = ROOT / ( + "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/" + "code/hpe_audit_and_transport.py" +) +BASELINE = PACKAGE / "baseline.py" +OPT_IN_FAST = ROOT / "research/hpe-audit-fast-seed93/hpe_audit_fast.py" +ARCHIVE = ROOT / "research/community-frontier1042-audit/selected-replay.tar.gz" +ROUTING = ROOT / ( + "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/" + "complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz" +) + +BASE_COMMIT = "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2" +ORIGINAL_BLOB = "d5d3509d90c01fd91dd00b78743287614b532e48" +ORIGINAL_SHA256 = "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3" +OPTIMIZED_SHA256 = "0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747" +ROUTING_SHA256 = "e070ae2c78b4a1b644b418774af62b40d8d16e6ba89602f0474afb557d507c37" +WORDS = ("p6n", "promo", "jx", "hyb", "frames") +SECTIONS = ("A", "B", "cut", "precondition", "cleanup") + + +def require(condition, message): + if not condition: + raise AssertionError(message) + + +def digest_file(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def unique_object(pairs): + out = {} + for key, value in pairs: + require(key not in out, f"duplicate JSON key: {key}") + out[key] = value + return out + + +def load_module(name: str, path: Path): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + assert spec.loader is not None + spec.loader.exec_module(module) + return module + + +def check_baseline_bytes() -> None: + original = subprocess.check_output( + ["git", "show", f"{BASE_COMMIT}:research/complex-sw4-frame8/vendor/pr635/" + "research/complex-571-cold14-st2/code/hpe_audit_and_transport.py"], + cwd=ROOT, + ) + require(hashlib.sha256(original).hexdigest() == ORIGINAL_SHA256, "base audit sha256 drift") + blob = ( + subprocess.check_output( + ["git", "rev-parse", f"{BASE_COMMIT}:research/complex-sw4-frame8/vendor/pr635/" + "research/complex-571-cold14-st2/code/hpe_audit_and_transport.py"], + cwd=ROOT, + ) + .decode() + .strip() + ) + require(blob == ORIGINAL_BLOB, "base audit blob drift") + require(BASELINE.read_bytes() == original, "baseline.py must equal the base-commit audit") + require(digest_file(PRODUCTION) == OPTIMIZED_SHA256, "production audit digest drift") + require(PRODUCTION.read_bytes() != original, "production must differ from pairwise baseline") + require(digest_file(ROUTING) == ROUTING_SHA256, "routing word digest drift") + # Opt-in fast file must remain an equivalent algorithm source. + require(OPT_IN_FAST.exists(), "opt-in hpe_audit_fast.py missing") + require("def apply" in PRODUCTION.read_text(encoding="utf-8"), "production must define apply") + require("_NORMALIZE_BITS" in PRODUCTION.read_text(encoding="utf-8"), "production must use integer rows") + require("_NORMALIZE_BITS" not in BASELINE.read_text(encoding="utf-8"), "baseline must stay pairwise") + + +def outcome(module, raw: Path, out: Path): + printed = io.StringIO() + try: + with contextlib.redirect_stdout(printed): + module.run(raw, ROUTING, out) + except Exception as exc: # noqa: BLE001 - compare exact failure class + return ("raise", type(exc).__name__, repr(exc.args)) + files = {p.name: p.read_bytes() for p in sorted(out.iterdir())} + receipt = json.loads(files.pop("SCALAR-FRAME-AUDIT.json"), object_pairs_hook=unique_object) + receipt.pop("seconds", None) + text = json.loads(printed.getvalue(), object_pairs_hook=unique_object) + text.pop("seconds", None) + return ("pass", files, receipt, text) + + +def archived_words(): + with tarfile.open(ARCHIVE) as archive: + for name in WORDS: + member = f"chain/{name}/FULL-WORD.json.gz" + data = archive.extractfile(member).read() + yield name, data + + +def check_identical_receipts() -> dict: + ref = load_module("hpe_baseline", BASELINE) + prod = load_module("hpe_production", PRODUCTION) + honest = 0 + with tempfile.TemporaryDirectory(prefix="hpe-audit-prod-") as tmp: + tmp_path = Path(tmp) + for name, data in archived_words(): + raw = tmp_path / f"{name}.json.gz" + raw.write_bytes(data) + left = outcome(ref, raw, tmp_path / f"{name}-ref") + right = outcome(prod, raw, tmp_path / f"{name}-prod") + require(left == right, f"honest mismatch on {name}") + honest += 1 + # Seeded fuzz on hyb word + hyb = json.loads(gzip.decompress((tmp_path / "hyb.json.gz").read_bytes())) + rng = random.Random(93) + fuzz_ok = 0 + for i in range(40): + word = mutate(hyb, rng) + raw = tmp_path / f"fuzz-{i}.json.gz" + raw.write_bytes(gzip.compress(json.dumps(word).encode(), mtime=0)) + left = outcome(ref, raw, tmp_path / f"fuzz-{i}-ref") + right = outcome(prod, raw, tmp_path / f"fuzz-{i}-prod") + require(left == right, f"fuzz mismatch #{i}") + fuzz_ok += 1 + return {"honest": honest, "fuzz": fuzz_ok} + + +def mutate(word, rng): + w = copy.deepcopy(word) + n = 2 * w["report"]["v"] + w["report"]["R"] + sec = rng.choice([s for s in SECTIONS if w[s]]) + i = rng.randrange(len(w[sec])) + g = w[sec][i] + kind = rng.choice(["coef", "coef", "coef", "edge", "drop", "swap", "dup", "reg", "frame"]) + if kind == "coef": + k = 3 if g[0] == "add" else 2 + g[k + rng.randrange(2)] = rng.choice([-3, -2, -1, 1, 2, 3, 5, 7, 4, 1024, -1024]) + elif kind == "edge": + k = 3 if g[0] == "add" else 2 + g[k + rng.choice([0, 1])] = rng.choice([0, 3**60, -(5**50), 2**300, "x", 1.5, None]) + elif kind == "drop": + del w[sec][i] + elif kind == "swap" and len(w[sec]) > 1: + j = i + 1 if i + 1 < len(w[sec]) else i - 1 + w[sec][i], w[sec][j] = w[sec][j], w[sec][i] + elif kind == "dup": + w[sec].insert(i, copy.deepcopy(g)) + elif kind == "reg": + g[1 + (rng.randrange(2) if g[0] == "add" else 0)] = rng.randrange(n) + elif kind == "frame" and isinstance(g[-1], list): + if g[-1]: + g[-1][rng.randrange(len(g[-1]))] ^= 1 << rng.randrange(8) + return w + + +def check_assertions_preserved() -> int: + def assertion_list(text: str): + return [ + ast.dump(n, include_attributes=False) + for n in ast.walk(ast.parse(text)) + if isinstance(n, ast.Assert) + ] + + # Production adds no assert nodes beyond the baseline control-flow asserts; + # compare the baseline assert dump to the production dump after stripping + # only docstring/import differences is fragile, so require every baseline + # assert string literal still appears in production source. + base_src = BASELINE.read_text(encoding="utf-8") + prod_src = PRODUCTION.read_text(encoding="utf-8") + base_asserts = assertion_list(base_src) + prod_asserts = assertion_list(prod_src) + require(len(prod_asserts) >= len(base_asserts), "production dropped asserts") + for msg in ( + "hpe cone pre-check (row / column)", + "paid local profile differs from the reported local_profile", + "cleanup on non-FULL end", + ): + require(msg in prod_src, f"missing assert message: {msg}") + require(msg in base_src, f"baseline missing assert message: {msg}") + return len(prod_asserts) + + +def check_temp_corruption_rejection() -> dict: + """On-disk foil that skips ADD row updates must diverge or fail closed.""" + ref = load_module("hpe_baseline_corrupt", BASELINE) + with tempfile.TemporaryDirectory(prefix="hpe-audit-prod-honest-") as tmp: + tmp_path = Path(tmp) + name, data = next(archived_words()) + raw = tmp_path / "honest.json.gz" + raw.write_bytes(data) + honest = outcome(load_module("hpe_production_honest", PRODUCTION), raw, tmp_path / "honest") + + text = PRODUCTION.read_text(encoding="utf-8") + needle = "def apply(e, rows):" + require(needle in text, "apply site missing for corruption control") + # Foil: no-op apply so compensation/endpoints break. + foil_text = text.replace( + needle, + "def apply(e, rows):\n return\n\ndef apply_disabled(e, rows):", + 1, + ) + require(foil_text != text, "mutant must differ on disk") + with tempfile.TemporaryDirectory(prefix="hpe-audit-prod-foil-") as tmp: + mutant_path = Path(tmp) / "hpe_audit_and_transport.py" + mutant_path.write_text(foil_text, encoding="utf-8") + work = Path(tmp) / "work" + work.mkdir() + name, data = next(archived_words()) + raw = work / "word.json.gz" + raw.write_bytes(data) + try: + bad = outcome(load_module("hpe_foil", mutant_path), raw, work / "out") + except Exception as exc: # noqa: BLE001 + return {"rejected": True, "mode": "import_or_runtime_failure", "detail": str(exc)[:240]} + require(bad != honest, "ADD-drop foil must change the audit outcome") + return {"rejected": True, "mode": "receipt_divergence"} + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.parse_args(argv) + check_baseline_bytes() + assertions = check_assertions_preserved() + receipts = check_identical_receipts() + corruption = check_temp_corruption_rejection() + require(corruption["rejected"], "corruption control must reject") + print( + "PASS_HPE_AUDIT_INTEGER_PRODUCTION " + f"assertions={assertions} " + f"honest={receipts['honest']} " + f"fuzz={receipts['fuzz']} " + f"corruption={corruption['mode']} " + "certs=0 no_new_kappa", + flush=True, + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/k8-hpe450-binding/SOURCES.json b/research/k8-hpe450-binding/SOURCES.json index e9441e66ad..34ee35113c 100644 --- a/research/k8-hpe450-binding/SOURCES.json +++ b/research/k8-hpe450-binding/SOURCES.json @@ -22,9 +22,10 @@ }, { "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", - "usage": "input", + "usage": "provenance", "git_blob": "d5d3509d90c01fd91dd00b78743287614b532e48", - "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3" + "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "note": "Pairwise-era digest retained as provenance after research/hpe-audit-integer-production/; working PR635 hpe_audit_and_transport.py ships integer rows." }, { "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_emit_local.py", diff --git a/research/k8-hpe450-binding/VERIFY.json b/research/k8-hpe450-binding/VERIFY.json index 3c84195008..cda9eda8bb 100644 --- a/research/k8-hpe450-binding/VERIFY.json +++ b/research/k8-hpe450-binding/VERIFY.json @@ -8,7 +8,6 @@ "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_adapters_local.py", - "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_emit_local.py", "research/e8-lemma-g-lean/LemmaG/Stream.lean", "research/gauge44-slots/construction/slots/SLOT-PINS-k8.json", diff --git a/research/k8-hpe450-forward-audit/SOURCES.json b/research/k8-hpe450-forward-audit/SOURCES.json index b816d8a0d7..fcf6063926 100644 --- a/research/k8-hpe450-forward-audit/SOURCES.json +++ b/research/k8-hpe450-forward-audit/SOURCES.json @@ -10,9 +10,10 @@ }, { "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", - "usage": "input", + "usage": "provenance", "git_blob": "d5d3509d90c01fd91dd00b78743287614b532e48", - "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3" + "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "note": "Pairwise-era digest retained as provenance after research/hpe-audit-integer-production/; working PR635 hpe_audit_and_transport.py ships integer rows." }, { "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_emit_local.py", diff --git a/research/k8-hpe450-forward-audit/VERIFY.json b/research/k8-hpe450-forward-audit/VERIFY.json index 390b40d1cd..5e2b2124fc 100644 --- a/research/k8-hpe450-forward-audit/VERIFY.json +++ b/research/k8-hpe450-forward-audit/VERIFY.json @@ -6,7 +6,6 @@ "inputs": [ "research/community-frontier1094-audit/SELECTED-SOURCE.json", "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz", - "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_emit_local.py", "research/gauge44-slots/construction/slots/SLOT-PINS-k8.json", "research/t16-owner-audit-seed67/inputs/k8-seven-slot-word.json.gz" diff --git a/research/k8-rank7-composition/SOURCES.json b/research/k8-rank7-composition/SOURCES.json index b102f57b6c..50abba3e46 100644 --- a/research/k8-rank7-composition/SOURCES.json +++ b/research/k8-rank7-composition/SOURCES.json @@ -315,7 +315,11 @@ "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/generated_identity.py": "c8af22719c0f3097a991a3f6ccac8f090afd2faba554745733d9ea88f2c25708", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/generated_identity_controls.py": "a7b93207a673575d1fddc3e579153349c145c8f08d4575ae0a5d1e3cffec01de", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_adapters_local.py": "eb0b5c6c7161e18dc22168da3211448d321586edd15bcfb4b4741174d36993cf", - "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py": { + "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "usage": "provenance", + "note": "Pairwise-era digest retained as provenance after research/hpe-audit-integer-production/; working PR635 hpe_audit_and_transport.py ships integer rows." + }, "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_local.py": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_controls_atc.py": "63aa3909b5bfd3bf270c313bebb5c46e7789c67a8f2439f568bc4b2b4a35d17b", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_emit_local.py": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805", diff --git a/research/layer-end-controls-parallel/PINS.json b/research/layer-end-controls-parallel/PINS.json index 512f8d4797..fa55ceea5d 100644 --- a/research/layer-end-controls-parallel/PINS.json +++ b/research/layer-end-controls-parallel/PINS.json @@ -21,7 +21,8 @@ }, "pr635_code": { "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code", - "audit_sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3" + "audit_sha256": "0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747", + "note": "Updated for research/hpe-audit-integer-production integer-row production audit." }, "layer_controls": 95 } diff --git a/research/layer-end-controls-parallel/audit_worker.py b/research/layer-end-controls-parallel/audit_worker.py index 5f5a3d4592..4a9dabfddf 100644 --- a/research/layer-end-controls-parallel/audit_worker.py +++ b/research/layer-end-controls-parallel/audit_worker.py @@ -10,7 +10,7 @@ import tempfile from pathlib import Path -AUDIT_SHA256 = 'c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3' +AUDIT_SHA256 = '0dacf4cedb020d561e0188052319f1a6e6abaf6c79f9e94d8c9c91492e5c1747' AUDIT = None diff --git a/research/selected1094-extended-labels-seed65/SOURCES.json b/research/selected1094-extended-labels-seed65/SOURCES.json index fc54b62560..4dfb0ba88f 100644 --- a/research/selected1094-extended-labels-seed65/SOURCES.json +++ b/research/selected1094-extended-labels-seed65/SOURCES.json @@ -34,9 +34,10 @@ }, { "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", - "usage": "input", + "usage": "provenance", "git_blob": "d5d3509d90c01fd91dd00b78743287614b532e48", - "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3" + "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "note": "Pairwise-era digest retained as provenance after research/hpe-audit-integer-production/; working PR635 hpe_audit_and_transport.py ships integer rows." }, { "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_local.py", diff --git a/research/selected1094-extended-labels-seed65/VERIFY.json b/research/selected1094-extended-labels-seed65/VERIFY.json index c4c0bb95a4..e0c3d63583 100644 --- a/research/selected1094-extended-labels-seed65/VERIFY.json +++ b/research/selected1094-extended-labels-seed65/VERIFY.json @@ -7,7 +7,6 @@ "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/code/phases_full.py", "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", "research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-local/inputs/phase-baseline/CANONICAL-WORD.json.gz", - "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_local.py", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_emit_local.py", "research/complex-t16-rare-pattern-exchanges/data/PLAN.json", @@ -25,12 +24,21 @@ ], "commands": [ { - "argv": ["{python}", "-B", "{package}/verify.py"], + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], "timeout_seconds": 540, "checks": "Identity: every input SHA-256/blob against SOURCES.json, quoted source lines, patched checker rebuilt byte-for-byte from the pinned original, SLOT-PINS-k8 and the #1094 PLAN registry name the same hashes. Positive fixture: canonical 4ddb29fb, programs 071ecdac/f36c5831 and CLIFFORD-RECIPES d0768f21 regenerated from committed bytes; independent HPE-aware extended-label check 0 violations in both orientations and two readings, exact scalar shadow, 224 non-identity endpoint monomials, patched Lemma G checker 0 violations. Failure controls: 28 forward and 27 backward label-checker edits rejected under both readings plus one strict-only edit; the three admission mutants X, Y, Z (accepted by the pinned frame-only replay; rejected by both label checkers and by the recommended adapter rule; exact witnesses); every one of the 32 single-clause weakenings of the label checker re-run on all 62 pinned inputs (31 change a pinned value; the redundant survivor is pinned); the published checker's parse failure and 96 stripped-field violations; the patched checker's own 5 mutants. Every number is compared with EXPECTED.json." }, { - "argv": ["{python}", "-O", "-B", "{package}/verify.py"], + "argv": [ + "{python}", + "-O", + "-B", + "{package}/verify.py" + ], "timeout_seconds": 540, "checks": "Optimisation control: the same verifier under -O must reach the same EXPECTED.json result, because every package check raises ValueError and the pinned producer scripts run in separate -I -B subprocesses with their assertions active." } diff --git a/research/two-accumulator-saved-arms/SOURCES.json b/research/two-accumulator-saved-arms/SOURCES.json index 7cfef2c237..02fa684c19 100644 --- a/research/two-accumulator-saved-arms/SOURCES.json +++ b/research/two-accumulator-saved-arms/SOURCES.json @@ -121,7 +121,9 @@ "commit": "bce54fb3f895cbe5cd4c0eb477c3afeed100190f", "path": "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py", "git_blob": "d5d3509d90c01fd91dd00b78743287614b532e48", - "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3" + "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "usage": "provenance", + "note": "Pairwise-era digest retained as provenance after research/hpe-audit-integer-production/; working PR635 hpe_audit_and_transport.py ships integer rows." }, { "commit": "bce54fb3f895cbe5cd4c0eb477c3afeed100190f", diff --git a/research/u8-e4-gap-fill/SOURCES.json b/research/u8-e4-gap-fill/SOURCES.json index 1b9b54e8be..a18a2e0d49 100644 --- a/research/u8-e4-gap-fill/SOURCES.json +++ b/research/u8-e4-gap-fill/SOURCES.json @@ -40,7 +40,11 @@ "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/generated_identity.py": "c8af22719c0f3097a991a3f6ccac8f090afd2faba554745733d9ea88f2c25708", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/generated_identity_controls.py": "a7b93207a673575d1fddc3e579153349c145c8f08d4575ae0a5d1e3cffec01de", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_adapters_local.py": "eb0b5c6c7161e18dc22168da3211448d321586edd15bcfb4b4741174d36993cf", - "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py": { + "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", + "usage": "provenance", + "note": "Pairwise-era digest retained as provenance after research/hpe-audit-integer-production/; working PR635 hpe_audit_and_transport.py ships integer rows." + }, "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_local.py": "6bd9a1e279c9c9e4f3767d9f82e537b559292906feb2ddab02f380fb6523a810", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_controls_atc.py": "63aa3909b5bfd3bf270c313bebb5c46e7789c67a8f2439f568bc4b2b4a35d17b", "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_emit_local.py": "7e4a6fbc38c8228157b6311457d1496bf460291393043932d2c365f004f77805", diff --git a/research/u8-terminal-cone-census/SOURCES.json b/research/u8-terminal-cone-census/SOURCES.json index 2f23c2f738..819107e70a 100644 --- a/research/u8-terminal-cone-census/SOURCES.json +++ b/research/u8-terminal-cone-census/SOURCES.json @@ -38,7 +38,9 @@ }, "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/hpe_audit_and_transport.py": { "sha256": "c9a05ff291016b870b4fc925b317abd9c3a604c73ffc8920dfdbbeb475e20aa3", - "git_blob": "d5d3509d90c01fd91dd00b78743287614b532e48" + "git_blob": "d5d3509d90c01fd91dd00b78743287614b532e48", + "usage": "provenance", + "note": "Pairwise-era digest retained as provenance after research/hpe-audit-integer-production/; working PR635 hpe_audit_and_transport.py ships integer rows." }, "research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/README.md": { "sha256": "d74a9499a23a729d3470bde7b06b85c4cf8602d06d10af9bf9991aea2da8ed7e", diff --git a/tests/test_hpe_audit_integer_production.py b/tests/test_hpe_audit_integer_production.py new file mode 100644 index 0000000000..d51b821091 --- /dev/null +++ b/tests/test_hpe_audit_integer_production.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +"""unittest entry for research/hpe-audit-integer-production.""" +import unittest +import subprocess +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +class HpeAuditIntegerProductionTests(unittest.TestCase): + def test_verify(self): + proc = subprocess.run( + [sys.executable, "-I", "-B", str(ROOT / "research/hpe-audit-integer-production/verify.py")], + cwd=ROOT, + capture_output=True, + text=True, + ) + self.assertEqual(proc.returncode, 0, proc.stderr + proc.stdout) + self.assertIn("PASS_HPE_AUDIT_INTEGER_PRODUCTION", proc.stdout) + + +if __name__ == "__main__": + unittest.main() From dbaf88ec7165ae8547d2756407583c04b3ead27b Mon Sep 17 00:00:00 2001 From: Wentao Li Date: Thu, 15 Oct 2026 07:44:00 +0000 Subject: [PATCH 2/2] Tooling: enforce -O admission and retarget seed93 tests to baseline Load production/baseline checkers with compile(..., optimize=0) and gate scale-zero AssertionError under -O. Point hpe-audit-fast-seed93 unit tests and crosscheck reference at vendored pairwise baseline.py. Prepared by Wentao Li with substantial AI assistance. --- research/hpe-audit-fast-seed93/README.md | 9 +++++-- .../hpe-audit-fast-seed93/test_package.py | 8 +++--- .../hpe-audit-integer-production/VERIFY.json | 2 +- .../hpe-audit-integer-production/verify.py | 26 +++++++++++++++---- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/research/hpe-audit-fast-seed93/README.md b/research/hpe-audit-fast-seed93/README.md index d1792292f4..2c4efa7f57 100644 --- a/research/hpe-audit-fast-seed93/README.md +++ b/research/hpe-audit-fast-seed93/README.md @@ -14,13 +14,18 @@ In the selected #1042 replay, the `chain` stage takes 711 s. Of that, 530 s is spent in its five layer-end control steps (`lec-p6n`, `lec-promo`, `lec-jx`, `lec-hyb`, `lec-frames`). -Each step runs the pinned `layer_end_controls_leaver.py`. That script calls PR635's `hpe_audit_and_transport.run` (sha256 `c9a05ff2…0aa3`) about 96 times: once on the honest word, then on each of 95 mutants, every one of which must be rejected at its pinned reason. +Each step runs the pinned `layer_end_controls_leaver.py`. That script calls PR635's +`hpe_audit_and_transport.run` about 96 times: once on the honest word, then on each of +95 mutants, every one of which must be rejected at its pinned reason. After +`research/hpe-audit-integer-production/`, the live PR635 path ships integer rows; the +pairwise Fraction-dict bytes used for differential checks live in this package's +`baseline.py` (sha256 `c9a05ff2…0aa3`). The cost is in exact arithmetic. On one audit, profiling shows: | Share | Where | |---|---| -| ~63% | `Fraction` operations in the row updates (endpoint replay in both orientations, plus the P and P⁻¹ state maps) | +| ~63% | `Fraction` operations in the pairwise row updates (endpoint replay in both orientations, plus the P and P⁻¹ state maps) | | ~22% | `copy.deepcopy` of gates | ## What changes diff --git a/research/hpe-audit-fast-seed93/test_package.py b/research/hpe-audit-fast-seed93/test_package.py index 16478c0d12..ceb541f7fb 100644 --- a/research/hpe-audit-fast-seed93/test_package.py +++ b/research/hpe-audit-fast-seed93/test_package.py @@ -18,8 +18,8 @@ def load(name, path): F = load('hpe_fast_test', HERE / 'hpe_audit_fast.py') -R = load('hpe_reference_test', HERE.parents[1] / 'research/complex-sw4-frame8/vendor/pr635/research/' - 'complex-571-cold14-st2/code/hpe_audit_and_transport.py') +# Pairwise-era Fraction-dict reference; production PR635 path ships integer rows. +R = load('hpe_reference_test', HERE / 'baseline.py') class RowArithmetic(unittest.TestCase): @@ -84,9 +84,7 @@ def test_wrong_fast_audit_is_caught_not_absorbed(self): tmp = Path(tempfile.mkdtemp()) word = tmp / 'w.json.gz' word.write_bytes(data) - os.environ.update(HPE_AUDIT_MODE='crosscheck', HPE_AUDIT_REFERENCE=str( - HERE.parents[1] / 'research/complex-sw4-frame8/vendor/pr635/research/complex-571-cold14-st2/code/' - 'hpe_audit_and_transport.py')) + os.environ.update(HPE_AUDIT_MODE='crosscheck', HPE_AUDIT_REFERENCE=str(HERE / 'baseline.py')) try: shim = load('hpe_shim_test', HERE / 'shim/hpe_audit_and_transport.py') finally: diff --git a/research/hpe-audit-integer-production/VERIFY.json b/research/hpe-audit-integer-production/VERIFY.json index cead5a52f8..1ff5d7f276 100644 --- a/research/hpe-audit-integer-production/VERIFY.json +++ b/research/hpe-audit-integer-production/VERIFY.json @@ -30,7 +30,7 @@ "{package}/verify.py" ], "timeout_seconds": 300, - "checks": "Same equivalence and pin discipline under -O (require() gates remain; audit asserts still fire in child imports unless -O clears them\u2014production package require() gates do not rely on -O)." + "checks": "Same equivalence and pin discipline under -O. Loaders use compile(..., optimize=0) so audit asserts stay enforced; scale-zero admission must raise AssertionError (not NO_ASSERT_FIRED)." } ] } diff --git a/research/hpe-audit-integer-production/verify.py b/research/hpe-audit-integer-production/verify.py index 0c1018fc34..f2ca15ac13 100755 --- a/research/hpe-audit-integer-production/verify.py +++ b/research/hpe-audit-integer-production/verify.py @@ -11,7 +11,6 @@ import copy import gzip import hashlib -import importlib.util import io import json import os @@ -22,6 +21,7 @@ import tarfile import tempfile import time +import types ROOT = Path(__file__).resolve().parents[2] PACKAGE = Path(__file__).resolve().parent @@ -64,10 +64,10 @@ def unique_object(pairs): def load_module(name: str, path: Path): - spec = importlib.util.spec_from_file_location(name, path) - module = importlib.util.module_from_spec(spec) - assert spec.loader is not None - spec.loader.exec_module(module) + """Load a checker with assertions kept even when this wrapper runs under -O.""" + module = types.ModuleType(name) + module.__file__ = str(path) + exec(compile(path.read_bytes(), str(path), "exec", optimize=0), module.__dict__) return module @@ -202,6 +202,22 @@ def assertion_list(text: str): ): require(msg in prod_src, f"missing assert message: {msg}") require(msg in base_src, f"baseline missing assert message: {msg}") + + # Admission must stay enforced when this wrapper is launched under -O: + # loaders use compile(..., optimize=0), so a known apply assert still fires. + prod = load_module("hpe_production_assert_gate", PRODUCTION) + rows = prod.rows_identity(2) if hasattr(prod, "rows_identity") else None + if rows is None: + # Integer-row production uses (den, map) pairs; seed a 2x2 identity. + rows = [(1, {0: 1}), (1, {1: 1})] + fired = False + try: + prod.apply(["scale", 0, 0, 1], rows) + except AssertionError: + fired = True + except Exception as exc: # noqa: BLE001 + require(False, f"scale-zero admission must raise AssertionError, got {type(exc).__name__}: {exc}") + require(fired, "NO_ASSERT_FIRED: scale-zero admission stripped under -O loader") return len(prod_asserts)