diff --git a/research/complex-571-plain8/LICENSE b/research/complex-571-plain8/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/complex-571-plain8/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/complex-571-plain8/MANIFEST.json b/research/complex-571-plain8/MANIFEST.json new file mode 100644 index 0000000000..9b528074ee --- /dev/null +++ b/research/complex-571-plain8/MANIFEST.json @@ -0,0 +1,15 @@ +{ + "code/assemble.py": "06aac1983c6b30e62ddec285eb73684630974c1aa139ae0d8929bc3b2abe6ab3", + "code/assembly_controls.py": "65ac20c51225143b3ec1966e1da8e2405dfd8f0f5e7765c04f07d55e86fba535", + "code/audit_allcold.py": "b0852603c26f62777934be923210818d2b813e76b92f9822f68111b54720deef", + "code/bind_providers_portable.py": "e386bed82c078fcf9e65e7d0dd815885bef468115fdac40159f1721e4247b598", + "code/emit_allcold.py": "9e7c53d9760391584ea3c80977fde4337f603a5732b2fe4f0dd36fd96c9c4627", + "code/invoice_allcold.py": "6a14639e2849d50978a7821dcda97746b5a66722bb3ca2d6fc8c611d2eaf4e49", + "code/phase_timing_controls.py": "edd53ac292132ba894ab17ca783909ffa5140742c45f796e8546383567fa924f", + "data/OWNERS.json.gz": "437670a2f8dcb239abe88f9b8df1aaac04567720da11df46288fe709c164e52a", + "data/PINS.json": "bf876d45f80a55006fdd46fcd38a2a9fc2d138d1430669140d8da92bb6515f13", + "data/PLAN.json": "2a53c448951981285c54fec3cf007921d76a6fbad30d5c2ff44141bd921df881", + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "NOTICE.md": "f5888555f8c5321e3d6c66a26c927329447a26e9f5be7552324944810b24673b", + "verify.py": "e73efb7b37e3cbecfeabef15284d40f8767e45c5121564ac5950df784b8fca5f" +} diff --git a/research/complex-571-plain8/NOTICE.md b/research/complex-571-plain8/NOTICE.md new file mode 100644 index 0000000000..38d89b58fc --- /dev/null +++ b/research/complex-571-plain8/NOTICE.md @@ -0,0 +1,16 @@ +# Attribution and scope + +This package adds no new local scalar operation. It combines two existing admitted providers under a new literal owner map: + +- #571 (`research/structural-gain`, commit `b7bdc5a8de18fcf418cfb9c7d83a2b1097a5e4a3`): the combined-prefix width-seven provider word `frontier-composition/combined-prefix-word/FULL-WORD.json.gz`, its retained local (`frontier-composition/combined-prefix-local`), its dispatch of 63 width-seven and 9 plain calls, and the global admission scripts in `frontier-composition/global-code/`. #571 was prepared with OpenAI Codex assistance under Apache-2.0. +- PR568 (`research/complex-multicold`, commit `71c99ac935a33bb7b59a1b4a7af8725a939b0b90`): the eight-cold multi-cut eight-pivot provider word, rebuilt by its unchanged scripts. It replaces #571's four-cold plain provider on #571's nine plain calls. + +Both packages are pinned external sources. `verify.py` checks their manifests and the exact file hashes it uses. It runs their unchanged scripts, rebuilds the width-seven local from #571's pinned word, and requires that rebuilt local to match #571's retained local byte for byte. + +The scripts in `code/` are copied from #571's `frontier-composition/global-code/` with these changes: +- `bind_providers_portable.py` and `audit_allcold.py`: the plain provider (`fourcold_eight`) inventory and profile now pin PR568's eight-cold word (`{4:8,5:48,8:164,9:284}`, profile `{1:2332,2:436,3:448,4:192,5:56,6:56,8:8}`). +- `assemble.py`: pins this witness's provider values, owner geometry, idle remainders, profile, endpoints and kappa. + +The literal owner map was nominated by a HiGHS window MILP at #571's fixed dispatch, adapted from PR569's `global/nominate_width7.py`. Lazy cross-time Hall cuts make every window literally decomposable. The admission scripts check the map independently. + +The provider swap, literal owner assignment and this package were prepared by Claude Code (Anthropic) research agents. Apache-2.0 applies; LICENSE is included. All notices, licenses, source pins and AI disclosures of #571, PR568 and their ancestry are retained in those packages and are not replaced by this notice. All inherited conditional assumptions remain conditional. diff --git a/research/complex-571-plain8/code/assemble.py b/research/complex-571-plain8/code/assemble.py new file mode 100644 index 0000000000..f70e05c063 --- /dev/null +++ b/research/complex-571-plain8/code/assemble.py @@ -0,0 +1,207 @@ +"""Hardened 63 width-seven (#571 prefix word) and 9 plain eight-cold (#568 E8) provider assembly with the native exact-complex moment. + +Prepared with OpenAI Codex assistance. The rational engines and outer +constraints are retained from PR547/PR548 and their preserved ancestry. +The bit operator is the cited unchanged PR543 supplier. The complex owner +and invoice inputs must be freshly emitted by the packaged physical replay. +All conservative admission guards and conservative moment/outer witnesses run +before the PR559 native-complex correction. The bit surcharge is retained. +""" +from pathlib import Path +from fractions import Fraction as Q +from decimal import Decimal, localcontext +import argparse,json,hashlib,importlib.util,os,sys +from collections import Counter +assert __debug__, 'Assertions required' +P=Path(sys.argv[1] if __name__=='__main__' else os.environ['GAIN_PR564_SOURCE']).resolve() +read=lambda p:json.loads(p.read_text()) +sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() +hash_ok=lambda x:isinstance(x,str) and len(x)==64 and all(t in '0123456789abcdef'for t in x) +digest=lambda x:hashlib.sha256(json.dumps(x,separators=(',',':')).encode()).hexdigest() +def load(n): + s=importlib.util.spec_from_file_location(n,P/'engines'/(n+'.py'));m=importlib.util.module_from_spec(s);s.loader.exec_module(m);return m +M,B,A=[load(n)for n in ('moment','base_two_moment','outer')] +def dec(x): + with localcontext()as ctx:ctx.prec=70;return str(Decimal(x.numerator)/Decimal(x.denominator)) +PROVIDERS={'fourcold_eight': {'semantic_phase_sha256': 'ac32ac4b9cd18a383df1b28c9e2a06389e57d75d8e1e1454ab0adeeb97ad7cec', 'promoted': 0, 'width_digest': 'c981156345ace92e314d8a14d5991f5a0fe60275baef0894311b568bc81a166d', 'program_hashes': {'backward': '9a28d43dfc68e4f9af4e3b0b261000971fe4e6e16260ee09c9e92f4ad048370f', 'forward': 'de1b6c0c8cd6bcebaab701bff3d24363e27b5c3e09ee48f5842dba666bcabcec'}, 'artifacts': {'CANONICAL-WORD.json.gz': '94dba75199d70b744be5604386b8eca6767f0b0e1aeee06b2bd0e4e1db858940', 'CLIFFORD-RECIPES.json': 'b32e904cac5f4ac2b9a80a50dfd112ced1e44a2eab1ee24149c501f0d6979748', 'FULL-WORD.json.gz': '4d4a59db7f74d7505447fbb2aa87735771cca1d04a0afafa455d21bd8dbf1f77', 'INDEPENDENT-LOCAL-REPLAY.json': '05a6ff6313baf97f9a2a4be1abcf502919912643b2f9be40a8ad566059e84da2', 'LOCAL-CHECKS.json': '57b8a93866ebfb23b81225264229742a980ab60b7dd6ff1df014ba43c8d0ead8', 'LOCAL-PROGRAMS.json.gz': 'c4581db41fd2a07aa82655a07c0c4bb041b7f5ae96ef11d4cd33294dc66022f7', 'RESIDUAL-ADAPTERS.json': 'baafef737acc16dafbe1150896feb16744f3d669fa123bb2bff19ecc4e71b275', 'SCALAR-FRAME-AUDIT.json': 'a3a3217967e0a7d05d6241f0ba0ac677c8c6f95347170efd152c164892e89297', 'WRAPPER-CHECKS.json': '9a09146e686c4f535b04fdef3753fe01dad8f5e8881a69408a91394acb5b48f5'}, 'expected_profile': {'1': 2332, '2': 436, '3': 448, '4': 192, '5': 56, '6': 56, '8': 8}, 'expected_local': {'backward': {'events': 21483, 'macros': 16270, 'real_component_primitives': 161120, 'prefix_l1': '1044730572477', 'coefficient_work_primitive_count': 79788}, 'forward': {'events': 21483, 'macros': 16270, 'real_component_primitives': 161072, 'prefix_l1': '88876257700', 'coefficient_work_primitive_count': 79756}}, 'entering': 220, 'entrance': 396, 'inventory': {'4': 8, '5': 48, '8': 164, '9': 284}, 'wrappers': 220}, 'width7_eight': {'semantic_phase_sha256': '2dc31326f16d2766252083531e6c058cfecca7d59db0adcc596165c2e567f60f', 'promoted': 32, 'width_digest': '0ede35d2ce74b951eb5e5ccc4763c1d8c6b1b2b331c25a801bb71149fb0dd249', 'program_hashes': {'forward': '89d13561cfa5e2cd20155f0e3fcdda8914e9c03813b6416addfe6d6e400a05a3', 'backward': 'a0a2b3ff1861b90fb5c702e9106e5e53b644981b89ff7f2dfb0d137d7baad917'}, 'artifacts': {'CANONICAL-WORD.json.gz': '81ef773a4b22b91ac74880c5b8606d93794c0b98b2e7e7291a01580cba79ceac', 'LOCAL-PROGRAMS.json.gz': '4fd7b2ad67b037c17fcc68d12663d0d70c45e66d802e2eb558daa859802f499c', 'LOCAL-CHECKS.json': '66a2f5d82e13179626dec71bb5a4b49bcae32f91e4812fa4056fe1f3c3ecadcb', 'INDEPENDENT-LOCAL-REPLAY.json': '895080ffbe54cf6a7ea148ee902308205ba9fa72248a8f7e4b7b375bf9e38d16', 'CLIFFORD-RECIPES.json': '3323144380012a59c59e56348dd56d17da0f93e7783415efdaabe6fd5d3edadc', 'RESIDUAL-ADAPTERS.json': 'b55f994f7cad5b0be48084362f1461f7587689eb35ad4bb253de138792b1c526'}, 'expected_profile': {'1': 2352, '2': 580, '3': 336, '4': 192, '5': 56, '6': 56, '8': 8}, 'expected_local': {'backward': {'events': 21543, 'macros': 16282, 'real_component_primitives': 161336, 'prefix_l1': '1044730572477', 'coefficient_work_primitive_count': 79896}, 'forward': {'events': 21543, 'macros': 16282, 'real_component_primitives': 161288, 'prefix_l1': '88876257700', 'coefficient_work_primitive_count': 79864}}, 'entering': 216, 'entrance': 424, 'inventory': {'4': 8, '5': 48, '7': 32, '8': 128, '9': 288}, 'wrappers': 216}} +DISPATCH={(0, 0): 'width7_eight', (0, 1): 'width7_eight', (1, 0): 'width7_eight', (0, 2): 'width7_eight', (1, 1): 'width7_eight', (2, 0): 'width7_eight', (0, 3): 'width7_eight', (1, 2): 'width7_eight', (2, 1): 'fourcold_eight', (3, 0): 'width7_eight', (0, 4): 'width7_eight', (1, 3): 'width7_eight', (2, 2): 'width7_eight', (3, 1): 'width7_eight', (4, 0): 'width7_eight', (0, 5): 'width7_eight', (1, 4): 'width7_eight', (2, 3): 'width7_eight', (3, 2): 'width7_eight', (4, 1): 'width7_eight', (5, 0): 'width7_eight', (0, 6): 'fourcold_eight', (1, 5): 'width7_eight', (2, 4): 'width7_eight', (3, 3): 'width7_eight', (4, 2): 'width7_eight', (5, 1): 'width7_eight', (0, 7): 'width7_eight', (6, 0): 'width7_eight', (1, 6): 'width7_eight', (2, 5): 'width7_eight', (3, 4): 'width7_eight', (4, 3): 'fourcold_eight', (5, 2): 'fourcold_eight', (6, 1): 'width7_eight', (1, 7): 'width7_eight', (7, 0): 'fourcold_eight', (2, 6): 'width7_eight', (3, 5): 'width7_eight', (4, 4): 'fourcold_eight', (5, 3): 'width7_eight', (6, 2): 'width7_eight', (7, 1): 'width7_eight', (2, 7): 'width7_eight', (8, 0): 'width7_eight', (3, 6): 'width7_eight', (4, 5): 'width7_eight', (5, 4): 'width7_eight', (6, 3): 'width7_eight', (7, 2): 'width7_eight', (8, 1): 'fourcold_eight', (3, 7): 'width7_eight', (4, 6): 'width7_eight', (5, 5): 'width7_eight', (6, 4): 'width7_eight', (7, 3): 'width7_eight', (8, 2): 'fourcold_eight', (4, 7): 'width7_eight', (5, 6): 'width7_eight', (6, 5): 'width7_eight', (7, 4): 'width7_eight', (8, 3): 'width7_eight', (5, 7): 'width7_eight', (6, 6): 'width7_eight', (7, 5): 'width7_eight', (8, 4): 'width7_eight', (6, 7): 'width7_eight', (7, 6): 'width7_eight', (8, 5): 'width7_eight', (7, 7): 'width7_eight', (8, 6): 'fourcold_eight', (8, 7): 'width7_eight'} +CALL_ORDER=[(0, 0), (0, 1), (1, 0), (0, 2), (1, 1), (2, 0), (0, 3), (1, 2), (2, 1), (3, 0), (0, 4), (1, 3), (2, 2), (3, 1), (4, 0), (0, 5), (1, 4), (2, 3), (3, 2), (4, 1), (5, 0), (0, 6), (1, 5), (2, 4), (3, 3), (4, 2), (5, 1), (0, 7), (6, 0), (1, 6), (2, 5), (3, 4), (4, 3), (5, 2), (6, 1), (1, 7), (7, 0), (2, 6), (3, 5), (4, 4), (5, 3), (6, 2), (7, 1), (2, 7), (8, 0), (3, 6), (4, 5), (5, 4), (6, 3), (7, 2), (8, 1), (3, 7), (4, 6), (5, 5), (6, 4), (7, 3), (8, 2), (4, 7), (5, 6), (6, 5), (7, 4), (8, 3), (5, 7), (6, 6), (7, 5), (8, 4), (6, 7), (7, 6), (8, 5), (7, 7), (8, 6), (8, 7)] +def assemble(owner,invoice,owner_sha,invoice_sha): + # These are admission receipts, not optional collections of successful rows. + # Require both orientations and every finite check before pricing anything. + assert owner['status']=='PASS_INDEPENDENT_ASYNC_OWNERS_AND_PROFILE' + assert invoice['status']=='PASS_INDEPENDENT_MIXED_ASYNC_SCALAR_PREFIX_AND_FINITE_INVOICE' + assert all(hash_ok(x)for x in (owner_sha,invoice_sha,owner['template_sha256'],owner['controller_audit_sha256'],invoice['parent_template_sha256'])) + checks={'local_primitive_bound','logical','router','literal','mass','precision','tape','row','halving'} + assert set(invoice['strict_checks'])==checks + assert all(invoice['strict_checks'][name] is True for name in checks) + assert set(invoice['providers'])==set(PROVIDERS) + assert invoice['provider_counts']=={'width7_eight': 63, 'fourcold_eight': 9} + assert owner['all_live_owners_per_call_distinct'] is True + assert owner['owners_per_call']==728 and owner['actual_helper_owner_charts']==36288 + assert owner['rank_mass']==520704 + assert owner['actual_73column_sigmas']==6493 and owner['cross_replica_helper_roles']==28088 + assert owner['explicit_idle_remainder_children']==3054 + assert invoice['complete_invocation_sweeps']==invoice['bridge_sweeps']==72 + assert invoice['live']==owner['live'] and invoice['physical']==owner['physical'] + assert invoice['helpers']==504 and invoice['centres']==8 + assert invoice['physical_stock_identity']==dict(data_and_owner_families=7168,local_helpers=504,private_centres=8,coefficient_work=2) + assert sum(invoice['physical_stock_identity'].values())==invoice['physical'] + assert invoice['controller_audit_sha256']==owner['controller_audit_sha256'] + for pid,p in invoice['providers'].items(): + promoted=PROVIDERS[pid]['promoted'] + assert set(p['local'])=={'forward','backward'} + assert p['helpers']==504 and p['centres']==8 and p['n']==728 and p['v']==112 and p['h']==9 + assert p['entering_helpers']==PROVIDERS[pid]['entering'] and p['entrance_rank']==PROVIDERS[pid]['entrance'] + assert p['width_inventory']==PROVIDERS[pid]['inventory'] + assert all(type(w) is int and 00 + assert prior['added_complete_new_pervertex']==pervertex + assert prior['policy']=='Retain old allowance and add entire fresh mixed recount.' + used=max(used,prior['previous_pervertex_allowance']+pervertex) + assert invoice['conservative_pervertex_used']==used + finite=invoice['finite'] + assert 02*48*48) + assert actual_checks==invoice['strict_checks'] and all(actual_checks.values()) + bit_path=P/'inputs/PR543-EXPECTED.json';bit_data=bit_path.read_bytes() + assert hashlib.sha1(b'blob '+str(len(bit_data)).encode()+b'\0'+bit_data).hexdigest()=='b61d859826246e0c3dabbe096e57ad7015eadfd5' + bit=json.loads(bit_data)['nine'] + c=Q(bit['bit_lower']);conservative_b=Q('0.001603300880687220210664');b=Q('0.0016033008834787854416') + expected={1: 169164, 2: 40472, 3: 26398, 4: 13824, 5: 4032, 6: 4032, 7: 38, 8: 576, 48: 1810} + H={int(r):n for r,n in owner['paid_profile'].items()};assert H==expected + assert owner['template_sha256']==invoice['template_sha256'] and owner_sha==invoice['owner_audit_sha256'] + assert owner['live']==7168 and owner['physical']==7682 and owner['deficit']==2560 + assert owner['hosted_residuals']==36288 and owner['banked_residuals']==0 + def check_moment(side,h,m,W,lower,deficit,bad): + assert m*W-sum(r*n for r,n in h.items())==deficit and m*m>2*max(h)**2 + rows=[] + for z,accept in [(lower,True),(lower+Q(1,10**24),False)]: + l,u=M.moment(h,m,W,z,bad);ll,uu=B.moment(m,W,list(h.items()),z) + if bad: + fl,fu=B.moment(m,W,[(1,32*m*m*sum(h.values()))],z);ll+=fl/10**16;uu+=fu/10**16 + assert (u<1 and uu<1)if accept else(l>1 and ll>1) + rows.append(dict(side=side,surcharge=bad,endpoint=str(z),accept=accept,mercator=[str(l-1),str(u-1)],base_two=[str(ll-1),str(uu-1)])) + return rows + bitH={int(r):n for r,n in bit['profile'].items()} + bit_moments=check_moment('bit',bitH,64,bit['bit']['live'],c,9984,True) + conservative_moments=check_moment('conservative_complex',H,73,owner['live'],conservative_b,2560,True) + assert bit['bit']['two_level_coefficient_bits']0 + ceil=lambda x:-(-x.numerator//x.denominator);cut=max(ceil(36/gap**2),ceil(2*(4+512)/gap));assert cut*gap**2>=36 and cut*gap>=2*(4+512) + cuts.append(dict(exponent=str(a),gap=str(gap),cutoff_log2=str(cut)));chain.append(a) + q=chain[-1]*(1-2*eta);margin=(1-eta)*q/(1+q);ticks=margin*10**18;k=Q((ticks.numerator-1)//ticks.denominator,10**18) + bridge={'semantic':{'C0':{'base':2,'exponent':210000},'strict_literal_gap':1},'rows':{'degree_gap':Q(10**6)-Q(51*20161,25)}} + outer=A.assembly(chain[-1],bb,bridge,k,eta=eta,beta=beta);assert len(outer['strict_constraints'])==47 and all(v>0 for v in outer['strict_constraints'].values()) + controls=[] + for name,kk,ee,be in [('next_grid',k+Q(1,10**18),eta,beta),('zero_eta',k,Q(0),beta),('zero_beta',k,eta,Q(0)),('unit_beta',k,eta,Q(1))]: + try:A.assembly(chain[-1],bb,bridge,kk,eta=ee,beta=be) + except AssertionError:controls.append(name) + else:raise AssertionError(name) + return k,cuts,outer,controls + conservative_k,conservative_cuts,conservative_outer,conservative_controls=outer_witness(conservative_b) + assert conservative_k==Q('0.001600734421779035') + # Only after every conservative supplier/admission/outer check succeeds is + # the reviewed native exact-complex recurrence selected. Bit charge stays. + native_moments=check_moment('complex',H,73,owner['live'],b,2560,False) + k,cuts,outer,controls=outer_witness(b) + assert k==Q('0.00160073442456167') + assert M.moment(H,73,owner['live'],b,True)[0]>1 + assert M.moment(bitH,64,bit['bit']['live'],c+Q(1,10**24),False)[1]<1 + model_controls=['native_complex_endpoint_rejected_with_old_surcharge','omitting_bit_surcharge_would_fail_next_endpoint_rejection'] + moments=bit_moments+native_moments + input_hashes={'owner_audit':owner_sha,'fresh_invoice':invoice_sha,'inputs/PR543-EXPECTED.json':sha(bit_path)} + input_hashes.update({'engines/'+name+'.py':sha(P/'engines'/(name+'.py'))for name in ('moment','base_two_moment','outer')}) + return dict(status='PASS_FRESH_MIXED_048_ALLCOLD_NATIVE_EXACT_ASSEMBLY',kappa=str(k),kappa_decimal=dec(k),complex_lower=str(b),complex_decimal=dec(b),bit_lower=str(c),bit_decimal=dec(c),binding='complex',gain_over_pinned569_percent=dec(100*(k/Q('0.001600067494703216')-1)),complex_profile=H,provider_counts=invoice['provider_counts'],surcharge_model={'complex':False,'bit':True},conservative_complex_lower=str(conservative_b),conservative_complex_decimal=dec(conservative_b),conservative_kappa=str(conservative_k),conservative_kappa_decimal=dec(conservative_k),conservative_moments=conservative_moments,conservative_bootstrap=conservative_cuts,conservative_outer={n:str(v)for n,v in conservative_outer['strict_constraints'].items()},conservative_controls=conservative_controls,model_controls=model_controls,native_correction_gain=dec(k-conservative_k),template_sha256=owner['template_sha256'],input_sha256=input_hashes,bit_supplier=dict(pr=543,repository='eumemic/integer-mult-bounds',commit='2065fe4f72a914d907f1046603f5a36f17018535',path='research/e8-bit-r420/EXPECTED.json',git_blob_sha1='b61d859826246e0c3dabbe096e57ad7015eadfd5',replay_scope='Cited unchanged supplier; this assembly reprices its full profile and does not rebuild its bit circuit.'),moments=moments,bootstrap=cuts,outer={n:str(v)for n,v in outer['strict_constraints'].items()},controls=controls,scope='Conditional native exact-complex witness after complete conservative admission, moment and outer checks; PR559 exact-cover recurrence correction only, bit bad-residue surcharge and H1-H5 retained. Two fixed plain/composed-prefix-multicold per-invocation providers composed with cited unchanged PR543 bit supplier. All-size compiler, common-label/mutable-source realization, whole-call hosting, precision/tape and analytic transfer remain assumptions. No unconditional theorem or full Lean certification.') +if __name__=='__main__': + import sys + package,C,out=map(Path,sys.argv[1:4]);assert package.resolve()==P and not out.exists() + owner_path=C/'audit/OWNERS-AND-PROFILE.json';invoice_path=C/'audit/PREFIX-AND-INVOICE.json' + owner,invoice=read(owner_path),read(invoice_path) + assert owner['template_sha256']==read(C/'hosted/HOSTED.json')['template_sha256'] + r=assemble(owner,invoice,sha(owner_path),sha(invoice_path));out.write_text(json.dumps(r,indent=2)+'\n');print(r['status'],r['kappa_decimal']) diff --git a/research/complex-571-plain8/code/assembly_controls.py b/research/complex-571-plain8/code/assembly_controls.py new file mode 100644 index 0000000000..35068a5128 --- /dev/null +++ b/research/complex-571-plain8/code/assembly_controls.py @@ -0,0 +1,265 @@ +"""Independent admission controls for the two-provider width-seven native-complex assembly. + +Prepared with OpenAI Codex assistance; Apache-2.0. Mutation receipts are +rebound to their new owner digest, so unrelated stale hashes cannot conceal +an incomplete width, provider, orientation, paid-profile or finite check. +The fresh physical replay remains a separate prerequisite. +""" +import argparse +import copy +import hashlib +import json +import os +from pathlib import Path + +assert __debug__, 'Assertions required' +P = Path(__file__).resolve().parent +sha = lambda p: hashlib.sha256(p.read_bytes()).hexdigest() +digest = lambda x: hashlib.sha256(json.dumps(x, sort_keys=True, separators=(',', ':')).encode()).hexdigest() + + +def verify(owner_path, invoice_path, source_package): + os.environ['GAIN_PR564_SOURCE'] = str(source_package.resolve()) + from assemble import assemble + owner = json.loads(owner_path.read_text()) + invoice = json.loads(invoice_path.read_text()) + baseline = assemble(owner, invoice, sha(owner_path), sha(invoice_path)) + + def empty_maps(o, i): + i['strict_checks'] = {} + i['providers'] = {} + + def missing_backward(o, i): + del i['providers']['fourcold_eight']['local']['backward'] + + def understated_stock(o, i): + o['physical'] -= 1 + i['physical'] -= 1 + i['physical_stock_identity']['coefficient_work'] -= 1 + + def changed_profile(o, i): + o['paid_profile']['1'] += 2 + o['paid_profile']['2'] -= 1 + + def changed_widths(o, i): + widths = i['providers']['width7_eight']['widths'] + a, b = widths.index(4), widths.index(9) + widths[a] += 1 + widths[b] -= 1 + + def permuted_widths(o, i): + widths = i['providers']['width7_eight']['widths'] + a, b = widths.index(4), widths.index(9) + widths[a], widths[b] = widths[b], widths[a] + + def compensating_profiles(o, i): + # The two dishonest profiles cancel exactly in the 63+9 weighted aggregate. + p, q = i['providers']['width7_eight'], i['providers']['fourcold_eight'] + p['paid_profile']['1'] += 1 + q['paid_profile']['1'] -= 7 + p['children'] += 1 + q['children'] -= 7 + + def wrong_orientation(o, i): + c = next(c for c in i['selected_calls'] if c['stage'] == 0) + c['orientation'] = 'backward' + p = i['providers'][c['provider_id']] + z = p['local']['backward'] + c['program_sha256'] = p['program_hashes']['backward'] + for name in ('events', 'macros', 'real_component_primitives', + 'coefficient_work_primitive_count', 'pre_wrappers', 'post_wrappers'): + c[name] = z[name] + i['selected_real_component_primitives'] = sum(c['real_component_primitives'] for c in i['selected_calls']) + i['selected_coefficient_work_primitive_count'] = sum(c['coefficient_work_primitive_count'] for c in i['selected_calls']) + + def forged_program_hash(o, i): + i['providers']['fourcold_eight']['program_hashes']['forward'] = '0' * 64 + for c in i['selected_calls']: + if c['provider_id'] == 'fourcold_eight': + c['program_sha256'] = '0' * 64 + + def wrong_selected_call(o, i): + c = next(c for c in i['selected_calls'] if c['provider_id'] == 'fourcold_eight') + d = next(d for d in i['selected_calls'] if d['stage'] == c['stage'] and d['provider_id'] != c['provider_id']) + c['replica'], d['replica'] = d['replica'], c['replica'] + + def understated_prefix(o, i): + for p in i['providers'].values(): + for z in p['local'].values(): + z['prefix_bits'], z['prefix_l1'] = 1, '1' + i['global_prefix_bits'] = 1 + 37 + 72 + 72 + 4 + + def stale_plain_program(o, i): + p = i['providers']['fourcold_eight'] + p['program_hashes'] = copy.deepcopy(i['providers']['width7_eight']['program_hashes']) + for c in i['selected_calls']: + if c['provider_id'] == 'fourcold_eight': + c['program_sha256'] = p['program_hashes'][c['orientation']] + + def moved_providers(o, i): + a = next(c for c in i['selected_calls'] if c['provider_id'] == 'fourcold_eight') + b = next(c for c in i['selected_calls'] if c['provider_id'] == 'width7_eight' and c['stage'] == a['stage']) + a['provider_id'], b['provider_id'] = b['provider_id'], a['provider_id'] + for c in (a, b): + p = i['providers'][c['provider_id']] + c['program_sha256'] = p['program_hashes'][c['orientation']] + c['entering_helpers'], c['entrance_rank'] = p['entering_helpers'], p['entrance_rank'] + for name in ('events','macros','real_component_primitives','coefficient_work_primitive_count','pre_wrappers','post_wrappers'): + c[name] = p['local'][c['orientation']][name] + + def reordered_calls(o, i): + i['selected_calls'][0], i['selected_calls'][1] = i['selected_calls'][1], i['selected_calls'][0] + + def permuted_plain_widths(o, i): + widths = i['providers']['fourcold_eight']['widths'] + a, b = widths.index(4), widths.index(5) + widths[a], widths[b] = widths[b], widths[a] + + def stale_plain_profile(o, i): + p = i['providers']['fourcold_eight'] + p['paid_profile'] = copy.deepcopy(i['providers']['width7_eight']['paid_profile']) + p['children'] = sum(p['paid_profile'].values()) + + controls = [ + ('empty_certification_maps', empty_maps), + ('missing_provider_backward_orientation', missing_backward), + ('failed_invoice_status', lambda o, i: i.__setitem__('status', 'FAIL')), + ('nonboolean_precision_check', lambda o, i: i['strict_checks'].__setitem__('precision', 'true')), + ('wrong_owner_role_count', lambda o, i: o.__setitem__('actual_helper_owner_charts', 36287)), + ('understated_physical_stock', understated_stock), + ('changed_profile_same_rank_mass', changed_profile), + ('insufficient_finite_C0', lambda o, i: i['finite'].__setitem__('required_C0_bits', 210001)), + ('unpaid_scalar_primitive', lambda o, i: i['providers']['fourcold_eight']['local']['forward'].__setitem__('real_component_primitives', 161300)), + ('wrong_local_artifact_binding', lambda o, i: i['providers']['fourcold_eight']['artifacts'].__setitem__('LOCAL-PROGRAMS.json.gz', '0' * 64)), + ('false_dirty_restoration', lambda o, i: i['providers']['fourcold_eight']['local']['backward'].__setitem__('all_dirty_helper_columns_restored', False)), + ('missing_finite_check', lambda o, i: i['strict_checks'].pop('halving')), + ('width_inventory_wrong_same_total', changed_widths), + ('width_order_wrong_same_inventory', permuted_widths), + ('compensating_false_provider_profiles', compensating_profiles), + ('wrong_reflected_orientation_selfconsistent_totals', wrong_orientation), + ('forged_provider_and_call_program_hash', forged_program_hash), + ('plain_provider_at_wrong_call', wrong_selected_call), + ('wrong_declared_provider_count', lambda o, i: i['provider_counts'].__setitem__('fourcold_eight', 3)), + ('missing_selected_call', lambda o, i: i['selected_calls'].pop()), + ('wrong_selected_primitive_sum', lambda o, i: i.__setitem__('selected_real_component_primitives', i['selected_real_component_primitives'] - 1)), + ('wrong_selected_coefficient_work_sum', lambda o, i: i.__setitem__('selected_coefficient_work_primitive_count', i['selected_coefficient_work_primitive_count'] - 1)), + ('unpaid_wrapper_factors', lambda o, i: i.__setitem__('wrapper_elementary_factors_charged', i['wrapper_elementary_factors_charged'] - 144)), + ('wrong_local_compiler', lambda o, i: i['providers']['fourcold_eight'].__setitem__('compiler', 1)), + ('wrong_global_compiler', lambda o, i: i.__setitem__('compiler', 1)), + ('wrong_local_adapter_charge', lambda o, i: i['providers']['fourcold_eight'].__setitem__('local_adapters', 1)), + ('wrong_global_adapter_maximum', lambda o, i: i.__setitem__('local_adapters', 1)), + ('wrong_local_primitive_bound', lambda o, i: i['providers']['fourcold_eight'].__setitem__('local_primitive_bound', 1)), + ('understated_exact_prefix_and_global_sum', understated_prefix), + ('wrong_global_prefix_sum', lambda o, i: i.__setitem__('global_prefix_bits', 224)), + ('wrong_row_prefix_reserve', lambda o, i: i.__setitem__('row_prefix_extra', 0)), + ('wrong_parent_geometry_charge', lambda o, i: i.__setitem__('unhosted_pervertex', 1)), + ('wrong_rebased_geometry_charge', lambda o, i: i.__setitem__('hosted_rebased_pervertex', 1)), + ('wrong_complete_pervertex_envelope', lambda o, i: i.__setitem__('conservative_pervertex_used', 1)), + ('wrong_prior_added_complete_invoice', lambda o, i: i['retained_prior_overcharge'].__setitem__('added_complete_new_pervertex', 1)), + ('wrong_finite_router_bits', lambda o, i: i['finite'].__setitem__('router_bits', 1)), + ('wrong_finite_literal_bits', lambda o, i: i['finite'].__setitem__('literal_bits', 1)), + ('wrong_finite_physical_stock_bits', lambda o, i: i['finite'].__setitem__('physical_stock_bits', 1)), + ('wrong_finite_row_coefficient', lambda o, i: i['finite'].__setitem__('physical_row_coefficient', 1)), + ] + controls.extend([ + ('missing_plain_provider', lambda o, i: i['providers'].pop('fourcold_eight')), + ('missing_width7_provider_backward', lambda o, i: i['providers']['width7_eight']['local'].pop('backward')), + ('stale_plain_program_and_consistent_selected_hashes', stale_plain_program), + ('stale_plain_profile_with_consistent_child_total', stale_plain_profile), + ('reordered_complete_calls', reordered_calls), + ('relocated_plain_and_width7_providers_same_counts', moved_providers), + ('plain_provider_widths_permuted_same_inventory', permuted_plain_widths), + ('understated_explicit_idle_remainders', lambda o, i: o.__setitem__('explicit_idle_remainder_children', o['explicit_idle_remainder_children']-1)), + ('understated_actual_chart_types', lambda o, i: o.__setitem__('actual_73column_sigmas', o['actual_73column_sigmas']-1)), + ('wrong_cross_replica_role_count', lambda o, i: o.__setitem__('cross_replica_helper_roles', o['cross_replica_helper_roles']-1)), + ]) + def cold_width_permutation(o, i): + w = i['providers']['fourcold_eight']['widths'] + j = w.index(9) + w[270], w[j] = w[j], w[270] + def no_cold_wrappers(o, i): + for p in i['providers'].values(): + p['entering_helpers'] = 212 + for z in p['local'].values():z['pre_wrappers'] = z['post_wrappers'] = 212 + for c in i['selected_calls']: + c['entering_helpers'] = c['pre_wrappers'] = c['post_wrappers'] = 212 + i['wrapper_elementary_factors_charged'] = 72*424*144 + def synchronized_forged_recipe(o, i): + pid = 'fourcold_eight';name = 'CLIFFORD-RECIPES.json' + i['providers'][pid]['artifacts'][name] = '0'*64 + o['source_artifacts']['providers/'+pid+'/'+name] = '0'*64 + def synchronized_forged_phase_semantics(o, i): + pid = 'fourcold_eight' + i['providers'][pid]['semantic_artifact_sha256']['CLIFFORD-REVIEW.json'] = '0'*64 + o['provider_phase_semantic_sha256'][pid] = i['provider_phase_semantic_sha256'][pid] = '0'*64 + controls.extend([ + ('synchronized_forged_phase_review_semantics', synchronized_forged_phase_semantics), + ('cold_helper_width_permuted_same_inventory', cold_width_permutation), + ('old_no_cold_wrapper_counts_selfconsistent', no_cold_wrappers), + ('synchronized_forged_source_recipe_hash', synchronized_forged_recipe), + ]) + for helper in (282, 294, 306): + def move_extra_width(o, i, helper=helper): + widths = i['providers']['width7_eight']['widths'] + other = widths.index(9) + widths[helper], widths[other] = widths[other], widths[helper] + controls.append(('extra_kernel_width_swap_' + str(helper), move_extra_width)) + for helper in [262, 263, 264, 265, 274, 275, 276, 277, 310, 311, 312, 313, 314, 315, 316, 317, 322, 323, 324, 325, 326, 327, 328, 329, 338, 339, 340, 341, 350, 351, 352, 353]: + def swap_width7(o, i, helper=helper): + widths = i['providers']['width7_eight']['widths'] + other = widths.index(8) + widths[helper], widths[other] = widths[other], widths[helper] + controls.append(('width7_entrance_width_swap_' + str(helper), swap_width7)) + for helper in (271, 283, 295, 307): + def move_new_cold(o, i, helper=helper): + widths = i['providers']['width7_eight']['widths'] + other = widths.index(9) + widths[helper], widths[other] = widths[other], widths[helper] + controls.append(('new_target_kernel_width_swap_' + str(helper), move_new_cold)) + rejected = [] + for name, mutate in controls: + o, i = copy.deepcopy(owner), copy.deepcopy(invoice) + mutate(o, i) + oh = digest(o) + i['owner_audit_sha256'] = oh + try: + assemble(o, i, oh, digest(i)) + except (AssertionError, KeyError): + rejected.append(name) + else: + raise AssertionError('Invalid admission receipt accepted: ' + name) + try: + assemble(owner, invoice, '0' * 64, sha(invoice_path)) + except AssertionError: + rejected.append('wrong_owner_receipt_hash') + else: + raise AssertionError('Wrong owner digest accepted') + assert len(rejected) == 93 + assert baseline['controls'] == ['next_grid', 'zero_eta', 'zero_beta', 'unit_beta'] + assert baseline['conservative_controls'] == baseline['controls'] + assert baseline['surcharge_model'] == {'complex': False, 'bit': True} + assert len(baseline['model_controls']) == 2 + return dict( + status='PASS_EXACT_MIXED_048_ALLCOLD_NATIVE_ASSEMBLY_ADMISSION_NEGATIVE_CONTROLS', + valid_receipt_kappa=baseline['kappa'], + input_sha256=baseline['input_sha256'], + assembler_sha256=sha(P / 'assemble.py'), + rejected_controls=rejected, + exact_outer_controls=baseline['controls'], + conservative_outer_controls=baseline['conservative_controls'], + recurrence_model_controls=baseline['model_controls'], + scope='Complete receipt schema; ordered widths and both reflected providers; exact program, work and paid-profile binding; independently recounted compiler, conservative envelope and finite inequalities. Does not replace fresh physical replay.', + ) + + +if __name__ == '__main__': + ap = argparse.ArgumentParser(description=__doc__) + ap.add_argument('--source-package', type=Path, required=True) + ap.add_argument('--owner', type=Path, required=True) + ap.add_argument('--invoice', type=Path, required=True) + ap.add_argument('--out', type=Path, required=True) + a = ap.parse_args() + assert not a.out.exists() + result = verify(a.owner, a.invoice, a.source_package) + a.out.write_text(json.dumps(result, indent=2) + '\n') + print(result['status'], len(result['rejected_controls'])) diff --git a/research/complex-571-plain8/code/audit_allcold.py b/research/complex-571-plain8/code/audit_allcold.py new file mode 100644 index 0000000000..7a059dfa7f --- /dev/null +++ b/research/complex-571-plain8/code/audit_allcold.py @@ -0,0 +1,220 @@ +"""OpenAI Codex independent serialized ASYNCHRONOUS controller/spectator audit. +Imports no emitter, optimizer, expander, edge-coloring, or source hosting code. +CLI: BASE HOSTED REPORT [--mutation-controls] +Each provider is independently read from BASE/providers, never from a baseline width histogram. +OpenAI Codex two-provider width-seven extension; retains all inherited independent controller checks. +The exact 63 width-seven and 9 plain calls are frozen below. +""" +import sys,json,gzip,hashlib,copy +assert __debug__, 'Assertions must remain enabled' +from pathlib import Path +from collections import Counter,defaultdict +BASE,OUT,REPORT=map(lambda p:Path(p).resolve(),sys.argv[1:4]);read=lambda p:json.loads(gzip.decompress(p.read_bytes())if p.suffix=='.gz'else p.read_bytes()) +parent=read(BASE/'split-centres/GLOBAL-TEMPLATE.json.gz') +ph=read(BASE/'work/complex-nine-native/DATA-PHASES.json') +ct=read(OUT/'GLOBAL-TEMPLATE.json.gz');summary=read(OUT/'HOSTED.json') +sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest() +provider_ids=('fourcold_eight', 'width7_eight') +providers={};registry={};phase_semantic_hashes={} +required_artifacts={'work/complex-nine-native/DATA-PHASES.json'} +provider_files=('CANONICAL-WORD.json.gz','LOCAL-PROGRAMS.json.gz','LOCAL-CHECKS.json', + 'INDEPENDENT-LOCAL-REPLAY.json','RESIDUAL-ADAPTERS.json','CLIFFORD-RECIPES.json','CLIFFORD-REVIEW.json') +for pid in provider_ids: + p=BASE/'providers'/pid + c=read(p/'CANONICAL-WORD.json.gz');checks=read(p/'LOCAL-CHECKS.json') + programs=read(p/'LOCAL-PROGRAMS.json.gz');replay=read(p/'INDEPENDENT-LOCAL-REPLAY.json') + phase=read(p/'CLIFFORD-REVIEW.json');adapters=read(p/'RESIDUAL-ADAPTERS.json')['recipes'] + widths=[c['h']-len(c['frames'][c['start'][2*c['v']+h]])for h in range(c['R'])] + promoted={'fourcold_eight':0,'width7_eight':32}[pid] + assert all(widths[h]==8 for h in (270,282,294,306)) and Counter(widths)==Counter({'fourcold_eight':{4:8,5:48,8:164,9:284},'width7_eight':{4:8,5:48,7:32,8:128,9:288}}[pid]) + canonical_sha=sha(p/'CANONICAL-WORD.json.gz');programs_sha=sha(p/'LOCAL-PROGRAMS.json.gz') + assert replay['status']=='PASS_INDEPENDENT_LOCAL_SCALAR_FRAME_AND_WRAPPER_REPLAY' + assert replay['canonical_word_sha256']==canonical_sha and replay['local_programs_sha256']==programs_sha + assert replay['v']==c['v'] and replay['helpers']==c['R'] + assert set(programs)==set(checks)==set(replay['local'])==set(replay['paid_profiles'])=={'forward','backward'} + for orientation,events in programs.items(): + ck=checks[orientation];rr=replay['local'][orientation] + assert hashlib.sha256(json.dumps(events,sort_keys=True,separators=(',',':')).encode()).hexdigest()==ck['sha256'] + assert ck['events']==len(events) and ck['all_columns']==2*c['v']+c['R'] + assert ck['private_centers_cleared'] and ck['private_coefficient_stream_cleared_after_each_macro'] + assert rr['all_exact_columns']==2*c['v']+c['R'] and rr['private_work_erased'] + literal=Counter(e[-1]for e in events if e[0]in('climb','center')) + assert dict(literal)=={int(r):n for r,n in ck['paid_profile'].items()}=={int(r):n for r,n in c['local_profile'].items()} + assert ck['paid_profile']==replay['paid_profiles'][orientation] + assert phase['canonical_word_sha256']==canonical_sha and phase['recipe_sha256']==sha(p/'CLIFFORD-RECIPES.json') + assert phase['all_child_equalities_include_global_phase'] + phase_semantic_hashes[pid]=hashlib.sha256(json.dumps({k:v for k,v in phase.items()if k!='seconds'},sort_keys=True,separators=(',',':')).encode()).hexdigest() + for h,w in enumerate(widths): + assert 0>i)&1==0);a=q^(1<>i&1 else 0)for i in order]+[1<2*max(paid)**2 + return dict(profile=dict(sorted(paid.items())),mass=mass,hosted=HOSTED,entering=entering,cross_replica=cross,sigma_digest=digest.hexdigest(),sigmas=sigmas,idle_remainders=len(wanted),busy_family_checks=len(roles),invocations=72) + +r=audit(ct);raw=gzip.decompress((OUT/'GLOBAL-TEMPLATE.json.gz').read_bytes());assert hashlib.sha256(raw).hexdigest()==summary['template_sha256'];assert r['profile']=={int(k):v for k,v in summary['global_profile'].items()};assert r['sigmas']==read(OUT/'ACTUAL-SIGMAS.json.gz');assert r['sigma_digest']==summary['sigma_stream_sha256'] +assert all(hashlib.sha256((BASE/name).read_bytes()).hexdigest()==value for name,value in summary['source_artifacts'].items()) +controls=[] +def reject(name,mut): + if '--mutation-controls' not in sys.argv[4:]:return + q=copy.deepcopy(ct);mut(q) + try:audit(q) + except(AssertionError,KeyError,IndexError,ValueError,TypeError):controls.append(name) + else:raise AssertionError('ACCEPTED '+name) +enter=lambda q:next(o for c in q['calls']for o in c['owners'][(2*V):]if o[1][0]==4) +reject('alias two whole owners',lambda q:q['calls'][0]['owners'].__setitem__((2*V+1),q['calls'][0]['owners'][(2*V)])) +reject('helper on active data family',lambda q:q['calls'][0]['owners'][(2*V)].__setitem__(0,q['calls'][0]['owners'][0][0])) +reject('owner in private namespace',lambda q:q['calls'][0]['owners'][(2*V)].__setitem__(0,DATA)) +reject('wrong residual width',lambda q:enter(q)[1].__setitem__(3,enter(q)[1][3]-1)) +reject('wrong spectator coordinate',lambda q:enter(q)[1][4].__setitem__(0,72)) +reject('omit idle remainder',lambda q:q['idle_children'].pop()) +reject('understate physical reserve',lambda q:q.__setitem__('physical',PHYSICAL-1)) +special=lambda q:next(c for c in q['calls']if c['provider_id']=='fourcold_eight') +changed=next(h for h in range(R)if providers['fourcold_eight']['widths'][h]!=providers['width7_eight']['widths'][h]) +assert providers['fourcold_eight']['widths'][changed]==8 and providers['width7_eight']['widths'][changed]==7 +reject('wrong provider at a plain invocation',lambda q:special(q).__setitem__('provider_id','width7_eight')) +reject('stale per-call local program hash',lambda q:special(q).__setitem__('local_program_sha256',registry['width7_eight']['local_program_checks'][special(q)['orientation']]['sha256'])) +reject('stale serialized plain provider program',lambda q:q['local_providers']['fourcold_eight'].__setitem__('local_programs',registry['width7_eight']['local_programs'])) +reject('unbound residual adapter hash',lambda q:q['local_providers']['fourcold_eight'].__setitem__('residual_adapter_sha256','0'*64)) +reject('wrong provider width registry',lambda q:q['local_providers']['fourcold_eight']['widths'].__setitem__(changed,7)) +reject('wrong per-call width at a plain invocation',lambda q:special(q)['owners'][2*V+changed][1].__setitem__(3,7)) +reject('wrong sweep provider',lambda q:next(e for e in q['execution_schedule']if e['kind']=='local_cover_sweep'and DISPATCH[e['stage'],e['replica']]=='fourcold_eight').__setitem__('provider_id','width7_eight')) +reject('cold helper width silently restored to nine',lambda q:q['local_providers']['fourcold_eight']['widths'].__setitem__(270,9)) +reject('missing cold helper wrapper binding',lambda q:q['local_providers']['fourcold_eight'].__setitem__('residual_adapter_sha256','0'*64)) +report=dict(status='PASS_INDEPENDENT_ASYNC_WHOLE_OWNER_CONTROLLER_PHASES_AND_SPECTATORS',template_sha256=summary['template_sha256'],complex_template_sha256=summary['template_sha256'],complex_live=DATA,complex_profile=r['profile'],complex_hosted_residuals=HOSTED,physical=PHYSICAL,rank_mass=r['mass'],deficit=2560,entering_helper_roles=r['entering'],cross_replica_helper_roles=r['cross_replica'],one_owner_per_complete_invocation=True,helper_busy_family_window_checks=r['busy_family_checks'],complete_invocations=r['invocations'],actual_orthogonal_73column_maps=len(r['sigmas']),actual_sigma_stream_sha256=r['sigma_digest'],all_actual_residual_and_spectator_charts=True,idle_remainders=r['idle_remainders'],mutations_rejected=controls,mutation_controls_run='--mutation-controls' in sys.argv[4:],provider_phase_semantic_sha256=phase_semantic_hashes,widths_by_provider={pid:dict(sorted(Counter(providers[pid]['widths']).items()))for pid in provider_ids},provider_counts=dict(Counter(c['provider_id']for c in ct['calls'])),all_provider_program_phase_and_wrapper_bindings=True,scope='Independent exact asynchronous chronology, per-replica phase projection, owner/chart/paid-profile audit. Uses two per-invocation local providers bound by exact scalar, phase and residual-wrapper receipts; all-size compilation and complete coefficient invoice are separate inherited obligations.') +REPORT.parent.mkdir(parents=True,exist_ok=True) +REPORT.write_text(json.dumps(report,indent=2)+'\n');print(json.dumps(report,indent=2)) + +owners=dict(status='PASS_INDEPENDENT_ASYNC_OWNERS_AND_PROFILE',template_sha256=summary['template_sha256'],paid_profile=r['profile'],live=DATA,physical=PHYSICAL,rank_mass=r['mass'],deficit=2560,hosted_residuals=HOSTED,banked_residuals=0,all_live_owners_per_call_distinct=True,owners_per_call=N,actual_helper_owner_charts=HOSTED,actual_73column_sigmas=len(r['sigmas']),cross_replica_helper_roles=r['cross_replica'],explicit_idle_remainder_children=r['idle_remainders'],source_idle_children_charged=sum(x['replicas']for x in parent['idle_children']),source_artifacts=summary['source_artifacts'],provider_phase_semantic_sha256=phase_semantic_hashes,controller_audit_sha256=hashlib.sha256(REPORT.read_bytes()).hexdigest()) +(REPORT.parent/'OWNERS-AND-PROFILE.json').write_text(json.dumps(owners,indent=2)+'\n') + +# Literal residual frames are a compact export of the already checked offsets, +# not another global replay. Every row names its actual inherited axes. +frames=[] +for z in ct['idle_children']: + axes=list(map(int,ph['recipes'][z['port']]['idle_children'][z['child']]['orthogonal_axes'])) + tail=axes[z['pending_offset']:] + assert len(tail)==z['rank'] + frames.append(dict(z,orthogonal_axes=tail)) +frame_raw=json.dumps(frames,sort_keys=True,separators=(',',':')).encode() +portable=bytearray(gzip.compress(frame_raw,mtime=0));portable[9]=255 +(OUT/'IDLE-REMAINDER-FRAMES.json.gz').write_bytes(bytes(portable)) +frame_receipt=dict(status='PASS_LITERAL_IDLE_REMAINDER_FRAMES',template_sha256=summary['template_sha256'], + uncompressed_frames_sha256=hashlib.sha256(frame_raw).hexdigest(),children=len(frames), + rank_profile=dict(sorted(Counter(z['rank']for z in frames).items())), + source_data_phase_sha256=hashlib.sha256((BASE/'work/complex-nine-native/DATA-PHASES.json').read_bytes()).hexdigest(), + scope='Actual orthogonal axes after the independently checked whole-owner prefix in each inherited pending child.') +(REPORT.parent/'IDLE-REMAINDER-FRAMES.json').write_text(json.dumps(frame_receipt,indent=2)+'\n') + diff --git a/research/complex-571-plain8/code/bind_providers_portable.py b/research/complex-571-plain8/code/bind_providers_portable.py new file mode 100644 index 0000000000..f8de977ce8 --- /dev/null +++ b/research/complex-571-plain8/code/bind_providers_portable.py @@ -0,0 +1,61 @@ +"""Bind freshly verified plain and width-seven four-cold providers to the frozen literal owner plan. +Prepared with OpenAI Codex assistance; Apache-2.0. All byte-stable native +files are pinned to the plan. Only validated phase-receipt timing/serialization +and directory fields are rebound; no dispatch, width or owner choice changes. +""" +import argparse,copy,gzip,hashlib,json,shutil +from collections import Counter +from pathlib import Path +assert __debug__, 'Assertions required' +ap=argparse.ArgumentParser(description=__doc__) +for name in ('baseline','plain','width7','plan','out'):ap.add_argument('--'+name,type=Path,required=True) +a=ap.parse_args();assert not a.out.exists();a.out.mkdir(parents=True) +def read(p):return json.loads(gzip.decompress(p.read_bytes())if p.suffix=='.gz'else p.read_bytes()) +def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest() +base=a.out/'base';shutil.copytree(a.baseline/'complex-global/base',base) +dirs={'fourcold_eight':a.plain,'width7_eight':a.width7} +promotions={'fourcold_eight':0,'width7_eight':32} +INV={'fourcold_eight':Counter({4:8,5:48,8:164,9:284}),'width7_eight':Counter({4:8,5:48,7:32,8:128,9:288})} +for pid,src in dirs.items():shutil.copytree(src,base/'providers'/pid) +plan=read(a.plan);original=copy.deepcopy(plan);sources={} +assert set(plan['provider_registry'])==set(dirs) +assert Counter(c['provider']for c in plan['provider_calls'])=={'width7_eight': 63, 'fourcold_eight': 9} +stable=('CANONICAL-WORD.json.gz','LOCAL-PROGRAMS.json.gz','LOCAL-CHECKS.json','INDEPENDENT-LOCAL-REPLAY.json','CLIFFORD-RECIPES.json','RESIDUAL-ADAPTERS.json') +for pid,desc in plan['provider_registry'].items(): + d=base/'providers'/pid;p=promotions[pid] + word,program,checks,native,phase=[read(d/name)for name in('CANONICAL-WORD.json.gz','LOCAL-PROGRAMS.json.gz','LOCAL-CHECKS.json','INDEPENDENT-LOCAL-REPLAY.json','CLIFFORD-REVIEW.json')] + assert (word['v'],word['h'],word['R'],len(word['centers']))==(112,9,504,8) + assert word['ports']==desc['ports'] and word['centers']==desc['centers'] + widths=[9-len(word['frames'][f])for f in word['start'][224:]] + assert all(widths[h]==8 for h in (270,282,294,306)) + assert widths==desc['widths'] and Counter(widths)==INV[pid] + assert native['status']=='PASS_INDEPENDENT_LOCAL_SCALAR_FRAME_AND_WRAPPER_REPLAY' + assert len(native['negative_controls_rejected'])==11 + assert native['canonical_word_sha256']==sha(d/'CANONICAL-WORD.json.gz') and native['local_programs_sha256']==sha(d/'LOCAL-PROGRAMS.json.gz') + assert phase['status']=='PASS_NEW_WORD_EXACT_LOCAL_PHASE_RECIPES' + assert phase['canonical_word_sha256']==sha(d/'CANONICAL-WORD.json.gz') and phase['recipe_sha256']==sha(d/'CLIFFORD-RECIPES.json') + assert phase['all_child_equalities_include_global_phase'] is True and phase['endpoint_adapters']==224 and phase['directed_edges']==(3004 if p else 2929) + assert set(program)==set(checks)=={'forward','backward'} + expected=({1:2352,2:580,3:336,4:192,5:56,6:56,8:8} if p else {1:2332,2:436,3:448,4:192,5:56,6:56,8:8}) + for orientation,events in program.items(): + profile=Counter() + for e in events: + if e[0]=='climb':profile[e[5]]+=1 + elif e[0]=='center':profile[e[4]]+=1 + assert dict(profile)==expected=={int(r):n for r,n in checks[orientation]['paid_profile'].items()}=={int(r):n for r,n in native['paid_profiles'][orientation].items()} + assert hashlib.sha256(json.dumps(events,separators=(',',':')).encode()).hexdigest()==checks[orientation]['sha256'] + for name in stable: + assert sha(d/name)==desc['artifact_sha256'][name],(pid,name,'changed non-timing artifact') + if name.endswith('.gz'):assert(d/name).read_bytes()[9]==255,(pid,name,'nonportable gzip header') + for c in plan['provider_calls']: + if c['provider']==pid: + assert c['orientation']==('forward'if c['stage']%2==0 else'backward') + assert c['local_program_sha256']==checks[c['orientation']]['sha256'] + desc['directory']='providers/'+pid + desc['artifact_sha256']={name:sha(d/name)for name in desc['artifact_sha256']} + sources[pid]=dict(artifact_sha256=desc['artifact_sha256'],canonical_content_sha256=hashlib.sha256(json.dumps(word,sort_keys=True,separators=(',',':')).encode()).hexdigest(),all_phase_edges=(3004 if p else 2929)) +plan['runtime_source_plan_sha256']=sha(a.plan) +(a.out/'PLAN.json').write_text(json.dumps(plan,indent=2)+'\n') +receipt=dict(status='PASS_FROZEN_048_ALLCOLD_DISPATCH_FRESH_PROVIDER_BINDING',source_plan_sha256=sha(a.plan),runtime_plan_sha256=sha(a.out/'PLAN.json'),providers=sources,only_rebound_fields=['provider_registry.directory','provider_registry.artifact_sha256.CLIFFORD-REVIEW.json','runtime_source_plan_sha256']) +(a.out/'BINDING.json').write_text(json.dumps(receipt,indent=2)+'\n') +print(receipt['status']) diff --git a/research/complex-571-plain8/code/emit_allcold.py b/research/complex-571-plain8/code/emit_allcold.py new file mode 100644 index 0000000000..f1a7431a16 --- /dev/null +++ b/research/complex-571-plain8/code/emit_allcold.py @@ -0,0 +1,140 @@ +"""Two-provider width-seven whole-owner derivative, adapted with OpenAI Codex assistance. +Based on PR514 and its credited PR484/507 lineage. +CLI: --base VERIFIED_VARIANT --owners ASYNC-OWNERS.json.gz --plan ASYNC-PLAN.json --out OUT +No optimizer or unpublished word builder runs. The frozen map explicitly names +one whole helper per family per complete invocation, plus borrowed spectators. +""" +import sys,json,gzip,hashlib,copy,argparse +from pathlib import Path +from collections import Counter,defaultdict +parser=argparse.ArgumentParser(description=__doc__) +parser.add_argument('--base',type=Path,required=True);parser.add_argument('--owners',type=Path,required=True);parser.add_argument('--plan',type=Path,required=True);parser.add_argument('--out',type=Path,required=True) +a=parser.parse_args();BASE,MAP,PLAN,OUT=(p.resolve()for p in(a.base,a.owners,a.plan,a.out));assert not OUT.exists();OUT.mkdir(parents=True) +class OH: + @staticmethod + def idle_basis(q): + z=next(i for i in range(9)if not(q>>i)&1);u=q^(1<>i&1 else 0)for i in order]+[1<=0 and off+w<=rank[i] + assert z['time']==at[s,rep] and z['time'] in plan['windows'][f'{orp},{i}'][1] + B=OH.idle_basis(canon['ports'][port]);pending=list(map(int,ph['recipes'][port]['idle_children'][i]['orthogonal_axes']));assert len(pending)==rank[i] + occ=[B.index(v)for v in pending[off:off+w]];sp=OH.spectators(canon['ports'][port],pending,off,w)if w<9 else[] + order=occ+sp+[j for j in range(M)if j not in occ and j not in sp];assert len(order)==len(set(order))==M + sigma=[B[j]for j in order];sigmahash=hashlib.sha256(json.dumps(sigma,separators=(',',':')).encode()).hexdigest();sigmas[sigmahash]=sigma + route=[4,i,off,w,sp]if w<9 else[3,i,off];bycall[s,rep][h]=[f,route];entering+=w<9 + cells=set(range(off,off+w));assert not used[i,orp,port]&cells;used[i,orp,port]|=cells + digest.update(json.dumps([s,rep,h,f,sigmahash],separators=(',',':')).encode()+b'\n') +for c in t['calls']: + k=(c['stage'],c['replica']);assert set(bycall[k])==set(range(R)) + c['owners']=c['owners'][:(2*V)]+[bycall[k][h]for h in range(R)];assert len({f for f,r in c['owners']})==2*V+R and all(f2*max(paid)**2 + +assert all(c['local_program_sha256']==registry[c['provider_id']]['local_program_checks'][c['orientation']]['sha256']for c in t['calls']) +t['provider_dispatch']='For each indivisible local_cover_sweep, execute local_providers[call.provider_id].local_programs[call.orientation] with that provider residual adapters and Clifford recipes. The sweep provider_id must equal its call provider_id.' +raw=json.dumps(t,sort_keys=True,separators=(',',':')).encode();(OUT/'GLOBAL-TEMPLATE.json.gz').write_bytes(gzip.compress(raw,mtime=0)) +res=dict(status='EMITTED_MIXED_PROVIDER_ASYNCHRONOUS_WHOLE_OWNER_COMPLEX_TEMPLATE', + template_sha256=hashlib.sha256(raw).hexdigest(), + parent_template_sha256=hashlib.sha256(gzip.decompress((BASE/'split-centres/GLOBAL-TEMPLATE.json.gz').read_bytes())).hexdigest(), + live=DATA,physical=physical,global_profile=dict(sorted(paid.items())), + rank_mass=sum(r*n for r,n in paid.items()),deficit=2560,maxchild=max(paid), + hosted_residuals=len(roles),banks_per_stage=[0]*9,entering_helper_roles=entering, + unique_actual_73column_sigmas=len(sigmas),sigma_stream_sha256=digest.hexdigest(), + cross_replica_helper_roles=sum(z['replica']!=z['owner_replica']for z in roles), + asynchronous_order_sha256=hashlib.sha256(json.dumps(call_order,separators=(',',':')).encode()).hexdigest(), + source_artifacts=source_artifacts,provider_counts=dict(Counter(c['provider_id']for c in t['calls'])), + scope='Two actual verified plain/width-seven providers dispatched per complete invocation; independent controller/spectator/normalization and complete finite invoice admission required.') +(OUT/'HOSTED.json').write_text(json.dumps(res,indent=2)+'\n');(OUT/'ACTUAL-SIGMAS.json.gz').write_bytes(gzip.compress(json.dumps(sigmas,separators=(',',':')).encode(),mtime=0));print(json.dumps(res,indent=2)) diff --git a/research/complex-571-plain8/code/invoice_allcold.py b/research/complex-571-plain8/code/invoice_allcold.py new file mode 100644 index 0000000000..657fae2c76 --- /dev/null +++ b/research/complex-571-plain8/code/invoice_allcold.py @@ -0,0 +1,314 @@ +"""Fresh call-specific mixed-provider finite invoice. + +Prepared with OpenAI Codex assistance, Apache-2.0. The scalar/Horner recount +and finite inequalities are adapted from the retained PR558 -> PR552 -> +PR531 invoice_final.py, whose notices and sources are preserved in the package. +Every call selects a hash-bound provider. Shared compiler reserves use maxima; +primitive work, coefficient work, local children and wrappers are also summed +from actual selected provider/orientation records. +""" +import argparse, gzip, hashlib, json +from collections import Counter +from fractions import Fraction as Q +from pathlib import Path +assert __debug__, 'Assertions required' + +def read(path): + data=path.read_bytes() + return json.loads(gzip.decompress(data) if path.suffix=='.gz' else data) +def filehash(path): return hashlib.sha256(path.read_bytes()).hexdigest() +def contenthash(path): + data=path.read_bytes() + return hashlib.sha256(gzip.decompress(data) if path.suffix=='.gz' else data).hexdigest() +def programhash(events): + return hashlib.sha256(json.dumps(events,separators=(',',':')).encode()).hexdigest() + +def recount_provider(local_dir, registry): + cp=local_dir/'CANONICAL-WORD.json.gz'; pp=local_dir/'LOCAL-PROGRAMS.json.gz' + rp=local_dir/'INDEPENDENT-LOCAL-REPLAY.json' + w,programs,replay=read(cp),read(pp),read(rp) + checks=read(local_dir/'LOCAL-CHECKS.json') + assert set(programs)=={'forward','backward'} + assert replay['status']=='PASS_INDEPENDENT_LOCAL_SCALAR_FRAME_AND_WRAPPER_REPLAY' + assert replay['canonical_word_sha256']==filehash(cp)==registry['canonical_word_sha256'] + assert replay['local_programs_sha256']==filehash(pp)==registry['local_programs_sha256'] + assert programs==registry['local_programs'] + assert checks==registry['local_program_checks'] + assert filehash(local_dir/'CLIFFORD-RECIPES.json')==registry['exact_local_clifford_recipe_sha256'] + assert filehash(local_dir/'RESIDUAL-ADAPTERS.json')==registry['residual_adapter_sha256'] + v,helpers,h,m=w['v'],w['R'],w['h'],73 + assert (v,helpers,h)==(112,504,9) + assert registry['v']==v and registry['R']==helpers and registry['h']==h + assert registry['ports']==w['ports'] and registry['centers']==w['centers'] + assert replay['v']==v and replay['helpers']==helpers + n=2*v+helpers + widths = [h-len(w['frames'][f]) for f in w['start'][2*v:]] + assert len(widths) == helpers + entrances = {r: f for r, f in enumerate(w['start']) if r >= 2*v and f != 0} + entering = len(entrances) + assert entering == replay['entering_helpers'] + local = {} + for orientation, events in programs.items(): + # Endpoint equality and native frames were already independently + # replayed on all n columns in the hash-bound receipt above. + env = {('L', r): Q(1) for r in range(n)} + peak = Q(1) + real = macros = workops = 0 + paid = Counter() + wrappers = {'pre': set(), 'post': set()} + for event in events: + tag = event[0] + if tag == 'climb': + paid[event[5]] += 1 + elif tag == 'center': + paid[event[4]] += 1 + elif tag == 'residual_adapter': + _, kind, register, frame = event + assert kind in wrappers and entrances.get(register) == frame + assert register not in wrappers[kind] + wrappers[kind].add(register) + elif tag == 'scalar': + macros += 1 + scalar = event[1] + op, target = scalar[0], tuple(scalar[1]) + if op == 'clear': + env[target] = Q(0) + count = 1 + elif op == 'copy': + env[target] = env[tuple(scalar[2])] + count = 1 + elif op == 'scale': + q = Q(scalar[2], scalar[3]) + numerator, denominator = abs(q.numerator), q.denominator + assert numerator and numerator & (numerator-1) == 0 + assert denominator & (denominator-1) == 0 + env[target] *= abs(q) + count = abs(numerator.bit_length()-denominator.bit_length()) + int(q < 0) + elif op == 'add': + source = tuple(scalar[2]) + q = Q(scalar[3], scalar[4]) + numerator, denominator = abs(q.numerator), q.denominator + assert source != target and numerator > 0 + assert denominator & (denominator-1) == 0 + acc, count = 0, 1 # clear coefficient work + for i, bit in enumerate(bin(numerator)[2:]): + if i: + acc *= 2 + count += 1 + peak = max(peak, acc*env[source]) + if bit == '1': + acc += 1 + count += 1 + peak = max(peak, acc*env[source]) + value = Q(acc) + for _ in range(denominator.bit_length()-1): + value /= 2 + count += 1 + peak = max(peak, value*env[source]) + assert value == abs(q) + count += 2 # signed accumulation and work clear + env[target] = env.get(target, Q(0)) + abs(q)*env[source] + workops += count + else: + raise AssertionError(op) + real += 2*count + peak = max(peak, env[target]) + else: + assert tag in ('adapter', 'phase') + assert wrappers['pre'] == wrappers['post'] == set(entrances) + assert all(value == 0 for register, value in env.items() if register[0] == 'C') + prior = replay['local'][orientation] + assert prior['all_exact_columns'] == n and prior['private_work_erased'] + assert peak == Q(prior['prefix_l1_upper']) and peak < 2**prior['charged_payload_bits'] + bits = peak.numerator.bit_length()-peak.denominator.bit_length()+1 + assert bits == prior['prefix_bits_upper'] + assert real == checks[orientation]['real_component_primitive_bound'] + assert macros == checks[orientation]['scalar_macros'] + assert dict(paid) == {int(r): count for r, count in checks[orientation]['paid_profile'].items()} + assert dict(paid) == {int(r): count for r, count in replay['paid_profiles'][orientation].items()} + local[orientation] = dict( + events=len(events), macros=macros, real_component_primitives=real, + prefix_l1=str(peak), prefix_bits=bits, + coefficient_work_primitive_count=workops, all_exact_columns=n, + dirty_helper_columns=helpers, all_dirty_helper_columns_restored=True, + private_centres_and_coefficient_work_cleared=True, + pre_wrappers=len(wrappers['pre']), post_wrappers=len(wrappers['post']), + endpoint_evidence='Hash-bound fresh INDEPENDENT-LOCAL-REPLAY.json') + + centres = len(w['centers']) + children = sum(checks['forward']['paid_profile'].values()) + assert checks['forward']['paid_profile'] == checks['backward']['paid_profile'] + macro_bound = max(row['macros'] for row in local.values()) + compiler = 64*(m+1)**3 + adapters = 16*(macro_bound+children+n+centres)+64*m + primitive_bound = max(row['real_component_primitives'] for row in local.values())+adapters*compiler + + assert widths==registry['widths'] + artifacts={f.name:filehash(f) for f in local_dir.iterdir() if f.is_file()} + phase_review=read(local_dir/'CLIFFORD-REVIEW.json') + semantic_phase=hashlib.sha256(json.dumps({k:v for k,v in phase_review.items()if k!='seconds'},sort_keys=True,separators=(',',':')).encode()).hexdigest() + return dict(local=local,helpers=helpers,centres=centres,v=v,h=h,n=n, + entering_helpers=entering,entrance_rank=sum(h-width for width in widths), + width_inventory=dict(sorted(Counter(widths).items())),widths=widths, + local_adapters=adapters,local_primitive_bound=primitive_bound, + compiler=compiler,children=children,artifacts=artifacts, + paid_profile=checks['forward']['paid_profile'], + program_hashes={o:programhash(events) for o,events in programs.items()},semantic_artifact_sha256={'CLIFFORD-REVIEW.json':semantic_phase}) + + +def run(base, hosted, audit, out, retained_invoice=None): + local_dir=base/'split-centres' + parent=read(local_dir/'GLOBAL-TEMPLATE.json.gz') + template_path=hosted/'GLOBAL-TEMPLATE.json.gz' + template=read(template_path); summary=read(hosted/'HOSTED.json') + owners=read(audit/'OWNERS-AND-PROFILE.json'); control=read(audit/'ASYNC-AUDIT.json') + template_hash=contenthash(template_path) + assert template_hash==control['complex_template_sha256']==owners['template_sha256']==summary['template_sha256'] + assert owners['status']=='PASS_INDEPENDENT_ASYNC_OWNERS_AND_PROFILE' + assert template['recipe']==parent['recipe'] + assert 'local_programs' not in template + assert set(template['local_providers'])=={'fourcold_eight', 'width7_eight'} + providers={pid:recount_provider(base/'providers'/pid,registry) + for pid,registry in template['local_providers'].items()} + for pid,p in providers.items(): + assert owners['provider_phase_semantic_sha256'][pid]==control['provider_phase_semantic_sha256'][pid]==p['semantic_artifact_sha256']['CLIFFORD-REVIEW.json'] + # The fresh controller admission must cite precisely these provider bytes. + for name in ('CANONICAL-WORD.json.gz','LOCAL-PROGRAMS.json.gz','LOCAL-CHECKS.json', + 'INDEPENDENT-LOCAL-REPLAY.json','CLIFFORD-RECIPES.json', + 'CLIFFORD-REVIEW.json','RESIDUAL-ADAPTERS.json'): + path='providers/'+pid+'/'+name + assert summary['source_artifacts'][path]==p['artifacts'][name] + assert owners['source_artifacts'][path]==p['artifacts'][name] + v,helpers,h,m,centres,n=112,504,9,73,8,728 + stages,replicas,blocks_per_stream=9,8,4 + call_count=len(template['calls']) + assert call_count==stages*replicas==control['complete_invocations'] + assert control['one_owner_per_complete_invocation'] + assert len({(c['stage'],c['replica']) for c in template['calls']})==call_count + parent_calls={(c['stage'],c['replica']):c for c in parent['calls']} + sweeps=[e for e in template['execution_schedule'] if e['kind']=='local_cover_sweep'] + assert len(sweeps)==call_count + selected=[]; selected_paid=Counter(); provider_counts=Counter(); orientation_counts=Counter() + scalar=coefficient_work=macros=0; wrapper_factors=0 + factors_per_wrapper=2*(m-1) + for c in template['calls']: + pid,orientation=c['provider_id'],c['orientation']; p=providers[pid] + old=parent_calls[(c['stage'],c['replica'])] + assert orientation==old['orientation'] and c['owners'][:2*v]==old['owners'][:2*v] + assert c['local_program_sha256']==p['program_hashes'][orientation] + r=p['local'][orientation] + scalar+=r['real_component_primitives']; coefficient_work+=r['coefficient_work_primitive_count']; macros+=r['macros'] + wrapper_factors+=(r['pre_wrappers']+r['post_wrappers'])*factors_per_wrapper + provider_counts[pid]+=1; orientation_counts[(pid,orientation)]+=1 + selected_paid.update({int(k):v for k,v in p['paid_profile'].items()}) + selected.append(dict(stage=c['stage'],replica=c['replica'],provider_id=pid,orientation=orientation, + program_sha256=c['local_program_sha256'],events=r['events'],macros=r['macros'], + real_component_primitives=r['real_component_primitives'], + coefficient_work_primitive_count=r['coefficient_work_primitive_count'], + entering_helpers=p['entering_helpers'],entrance_rank=p['entrance_rank'], + pre_wrappers=r['pre_wrappers'],post_wrappers=r['post_wrappers'])) + assert provider_counts=={'width7_eight': 63, 'fourcold_eight': 9} + # The sweep registry is executable: no hidden use of the historical supplier. + by_call={(c['stage'],c['replica']):c for c in template['calls']} + for e in sweeps: + c=by_call[(e['stage'],e['replica'])] + assert e['provider_id']==c['provider_id'] + assert set(p['compiler'] for p in providers.values())=={64*(m+1)**3} + compiler=64*(m+1)**3 + adapters=max(p['local_adapters'] for p in providers.values()) + primitive_bound=max(p['local_primitive_bound'] for p in providers.values()) + bridge_steps=sum(event['kind']=='bridge' for event in parent['recipe']) + bridge_sweeps=sum(event['kind']=='bridge' for event in template['execution_schedule']) + assert bridge_sweeps==replicas*bridge_steps + bridge_additions=2*v*bridge_sweeps + shifts=blocks_per_stream*v*replicas; moves=2*shifts + parent_live,parent_physical=parent['live'],parent['physical'] + data_stock=2*v*blocks_per_stream*replicas + assert (parent_live-data_stock)%stages==0 + parent_banks=(parent_live-data_stock)//stages + assert parent_banks>=0 and parent_physical==parent_live+helpers+centres+2 + nonlocal_items=(4*v*replicas*stages+2*v*replicas*stages+2*call_count*helpers + +sum(child['replicas'] for child in parent['idle_children'])+stages*parent_banks + +bridge_additions+shifts+moves+parent_live+parent_physical+wrapper_factors) + outside=8*nonlocal_items+64*m + parent_pervertex=(scalar+bridge_additions+shifts+moves+parent_live + +(call_count*adapters+outside)*compiler+64*parent_physical) + live,physical=template['live'],template['physical'] + mass,profile=owners['rank_mass'],owners['paid_profile'] + assert m*live-mass==owners['deficit']==2560 + assert mass==sum(int(r)*count for r,count in profile.items()) + assert physical==live+helpers+centres+2 + assert live==owners['live'] and physical==owners['physical'] + assert live<=parent_live and physical<=parent_physical + assert not template['bank_padding']['families'] + assert owners['explicit_idle_remainder_children']<=owners['source_idle_children_charged'] + # The old dedicated-bank geometry is only a conservative reserve envelope. + # Its singular program is never used as evidence for a mixed invocation. + rebased=parent_pervertex+65*(physical-parent_physical)+(live-parent_live) + used=max(rebased,parent_pervertex); retained=None; payload=512 + if retained_invoice is not None: + previous=read(retained_invoice) + assert previous['compiler']==compiler and previous['charged_prefix_bits']==payload + previous_bound=previous['conservative_pervertex_used'] + used=max(used,previous_bound+parent_pervertex) + retained=dict(sha256=filehash(retained_invoice),previous_pervertex_allowance=previous_bound, + added_complete_new_pervertex=parent_pervertex,policy='Retain old allowance and add entire fresh mixed recount.') + half=m//2; group=2**(half*half) + for i in range(1,half+1): group*=2**(2*i)-1 + stock,streamed_mass=group*physical,group*mass + logical=group*used+64; router=compiler*(logical+1)*(stock+1)**2 + g_bound,e_bound,c0=2**30000,2**100000,2**210000 + total_mass=streamed_mass+e_bound + literal=2*g_bound*stock**2+8*streamed_mass+4*stock+4+32*m + row=2*stock.bit_length()+9909+252+2*payload + maxchild=max(map(int,profile)) + inequalities=dict(local_primitive_bound=primitive_bound<2**48, + logical=logical<2**6050,router=router2*maxchild*maxchild) + assert all(inequalities.values()) + localbits=max(r['prefix_bits'] for p in providers.values() for r in p['local'].values()) + input_l2_bits=(m+1)//2 + required_prefix=localbits+input_l2_bits+call_count+bridge_sweeps+4 + assert required_prefix