From 563ac6bf2431aa3b90c1a6d321b1a9d34387eb8f Mon Sep 17 00:00:00 2001 From: Chris R Date: Wed, 11 Nov 2026 09:57:24 +1100 Subject: [PATCH 1/3] Archive V02 parent custody and unresolved pre-seal review evidence Retain exact source and conflicting review records for contributor inspection. Archive integrity only. Prepared with substantial OpenAI Codex assistance. --- .../CONTRIBUTOR-TASK.md | 13 + .../h25-v02-parent-custody-evidence/LICENSE | 201 ++ .../MANIFEST.json | 302 +++ .../h25-v02-parent-custody-evidence/NOTICE.md | 1 + .../PREDECESSORS.json | 32 + .../h25-v02-parent-custody-evidence/README.md | 50 + .../SOURCE-MAP.json | 423 ++++ .../TRANSPORT-POINT.md | 20 + .../check_integrity.py | 44 + .../CONTROL-RECEIVER-e4a776-opt0.json | 13 + .../CONTROL-RECEIVER-e4a776-opt1.json | 13 + .../independent-review/FINAL-LEDGER-opt0.json | 11 + .../independent-review/FINAL-LEDGER-opt1.json | 11 + .../INITIAL-RECEIVER-e4a776-opt0.json | 12 + .../INITIAL-RECEIVER-e4a776-opt1.json | 12 + .../independent-review/REPLAY-opt0.json | 48 + .../independent-review/REPLAY-opt1.json | 48 + .../independent-review/REVIEW.md | 20 + .../probe_control_receiver-opt0.json | 11 + .../probe_control_receiver-opt1.json | 11 + .../probe_controls-opt0.json | 23 + .../probe_controls-opt1.json | 23 + .../probe_final_ledger-opt0.json | 11 + .../probe_final_ledger-opt1.json | 11 + .../probe_initial_receiver-opt0.json | 10 + .../probe_initial_receiver-opt1.json | 10 + .../direct-v02-entry/run_direct_v02.py.txt | 893 +++++++ .../independent-review/REPLAY-normal.json | 16 + .../independent-review/REPLAY-optimized.json | 16 + .../independent-review/REVIEW-final.md | 11 + .../independent-review/INDEPENDENT-opt0.json | 49 + .../independent-review/INDEPENDENT-opt1.json | 49 + .../PATH-TYPE-GUARD-cefcf1f7.json | 6 + .../independent-review/REPLAY-opt0.json | 40 + .../independent-review/REPLAY-opt1.json | 40 + .../independent-review/REVIEW-final.md | 18 + .../SOURCE-COMPARISON-final.json | 35 + .../supervisor_outer_read_v1.py.txt | 2173 +++++++++++++++++ .../independent-review/PROFILE-opt0.json | 36 + .../independent-review/PROFILE-opt1.json | 36 + .../independent-review/REPLAY-opt0.json | 45 + .../independent-review/REPLAY-opt1.json | 45 + .../independent-review/REVIEW.md | 13 + .../independent-review/SOURCE-CHECK.json | 24 + .../frame_encoder_v1.py.txt | 168 ++ .../host_preseal_writer.js.txt | 183 ++ .../review/ENCODER-INDEPENDENT.json | 52 + .../review/FINAL-DELTA.json | 19 + .../review/HOST-INDEPENDENT.json | 57 + .../HOST-JSON-NUMBER-COUNTEREXAMPLE.json | 7 + .../review/INGRESS-INDEPENDENT.json | 69 + .../review/INTERMEDIATE-7001e2ba.json | 15 + .../review/REJECTED-b62f61f9.json | 28 + .../review/REPLAY-author-host.json | 79 + .../review/REPLAY-author-ingress.json | 129 + .../review/REPLAY-transferred-22.json | 342 +++ .../review/REPLAY-transferred-35.json | 187 ++ .../review/REVIEW-final.json | 92 + .../review/REVIEW-final.md | 25 + .../selected_child_preseal_v1.py.txt | 2077 ++++++++++++++++ 60 files changed, 8458 insertions(+) create mode 100644 research/h25-v02-parent-custody-evidence/CONTRIBUTOR-TASK.md create mode 100644 research/h25-v02-parent-custody-evidence/LICENSE create mode 100644 research/h25-v02-parent-custody-evidence/MANIFEST.json create mode 100644 research/h25-v02-parent-custody-evidence/NOTICE.md create mode 100644 research/h25-v02-parent-custody-evidence/PREDECESSORS.json create mode 100644 research/h25-v02-parent-custody-evidence/README.md create mode 100644 research/h25-v02-parent-custody-evidence/SOURCE-MAP.json create mode 100644 research/h25-v02-parent-custody-evidence/TRANSPORT-POINT.md create mode 100644 research/h25-v02-parent-custody-evidence/check_integrity.py create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REPLAY-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REPLAY-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REVIEW.md create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_controls-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_controls-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/run_direct_v02.py.txt create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REPLAY-normal.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REPLAY-optimized.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REVIEW-final.md create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/PATH-TYPE-GUARD-cefcf1f7.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REPLAY-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REPLAY-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REVIEW-final.md create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/SOURCE-COMPARISON-final.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/supervisor_outer_read_v1.py.txt create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/PROFILE-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/PROFILE-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REPLAY-opt0.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REPLAY-opt1.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REVIEW.md create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/SOURCE-CHECK.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/frame_encoder_v1.py.txt create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/host_preseal_writer.js.txt create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/ENCODER-INDEPENDENT.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/FINAL-DELTA.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/HOST-INDEPENDENT.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/HOST-JSON-NUMBER-COUNTEREXAMPLE.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/INGRESS-INDEPENDENT.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/INTERMEDIATE-7001e2ba.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REJECTED-b62f61f9.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-author-host.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-author-ingress.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-transferred-22.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-transferred-35.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REVIEW-final.json create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REVIEW-final.md create mode 100644 research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/selected_child_preseal_v1.py.txt diff --git a/research/h25-v02-parent-custody-evidence/CONTRIBUTOR-TASK.md b/research/h25-v02-parent-custody-evidence/CONTRIBUTOR-TASK.md new file mode 100644 index 0000000000..938125b324 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/CONTRIBUTOR-TASK.md @@ -0,0 +1,13 @@ +# Contributor request: reconcile and specify the original origin join + +Please take one bounded integration review of the authenticated parent-to-child pre-seal join. Start with `snapshots/direct-v02-entry/run_direct_v02.py.txt` at `RootProxy._run` and its `_prebirth_v02` call, then `snapshots/parent-owner-adaptation/supervisor_outer_read_v1.py.txt` at `run_root`, and `snapshots/trusted-preseal-ingress/selected_child_preseal_v1.py.txt` at `prepare_selected_child`, `install_before_capture` and `_receive_v02_preseal`. These exact public source files and their SHA pins are indexed in SOURCE-MAP.json. The repository prefix is `research/h25-v02-parent-custody-evidence/`. + +First reconcile the preserved intermediate/final imported-decoder findings that name identical child bytes. Compare their harness assumptions and callback/namespace identity checks against that exact source. A useful review must explain the three-callback/SEALED receipt and the final rejection receipt without silently changing source attribution or discarding the failing observation. The contradiction and required evidence are described in README.md. Until reconciled, the affected child source has no settled correctness qualification in this archive. + +Then specify the smallest source-owned join from the actual admitted original parent's prebirth result to the child's protected-origin expectation and its retained P bytes. The prospective anonymous-pipe insertion point lies after `_prebirth_v02` and before `run_root`; the public argv/kwargs/environment contract should remain explicit. Compare this with the existing ordinary host Tool failure and benign preloaded-FIFO point in TRANSPORT-POINT.md. Keep the source bootstrap and genuine issuer dependency visible: an approval flag, matching frame, FIFO identity or synthetic test record cannot replace it. + +The decisive acceptance is an exact-source, independently reviewed caller contract in which the authenticated original parent owns the complete-pinned preparation/P/E association and pipe lifecycle; only its one original selected child receives the frame; protected origin and descriptor stability are justified before child I/O; the actual original live-profile/issuer identities remain unchanged; and all failure paths preserve the first error, prevent unintended callbacks, close or explicitly retain uncertain resources, and bound the full caller's operations and costs. State unavailable external assumptions as unresolved dependencies. A source design with remaining prerequisites can be useful, but cannot count as a genuine original execution. + +Original V02 completion remains a separate final gate: run the eight genuine single-omission cases through the real caller, preserve the other seven decision identities in each case, reject before producer/native/fixture/compiler work, validate the fixed 36-event DATA independently, and close source, ownership, retirement and full costs. Report case acceptance over the fixed denominator eight. Existing inert controls and publication still count as zero original cases. + +Coordinate in the existing [verification contributor discussion](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166), crediting predecessors #6867, #6873, #6885 and #6910. This request is a handoff; it does not authorize live operations, new controller installation, accounting changes or guessed origin credentials. diff --git a/research/h25-v02-parent-custody-evidence/LICENSE b/research/h25-v02-parent-custody-evidence/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/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/h25-v02-parent-custody-evidence/MANIFEST.json b/research/h25-v02-parent-custody-evidence/MANIFEST.json new file mode 100644 index 0000000000..25055c2daf --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/MANIFEST.json @@ -0,0 +1,302 @@ +{ + "checks": "exact inventory, SHA-256, bytes, retained source mapping and AST syntax; zero imports/replays", + "files": [ + { + "bytes": 3400, + "path": "CONTRIBUTOR-TASK.md", + "sha256": "ef6cf07e3afb6d40a037d378ef0f2ec86b5bc292d86ab174b903c8b240b64be9" + }, + { + "bytes": 11357, + "path": "LICENSE", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "bytes": 443, + "path": "NOTICE.md", + "sha256": "b483c454c026a6f8fe8446a12c4b0e0a777a3324b062e1aeab2e2beaeb8afc97" + }, + { + "bytes": 1223, + "path": "PREDECESSORS.json", + "sha256": "8b9646dc74007cddf3bcb34656b4becf0d514931b7761613666c38daea2a9e43" + }, + { + "bytes": 9495, + "path": "README.md", + "sha256": "3f5b62e7977e92f618230cb1aadb8501841b7b6698be4ec9880bf23223e512b5" + }, + { + "bytes": 20920, + "path": "SOURCE-MAP.json", + "sha256": "168e369d25e6ddc5996f297a52f40ee0d5b78c227d80e9dbeb536dd7eec877e5" + }, + { + "bytes": 2863, + "path": "TRANSPORT-POINT.md", + "sha256": "ca932459c44e7cca0d2cb5d65c04bee43e04023c9e92fc4ca37c9217b8f9d8cf" + }, + { + "bytes": 2089, + "path": "check_integrity.py", + "sha256": "0c53180e7060bcca3e015d49e09e1d2b9d49814d0158fa41bdc876c5c7deb112" + }, + { + "bytes": 325, + "path": "snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt0.json", + "sha256": "53947cc155d568c1b5c03fe6a0e0d680d4452edb7bd95d8570cd633afa3ab406" + }, + { + "bytes": 325, + "path": "snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt1.json", + "sha256": "67e04a3eaaa6ac2c5d74a063865841abc44ab5c3d49412aaefa2628081db17c1" + }, + { + "bytes": 332, + "path": "snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt0.json", + "sha256": "450733dbae5716b0fdf64aa5f222e28526cc2416f7e13caafa24cc8a993b9ef2" + }, + { + "bytes": 332, + "path": "snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt1.json", + "sha256": "564693adacee0380f8f3903ba55bd3e11c1ce99227292116cc9a434327272a9e" + }, + { + "bytes": 304, + "path": "snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt0.json", + "sha256": "95fabbaf4d436c577b0c222310af8eabbb5b3a6533c78f3884583b08ef2cb167" + }, + { + "bytes": 304, + "path": "snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt1.json", + "sha256": "8fe3365d0688346d055444629c0dd219993b03ce308bc2ffda70fbec9530cd3c" + }, + { + "bytes": 2898, + "path": "snapshots/direct-v02-entry/independent-review/REPLAY-opt0.json", + "sha256": "dfca48588de89a135ce3fdd3ca5ebdc98f6a98b3bf2f2ede3a25728a2116fcd3" + }, + { + "bytes": 2898, + "path": "snapshots/direct-v02-entry/independent-review/REPLAY-opt1.json", + "sha256": "fca70a2439620948559261d899ac63c4c8f52ab2f3e854f61827bbcffe97accf" + }, + { + "bytes": 7171, + "path": "snapshots/direct-v02-entry/independent-review/REVIEW.md", + "sha256": "fb843c3181f3500ada82faee500bebc1710ce02964fc812ecfb0990372d9fac6" + }, + { + "bytes": 286, + "path": "snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt0.json", + "sha256": "1dac533297381ab97c0791132e33d7c8e9362928e18cdad5d13b99e832ce19fa" + }, + { + "bytes": 286, + "path": "snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt1.json", + "sha256": "7d97b01b083aaebf0ac5d9fb6c60f745cf173078452bebdda48790c7c34598d8" + }, + { + "bytes": 761, + "path": "snapshots/direct-v02-entry/independent-review/probe_controls-opt0.json", + "sha256": "840197d94050117f3ae938825b147c93a66ef336dde0b8e7d7732ab6f3bf300d" + }, + { + "bytes": 761, + "path": "snapshots/direct-v02-entry/independent-review/probe_controls-opt1.json", + "sha256": "b64d9020f7a6f9f8bec037b0c3d755d8c018b52f6e40070045b7ee69161d6de1" + }, + { + "bytes": 321, + "path": "snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt0.json", + "sha256": "7467579fc7e18b82f7e015de5fcc70b810e3d19e7813f7d97fdea0807128fbc3" + }, + { + "bytes": 321, + "path": "snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt1.json", + "sha256": "28b337c37a5cfff4dfc91a91ae3c2b0b1941ae2540639fbbf489af379310102b" + }, + { + "bytes": 265, + "path": "snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt0.json", + "sha256": "f4d4a4367ef482638f7128ec688d24ca36ef559881cce835236287526620ff82" + }, + { + "bytes": 265, + "path": "snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt1.json", + "sha256": "1c50bcff9172b34a4650b5398adec612492f59410c1bd1ba1ebf34f483281549" + }, + { + "bytes": 50919, + "path": "snapshots/direct-v02-entry/run_direct_v02.py.txt", + "sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422" + }, + { + "bytes": 780, + "path": "snapshots/paired-prebirth-child/independent-review/REPLAY-normal.json", + "sha256": "244b9c0f56557e6331b27a103144a4dac9bfd0679e4455d6de85bc3853c64c05" + }, + { + "bytes": 780, + "path": "snapshots/paired-prebirth-child/independent-review/REPLAY-optimized.json", + "sha256": "be1f72747e44c743e3b5f9989651ff0339e0cf722649bf02112d7c823dc2e136" + }, + { + "bytes": 2885, + "path": "snapshots/paired-prebirth-child/independent-review/REVIEW-final.md", + "sha256": "815d1a5dcef297125dce001607d071d1324e3ce52262ba5247f01dcc33dc7421" + }, + { + "bytes": 1510, + "path": "snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt0.json", + "sha256": "d16169a17e6973a7ce1fcddbe588487e74070f250b353f8203e9f8d18d3cf705" + }, + { + "bytes": 1510, + "path": "snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt1.json", + "sha256": "7993d1771fe0317eb5ebb81ade34d707d092011d9ffbeaed63df9717b136495a" + }, + { + "bytes": 202, + "path": "snapshots/parent-owner-adaptation/independent-review/PATH-TYPE-GUARD-cefcf1f7.json", + "sha256": "a6d8f43c8b9f51778c96d44d9f4d1fa8606b870666bdfa4fe63c6130535f58d6" + }, + { + "bytes": 2205, + "path": "snapshots/parent-owner-adaptation/independent-review/REPLAY-opt0.json", + "sha256": "ef3f0f8f4bf8830c53255a43b778ec0cc3cc4f8dfc836e18b7b8b60858fd0fd4" + }, + { + "bytes": 2205, + "path": "snapshots/parent-owner-adaptation/independent-review/REPLAY-opt1.json", + "sha256": "97115a71b5bf3f59c28717856f671963fad498d5495c2546d7f85767164471a4" + }, + { + "bytes": 3583, + "path": "snapshots/parent-owner-adaptation/independent-review/REVIEW-final.md", + "sha256": "c69538634f7d6b8cdcb65cd61783f6165a01991f4cf62f0b4bcb25e278761e19" + }, + { + "bytes": 907, + "path": "snapshots/parent-owner-adaptation/independent-review/SOURCE-COMPARISON-final.json", + "sha256": "f8a3fdb1590145360997b3eae9b747117cafd94d1272a5c01e2110f0d8723c0e" + }, + { + "bytes": 110940, + "path": "snapshots/parent-owner-adaptation/supervisor_outer_read_v1.py.txt", + "sha256": "a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a" + }, + { + "bytes": 1054, + "path": "snapshots/parent-terminal-join/independent-review/PROFILE-opt0.json", + "sha256": "6d0be03bf4fc981810752a9831c716f6c3c7cab317cc5c5d047e731457fd26ba" + }, + { + "bytes": 1054, + "path": "snapshots/parent-terminal-join/independent-review/PROFILE-opt1.json", + "sha256": "2d1176d02ffbb330f952fdc3ef6de62b714a3c2b6b113997d4dbe5197d350876" + }, + { + "bytes": 2455, + "path": "snapshots/parent-terminal-join/independent-review/REPLAY-opt0.json", + "sha256": "93726995eecc32e5768aa32c734329a0e4bdde4db563095680ee636f61ecf9e5" + }, + { + "bytes": 2455, + "path": "snapshots/parent-terminal-join/independent-review/REPLAY-opt1.json", + "sha256": "02e75f0577b6db05f2173f0073b9df45b9207105039c310e3f902251ce74d9cd" + }, + { + "bytes": 3771, + "path": "snapshots/parent-terminal-join/independent-review/REVIEW.md", + "sha256": "a520f787510e4852238c247ddaca55f583e739feae15d5702221c2d8fcec6b81" + }, + { + "bytes": 578, + "path": "snapshots/parent-terminal-join/independent-review/SOURCE-CHECK.json", + "sha256": "f1de5aa0519481c54e464965256c17107418a7ecc1c412edae5642d4d448891a" + }, + { + "bytes": 8065, + "path": "snapshots/trusted-preseal-ingress/frame_encoder_v1.py.txt", + "sha256": "7fe7abcee99f3629bbc6bb73b86c76c5580607806432cf10c622018c18299700" + }, + { + "bytes": 8966, + "path": "snapshots/trusted-preseal-ingress/host_preseal_writer.js.txt", + "sha256": "b5f7af26ea0cb3702cddd792061f434c055a7146ed726a6317395559a44c2bb9" + }, + { + "bytes": 1501, + "path": "snapshots/trusted-preseal-ingress/review/ENCODER-INDEPENDENT.json", + "sha256": "bfc3bcee03a52003e3e5cbcfb288b25e59e45eb561d1779d4f612e9e75df3015" + }, + { + "bytes": 695, + "path": "snapshots/trusted-preseal-ingress/review/FINAL-DELTA.json", + "sha256": "91a278dbcfb148e9d73ebef89696e35b48be03ec30c05d04c2aa2a02b557e0e3" + }, + { + "bytes": 1628, + "path": "snapshots/trusted-preseal-ingress/review/HOST-INDEPENDENT.json", + "sha256": "4dfa1578dbd7a090a8ae0726a693e79e3ab391547ce7ce976054f523ef441e01" + }, + { + "bytes": 330, + "path": "snapshots/trusted-preseal-ingress/review/HOST-JSON-NUMBER-COUNTEREXAMPLE.json", + "sha256": "bec168ce3546eb6e87767c53cd462db02cf0c4d9b7cc42e9fe8732a57c0654d1" + }, + { + "bytes": 2103, + "path": "snapshots/trusted-preseal-ingress/review/INGRESS-INDEPENDENT.json", + "sha256": "bd74779a39172a77185bf118faccf4a6804ae97fd7c6e0de2ce27ce33d47f4bb" + }, + { + "bytes": 481, + "path": "snapshots/trusted-preseal-ingress/review/INTERMEDIATE-7001e2ba.json", + "sha256": "1ae26dddbdd917481e5972b4b98eca21a48733eefd04f1585741b7583b42f807" + }, + { + "bytes": 963, + "path": "snapshots/trusted-preseal-ingress/review/REJECTED-b62f61f9.json", + "sha256": "ce63e4869f2be8b8de62a2e7adaff5cbd9dad3d99b1f30f516bc826134419e92" + }, + { + "bytes": 1841, + "path": "snapshots/trusted-preseal-ingress/review/REPLAY-author-host.json", + "sha256": "71036e691fbfda4231bc44538ee1d3f36504e4483f9f7e176485f343704b63a0" + }, + { + "bytes": 3055, + "path": "snapshots/trusted-preseal-ingress/review/REPLAY-author-ingress.json", + "sha256": "d155d27a3ddd898d43634a627498adddd615cb5a84c1e0415c734b7e58b4626b" + }, + { + "bytes": 9868, + "path": "snapshots/trusted-preseal-ingress/review/REPLAY-transferred-22.json", + "sha256": "4d90871ed430ef362b45ef10f69af2601b4c928263908d76a99c05cecef68e35" + }, + { + "bytes": 4522, + "path": "snapshots/trusted-preseal-ingress/review/REPLAY-transferred-35.json", + "sha256": "3a18512f246d0e54db74c0e6fd35a79cf8c1e38d517e27733a656105f252f18f" + }, + { + "bytes": 3363, + "path": "snapshots/trusted-preseal-ingress/review/REVIEW-final.json", + "sha256": "6db9bd22e5e34eef213d0f4e29553713a58de16680618566dabdf6a01b29e35c" + }, + { + "bytes": 5500, + "path": "snapshots/trusted-preseal-ingress/review/REVIEW-final.md", + "sha256": "0209ec0656367538ed48e17daffad5664db8d5c78ac06c8766fc8f9bfc0d7ac6" + }, + { + "bytes": 120929, + "path": "snapshots/trusted-preseal-ingress/selected_child_preseal_v1.py.txt", + "sha256": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048" + } + ], + "manifest_self_hash": "excluded; commit and review pin the manifest itself", + "schema": "v02-parent-archive-integrity-v1" +} diff --git a/research/h25-v02-parent-custody-evidence/NOTICE.md b/research/h25-v02-parent-custody-evidence/NOTICE.md new file mode 100644 index 0000000000..514d468c25 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/NOTICE.md @@ -0,0 +1 @@ +Original source notices and the encoder's Apache-2.0 SPDX identifier remain byte-for-byte intact. Predecessor contributors retain credit; see PREDECESSORS.json and PRs #6867, #6873, #6885 and #6910. The accompanying LICENSE preserves the repository license. This archive and its earlier source/review work used OpenAI AI assistance. Independent reviews in this archive are separate AI reviews, not human approval or proof-kernel verification. diff --git a/research/h25-v02-parent-custody-evidence/PREDECESSORS.json b/research/h25-v02-parent-custody-evidence/PREDECESSORS.json new file mode 100644 index 0000000000..62ed27ec7e --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/PREDECESSORS.json @@ -0,0 +1,32 @@ +{ + "dependencies": [ + { + "disposition": "adapt", + "head": "319ea1c5f4097ef87cc0b037327f26374e93e54d", + "pr": 6867, + "purpose": "Persistent outer read ownership and primary-preserving failure continuation." + }, + { + "disposition": "adapt", + "head": "ae7add49484492b49b0141445fbfd6002858da54", + "pr": 6873, + "purpose": "Bounded original-parent framing and single-session ownership; no inherited original operation authority." + }, + { + "disposition": "adapt", + "head": "6f9457478d22fa31c1e26b98ca4ee1ed43129ac4", + "pr": 6885, + "purpose": "Selected-child source/custody, queue wrapper and supervisor; original run_root and OwnedDomain remain unchanged in reviewed supervisor." + }, + { + "disposition": "review-only", + "head": "3ff875875cb608907c175a7e319370b7b2f7c005", + "pr": 6910, + "purpose": "Separate exact import-order audit context; supplies no original V02 live-profile or bootstrap admission." + } + ], + "merged_status_confers_no_runtime_admission": true, + "metadata_refreshed_utc_date": "2026-11-10", + "publication_base": "e54523517d0f03e58352e647c403a5af3e525a57", + "repository": "CrocSwap/integer-mult-bounds" +} diff --git a/research/h25-v02-parent-custody-evidence/README.md b/research/h25-v02-parent-custody-evidence/README.md new file mode 100644 index 0000000000..98335ba839 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/README.md @@ -0,0 +1,50 @@ +# V02 parent custody and pre-seal evidence archive + +This source-inspection archive makes the final direct parent caller, persistent read owner and prospective pre-seal channel available for contributor review. It preserves exact source bytes and earlier conditional AI review receipts, including a conflicting intermediate/final receipt for the same child digest. **Original V02 omission acceptance remains 0/8; original activity completion remains zero.** Publication supplies no new runtime admission, measured cost, performance gain or mathematical result. + +The next missing integration is an authenticated original parent-to-child origin join. The ordinary direct caller refuses at `_require_original_fresh_round` before I/O; the ordinary child has no protected origin, and the host writer has null installation/admission inputs. The benign preloaded-FIFO point establishes transport feasibility under its stated constraints, without closing those seams. The [contributor task](CONTRIBUTOR-TASK.md) names the actual owning functions and a decisive next acceptance condition. + +## Read the evidence in this order + +| Artifact | Exact retained source | Interpretation | +| --- | --- | --- | +| Direct caller | [run_direct_v02.py.txt](snapshots/direct-v02-entry/run_direct_v02.py.txt), SHA `976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422` | Actual selected main/RootProxy and finalization were reviewed with inert Root/native seams; ordinary admission remains closed. | +| Persistent parent read owner | [supervisor_outer_read_v1.py.txt](snapshots/parent-owner-adaptation/supervisor_outer_read_v1.py.txt), SHA `a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a` | Retains primary and uncertain-close state across post-Root reads. Bootstrap, locks and publication still require their own complete custody join. | +| Prospective child | [selected_child_preseal_v1.py.txt](snapshots/trusted-preseal-ingress/selected_child_preseal_v1.py.txt), SHA `7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048` | Requires independently authenticated protected-origin state before fd0 observation. Conflicting receipts for this exact digest remain unresolved below. | +| Pure encoder | [frame_encoder_v1.py.txt](snapshots/trusted-preseal-ingress/frame_encoder_v1.py.txt), SHA `7fe7abcee99f3629bbc6bb73b86c76c5580607806432cf10c622018c18299700` | Canonical ASCII representation and complete pin associations; no substantive decision authority. | +| Prospective host | [host_preseal_writer.js.txt](snapshots/trusted-preseal-ingress/host_preseal_writer.js.txt), SHA `b5f7af26ea0cb3702cddd792061f434c055a7146ed726a6317395559a44c2bb9` | Carries opaque Python frame bytes, preserving integer pins that JavaScript cannot represent exactly. Native Tool channel remains incompatible with its ordinary route. | + +All snapshots are inert text. The `.py` encoder receives only a `.txt` filename suffix; its bytes are unchanged. [SOURCE-MAP.json](SOURCE-MAP.json) records the exact original collection-relative path, exported path, byte count and SHA for every retained source, review and receipt. The original collection was preserved. Older near-duplicate source versions, test harnesses and fixture trees are intentionally outside this curated export. References to them in verbatim historical reviews or receipt inventories are historical references, not assertions that those files are included. The top-level manifest alone defines this archive's inventory. + +## Inherited evidence and its limits + +These are recorded results from the prior research activity. Publication did not rerun them. The reviews are independent AI reviews rather than human or proof-kernel acceptance. + +| Historical review | Recorded scope | +| --- | --- | +| [Parent owner](snapshots/parent-owner-adaptation/independent-review/REVIEW-final.md) | 24 author controls and five independent probes in each Python mode. Earlier wrapper error ordering and callback-bearing path equality failed and were corrected. The wrapper reviewed here is a historical ancestor, digest-indexed in SOURCE-MAP. | +| [Terminal join](snapshots/parent-terminal-join/independent-review/REVIEW.md) | 19 author controls in each mode, actual selected prebirth/RootProxy path with inert Root/native seams, 14 persistent tickets and both installed parser paths. Reduced receiver-profile counterexample retained. This ancestor still used the queue entry requiring a science receipt. | +| [Paired parent/child](snapshots/paired-prebirth-child/independent-review/REVIEW-final.md) | Six author controls plus two independent falsifiers in each mode. The same P bytes reached actual selected parent/child functions, with a fake process birth and explicit test issuer. Detached E stayed with the parent. Neither reviewed ancestor is a live channel. | +| [Direct entry](snapshots/direct-v02-entry/independent-review/REVIEW.md) | 33 author controls and seven independent checks in each mode. Actual main, RootProxy and parser declarations with inert Root/native seams. The positive 25-ticket count excludes bootstrap, registry and separate prebirth acquisitions. Changed-final-charge and receiver-substitution rejection receipts are retained. | +| [Pre-seal](snapshots/trusted-preseal-ingress/review/REVIEW-final.md) | Final review reports 23 ingress, 12 host, transferred 35 typed and 22 predecessor controls, plus 10/9/6 independent ingress/encoder/host controls. Transferred controls bypass ingress. The same-digest discrepancy below prevents treating this record as settled correctness qualification. | + +The preserved [intermediate receipt](snapshots/trusted-preseal-ingress/review/INTERMEDIATE-7001e2ba.json) marks child SHA `7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048` as requiring imported-decoder reconciliation and records three foreign callbacks followed by SEALED. The [final review receipt](snapshots/trusted-preseal-ingress/review/REVIEW-final.json) names that identical SHA and reports final conditional acceptance; [INGRESS-INDEPENDENT.json](snapshots/trusted-preseal-ingress/review/INGRESS-INDEPENDENT.json) reports imported-decoder replacement rejection. The preserved intermediate source bytes also equal the final source bytes. These are genuinely conflicting recorded findings. They are exported unchanged; source attribution, harness assumptions and chronology need reconciliation. The archive does not silently select one finding or claim that publication resolves the discrepancy. + +Full original work still needs independently authenticated source bootstrap and exact protected state; genuine eight decision issuers; actual live Root/provider/API4 profile; the original one-shot parent/child path; complete lock, write, descriptor and descendant ownership; fixed 36-event DATA observation with independent existing wire/family validation; every omission refused before producer/native/fixture/compiler work; a complete resource census; and external terminal and cost settlement. Shallow receiver snapshots require protection of nested mutable state. The parent owner's 128 cumulative read-ticket cap is a bound requiring an actual complete count, not evidence that the complete path fits. Stored `OPEN_NOT_ZERO` values are not settlement. + +The related source-owned census-controller study remains contextual and is omitted because its source includes private operational accounting. Its final source digest is `aab094cc2aa43729c0a4640eae725759ca30478dd0d273c59be23de586aa212e`; review digest is `1a85db80b2a608cc6891b2f14af85fe0fabe628776bc0853eff7ac75e896f8b8`. Its recorded 20 inert prospective-entry cases do not supply authentic scope/funding, the actual writer census, full external metering, or a genuine origin issuer. No private source or accounting amount is exported. + +## Static archive check + +From repository root: + +```sh +python3 -I -S -B research/h25-v02-parent-custody-evidence/check_integrity.py +python3 -I -S -B -O research/h25-v02-parent-custody-evidence/check_integrity.py +``` + +The checker validates the exact file inventory, sizes, SHA-256 values, retained mapping and Python syntax via AST. It neither imports nor runs any snapshot and does not replay historical controls. The manifest hashes every other file, including the checker, and is itself pinned by the publication commit. These checks establish archival integrity only. No registered replay hook is provided. Reproducing research would require the separately pinned predecessor packages, original harness/fixture provenance and independently authorized original runtime; this archive is self-contained for source inspection, not a turnkey replay bundle. + +## Attribution and public context + +[PREDECESSORS.json](PREDECESSORS.json) pins the refreshed heads and specific reuse disposition for [#6867](https://github.com/CrocSwap/integer-mult-bounds/pull/6867), [#6873](https://github.com/CrocSwap/integer-mult-bounds/pull/6873), [#6885](https://github.com/CrocSwap/integer-mult-bounds/pull/6885) and [#6910](https://github.com/CrocSwap/integer-mult-bounds/pull/6910), all observed merged under publication base `e54523517d0f03e58352e647c403a5af3e525a57`. Merge supplies no current runtime credit. Original authors retain credit and source notices; LICENSE and NOTICE.md travel with this archive. Related work is organized in the [verification overview](https://github.com/CrocSwap/integer-mult-bounds/pull/6321#issuecomment-6713710045) and [contributor discussion](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166). diff --git a/research/h25-v02-parent-custody-evidence/SOURCE-MAP.json b/research/h25-v02-parent-custody-evidence/SOURCE-MAP.json new file mode 100644 index 0000000000..ce8a8979fb --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/SOURCE-MAP.json @@ -0,0 +1,423 @@ +{ + "omitted": [ + "Private controller/donor source and all operational/funding/host records; only sanitized contextual source digests appear in README.", + "Candidate builders, replay scripts, fixtures, older duplicate sources and private consultation records. Original review receipts can name these omitted historical inputs; those references are not package manifest entries.", + "Predecessor wrapper 8fcf1e5749eb35c1cccbc84ea694c10f6dba7e4c72f26cdb0ee744338ea3a4c7 and terminal wrapper 80b3a03c3bce5324efd272390d59d6f41210a0eade13ec8bbf9b9bad051eb197 are historical review subjects, superseded by the retained direct entry.", + "Paired review parent 186905e138135e35e05172d18800ecdfe3328f40bb9e52707195bdfb85a64de8 and child 926edbf69c4e296edfd8ebcdebfb66cf07e9c5551a1a0aec03450954310cbff2 are historical subjects, not the final preseal source." + ], + "original_files_modified": false, + "receipt_caveat": "INTERMEDIATE-7001e2ba.json and REVIEW-final.json name the same full child digest but differ in their imported-decoder finding. Both are retained unchanged. Receipt chronology/source attribution is unresolved; no historical replay was performed for publication.", + "retained": [ + { + "archive_relative_path": "snapshots/direct-v02-entry/run_direct_v02.py.txt", + "bytes": 50919, + "kind": "final_source", + "original_relative_path": "direct-v02-entry/run_direct_v02.py.txt", + "sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-owner-adaptation/supervisor_outer_read_v1.py.txt", + "bytes": 110940, + "kind": "final_source", + "original_relative_path": "parent-owner-adaptation/supervisor_outer_read_v1.py.txt", + "sha256": "a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/selected_child_preseal_v1.py.txt", + "bytes": 120929, + "kind": "final_source", + "original_relative_path": "trusted-preseal-ingress/selected_child_preseal_v1.py.txt", + "sha256": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/frame_encoder_v1.py.txt", + "bytes": 8065, + "kind": "final_source", + "original_relative_path": "trusted-preseal-ingress/frame_encoder_v1.py", + "sha256": "7fe7abcee99f3629bbc6bb73b86c76c5580607806432cf10c622018c18299700", + "transformation": "none; filename-only .txt suffix for encoder" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/host_preseal_writer.js.txt", + "bytes": 8966, + "kind": "final_source", + "original_relative_path": "trusted-preseal-ingress/host_preseal_writer.js.txt", + "sha256": "b5f7af26ea0cb3702cddd792061f434c055a7146ed726a6317395559a44c2bb9", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/REVIEW.md", + "bytes": 7171, + "kind": "conditional_ai_review", + "original_relative_path": "direct-v02-entry/independent-review/REVIEW.md", + "sha256": "fb843c3181f3500ada82faee500bebc1710ce02964fc812ecfb0990372d9fac6", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-owner-adaptation/independent-review/REVIEW-final.md", + "bytes": 3583, + "kind": "conditional_ai_review", + "original_relative_path": "parent-owner-adaptation/independent-review/REVIEW-final.md", + "sha256": "c69538634f7d6b8cdcb65cd61783f6165a01991f4cf62f0b4bcb25e278761e19", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-terminal-join/independent-review/REVIEW.md", + "bytes": 3771, + "kind": "conditional_ai_review", + "original_relative_path": "parent-terminal-join/independent-review/REVIEW.md", + "sha256": "a520f787510e4852238c247ddaca55f583e739feae15d5702221c2d8fcec6b81", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/paired-prebirth-child/independent-review/REVIEW-final.md", + "bytes": 2885, + "kind": "conditional_ai_review", + "original_relative_path": "paired-prebirth-child/independent-review/REVIEW-final.md", + "sha256": "815d1a5dcef297125dce001607d071d1324e3ce52262ba5247f01dcc33dc7421", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/REVIEW-final.md", + "bytes": 5500, + "kind": "conditional_ai_review", + "original_relative_path": "trusted-preseal-ingress/review/REVIEW-final.md", + "sha256": "0209ec0656367538ed48e17daffad5664db8d5c78ac06c8766fc8f9bfc0d7ac6", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt0.json", + "bytes": 325, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt0.json", + "sha256": "53947cc155d568c1b5c03fe6a0e0d680d4452edb7bd95d8570cd633afa3ab406", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt1.json", + "bytes": 325, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt1.json", + "sha256": "67e04a3eaaa6ac2c5d74a063865841abc44ab5c3d49412aaefa2628081db17c1", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt0.json", + "bytes": 332, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/FINAL-LEDGER-opt0.json", + "sha256": "450733dbae5716b0fdf64aa5f222e28526cc2416f7e13caafa24cc8a993b9ef2", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt1.json", + "bytes": 332, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/FINAL-LEDGER-opt1.json", + "sha256": "564693adacee0380f8f3903ba55bd3e11c1ce99227292116cc9a434327272a9e", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt0.json", + "bytes": 304, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt0.json", + "sha256": "95fabbaf4d436c577b0c222310af8eabbb5b3a6533c78f3884583b08ef2cb167", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt1.json", + "bytes": 304, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt1.json", + "sha256": "8fe3365d0688346d055444629c0dd219993b03ce308bc2ffda70fbec9530cd3c", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/REPLAY-opt0.json", + "bytes": 2898, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/REPLAY-opt0.json", + "sha256": "dfca48588de89a135ce3fdd3ca5ebdc98f6a98b3bf2f2ede3a25728a2116fcd3", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/REPLAY-opt1.json", + "bytes": 2898, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/REPLAY-opt1.json", + "sha256": "fca70a2439620948559261d899ac63c4c8f52ab2f3e854f61827bbcffe97accf", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt0.json", + "bytes": 286, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/probe_control_receiver-opt0.json", + "sha256": "1dac533297381ab97c0791132e33d7c8e9362928e18cdad5d13b99e832ce19fa", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt1.json", + "bytes": 286, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/probe_control_receiver-opt1.json", + "sha256": "7d97b01b083aaebf0ac5d9fb6c60f745cf173078452bebdda48790c7c34598d8", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/probe_controls-opt0.json", + "bytes": 761, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/probe_controls-opt0.json", + "sha256": "840197d94050117f3ae938825b147c93a66ef336dde0b8e7d7732ab6f3bf300d", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/probe_controls-opt1.json", + "bytes": 761, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/probe_controls-opt1.json", + "sha256": "b64d9020f7a6f9f8bec037b0c3d755d8c018b52f6e40070045b7ee69161d6de1", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt0.json", + "bytes": 321, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/probe_final_ledger-opt0.json", + "sha256": "7467579fc7e18b82f7e015de5fcc70b810e3d19e7813f7d97fdea0807128fbc3", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt1.json", + "bytes": 321, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/probe_final_ledger-opt1.json", + "sha256": "28b337c37a5cfff4dfc91a91ae3c2b0b1941ae2540639fbbf489af379310102b", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt0.json", + "bytes": 265, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/probe_initial_receiver-opt0.json", + "sha256": "f4d4a4367ef482638f7128ec688d24ca36ef559881cce835236287526620ff82", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt1.json", + "bytes": 265, + "kind": "inherited_receipt", + "original_relative_path": "direct-v02-entry/independent-review/probe_initial_receiver-opt1.json", + "sha256": "1c50bcff9172b34a4650b5398adec612492f59410c1bd1ba1ebf34f483281549", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt0.json", + "bytes": 1510, + "kind": "inherited_receipt", + "original_relative_path": "parent-owner-adaptation/independent-review/INDEPENDENT-opt0.json", + "sha256": "d16169a17e6973a7ce1fcddbe588487e74070f250b353f8203e9f8d18d3cf705", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt1.json", + "bytes": 1510, + "kind": "inherited_receipt", + "original_relative_path": "parent-owner-adaptation/independent-review/INDEPENDENT-opt1.json", + "sha256": "7993d1771fe0317eb5ebb81ade34d707d092011d9ffbeaed63df9717b136495a", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-owner-adaptation/independent-review/PATH-TYPE-GUARD-cefcf1f7.json", + "bytes": 202, + "kind": "inherited_receipt", + "original_relative_path": "parent-owner-adaptation/independent-review/PATH-TYPE-GUARD-cefcf1f7.json", + "sha256": "a6d8f43c8b9f51778c96d44d9f4d1fa8606b870666bdfa4fe63c6130535f58d6", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-owner-adaptation/independent-review/REPLAY-opt0.json", + "bytes": 2205, + "kind": "inherited_receipt", + "original_relative_path": "parent-owner-adaptation/independent-review/REPLAY-opt0.json", + "sha256": "ef3f0f8f4bf8830c53255a43b778ec0cc3cc4f8dfc836e18b7b8b60858fd0fd4", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-owner-adaptation/independent-review/REPLAY-opt1.json", + "bytes": 2205, + "kind": "inherited_receipt", + "original_relative_path": "parent-owner-adaptation/independent-review/REPLAY-opt1.json", + "sha256": "97115a71b5bf3f59c28717856f671963fad498d5495c2546d7f85767164471a4", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-owner-adaptation/independent-review/SOURCE-COMPARISON-final.json", + "bytes": 907, + "kind": "inherited_receipt", + "original_relative_path": "parent-owner-adaptation/independent-review/SOURCE-COMPARISON-final.json", + "sha256": "f8a3fdb1590145360997b3eae9b747117cafd94d1272a5c01e2110f0d8723c0e", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-terminal-join/independent-review/PROFILE-opt0.json", + "bytes": 1054, + "kind": "inherited_receipt", + "original_relative_path": "parent-terminal-join/independent-review/PROFILE-opt0.json", + "sha256": "6d0be03bf4fc981810752a9831c716f6c3c7cab317cc5c5d047e731457fd26ba", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-terminal-join/independent-review/PROFILE-opt1.json", + "bytes": 1054, + "kind": "inherited_receipt", + "original_relative_path": "parent-terminal-join/independent-review/PROFILE-opt1.json", + "sha256": "2d1176d02ffbb330f952fdc3ef6de62b714a3c2b6b113997d4dbe5197d350876", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-terminal-join/independent-review/REPLAY-opt0.json", + "bytes": 2455, + "kind": "inherited_receipt", + "original_relative_path": "parent-terminal-join/independent-review/REPLAY-opt0.json", + "sha256": "93726995eecc32e5768aa32c734329a0e4bdde4db563095680ee636f61ecf9e5", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-terminal-join/independent-review/REPLAY-opt1.json", + "bytes": 2455, + "kind": "inherited_receipt", + "original_relative_path": "parent-terminal-join/independent-review/REPLAY-opt1.json", + "sha256": "02e75f0577b6db05f2173f0073b9df45b9207105039c310e3f902251ce74d9cd", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/parent-terminal-join/independent-review/SOURCE-CHECK.json", + "bytes": 578, + "kind": "inherited_receipt", + "original_relative_path": "parent-terminal-join/independent-review/SOURCE-CHECK.json", + "sha256": "f1de5aa0519481c54e464965256c17107418a7ecc1c412edae5642d4d448891a", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/paired-prebirth-child/independent-review/REPLAY-normal.json", + "bytes": 780, + "kind": "inherited_receipt", + "original_relative_path": "paired-prebirth-child/independent-review/REPLAY-normal.json", + "sha256": "244b9c0f56557e6331b27a103144a4dac9bfd0679e4455d6de85bc3853c64c05", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/paired-prebirth-child/independent-review/REPLAY-optimized.json", + "bytes": 780, + "kind": "inherited_receipt", + "original_relative_path": "paired-prebirth-child/independent-review/REPLAY-optimized.json", + "sha256": "be1f72747e44c743e3b5f9989651ff0339e0cf722649bf02112d7c823dc2e136", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/ENCODER-INDEPENDENT.json", + "bytes": 1501, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/ENCODER-INDEPENDENT.json", + "sha256": "bfc3bcee03a52003e3e5cbcfb288b25e59e45eb561d1779d4f612e9e75df3015", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/FINAL-DELTA.json", + "bytes": 695, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/FINAL-DELTA.json", + "sha256": "91a278dbcfb148e9d73ebef89696e35b48be03ec30c05d04c2aa2a02b557e0e3", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/HOST-INDEPENDENT.json", + "bytes": 1628, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/HOST-INDEPENDENT.json", + "sha256": "4dfa1578dbd7a090a8ae0726a693e79e3ab391547ce7ce976054f523ef441e01", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/HOST-JSON-NUMBER-COUNTEREXAMPLE.json", + "bytes": 330, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/HOST-JSON-NUMBER-COUNTEREXAMPLE.json", + "sha256": "bec168ce3546eb6e87767c53cd462db02cf0c4d9b7cc42e9fe8732a57c0654d1", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/INGRESS-INDEPENDENT.json", + "bytes": 2103, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/INGRESS-INDEPENDENT.json", + "sha256": "bd74779a39172a77185bf118faccf4a6804ae97fd7c6e0de2ce27ce33d47f4bb", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/INTERMEDIATE-7001e2ba.json", + "bytes": 481, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/INTERMEDIATE-7001e2ba.json", + "sha256": "1ae26dddbdd917481e5972b4b98eca21a48733eefd04f1585741b7583b42f807", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/REJECTED-b62f61f9.json", + "bytes": 963, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/REJECTED-b62f61f9.json", + "sha256": "ce63e4869f2be8b8de62a2e7adaff5cbd9dad3d99b1f30f516bc826134419e92", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/REPLAY-author-host.json", + "bytes": 1841, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/REPLAY-author-host.json", + "sha256": "71036e691fbfda4231bc44538ee1d3f36504e4483f9f7e176485f343704b63a0", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/REPLAY-author-ingress.json", + "bytes": 3055, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/REPLAY-author-ingress.json", + "sha256": "d155d27a3ddd898d43634a627498adddd615cb5a84c1e0415c734b7e58b4626b", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/REPLAY-transferred-22.json", + "bytes": 9868, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/REPLAY-transferred-22.json", + "sha256": "4d90871ed430ef362b45ef10f69af2601b4c928263908d76a99c05cecef68e35", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/REPLAY-transferred-35.json", + "bytes": 4522, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/REPLAY-transferred-35.json", + "sha256": "3a18512f246d0e54db74c0e6fd35a79cf8c1e38d517e27733a656105f252f18f", + "transformation": "none" + }, + { + "archive_relative_path": "snapshots/trusted-preseal-ingress/review/REVIEW-final.json", + "bytes": 3363, + "kind": "inherited_receipt", + "original_relative_path": "trusted-preseal-ingress/review/REVIEW-final.json", + "sha256": "6db9bd22e5e34eef213d0f4e29553713a58de16680618566dabdf6a01b29e35c", + "transformation": "none" + } + ], + "schema": "v02-parent-source-inspection-archive-map-v1", + "snapshot_byte_comparison": "Every retained snapshot is byte-identical to the stated collection-relative source.", + "source_collection": "s05-v02-original-gate-continuation-20261110T2018Z" +} diff --git a/research/h25-v02-parent-custody-evidence/TRANSPORT-POINT.md b/research/h25-v02-parent-custody-evidence/TRANSPORT-POINT.md new file mode 100644 index 0000000000..931f90e489 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/TRANSPORT-POINT.md @@ -0,0 +1,20 @@ +# Observed transport points and remaining origin gap + +This is a sanitized summary of earlier point observations. It contains no host identity, operational paths, process IDs, accounting records or transcript. The underlying private records were preserved, not exported. This publication did not repeat their commands. + +| Prior observation | Result and precise scope | +| --- | --- | +| Actual Tool `tty:false, login:false` | fd0 was a character device, returned immediate zero-byte EOF and offered no writable retained session. This route cannot feed the candidate's FIFO-only ingress. | +| Actual Tool raw PTY | 63-byte and 32,768-byte samples arrived correctly, but fd0 remained a character device and fails the current FIFO condition. Successful byte transport alone does not qualify the channel. | +| Fresh anonymous pipe | Capacity was 8,192 bytes; `PIPE_BUF` was 4,096. A private request to increase capacity to 32,768 failed with EPERM. This is a point observation, not a universal Linux configuration claim. | +| Benign preloaded FIFO | With a narrower prospective frame bound, one nonblocking preload succeeded and the sole writer closed before benign child birth. GNU Time passed the same FIFO, exact bytes and EOF to that child. No original parent, protected-origin assignment, genuine decisions or full cost accounting ran. | + +The narrower prospective frame domain allows three unescaped printable-ASCII paths of at most 512 characters, three printable identifiers of at most 96 characters, and uint64 metadata. A deliberately overbounding combination produced 3,613 canonical bytes including LF, fitting the observed capacity and atomic-write bound. This restricted domain is a proposed transport assumption, not a source change, current complete source census, or accepted policy for every valid original input. The shipped general encoder and ingress still retain their own wider bounds. The preload design has not been joined to the original caller. + +Private observation record digests for audit continuity: + +- `TOOL-STDIN-CAPABILITY-POINT-v1.json`: `fdc1e8e33125cecb91325288138f9cc82daac79092445e9b42bfca816672f1c4`. +- `NATIVE-TIME-FD0-POINT-v1.json`: `633a3af60755b22a62bc018c7aef947e07dcc0062b4a4a193cb37661ee3d18ef`. +- `PARENT-PRELOADED-FIFO-FEASIBILITY-v1.json`: `80b14118c4c1b7352305d3e3fcb73aea81deda79e9d600d614a3f12f45701c22`. + +These digests identify omitted observations; readers cannot independently reconstruct their private contents from this summary. They confer no operational permission or authenticity. FIFO shape, endpoint identity, expected hashes and an ACK never establish protected origin. A real join must establish independently authenticated original writer/session authority, sole-reader custody, descriptor stability throughout the frame interval, preparation/P continuity, and every failure's cleanup/first-error ownership. diff --git a/research/h25-v02-parent-custody-evidence/check_integrity.py b/research/h25-v02-parent-custody-evidence/check_integrity.py new file mode 100644 index 0000000000..7d50a47bd9 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/check_integrity.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""Validate archive bytes and Python syntax only; never import archived candidates.""" +import ast +import hashlib +import json +from pathlib import Path + +root = Path(__file__).resolve().parent +def require(ok, reason): + if not ok: + raise SystemExit(reason) + +manifest_path = root / "MANIFEST.json" +require(not manifest_path.is_symlink(), "manifest must be a regular local file") +manifest = json.loads(manifest_path.read_text()) +require(manifest.get("schema") == "v02-parent-archive-integrity-v1", "manifest schema mismatch") +entries = manifest["files"] +names = [row["path"] for row in entries] +require(len(names) == len(set(names)), "duplicate manifest path") +actual = set() +for path in root.rglob("*"): + require(not path.is_symlink(), "symlink prohibited") + if path.is_file(): + actual.add(path.relative_to(root).as_posix()) +require(actual == set(names) | {"MANIFEST.json"}, "archive inventory mismatch") +for row in entries: + name = row["path"] + require(not Path(name).is_absolute() and ".." not in Path(name).parts, "nonlocal manifest path") + raw = (root / name).read_bytes() + require(len(raw) == row["bytes"], "byte count mismatch: " + name) + require(hashlib.sha256(raw).hexdigest() == row["sha256"], "digest mismatch: " + name) +source_map = json.loads((root / "SOURCE-MAP.json").read_text()) +indexed = {row["path"]: row for row in entries} +parsed = 0 +for row in source_map["retained"]: + name = row["archive_relative_path"] + require(name in indexed, "source mapping missing from manifest") + require(all(row[key] == indexed[name][key] for key in ("bytes", "sha256")), "source map mismatch") + if row["kind"] == "final_source" and name.endswith(".py.txt"): + ast.parse((root / name).read_text(), filename=name) + parsed += 1 +print(json.dumps({"status": "PASS_STATIC_ARCHIVE_INTEGRITY", "manifest_entries": len(entries), + "retained_snapshots": len(source_map["retained"]), "python_snapshots_ast_parsed": parsed, + "candidate_imports": 0, "historical_replays": 0, "original_v02_cases": 0}, sort_keys=True)) diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt0.json new file mode 100644 index 0000000000..cc8faa88a9 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt0.json @@ -0,0 +1,13 @@ +{ + "candidate_sha256": "e4a77627392cd59bc381e80f49cbe3f5dbcb880a8bc191e61b20031f0e142227", + "config_reads": 2, + "foreign_callbacks": [ + "/INERT/v02/control/policy.json" + ], + "lock_close": 1, + "optimize": 0, + "original_launches": 0, + "outward_foreign_error": true, + "packet_calls": 0, + "primary_retained": true +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt1.json new file mode 100644 index 0000000000..05990952fb --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/CONTROL-RECEIVER-e4a776-opt1.json @@ -0,0 +1,13 @@ +{ + "candidate_sha256": "e4a77627392cd59bc381e80f49cbe3f5dbcb880a8bc191e61b20031f0e142227", + "config_reads": 2, + "foreign_callbacks": [ + "/INERT/v02/control/policy.json" + ], + "lock_close": 1, + "optimize": 1, + "original_launches": 0, + "outward_foreign_error": true, + "packet_calls": 0, + "primary_retained": true +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt0.json new file mode 100644 index 0000000000..1537d5cb69 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt0.json @@ -0,0 +1,11 @@ +{ + "candidate_sha256": "b08e769533eef4e05717c48a0d0fd6f76089cb1c98847f419df587e665849eaf", + "error_type": null, + "final_ledger_charge": 0.9, + "optimize": 0, + "original_launches": 0, + "published_nested_runner_seconds": 0.9, + "published_status": "SCOPED_V02_DATA_OBSERVED", + "retained_runner_charge": 0.2, + "root_calls": 1 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt1.json new file mode 100644 index 0000000000..695872f2a1 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/FINAL-LEDGER-opt1.json @@ -0,0 +1,11 @@ +{ + "candidate_sha256": "b08e769533eef4e05717c48a0d0fd6f76089cb1c98847f419df587e665849eaf", + "error_type": null, + "final_ledger_charge": 0.9, + "optimize": 1, + "original_launches": 0, + "published_nested_runner_seconds": 0.9, + "published_status": "SCOPED_V02_DATA_OBSERVED", + "retained_runner_charge": 0.2, + "root_calls": 1 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt0.json new file mode 100644 index 0000000000..6266ad293a --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt0.json @@ -0,0 +1,12 @@ +{ + "candidate_sha256": "e4a77627392cd59bc381e80f49cbe3f5dbcb880a8bc191e61b20031f0e142227", + "foreign_callbacks": [ + "/INERT/v02/control/policy.json" + ], + "optimize": 0, + "original_launches": 0, + "outward_foreign_error": true, + "packet_calls": 0, + "primary_retained": true, + "root_calls": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt1.json new file mode 100644 index 0000000000..5bbf9dd43c --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/INITIAL-RECEIVER-e4a776-opt1.json @@ -0,0 +1,12 @@ +{ + "candidate_sha256": "e4a77627392cd59bc381e80f49cbe3f5dbcb880a8bc191e61b20031f0e142227", + "foreign_callbacks": [ + "/INERT/v02/control/policy.json" + ], + "optimize": 1, + "original_launches": 0, + "outward_foreign_error": true, + "packet_calls": 0, + "primary_retained": true, + "root_calls": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REPLAY-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REPLAY-opt0.json new file mode 100644 index 0000000000..0d51ad6594 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REPLAY-opt0.json @@ -0,0 +1,48 @@ +{ + "authentic_source_bootstrap_funding_joined": false, + "authority_seam": "selected namespace dependency replacement only", + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "checks": [ + "ordinary main refuses before I/O without authentic bootstrap/fresh funding", + "actual main direct RootProxy retained original receipt predicates and finalization", + "actual main read-close retains primary and suppresses generic finally/retry", + "actual main read retains primary and suppresses generic finally/retry", + "actual main close retains primary and suppresses generic finally/retry", + "actual main open retains primary and suppresses generic finally/retry", + "original unit receipt predicate rejects stage_sha256", + "original unit receipt predicate rejects runner_sha256", + "original unit receipt predicate rejects budget_phase_sha256", + "original unit receipt predicate rejects parent_launch", + "original unit receipt predicate rejects command", + "original unit receipt predicate rejects fractions_sha256", + "original unit receipt predicate rejects label", + "original unit receipt predicate rejects job", + "original unit receipt predicate rejects log_read_chunk_bytes", + "original unit receipt predicate rejects runner_wall_seconds", + "original unit receipt predicate rejects spent_before_seconds", + "actual main rejects extra-ledger with protected finalization", + "actual main rejects changed-prior with protected finalization", + "actual main rejects missing-current with protected finalization", + "actual main rejects ledger-read with protected finalization", + "actual main rejects start-mismatch with protected finalization", + "actual main rejects late-read-close with protected finalization", + "actual main rejects lock-close with protected finalization", + "actual main rejects final-current-charge with protected finalization", + "full eleven-module receiver drift rejected before first post-root receipt", + "actual main initial-config receiver mutation refuses before replacement callback", + "actual main final-config receiver mutation refuses before replacement callback", + "actual main launch receiver mutation refuses before replacement callback", + "actual main subreaper receiver mutation refuses before replacement callback", + "actual main setup-write receiver mutation refuses before replacement callback", + "actual main final-write receiver mutation refuses before replacement callback", + "actual main has no generic queue main/finally or skip-unclosed path" + ], + "cost_status": "OPEN_NOT_ZERO", + "optimize": 0, + "original_launches": 0, + "original_v02_complete": false, + "passed": 33, + "positive_outer_tickets": 25, + "schema": "v02-direct-main-inert-replay-v1", + "terminal_parser_pair": "exact installed observer/wire/family modules" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REPLAY-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REPLAY-opt1.json new file mode 100644 index 0000000000..6d6c5f00d9 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REPLAY-opt1.json @@ -0,0 +1,48 @@ +{ + "authentic_source_bootstrap_funding_joined": false, + "authority_seam": "selected namespace dependency replacement only", + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "checks": [ + "ordinary main refuses before I/O without authentic bootstrap/fresh funding", + "actual main direct RootProxy retained original receipt predicates and finalization", + "actual main read-close retains primary and suppresses generic finally/retry", + "actual main read retains primary and suppresses generic finally/retry", + "actual main close retains primary and suppresses generic finally/retry", + "actual main open retains primary and suppresses generic finally/retry", + "original unit receipt predicate rejects stage_sha256", + "original unit receipt predicate rejects runner_sha256", + "original unit receipt predicate rejects budget_phase_sha256", + "original unit receipt predicate rejects parent_launch", + "original unit receipt predicate rejects command", + "original unit receipt predicate rejects fractions_sha256", + "original unit receipt predicate rejects label", + "original unit receipt predicate rejects job", + "original unit receipt predicate rejects log_read_chunk_bytes", + "original unit receipt predicate rejects runner_wall_seconds", + "original unit receipt predicate rejects spent_before_seconds", + "actual main rejects extra-ledger with protected finalization", + "actual main rejects changed-prior with protected finalization", + "actual main rejects missing-current with protected finalization", + "actual main rejects ledger-read with protected finalization", + "actual main rejects start-mismatch with protected finalization", + "actual main rejects late-read-close with protected finalization", + "actual main rejects lock-close with protected finalization", + "actual main rejects final-current-charge with protected finalization", + "full eleven-module receiver drift rejected before first post-root receipt", + "actual main initial-config receiver mutation refuses before replacement callback", + "actual main final-config receiver mutation refuses before replacement callback", + "actual main launch receiver mutation refuses before replacement callback", + "actual main subreaper receiver mutation refuses before replacement callback", + "actual main setup-write receiver mutation refuses before replacement callback", + "actual main final-write receiver mutation refuses before replacement callback", + "actual main has no generic queue main/finally or skip-unclosed path" + ], + "cost_status": "OPEN_NOT_ZERO", + "optimize": 1, + "original_launches": 0, + "original_v02_complete": false, + "passed": 33, + "positive_outer_tickets": 25, + "schema": "v02-direct-main-inert-replay-v1", + "terminal_parser_pair": "exact installed observer/wire/family modules" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REVIEW.md b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REVIEW.md new file mode 100644 index 0000000000..2c1c54f49f --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/REVIEW.md @@ -0,0 +1,20 @@ +Conditionally accepted the direct V02 entry source at SHA-256 `976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422` for the source-selected caller and inert integration scope below. This is not genuine bootstrap, funding or execution admission. Ordinary `main` refuses unconditionally at `_require_original_fresh_round` before the clock, argument parser, source loading or any I/O. The positive tests replace that missing dependency only inside their selected namespace and install the pre-existing private admission tuple through a test trace; they do not supply a production issuer. + +Independent replays passed all 33 author controls in both isolated ordinary and optimized Python. The actual selected `main`, constructor, `RootProxy`, prebirth checks, retained receipt validator, observer and installed wire/family parser functions execute against benign memory I/O and an inert Root result. The positive fixture uses 25 cumulative persistent outer read tickets. This count excludes authentic bootstrap, financial-registry operations and the separate copying-owned prebirth acquisitions, so it is not an operational total. [Normal author replay](REPLAY-opt0.json) · [Optimized author replay](REPLAY-opt1.json) + +Seven additional independent checks passed in each interpreter mode: three behavioral probes plus the reversible-source check in `probe_controls.py`, final-charge drift, final-control receiver substitution, and initial-control receiver substitution. Late receiver change during the retained unit ledger scan is rejected before either parser and before packet finalization. An uncertain post-Root read preserves the original exception, the read-close exception and the distinct lock-close exception while avoiding the late final-directory resolver, all ledger reads and packet reads. The default entry also refuses when even the clock is replaced with a failure sentinel. [Normal independent controls](probe_controls-opt0.json) · [Optimized independent controls](probe_controls-opt1.json) + +Review rejected two intervening source versions and retained exact evidence: + +- `b08e769533eef4e05717c48a0d0fd6f76089cb1c98847f419df587e665849eaf`. Its first ledger scan validated a current charge of 0.2, but a second scan returning 0.9 still produced `SCOPED_V02_DATA_OBSERVED` and published the changed nested charge. The final source requires the current amount to equal the retained validated receipt amount before cost publication. The independent reproduction now refuses and publishes neither wrapper status nor nested charge. [Rejected normal evidence](FINAL-LEDGER-opt0.json) · [Rejected optimized evidence](FINAL-LEDGER-opt1.json) · [Corrected normal probe](probe_final_ledger-opt0.json) · [Corrected optimized probe](probe_final_ledger-opt1.json) +- `e4a77627392cd59bc381e80f49cbe3f5dbcb880a8bc191e61b20031f0e142227` still allowed a configuration read to substitute the receiver used for the next policy read. This occurred both during initial `read_json` acquisition and during final `stable_file` revalidation. The foreign callback actually ran and its exception became primary. The final source checks freshness between these calls, uses `_unit_read` for final control reads, and adds checks after setup and publication callbacks. Both independent substitution probes now record zero foreign callbacks, preserve the freshness failure and perform no packet read. [Rejected initial probe](INITIAL-RECEIVER-e4a776-opt0.json) · [Rejected final probe](CONTROL-RECEIVER-e4a776-opt0.json) · [Corrected initial probe](probe_initial_receiver-opt0.json) · [Corrected final probe](probe_control_receiver-opt0.json) + +The builder was evaluated with its output calls excluded. Its inverse reconstructs reviewed predecessor `80b3a03c3bce5324efd272390d59d6f41210a0eade13ec8bbf9b9bad051eb197` byte for byte, and its generated source equals the candidate. Independent AST/source comparison found only `RootProxy`, `_observe_v02` and `main` changed among previous declarations, with `_require_original_fresh_round`, `_unit_read` and `_validate_retained_unit` added. The underlying supervisor, `run_root`, `OwnedDomain` and retained installed parser files are dependencies; this activity does not modify them. + +The original queue obligations were inspected against its exact source `1348a7b4d7cc1f9fef556f5e0abdaf04411a998afdcd574d7812c76ab37dcf68`. Its trusted-launch declaration is retained and executed from authenticated bytes. The adapted validator preserves stage/runner/budget/fractions identity, launch provenance and flags, START consistency, label/job, successful original receipt status, custody/log flags, raw stream hashes/counts/caps, bounded chunk size, stderr, timing and aggregate ledger checks. It runs before the observer parsers. Strict runner-ledger scans require the baseline plus exactly the current label, unchanged prior amounts and the retained current charge through finalization. The existing strict budget ledger rejects unclosed prior run folders; the direct caller rejects a previously registered label. Original safe case-identity validation remains in `run_root`, and the prebirth route checks the pinned stage before calling it. + +The scientific receipt lookup is intentionally omitted only for the restricted component-unit case with `IMPLEMENTED_UNIT_PASS` and empty scientific fields. No replacement science receipt is fabricated. The original queue's extra stream copies, gate file, per-case printed result and its unconditional cost-writing `finally` are bypassed. The retained original streams and unit result remain on the source-owned proxy; the enclosing direct wrapper records its own elapsed and self-plus-child CPU scopes and subtracts the consistent runner charge. Its terminal metadata explicitly keeps `original_v02_complete=False`, `runtime_admitted=False`, `cost_status=OPEN_NOT_ZERO` and a required external final-tail reconciliation. These accounting formulas and inert values establish no measured original cost or settled terminal state. + +Acceptance assumes independently authenticated modules and protected exact private owner/admission state. Receiver snapshots are shallow; nested configuration and owner state still require their stated external protection. `source_packet` performs bootstrap acquisitions before this persistent owner and still needs its actual source/custody implementation. Original parent-lock internal acquisition/close failures, native publication ownership, complete source/member and ticket bounds, genuine selected financial registry binding, original one-shot execution and terminal settlement remain outside this acceptance. The runner subledger cannot substitute for the selected fresh financial registry or its genuine current owner. The ordinary refusing seam cannot be lifted by an approval boolean or synthetic funding data. + +This review performed zero original Root/Popen/supervisor/guest/producer executions, zero privilege actions and zero public actions. It accepted zero original V02 omission cases and completed zero original V02 launch activities. It accepts the exact bounded source adaptation and its inert caller behavior after the recorded corrections. diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt0.json new file mode 100644 index 0000000000..f36b7b2134 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt0.json @@ -0,0 +1,11 @@ +{ + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "config_reads": 2, + "foreign_callbacks": [], + "lock_close": 1, + "optimize": 0, + "original_launches": 0, + "outward_foreign_error": false, + "packet_calls": 0, + "primary_retained": true +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt1.json new file mode 100644 index 0000000000..576f3a0b24 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_control_receiver-opt1.json @@ -0,0 +1,11 @@ +{ + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "config_reads": 2, + "foreign_callbacks": [], + "lock_close": 1, + "optimize": 1, + "original_launches": 0, + "outward_foreign_error": false, + "packet_calls": 0, + "primary_retained": true +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_controls-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_controls-opt0.json new file mode 100644 index 0000000000..1eeccd88f6 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_controls-opt0.json @@ -0,0 +1,23 @@ +{ + "added_declarations": [ + "_require_original_fresh_round", + "_unit_read", + "_validate_retained_unit" + ], + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "changed_declarations": [ + "RootProxy", + "_observe_v02", + "main" + ], + "checks": [ + "receiver drift in retained unit ledger stops before both parsers and packet finalization", + "uncertain post-root read keeps first error, close error and distinct lock close while skipping resolver", + "ordinary main refuses before clock, launch, parser and I/O", + "builder reversed byte-exactly with only three changed and three added declarations" + ], + "optimize": 0, + "original_cases_accepted": 0, + "original_launches": 0, + "passed": 4 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_controls-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_controls-opt1.json new file mode 100644 index 0000000000..0cc349a3ed --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_controls-opt1.json @@ -0,0 +1,23 @@ +{ + "added_declarations": [ + "_require_original_fresh_round", + "_unit_read", + "_validate_retained_unit" + ], + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "changed_declarations": [ + "RootProxy", + "_observe_v02", + "main" + ], + "checks": [ + "receiver drift in retained unit ledger stops before both parsers and packet finalization", + "uncertain post-root read keeps first error, close error and distinct lock close while skipping resolver", + "ordinary main refuses before clock, launch, parser and I/O", + "builder reversed byte-exactly with only three changed and three added declarations" + ], + "optimize": 1, + "original_cases_accepted": 0, + "original_launches": 0, + "passed": 4 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt0.json new file mode 100644 index 0000000000..375afa4c58 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt0.json @@ -0,0 +1,11 @@ +{ + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "error_type": "RuntimeError", + "final_ledger_charge": 0.9, + "optimize": 0, + "original_launches": 0, + "published_nested_runner_seconds": null, + "published_status": null, + "retained_runner_charge": 0.2, + "root_calls": 1 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt1.json new file mode 100644 index 0000000000..e159259376 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_final_ledger-opt1.json @@ -0,0 +1,11 @@ +{ + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "error_type": "RuntimeError", + "final_ledger_charge": 0.9, + "optimize": 1, + "original_launches": 0, + "published_nested_runner_seconds": null, + "published_status": null, + "retained_runner_charge": 0.2, + "root_calls": 1 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt0.json new file mode 100644 index 0000000000..9c1c93e027 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt0.json @@ -0,0 +1,10 @@ +{ + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "foreign_callbacks": [], + "optimize": 0, + "original_launches": 0, + "outward_foreign_error": false, + "packet_calls": 0, + "primary_retained": true, + "root_calls": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt1.json new file mode 100644 index 0000000000..661cf40424 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/independent-review/probe_initial_receiver-opt1.json @@ -0,0 +1,10 @@ +{ + "candidate_sha256": "976f1116a5d28a9092cdabf965678a7774743c8e7198aca46f2e1c3cc96f6422", + "foreign_callbacks": [], + "optimize": 1, + "original_launches": 0, + "outward_foreign_error": false, + "packet_calls": 0, + "primary_retained": true, + "root_calls": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/run_direct_v02.py.txt b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/run_direct_v02.py.txt new file mode 100644 index 0000000000..2e8ee82a7a --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/direct-v02-entry/run_direct_v02.py.txt @@ -0,0 +1,893 @@ +"""Same-process subreaper wrapper around byte-unchanged reviewed queue v4. + +The actual consumer is this wrapper plus its explicitly narrow subprocess alias +proxy and supervisor. The queue's calling environment is deliberately extended; +its original bytes and real root status/stdout/stderr remain independently pinned. +""" +import argparse +import resource +import os +import ast +import hashlib +import importlib.util as _importlib_util +import json +from pathlib import Path +import subprocess +import sys +import time + +# Exact primitive-key and native descriptor checks reused from reviewed e156. +import types +_TYPE, _LEN = type, len +_MODULE_TYPE, _FUNCTION_TYPE, _CELL_TYPE = types.ModuleType, types.FunctionType, types.CellType +_DICT_TYPE, _TUPLE_TYPE, _STR_TYPE = dict, tuple, str +_MODULE_DICT = _MODULE_TYPE.__dict__['__dict__'].__get__ +_FUNCTION_GETTERS = tuple(_FUNCTION_TYPE.__dict__[name].__get__ for name in + ('__code__', '__globals__', '__builtins__', '__defaults__', '__kwdefaults__', '__closure__', '__dict__')) +_CELL_GET = _CELL_TYPE.__dict__['cell_contents'].__get__ +_EMPTY_CELL = object() +_OUTER_LAST = [None] + +class ScopedParentStop(RuntimeError): + pass + + +def _need(condition, reason): + if condition is not True: + raise ScopedParentStop(reason) + + +def _cell_value(cell): + _need(_TYPE(cell) is _CELL_TYPE, 'exact source closure cell required') + try: + return _CELL_GET(cell, _CELL_TYPE) + except ValueError: + return _EMPTY_CELL + + +def _mapping_items(mapping): + # Reused selected-binder rule: exact native mapping, finite complete key + # census BEFORE membership/subscript/set/sort/hash/equality or items lookup. + _need(_TYPE(mapping) is _DICT_TYPE, 'exact receiver mapping required') + _need(_LEN(mapping) <= 512, 'receiver mapping bound exceeded') + for key in mapping: + _need(_TYPE(key) is _STR_TYPE and _LEN(key) <= 256, + 'foreign receiver mapping key') + return _TUPLE_TYPE(mapping.items()) + + +def _module_namespace(module): + _need(_TYPE(module) is _MODULE_TYPE, 'exact source module type required') + namespace = _MODULE_DICT(module, _MODULE_TYPE) + items = _mapping_items(namespace) + return namespace, items + + +def _function_values(function): + _need(_TYPE(function) is _FUNCTION_TYPE, 'exact source function required') + return _TUPLE_TYPE(getter(function, _FUNCTION_TYPE) for getter in _FUNCTION_GETTERS) + + +def _capture_receivers(modules): + """Retain identities before factory/gates; no input authenticates itself. + + These shallow namespace plus function-layout snapshots cover receiver and + transitive module-global replacement and in-place code/default/cell changes. + They are not a recursive immutable source profile or external source seal. + """ + rows = [] + for module in modules: + namespace, items = _module_namespace(module) + functions = [] + for unused, function in items: + if _TYPE(function) is _FUNCTION_TYPE: + values = _function_values(function) + keywords, closure = values[4], values[5] + keyword_items = None if keywords is None else _mapping_items(keywords) + if closure is not None: + _need(_TYPE(closure) is _TUPLE_TYPE and _LEN(closure) <= 64, + 'bounded exact source closure required') + cells = () if closure is None else _TUPLE_TYPE(_cell_value(c) for c in closure) + functions.append((function, values, keyword_items, cells)) + rows.append((module, namespace, items, _TUPLE_TYPE(functions))) + return _TUPLE_TYPE(rows) + + +def _receivers_unchanged(profile): + for module, namespace, items, functions in profile: + actual_namespace, actual_items = _module_namespace(module) + if actual_namespace is not namespace or _LEN(actual_items) != _LEN(items): + return False + for key, value in items: + if key not in namespace or namespace[key] is not value: + return False + for function, values, keyword_items, cells in functions: + actual = _function_values(function) + if any(value is not expected for value, expected in zip(actual, values)): + return False + keywords, closure = actual[4], actual[5] + if keywords is not None: + actual_keywords = _mapping_items(keywords) + if _LEN(actual_keywords) != _LEN(keyword_items): + return False + for key, value in keyword_items: + if key not in keywords or keywords[key] is not value: + return False + if closure is not None: + _need(_TYPE(closure) is _TUPLE_TYPE and _LEN(closure) <= 64, + 'bounded exact source closure required') + if _LEN(closure) != _LEN(cells) or any(_cell_value(c) is not v for c, v in zip(closure, cells)): + return False + return True + + + +def _stop_outer(state, error, secondary=False): + # Protected exact private state. No receiver or diagnostic callback follows + # a failed receiver freshness check. + state['phase'] = 'STOP' + if secondary and state['secondary'] is None: + state['secondary'] = error + if state['primary'] is None: + state['primary'] = error + + +def _outer_fresh(supervisor, profile, state): + _need(_receivers_unchanged(profile), 'outer supervisor receiver changed') + namespace, unused = _module_namespace(supervisor) + _need(namespace['_PARENT_READ_IO'] is state, 'outer retained read owner changed') + if state['primary'] is not None: + raise state['primary'] + _need(state['phase'] == 'ACTIVE' and not state['unknown'], 'outer read ownership is pending') + + +def _finish_packet(supervisor, profile, state, directory, manifest): + """Actual main-finalization gate, with no further reads after STOP.""" + if state['primary'] is not None or state['phase'] != 'ACTIVE' or state['unknown']: + return False + try: + _outer_fresh(supervisor, profile, state) + supervisor.packet_unchanged(directory, manifest) + _outer_fresh(supervisor, profile, state) + return True + except BaseException as error: + _stop_outer(state, error) + return False + + +def source_packet(expected): + here = Path(__file__).resolve().parent + manifest_path = here / 'SOURCE-READINESS.json' + if manifest_path.is_symlink() or manifest_path.stat().st_mode & 0o222: + raise RuntimeError('Concrete source manifest must be readonly') + with manifest_path.open('rb') as stream: + raw = stream.read(262145) + if len(raw) > 262144 or hashlib.sha256(raw).hexdigest() != expected: + raise RuntimeError('Parent-reviewed source manifest differs') + manifest = json.loads(raw) + blobs = {} + for name, row in manifest['files'].items(): + if Path(name).name != name or name == 'SOURCE-READINESS.json': + raise RuntimeError('Unsafe source packet member') + path = here / name + if path.is_symlink() or path.stat().st_mode & 0o222: + raise RuntimeError('Parent must freeze the concrete source packet readonly') + with path.open('rb') as stream: + data = stream.read(262145) + if len(data) > 262144 or len(data) != row['bytes'] or hashlib.sha256(data).hexdigest() != row['sha256']: + raise RuntimeError('Source packet member differs: ' + name) + blobs[name] = data + if blobs[Path(__file__).name] != Path(__file__).read_bytes(): + raise RuntimeError('Actual queue entry differs from frozen source packet') + path = here / 'supervisor.py' + spec = _importlib_util.spec_from_file_location('h25_parent_supervisor', path) + module = _importlib_util.module_from_spec(spec) + exec(compile(blobs['supervisor.py'], str(path), 'exec'), module.__dict__) + return module, manifest + + + + +# No production provider or setter exists for this private admission. Source +# review and this data association do not establish original issuer authority. +# The only positive replay installs an independently supplied INERT owner seam. +_V02_PREBIRTH_SCOPE = None +_V02_PARENT_ENDORSEMENT_SCOPE = None +schema = copying = offline = anchor = configured = bindings = supervisor = orchestration = None +observation = preflight_wire = preflight_validator = None +_MAX_CHAIN_BYTES = 1048576 +_MAX_CASES = 1 +LAUNCH_FLAGS = ('-S', '-s', '-P', '-B') + + +def _prebirth_scope(proxy): + scope = _V02_PREBIRTH_SCOPE + _need(type(scope) is tuple and len(scope) == 7, + 'authentic singleton prebirth admission absent') + _need(scope[0] is proxy and scope[1] is proxy.outer, + 'foreign singleton parent read owner') + state, child, original, profile, child_bytes = scope[2:] + _need(type(state) is dict and type(child) is dict and type(original) is dict and + type(profile) is tuple and type(child_bytes) is bytes, + 'prebirth admission shape differs') + _mapping_items(state) + _mapping_items(original) + _need(state['original'] is original and supervisor is proxy.s, + 'foreign original parent or supervisor') + _need(len(profile) == 11 and all(type(row) is tuple and len(row) == 4 for row in profile), + 'prebirth receiver profile shape differs') + _need(all(row[0] is module for row, module in zip(profile, + (schema, copying, offline, anchor, configured, bindings, supervisor, orchestration, + observation, preflight_wire, preflight_validator))), + 'complete prebirth receiver profile absent') + _need(_receivers_unchanged(profile), 'prebirth receiver changed') + proxy._fresh() + _observation_bindings() + _plain(child) + _need(_canonical(child) == child_bytes, 'admitted child substituted or repinned') + _mapping_items(state['plan']) + _mapping_items(state['cases']) + case_state = state['cases'][child['case_id']] + _mapping_items(case_state) + _need(type(state['mode']) is str and state['mode'] == 'normal' and + type(state['plan']['root']) is str and state['plan']['root'] == str(proxy.root) and + type(case_state['unit_id']) is str and case_state['unit_id'] == 'variant/V02/python-preflight-v1', + 'singleton V02 normal parent context differs') + _need('expected_context' in child and type(child.get('raw_artifacts')) is list and + child['raw_artifacts'] == [], 'complete V02 observation declarations required') + return state, child + + +def _fresh(state): + scope = _V02_PREBIRTH_SCOPE + _need(type(scope) is tuple and len(scope) == 7 and scope[2] is state, + 'prebirth read escaped admitted parent') + _prebirth_scope(scope[0]) + + +def _prebirth_v02(proxy, case, command): + _need(proxy.prebirth_attempted is False, 'singleton prebirth attempt already consumed') + proxy.prebirth_attempted = True + state, child = _prebirth_scope(proxy) + proxy.observation_profile = _V02_PREBIRTH_SCOPE[5] + _need(len(proxy.cases) == 1 and _equal(case, child['queue_case']), + 'singleton queue case differs from original admission') + _validate_case_source(state, child) + # Repeat complete pinned reads for the separate derived inner Root argv. + # Detached E binds runner argv; it does not pretend to bind this different + # vector. Exact STAGE/JOBS plus unchanged runner determine the inner vector. + stage = Path(state['plan']['root']) / 'stages' / case['stage'] + stage_pin = copying.inspect(str(stage / 'STAGE.json'), schema.RECORD_BYTES, + error_owner=state['original']['errors']) + _need(stage_pin['sha256'] == case['stage_sha256'], 'stage changed during prebirth join') + declared = offline.decode(_read(state, stage_pin)) + jobs_pin = copying.inspect(str(stage / 'JOBS.json'), schema.RECORD_BYTES, + error_owner=state['original']['errors']) + _need(jobs_pin['sha256'] == declared['files']['JOBS.json']['sha256'], + 'jobs changed during prebirth join') + job = offline.decode(_read(state, jobs_pin))[case['job']] + folder = Path(state['plan']['root']) / 'runtime/runs' / case['label'] + inner = _derive_inner_root_argv(stage, folder, job, declared) + _fresh(state) + proxy.prebirth_evidence = {'runner_argv': tuple(command), 'root_argv': inner, + 'stage_sha256': case['stage_sha256'], 'runtime_authority': False} + + +def _derive_inner_root_argv(stage, folder, job, declared): + entry = job.get('entry', 'integration/full_driver.py') + command = ['/usr/bin/python3.12', *LAUNCH_FLAGS] + if job.get('optimized', False): + command.append('-O') + if 'entry' in job: + command.append(str(stage / entry)) + else: + command.append(str(stage / 'integration/full_driver.py')) + if 'bootstrap' in job: + bootstrap = job['bootstrap'] + if type(bootstrap) is not dict or set(bootstrap) != {'provider', 'driver'}: + raise ValueError('Exact bootstrap map required') + for relative in bootstrap.values(): + if (type(relative) is not str or relative not in declared['files'] or + Path(relative).is_absolute() or '..' in Path(relative).parts or + Path(relative).parent != Path('integration')): + raise ValueError('Bootstrap source must be a declared integration file') + command.extend(['--root-sha256', declared['files']['integration/full_driver.py']['sha256'], + '--provider', str(stage / bootstrap['provider']), + declared['files'][bootstrap['provider']]['sha256'], + '--driver', str(stage / bootstrap['driver']), + declared['files'][bootstrap['driver']]['sha256'], + '--integration', str(stage / 'integration'), '--']) + command.extend(['--output', str(folder / 'science'), '--lanes', job['lanes']]) + if job.get('finite_only', False): + command.append('--finite-only') + return tuple(command) + +def _canonical(value): + return json.dumps(value, sort_keys=True, separators=(',', ':'), ensure_ascii=True, + allow_nan=False).encode('ascii') + b'\n' + +def _read(state, pin, limit=_MAX_CHAIN_BYTES): + _fresh(state) + raw = copying.read_verified_complete_v3(pin, limit, error_owner=state['original']['errors']) + _fresh(state) + return raw + +def _plain(value, depth=0): + """Closed native data, including exact typed protocol projections only.""" + schema.need(depth <= 64, 'oracle traversal depth exceeded') + kind = type(value) + if value is None or kind is str or kind is bytes or kind is int or kind is bool: + return + schema.need(kind is tuple or kind is list or kind is dict, 'foreign oracle input rejected') + schema.need(len(value) <= 8192, 'oracle collection bound exceeded') + if kind is dict: + for key in value: + schema.need(type(key) is str, 'foreign oracle key') + schema.need('opaque_observation_tag' not in value, 'opaque runtime identity has no independent parent oracle') + for item in value.values() if kind is dict else value: + _plain(item, depth + 1) + +def _equal(actual, expected): + _plain(actual); _plain(expected) + if type(actual) is not type(expected): + return False + if type(actual) is dict: + return set(actual) == set(expected) and all(_equal(actual[k], expected[k]) for k in actual) + if type(actual) is tuple or type(actual) is list: + return len(actual) == len(expected) and all(_equal(a, b) for a, b in zip(actual, expected)) + return actual == expected + +def _validate_v02_parent_endorsement(state, child, plan, job=None, stage_doc=None): + """Associate exact retained inputs, conditional on independently authentic scope. + + This source candidate does not establish substantive issuer authorization. + Its private scope has no production provider and is closed by default. + """ + scope = _V02_PARENT_ENDORSEMENT_SCOPE + schema.need(type(scope) is tuple and len(scope) == 2 and + scope[0] is state['original'] and type(scope[1]) is tuple, + 'authentic original parent V02 endorsement scope absent') + rows = scope[1] + schema.need(len(rows) <= _MAX_CASES and all(type(row) is tuple and len(row) == 3 and + type(row[0]) is str and type(row[1]) is str and type(row[2]) is bytes and + len(row[2]) <= schema.RECORD_BYTES for row in rows), 'parent V02 scope shape differs') + selected = [row[2] for row in rows if row[:2] == (child['case_id'], child['generation'])] + schema.need(len(selected) == 1, 'exact original case generation endorsement absent or repeated') + endorsement_pin = offline.decode(selected[0]) + schema.blob(endorsement_pin, schema.RECORD_BYTES) + schema.need(_canonical(endorsement_pin) == selected[0] and + not endorsement_pin['identity']['mode'] & 0o222, 'parent endorsement pin is not exact immutable input') + schema.blob(plan['preflight_package'], schema.RECORD_BYTES) + schema.need(not plan['preflight_package']['identity']['mode'] & 0o222, + 'V02 preflight package is not immutable') + by_path = {pin['path']: pin for pin in child['source_pins']} + schema.need(plan['preflight_package']['path'] in by_path and + _equal(by_path[plan['preflight_package']['path']], plan['preflight_package']), + 'V02 preflight package omitted from complete child source custody') + schema.need(endorsement_pin['path'] not in by_path, 'parent endorsement entered child source custody') + endorsement = offline.decode(_read(state, endorsement_pin, schema.RECORD_BYTES)) + schema.exact(endorsement, ('schema', 'preflight_package', 'preparation', 'stage_sha256', + 'command_sha256', 'case_id', 'generation', 'unit_id', 'mode')) + case = child['queue_case']; root = Path(state['plan']['root']) + command = ['/usr/bin/python3.12', *supervisor.FLAGS, str(root / 'run_guarded_v3.py'), + case['stage'], case['job'], case['label']] + command_digest = hashlib.sha256(_canonical({'argv': command})).hexdigest() + schema.need(command_digest == child['command_sha256'], 'V02 canonical command differs before Root birth') + schema.need(_equal(endorsement, {'schema': 'h25-v02-parent-endorsement-v1', + 'preflight_package': plan['preflight_package'], 'preparation': child['preparation'], + 'stage_sha256': case['stage_sha256'], 'command_sha256': command_digest, + 'case_id': child['case_id'], 'generation': child['generation'], 'unit_id': 'variant/V02/python-preflight-v1', 'mode': 'normal'}), + 'parent endorsement differs from exact V02 final inputs') + # P is read through the original verified copier. Its substantive schema and + # gate checks belong to the child binder; no P schema is invented here. + package = offline.decode(_read(state, plan['preflight_package'], schema.RECORD_BYTES)) + # Reject direct E path/hash tokens without extending child record schemas. + # This limited guard is not a proof of the typed P/STAGE/JOBS dependency DAG. + # Encoded nested documents, aliases and substantive gate edges need the + # separately reviewed typed package closure at the actual binder boundary. + forbidden = (json.dumps(endorsement_pin['path'], ensure_ascii=True).encode('ascii'), + json.dumps(endorsement_pin['sha256'], ensure_ascii=True).encode('ascii')) + for value in (package, plan, child['source_pins'], job, stage_doc): + if value is not None: + encoded = _canonical(value) + schema.need(all(token not in encoded for token in forbidden), + 'parent endorsement backedge entered child input') + return None + +def _validate_child_preparation(state, child, job=None, stage_doc=None): + """Original same-operation parent authenticates actual late child inputs. + + All checks run before Root birth. The genuine original plan supplies this + pin; a child report, source review marker, or caller hash grants nothing. + The fixed existing runner transports exactly the checked JOBS lane bytes. + """ + schema.blob(child['preparation'], schema.RECORD_BYTES) + schema.need(not child['preparation']['identity']['mode'] & 0o222, + 'immutable same-operation child preparation required') + plan = offline.decode(_read(state, child['preparation'], schema.RECORD_BYTES)) + unit = state['cases'][child['case_id']]['unit_id'] + v02_normal = unit == 'variant/V02/python-preflight-v1' and state['mode'] == 'normal' + if v02_normal: + schema.exact(plan, ('schema', 'outer_context', 'entry_configuration', 'selection', 'preflight_package')) + schema.need(plan['schema'] == 'h25-selected-child-preparation-v02-v1', 'V02 child preparation schema differs') + else: + schema.exact(plan, ('schema', 'outer_context', 'entry_configuration', 'selection')) + schema.need(plan['schema'] == 'h25-selected-child-preparation-v1', 'child preparation schema differs') + kind = 'NATIVE_PRODUCTION' if unit in anchor.NATIVE_ACQUISITION_EXTENSION['units'] else 'HISTORICAL_PORT' + schema.need(_equal(plan['selection'], {'unit_id': unit, 'mode': state['mode'], 'kind': kind}), + 'original fixed unit cannot select another production/port image') + outer = offline.decode(_read(state, plan['outer_context'], schema.RECORD_BYTES)) + schema.exact(outer, ('schema', 'source_manifest', 'binding_plan', 'source_review_sha256', + 'bootstrap_review_sha256', 'command_review_sha256', 'root_source_sha256', 'runtime_premise_sha256')) + schema.need(outer['schema'] == 'h25-authenticated-pre-capture-context-v2' and + outer['root_source_sha256'] == anchor.SELECTED_ROOT_SHA256, 'actual original Root source differs') + for key in ('source_review_sha256','bootstrap_review_sha256','command_review_sha256','runtime_premise_sha256'): + schema.digest(outer[key]) + manifest = offline.decode(_read(state, outer['source_manifest'], schema.RECORD_BYTES)) + binding_plan = offline.decode(_read(state, outer['binding_plan'], schema.RECORD_BYTES)) + schema.exact(manifest, ('schema', 'modules')) + schema.exact(binding_plan, ('schema', 'bindings')) + schema.need(manifest['schema'] == 'h25-bootstrap-module-manifest-v2' and + binding_plan['schema'] == 'h25-pre-capture-bindings-v2', 'actual original installer records differ') + expected = anchor.SELECTED_CHILD_TEMPLATES[kind] + schema.exact(manifest['modules'], tuple(expected)) + by_path = {pin['path']: pin for pin in child['source_pins']} + for name, row in manifest['modules'].items(): + schema.exact(row, ('source', 'template_inverse')) + pin, inverse = row['source'], row['template_inverse'] + schema.need(pin['path'] in by_path and _equal(by_path[pin['path']], pin) and + inverse['module'] == name and inverse['template_sha256'] == expected[name] and + inverse['configured_sha256'] == pin['sha256'], + 'actual child module/template/source inverse is absent or substituted') + configured.verify_configured_source(_read(state, pin, 8388608), inverse) + values = binding_plan['bindings'] + schema.need(type(values) is dict and 'component_control_root_v1' in values and + type(values['component_control_root_v1']) is dict, 'actual fixed context installation omitted') + literal = values['component_control_root_v1'].get('CONTEXT_CONFIGURATION') + schema.need(type(literal) is str and _equal(bindings.ast.literal_eval(literal), child['context_configuration']), + 'actual source None context is not installed with original complete values') + receiver = offline.decode(_read(state, child['context_configuration']['receiver_policy'], schema.RECORD_BYTES)) + schema.need(_equal(receiver, {name: row['source'] for name,row in manifest['modules'].items()}), + 'actual receiver policy differs from complete constructor source manifest') + expected_entry = {'marker_path': child['start_marker'], 'case_id': child['case_id'], + 'context_id': child['context_id'], 'unit_id': unit, 'mode': state['mode'], 'guard': child['guard'], + 'publication_admission': orchestration.CONFIGURATION['publication_admission'], + 'publication_root': state['plan']['root']} + schema.need(_equal(plan['entry_configuration'], expected_entry), 'actual entry/guard/publication context differs') + # Every late dependency is already retained by the original complete source + # plan. The configured source bytes are frozen before these final inputs. + for pin in (child['preparation'], plan['outer_context'], outer['source_manifest'], outer['binding_plan'], + child['context_configuration']['receiver_policy']): + schema.need(pin['path'] in by_path and _equal(by_path[pin['path']], pin), + 'late input omitted from complete immutable child source custody') + if v02_normal: + _validate_v02_parent_endorsement(state, child, plan, job, stage_doc) + transport = json.dumps({'schema':'h25-selected-child-argv-v1','plan':child['preparation']}, + sort_keys=True, separators=(',', ':')) + if job is not None: + schema.need(job['lanes'] == transport, 'actual original runner lane is not authenticated final input') + return None + +def _validate_case_source(state, child): + case = child['queue_case']; root = Path(state['plan']['root']) + stage = root / 'stages' / case['stage'] + stage_pin = copying.inspect(str(stage / 'STAGE.json'), schema.RECORD_BYTES, + error_owner=state['original']['errors']) + schema.need(stage_pin['sha256'] == case['stage_sha256'], 'exact child immutable stage changed') + stage_doc = json.loads(_read(state, stage_pin)) + jobs_pin = copying.inspect(str(stage / 'JOBS.json'), schema.RECORD_BYTES, error_owner=state['original']['errors']) + schema.need(jobs_pin['sha256'] == stage_doc['files']['JOBS.json']['sha256'], 'complete declared jobs source differs') + job = json.loads(_read(state, jobs_pin))[case['job']] + schema.need(job.get('entry', 'integration/full_driver.py') == 'integration/full_driver.py' and + stage_doc['files']['integration/full_driver.py']['sha256'] == + 'f5a2d33f2b4d3651f214156a0e7094c2bb516ce2d5ab7698d18c11f98f35dee0', + 'each child must invoke the genuine unchanged Root') + driver = job['bootstrap']['driver'] + schema.need(stage_doc['files'][driver]['sha256'] == child['entry_source']['sha256'] and + child['entry_source']['path'] == str(stage / driver) and + child['entry_inverse']['template_sha256'] == anchor.STAGE_ENTRY_SHA256 and + job.get('optimized', False) is (state['mode'] == 'optimized'), + 'fixed canonical unit main adapter or actual mode differs') + schema.need(child['entry_inverse']['assignments'] == {} and job.get('finite_only', False) is False, + 'actual selected child needs fixed unconfigured entry and complete canonical Root tail') + _validate_child_preparation(state, child, job, stage_doc) + entry_values = configured.verify_configured_source(_read(state, child['entry_source']), child['entry_inverse']) + expected_entry = {'marker_path': child['start_marker'], + 'case_id': child['case_id'], 'context_id': child['context_id'], + 'unit_id': state['cases'][child['case_id']]['unit_id'], 'mode': state['mode'], 'guard':child['guard'], + 'publication_admission': orchestration.CONFIGURATION['publication_admission'], + 'publication_root': state['plan']['root']} + if 'START_CONFIGURATION' in entry_values: + schema.need(_equal(entry_values['START_CONFIGURATION'], expected_entry), + 'fixed pre-target stage entry context/identity binding differs') + schema.need(child['context_source']['path'].startswith(str(stage) + '/') and + any(p['path'] == child['context_source']['path'] and p['sha256'] == child['context_source']['sha256'] + for p in child['source_pins']), 'configured canonical unit source absent from whole stage/source custody') + return None + + + +def _observation_bindings(): + observer_namespace, unused = _module_namespace(observation) + wire_namespace, unused = _module_namespace(preflight_wire) + validator_namespace, unused = _module_namespace(preflight_validator) + _need(observer_namespace.get('_INSTALLED_WIRE') is preflight_wire and + observer_namespace.get('_INSTALLED_VALIDATOR') is preflight_validator and + validator_namespace.get('wire') is preflight_wire and + observer_namespace.get('_INSTALLED_WIRE_PARSE') is wire_namespace.get('validate_protocol') and + observer_namespace.get('_INSTALLED_FAMILY_PARSE') is validator_namespace.get('validate_preflight_protocol'), + 'same installed V02 parser pair required') + + +def _observe_v02(proxy): + """Retain declared post-Root bytes under the same persistent read owner. + + The three DATA modules share the independently supplied source profile in + the prebirth scope. This join cannot issue that scope or terminal authority. + """ + state, child = _prebirth_scope(proxy) + _need(child['raw_artifacts'] == [], 'V02 has no external fixture substitution inputs') + folder = proxy.root / 'runtime/runs' / child['queue_case']['label'] + evidence = proxy.evidence / child['queue_case']['label'] + declarations = ( + ('stdout', str(folder / 'stdout.txt'), schema.LOG_BYTES), + ('stderr', str(folder / 'stderr.txt'), schema.LOG_BYTES), + ('supervision', str(evidence / 'SUPERVISION.json'), schema.RECORD_BYTES), + ('proxy', str(evidence / 'PROXY.json'), schema.RECORD_BYTES), + ('receipt', str(folder / 'receipt.json'), 4 * 1024 * 1024), + ('marker', child['start_marker'], schema.RECORD_BYTES), + ('root.stdout.raw', str(evidence / 'root.stdout.raw'), proxy.s.LOG_CAP), + ('root.stderr.raw', str(evidence / 'root.stderr.raw'), proxy.s.LOG_CAP), + ('request', child['guard']['request_path'], proxy.s.GUARD_CAP), + ('ack', child['guard']['ack_path'], proxy.s.GUARD_CAP), + ('consume', child['guard']['consume_path'], proxy.s.GUARD_CAP), + ) + identity_keys = ('device', 'inode', 'mode', 'size', 'mtime_ns', 'ctime_ns') + for name, path, limit in declarations: + proxy._fresh() + native_pin, raw = proxy.s.stable_file(path, limit, True) + retained = {'native_pin': native_pin, 'raw': raw} + proxy.observation_blobs[name] = retained + proxy._fresh() + identity = native_pin['identity'] + _need(type(identity) is list and len(identity) == len(identity_keys) and + all(type(value) is int for value in identity), 'original outer identity shape differs') + retained['pin'] = dict(native_pin, identity=dict(zip(identity_keys, identity))) + # The complete admitted child is frozen by the same prebirth scope. These + # fields bind the existing observer's paths and publication expectations. + observer_child = dict(child, root=state['plan']['root'], evidence=str(proxy.evidence), + publication_admission=orchestration.CONFIGURATION['publication_admission'], raw_artifact_names=[]) + proxy._fresh() + _observation_bindings() + proxy.unit_result = _validate_retained_unit(proxy, proxy.unit_initial, proxy.unit_launch) + proxy._fresh() + result = observation._retained_data_observation(proxy.observation_blobs, observer_child, + child['expected_context'], preflight_wire, preflight_validator) + proxy._fresh() + return result + + +class RootProxy: + def __init__(self, supervisor, root, cases, evidence, policy, deadline): + self.s, self.root, self.cases = supervisor, root, cases + self.evidence, self.policy, self.deadline = evidence, policy, deadline + self.next = 0 + self.records = [] + self.prebirth_attempted = False + self.prebirth_evidence = None + self.observation_profile = None + self.observation_blobs = {} + self.observation_result = None + self.unit_blobs = {} + self.pending_result = None + self.unit_result = None + self.profile = _capture_receivers((supervisor,)) + namespace, unused = _module_namespace(supervisor) + self.outer = namespace['_PARENT_READ_IO'] + + def _fresh(self): + _outer_fresh(self.s, self.profile, self.outer) + if self.observation_profile is not None: + _need(_receivers_unchanged(self.observation_profile), 'observation receiver changed') + + def run(self, command, **kwargs): + try: + self._fresh() + return self._run(command, **kwargs) + except BaseException as error: + _stop_outer(self.outer, error) + raise + + def _run(self, command, **kwargs): + s = self.s + s.need(self.next < len(self.cases), 'Unregistered extra queue root command') + case = self.cases[self.next] + expected = ['/usr/bin/python3.12', *s.FLAGS, str(self.root / 'run_guarded_v3.py'), + case['stage'], case['job'], case['label']] + s.need(command == expected and set(kwargs) == {'cwd', 'env', 'capture_output', 'timeout'} and + kwargs['cwd'] == self.root and kwargs['env'] == s.ENV and + kwargs['capture_output'] is True and kwargs['timeout'] == 190, + 'Queue subprocess alias call exceeded its exact reviewed interface') + _prebirth_v02(self, case, command) + folder = self.evidence / case['label'] + result = s.run_root(self.root, case, folder, self.policy['root_seconds'], self.deadline, + self.policy['root_address_space_bytes'], self.policy['root_rss_sum_bytes']) + self._fresh() + original_rc = result['returncode'] + receipt_path = self.root / 'runtime/runs' / case['label'] / 'receipt.json' + if receipt_path.exists(): + root_receipt, root_pin = s.read_json(receipt_path, 4 * 1024 * 1024) + else: + root_receipt, root_pin = {'status': 'ABSENT_UNCLOSED_ROOT'}, None + self._fresh() + failure = result['failure'] + if original_rc == 0 and (result['cleanup']['observed_after_root_exit'] or + result['cleanup']['reaped_adopted']): + failure = failure or {'type': 'OrphanAfterApparentPass', + 'message': 'Original root exit 0 retained; supervisor admission STOP'} + if not result['cleanup']['complete']: + failure = failure or {'type': 'CleanupIncomplete', 'message': 'Owned process groups not empty'} + originals = {'root_returncode': original_rc, 'root_status': root_receipt['status'], + 'root_receipt_pin': root_pin, 'root_stdout': result['outer_logs']['root.stdout.raw'], + 'root_stderr': result['outer_logs']['root.stderr.raw']} + row = {'label': case['label'], 'actual_consumer': 'wrapper+module-alias-proxy+supervisor+queue-v4', + 'original': originals, 'effective_admission': 'STOP' if failure else 'DEFER_TO_QUEUE_V4', + 'supervision_failure': failure, 'original_root_receipt_unchanged': True, + 'cleanup_before_queue_validation': True} + self._fresh() + s.write_new(folder / 'PROXY.json', row) + self._fresh() + self.records.append(row) + if failure: + s.stop_supplement(self.root, case['label'], failure) + raise RuntimeError('Root supervision rejected case; original status retained: ' + case['label']) + stdout_record, stdout = s.stable_file(folder / 'root.stdout.raw', s.LOG_CAP, True) + self._fresh() + stderr_record, stderr = s.stable_file(folder / 'root.stderr.raw', s.LOG_CAP, True) + self._fresh() + s.need(stdout_record == originals['root_stdout'] and stderr_record == originals['root_stderr'], + 'Original root command streams changed before queue consumption') + self.observation_result = _observe_v02(self) + self._fresh() + self.next += 1 + return subprocess.CompletedProcess(command, original_rc, stdout, stderr) + + + +def _require_original_fresh_round(): + """Closed assembly edge, not an admission setter or DATA approval flag. + + The genuine source/bootstrap and selected fresh funding owner must replace + this seam in a separately reviewed source assembly. funding_current DATA + eligibility is not original command authority. No implementation is supplied + here because no authentic new-round binding is available. Inert replays + replace this dependency only in their selected namespace. + """ + raise ScopedParentStop('authentic source/bootstrap and fresh round owner are unjoined') + + +def _unit_read(proxy, path, limit): + proxy._fresh() + pin, raw = proxy.s.stable_file(path, limit, True) + proxy.unit_blobs[str(path)] = {'pin': pin, 'raw': raw} + proxy._fresh() + return pin, raw + + +def _validate_retained_unit(proxy, initial, launch): + """#6885 original queue unit predicates, evaluated on retained owner bytes. + + The separate original fresh-funding registry must already be authentically + admitted. initial is only the runner subledger, never the financial ledger. + """ + proxy._fresh() + unused, child = _prebirth_scope(proxy) + case, root, s = child['queue_case'], proxy.root, proxy.s + stage = root / 'stages' / case['stage'] + folder = root / 'runtime/runs' / case['label'] + stage_pin, raw = _unit_read(proxy, stage / 'STAGE.json', s.META_CAP) + _need(stage_pin['sha256'] == case['stage_sha256'], 'Reviewed stage changed') + declared = json.loads(raw) + receipt = json.loads(proxy.observation_blobs['receipt']['raw']) + unused, raw = _unit_read(proxy, folder / 'START.json', 4 * 1024 * 1024) + start = json.loads(raw) + for key, value in start.items(): + _need(receipt.get(key) == value, 'START differs from receipt: ' + key) + _need(receipt['stage_sha256'] == stage_pin['sha256'], 'Receipt stage differs') + runner, unused = _unit_read(proxy, root / 'run_guarded_v3.py', 4 * 1024 * 1024) + _need(receipt['runner_sha256'] == declared['runner_sha256'] == runner['sha256'], 'Runner identity differs') + phase, unused = _unit_read(proxy, root / 'control/EXECUTION-PHASE.json', s.META_CAP) + _need(receipt['budget_phase_sha256'] == phase['sha256'], 'Budget identity differs') + _need(receipt['parent_launch'] == launch, 'Parent launch provenance differs') + _need(receipt['command'][:5] == ['/usr/bin/python3.12', *s.FLAGS], 'Child launch flags differ') + fractions, unused = _unit_read(proxy, Path('/usr/lib/python3.12/fractions.py'), 4 * 1024 * 1024) + _need(receipt['fractions_sha256'] == fractions['sha256'], 'Actual Fraction source differs') + _need(receipt['label'] == case['label'] and receipt['job'] == case['job'], 'Receipt case differs') + _need(receipt['status'] == 'PASS' and receipt['exit'] == 0 and receipt['termination'] is None, 'Actual runner rejected case') + _need(receipt['source_bytes_and_modes_unchanged'] is True and receipt['retained_log_bytes_stable'] is True, 'Custody or logs changed') + _need(receipt['log_read_chunk_bytes'] == 65536, 'Bounded log reader differs') + for name in ('stdout', 'stderr'): + pin = proxy.observation_blobs[name]['native_pin'] + _need(pin['sha256'] == receipt[name + '_sha256'], 'Raw log digest differs') + _need(pin['bytes'] == receipt[name + '_bytes'] == receipt[name + '_final_bytes'], 'Raw log byte count differs') + _need(pin['bytes'] <= 2097152, 'Ordinary raw log cap exceeded') + _need(receipt['stderr_bytes'] == 0, 'Unexpected actual child stderr') + _need(receipt['runner_wall_seconds'] >= receipt['wall_seconds'] >= 0, 'Runner time scope differs') + proxy._fresh() + current = s.ledger(root) + proxy._fresh() + _need(set(current) == set(initial) | {case['label']} and case['label'] not in initial, + 'Singleton runner subledger domain differs') + _need(all(current[key] == value for key, value in initial.items()), 'Prior runner subledger changed') + _need(current[case['label']] == receipt['runner_wall_seconds'], 'Runner charge differs') + _need(abs(sum(initial.values()) - receipt['spent_before_seconds']) < 1e-7, 'Aggregate ledger differs') + _need(case.get('kind') == 'component-unit' and case['science_status'] == 'IMPLEMENTED_UNIT_PASS' and + case.get('science_fields', {}) == {}, 'Original scientific field checks cannot be omitted via unit adapter') + return {'label': case['label'], 'job': case['job'], 'stage': case['stage'], + 'gate': 'PASS_RETAINED_RECEIPT', 'science_status': 'UNIT_RAW_WIRE_PENDING_INDEPENDENT_PARENT_JUDGMENT', + 'runner_wall_seconds': receipt['runner_wall_seconds'], 'child_wall_seconds': receipt['wall_seconds'], + 'cpu_seconds': receipt['usage']['user_seconds'] + receipt['usage']['system_seconds'], + 'runner_cpu_seconds_before_own_receipt': receipt['runner_user_seconds'] + receipt['runner_system_seconds'], + 'kernel_max_rss_kib': receipt['usage']['kernel_max_rss_kib'], + 'sampled_process_group_rss_bytes': receipt['sampled_process_group_rss_bytes']} + + +def main(): + _require_original_fresh_round() + began = time.monotonic() + usage_start = (resource.getrusage(resource.RUSAGE_SELF), resource.getrusage(resource.RUSAGE_CHILDREN)) + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--root', type=Path, required=True) + parser.add_argument('--config', type=Path, required=True) + parser.add_argument('--policy', type=Path, required=True) + parser.add_argument('--source-sha256', required=True) + args = parser.parse_args() + s, source_manifest = source_packet(args.source_sha256) + namespace, unused = _module_namespace(s) + state = namespace['_PARENT_READ_IO'] + _OUTER_LAST[0] = state + profile = _capture_receivers((s,)) + lock = initial = proxy = keeper = None + failure = None + old_argv = sys.argv + try: + _outer_fresh(s, profile, state) + s.launch_contract() + _outer_fresh(s, profile, state) + root = args.root.resolve() + config_path, policy_path = args.config.resolve(), args.policy.resolve() + s.need(config_path.is_relative_to(root / 'control') and policy_path.is_relative_to(root / 'control'), + 'Config and policy must be frozen round controls') + config, config_pin = s.read_json(config_path) + _outer_fresh(s, profile, state) + policy, policy_pin = s.read_json(policy_path) + _outer_fresh(s, profile, state) + s.need(set(policy) == {'queue', 'shared_seconds', 'root_seconds', 'root_address_space_bytes', 'root_rss_sum_bytes'}, + 'Exact supervisor policy shape required') + name = config['queue'] + s.need(type(name) is str and name.isalnum() and policy['queue'] == name, 'Queue policy identity differs') + s.need(type(policy['shared_seconds']) in (int, float) and 0 < policy['shared_seconds'] <= 600 and + type(policy['root_seconds']) in (int, float) and 0 < policy['root_seconds'] <= 190 and + type(policy['root_address_space_bytes']) is int and 0 < policy['root_address_space_bytes'] <= 1024 ** 3 and + type(policy['root_rss_sum_bytes']) is int and 0 < policy['root_rss_sum_bytes'] <= 1024 ** 3, + 'Unadmitted generic supervisor limits') + evidence = root / 'validation/attempts' / (name + '-supervision') + evidence.mkdir() + lock = s.parent_lock(root) + _outer_fresh(s, profile, state) + cap, initial = s.budget(root) + _outer_fresh(s, profile, state) + deadline = min(began + policy['shared_seconds'], began + cap - sum(initial.values())) + subreaper, keeper = s.install_subreaper(root) + _outer_fresh(s, profile, state) + s.write_new(evidence / 'PARENT-SUBREAPER.json', subreaper) + _outer_fresh(s, profile, state) + path = root / 'integration/run_reviewed_queue_v4.py' + queue_pin, raw = s.stable_file(path, s.META_CAP, True) + _outer_fresh(s, profile, state) + s.need(queue_pin['sha256'] == s.QUEUE_SHA, 'Original reviewed queue-v4 bytes changed') + # Authenticate the original queue's launch predicate only. Its science + # main/finally is never executed: V02 emits UNIT_TERMINAL, no science file. + queue_tree = ast.parse(raw, filename=str(path)) + launch_node = next(node for node in queue_tree.body + if isinstance(node, ast.FunctionDef) and node.name == 'require_trusted_launch') + launch_namespace = {'sys': sys, 'os': os, 'LAUNCH_ENV': s.ENV} + exec(compile(ast.Module(body=[launch_node], type_ignores=[]), str(path), 'exec'), launch_namespace) + launch = launch_namespace['require_trusted_launch']() + s.need(type(config['cases']) is list and len(config['cases']) == 1, 'Exact singleton V02 case required') + case = config['cases'][0] + proxy = RootProxy(s, root, config['cases'], evidence, policy, deadline) + unused, child = _prebirth_scope(proxy) + _need(child['queue_case'] == case, 'Exact frozen V02 case differs') + command = ['/usr/bin/python3.12', *s.FLAGS, str(root / 'run_guarded_v3.py'), + case['stage'], case['job'], case['label']] + _need(hashlib.sha256(_canonical({'argv': command})).hexdigest() == child['command_sha256'], + 'Actual canonical queue command differs') + _need(case['label'] not in initial, 'Runner label already registered') + proxy.pending_result = {'command': command, 'result': None} + proxy.unit_initial = initial + proxy.unit_launch = launch + result = proxy.run(command, cwd=root, env=dict(s.ENV), capture_output=True, timeout=190) + proxy.pending_result['result'] = result + proxy._fresh() + s.need(result.returncode == 0 and result.stderr == b'' and proxy.next == 1, + 'Actual source-owned Root proxy rejected child') + _need(type(proxy.unit_result) is dict and proxy.unit_result['gate'] == 'PASS_RETAINED_RECEIPT', + 'Retained unit receipt validation omitted') + observed = proxy.observation_result + _need(type(observed) is dict and observed.get('original_v02_complete') is False and + observed.get('runtime_admitted') is False and observed.get('cost_status') == 'OPEN_NOT_ZERO', + 'Retained DATA observation cannot confer runtime or cost admission') + proxy._fresh() + children = s.children_now() + proxy._fresh() + s.need(not children, 'Wrapper finished with children still present') + final_config, unused = _unit_read(proxy, config_path, s.META_CAP) + final_policy, unused = _unit_read(proxy, policy_path, s.META_CAP) + s.need(final_config['sha256'] == config_pin['sha256'] and + final_policy['sha256'] == policy_pin['sha256'], 'Control policy changed') + except BaseException as error: + _stop_outer(state, error) + raise + finally: + sys.argv = old_argv + packet_ready = False + if state['primary'] is None and state['phase'] == 'ACTIVE' and not state['unknown']: + try: + packet_ready = _finish_packet(s, profile, state, + Path(__file__).resolve().parent, source_manifest) + except BaseException as error: + _stop_outer(state, error) + if packet_ready: + try: + elapsed = time.monotonic() - began + state['elapsed_before_terminal'] = elapsed + current = s.ledger(root) + _outer_fresh(s, profile, state) + s.need(set(current) == set(initial) | {case['label']}, 'Final singleton runner subledger domain differs') + s.need(current[case['label']] == proxy.unit_result['runner_wall_seconds'], 'Retained runner charge changed at finalization') + s.need(all(current.get(k) == v for k, v in initial.items()), 'Prior cost records changed') + nested = sum(v for k, v in current.items() if k not in initial) + residual = max(0.0, elapsed - nested) + if time.monotonic() > deadline: + failure = failure or {'type': 'SupervisorBudget', 'message': 'Full wrapper bound crossed; cleanup remains charged'} + usage_end = (resource.getrusage(resource.RUSAGE_SELF), resource.getrusage(resource.RUSAGE_CHILDREN)) + result = {'schema': 'h25-queue-v4-supervisor-envelope-v1', 'queue': name, + 'status': 'STOP' if failure else 'SCOPED_V02_DATA_OBSERVED', 'failure': failure, + 'actual_consumer': 'direct-singleton-wrapper+RootProxy+retained-unit-observer', + 'original_v02_complete': False, 'runtime_admitted': False, 'cost_status': 'OPEN_NOT_ZERO', + 'original_queue_sha256': s.QUEUE_SHA, 'original_root_sha256': s.RUNNER_SHA, + 'source_manifest_sha256': args.source_sha256, 'config_pin': config_pin, 'policy_pin': policy_pin, + 'controls': [] if proxy is None else proxy.records, + 'complete_wrapper_seconds_before_own_receipt': elapsed, + 'complete_cpu_seconds_before_own_receipt': sum((z.ru_utime + z.ru_stime) - (a.ru_utime + a.ru_stime) for a, z in zip(usage_start, usage_end)), + 'nested_runner_seconds': nested, 'wrapper_residual_seconds': residual, + 'outer_GNU_time_final_tail_reconciliation_required': True, + 'subreaper_is_same_queue_process': True, 'original_root_receipts_preserved': True} + folder = root / 'runtime/runs' / (name + '-supervisor-overhead') + folder.mkdir() + _outer_fresh(s, profile, state) + s.write_new(folder / 'START.json', {'kind': 'parent_cost_only'}) + _outer_fresh(s, profile, state) + s.write_new(folder / 'receipt.json', dict(result, label=folder.name, kind='parent_cost_only', + wall_seconds=residual, runner_wall_seconds=residual)) + _outer_fresh(s, profile, state) + s.write_new(evidence / 'WRAPPER.json', result) + _outer_fresh(s, profile, state) + except BaseException as error: + _stop_outer(state, error) + if lock is not None: + try: + lock.close() + except BaseException as error: + state['unknown'] = True + state['lock_close_error'] = error + _stop_outer(state, error, secondary=True) + if state['primary'] is not None: + raise state['primary'] + if failure: + raise SystemExit(1) + + +if __name__ == '__main__': + main() diff --git a/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REPLAY-normal.json b/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REPLAY-normal.json new file mode 100644 index 0000000000..80307dc999 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REPLAY-normal.json @@ -0,0 +1,16 @@ +{ + "authentic_cross_process_inlet": false, + "checks": [ + "six paired author owning-path controls independently rerun", + "equal-length P byte substitution with unchanged complete pin refuses in actual child digest check before issuer and quarantines retry", + "preparation removal after parent checks refuses in actual child entry with descriptors closed before issuer" + ], + "child_sha256": "926edbf69c4e296edfd8ebcdebfb66cf07e9c5551a1a0aec03450954310cbff2", + "optimize": 0, + "original_executions": 0, + "pair_sha256": "4539bab110316f138998130ed36d5ddfae65343b8a6e92833932f6e14e8ac3a6", + "parent_sha256": "186905e138135e35e05172d18800ecdfe3328f40bb9e52707195bdfb85a64de8", + "passed": 3, + "runtime_authority": false, + "schema": "v02-paired-independent-inert-v1" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REPLAY-optimized.json b/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REPLAY-optimized.json new file mode 100644 index 0000000000..072b7edc68 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REPLAY-optimized.json @@ -0,0 +1,16 @@ +{ + "authentic_cross_process_inlet": false, + "checks": [ + "six paired author owning-path controls independently rerun", + "equal-length P byte substitution with unchanged complete pin refuses in actual child digest check before issuer and quarantines retry", + "preparation removal after parent checks refuses in actual child entry with descriptors closed before issuer" + ], + "child_sha256": "926edbf69c4e296edfd8ebcdebfb66cf07e9c5551a1a0aec03450954310cbff2", + "optimize": 1, + "original_executions": 0, + "pair_sha256": "4539bab110316f138998130ed36d5ddfae65343b8a6e92833932f6e14e8ac3a6", + "parent_sha256": "186905e138135e35e05172d18800ecdfe3328f40bb9e52707195bdfb85a64de8", + "passed": 3, + "runtime_authority": false, + "schema": "v02-paired-independent-inert-v1" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REVIEW-final.md b/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REVIEW-final.md new file mode 100644 index 0000000000..c5c21630fb --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/paired-prebirth-child/independent-review/REVIEW-final.md @@ -0,0 +1,11 @@ +# Independent paired parent and child transport review + +Conditional inert data-path scope accepted. Reviewed parent source is `186905e138135e35e05172d18800ecdfe3328f40bb9e52707195bdfb85a64de8`; child source is `926edbf69c4e296edfd8ebcdebfb66cf07e9c5551a1a0aec03450954310cbff2`. The paired harness is `4539bab110316f138998130ed36d5ddfae65343b8a6e92833932f6e14e8ac3a6`. Neither candidate changed during this review. + +The positive path follows the actual selected parent `RootProxy.run`, complete prebirth association, explicitly inert process-birth replacement, actual child `prepare_selected_child`, and actual installer, typed constructor and registrar. The child retains P through its own complete-pin reader from the lane's preparation record. The paired harness does not assign `v02_preflight_package_data` manually. Its issuer seam reads the tuple already created by the child, compares its bytes and pin with the parent fixture, and conditionally installs the independently supplied inert `v02_pre_admitted_input`. Detached E is never read by the child. + +One P memory file supplies both readers. In the positive fixture it contains 3,627 bytes, SHA-256 `1f42e0e5e805855cdd9246859f967df45673036c311b6448c5a2950a3a808d6c`; parent and child each read it once. The exact parent-derived lane reaches the child. This establishes conditional continuity of bytes and complete pins through the real selected functions. + +All six author controls were independently rerun in ordinary and optimized Python. Two additional falsifiers pass in both modes. First, replacing P with different equal-length bytes while keeping its complete pin and synthetic file identity unchanged after parent validation is rejected by the child's actual final digest/custody check, before the issuer seam. The original error is retained and a retry performs no further reads. Second, removing preparation after parent validation is rejected in the actual child entry, with descriptors closed and no issuer invocation. The independent test initially expected a different error string; inspection confirmed the actual source message `binding source custody changed`, and the assertion was corrected without changing either candidate. + +No authentic cross-process admission inlet is implemented or tested here. The issuer seam is an explicit test insertion before the actual installer. The live-profile capture/check seam, synthetic Root/provider/API identities, memory descriptors, parent admission and source-template admission remain conditional fixture premises. Sealed state in this test proves conditional software execution only. It does not establish genuine producer decisions, actual Root/provider calls, a real process birth, eight omission outcomes, independent DATA acceptance, a source-seal-compatible production caller, or cost closure. Original execution and original accepted case counts remain zero. diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt0.json new file mode 100644 index 0000000000..53cc6b67d7 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt0.json @@ -0,0 +1,49 @@ +{ + "native_io_executed": false, + "optimization": 0, + "original_root_executed": false, + "results": { + "after_close_metadata_drift": { + "descriptor_known_closed": true, + "first_error_retained": true, + "no_retry_io": true, + "retry_same_error": true, + "root_calls": 1 + }, + "main_final_path_before_stop_gate": { + "final_source_path_resolved_after_stop": false, + "known_lock_close_calls": 1, + "ledger_calls": 0, + "outward_is_late_resolve_error": false, + "outward_is_original_read_error": true, + "packet_calls": 0, + "stored_close_secondary_preserved": true, + "stored_read_primary_preserved": true + }, + "packet_read_close_during_main_finalization": { + "known_lock_close_calls": 1, + "ledger_calls": 0, + "outward_primary": true, + "packet_calls": 1, + "stored_secondary": true, + "unknown": true + }, + "path_type_rejection": { + "metaclass_callbacks": 0, + "native_open_calls": 0, + "retained_primary": true + }, + "permitted_final_path_failure": { + "known_lock_close_calls": 1, + "ledger_calls": 0, + "outward_primary": true, + "packet_calls": 0, + "stored_primary": true + } + }, + "schema": "v02-independent-postroot-probes-v1", + "sources": { + "run_queue_outer_read_v1.py.txt": "8fcf1e5749eb35c1cccbc84ea694c10f6dba7e4c72f26cdb0ee744338ea3a4c7", + "supervisor_outer_read_v1.py.txt": "a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a" + } +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt1.json new file mode 100644 index 0000000000..4f216a948d --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/INDEPENDENT-opt1.json @@ -0,0 +1,49 @@ +{ + "native_io_executed": false, + "optimization": 1, + "original_root_executed": false, + "results": { + "after_close_metadata_drift": { + "descriptor_known_closed": true, + "first_error_retained": true, + "no_retry_io": true, + "retry_same_error": true, + "root_calls": 1 + }, + "main_final_path_before_stop_gate": { + "final_source_path_resolved_after_stop": false, + "known_lock_close_calls": 1, + "ledger_calls": 0, + "outward_is_late_resolve_error": false, + "outward_is_original_read_error": true, + "packet_calls": 0, + "stored_close_secondary_preserved": true, + "stored_read_primary_preserved": true + }, + "packet_read_close_during_main_finalization": { + "known_lock_close_calls": 1, + "ledger_calls": 0, + "outward_primary": true, + "packet_calls": 1, + "stored_secondary": true, + "unknown": true + }, + "path_type_rejection": { + "metaclass_callbacks": 0, + "native_open_calls": 0, + "retained_primary": true + }, + "permitted_final_path_failure": { + "known_lock_close_calls": 1, + "ledger_calls": 0, + "outward_primary": true, + "packet_calls": 0, + "stored_primary": true + } + }, + "schema": "v02-independent-postroot-probes-v1", + "sources": { + "run_queue_outer_read_v1.py.txt": "8fcf1e5749eb35c1cccbc84ea694c10f6dba7e4c72f26cdb0ee744338ea3a4c7", + "supervisor_outer_read_v1.py.txt": "a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a" + } +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/PATH-TYPE-GUARD-cefcf1f7.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/PATH-TYPE-GUARD-cefcf1f7.json new file mode 100644 index 0000000000..8f6abecf16 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/PATH-TYPE-GUARD-cefcf1f7.json @@ -0,0 +1,6 @@ +{ + "new_path_type_guard_metaclass_callbacks": 2, + "native_open_calls": 0, + "state": "STOP", + "scope": "unsupported foreign path input only; original RootProxy supplies exact source-derived paths" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REPLAY-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REPLAY-opt0.json new file mode 100644 index 0000000000..c671b54aad --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REPLAY-opt0.json @@ -0,0 +1,40 @@ +{ + "actual_issuer_or_gate_records": 0, + "actual_root_executed": false, + "actual_v02_cases_accepted": 0, + "checks": [ + "frozen original reproduces retained-read ownership gap and later packet read", + "actual RootProxy positive path retains receipt and both complete streams", + "actual RootProxy and finalization retain read and uncertain close", + "actual RootProxy and finalization retain read error and known close", + "actual RootProxy and finalization retain close-only failure", + "actual RootProxy and finalization retain uncertain open", + "explicit EOF countercontrol refuses before proxy publication", + "original read_json parse failure latches in RootProxy continuation", + "e156 receiver mutation refuses before Root and substituted callback", + "post-root receiver drift refuses before the first receipt read", + "e156 primitive-key census rejects foreign key before callbacks", + "128 cumulative outer tickets refuse before another descriptor acquisition", + "size gate retains first error before open", + "exact path type guard rejects foreign metaclass without callback", + "child-owned stable_file remainder restores exact original AST", + "actual source-selected main joins RootProxy and normal finalization through inert queue", + "actual source-selected main blocks packet and ledger after post-root read and uncertain close", + "actual source-selected main retains lock failure", + "actual source-selected main retains budget failure", + "actual source-selected main retains ledger failure", + "actual source-selected main retains lock_close failure", + "main known lock close failure preserves earlier retained read primary", + "main final path gate preserves prior read error", + "main final path gate preserves resolver error" + ], + "full_outer_entry_qualified": false, + "native_io_executed": false, + "optimization": 0, + "passed": 24, + "schema": "v02-original-post-root-caller-replay-v1", + "sources": { + "run_queue_outer_read_v1.py.txt": "8fcf1e5749eb35c1cccbc84ea694c10f6dba7e4c72f26cdb0ee744338ea3a4c7", + "supervisor_outer_read_v1.py.txt": "a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a" + } +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REPLAY-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REPLAY-opt1.json new file mode 100644 index 0000000000..5ceaa7ef34 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REPLAY-opt1.json @@ -0,0 +1,40 @@ +{ + "actual_issuer_or_gate_records": 0, + "actual_root_executed": false, + "actual_v02_cases_accepted": 0, + "checks": [ + "frozen original reproduces retained-read ownership gap and later packet read", + "actual RootProxy positive path retains receipt and both complete streams", + "actual RootProxy and finalization retain read and uncertain close", + "actual RootProxy and finalization retain read error and known close", + "actual RootProxy and finalization retain close-only failure", + "actual RootProxy and finalization retain uncertain open", + "explicit EOF countercontrol refuses before proxy publication", + "original read_json parse failure latches in RootProxy continuation", + "e156 receiver mutation refuses before Root and substituted callback", + "post-root receiver drift refuses before the first receipt read", + "e156 primitive-key census rejects foreign key before callbacks", + "128 cumulative outer tickets refuse before another descriptor acquisition", + "size gate retains first error before open", + "exact path type guard rejects foreign metaclass without callback", + "child-owned stable_file remainder restores exact original AST", + "actual source-selected main joins RootProxy and normal finalization through inert queue", + "actual source-selected main blocks packet and ledger after post-root read and uncertain close", + "actual source-selected main retains lock failure", + "actual source-selected main retains budget failure", + "actual source-selected main retains ledger failure", + "actual source-selected main retains lock_close failure", + "main known lock close failure preserves earlier retained read primary", + "main final path gate preserves prior read error", + "main final path gate preserves resolver error" + ], + "full_outer_entry_qualified": false, + "native_io_executed": false, + "optimization": 1, + "passed": 24, + "schema": "v02-original-post-root-caller-replay-v1", + "sources": { + "run_queue_outer_read_v1.py.txt": "8fcf1e5749eb35c1cccbc84ea694c10f6dba7e4c72f26cdb0ee744338ea3a4c7", + "supervisor_outer_read_v1.py.txt": "a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a" + } +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REVIEW-final.md b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REVIEW-final.md new file mode 100644 index 0000000000..8d13b38f8f --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/REVIEW-final.md @@ -0,0 +1,18 @@ +# Independent post-Root caller review + +Accepted for the bounded outer receipt/stream read and finalization source scope under the retained authentic-source, protected private-state and native-operation premises. + +| Source | SHA-256 | +| --- | --- | +| Supervisor derivative | `a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a` | +| Queue wrapper derivative | `8fcf1e5749eb35c1cccbc84ea694c10f6dba7e4c72f26cdb0ee744338ea3a4c7` | + +The persistent outer read state is reached by the actual `stable_file` entry when the child supervision slot is empty. The candidate `RootProxy.run` uses that path for its original receipt and two stream reads. The retained first read error and separate uncertain-close error stop later packet and ledger acquisition through the actual main-finalization continuation. Known lock close occurs once. A distinct lock-close error has a separate retention field. Original `run_root` and `OwnedDomain` bytes remain equal to #6885, as do all other original supervisor declarations except the short `stable_file` dispatch extension. Eight e156 descriptor, primitive-key and receiver-check helpers retain their exact source bytes. + +Independent replay passed all 24 author controls in each of normal and optimized Python. The harness modification only relocated its output. Five independent probes passed in each mode. They cover a final source-path resolver fault after an earlier read/close failure, final metadata drift after known close, packet-read failure during main finalization, a permitted final path-resolution error, and a foreign path class with callback-bearing metaclass equality. + +The first reviewed wrapper `cefcf1f7...` evaluated `Path(__file__).resolve().parent` before `_finish_packet` could check STOP. An independent fault there replaced the outward read error and skipped known lock close. The successor checks STOP before evaluating that argument and catches a permitted resolver failure before lock cleanup. The independent replay now observes zero final source-path resolution after STOP, the original outward primary, and one known lock close. The path-type check also uses exact type identity, and the unsupported foreign-type probe now records zero equality callbacks and zero opens. Earlier source and failing observations remain in the author’s rejected directories and `rejected-cefcf1f7/`. + +The accepted boundary is precise. Tests select the candidate owning functions and invoke actual `RootProxy.run` and `main` against inert file, queue, subreaper and Root seams. They execute zero original Root bodies, native I/O operations, production programs, guest launches or producer cases. Source-packet bootstrap reads, original `parent_lock` acquisition/failure internals, fresh closed-registry binding, actual launch permission, V02 observer invocation, and external terminal and cost settlement remain open. Post-Root `write_new` and `stop_supplement` retain their inherited publication ownership and still require the actual outer publication and registry join. This acceptance covers retained reads and their main failure continuation. Complete write, lock and bootstrap custody need their own integration evidence. The persistent cumulative 128-ticket limit requires a complete actual-operation count. A stored `OPEN_NOT_ZERO` value supplies no settlement fact. + +The reviewed source and result pins were checked after replay. `SOURCE-COMPARISON-final.json`, the two source diffs, `REPLAY-opt0.json`, `REPLAY-opt1.json`, `INDEPENDENT-opt0.json`, `INDEPENDENT-opt1.json`, and the replay scripts retain the evidence. diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/SOURCE-COMPARISON-final.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/SOURCE-COMPARISON-final.json new file mode 100644 index 0000000000..e96ee9abce --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/independent-review/SOURCE-COMPARISON-final.json @@ -0,0 +1,35 @@ +{ + "author_controls_per_mode": 24, + "changed_original_supervisor_declarations": [ + "stable_file" + ], + "e156_helper_bytes_equal": [ + "ScopedParentStop", + "_need", + "_cell_value", + "_mapping_items", + "_module_namespace", + "_function_values", + "_capture_receivers", + "_receivers_unchanged" + ], + "independent_probes_per_mode": 5, + "modes": [ + 0, + 1 + ], + "original_owned_domain_bytes_equal": true, + "original_run_root_bytes_equal": true, + "original_supervisor_declarations": 43, + "pins": { + "run_queue_outer_read_v1.py.txt": { + "bytes": 18594, + "sha256": "8fcf1e5749eb35c1cccbc84ea694c10f6dba7e4c72f26cdb0ee744338ea3a4c7" + }, + "supervisor_outer_read_v1.py.txt": { + "bytes": 110940, + "sha256": "a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a" + } + }, + "schema": "independent-original-postroot-source-comparison-v2" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/supervisor_outer_read_v1.py.txt b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/supervisor_outer_read_v1.py.txt new file mode 100644 index 0000000000..a9a82ecbc2 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-owner-adaptation/supervisor_outer_read_v1.py.txt @@ -0,0 +1,2173 @@ +"""Parent-only bounded process supervision; imports no candidate implementation. + +The runtime caller must establish the trusted clean launcher before calling us. +This source was prepared without loading ctypes or running any control. The +closed single-threaded child domain is an explicit premise, not a hostile-fork +sandbox. Numeric process IDs are never used as signal destinations. +""" +import fcntl +import hashlib +import json +import os +from pathlib import Path +import resource +import signal +import stat +import subprocess +import sys +import time + +FLAGS = ('-S', '-s', '-P', '-B') +ENV = {'PATH': '/usr/bin:/bin', 'PYTHONHASHSEED': '0', 'LANG': 'C.UTF-8', + 'LC_ALL': 'C.UTF-8', 'TZ': 'UTC', 'PYTHONDONTWRITEBYTECODE': '1'} +RUNNER_SHA = '7e8c678cfd7773780a2eb6f0e70f53ae251dc121d05df9d13879dd70d9d79292' +QUEUE_SHA = '1348a7b4d7cc1f9fef556f5e0abdaf04411a998afdcd574d7812c76ab37dcf68' +TCB_SHA = '610492b3fc06baa0560175edc3ba27057de00d00b8fd3d58dbe55e5a371c042a' +LIBC = '/usr/lib/x86_64-linux-gnu/libc.so.6' +NATIVE_PINS = { + LIBC: '3a15d66867d83762c7f2f1e37359cb8f6c5743edb369c65285cb0b1c4f7498bf', + '/usr/lib/python3.12/lib-dynload/_ctypes.cpython-312-x86_64-linux-gnu.so': 'aad3e24f186e6c0a1c7efa8f16004f951f527db86f6451d30118657384a456c1', + '/usr/lib/x86_64-linux-gnu/libffi.so.8.1.4': '00f593fe192f2851b8ce23b25cec2488d769beb5a8f63e8c9e563071e1075153', + '/usr/lib/python3.12/ctypes/__init__.py': '0782592567ad71097198a3afe985ac3e2ea0b9b5e75452402c9460c89a86318a', + '/usr/lib/python3.12/ctypes/_endian.py': 'c5d692bdce10dfee242752620061bab684633bc72445a3def484961ef1bdbf3a', +} +CHUNK = 65536 +LOG_CAP = 2 * 1024 * 1024 +META_CAP = 256 * 1024 +CLEANUP_SECONDS = 2.0 + + +def need(condition, message): + if not condition: + raise RuntimeError(message) + + +def launch_contract(): + need(sys.executable == '/usr/bin/python3.12', 'Pinned interpreter required') + need(sys.flags.no_site == sys.flags.no_user_site == sys.flags.dont_write_bytecode == 1 and + sys.flags.safe_path and sys.flags.ignore_environment == sys.flags.isolated == + sys.flags.hash_randomization == 0, 'Trusted no-site safe-path fixed-seed flags required') + need(dict(os.environ) == ENV, 'Exact clean environment required') + need(tuple(sys.path) == ('/usr/lib/python312.zip', '/usr/lib/python3.12', + '/usr/lib/python3.12/lib-dynload'), 'Initial system stdlib path changed') + need(list(Path('/proc/self/task').iterdir()) == [Path('/proc/self/task') / str(os.getpid())], + 'Exactly one parent task required') + + +def identity(info): + return (info.st_dev, info.st_ino, info.st_mode, info.st_size, info.st_mtime_ns, info.st_ctime_ns) + + +# Persistent outer metadata custody derived from PR6867. This state belongs to +# this exact supervisor module and survives the retirement of each child domain. +# Its private exact-native containers and native bindings are protected premises. +_PARENT_READ_IO = {'rows': [], 'unknown': False, 'phase': 'ACTIVE', + 'primary': None, 'secondary': None, + 'lock_close_error': None, + 'cost_status': 'OPEN_NOT_ZERO', 'elapsed_before_terminal': None} +_OUTER_OPEN, _OUTER_READ, _OUTER_FSTAT, _OUTER_CLOSE = os.open, os.read, os.fstat, os.close +_OUTER_PATH_TYPE = type(Path()) + + +def _outer_read_stop(error, secondary=False): + state = _PARENT_READ_IO + state['phase'] = 'STOP' + if secondary: + if state['secondary'] is None: + state['secondary'] = error + if state['primary'] is None: + state['primary'] = error + + +def _outer_read_gate(): + state = _PARENT_READ_IO + if state['primary'] is not None: + raise state['primary'] + need(state['phase'] == 'ACTIVE' and not state['unknown'], + 'outer read custody is no longer active') + need(_OUTER_OPEN is os.open and _OUTER_READ is os.read and + _OUTER_FSTAT is os.fstat and _OUTER_CLOSE is os.close, + 'outer native read receiver changed') + + +def _outer_stable_file(path, limit, keep=False): + """Retain every outer acquisition and the first error through close-once.""" + state = _PARENT_READ_IO + fd = ticket = None + primary = secondary = None + try: + _outer_read_gate() + need((type(path) is str or type(path) is _OUTER_PATH_TYPE) and type(limit) is int and + limit >= 0 and type(keep) is bool, 'outer read input domain') + path = Path(path) + before = path.stat(follow_symlinks=False) + need(stat.S_ISREG(before.st_mode) and before.st_size <= limit, + 'outer file type or size bound') + need(len(state['rows']) < 128, 'bounded cumulative outer read tickets') + ticket = {'path': path, 'object': None, 'attempted_close_fd': None, + 'state': 'PENDING', 'primary': None, 'secondary': None} + state['rows'].append(ticket) + h, count, blocks = hashlib.sha256(), 0, [] + try: + fd = _OUTER_OPEN(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK | os.O_CLOEXEC) + ticket['object'], ticket['state'] = fd, 'OWNED' + opened = _OUTER_FSTAT(fd) + need(identity(before) == identity(opened), 'file changed while opening') + while count < opened.st_size: + block = _OUTER_READ(fd, min(CHUNK, opened.st_size - count)) + need(bool(block), 'short retained file read') + count += len(block) + h.update(block) + if keep: + blocks.append(block) + need(_OUTER_READ(fd, 1) == b'', 'complete retained file EOF') + after_fd = _OUTER_FSTAT(fd) + except BaseException as error: + primary = ticket['primary'] = error + _outer_read_stop(error) + if fd is None: + ticket['state'], state['unknown'] = 'UNKNOWN', True + finally: + if fd is not None: + closing, fd = fd, None + ticket['attempted_close_fd'] = closing + ticket['object'], ticket['state'] = None, 'CLOSING' + try: + _OUTER_CLOSE(closing) + except BaseException as error: + secondary = ticket['secondary'] = error + ticket['state'], state['unknown'] = 'UNKNOWN', True + _outer_read_stop(error, secondary=True) + else: + ticket['state'] = 'CLOSED' + if primary is not None: + raise primary + if secondary is not None: + raise secondary + after = path.stat(follow_symlinks=False) + need(identity(before) == identity(after_fd) == identity(after), + 'file drift during retained snapshot') + row = {'path': str(path), 'sha256': h.hexdigest(), 'bytes': count, + 'identity': list(identity(after)), 'stable': True, 'read_chunk_bytes': CHUNK} + return (row, b''.join(blocks)) if keep else row + except BaseException as error: + # Failure after acquisition, including final metadata or result assembly, + # also closes this outer operation to future reads and Root attempts. + _outer_read_stop(error) + raise + + +def stable_file(path, limit, keep=False): + """Full bounded snapshot with local raw primary and close-once custody.""" + if _SUPERVISION_CURRENT[0] is None: + return _outer_stable_file(path, limit, keep) + path = Path(path) + owner = _SUPERVISION_CURRENT[0] + before = path.stat(follow_symlinks=False) + need(stat.S_ISREG(before.st_mode) and before.st_size <= limit, 'File type/size bound: ' + str(path)) + slot = None + fd = None + primary = close_error = None + h, count, blocks = hashlib.sha256(), 0, [] + try: + if owner is not None: + slot = owner.open_fd(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK | os.O_CLOEXEC) + fd = slot['fd'] + else: + fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK | os.O_CLOEXEC) + opened = os.fstat(fd) + need(identity(before) == identity(opened), 'File changed while opening') + while count < opened.st_size: + block = os.read(fd, min(CHUNK, opened.st_size - count)) + need(bool(block), 'Short retained-file read') + count += len(block) + h.update(block) + if keep: + blocks.append(block) + need(os.read(fd, 1) == b'', 'Complete retained-file EOF') + after_fd = os.fstat(fd) + except BaseException as error: + primary = error + if slot is not None: + slot['working'] = error + if owner is not None: + owner.last_error = error + if owner.first_error is None: + owner.first_error = error + if owner.guard['primary'][0] is None: + owner.guard['primary'][0] = error + owner.last_error = error + if owner.first_error is None: + owner.first_error = error + if owner.guard['primary'][0] is None: + owner.guard['primary'][0] = error + if owner.error_count < 1024: + owner.error_events[owner.error_count][0] = 'stable-file-read' + owner.error_events[owner.error_count][1] = error + owner.error_count = owner.error_next[owner.error_count] + else: + owner.unknown = True + finally: + if fd is not None: + if slot is not None: + try: + owner.close_fd(slot) + except BaseException as error: + close_error = error + slot['close_entry_error'] = error + owner.last_error = error + if owner.first_error is None: + owner.first_error = error + if owner.guard['primary'][0] is None: + owner.guard['primary'][0] = error + if owner.error_count < 1024: + owner.error_events[owner.error_count][0] = 'metadata-close-helper-entry' + owner.error_events[owner.error_count][1] = error + owner.error_count = owner.error_next[owner.error_count] + else: + owner.unknown = True + else: + closing, fd = fd, None + try: + os.close(closing) + except BaseException as error: + close_error = error + if primary is not None: + raise primary + if close_error is not None: + raise close_error + after = path.stat(follow_symlinks=False) + need(identity(before) == identity(after_fd) == identity(after), 'File drift during retained snapshot') + row = {'path': str(path), 'sha256': h.hexdigest(), 'bytes': count, + 'identity': list(identity(after)), 'stable': True, 'read_chunk_bytes': CHUNK} + return (row, b''.join(blocks)) if keep else row + + +def read_json(path, limit=META_CAP): + row, raw = stable_file(path, limit, True) + return json.loads(raw), row + + +def write_new(path, row): + raw = json.dumps(row, sort_keys=True, indent=2).encode('ascii') + b'\n' + need(len(raw) <= META_CAP, 'Bounded metadata record exceeded') + owner = _SUPERVISION_CURRENT[0] + slot = None + fd = None + primary = close_error = None + try: + if owner is not None: + slot = owner.open_fd(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_CLOEXEC | os.O_NOFOLLOW) + fd = slot['fd'] + else: + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_CLOEXEC | os.O_NOFOLLOW, 0o600) + view = memoryview(raw) + while view: + written = os.write(fd, view) + need(written > 0, 'Metadata write made no progress') + view = view[written:] + os.fsync(fd) + except BaseException as error: + primary = error + if slot is not None: + slot['working'] = error + if owner is not None: + owner.last_error = error + if owner.first_error is None: + owner.first_error = error + if owner.guard['primary'][0] is None: + owner.guard['primary'][0] = error + owner.last_error = error + if owner.first_error is None: + owner.first_error = error + if owner.guard['primary'][0] is None: + owner.guard['primary'][0] = error + if owner.error_count < 1024: + owner.error_events[owner.error_count][0] = 'metadata-write' + owner.error_events[owner.error_count][1] = error + owner.error_count = owner.error_next[owner.error_count] + else: + owner.unknown = True + finally: + if fd is not None: + if slot is not None: + try: + owner.close_fd(slot) + except BaseException as error: + close_error = error + slot['close_entry_error'] = error + owner.last_error = error + if owner.first_error is None: + owner.first_error = error + if owner.guard['primary'][0] is None: + owner.guard['primary'][0] = error + if owner.error_count < 1024: + owner.error_events[owner.error_count][0] = 'metadata-close-helper-entry' + owner.error_events[owner.error_count][1] = error + owner.error_count = owner.error_next[owner.error_count] + else: + owner.unknown = True + else: + closing, fd = fd, None + try: + os.close(closing) + except BaseException as error: + close_error = error + if primary is not None: + raise primary + if close_error is not None: + raise close_error + + +def _plain_proc_read(path, cap): + """Pre-root metadata transport; the existing original caller owns errors.""" + fd, primary, close_error = None, None, None + parts, count = [], 0 + try: + fd = os.open(path, os.O_RDONLY | os.O_NONBLOCK | os.O_NOFOLLOW | os.O_CLOEXEC) + while True: + data = os.read(fd, min(CHUNK, cap + 1 - count)) + if not data: + break + count += len(data) + need(count <= cap, 'complete bounded pre-root process metadata') + parts.append(data) + raw = b''.join(parts) + except BaseException as error: + primary = error + finally: + if fd is not None: + closing, fd = fd, None + try: + os.close(closing) + except BaseException as error: + close_error = error + if primary is not None: + raise primary + if close_error is not None: + raise close_error + return raw + + +def proc(pid): + owner = _SUPERVISION_CURRENT[0] + if owner is not None: + return owner.proc(pid, pid != owner.pid) + try: + raw = _plain_proc_read('/proc/' + str(pid) + '/stat', 8192) + except (FileNotFoundError, ProcessLookupError): + return None + end = raw.rfind(b') ') + need(end >= 0, 'Malformed process stat') + fields = raw[end + 2:].split() + need(len(fields) > 21, 'Complete process identity/RSS fields') + return {'pid': int(pid), 'ppid': int(fields[1]), 'pgid': int(fields[2]), + 'sid': int(fields[3]), 'start_ticks': int(fields[19]), + 'state': fields[0].decode('ascii'), + 'rss_bytes': int(fields[21]) * os.sysconf('SC_PAGE_SIZE')} + + +def census(): + owner = _SUPERVISION_CURRENT[0] + if owner is not None: + return owner.observe()[0] + found = {} + with os.scandir('/proc') as entries: + for entry in entries: + if entry.name.isdecimal(): + row = proc(int(entry.name)) + if row is not None: + found[row['pid']] = row + return found + + +def generation(row): + return row['pid'], row['start_ticks'] + + +def children_now(): + owner = _SUPERVISION_CURRENT[0] + if owner is not None: + return owner.direct() + parent = os.getpid() + raw = _plain_proc_read('/proc/' + str(parent) + '/task/' + str(parent) + '/children', 32768) + pids = [int(word) for word in raw.split()] + need(len(pids) <= 128 and len(set(pids)) == len(pids), 'finite exact original child list') + rows = [] + for pid in pids: + row = proc(pid) + need(row is not None and row['ppid'] == parent, 'actual direct child must remain readable') + rows.append(row) + return rows + + +def install_subreaper(root): + """Called only by the future parent, before any controlled root exists.""" + launch_contract() + need(not children_now(), 'Parent must own no preexisting child processes') + tcb, tcb_row = read_json(root / 'control/NATIVE-INITIAL-TCB-v1.json') + need(tcb_row['sha256'] == TCB_SHA, 'Accepted initial TCB changed') + need(any(row['path'] == LIBC and row['sha256'] == NATIVE_PINS[LIBC] + for row in tcb['files']), 'Pinned libc absent from accepted TCB') + evidence = {path: stable_file(path, 16 * 1024 * 1024) for path in NATIVE_PINS} + need(all(evidence[path]['sha256'] == expected for path, expected in NATIVE_PINS.items()), + 'Subreaper native/stdlib source supplement changed') + # This import and native call have NOT been performed during source authoring. + need(Path('/usr/lib/x86_64-linux-gnu/libffi.so.8').resolve() == + Path('/usr/lib/x86_64-linux-gnu/libffi.so.8.1.4'), 'Foreign libffi SONAME resolution') + import ctypes + need(sys.modules['_ctypes'].__file__ == + '/usr/lib/python3.12/lib-dynload/_ctypes.cpython-312-x86_64-linux-gnu.so', 'Foreign _ctypes owner') + need(ctypes.__file__ == '/usr/lib/python3.12/ctypes/__init__.py', 'Foreign ctypes owner') + library = ctypes.CDLL(LIBC, use_errno=True) + call = library.prctl + call.argtypes = [ctypes.c_int, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong] + call.restype = ctypes.c_int + prior, actual = ctypes.c_int(), ctypes.c_int() + need(call(37, ctypes.addressof(prior), 0, 0, 0) == 0, 'PR_GET_CHILD_SUBREAPER failed') + need(call(36, 1, 0, 0, 0) == 0, 'PR_SET_CHILD_SUBREAPER failed') + need(call(37, ctypes.addressof(actual), 0, 0, 0) == 0 and actual.value == 1, + 'Same-process subreaper readback failed') + for path, expected in NATIVE_PINS.items(): + need(stable_file(path, 16 * 1024 * 1024)['sha256'] == expected, 'TCB bytes changed across load') + # Retain the CDLL and typed function in the owning parent for its whole queue. + return {'pid': os.getpid(), 'prior': prior.value, 'actual': actual.value, + 'tcb_sha256': TCB_SHA, 'native_source_evidence': evidence, + 'trust': 'Trusted OS/loader/initial system stdlib; file pins do not authenticate native memory'}, (library, call) + + +def ledger(root, allow_unclosed=False): + result = {} + runs = root / 'runtime/runs' + for folder in sorted(runs.iterdir()): + need(folder.is_dir() and not folder.is_symlink(), 'Unexpected round run entry') + if allow_unclosed and not (folder / 'receipt.json').exists(): + continue + receipt, _ = read_json(folder / 'receipt.json', 4 * 1024 * 1024) + amount = receipt.get('runner_wall_seconds', receipt.get('wall_seconds')) + need(type(amount) in (int, float) and amount >= 0, 'Invalid ledger amount') + result[folder.name] = float(amount) + return result + + +def budget(root): + phase, _ = read_json(root / 'control/EXECUTION-PHASE.json') + cap = phase['aggregate_cap_seconds'] + need(type(cap) is int and cap in (600, 2400), 'Unrecognized budget phase') + current = ledger(root) + need(sum(current.values()) < cap, 'Round budget consumed') + return cap, current + + +def parent_lock(root): + lock = (root / 'runtime/parent-queue.lock').open('a') + try: + fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) + except BaseException: + lock.close() + raise + return lock + + +class ExecutionDeadline(RuntimeError): + pass + + +def deadline_handler(signum, frame): + raise ExecutionDeadline('Outer execution deadline reached, including Popen/preexec') + + +# AI-authored adaptation of the original selected supervision and #6873 owner. +# Mutable lists are sealed by actual object identity in the source receiver. +_SUPERVISION_CURRENT = [None] +_SUPERVISION_HISTORY = [] + + +class CustodyPending(RuntimeError): + """A live actual owner remains responsible; this is never retirement.""" + pass + + +class OwnedDomain: + """One source-owned birth, retained generations, and exact terminal custody. + + The first caught exception is stored in its preallocated operation slot + before any reporting helper is entered. A normal Python memory allocation + is not represented as a guarantee of arbitrary allocation-failure recovery. + """ + def __init__(self, guard): + need(any(prior is guard for prior in _GUARD_ATTEMPTS), 'genuine reserved original guard') + self.guard = guard + self.pid = os.getpid() + self.rows, self.fds, self.groups, self.reaped = {}, {}, set(), [] + self.root = None + self.process = None + self.parent_group, self.parent_session = os.getpgrp(), os.getsid(0) + self.phase, self.birth = 'ALLOCATED', 'UNENTERED' + self.native, self.native_evidence = None, None + self.native_types, self.native_addressof, self.ctypes = None, None, None + self.native_handle, self.native_flags, self.native_call = None, None, None + self.unknown = False + self.retire_entered = self.empty_observed = self.retired = False + self.retire_deadline = None + self.close_entered = False + self.pending_error = CustodyPending('actual family custody remains pending') + self.pending_reason = None + self.last_error = None + self.first_error = None + self.error_events = [[None, None] for unused in range(1024)] + self.error_next = list(range(1, 1025)) + self.error_count = 0 + self.error_overflow = None + self.stop_signal = None + self.stop_handlers = [None, None, None] + self.stop_handler_changed = [False, False, False] + self.handler_errors = [None, None, None, None, None, None] + self.pause_errors = [None] * 16 + self.pause_next = list(range(1, 17)) + self.pause_count = 0 + self.pause_overflow = None + self.pause_error_history_complete = True + self.io = [dict(phase='FREE', fd=None, attempted_close_fd=None, path=None, working=None, + close_error=None, close_entry_error=None, sequence=None) for unused in range(32)] + self.tickets = [dict(phase='FREE', authority='UNASSIGNED', fd=None, attempted_close_fd=None, key=None, pid=None, + signal_entered=False, signal_returned=False, + wait_entered=False, wait_returned=False, + exit_observation=None, wait_status=None, + errors=[None, None, None, None, None]) + for unused in range(128)] + self.capture = [dict(kind='outer', path=None, name=name, writer=None, reader=None, read_error=None, + close_entry_error=None, observation=None, initial=None, + acquisition_boundary='BEFORE_ROOT_BIRTH') + for name in ('root.stdout.raw', 'root.stderr.raw')] + self.inner_capture = [dict(kind='inner', name=name, writer=None, reader=None, read_error=None, + acquire_error=None, close_entry_error=None, observation=None, + initial=None, path=None, attempted=False, absence_observed=False, + acquisition_boundary=None) + for name in ('stdout.txt', 'stderr.txt')] + self.all_capture = self.capture + self.inner_capture + for item in self.all_capture: + item['read_entered'], item['read_bytes'], item['raw_complete'] = False, 0, False + item['read_digest'], item['raw_eof'] = None, False + self.round_root = self.label = None + self.inner_release_prepared = False + self.cleanup_errors = [None] * 8 + self.after_root = set() + self.guard['owned_domain'] = self + + def _actual(self): + need(_SUPERVISION_CURRENT[0] is self and self.pid == os.getpid() and + self.guard['owned_domain'] is self and + any(owner is self for owner in _SUPERVISION_HISTORY), + 'actual same-process selected family custodian') + + def _check(self): + self._actual() + if self.retire_entered and time.monotonic() >= self.retire_deadline: + self.pending_reason = 'original bounded retirement tail exhausted' + raise self.pending_error + + def _io_slot(self, path): + self._actual() + need(not self.unknown, 'uncertain custody blocks fresh descriptor acquisition') + slot = next((item for item in self.io if item['phase'] in ('FREE', 'CLOSED')), None) + need(slot is not None, 'finite preallocated metadata/capture holders') + # All potentially allocating preparation precedes OPEN_PENDING. + name = str(path) + slot.update(path=name, working=None, close_error=None, close_entry_error=None, sequence=None) + slot['fd'], slot['phase'] = None, 'OPEN_PENDING' + return slot + + def open_fd(self, path, flags, mode=0o600): + slot = self._io_slot(path) + try: + slot['fd'] = os.open(path, flags, mode) + slot['phase'] = 'OWNED' + except BaseException as error: + slot['working'] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + # REQUIRED-NATIVE-PREMISES condition6: an exception class is + # never evidence that an acquiring operation acquired nothing. + slot['phase'], self.unknown = 'OPEN_UNKNOWN', True + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'open' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + raise + return slot + + def close_fd(self, slot): + if slot is None or slot['phase'] != 'OWNED': + return + fd = slot['fd'] + slot['attempted_close_fd'] = fd + slot['fd'], slot['phase'] = None, 'CLOSE_ENTERED' + try: + os.close(fd) + slot['phase'] = 'CLOSED' + except BaseException as error: + slot['close_error'] = error + slot['phase'], self.unknown = 'CLOSE_UNKNOWN', True + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'close' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + raise + + def read_metadata(self, path, cap, absent_ok=False): + self._check() + if absent_ok: + # os.stat is metadata-only in the original pinned primitive. An + # actual absent observation may skip a non-direct process, but a + # raced failure of the following open remains quarantined. + try: + os.stat(path, follow_symlinks=False) + except FileNotFoundError: + return None + slot = None + primary = None + parts, total = [], 0 + try: + slot = self.open_fd(path, os.O_RDONLY | os.O_NONBLOCK | os.O_NOFOLLOW | os.O_CLOEXEC) + while True: + data = os.read(slot['fd'], min(CHUNK, cap + 1 - total)) + if not data: + break + total += len(data) + need(total <= cap, 'bounded complete kernel metadata') + parts.append(data) + result = b''.join(parts) + except BaseException as error: + primary = error + if slot is not None: + slot['working'] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'metadata-read' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + finally: + if slot is not None: + try: + self.close_fd(slot) + except BaseException as error: + slot['close_entry_error'] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'metadata-close-helper-entry' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + if primary is None: + primary = error + if primary is not None: + raise primary + return result + + def proc(self, pid, absent_ok=False): + raw = self.read_metadata('/proc/' + str(pid) + '/stat', 8192, absent_ok) + if raw is None: + return None + end = raw.rfind(b') ') + need(end >= 0, 'complete actual process-stat grammar') + fields = raw[end + 2:].split() + need(len(fields) > 21, 'complete process identity/RSS fields') + return dict(pid=pid, ppid=int(fields[1]), pgid=int(fields[2]), + sid=int(fields[3]), start_ticks=int(fields[19]), + state=fields[0].decode('ascii'), + rss_bytes=int(fields[21]) * os.sysconf('SC_PAGE_SIZE')) + + def child_pids(self, pid, absent_ok=False): + raw = self.read_metadata('/proc/' + str(pid) + '/task/' + str(pid) + '/children', + 32768, absent_ok) + if raw is None: + return None + pids = [int(word) for word in raw.split()] + need(len(pids) <= 128 and len(set(pids)) == len(pids) and + all(0 < item <= 2147483647 for item in pids), + 'original finite distinct child identities') + return pids + + def direct(self): + rows = [] + for pid in self.child_pids(self.pid): + row = self.proc(pid) + need(row['ppid'] == self.pid, 'unreaped actual direct child') + rows.append(row) + return rows + + def install(self, root): + self._actual() + need(signal.getsignal(signal.SIGCHLD) == signal.SIG_DFL, + 'fresh-exec SIGCHLD default; exclusive consuming-wait source') + need(not self.direct(), 'no unrelated child before this original operation') + self.phase = 'SUBREAPER_INSTALL_PENDING' + evidence, native = install_subreaper(root) + self.native_evidence, self.native = evidence, native + self.native_call = native[1] + self.native_handle, self.native_flags = native[0]._handle, native[1]._flags_ + self.ctypes = sys.modules['ctypes'] + self.native_types = (self.ctypes.c_int, self.ctypes.c_ulong) + self.native_addressof = self.ctypes.addressof + need(type(native) is tuple and len(native) == 2 and + evidence['pid'] == self.pid and evidence['actual'] == 1, + 'actual original installer/native association') + self.verify_native() + need(not self.direct(), 'exact pre-birth empty same-operation domain') + self.phase = 'READY' + + def verify_native(self): + self._check() + ctypes = self.ctypes + need(sys.modules.get('ctypes') is ctypes and + ctypes.c_int is self.native_types[0] and + ctypes.c_ulong is self.native_types[1] and + ctypes.addressof is self.native_addressof, + 'retained original ctypes/native identities') + call = self.native[1] + need(call is self.native_call and self.native[0].prctl is call and + self.native[0]._name == LIBC and self.native[0]._handle == self.native_handle and + call._flags_ == self.native_flags and call.errcheck is None, + 'actual retained libc/prctl association without an added callback') + need(call.argtypes == [ctypes.c_int, ctypes.c_ulong, ctypes.c_ulong, + ctypes.c_ulong, ctypes.c_ulong] and + call.restype is ctypes.c_int, 'original prctl ABI unchanged') + current = ctypes.c_int() + need(call(37, ctypes.addressof(current), 0, 0, 0) == 0 and current.value == 1, + 'actual surviving same-process subreaper') + + def birth_pending(self): + self._actual() + need(self.phase == 'READY' and self.birth == 'UNENTERED', + 'one original selected Popen entry') + self.verify_native() + need(not self.direct(), 'no unrelated child at controlled birth boundary') + self.birth, self.phase = 'POPEN_PENDING', 'ACTIVE' + + def retain_process(self, process): + self.process = process + self.guard['actual_process'] = process + self.birth = 'POPEN_RETURNED' + row = self.proc(process.pid) + need(row['ppid'] == self.pid and row['pgid'] == row['sid'] == process.pid, + 'actual unreaped new-session direct root') + self.root = generation(row) + self.add(row) + return row + + def add(self, row): + key = generation(row) + authority = 'DIRECT' if row['ppid'] == self.pid else 'OBSERVATION' + # An old observational pidfd is never promoted by a matching numeric + # generation. Adoption gets a fresh pidfd while the actual direct child + # is unreaped. Both holders remain until exact domain emptiness. + old = next((item for item in self.tickets if item['key'] == key and + item['authority'] == authority), None) + if old is not None: + need(not old['wait_entered'], 'consumed generation never re-enters custody') + return old + need(not self.unknown and row['pid'] != self.pid, + 'no new native child holder after uncertain custody') + ticket = next((item for item in self.tickets if item['phase'] == 'FREE'), None) + need(ticket is not None, 'original 128 native-holder capacity; no automatic increase') + ticket['authority'] = authority + ticket['pid'], ticket['key'], ticket['phase'] = row['pid'], key, 'PIDFD_PENDING' + try: + ticket['fd'] = os.pidfd_open(row['pid'], 0) + ticket['phase'] = 'OWNED' + current = self.proc(row['pid'], row['ppid'] != self.pid) + if current is None or generation(current) != key: + # A non-direct child may be reaped by its actual parent. The + # acquired pidfd remains owned until whole-domain retirement. + ticket['phase'] = 'STALE_OWNED' + return ticket + if authority == 'DIRECT': + need(current['ppid'] == self.pid, 'same unreaped direct child across pidfd acquisition') + self.rows[key] = dict(current) + self.fds[key] = ticket['fd'] + if current['pgid'] != self.parent_group: + self.groups.add((current['pgid'], current['sid'])) + except BaseException as error: + ticket['errors'][0] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if ticket['phase'] == 'PIDFD_PENDING': + ticket['phase'], self.unknown = 'PIDFD_UNKNOWN', True + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'pidfd-open' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + raise + return ticket + + def observe(self): + # Exact parent-to-child traversal replaces a broad census whose omitted + # unreadable direct child could previously masquerade as an empty domain. + self.verify_native() + rows = self.direct() + queue = list(rows) + all_rows = {} + while queue: + row = queue.pop(0) + key = generation(row) + if row['pid'] in all_rows: + need(generation(all_rows[row['pid']]) == key, 'one current process generation') + continue + need(len(all_rows) < 128, 'original current descendant bound') + self.add(row) + all_rows[row['pid']] = row + children = self.child_pids(row['pid'], row['ppid'] != self.pid) + if children is None: + continue + for pid in children: + child = self.proc(pid, True) + if child is not None and child['ppid'] == row['pid']: + queue.append(child) + return all_rows, list(all_rows.values()) + + def _exit_observation(self, ticket): + self._check() + need(ticket['phase'] == 'OWNED' and ticket['authority'] == 'DIRECT' and + not ticket['wait_entered'], 'actual direct-child holder before any consuming wait') + observed = os.waitid(os.P_PID, ticket['pid'], os.WEXITED | os.WNOWAIT | os.WNOHANG) + if observed is not None: + need(observed.si_pid == ticket['pid'], 'same retained direct exit') + ticket['exit_observation'] = observed + return observed + + def root_exit_observed(self): + ticket = next(item for item in self.tickets if item['key'] == self.root and item['authority'] == 'DIRECT') + return self._exit_observation(ticket) is not None + + def _signal_once(self, ticket): + need(ticket['authority'] == 'DIRECT', 'observational pidfds never grant signal authority') + if ticket['signal_entered'] or ticket['wait_entered']: + return + self._check() + ticket['signal_entered'] = True + try: + signal.pidfd_send_signal(ticket['fd'], signal.SIGKILL, None, 0) + ticket['signal_returned'] = True + except BaseException as error: + ticket['errors'][1] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'pidfd-signal' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + + def _consume_once(self, ticket): + self._check() + need(ticket['authority'] == 'DIRECT' and ticket['exit_observation'] is not None and + not ticket['wait_entered'], 'actual direct exit before one consuming wait') + ticket['wait_entered'] = True + try: + pid, status = os.waitpid(ticket['pid'], os.WNOHANG) + need(pid == ticket['pid'], 'exclusive same-generation consuming wait') + ticket['wait_returned'], ticket['wait_status'] = True, status + if ticket['key'] == self.root and self.process is not None: + # Retain consumed status before any append/report operation. + self.process.returncode = os.waitstatus_to_exitcode(status) + else: + self.reaped.append(dict(pid=pid, start_ticks=ticket['key'][1], wait_status=status)) + except BaseException as error: + ticket['errors'][2] = error + self.unknown = True + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'consuming-wait' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + + def _empty_exact(self): + self._check() + if self.direct(): + return False + try: + os.waitid(os.P_ALL, 0, os.WEXITED | os.WNOWAIT | os.WNOHANG) + except ChildProcessError: + return not self.direct() + return False + + def _close_holders_once(self): + need(self.empty_observed and not self.close_entered, + 'actual domain emptiness precedes native-holder release') + self.close_entered = True + for ticket in self.tickets: + if ticket['phase'] not in ('OWNED', 'STALE_OWNED'): + continue + self._check() + fd = ticket['fd'] + ticket['attempted_close_fd'] = fd + ticket['fd'], ticket['phase'] = None, 'CLOSE_ENTERED' + try: + os.close(fd) + ticket['phase'] = 'CLOSED' + except BaseException as error: + ticket['phase'], ticket['errors'][3] = 'CLOSE_UNKNOWN', error + self.unknown = True + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'pidfd-close' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + # Keep historical key->fd identities for evidence. Closed numeric values + # are never used again, and rows/tickets remain retained by this owner. + + def cleanup(self, process, absolute_deadline): + self._actual() + need(not self.retire_entered, 'one actual bounded retirement entry') + self.retire_entered = True + start = time.monotonic() + self.retire_deadline = min(absolute_deadline, start + CLEANUP_SECONDS) + self.phase = 'RETIRING' + try: + while True: + self._check() + if self.unknown or self.birth == 'POPEN_UNKNOWN': + # Popen may have acquired private native holders before its + # result failed to reach us. Retain the actual exception and + # its frames. Never infer absence from no returned object. + for ticket in self.tickets: + if ticket['phase'] == 'OWNED' and ticket['authority'] == 'DIRECT' and not ticket['wait_entered']: + self._signal_once(ticket) + self.pending_reason = 'uncertain acquisition/wait/close or Popen return' + raise self.pending_error + self.verify_native() + direct = self.direct() + for row in direct: + if self.process is not None and row['pid'] == self.process.pid and self.root is None: + self.root = generation(row) + ticket = self.add(row) + if self.process is not None and self.process.returncode is not None and row['pid'] != self.process.pid: + self.after_root.add(generation(row)) + if self._exit_observation(ticket) is None: + self._signal_once(ticket) + if self._exit_observation(ticket) is not None: + self._consume_once(ticket) + if self.unknown: + continue + if self._empty_exact(): + self.empty_observed = True + self._close_holders_once() + if self.unknown: + self.pending_reason = 'empty domain but native holder close is uncertain' + raise self.pending_error + self.retired, self.phase = True, 'RETIRED' + break + time.sleep(0.01) + except BaseException as error: + self.cleanup_errors[0] = error + self.last_error = error + if error is not self.pending_error: + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'domain-retirement' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + self.phase = 'CUSTODY_PENDING' + return self.observation(start) + + def observation(self, start): + return dict(complete=self.retired and not self.unknown, + owned_generations=list(self.rows.values()), + groups=[dict(pgid=g, sid=s) for g, s in sorted(self.groups)], + reaped_adopted=self.reaped, + observed_after_root_exit=[list(key) for key in sorted(self.after_root)], + remaining=[] if self.empty_observed else 'UNKNOWN_UNRETIRED_DOMAIN', + cleanup_seconds=time.monotonic() - start, + cleanup_tail_limit_seconds=CLEANUP_SECONDS, + group_empty_proved=self.empty_observed, + kernel_echild_and_direct_empty=self.empty_observed and self.retire_entered, + emptiness_basis=('KERNEL_ECHILD_AND_DIRECT_EMPTY' if self.empty_observed and self.retire_entered + else 'NO_CONTROLLED_BIRTH_SOURCE_EDGE' if self.empty_observed and self.birth == 'UNENTERED' + else 'UNKNOWN'), + holders_retired=self.retired and not self.unknown, + phase=self.phase, birth=self.birth, + signal_method='one SIGKILL through fresh direct-child pidfd before one WNOWAIT-authorised consuming wait; observational pidfds never signal; no killpg', + direct_authority_holders=sum(item['authority'] == 'DIRECT' for item in self.tickets), + observational_holders=sum(item['authority'] == 'OBSERVATION' for item in self.tickets), + total_native_holder_capacity=128) + + def stop_handler(self, signum, frame): + if self.stop_signal is None: + self.stop_signal = signum + + def install_stop_handlers(self): + for index, signum in enumerate((signal.SIGINT, signal.SIGTERM, signal.SIGHUP)): + self.stop_handlers[index] = signal.getsignal(signum) + self.stop_handler_changed[index] = True + signal.signal(signum, self.stop_handler) + + def restore_stop_handlers(self): + need(self.retired and not self.unknown, 'known retirement before ordinary handler restoration') + for index, signum in enumerate((signal.SIGINT, signal.SIGTERM, signal.SIGHUP)): + if not self.stop_handler_changed[index]: + continue + self.stop_handler_changed[index] = False + try: + signal.signal(signum, self.stop_handlers[index]) + except BaseException as error: + self.handler_errors[index + 3] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'restore-stop-handler' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + + def hold_pending(self): + # Reached by run_root whenever retirement/holder knowledge is incomplete. + # This is the very same original parent and original unclosed operation. + # No return, exception unwind, replacement owner, new attempt, retry, + # grant, or budget is created. Continuing physical cost stays OPEN. + self.phase = 'ACTUAL_SURVIVING_CUSTODY_PENDING' + self.guard['surviving_pending_owner'] = self + while True: + try: + signal.pause() + except BaseException as error: + if self.pause_count < 16: + self.pause_errors[self.pause_count] = error + self.pause_count = self.pause_next[self.pause_count] + elif self.pause_overflow is None: + self.pause_overflow = error + else: + self.pause_error_history_complete = False + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + + def prepare_capture(self, evidence): + # Both immutable reader identities are acquired before the only birth. + for item in self.capture: + path = evidence / item['name'] + item['path'] = path + item['writer'] = self.open_fd(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | + os.O_CLOEXEC | os.O_NOFOLLOW) + item['reader'] = self.open_fd(path, os.O_RDONLY | os.O_NONBLOCK | + os.O_CLOEXEC | os.O_NOFOLLOW) + a, b = os.fstat(item['writer']['fd']), os.fstat(item['reader']['fd']) + need(stat.S_ISREG(a.st_mode) and stat.S_IMODE(a.st_mode) == 0o600 and + a.st_uid == os.getuid() and a.st_nlink == 1 and + identity(a) == identity(b) == identity(path.lstat()), + 'same exclusive parent capture writer/preowned reader') + item['initial'] = (a.st_dev, a.st_ino, a.st_mode, a.st_uid, a.st_nlink) + + def read_capture_known(self, item): + """Read available held bytes before name/initial-seal corroboration.""" + reader = item['reader'] + need(reader is not None and reader['phase'] == 'OWNED', 'actual retained capture reader') + fd, path = reader['fd'], item['path'] + item['read_entered'] = True + before = os.fstat(fd) + need(stat.S_ISREG(before.st_mode) and before.st_size <= LOG_CAP, + 'actual bounded regular capture descriptor') + need(os.lseek(fd, 0, os.SEEK_SET) == 0, 'retained capture reader starts at zero') + digest, total = hashlib.sha256(), 0 + item['read_digest'] = digest + while total < before.st_size: + data = os.read(fd, min(CHUNK, before.st_size - total)) + need(bool(data), 'complete available bounded capture') + total += len(data) + item['read_bytes'] = total + digest.update(data) + eof = os.read(fd, 1) + item['raw_eof'] = eof == b'' + item['raw_complete'] = total == before.st_size and eof == b'' + after = os.fstat(fd) + # An earlier failed identity-seal operation does not suppress reading + # an available known descriptor. It still prevents accepted evidence. + need(item['initial'] is not None and + (before.st_dev, before.st_ino, before.st_mode, before.st_uid, before.st_nlink) == + item['initial'] and eof == b'' and + identity(before) == identity(after) == identity(path.lstat()), + 'stable complete capture EOF and original named inode after domain emptiness') + item['observation'] = dict(path=str(path), sha256=digest.hexdigest(), bytes=total, + identity=list(identity(after)), stable=True, + full_read=True, eof=True, + reader_acquisition_boundary=item['acquisition_boundary'], + read_chunk_bytes=CHUNK) + return item['observation'] + + def prepare_inner_capture(self, guard, captured): + self._actual() + need(guard is self.guard and guard['phase'] == 'WAITING_REQUEST' and + generation(captured) == self.root and self.birth == 'POPEN_RETURNED' and + not self.inner_release_prepared and self.round_root is not None, + 'actual source-authenticated original runner before target release') + for item in self.inner_capture: + need(not item['attempted'] and item['reader'] is None and + item['path'] == self.round_root / 'runtime/runs' / self.label / item['name'], + 'one actual original label/folder capture acquisition') + item['attempted'] = True + item['reader'] = self.open_fd(item['path'], os.O_RDONLY | os.O_NONBLOCK | + os.O_NOFOLLOW | os.O_CLOEXEC) + info = os.fstat(item['reader']['fd']) + need(stat.S_ISREG(info.st_mode) and info.st_uid == os.getuid() and + info.st_nlink == 1 and not info.st_mode & 0o022 and + identity(info) == identity(item['path'].lstat()), + 'actual exclusive original runner inner capture inode') + item['initial'] = (info.st_dev, info.st_ino, info.st_mode, info.st_uid, info.st_nlink) + item['acquisition_boundary'] = 'AUTHENTICATED_BEFORE_TARGET_ACK' + self.inner_release_prepared = True + + def acquire_retired_inner(self, item): + # Only a pre-ACK failure can reach this fallback. A working error alone + # does not prohibit a safe read acquisition after proved retirement. + self._actual() + need(self.empty_observed and self.retired and not self.unknown and + item['kind'] == 'inner' and item['reader'] is None and + not item['attempted'] and self.round_root is not None and + item['path'] == self.round_root / 'runtime/runs' / self.label / item['name'], + 'known retirement and exact original label before fallback read') + try: + before = item['path'].lstat() + except FileNotFoundError: + item['absence_observed'] = True + item['acquisition_boundary'] = 'NOT_CREATED_BEFORE_KNOWN_RETIREMENT' + return + need(stat.S_ISREG(before.st_mode) and before.st_uid == os.getuid() and + before.st_nlink == 1 and not before.st_mode & 0o022, + 'original source-owned retained inner capture') + item['attempted'] = True + item['reader'] = self.open_fd(item['path'], os.O_RDONLY | os.O_NONBLOCK | + os.O_NOFOLLOW | os.O_CLOEXEC) + opened = os.fstat(item['reader']['fd']) + need(identity(before) == identity(opened) == identity(item['path'].lstat()), + 'complete actual original inner-capture open join') + item['initial'] = (opened.st_dev, opened.st_ino, opened.st_mode, opened.st_uid, opened.st_nlink) + item['acquisition_boundary'] = 'AFTER_PROVED_RETIREMENT_WITH_CERTAIN_CUSTODY' + + def capture_after_retirement(self): + # Four preallocated stream records, with independent read/close attempts. + # No optional reporting helper is entered between these attempts. + for item in self.all_capture: + if (self.empty_observed and self.retired and not self.unknown and + item['kind'] == 'inner' and item['reader'] is None and + not item['attempted'] and self.round_root is not None): + try: + self.acquire_retired_inner(item) + except BaseException as error: + item['acquire_error'] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'inner-capture-acquire' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + if self.empty_observed and item['reader'] is not None and item['reader']['phase'] == 'OWNED': + try: + self.read_capture_known(item) + except BaseException as error: + item['read_error'] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'capture-full-read' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + if self.empty_observed and item['reader'] is not None: + try: + self.close_fd(item['reader']) + except BaseException as error: + item['close_entry_error'] = error + self.last_error = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + if self.error_count < 1024: + self.error_events[self.error_count][0] = 'capture-reader-close' + self.error_events[self.error_count][1] = error + self.error_count = self.error_next[self.error_count] + else: + self.unknown = True + + def close_capture_writers(self): + for item in self.capture: + if item['writer'] is not None: + try: + self.close_fd(item['writer']) + except BaseException as error: + self.cleanup_errors[4 if item['name'] == 'root.stdout.raw' else 5] = error + if self.first_error is None: + self.first_error = error + if self.guard['primary'][0] is None: + self.guard['primary'][0] = error + + +def reconcile_missing_receipt(root, label, began, cause, cleanup): + folder = root / 'runtime/runs' / label + folder.mkdir(exist_ok=True) + if not cleanup['complete'] and not (folder / 'receipt.json').exists(): + # A surviving root must never race a replacement canonical receipt. + # Leave its attempt unclosed, blocking the unchanged runner, and add a + # distinct charged STOP record for the parent to reconcile manually. + folder = root / 'runtime/runs' / (label + '-outer-unclosed-stop') + folder.mkdir() + path = folder / 'receipt.json' + if path.exists(): + return None + start = {} + if (folder / 'START.json').exists(): + start, _ = read_json(folder / 'START.json') + row = dict(start, schema='h25-outer-reconciled-stop-v1', status='STOP', label=label, + kind='outer_reconciled_incomplete_root', termination=cause, attempt_label=label, + wall_seconds=time.monotonic() - began, original_root_receipt_absent=True, + original_root_completion_claimed=False, cleanup_complete=cleanup['complete'], + all_prior_files_preserved=True) + row['label'] = folder.name + row['runner_wall_seconds'] = row['wall_seconds'] + if not (folder / 'START.json').exists(): + write_new(folder / 'START.json', {'kind': row['kind'], 'label': label}) + write_new(path, row) + return row + + +# Additive V2 before-target guard. The admitted single-writer/no-mutator startup +# premise is inherited; these files are not a hostile-child authentication claim. +GUARD_CAP = 1048576 +MARKER_CAP = 1048576 +_GUARD_ATTEMPTS = [] + + +def _guard_exact(value, keys): + need(type(value) is dict and all(type(k) is str for k in value) and + set(value) == set(keys), 'Guard exact native keys differ') + + +def _guard_bytes(value): + raw = json.dumps(value, sort_keys=True, indent=2, ensure_ascii=True, allow_nan=False).encode('ascii') + b'\n' + need(len(raw) <= GUARD_CAP, 'Guard complete packet exceeds bounded channel') + return raw + + +def _guard_digest(value): + need(type(value) is str and len(value) == 64 and + all(c in '0123456789abcdef' for c in value), 'Guard exact digest differs') + + +def _guard_path(value): + need(type(value) is str and value.startswith('/') and len(value) <= 4096 and + all(c not in ('', '.', '..') for c in value.split('/')[1:]), 'Guard absolute path differs') + cursor = Path('/') + for component in Path(value).parts[1:-1]: + cursor = cursor / component + info = cursor.stat(follow_symlinks=False) + need(stat.S_ISDIR(info.st_mode), 'Guard parent path is not a genuine directory') + + +def _guard_generation(row): + _guard_exact(row, ('pid', 'start_ticks')) + need(all(type(row[k]) is int and 0 < row[k] and row[k].bit_length() <= 128 for k in row), 'Guard generation exact integers required') + + +def _guard_leaf(row): + _guard_exact(row, ('pid', 'ppid', 'pgid', 'sid', 'start_ticks')) + need(all(type(row[k]) is int and 0 < row[k] and row[k].bit_length() <= 128 for k in row), 'Guard leaf exact integers required') + + +def _guard_source(pin): + _guard_exact(pin, ('path', 'sha256', 'bytes')) + _guard_path(pin['path']); _guard_digest(pin['sha256']) + need(type(pin['bytes']) is int and 0 <= pin['bytes'] <= 8388608, 'Guard complete source bound') + row = stable_file(pin['path'], 8388608) + need(row['sha256'] == pin['sha256'] and row['bytes'] == pin['bytes'] and + not row['identity'][2] & 0o222, 'Guard immutable exact source changed') + + +def _guard_binding(binding): + _guard_exact(binding, ('case_id', 'context_id', 'unit_id', 'mode', 'action_id', 'generation', + 'nonce', 'parent_generation', 'component_source', 'entry_source', 'supervisor_source', + 'context_sha256', 'marker_path', 'request_path', 'ack_path', 'consume_path', 'timeout_milliseconds')) + for key in ('case_id', 'context_id', 'unit_id', 'action_id', 'generation'): + need(type(binding[key]) is str and 0 < len(binding[key]) <= 256, 'Guard declared identity differs') + need(type(binding['mode']) is str and binding['mode'] in ('normal', 'optimized'), 'Guard declared mode differs') + for key in ('nonce', 'context_sha256'): + _guard_digest(binding[key]) + _guard_generation(binding['parent_generation']) + need(type(binding['timeout_milliseconds']) is int and 1 <= binding['timeout_milliseconds'] <= 180000, + 'Guard deadline allocation differs') + for key in ('marker_path', 'request_path', 'ack_path', 'consume_path'): + _guard_path(binding[key]) + paths = [binding[k] for k in ('marker_path','request_path','ack_path','consume_path')] + paths += [binding[k] + '.pending' for k in ('request_path','ack_path','consume_path')] + need(len(set(paths)) == len(paths), 'Guard channel/marker path reused') + for key in ('component_source','entry_source','supervisor_source'): + _guard_source(binding[key]) + need(binding['supervisor_source']['path'] == __file__, 'Actual guard supervisor source origin differs') + _guard_bytes(binding) + + +def _guard_read(path): + before=os.stat(path,follow_symlinks=False) + need(before.st_nlink==1,'Guard final custody requires one link') + pin, raw = stable_file(path, GUARD_CAP, True) + after=os.stat(path,follow_symlinks=False) + need(after.st_nlink==1 and identity(before)==identity(after),'Guard single-link custody changed during read') + value = json.loads(raw) + need(_guard_bytes(value) == raw and not pin['identity'][2] & 0o222, + 'Guard complete canonical immutable packet required') + return value, pin + + +_PUBLICATION_BINDING = [None] + + +def prepare_atomic_publication(root, admission): + """Before-capture initialization by the externally authenticated caller. + + Input digests do not create authority. The actual caller must bind this + exact source/ABI/native profile and grant the operation before invoking it. + No native call or import occurred while authoring this source. + """ + need(_PUBLICATION_BINDING[0] is None, 'Atomic publication initializer already consumed') + state={'phase':'PREPARING','primary':[None],'secondary':[],'pid':os.getpid(), + 'library':None,'library_entered':False,'library_returned':False, + 'call':None,'call_binding_entered':False,'call_binding_returned':False} + _PUBLICATION_BINDING[0]=state # no retry after any partial load/binding + try: + launch_contract() + need(not _GUARD_ATTEMPTS,'Publication binding must precede every guard attempt') + _guard_exact(admission, ('schema','source_sha256','source_review_sha256','primitive_review_sha256', + 'kernel_profile_sha256','runtime_premise_sha256','command_approval_sha256','funding_sha256')) + need(admission['schema']=='h25-exclusive-single-link-publication-admission-v1', 'Publication admission shape differs') + for name in admission: + if name!='schema': + _guard_digest(admission[name]) + need(stable_file(__file__,8388608)['sha256']==admission['source_sha256'], 'Actual publication source differs') + tcb,tcb_pin=read_json(Path(root)/'control/NATIVE-INITIAL-TCB-v1.json') + need(tcb_pin['sha256']==TCB_SHA and any(r['path']==LIBC and r['sha256']==NATIVE_PINS[LIBC] + for r in tcb['files']), 'Publication original native premise differs') + source_evidence={name:stable_file(name,16*1024*1024) for name in NATIVE_PINS} + need(all(source_evidence[name]['sha256']==expected for name,expected in NATIVE_PINS.items()), + 'Publication libc/ctypes/libffi source supplement differs') + need(Path('/usr/lib/x86_64-linux-gnu/libffi.so.8').resolve()== + Path('/usr/lib/x86_64-linux-gnu/libffi.so.8.1.4'), 'Publication libffi SONAME differs') + import ctypes + need(ctypes.__file__=='/usr/lib/python3.12/ctypes/__init__.py' and + sys.modules['_ctypes'].__file__=='/usr/lib/python3.12/lib-dynload/_ctypes.cpython-312-x86_64-linux-gnu.so', + 'Publication ctypes owners differ') + state['module']=ctypes;state['source_evidence']=source_evidence;state['admission']=admission + state['library_entered']=True + library=ctypes.CDLL(LIBC,use_errno=True) + state['library']=library;state['library_returned']=True + state['call_binding_entered']=True + call=library.renameat2 # existing glibc symbol; absence stops, no fallback + state['call']=call;state['call_binding_returned']=True + signature=(ctypes.c_int,ctypes.c_char_p,ctypes.c_int,ctypes.c_char_p,ctypes.c_uint) + call.argtypes=list(signature);call.restype=ctypes.c_int + state.update({'module':ctypes,'library':library,'library_type':type(library),'call':call, + 'call_type':type(call),'call_flags':call._flags_,'library_handle':library._handle, + 'signature':signature,'get_errno':ctypes.get_errno, + 'set_errno':ctypes.set_errno,'source_evidence':source_evidence,'admission':admission, + 'admission_raw':_guard_bytes(admission),'source_path':__file__}) + for name,expected in NATIVE_PINS.items(): + need(stable_file(name,16*1024*1024)['sha256']==expected, 'Publication TCB drift across binding') + state['phase']='SEALED' + _publication_binding() + return None + except BaseException as error: + state['primary'][0]=error;state['phase']='STOP' + raise + + +def _publication_binding(): + state=_PUBLICATION_BINDING[0] + need(state is not None and state['phase']=='SEALED' and state['pid']==os.getpid() and + state['primary'][0] is None, 'Actual before-capture publication binding required') + module=state['module'];call=state['call'] + need(sys.modules.get('ctypes') is module and type(state['library']) is state['library_type'] and + state['library_type'] is module.CDLL and type(call) is state['call_type'] and + state['library'].renameat2 is call and module.get_errno is state['get_errno'] and + module.set_errno is state['set_errno'], 'Publication native function/owner binding changed') + actual=(module.c_int,module.c_char_p,module.c_int,module.c_char_p,module.c_uint) + need(all(a is z for a,z in zip(actual,state['signature'])) and + type(call.argtypes) is list and len(call.argtypes)==5 and + all(a is z for a,z in zip(call.argtypes,state['signature'])) and call.restype is module.c_int, + 'Publication exact renameat2 ABI changed') + need(type(state['library']._name) is str and state['library']._name==LIBC and + type(state['library']._handle) is int and state['library']._handle>0 and + state['library']._handle==state['library_handle'] and + type(call._flags_) is int and call._flags_==state['call_flags'] and call.errcheck is None, + 'Publication library handle/flags or hidden native callback changed') + need(_guard_bytes(state['admission'])==state['admission_raw'] and + stable_file(state['source_path'],8388608)['sha256']==state['admission']['source_sha256'], + 'Publication source/admission drifted') + for name,expected in NATIVE_PINS.items(): + need(stable_file(name,16*1024*1024)['sha256']==expected, 'Publication TCB current source drifted') + return state + + +def _publication_stat(path): + try: + info=os.stat(path,follow_symlinks=False) + except FileNotFoundError: + return {'path':str(path),'exists':False} + return {'path':str(path),'exists':True,'device':info.st_dev,'inode':info.st_ino,'mode':info.st_mode, + 'links':info.st_nlink,'bytes':info.st_size,'uid':info.st_uid,'gid':info.st_gid, + 'mtime_ns':info.st_mtime_ns,'ctime_ns':info.st_ctime_ns} + + +def _publication_close(token,custody): + if token['fd'] is None or token['closed']: + return + token['closed']=True # close entered once; ambiguity never causes retry + try: + os.close(token['fd']) + except BaseException as error: + if token['primary'][0] is None: + token['primary'][0]=error + else: + token['secondary'].append(error);custody['secondary'].append(error) + + +def _guard_publish(path, value, custody): + # The only publication operation moves a complete immutable staging inode + # with renameat2(RENAME_NOREPLACE). No hardlink alias ever becomes visible. + _guard_path(path) + native=_publication_binding() # authenticated before any packet acquisition + raw=_guard_bytes(value);pending=Path(path+'.pending') + record={'stage':str(pending),'final':path,'raw':raw,'before_stage':None,'before_final':None, + 'after_stage':None,'after_final':None,'directory_identity':None,'entered':False,'returned':False,'result':None, + 'errno':None,'committed':False,'uncertain':True,'primary':[None],'secondary':[],'tokens':[]} + custody.setdefault('publications',[]).append(record) + token={'fd':None,'entered':True,'closed':False,'primary':[None],'secondary':[]} + directory={'fd':None,'entered':True,'closed':False,'primary':[None],'secondary':[]} + custody.setdefault('io',[]).extend((token,directory));record['tokens']=[token,directory] + try: + token['fd']=os.open(pending,os.O_WRONLY|os.O_CREAT|os.O_EXCL|os.O_CLOEXEC|os.O_NOFOLLOW,0o600) + view=memoryview(raw) + while view: + count=os.write(token['fd'],view);need(count>0,'Guard complete write made no progress') + view=view[count:] + os.fsync(token['fd']) + os.fchmod(token['fd'],0o400) + os.fsync(token['fd']) + _publication_close(token,custody) + if token['primary'][0] is not None: + raise token['primary'][0] + before,retained=stable_file(pending,GUARD_CAP,True) + record['before_stage']=_publication_stat(pending);record['before_final']=_publication_stat(path) + need(retained==raw and record['before_stage']['links']==1 and + not record['before_stage']['mode'] & 0o222 and + before['identity']==[record['before_stage'][k] for k in + ('device','inode','mode','bytes','mtime_ns','ctime_ns')], + 'Complete immutable single-link staging custody differs') + directory['fd']=os.open(str(Path(path).parent),os.O_RDONLY|os.O_DIRECTORY|os.O_NOFOLLOW|os.O_CLOEXEC) + source_parent=Path(pending).parent;final_parent=Path(path).parent + held=os.fstat(directory['fd']);named=os.stat(final_parent,follow_symlinks=False) + record['directory_identity']={'device':held.st_dev,'inode':held.st_ino,'mode':held.st_mode} + relative_stage=os.stat(pending.name,dir_fd=directory['fd'],follow_symlinks=False) + need(source_parent==final_parent and stat.S_ISDIR(held.st_mode) and + (held.st_dev,held.st_ino)==(named.st_dev,named.st_ino) and + (relative_stage.st_dev,relative_stage.st_ino)== + (record['before_stage']['device'],record['before_stage']['inode']), + 'Publication source and target do not share the authenticated held parent') + # Both names are relative to the same held directory. No pre-check is + # trusted for destination exclusivity: the primitive enforces it atomically. + native['set_errno'](0) + record['entered']=True;record['uncertain']=True + result=native['call'](directory['fd'],os.fsencode(pending.name), + directory['fd'],os.fsencode(Path(path).name),1) + record['returned']=True;record['result']=result + need(type(result) is int and result in (0,-1),'Publication native return outside exact ABI') + if result!=0: + record['errno']=native['get_errno']() + need(type(record['errno']) is int and record['errno']>0,'Publication failure errno unavailable') + raise OSError(record['errno'],'Exclusive atomic single-link publication failed',path) + record['committed']=True + os.fsync(directory['fd']) + record['after_stage']=_publication_stat(pending);record['after_final']=_publication_stat(path) + need(record['after_stage']['exists'] is False and record['after_final']['exists'] is True and + record['after_final']['links']==1 and + all(record['after_final'][k]==record['before_stage'][k] for k in + ('device','inode','mode','bytes','uid','gid','mtime_ns')), + 'Atomic single-link move custody differs') + observed,pin=_guard_read(path) + need(_guard_bytes(observed)==raw,'Guard atomic publication complete readback differs') + _publication_close(directory,custody) + if directory['primary'][0] is not None: + raise directory['primary'][0] + record['uncertain']=False + return pin + except BaseException as error: + record['primary'][0]=error + if custody['primary'][0] is None: + custody['primary'][0]=error + elif custody['primary'][0] is not error: + custody['secondary'].append(error) + # Metadata only; never remove, overwrite, finish, or retry an uncertain + # stage/final. Exact raw and all known tokens remain in same-process custody. + for key,name in [('after_stage',pending),('after_final',path)]: + try: + record[key]=_publication_stat(name) + except BaseException as secondary: + record['secondary'].append(secondary);custody['secondary'].append(secondary) + raise + finally: + _publication_close(token,custody);_publication_close(directory,custody) + if record['primary'][0] is not None: + for item in (token,directory): + if item['primary'][0] is not None and item['primary'][0] is not record['primary'][0]: + record['secondary'].append(item['primary'][0]);custody['secondary'].append(item['primary'][0]) + + +def _guard_fail(guard, error): + if guard['primary'][0] is None: + guard['primary'][0] = error + elif guard['primary'][0] is not error: + guard['secondary'].append(error) + guard['phase'] = 'STOP' + + +def _guard_begin(case, deadline, guard=None): + if guard is None: + guard = _guard_reserve(deadline) + need(any(prior is guard for prior in _GUARD_ATTEMPTS), 'actual source-reserved guard') + try: + binding = case['family_guard'] + _guard_binding(binding) + need(binding['action_id'] == case['family_action_id'] and binding['generation'] == case['family_generation'], + 'Guard original action/generation source binding differs') + current = proc(os.getpid()) + need(current is not None and binding['parent_generation'] == + {'pid': current['pid'], 'start_ticks': current['start_ticks']}, 'Guard actual owning parent differs') + for old in _GUARD_ATTEMPTS[:-1]: + prior = old['binding'] + if prior is not None: + need(prior['nonce'] != binding['nonce'] and prior['generation'] != binding['generation'], + 'Guard release generation/nonce already consumed') + guard['binding'] = binding + for key in ('marker_path','request_path','ack_path','consume_path'): + path = Path(binding[key]) + need(not path.exists() and not path.is_symlink(), 'Stale/reused guard channel or marker') + if key != 'marker_path': + need(not Path(str(path) + '.pending').exists() and not Path(str(path) + '.pending').is_symlink(), + 'Stale/reused guard publication') + guard['deadline'] = min(deadline, time.monotonic() + binding['timeout_milliseconds'] / 1000) + guard['checkpoint'] = 'WAITING_REQUEST' + guard['phase'] = 'WAITING_REQUEST' + return guard + except BaseException as error: + if guard['primary'][0] is None: + guard['primary'][0] = error + _guard_fail(guard, error) + raise + + +def _guard_step(guard, domain, all_rows, current, captured): + try: + binding = guard['binding'] + if guard['phase'] == 'CONSUMED_RELEASE': + # The published request/release/consumption remain immutable through + # the entire child lifetime; final outer validation repeats this. + for key,pin in [('request_path',guard['request_pin']),('ack_path',guard['ack_pin']), + ('consume_path',guard['consume_pin'])]: + _, actual = _guard_read(binding[key]) + need(actual == pin, 'Guard retained packet drifted after release') + return + need(time.monotonic() <= guard['deadline'], 'Before-target parent guard deadline expired') + if guard['phase'] == 'WAITING_REQUEST': + request_path = Path(binding['request_path']) + if not request_path.exists(): + return + request, request_pin = _guard_read(request_path) + _guard_exact(request, ('schema','binding','process','marker')) + need(type(request['schema']) is str and request['schema'] == 'h25-family-guard-request-v2' and + _guard_bytes(request['binding']) == _guard_bytes(binding), 'Guard request expected source/context differs') + leaf = request['process']; _guard_leaf(leaf) + marker = request['marker']; _guard_exact(marker, ('path','sha256','bytes')) + need(type(marker['path']) is str and marker['path'] == binding['marker_path'] and + type(marker['bytes']) is int and 0 <= marker['bytes'] <= MARKER_CAP, 'Guard marker bound differs') + _guard_digest(marker['sha256']) + marker_pin, marker_raw = stable_file(marker['path'], MARKER_CAP, True) + need(marker_pin['sha256'] == marker['sha256'] and marker_pin['bytes'] == marker['bytes'], + 'Guard complete source/context marker changed') + marked = json.loads(marker_raw) + need(type(marked) is dict and type(marked.get('actual_context')) is dict and + marked.get('schema') == 'h25-component-pretarget-identity-v1' and + all(type(marked.get(k)) is str and marked[k] == binding[k] for k in + ('case_id','context_id','unit_id','mode')) and + marked.get('component_source_path') == binding['component_source']['path'], + 'Guard actual case/context/unit/mode/source marker differs') + context_raw = json.dumps(marked['actual_context'], sort_keys=True, separators=(',', ':'), + ensure_ascii=True, allow_nan=False).encode('ascii') + b'\n' + need(hashlib.sha256(context_raw).hexdigest() == binding['context_sha256'] and + all(type(marked['process'][k]) is int and marked['process'][k] == leaf[k] for k in leaf), + 'Guard actual context or process differs') + _guard_binding(binding) # complete immutable sources again before ACK + key = generation(leaf) + live = proc(leaf['pid']); root_live = proc(captured['pid']) + need(live is not None and root_live is not None and live['state'] != 'Z' and root_live['state'] != 'Z' and + generation(root_live) == domain.root and key in domain.rows and key in domain.fds and + all(type(live[k]) is int and live[k] == leaf[k] for k in leaf) and + any(generation(r) == key for r in current), 'Guard leaf is not a live generation-owned child') + cursor = leaf['pid']; seen = set() + while cursor != captured['pid']: + need(cursor not in seen and len(seen) < 128 and cursor in all_rows, + 'Guard live ancestor chain to captured Root absent') + seen.add(cursor); cursor = all_rows[cursor]['ppid'] + need(generation(all_rows[captured['pid']]) == domain.root, + 'Guard captured Root generation no longer current') + # The actual pinned runner created its two inner files before + # launching this waiting child. Hold their read descriptors before + # authenticating release of the selected component body. + domain.prepare_inner_capture(guard, captured) + guard['checkpoint'] = 'LIVE_GENERATION_SOURCE_CONTEXT_VALIDATED' + guard['request'], guard['request_pin'], guard['live'], guard['root'] = request, request_pin, dict(live), dict(root_live) + ack = {'schema':'h25-family-guard-release-v2','binding':binding, + 'request_sha256':request_pin['sha256'],'process':leaf, + 'parent_generation':binding['parent_generation'], + 'root_generation':{'pid':captured['pid'],'start_ticks':captured['start_ticks']}, + 'expires_monotonic':guard['deadline']} + guard['phase'] = 'RELEASE_CONSUMED' # once before publication, even if it fails + guard['ack'], guard['ack_pin'] = ack, _guard_publish(binding['ack_path'], ack, guard) + guard['checkpoint'] = 'ACK_DURABLY_PUBLISHED' + guard['phase'] = 'WAITING_CONSUME' + if guard['phase'] == 'WAITING_CONSUME' and Path(binding['consume_path']).exists(): + consumed, consumed_pin = _guard_read(binding['consume_path']) + _guard_exact(consumed, ('schema','request_sha256','ack_sha256','process')) + need(consumed['schema'] == 'h25-family-guard-consumed-v2' and + type(consumed['request_sha256']) is str and consumed['request_sha256'] == guard['request_pin']['sha256'] and + type(consumed['ack_sha256']) is str and consumed['ack_sha256'] == guard['ack_pin']['sha256'] and + _guard_bytes(consumed['process']) == _guard_bytes(guard['request']['process']), + 'Guard release consumption differs') + guard['consume_pin'] = consumed_pin; guard['phase'] = 'CONSUMED_RELEASE' + guard['checkpoint'] = 'CHILD_CONSUMED_RELEASE' + except BaseException as error: + if guard['primary'][0] is None: + guard['primary'][0] = error + _guard_fail(guard, error) + raise + + +def child_guard_wait(binding, marker_pin, process, state): + """Fixed child wait; no target callback until matching one-shot ACK consumed.""" + need(type(state) is dict and state['phase'] == 'PRETARGET' and state['primary'][0] is None, + 'Before-target child guard already consumed/stopped') + state['phase'] = 'WAITING_RELEASE' # burn before any acquisition + try: + _guard_binding(binding) + leaf = {k:process[k] for k in ('pid','ppid','pgid','sid','start_ticks')}; _guard_leaf(leaf) + need(leaf['pid'] == os.getpid(), 'Guard child process identity differs') + request = {'schema':'h25-family-guard-request-v2','binding':binding,'process':leaf, + 'marker':{k:marker_pin[k] for k in ('path','sha256','bytes')}} + request_pin = _guard_publish(binding['request_path'], request, state) + state['request'],state['request_pin'] = request,request_pin + deadline = time.monotonic() + binding['timeout_milliseconds'] / 1000 + while not Path(binding['ack_path']).exists(): + need(time.monotonic() < deadline, 'Before-target child ACK wait expired') + owner = proc(binding['parent_generation']['pid']) + need(owner is not None and owner['state'] != 'Z' and + generation(owner) == (binding['parent_generation']['pid'],binding['parent_generation']['start_ticks']), + 'Before-target owning parent is no longer live') + time.sleep(min(0.01,max(0.0,deadline-time.monotonic()))) + ack, ack_pin = _guard_read(binding['ack_path']) + _guard_exact(ack, ('schema','binding','request_sha256','process','parent_generation','root_generation','expires_monotonic')) + need(type(ack['schema']) is str and ack['schema'] == 'h25-family-guard-release-v2' and + _guard_bytes(ack['binding']) == _guard_bytes(binding) and + type(ack['request_sha256']) is str and ack['request_sha256'] == request_pin['sha256'] and + _guard_bytes(ack['process']) == _guard_bytes(leaf) and + _guard_bytes(ack['parent_generation']) == _guard_bytes(binding['parent_generation']) and + type(ack['expires_monotonic']) is float and + time.monotonic() <= min(deadline,ack['expires_monotonic']), 'Missing/wrong/stale/timedout parent ACK') + _guard_generation(ack['root_generation']) + owner = proc(binding['parent_generation']['pid']); own = proc(os.getpid()) + need(owner is not None and owner['state'] != 'Z' and own is not None and own['state'] != 'Z' and + generation(owner) == (binding['parent_generation']['pid'],binding['parent_generation']['start_ticks']) and + all(type(own[k]) is int and own[k] == leaf[k] for k in leaf), 'ACK owner/child generation no longer live') + need(_guard_read(binding['request_path'])[1] == request_pin, 'Own request changed before ACK consumption') + state['ack'],state['ack_pin'] = ack,ack_pin + state['phase'] = 'RELEASE_CONSUMED' # never retry even if publication fails + consumed = {'schema':'h25-family-guard-consumed-v2','request_sha256':request_pin['sha256'], + 'ack_sha256':ack_pin['sha256'],'process':leaf} + state['consume_pin'] = _guard_publish(binding['consume_path'],consumed,state) + need(time.monotonic() <= min(deadline,ack['expires_monotonic']), 'ACK expired during complete consume publication') + state['phase'] = 'TARGET_RELEASED' + return None + except BaseException as error: + _guard_fail(state,error) + raise + + +def guard_evidence(guard): + return {'schema':'h25-family-live-parent-guard-v2','phase':guard['phase'], + 'request':guard['request_pin'],'ack':guard['ack_pin'],'consume':guard['consume_pin'], + 'live_generation_before_release':guard['live'],'captured_root_before_release':guard['root'], + 'parent_generation':None if guard['binding'] is None else guard['binding']['parent_generation'], + 'actual_error_retained':guard['primary'][0] is not None, + 'no_post_exit_substitute':True,'no_retry':True} + +def _guard_reserve(deadline): + need(len(_GUARD_ATTEMPTS) < 1024, 'Two-mode finite guard attempt registry exhausted') + guard = {'phase': 'CONSUMED', 'primary': [None], 'secondary': [], 'binding': None, + 'request': None, 'request_pin': None, 'ack': None, 'ack_pin': None, + 'consume_pin': None, 'live': None, 'root': None, 'deadline': deadline, + 'checkpoint': 'BEFORE_SOURCE_BINDING', 'supervision_result': None} + _GUARD_ATTEMPTS.append(guard) + return guard + + +def run_root(root, case, evidence, seconds, shared_deadline, as_bytes=201326592, + rss_bytes=201326592): + """Actual original caller with surviving domain and preowned capture custody.""" + need(_SUPERVISION_CURRENT[0] is None, 'prior original root must be completely retired') + began = time.monotonic() + need(type(seconds) in (int, float) and 0 < seconds <= 190, 'Unadmitted root deadline') + need(type(as_bytes) is int and 0 < as_bytes <= 1024 ** 3, 'Unadmitted root address-space bound') + need(type(rss_bytes) is int and 0 < rss_bytes <= 1024 ** 3, 'Unadmitted aggregate RSS bound') + deadline = min(began + seconds, shared_deadline - CLEANUP_SECONDS) + guard = _guard_reserve(deadline) + domain = OwnedDomain(guard) + root_errors = [None] * 16 + guard['root_errors'] = root_errors + guard['actual_process'] = None + guard['terminal_custody_version'] = 'actual-surviving-family-owner-v1' + _SUPERVISION_HISTORY.append(domain) + _SUPERVISION_CURRENT[0] = domain + process, captured, cleanup = None, None, None + peak, spawn_entered = 0, False + alarm_handler_entered = alarm_arm_entered = False + old_handler = None + timer_retired = False + failure, reconciled = None, None + result = None + try: + domain.install_stop_handlers() + launch_contract() + _guard_begin(case, deadline, guard) + need(stable_file(root / 'run_guarded_v3.py', META_CAP)['sha256'] == RUNNER_SHA, + 'Actual root runner changed') + need(time.monotonic() + CLEANUP_SECONDS < shared_deadline, 'No reserved cleanup tail remains') + command = ['/usr/bin/python3.12', *FLAGS, str(root / 'run_guarded_v3.py'), + case['stage'], case['job'], case['label']] + for value in (case['stage'], case['job'], case['label']): + need(type(value) is str and value and + all(c in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_' for c in value), + 'Unsafe case identity') + evidence.mkdir() + domain.round_root, domain.label = root, case['label'] + for item in domain.inner_capture: + item['path'] = root / 'runtime/runs' / case['label'] / item['name'] + domain.install(root) + domain.prepare_capture(evidence) + setter, limit_kind, limits = resource.setrlimit, resource.RLIMIT_AS, (as_bytes, as_bytes) + def child_limit(): + setter(limit_kind, limits) + old_handler = signal.getsignal(signal.SIGALRM) + need(signal.getitimer(signal.ITIMER_REAL) == (0.0, 0.0), 'Parent already has an execution alarm') + write_new(evidence / 'LAUNCH.json', {'command': command, 'parent_pid': os.getpid(), + 'parent_pgid': os.getpgrp(), 'parent_sid': os.getsid(0), + 'root_execution_seconds': seconds, 'address_space_bytes': as_bytes, + 'rss_sum_bytes': rss_bytes, 'new_session': True, + 'cleanup_reserved_seconds': CLEANUP_SECONDS, + 'same_original_operation': True, 'preowned_capture_readers': True}) + need(time.monotonic() < deadline, 'No original root execution time remains after preparation') + alarm_handler_entered = True + signal.signal(signal.SIGALRM, deadline_handler) + alarm_arm_entered = True + signal.setitimer(signal.ITIMER_REAL, max(0.000001, deadline - time.monotonic())) + domain.birth_pending() + spawn_entered = True + try: + process = subprocess.Popen(command, cwd=root, env=dict(ENV), + stdout=domain.capture[0]['writer']['fd'], + stderr=domain.capture[1]['writer']['fd'], + start_new_session=True, preexec_fn=child_limit) + except BaseException as error: + # The exception and traceback retain the actual failed constructor. + root_errors[0] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if guard['primary'][0] is None: + guard['primary'][0] = error + domain.birth = 'POPEN_UNKNOWN' + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if domain.guard['primary'][0] is None: + domain.guard['primary'][0] = error + if domain.error_count < 1024: + domain.error_events[domain.error_count][0] = 'Popen-return' + domain.error_events[domain.error_count][1] = error + domain.error_count = domain.error_next[domain.error_count] + else: + domain.unknown = True + raise + # Store actual returned object before the first fallible observation. + domain.process = process + guard['actual_process'] = process + domain.birth = 'POPEN_RETURNED' + captured = domain.retain_process(process) + write_new(evidence / 'ROOT-PROCESS.json', captured) + while True: + need(domain.stop_signal is None, 'Original parent received termination request') + all_rows, current = domain.observe() + _guard_step(guard, domain, all_rows, current, captured) + peak = max(peak, sum(row['rss_bytes'] for row in current)) + need(peak <= rss_bytes, 'Owned process RSS sum exceeded') + need(max(os.fstat(item['reader']['fd']).st_size for item in domain.capture) <= LOG_CAP, + 'Outer raw log cap exceeded') + if domain.root_exit_observed(): + need(guard['phase'] == 'CONSUMED_RELEASE', + 'Root exited without actual before-target release consumption') + break + time.sleep(0.01) + except BaseException as error: + root_errors[1] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if guard['primary'][0] is None: + guard['primary'][0] = error + if guard['phase'] != 'CONSUMED_RELEASE': + guard['phase'] = 'STOP' + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if domain.guard['primary'][0] is None: + domain.guard['primary'][0] = error + if domain.error_count < 1024: + domain.error_events[domain.error_count][0] = 'root-working' + domain.error_events[domain.error_count][1] = error + domain.error_count = domain.error_next[domain.error_count] + else: + domain.unknown = True + finally: + # Cancellation is entered once and cannot bypass actual domain cleanup. + if alarm_arm_entered or alarm_handler_entered: + try: + signal.setitimer(signal.ITIMER_REAL, 0) + timer_retired = True + except BaseException as error: + root_errors[2] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if guard['primary'][0] is None: + guard['primary'][0] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if domain.guard['primary'][0] is None: + domain.guard['primary'][0] = error + if domain.error_count < 1024: + domain.error_events[domain.error_count][0] = 'timer-cancel' + domain.error_events[domain.error_count][1] = error + domain.error_count = domain.error_next[domain.error_count] + else: + domain.unknown = True + else: + timer_retired = True + # A potentially still-active timer keeps its known Python handler. + # Domain cleanup remains reachable independently of cancellation failure. + try: + domain.close_capture_writers() + except BaseException as error: + root_errors[3] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if guard['primary'][0] is None: + guard['primary'][0] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if domain.guard['primary'][0] is None: + domain.guard['primary'][0] = error + if domain.error_count < 1024: + domain.error_events[domain.error_count][0] = 'capture-writer-cleanup-entry' + domain.error_events[domain.error_count][1] = error + domain.error_count = domain.error_next[domain.error_count] + else: + domain.unknown = True + if process is not None and domain.process is None: + domain.process = process + guard['actual_process'] = process + domain.birth = 'POPEN_RETURNED' + # Publication's own real close/pending tokens join this same owner. They + # are never converted into a successful physical-retirement observation. + for token in guard.get('io', ()): + if (token.get('entered') and token.get('fd') is None) or not token.get('closed') or token['primary'][0] is not None: + domain.unknown = True + try: + if domain.birth == 'UNENTERED': + # The reached caller has not entered Popen. No controlled child + # or native child holder was created by this operation. + domain.empty_observed = True + domain.retired = not domain.unknown + domain.phase = 'RETIRED' if domain.retired else 'CUSTODY_PENDING' + cleanup = domain.observation(time.monotonic()) + else: + cleanup = domain.cleanup(process, shared_deadline) + except BaseException as error: + root_errors[4] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if guard['primary'][0] is None: + guard['primary'][0] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if domain.guard['primary'][0] is None: + domain.guard['primary'][0] = error + if domain.error_count < 1024: + domain.error_events[domain.error_count][0] = 'domain-cleanup-entry' + domain.error_events[domain.error_count][1] = error + domain.error_count = domain.error_next[domain.error_count] + else: + domain.unknown = True + domain.phase = 'CUSTODY_PENDING' + # Full known-reader attempts precede error formatting and receipt/report + # acquisition, including when a working or writer-close error exists. + try: + domain.capture_after_retirement() + except BaseException as error: + root_errors[5] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if guard['primary'][0] is None: + guard['primary'][0] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if domain.guard['primary'][0] is None: + domain.guard['primary'][0] = error + if domain.error_count < 1024: + domain.error_events[domain.error_count][0] = 'capture-readback-entry' + domain.error_events[domain.error_count][1] = error + domain.error_count = domain.error_next[domain.error_count] + else: + domain.unknown = True + if not timer_retired: + domain.unknown = True + if not domain.retired or domain.unknown or any(slot['phase'] not in ('FREE', 'CLOSED') for slot in domain.io): + domain.hold_pending() + if alarm_handler_entered and old_handler is not None: + try: + signal.signal(signal.SIGALRM, old_handler) + except BaseException as error: + root_errors[6] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if guard['primary'][0] is None: + guard['primary'][0] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if domain.guard['primary'][0] is None: + domain.guard['primary'][0] = error + if domain.error_count < 1024: + domain.error_events[domain.error_count][0] = 'alarm-handler-restore' + domain.error_events[domain.error_count][1] = error + domain.error_count = domain.error_next[domain.error_count] + else: + domain.unknown = True + # All children and known holders are retired before any formatting, new + # canonical receipt, or normal return/raise can escape this actual owner. + try: + if guard['primary'][0] is not None: + primary = guard['primary'][0] + failure = {'type': type(primary).__name__, 'message': str(primary)[:2048]} + if time.monotonic() > shared_deadline: + failure = failure or {'type': 'SharedDeadline', 'message': 'Shared cap crossed; all actual custody cost remains charged'} + reconciled = reconcile_missing_receipt(root, case['label'], began, + failure or {'type': 'MissingRootReceipt', 'message': 'Root exited without receipt'}, cleanup) + if reconciled is not None: + failure = failure or {'type': 'MissingRootReceipt', 'message': 'New reconciled STOP receipt; no retry'} + logs, inner_logs = {}, {} + for item in domain.all_capture: + destination = logs if item['kind'] == 'outer' else inner_logs + destination[item['name']] = item['observation'] or { + 'path': str(item.get('path')), 'sha256': None, 'bytes': None, + 'stable': False, 'full_read': False, 'eof': False, + 'raw_error_retained': item['read_error'] is not None or item.get('acquire_error') is not None, + 'read_entered': item['read_entered'], 'actually_read_bytes': item['read_bytes'], + 'available_fd_eof_observed': item['raw_eof'], + 'available_fd_full_read_observed': item['raw_complete'], + 'absence_observed': item.get('absence_observed', False), + 'reader_acquisition_boundary': item.get('acquisition_boundary')} + if item['observation'] is None: + failure = failure or {'type': 'CaptureUnavailable', 'message': 'Actual complete raw capture was not obtained'} + result = {'schema': 'h25-parent-root-supervision-v1', 'label': case['label'], + 'status': 'STOP' if failure else 'ROOT_COMPLETED_AND_OWNED_DOMAIN_EMPTY', + 'failure': failure, 'spawn_entered': spawn_entered, + 'spawn_returned': process is not None, 'captured_root': captured, + 'returncode': None if process is None else process.returncode, + 'cleanup': cleanup, 'outer_logs': logs, 'inner_target_logs': inner_logs, + 'sampled_owned_rss_bytes': peak, + 'execution_and_cleanup_seconds': time.monotonic() - began, + 'root_receipt_reconciled': reconciled is not None, + 'no_hostile_fork_or_concurrent_children_claim': True, + 'before_target_guard': guard_evidence(guard)} + guard['supervision_result'] = result + write_new(evidence / 'SUPERVISION.json', result) + except BaseException as error: + root_errors[7] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if guard['primary'][0] is None: + guard['primary'][0] = error + domain.last_error = error + if domain.first_error is None: + domain.first_error = error + if domain.guard['primary'][0] is None: + domain.guard['primary'][0] = error + if domain.error_count < 1024: + domain.error_events[domain.error_count][0] = 'terminal-report' + domain.error_events[domain.error_count][1] = error + domain.error_count = domain.error_next[domain.error_count] + else: + domain.unknown = True + if domain.unknown or any(slot['phase'] not in ('FREE', 'CLOSED') for slot in domain.io): + domain.hold_pending() + try: + domain.restore_stop_handlers() + except BaseException as error: + root_errors[8] = error + if guard['primary'][0] is None: + guard['primary'][0] = error + _SUPERVISION_CURRENT[0] = None + if guard['primary'][0] is not None: + raise guard['primary'][0] + return result + + +def stop_supplement(root, label, reason): + folder = root / 'runtime/runs' / (label + '-supervision-stop') + folder.mkdir() + row = {'status': 'STOP', 'label': folder.name, 'kind': 'supervision_failure_marker', + 'failure': reason, 'wall_seconds': 0.0, 'runner_wall_seconds': 0.0, + 'cost_accounted_by_enclosing_queue_overhead': True, 'original_receipts_preserved': True} + write_new(folder / 'START.json', {'kind': row['kind']}) + write_new(folder / 'receipt.json', row) + + +def packet_unchanged(directory, manifest): + for name, expected in manifest['files'].items(): + row = stable_file(directory / name, META_CAP) + need(row['sha256'] == expected['sha256'] and row['bytes'] == expected['bytes'], + 'Parent source packet changed: ' + name) + need(not (directory / name).stat().st_mode & 0o222, 'Parent source packet became writable') + return True diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/PROFILE-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/PROFILE-opt0.json new file mode 100644 index 0000000000..5a4199c012 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/PROFILE-opt0.json @@ -0,0 +1,36 @@ +{ + "optimization": 0, + "original_executions": 0, + "results": [ + { + "data_observation_present": true, + "failure_args": null, + "first_error_retained": false, + "full_profile_unchanged": false, + "label": "partial", + "orchestration_alias_replaced": true, + "parser_call_trace": [ + "_retained_data_observation", + "validate_preflight_protocol" + ], + "proxy_next": 1, + "retained_blobs": 11, + "source_sha256": "967dbcaee92928d19e5ab1cdc403eb98b83bd568cf4d6c81dc8df8fac96b526b" + }, + { + "data_observation_present": false, + "failure_args": [ + "observation receiver changed" + ], + "first_error_retained": true, + "full_profile_unchanged": false, + "label": "complete", + "orchestration_alias_replaced": true, + "parser_call_trace": [], + "proxy_next": 0, + "retained_blobs": 11, + "source_sha256": "80b3a03c3bce5324efd272390d59d6f41210a0eade13ec8bbf9b9bad051eb197" + } + ], + "schema": "v02-terminal-independent-profile-probe-v1" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/PROFILE-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/PROFILE-opt1.json new file mode 100644 index 0000000000..dc4e233cab --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/PROFILE-opt1.json @@ -0,0 +1,36 @@ +{ + "optimization": 1, + "original_executions": 0, + "results": [ + { + "data_observation_present": true, + "failure_args": null, + "first_error_retained": false, + "full_profile_unchanged": false, + "label": "partial", + "orchestration_alias_replaced": true, + "parser_call_trace": [ + "_retained_data_observation", + "validate_preflight_protocol" + ], + "proxy_next": 1, + "retained_blobs": 11, + "source_sha256": "967dbcaee92928d19e5ab1cdc403eb98b83bd568cf4d6c81dc8df8fac96b526b" + }, + { + "data_observation_present": false, + "failure_args": [ + "observation receiver changed" + ], + "first_error_retained": true, + "full_profile_unchanged": false, + "label": "complete", + "orchestration_alias_replaced": true, + "parser_call_trace": [], + "proxy_next": 0, + "retained_blobs": 11, + "source_sha256": "80b3a03c3bce5324efd272390d59d6f41210a0eade13ec8bbf9b9bad051eb197" + } + ], + "schema": "v02-terminal-independent-profile-probe-v1" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REPLAY-opt0.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REPLAY-opt0.json new file mode 100644 index 0000000000..3f56e3ad05 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REPLAY-opt0.json @@ -0,0 +1,45 @@ +{ + "accepted_original_cases": 0, + "authentic_source_loader_joined": false, + "candidate_sha256": "80b3a03c3bce5324efd272390d59d6f41210a0eade13ec8bbf9b9bad051eb197", + "checks": [ + "actual prebirth and RootProxy call owns fourteen complete reads then both actual parser calls", + "original return code streams proxy record and full raw bytes retained", + "outer terminal cost and original activity remain open after DATA success", + "missing prebirth admission rejects before prebirth reads and retains first error on retry", + "missing observation module rejects before prebirth reads and retains first error on retry", + "missing expected context rejects before prebirth reads and retains first error on retry", + "legacy eight-module profile rejects before prebirth reads and retains first error on retry", + "independently snapshotted crossed parser binding rejects before reads", + "parser drift during inert Root stops before first post-Root read", + "earlier orchestration receiver replacement during final read retains raw and rejects before parsers", + "receipt read/close/open failure preserves primary and uncertainty through no-read finalization", + "stdout read/close/open failure preserves primary and uncertainty through no-read finalization", + "stdout read/close/open failure preserves primary and uncertainty through no-read finalization", + "stdout read/close/open failure preserves primary and uncertainty through no-read finalization", + "false held pre-ACK EOF rejects retained observation before either parser", + "original cumulative 128-ticket cap rejects observation without widening", + "prior foreign prebirth profile row regression rejects before callbacks", + "prior foreign exact-state key regression rejects before callbacks", + "existing enclosing main and no-read failure finalizer remain byte exact" + ], + "complete_cost_accounted": false, + "complete_outer_terminal_joined": false, + "declared_observation_reads": 11, + "fixture_sha256": "48b8c4d77cab2003b2cd58dbe5a709c65be673f348108e3076cdcbcdb4cc391b", + "optimize": 0, + "original_executions": 0, + "passed": 19, + "positive_call_trace": [ + { + "caller": "_retained_data_observation", + "same_module_globals": true + }, + { + "caller": "validate_preflight_protocol", + "same_module_globals": true + } + ], + "positive_held_read_tickets": 14, + "schema": "v02-parent-terminal-join-inert-replay-v1" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REPLAY-opt1.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REPLAY-opt1.json new file mode 100644 index 0000000000..e1ecfb494f --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REPLAY-opt1.json @@ -0,0 +1,45 @@ +{ + "accepted_original_cases": 0, + "authentic_source_loader_joined": false, + "candidate_sha256": "80b3a03c3bce5324efd272390d59d6f41210a0eade13ec8bbf9b9bad051eb197", + "checks": [ + "actual prebirth and RootProxy call owns fourteen complete reads then both actual parser calls", + "original return code streams proxy record and full raw bytes retained", + "outer terminal cost and original activity remain open after DATA success", + "missing prebirth admission rejects before prebirth reads and retains first error on retry", + "missing observation module rejects before prebirth reads and retains first error on retry", + "missing expected context rejects before prebirth reads and retains first error on retry", + "legacy eight-module profile rejects before prebirth reads and retains first error on retry", + "independently snapshotted crossed parser binding rejects before reads", + "parser drift during inert Root stops before first post-Root read", + "earlier orchestration receiver replacement during final read retains raw and rejects before parsers", + "receipt read/close/open failure preserves primary and uncertainty through no-read finalization", + "stdout read/close/open failure preserves primary and uncertainty through no-read finalization", + "stdout read/close/open failure preserves primary and uncertainty through no-read finalization", + "stdout read/close/open failure preserves primary and uncertainty through no-read finalization", + "false held pre-ACK EOF rejects retained observation before either parser", + "original cumulative 128-ticket cap rejects observation without widening", + "prior foreign prebirth profile row regression rejects before callbacks", + "prior foreign exact-state key regression rejects before callbacks", + "existing enclosing main and no-read failure finalizer remain byte exact" + ], + "complete_cost_accounted": false, + "complete_outer_terminal_joined": false, + "declared_observation_reads": 11, + "fixture_sha256": "48b8c4d77cab2003b2cd58dbe5a709c65be673f348108e3076cdcbcdb4cc391b", + "optimize": 1, + "original_executions": 0, + "passed": 19, + "positive_call_trace": [ + { + "caller": "_retained_data_observation", + "same_module_globals": true + }, + { + "caller": "validate_preflight_protocol", + "same_module_globals": true + } + ], + "positive_held_read_tickets": 14, + "schema": "v02-parent-terminal-join-inert-replay-v1" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REVIEW.md b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REVIEW.md new file mode 100644 index 0000000000..a32c961cb6 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/REVIEW.md @@ -0,0 +1,13 @@ +Accepted the corrected scoped parent-to-observer composition at SHA-256 `80b3a03c3bce5324efd272390d59d6f41210a0eade13ec8bbf9b9bad051eb197`. The source uses the reviewed persistent supervisor `a9b39d9b670f860934a0ff4c42427ac580020759036e50a46af66a88c3f8201a`, observer `efcf36288c6c9e43b8b02c559e6c4085c577730597db768e584042170f506f81`, repaired wire `aaaeecf56b37fdd3d58f7e5d6ddee8daefc883c48358cb3de6ef7b9ac3163ba0` and original family validator `703cbdf7cbc6f7e2203d411f8f77b19f9006021e1f6a91feecf646fddb89c659`. + +Independent replay passed all 19 completed author controls in both isolated Python modes. The positive fixture enters the actual selected prebirth and `RootProxy._run` declarations, with explicitly inert Root and native file seams. Three original post-Root reads and eleven observation reads finish with fourteen closed persistent-owner tickets. The trace reaches the same wire parser code and module globals first from `_retained_data_observation`, then from the unchanged family validator. The original proxy return code, streams and record remain intact. [Normal replay](REPLAY-opt0.json) · [Optimized replay](REPLAY-opt1.json) + +The first draft `967dbcaee92928d19e5ab1cdc403eb98b83bd568cf4d6c81dc8df8fac96b526b` retained only the three observation module rows for post-Root freshness. An independent countercontrol replaces `orchestration.CONFIGURATION` with an equal new dictionary during the last retained consume read. That draft reaches both parsers and advances `proxy.next` while the complete prebirth profile has changed. The corrected source retains all eleven receiver rows. It keeps all eleven raw blobs, refuses with `observation receiver changed` before either parser, preserves that first error on retry and permits no further packet-finalization reads. Both interpreter modes reproduce this comparison. [Normal profile comparison](PROFILE-opt0.json) · [Optimized profile comparison](PROFILE-opt1.json) + +The retained controls cover missing and crossed bindings, change during Root, foreign profile rows and state keys, the 128-ticket limit, original primary errors with uncertain close, open failure, false held EOF and rejection of further reads after failure. The new composition checks the complete receiver profile before and after each added read and around the observer call. The observer converts each native identity vector only after retaining its complete raw bytes and original pin. + +The builder was replayed with its three writes intercepted. All generated bytes matched the reviewed source, delta and reuse record exactly, including the builder's inverse check. Independent AST/source comparison found only `_prebirth_scope`, `_prebirth_v02` and `RootProxy` changed among existing declarations, with `_observation_bindings` and `_observe_v02` added. `main` and `_finish_packet` remain byte-exact to the prebirth predecessor. [Independent source check](SOURCE-CHECK.json) + +The accepted scope relies on independently authenticated modules, the supplied prebirth admission and protected exact private state. Its receiver snapshots are shallow and require protection of nested mutable configuration and owner data. Authentic source loading and issuance still need their actual owner. The enclosing `main` continues through the original reviewed queue, whose validator requires `science/receipt.json`; that entry does not yet implement a complete V02 terminal path. Failure finalization here retains uncertainty and blocks further packet reads. Complete termination, settlement and measured cost remain open. + +The replay performed zero original Root, producer, supervisor or guest executions. It accepted zero original V02 omission cases. The current result qualifies the exact source composition and inert caller controls only. diff --git a/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/SOURCE-CHECK.json b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/SOURCE-CHECK.json new file mode 100644 index 0000000000..a594ef0102 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/parent-terminal-join/independent-review/SOURCE-CHECK.json @@ -0,0 +1,24 @@ +{ + "schema": "v02-parent-terminal-independent-source-review-v1", + "candidate_sha256": "80b3a03c3bce5324efd272390d59d6f41210a0eade13ec8bbf9b9bad051eb197", + "builder_outputs_exact": [ + "SOURCE-REUSE.json", + "run_queue_terminal_join_v1.py.txt", + "wrapper.diff" + ], + "changed_existing_declarations": [ + "_prebirth_scope", + "_prebirth_v02", + "RootProxy" + ], + "new_declarations": [ + "_observation_bindings", + "_observe_v02" + ], + "main_and_finish_packet_byte_exact": true, + "author_replay_passed": [ + 19, + 19 + ], + "source_replay_only": true +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/frame_encoder_v1.py.txt b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/frame_encoder_v1.py.txt new file mode 100644 index 0000000000..18348a566d --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/frame_encoder_v1.py.txt @@ -0,0 +1,168 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Pure prospective V02 frame encoder; representation checks confer no authority. + +The owning original parent independently approves decisions and validates its +actual prebirth result before using this encoder. No Tool call or source launch. +Exact primitive validators are copied from the reviewed child candidate. +""" +import json +import hashlib +import stat +_TYPE, _LEN = type, len +BindingStop = ValueError +def _need(value, message): + if not value: + raise BindingStop(message) + +def _exact(value, keys): + _need(_TYPE(value) is dict and all(_TYPE(k) is str for k in value) and set(value) == set(keys), 'binding exact keys differ') + +def _pairs(items): + _need(len(items) <= 8192, 'binding mapping bound') + result = {} + for key, value in items: + _need(_TYPE(key) is str and len(key) <= 1048576 and key not in result, 'binding duplicate/foreign key') + result[key] = value + return result + +def _reject(value): + raise BindingStop('binding noninteger/nonfinite literal rejected') + +def _document(raw): + value = json.loads(raw.decode('ascii'), object_pairs_hook=_pairs, parse_float=_reject, parse_constant=_reject) + _literal(value, [0]) + _need(_TYPE(value) is dict, 'binding top-level document differs') + return value + +def _digest(value): + _need(type(value) is str and len(value) == 64 and all(x in '0123456789abcdef' for x in value), + 'exact configuration digest required') + +def _literal(value, budget, depth=0): + budget[0] += 1 + _need(budget[0] <= 200000 and depth <= 32, 'finite configured literal tree bound') + kind = type(value) + if value is None or kind is bool: + return + if kind is int: + _need(value.bit_length() <= 127, 'configuration integer bound') + return + if kind is str or kind is bytes: + _need(len(value) <= 1048576, 'configuration atom bound') + return + _need((kind is tuple or kind is list or kind is dict) and len(value) <= 8192, 'configuration exact literal type') + if kind is dict: + for key in value: + _need(type(key) is str, 'configuration dictionary key type') + for item in (value.values() if kind is dict else value): + _literal(item, budget, depth + 1) + +def _v02_plain(value): + budget = [0, 0] + + def walk(item, depth): + budget[0] += 1 + if depth > 24 or budget[0] > 65536: + raise ValueError('gate tree bound') + kind = type(item) + if item is None or kind is bool: + return + if kind is int: + if not -(1 << 64) <= item < (1 << 64): + raise ValueError('gate integer bound') + return + if kind is str: + budget[1] += len(item) + if len(item) > 8192 or budget[1] > 524288: + raise ValueError('gate text bound') + return + if (kind is not list and kind is not dict) or len(item) > 1024: + raise ValueError('gate exact JSON domain') + if kind is dict: + for key in item: + if type(key) is not str: + raise ValueError('gate exact string key required') + for key in item: + walk(key, depth + 1) + walk(item[key], depth + 1) + else: + for child in item: + walk(child, depth + 1) + + walk(value, 0) + +def _v02_same(left, right): + if type(left) is not type(right): + return False + if type(left) is dict: + return (set(left) == set(right) and + all(_v02_same(left[k], right[k]) for k in left)) + if type(left) is list: + return (len(left) == len(right) and + all(_v02_same(a, b) for a, b in zip(left, right))) + return left == right + +def _v02_pin_shape(pin, limit): + # Same complete immutable regular-file pin contract as the owning reader. + _exact(pin, ('path', 'sha256', 'bytes', 'identity')) + _need(_TYPE(pin['path']) is str and pin['path'].startswith('/') and + _LEN(pin['path']) <= 4096 and + all(c not in ('', '.', '..') for c in pin['path'].split('/')[1:]), + 'V02 complete source path differs') + _digest(pin['sha256']) + _need(_TYPE(pin['bytes']) is int and 0 < pin['bytes'] <= limit, + 'V02 complete source byte bound') + _exact(pin['identity'], ('device', 'inode', 'mode', 'links', 'uid', 'gid', 'size', 'mtime_ns', 'ctime_ns')) + _need(all(_TYPE(x) is int and x >= 0 for x in pin['identity'].values()) and + pin['identity']['links'] == 1 and pin['identity']['size'] == pin['bytes'] and + stat.S_ISREG(pin['identity']['mode']) and not pin['identity']['mode'] & 0o222, + 'V02 immutable source identity differs') + +def encode_frame(binding, preparation_raw, endorsement_raw): + """Return one <=32768-byte canonical ASCII+LF frame from verified subjects. + + Output is DATA. Arbitrary callers can encode DATA; only the authenticated + original writer/session and inherited sole-reader pipe premise authorize + its interpretation at the child. This function cannot establish those facts. + """ + _v02_plain(binding) + _exact(binding, ('schema','preparation','preflight_package','case_id','context_id','generation', + 'unit_id','mode','stage_sha256','command_sha256','endorsement')) + _need(binding['schema']=='h25-v02-preseal-parent-frame-v1' and + binding['unit_id']=='variant/V02/python-preflight-v1' and binding['mode']=='normal', + 'V02 host frame fixed subject differs') + for key in ('case_id','context_id','generation'): + _need(type(binding[key]) is str and 0 ({ + phase: "FREE", tool: null, request: null, result: null, error: null + })); + const custody = { + phase: "PRE_DISPATCH", ordinal: 0, session: null, terminal: null, + firstError: null, cleanupErrors: Array(64).fill(null), errorCount: 0, + sendEntered: false, sendReturned: false, unknown: false, + requestAndResultOwners: records, inputOwner: GAMMA, + nativeCaptureFullReadbackEstablished: false, + financialCloseIssued: false, executionPermissionIssued: false + }; + function remember(error) { + if (custody.firstError === null) custody.firstError = error; + else if (error !== custody.firstError && custody.errorCount < 64) + custody.cleanupErrors[custody.errorCount++] = error; + else custody.unknown = true; + } + function requireValue(value, message) { + if (value !== true) throw new Error(message); + } + function sourceGuard() { + requireValue(tools.exec_command === execOriginal && + tools.write_stdin === stdinOriginal && text === emitOriginal, + "original native provider/function identities changed"); + } + function observe(result) { + requireValue(result !== null && typeof result === "object" && + !Array.isArray(result), "actual native result object required"); + const keys = Object.keys(result); + requireValue(keys.every(key => ["output", "wall_time_seconds", "session_id", + "exit_code", "chunk_id", "original_token_count"].includes(key)) && + typeof result.output === "string" && + Object.prototype.hasOwnProperty.call(result, "wall_time_seconds"), + "original native result contract"); + const hasExit = Number.isSafeInteger(result.exit_code); + if (!hasExit) { + requireValue(Number.isSafeInteger(result.session_id) && result.session_id >= 0, + "actual live provider session required"); + requireValue(custody.session === null || custody.session === result.session_id, + "native provider changed original session"); + custody.session = result.session_id; + } else { + requireValue(result.session_id === undefined || result.session_id === custody.session, + "terminal belongs to retained original session"); + custody.terminal = result; + } + } + async function callOriginal(name, request) { + sourceGuard(); + requireValue(custody.ordinal < records.length, "bounded original request chain exhausted"); + const slot = records[custody.ordinal++]; + slot.tool = name; + slot.request = request; + slot.phase = "CALL_PENDING"; // Before the fallible native acquisition/call. + try { + const result = name === "exec_command" + ? await tools.exec_command(request) : await tools.write_stdin(request); + slot.result = result; // Actual object retained before validation. + slot.phase = "RETURNED"; + observe(result); + slot.phase = "OBSERVED"; + return result; + } catch (error) { + slot.error = error; + slot.phase = "CALL_UNKNOWN"; + custody.unknown = true; + remember(error); + throw error; + } + } + try { + sourceGuard(); + requireValue(GAMMA.exact_candidate_document.exact_shell_command === + INSTALLATION.exact_shell_command, "original candidate/exact shell identity"); + requireValue(GAMMA.frame_subject.command_sha256 === INSTALLATION.runner_command_sha256 && + GAMMA.frame_subject.schema === "h25-v02-preseal-parent-frame-v1", + "same original exact shell and operation"); + const frame = GAMMA.encoded_frame; + requireValue(typeof frame === "string" && frame.length <= 32768 && /^[\x00-\x7f]*$/.test(frame), + "bounded ASCII original-parent transport"); + requireValue(frame.endsWith("\n") && + frame.split("\n").length === 2, "exact original V02 encoder frame required"); + // Only string metadata is read through JavaScript JSON. All complete pins, + // including 64-bit timestamps, remain opaque exact Python-encoded ASCII. + const frameMetadata = JSON.parse(frame); + requireValue(frameMetadata.schema === GAMMA.frame_subject.schema && + frameMetadata.command_sha256 === GAMMA.frame_subject.command_sha256, + "V02 encoded frame string subject differs"); + custody.phase = "BIRTH_PENDING"; + await callOriginal("exec_command", { + cmd: INSTALLATION.exact_shell_command, + workdir: INSTALLATION.workdir, + shell: "/bin/bash", login: false, tty: false, + yield_time_ms: 1000, max_output_tokens: 16384 + }); + requireValue(custody.terminal === null && custody.session !== null, + "entry did not retain the original input session"); + custody.phase = "INPUT_PENDING"; + custody.sendEntered = true; // Delivery may have occurred if the call fails. + await callOriginal("write_stdin", { + session_id: custody.session, chars: frame, + yield_time_ms: 1000, max_output_tokens: 16384 + }); + custody.sendReturned = true; + custody.phase = "NATIVE_RUNNING"; + while (custody.terminal === null) { + await callOriginal("write_stdin", { + session_id: custody.session, chars: "", + yield_time_ms: 5000, max_output_tokens: 16384 + }); + } + custody.phase = "NATIVE_TERMINAL_OBSERVED"; + } catch (error) { + remember(error); + custody.unknown = true; + custody.phase = "OPEN_UNCERTAIN"; + // Never launch a second attempt or resend a possibly delivered frame. + // This code cannot infer terminal retirement from an uncertain Tool call. + // A known provider session and every actual returned object remain in this + // original-parent record. The same target process remains the designated + // native owner; this host catch does not kill it, replace it, retry the + // operation, transfer authority, or establish that it actually survived. + } + const errorView = error => { + if (error === null) return null; + try { return {name: String(error.name), message: String(error.message)}; } + catch (_) { return {name: "unrendered-original-error", message: "retained"}; } + }; + // Actual request/result objects remain strongly retained until publication. + // The original authenticated parent captures this actual Tool chain. A pending + // record is not durable process custody, a retirement receipt, or new funding. + // The 64 slots bound retained call records, not authorised elapsed body time. + // Returned DATA is a native custody record, never formal CLOSE or acceptance. + const report = { + schema: "h25-v02-prospective-parent-native-custody-v1", + operation_id: "V02NormalOmissionPreseal", + phase: custody.phase, session_id: custody.session, + send_entered: custody.sendEntered, send_returned: custody.sendReturned, + terminal_observed: custody.terminal !== null, + pending_original_session: custody.session !== null && custody.terminal === null, + designated_native_owner_source: INSTALLATION.entry_pin, + pending_call_records: records.slice(0, custody.ordinal) + .filter(slot => slot.phase === "CALL_PENDING" || slot.phase === "CALL_UNKNOWN") + .map(slot => ({tool: slot.tool, request: slot.request, result: slot.result})), + actual_terminal_result: custody.terminal, + uncertainty: custody.unknown, + first_error: errorView(custody.firstError), + cleanup_errors: custody.cleanupErrors.slice(0, custody.errorCount).map(errorView), + calls: records.slice(0, custody.ordinal).map(slot => ({ + phase: slot.phase, tool: slot.tool, request: slot.request, + result: slot.result, error: errorView(slot.error) + })), + native_capture_full_readback_established: false, + complete_holder_retirement_established: false, + financial_close_issued: false, execution_permission_issued: false, + new_attempt_or_frame_retry_authorised: false, + policy_time_charge_asserted: false, complete_physical_cost: null + }; + try { emitOriginal(report); } + catch (error) { remember(error); throw custody.firstError; } + if (custody.firstError !== null) throw custody.firstError; +})(); diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/ENCODER-INDEPENDENT.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/ENCODER-INDEPENDENT.json new file mode 100644 index 0000000000..9f8aeece6d --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/ENCODER-INDEPENDENT.json @@ -0,0 +1,52 @@ +{ + "encoder_sha256": "7fe7abcee99f3629bbc6bb73b86c76c5580607806432cf10c622018c18299700", + "passed": 9, + "tests": [ + { + "case": "corrupt_preparation_raw", + "message": "V02 host subject raw custody differs", + "result": "PASS_PURE_DATA_ONLY" + }, + { + "case": "corrupt_endorsement_raw", + "message": "V02 host subject raw custody differs", + "result": "PASS_PURE_DATA_ONLY" + }, + { + "case": "wrong_command_vs_endorsement", + "message": "V02 host detached endorsement association differs", + "result": "PASS_PURE_DATA_ONLY" + }, + { + "case": "wrong_stage_vs_endorsement", + "message": "V02 host detached endorsement association differs", + "result": "PASS_PURE_DATA_ONLY" + }, + { + "case": "wrong_generation_vs_endorsement", + "message": "V02 host detached endorsement association differs", + "result": "PASS_PURE_DATA_ONLY" + }, + { + "case": "wrong_context_vs_preparation", + "message": "V02 host case/context differs", + "result": "PASS_PURE_DATA_ONLY" + }, + { + "case": "mode_drift", + "message": "V02 host frame fixed subject differs", + "result": "PASS_PURE_DATA_ONLY" + }, + { + "case": "unapproved_extra_field", + "message": "binding exact keys differ", + "result": "PASS_PURE_DATA_ONLY" + }, + { + "case": "lossless_large_identity_and_unicode", + "result": "PASS_PURE_DATA_ONLY" + } + ], + "actual_tool_calls": 0, + "original_executions": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/FINAL-DELTA.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/FINAL-DELTA.json new file mode 100644 index 0000000000..26742fa49f --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/FINAL-DELTA.json @@ -0,0 +1,19 @@ +{ + "source_pins": { + "selected_child_preseal_v1.py.txt": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048", + "frame_encoder_v1.py": "7fe7abcee99f3629bbc6bb73b86c76c5580607806432cf10c622018c18299700", + "host_preseal_writer.js.txt": "b5f7af26ea0cb3702cddd792061f434c055a7146ed726a6317395559a44c2bb9" + }, + "changed_existing_functions": [ + "prepare_binding_context", + "install_before_capture", + "prepare_selected_child" + ], + "added_functions": [ + "_v02_preseal_native_guard", + "_v02_preseal_binding_check", + "_receive_v02_preseal" + ], + "unchanged_existing_functions": 57, + "typed_constructor_and_original_registrar_live_profile_unchanged": true +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/HOST-INDEPENDENT.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/HOST-INDEPENDENT.json new file mode 100644 index 0000000000..a93e2c23ce --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/HOST-INDEPENDENT.json @@ -0,0 +1,57 @@ +{ + "host_sha256": "b5f7af26ea0cb3702cddd792061f434c055a7146ed726a6317395559a44c2bb9", + "passed": 6, + "tests": [ + { + "case": "lossless_full_encoder_frame", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 2, + "json_parse_calls": 1, + "actual_tool_calls": 0, + "failure": null + }, + { + "case": "ordinary_host_scope_absent", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "json_parse_calls": 0, + "actual_tool_calls": 0, + "failure": "V02 original protected parent/session scope absent" + }, + { + "case": "frame_metadata_command_mismatch", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "json_parse_calls": 1, + "actual_tool_calls": 0, + "failure": "V02 encoded frame string subject differs" + }, + { + "case": "double_frame_rejects", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "json_parse_calls": 0, + "actual_tool_calls": 0, + "failure": "exact original V02 encoder frame required" + }, + { + "case": "oversized_frame_before_parse", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "json_parse_calls": 0, + "actual_tool_calls": 0, + "failure": "bounded ASCII original-parent transport" + }, + { + "case": "nonascii_frame_before_parse", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "json_parse_calls": 0, + "actual_tool_calls": 0, + "failure": "bounded ASCII original-parent transport" + } + ], + "actual_tool_calls": 0, + "original_executions": 0, + "actual_origin_authenticated": false +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/HOST-JSON-NUMBER-COUNTEREXAMPLE.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/HOST-JSON-NUMBER-COUNTEREXAMPLE.json new file mode 100644 index 0000000000..456385f579 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/HOST-JSON-NUMBER-COUNTEREXAMPLE.json @@ -0,0 +1,7 @@ +{ + "scope": "pure JavaScript parse/stringify only; no Tool call", + "input": "{\"mtime_ns\":1700000000000000001}", + "reencoded": "{\"mtime_ns\":1700000000000000000}", + "same": false, + "implication": "Host cannot reserialize full Python exact64bit source identity pins through JavaScript Number without changing valid input" +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/INGRESS-INDEPENDENT.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/INGRESS-INDEPENDENT.json new file mode 100644 index 0000000000..3603ea1aa8 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/INGRESS-INDEPENDENT.json @@ -0,0 +1,69 @@ +{ + "candidate_sha256": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048", + "passed": 10, + "tests": [ + { + "case": "actual_prepare_to_seal_under_inert_origin", + "result": "PASS_INERT_ONLY" + }, + { + "case": "decoder_alias_after_read", + "result": "PASS_INERT_ONLY", + "message": "V02 preseal retained helper alias changed", + "fd0_model_reads": 1 + }, + { + "case": "decoder_code_after_read", + "result": "PASS_INERT_ONLY", + "message": "V02 preseal retained helper descriptor changed", + "fd0_model_reads": 1 + }, + { + "case": "imported_decoder_alias_after_read", + "result": "PASS_INERT_ONLY", + "message": "V02 preseal retained import alias changed", + "fd0_model_reads": 1 + }, + { + "case": "imported_decoder_code_after_read", + "result": "PASS_INERT_ONLY", + "message": "V02 preseal retained helper descriptor changed", + "fd0_model_reads": 1111 + }, + { + "case": "late_origin_change", + "result": "PASS_INERT_ONLY", + "message": "V02 protected ingress changed after final native call", + "fd0_model_reads": 1111 + }, + { + "case": "late_retained_change", + "result": "PASS_INERT_ONLY", + "message": "V02 protected ingress changed after final native call", + "fd0_model_reads": 1111 + }, + { + "case": "late_expected_change", + "result": "PASS_INERT_ONLY", + "message": "V02 protected ingress changed after final native call", + "fd0_model_reads": 1111 + }, + { + "case": "ordinary_origin_absent", + "result": "PASS_INERT_ONLY", + "message": "V02 concrete authenticated issued input absent", + "fd0_model_reads": 0 + }, + { + "case": "integer_zero_is_not_false_typestate", + "result": "PASS_INERT_ONLY", + "message": "V02 preseal ingress is one-shot before typed construction", + "fd0_model_reads": 0 + } + ], + "actual_fd0_calls": 0, + "actual_original_executions": 0, + "actual_origin_authenticated": false, + "full_live_profile_tested": false, + "original_activity_credit": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/INTERMEDIATE-7001e2ba.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/INTERMEDIATE-7001e2ba.json new file mode 100644 index 0000000000..2f55eb571e --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/INTERMEDIATE-7001e2ba.json @@ -0,0 +1,15 @@ +{ + "source_sha256": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048", + "status": "REQUIRES_IMPORTED_DECODER_RECONCILIATION", + "fixed": [ + "direct helper alias replacement before decode", + "late original-origin identity recheck" + ], + "remaining_counterexample": { + "mutation": "json.loads alias replaced during first fd0 read", + "foreign_callbacks": 3, + "final_phase": "SEALED" + }, + "actual_fd0_calls": 0, + "actual_original_executions": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REJECTED-b62f61f9.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REJECTED-b62f61f9.json new file mode 100644 index 0000000000..91eaf40111 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REJECTED-b62f61f9.json @@ -0,0 +1,28 @@ +{ + "source_sha256": "b62f61f9363635a52c29889fce6d218f2b1a3f3133a196d4d32b571240270e17", + "status": "REJECTED_PENDING_RECONCILIATION", + "findings": [ + { + "id": "I1", + "case": "decoder replacement during fd0 read with original source record witness", + "foreign_callbacks": 3, + "final_phase": "STOP", + "first_refusal": "installed source binding identity changed", + "issue": "callback before original refusal" + }, + { + "id": "I2", + "case": "final native guard swaps protected origin identity", + "final_phase": "SEALED", + "issue": "missing recheck after final fallible native receiver" + }, + { + "id": "I3", + "case": "encoder canonical sorted frame with original insertion-order wire", + "host_predicate": false, + "issue": "encoder-host representation pair incompatible without explicit canonical wire construction" + } + ], + "actual_native_calls": 0, + "original_executions": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-author-host.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-author-host.json new file mode 100644 index 0000000000..f506f24807 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-author-host.json @@ -0,0 +1,79 @@ +{ + "passed": 12, + "tests": [ + { + "case": "ordinary_host_scope_absent", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "frame_send_attempts": 0 + }, + { + "case": "one_actual_session_one_frame", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 2, + "frame_send_attempts": 1 + }, + { + "case": "early_terminal", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 1, + "frame_send_attempts": 0 + }, + { + "case": "uncertain_send", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 2, + "frame_send_attempts": 1 + }, + { + "case": "wrong_session", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 2, + "frame_send_attempts": 1 + }, + { + "case": "changed_tool", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 1, + "frame_send_attempts": 0 + }, + { + "case": "different_frame", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "frame_send_attempts": 0 + }, + { + "case": "second_frame", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "frame_send_attempts": 0 + }, + { + "case": "never_terminal", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 64, + "frame_send_attempts": 1 + }, + { + "case": "oversized", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "frame_send_attempts": 0 + }, + { + "case": "nonascii", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 0, + "frame_send_attempts": 0 + }, + { + "case": "full_python_encoder_frame_preserves_large_integer_and_unicode", + "result": "PASS_INERT_ONLY", + "tool_model_calls": 2, + "frame_send_attempts": 1 + } + ], + "actual_tool_calls": 0, + "actual_origin_authenticated": false +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-author-ingress.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-author-ingress.json new file mode 100644 index 0000000000..1e51c2d07b --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-author-ingress.json @@ -0,0 +1,129 @@ +{ + "schema": "v02-protected-preseal-ingress-inert-v1", + "source_sha256": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048", + "passed": 23, + "tests": [ + { + "case": "actual_prepare_reads_retained_P_then_child_local_eight_install", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1111 + }, + { + "case": "ordinary_route_no_origin", + "result": "PASS_INERT_ONLY", + "fd0_reads": 0 + }, + { + "case": "empty_eof", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1 + }, + { + "case": "truncated_frame", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1111 + }, + { + "case": "oversize_frame", + "result": "PASS_INERT_ONLY", + "fd0_reads": 32768 + }, + { + "case": "different_frame_subject", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1111 + }, + { + "case": "noncanonical_whitespace", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1112 + }, + { + "case": "duplicate_json_key", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1124 + }, + { + "case": "changed_context_binding", + "result": "PASS_INERT_ONLY", + "fd0_reads": 0 + }, + { + "case": "changed_preparation_pin", + "result": "PASS_INERT_ONLY", + "fd0_reads": 0 + }, + { + "case": "valid_frame_without_origin", + "result": "PASS_INERT_ONLY", + "fd0_reads": 0 + }, + { + "case": "expiry_before_install", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1 + }, + { + "case": "read_error_retained_pending", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1 + }, + { + "case": "fstat_error_owned", + "result": "PASS_INERT_ONLY", + "fd0_reads": 0 + }, + { + "case": "equal_copy_origin_during_read", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1 + }, + { + "case": "retained_package_swap", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1111 + }, + { + "case": "actual_native_guard_real_modules_no_native_call", + "result": "PASS_READ_ONLY" + }, + { + "case": "native_registry_clone_refuses", + "result": "PASS_READ_ONLY" + }, + { + "case": "post_read_decoder_alias_zero_callback", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1 + }, + { + "case": "post_read_decoder_code_zero_callback", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1 + }, + { + "case": "post_read_import_alias_zero_callback", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1 + }, + { + "case": "post_read_import_code_before_decode", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1111 + }, + { + "case": "origin_swap_last_native_callback", + "result": "PASS_INERT_ONLY", + "fd0_reads": 1111 + } + ], + "actual_origin_authenticated": false, + "actual_fd0_calls": 0, + "actual_original_executions": 0, + "seams": [ + "protected original origin/custody", + "select/clock and fd0 native IO", + "full live profile capture/check" + ], + "original_activity_credit": 0 +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-transferred-22.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-transferred-22.json new file mode 100644 index 0000000000..33f27a241c --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-transferred-22.json @@ -0,0 +1,342 @@ +{ + "schema": "structural-original-driver-handoff-inert-v1", + "stage_sha256": "0ef5ed5a41ed93926bfe9135ed2ead85ce610a1053b7a2385f1df1330bab6f5f", + "binder_sha256": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048", + "passed": 22, + "tests": [ + { + "case": "exact_handoff", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 concrete authenticated issued input absent", + "result": "PASS_INERT_ONLY" + }, + { + "case": "provider_refusal", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam" + ], + "prepared_contexts": 0, + "stage_events": [], + "refusal": "inert provider preflight refused", + "result": "PASS_INERT_ONLY" + }, + { + "case": "driver_digest", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam" + ], + "prepared_contexts": 0, + "stage_events": [], + "refusal": "Bootstrap scientific driver source differs", + "result": "PASS_INERT_ONLY" + }, + { + "case": "driver_registry_substitution", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "driver_registry_substituted_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 executing driver differs from registered main", + "result": "PASS_INERT_ONLY" + }, + { + "case": "coherent_clone", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "driver_registry_substituted_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 executing driver differs from registered main", + "result": "PASS_INERT_ONLY" + }, + { + "case": "copied_namespace", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 executing driver differs from registered main", + "result": "PASS_INERT_ONLY" + }, + { + "case": "wrong_path", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 actual driver path differs", + "result": "PASS_INERT_ONLY" + }, + { + "case": "api_foreign_globals", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 driver API functions have another globals owner", + "result": "PASS_INERT_ONLY" + }, + { + "case": "main_foreign_globals", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 executing driver differs from registered main", + "result": "PASS_INERT_ONLY" + }, + { + "case": "main_wrong_code_path", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 driver main code owner differs", + "result": "PASS_INERT_ONLY" + }, + { + "case": "retained_drift_registry", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 retained driver registry identity changed", + "result": "PASS_INERT_ONLY" + }, + { + "case": "retained_drift_capability", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 retained driver live references changed", + "result": "PASS_INERT_ONLY" + }, + { + "case": "retained_drift_api_tuple", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 retained driver live references changed", + "result": "PASS_INERT_ONLY" + }, + { + "case": "retained_drift_api_code", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "source function code/globals/builtins/defaults/closure/dict changed", + "result": "PASS_INERT_ONLY" + }, + { + "case": "retained_drift_source_projection", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "V02 retained driver source/main changed", + "result": "PASS_INERT_ONLY" + }, + { + "case": "generic_unchanged", + "unit": "historical/unfamiliar", + "mode": "normal", + "result": "PASS_INERT_ONLY" + }, + { + "case": "generic_unchanged", + "unit": "historical/unfamiliar", + "mode": "optimized", + "result": "PASS_INERT_ONLY" + }, + { + "case": "generic_unchanged", + "unit": "epoch-v4/C03/native-enoent", + "mode": "normal", + "result": "PASS_INERT_ONLY" + }, + { + "case": "generic_unchanged", + "unit": "epoch-v4/C03/native-enoent", + "mode": "optimized", + "result": "PASS_INERT_ONLY" + }, + { + "case": "P_1MiB_plus1_before_open", + "result": "PASS_INERT_ONLY" + }, + { + "case": "preserved_failed_helper_order", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "FOREIGN_HANDOFF_CALLBACK", + "callbacks": 1, + "result": "PASS_INERT_ONLY" + }, + { + "case": "replaced_helper_at_P_read_zero_callbacks", + "events": [ + "initialize_seam", + "admit_provider_seam", + "capture_api_seam", + "preflight_seam", + "driver_source_read_seam", + "driver_handoff", + "registered_driver_at_binder" + ], + "prepared_contexts": 1, + "stage_events": [ + "actual_child_prepare_selected_child" + ], + "refusal": "pre-capture source object changed", + "callbacks": 0, + "result": "PASS_INERT_ONLY" + } + ], + "actual_issued_input": false, + "loaded_source_oracle_claimed": false, + "actual_root_provider_producer_executions": 0, + "original_activity_credit": 0, + "scope": "Exact extracted Root entry, stage main and child context/reader/install/registrar. Existing synthetic source/native seams plus explicit observer and drift seams; no target module imports or full driver execution.", + "transfer_note": "Five retained registrar drift tests bypass only the new constructor to isolate unchanged registrar; remaining controls retain actual new constructor.", + "ingress_seam": "New ingress bypassed explicitly to isolate predecessor handoff/registry/alias/refusal controls." +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-transferred-35.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-transferred-35.json new file mode 100644 index 0000000000..6ec00716d7 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REPLAY-transferred-35.json @@ -0,0 +1,187 @@ +{ + "schema": "v02-typed-install-inert-v1", + "candidate_sha256": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048", + "passed": 35, + "tests": [ + { + "case": "actual_installer_constructs_and_registers_exact_eight_identities", + "result": "PASS_INERT_ONLY", + "profile_calls": 1 + }, + { + "case": "ordinary_ingress_absent", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "changed_presentation", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "changed_mode", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "final_command_backedge", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "reordered_gate", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "missing_gate", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "none_gate", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "configuration_extra_key", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "source_subject_changed", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "provenance_digest_only", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "provenance_mutable", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "wrong_context", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "equal_copy_retained_record", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "equal_copy_gate", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "package_mutation_after_admission", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "retained_raw_mutation", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "root_path_mismatch", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "root_metadata_mismatch", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "provider_path_mismatch", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "typed_attempt_consumed", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "oversized_string", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "payload_cannot_issue_authority", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "read_failure_after_attempt_consumed", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "helper_replacement__construct_v02_issued_input", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "helper_replacement__v02_plain", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "helper_replacement__v02_same", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "helper_replacement__v02_pin_shape", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "boolean_integer_not_equal", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "foreign_package_key_zero_callbacks", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "tombstone_foreign_key_zero_callbacks", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "post_read_equal_copy_and_mutated_original", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "integer_zero_attempt_not_false", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "foreign_attempt_zero_callbacks", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + }, + { + "case": "foreign_metaclass_zero_callbacks", + "result": "PASS_INERT_ONLY", + "profile_calls": 0 + } + ], + "actual_admission_ingress": false, + "actual_root_provider_producer_calls": 0, + "full_live_profile_tested": false, + "original_activity_credit": 0, + "ingress_seam": "New ingress bypassed explicitly to isolate unchanged accepted typed constructor/registrar controls." +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REVIEW-final.json b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REVIEW-final.json new file mode 100644 index 0000000000..c4680a1349 --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REVIEW-final.json @@ -0,0 +1,92 @@ +{ + "status": "ACCEPT_PROSPECTIVE_CONDITIONAL_SOURCE_ONLY", + "source_pins": { + "selected_child_preseal_v1.py.txt": "7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048", + "frame_encoder_v1.py": "7fe7abcee99f3629bbc6bb73b86c76c5580607806432cf10c622018c18299700", + "host_preseal_writer.js.txt": "b5f7af26ea0cb3702cddd792061f434c055a7146ed726a6317395559a44c2bb9" + }, + "independent_author_replays": { + "ingress": 23, + "host": 12, + "transferred_typed": 35, + "transferred_predecessor": 22 + }, + "additional_independent_controls": { + "ingress": 10, + "encoder": 9, + "host": 6 + }, + "operational_channel_accepted": false, + "protected_origin_authenticated": false, + "real_live_profile_tested": false, + "actual_fd0_or_tool_calls": 0, + "original_omission_cases": 0, + "original_activity_credit": 0, + "parent_reported_operational_blocker": "Actual tty=false Tool probe returned character-device fd0, immediate EOF, no retained input session; not independently rerun in this review.", + "files": { + "REVIEW-final.md": { + "sha256": "0209ec0656367538ed48e17daffad5664db8d5c78ac06c8766fc8f9bfc0d7ac6", + "bytes": 5500 + }, + "FINAL-DELTA.json": { + "sha256": "91a278dbcfb148e9d73ebef89696e35b48be03ec30c05d04c2aa2a02b557e0e3", + "bytes": 695 + }, + "INGRESS-INDEPENDENT.json": { + "sha256": "bd74779a39172a77185bf118faccf4a6804ae97fd7c6e0de2ce27ce33d47f4bb", + "bytes": 2103 + }, + "ENCODER-INDEPENDENT.json": { + "sha256": "bfc3bcee03a52003e3e5cbcfb288b25e59e45eb561d1779d4f612e9e75df3015", + "bytes": 1501 + }, + "HOST-INDEPENDENT.json": { + "sha256": "4dfa1578dbd7a090a8ae0726a693e79e3ab391547ce7ce976054f523ef441e01", + "bytes": 1628 + }, + "REPLAY-author-ingress.json": { + "sha256": "d155d27a3ddd898d43634a627498adddd615cb5a84c1e0415c734b7e58b4626b", + "bytes": 3055 + }, + "REPLAY-author-host.json": { + "sha256": "71036e691fbfda4231bc44538ee1d3f36504e4483f9f7e176485f343704b63a0", + "bytes": 1841 + }, + "REPLAY-transferred-35.json": { + "sha256": "3a18512f246d0e54db74c0e6fd35a79cf8c1e38d517e27733a656105f252f18f", + "bytes": 4522 + }, + "REPLAY-transferred-22.json": { + "sha256": "4d90871ed430ef362b45ef10f69af2601b4c928263908d76a99c05cecef68e35", + "bytes": 9868 + }, + "test_ingress_independent.py": { + "sha256": "52d6b54ee6c465a00d6bc4d0a5ccf4271376651a061246cf293d7a5dce0a429b", + "bytes": 4450 + }, + "test_encoder_independent.py": { + "sha256": "43c7e06aace0061e20e6cab00c75087acfaf610d4adb2d0c292122ee534d3fce", + "bytes": 2520 + }, + "test_host_independent.js": { + "sha256": "02c3e16e04976855cfdfd05c8d6b6947df369067268a70528d372027bcd41aab", + "bytes": 2958 + }, + "HOST-PAYLOAD-FIXTURE.json": { + "sha256": "e44c14cfa2afeafc603376e9c24e1e8cfe87819c11dd6e38070ea2bab548d32e", + "bytes": 1503 + }, + "HOST-JSON-NUMBER-COUNTEREXAMPLE.json": { + "sha256": "bec168ce3546eb6e87767c53cd462db02cf0c4d9b7cc42e9fe8732a57c0654d1", + "bytes": 330 + }, + "REJECTED-b62f61f9.json": { + "sha256": "ce63e4869f2be8b8de62a2e7adaff5cbd9dad3d99b1f30f516bc826134419e92", + "bytes": 963 + }, + "rejected-b62f61f9.py.txt": { + "sha256": "b62f61f9363635a52c29889fce6d218f2b1a3f3133a196d4d32b571240270e17", + "bytes": 117125 + } + } +} diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REVIEW-final.md b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REVIEW-final.md new file mode 100644 index 0000000000..856afa961b --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/review/REVIEW-final.md @@ -0,0 +1,25 @@ +The reviewed sources are accepted for **prospective, conditional source behavior only**: + +- Child: `7001e2ba395ebb7e943816301be7830e6a9bb699acc182e2bbeb786148459048`. +- Pure encoder: `7fe7abcee99f3629bbc6bb73b86c76c5580607806432cf10c622018c18299700`. +- Host writer: `b5f7af26ea0cb3702cddd792061f434c055a7146ed726a6317395559a44c2bb9`. + +This is not an operational channel acceptance, a protected-origin authentication, an original live-profile acceptance, or an original V02 completion. The ordinary child origin remains None and the ordinary host lexical scope remains null. Both refuse before their respective modeled native I/O or Tool calls. + +The final source comparison against accepted typed constructor `926edbf6...` preserves 57 existing top-level functions. It changes only `prepare_binding_context`, `install_before_capture`, and `prepare_selected_child`, and adds the three preseal helpers. The exact existing typed constructor, registrar, source oracle and complete live-profile validators are unchanged. + +The review independently replayed 23 ingress controls, 12 host controls and the transferred 35 typed/22 predecessor controls. The transferred controls expressly bypass the new ingress to isolate their original contracts; they are not evidence of a protected channel. Additional independent tests passed 10 ingress controls, 9 encoder controls and 6 host controls. No production module top-level, original Root/provider API, producer, compiler, guest, real fd0 or native Tool call ran in these tests. The fixtures replace the protected-origin premise, fd0/select/clock behavior and full live-profile capture/check. + +Three concrete counterexample families were found and repaired: + +1. A decoder alias replaced during the first modeled fd0 read ran three times in the initial candidate. With an original source-record witness, the existing final installer check eventually entered STOP, but only after those callbacks. The final source retains helper aliases and native function-descriptor records before I/O, uses a local checker after native boundaries, and retains error-owner cells for STOP without calling a replaced global helper. Direct decoder alias/code replacements now refuse before the changed function executes. +2. An intermediate repair left the imported `json.loads` alias exposed. It could run three times and reach SEALED. The final source retains direct imported module namespaces and their Python function descriptors before I/O; it checks them before post-I/O decode/encode. Independent imported alias and same-object code mutations both refuse before execution. This finite direct-import check does not claim to sandbox arbitrary interpreter or deeper stdlib implementation mutation; the original admitted runtime/source premise remains required. +3. A protected-origin identity replaced by the final modeled native guard could reach SEALED. The final source rechecks origin, retained package, preparation, frame expectation and I/O ownership after the final native call. Origin replacement, retained tuple replacement and expectation mutation all refuse. Frame subject comparison and bounded pin associations remain unchanged. + +The initial host also compared the Python canonical frame against JavaScript `JSON.stringify` of its parsed wire. This rejected valid insertion order and could round exact integer pins. The concrete preserved example changes `1700000000000000001` to `1700000000000000000`. The final host transports the Python encoded ASCII frame verbatim, reading only schema and command string metadata through JavaScript JSON. The independent full-frame test uses the real pure encoder/preparation/E fixture, an exact non-JavaScript-safe timestamp and an escaped Unicode pathname. The synthetic Tool receives precisely the original frame string. Oversized and non-ASCII host frames reject with zero JSON-parser calls and zero Tool-model calls; bounds now precede parsing. + +The private protected-origin record must come from an independently authenticated original writer/session and sole-reader custody arrangement. Its premise must include inherited descriptor stability throughout the frame interval. Neither FIFO shape, endpoint identity, the frame, hashes, expected data nor an ACK supplies that authority. The encoder checks complete preparation/E association as representation and custody data; it does not approve any substantive decision. The actual deep runtime/native premise, full original live graph, genuine decision issuers, exact channel, costs, terminal ownership and original omission cases remain separate obligations. + +The parent reports a further concrete operating blocker: its actual Tool `tty=false` probe produced a character-device fd0, immediate EOF and no retained input session. This review did not rerun that Tool probe. Conditional source acceptance does not resolve or overrule that reported channel failure, and does not authorize replacing it with a guessed pipe/session. + +The failed initial source and receipt remain under `review/rejected-b62f61f9.py.txt` and `review/REJECTED-b62f61f9.json`. The intermediate imported-decoder failure is retained separately. `FINAL-DELTA.json`, `INGRESS-INDEPENDENT.json`, `ENCODER-INDEPENDENT.json`, `HOST-INDEPENDENT.json`, and the four `REPLAY-*` receipts identify the final tested scope. Original protected-origin authentications, real fd0/Tool invocations, full live-profile admissions, executed original omission cases and original activity credit are all zero in this review. diff --git a/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/selected_child_preseal_v1.py.txt b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/selected_child_preseal_v1.py.txt new file mode 100644 index 0000000000..b67293381f --- /dev/null +++ b/research/h25-v02-parent-custody-evidence/snapshots/trusted-preseal-ingress/selected_child_preseal_v1.py.txt @@ -0,0 +1,2077 @@ +"""Source-owned one-shot PRE-CAPTURE binding under an authenticated outer parent. + +The outer caller must authenticate this immutable source and the supplied +manifest BEFORE import/entry (inherited C04); no hash supplied here grants that +trust. This module has no loader, exec, callback, source mutation, Root API write, +stage write or target launch. It verifies exact already imported source objects, +then installs only a fixed enum of literal gate bindings once, before capture. +""" +import ast +import builtins +import hashlib +import json +import os +import stat +import sys +import types +import marshal +import dataclasses +import parent_completion_v1 as parent +import parent_closure_v1 as original_closure +import configured_inverse_v2 as inverse + +_INSTALLATIONS = [] +_ENTRY_ATTEMPTS = [] +_TYPE, _LEN = type, len +_OPEN, _READ, _CLOSE, _FSTAT, _GETPID = os.open, os.read, os.close, os.fstat, os.getpid +_MODULE_DICT = types.ModuleType.__dict__['__dict__'].__get__ +_FUNCTION_GETTERS = tuple(types.FunctionType.__dict__[name].__get__ for name in + ('__code__', '__globals__', '__builtins__', '__defaults__', '__kwdefaults__', '__closure__', '__dict__')) +_CELL_GET = types.CellType.__dict__['cell_contents'].__get__ +_CLASS_DICT = type.__dict__['__dict__'].__get__ +_STATIC_FUNCTION = staticmethod.__dict__['__func__'].__get__ +_CLASS_FUNCTION = classmethod.__dict__['__func__'].__get__ +# Captured only at the inherited independently admitted no-mutator startup. +_STARTUP_MODULES = {name: module for name, module in tuple(sys.modules.items()) + if type(name) is str and type(module) is types.ModuleType} +_STARTUP_HELPERS = tuple((module, tuple(_MODULE_DICT(module, types.ModuleType).items())) + for module in (parent, original_closure, inverse)) +_V02_PRESEAL_NATIVE = tuple((name, _STARTUP_MODULES[name], + _MODULE_DICT(_STARTUP_MODULES[name], types.ModuleType), function, + _MODULE_DICT(_STARTUP_MODULES[name], types.ModuleType)[function]) + for name, function in (('select', 'select'), ('time', 'monotonic_ns'))) +_MAX_GLOBALS = 512 +MAX_MODULES = 57 +MAX_IMAGE = 8 * 1024 * 1024 +MAX_TOTAL = 64 * 1024 * 1024 + + +class BindingStop(RuntimeError): + pass + + +def _need(value, message): + if not value: + raise BindingStop(message) + + +def _exact(value, keys): + _need(_TYPE(value) is dict and all(_TYPE(k) is str for k in value) and set(value) == set(keys), 'binding exact keys differ') + + +def _identity(info): + return {'device': info.st_dev, 'inode': info.st_ino, 'mode': info.st_mode, 'links': info.st_nlink, + 'uid': info.st_uid, 'gid': info.st_gid, 'size': info.st_size, + 'mtime_ns': info.st_mtime_ns, 'ctime_ns': info.st_ctime_ns} + + +def _entry(context): + _need(_TYPE(context) is object, 'exact original installation context required') + for token, state in _INSTALLATIONS: + if token is context: + return state + raise BindingStop('unregistered pre-capture installation context') + + +def _primitive_bindings_match_v3(values): + _need(_TYPE(values) is tuple and _LEN(values) == 5, 'exact primitive binding tuple required') + return all(actual is expected for actual, expected in zip(values, (os.open, os.read, os.close, os.fstat, os.getpid))) + + +def _fresh(state): + owner = state['owner'] + _need(parent._UNKNOWN_OWNER is owner and _GETPID() == state['pid'] and state['phase'] != 'STOP' and + owner['primary'][0] is None and owner['quarantine'][0] is False and + owner['pending'][0] is False and owner['iterator_uncertain'][0] is False, + 'original installation owner requires teardown') + _need(_primitive_bindings_match_v3((_OPEN, _READ, _CLOSE, _FSTAT, _GETPID)) and + _TYPE is builtins.type and _LEN is builtins.len, + 'original installation primitive binding changed') + + +def _read_pin(state, pin, limit=MAX_IMAGE): + """Nofollow component descent; known tokens close once, uncertainty latches.""" + _fresh(state) + _exact(pin, ('path', 'sha256', 'bytes', 'identity')) + path = pin['path'] + _need(_TYPE(path) is str and path.startswith('/') and len(path) <= 4096 and + all(c not in ('', '.', '..') for c in path.split('/')[1:]), 'binding pin path differs') + _digest(pin['sha256']) + _need(_TYPE(pin['bytes']) is int and 0 <= pin['bytes'] <= limit, 'binding pin byte bound') + _exact(pin['identity'], ('device', 'inode', 'mode', 'links', 'uid', 'gid', 'size', 'mtime_ns', 'ctime_ns')) + _need(all(_TYPE(x) is int and x >= 0 for x in pin['identity'].values()) and + pin['identity']['links'] == 1 and pin['identity']['size'] == pin['bytes'] and + stat.S_ISREG(pin['identity']['mode']) and not pin['identity']['mode'] & 0o222, + 'immutable binding source pin required') + primary = close_primary = None + parts = path.split('/')[1:] + _need(len(parts) <= 2048, 'source path component bound') + record = {'fds': [None, None], 'close_fds': [None, None], + 'close_entered': [False, False], 'close_errors': [None, None], + 'walk_fds': [None] * len(parts), 'walk_entered': [False] * len(parts), + 'walk_errors': [None] * len(parts), 'primary': [None]} + # Record allocation/retention precedes every acquisition owned by this read. + state['read_records'].append(record) + state['fds'] = record['fds'] + try: + state['owner']['pending'][0] = True + state['fds'][0] = _OPEN('/', os.O_RDONLY | os.O_DIRECTORY | os.O_CLOEXEC | os.O_NOFOLLOW) + state['owner']['pending'][0] = False + for walk_index, component in enumerate(parts[:-1]): + state['owner']['pending'][0] = True + state['fds'][1] = _OPEN(component, os.O_RDONLY | os.O_DIRECTORY | os.O_CLOEXEC | os.O_NOFOLLOW, + dir_fd=state['fds'][0]) + state['owner']['pending'][0] = False + old = state['fds'][0] + record['walk_fds'][walk_index] = old + record['walk_entered'][walk_index] = True + state['fds'][0] = None + try: + _CLOSE(old) + except BaseException as error: + record['walk_errors'][walk_index] = error + raise + state['fds'][0] = state['fds'][1] + state['fds'][1] = None + state['owner']['pending'][0] = True + state['fds'][1] = _OPEN(parts[-1], os.O_RDONLY | os.O_CLOEXEC | os.O_NOFOLLOW, dir_fd=state['fds'][0]) + state['owner']['pending'][0] = False + _need(_identity(_FSTAT(state['fds'][1])) == pin['identity'], 'actual binding file identity differs') + chunks, count = [], 0 + while True: + raw = _READ(state['fds'][1], min(65536, pin['bytes'] + 1 - count)) + _need(_TYPE(raw) is bytes, 'native binding read type differs') + if not raw: + break + count += len(raw); _need(count <= pin['bytes'], 'binding source grew') + chunks.append(raw) + raw = b''.join(chunks) + _need(len(raw) == pin['bytes'] and hashlib.sha256(raw).hexdigest() == pin['sha256'] and + _identity(_FSTAT(state['fds'][1])) == pin['identity'], 'binding source custody changed') + return raw + except BaseException as error: + primary = error + record['primary'][0] = error + if state['owner']['primary'][0] is None: + state['owner']['primary'][0] = error + state['owner']['quarantine'][0] = True + state['phase'] = 'STOP' + raise + finally: + descriptor = state['fds'][1] + record['close_fds'][1] = descriptor + if descriptor is not None: + record['close_entered'][1] = True + state['fds'][1] = None + try: + _CLOSE(descriptor) + except BaseException as error: + record['close_errors'][1] = error + if close_primary is None: + close_primary = error + if state['owner']['primary'][0] is None: + state['owner']['primary'][0] = error + state['owner']['quarantine'][0] = True + state['phase'] = 'STOP' + descriptor = state['fds'][0] + record['close_fds'][0] = descriptor + if descriptor is not None: + record['close_entered'][0] = True + state['fds'][0] = None + try: + _CLOSE(descriptor) + except BaseException as error: + record['close_errors'][0] = error + if close_primary is None: + close_primary = error + if state['owner']['primary'][0] is None: + state['owner']['primary'][0] = error + state['owner']['quarantine'][0] = True + state['phase'] = 'STOP' + if primary is None and close_primary is not None: + raise close_primary + + +def _pairs(items): + _need(len(items) <= 8192, 'binding mapping bound') + result = {} + for key, value in items: + _need(_TYPE(key) is str and len(key) <= 1048576 and key not in result, 'binding duplicate/foreign key') + result[key] = value + return result + + +def _reject(value): + raise BindingStop('binding noninteger/nonfinite literal rejected') + + +def _document(raw): + value = json.loads(raw.decode('ascii'), object_pairs_hook=_pairs, parse_float=_reject, parse_constant=_reject) + _literal(value, [0]) + _need(_TYPE(value) is dict, 'binding top-level document differs') + return value + + +def _namespace(module): + _need(_TYPE(module) is types.ModuleType, 'exact installed module type required') + namespace = _MODULE_DICT(module, types.ModuleType) + _need(_TYPE(namespace) is dict and _LEN(namespace) <= _MAX_GLOBALS, 'bounded exact installed namespace required') + # Complete key walk BEFORE any membership, lookup, set, hash or equality. + for key in namespace: + _need(_TYPE(key) is str and _LEN(key) <= 256, 'foreign installed namespace key') + for key in ('__name__', '__file__'): + _need(key in namespace and _TYPE(namespace[key]) is str and 0 < _LEN(namespace[key]) <= 4096, + 'exact installed module metadata required') + return namespace + + +def _startup_helpers_unchanged(): + for module, items in _STARTUP_HELPERS: + namespace = _namespace(module) + _need(_LEN(namespace) == _LEN(items), 'startup helper namespace census changed') + for key, expected in items: + _need(_TYPE(key) is str and namespace.get(key) is expected, 'startup helper binding identity changed') + + + +def _function_record(function): + _need(_TYPE(function) is types.FunctionType, 'exact source function required') + values = tuple(getter(function, types.FunctionType) for getter in _FUNCTION_GETTERS) + closure = values[5] + cells = () if closure is None else tuple((cell, _CELL_GET(cell, types.CellType)) for cell in closure) + _need(_LEN(cells) <= 64, 'source function closure bound exceeded') + return function, values, cells + + +def _function_check(record): + function, values, cells = record + _need(_TYPE(function) is types.FunctionType, 'source function identity changed') + for getter, expected in zip(_FUNCTION_GETTERS, values): + _need(getter(function, types.FunctionType) is expected, + 'source function code/globals/builtins/defaults/closure/dict changed') + for cell, expected in cells: + _need(_CELL_GET(cell, types.CellType) is expected, 'source function closure contents changed') + + +def _codes(code, result): + result.setdefault(code.co_qualname, []).append(code) + for child in code.co_consts: + if _TYPE(child) is types.CodeType: + _codes(child, result) + + +def _data(value, depth=0): + """Snapshot literal data only; no foreign repr/hash/eq/iteration protocols.""" + _need(depth <= 32, 'literal snapshot depth exceeded') + kind = _TYPE(value) + if value is None or (kind is str or kind is int or kind is bool or kind is bytes or kind is float): + return (kind, value) + if (kind is list or kind is tuple): + _need(_LEN(value) <= 65536, 'literal sequence bound exceeded') + return (kind, tuple(_data(item, depth + 1) for item in value)) + if kind is dict: + _need(_LEN(value) <= 8192, 'literal mapping bound exceeded') + for key in value: + _need((_TYPE(key) is str or _TYPE(key) is int), 'nonliteral mapping key') + return (kind, tuple((_data(key, depth + 1), _data(item, depth + 1)) + for key, item in value.items())) + if (kind is set or kind is frozenset): + _need(_LEN(value) <= 8192 and all((_TYPE(item) is str or _TYPE(item) is int) for item in value), + 'nonliteral set value') + return (kind, frozenset(value)) + raise BindingStop('not literal data') + + +def _validate_code(function, compiled_codes, namespace, source_role, forest): + """Collect one source-fixed role; only the complete forest can admit code.""" + _need(_TYPE(function) is types.FunctionType, 'exact installed source function required') + values = tuple(getter(function, types.FunctionType) for getter in _FUNCTION_GETTERS) + _need(values[1] is namespace and values[2] is builtins.__dict__, + 'source function original namespace/builtins differs') + _need(_TYPE(source_role) is str, 'exact source code role required') + candidates = compiled_codes.get(source_role, ()) + _need(_LEN(candidates) == 1, 'source code role absent or ambiguous') + forest.append((values[0], candidates[0])) + return None + + +def _digest(value): + _need(type(value) is str and len(value) == 64 and all(x in '0123456789abcdef' for x in value), + 'exact configuration digest required') + + +def _literal(value, budget, depth=0): + budget[0] += 1 + _need(budget[0] <= 200000 and depth <= 32, 'finite configured literal tree bound') + kind = type(value) + if value is None or kind is bool: + return + if kind is int: + _need(value.bit_length() <= 127, 'configuration integer bound') + return + if kind is str or kind is bytes: + _need(len(value) <= 1048576, 'configuration atom bound') + return + _need((kind is tuple or kind is list or kind is dict) and len(value) <= 8192, 'configuration exact literal type') + if kind is dict: + for key in value: + _need(type(key) is str, 'configuration dictionary key type') + for item in (value.values() if kind is dict else value): + _literal(item, budget, depth + 1) + + + +def _source_value(node, namespace, definitions, active=()): + """Finite source expression interpreter; never eval or candidate callbacks.""" + if type(node) is ast.Name: + _need(node.id in definitions and node.id not in active and len(active) < 32, + 'source default name is not a finite constant') + value = _source_value(definitions[node.id], namespace, definitions, active + (node.id,)) + _need(_data(namespace[node.id]) == _data(value), 'source default constant changed') + return value + if type(node) is ast.Attribute and type(node.value) is ast.Name: + module = namespace[node.value.id] + _need(type(module) is types.ModuleType, 'source default owner is not a module') + value = _MODULE_DICT(module, types.ModuleType)[node.attr] + _data(value) + return value + if type(node) is ast.BinOp: + left = _source_value(node.left, namespace, definitions, active) + right = _source_value(node.right, namespace, definitions, active) + _need(type(left) is int and type(right) is int, 'exact source integer default required') + if type(node.op) is ast.Add: value = left + right + elif type(node.op) is ast.Sub: value = left - right + elif type(node.op) is ast.Mult: value = left * right + elif type(node.op) is ast.LShift: + _need(0 <= right <= 127, 'source default shift bound') + value = left << right + elif type(node.op) is ast.Pow: + _need(0 <= right <= 127 and left.bit_length() * right <= 128, 'source default power bound') + value = left ** right + else: raise BindingStop('unsupported source default arithmetic') + _need(value.bit_length() <= 128, 'source default integer bound') + return value + value = ast.literal_eval(node) + _data(value) + return value + + +def _defined_function(function, node, codes, namespace, definitions, forest, cls=None): + source_role = node.name if cls is None else cls.__qualname__ + '.' + node.name + _validate_code(function, codes, namespace, source_role, forest) + values = tuple(getter(function, types.FunctionType) for getter in _FUNCTION_GETTERS) + expected = tuple(_source_value(v, namespace, definitions) for v in node.args.defaults) or None + keywords = {a.arg: _source_value(v, namespace, definitions) + for a, v in zip(node.args.kwonlyargs, node.args.kw_defaults) if v is not None} or None + _need(_data(values[3]) == _data(expected) and _data(values[4]) == _data(keywords), + 'initial function defaults differ from actual selected source') + if cls is None or not function.__code__.co_freevars: + _need(values[5] is None, 'unexpected source function closure') + else: + _need(function.__code__.co_freevars == ('__class__',) and len(values[5]) == 1 and + _CELL_GET(values[5][0], types.CellType) is cls, 'class closure does not own actual class') + return _function_record(function) + + +def _source_objects(module, source_pin, raw, exact_modules): + # Original authenticated-source startup seal, never a caller record. + # These native checks occur inline before new oracle callbacks. + _need(_MODULE_DICT(builtins, types.ModuleType) is _CODE_ORACLE_BUILTINS, + 'source oracle builtin owner changed') + _need(_LEN(_CODE_ORACLE_BUILTINS) == _LEN(_CODE_ORACLE_BUILTIN_ITEMS), + 'source oracle builtin census changed') + for builtin_key in _CODE_ORACLE_BUILTINS: + _need(_TYPE(builtin_key) is str, 'source oracle foreign builtin key') + for builtin_key, builtin_value in _CODE_ORACLE_BUILTIN_ITEMS: + _need(_CODE_ORACLE_BUILTINS[builtin_key] is builtin_value, + 'source oracle builtin binding changed') + for oracle_name, oracle_value, oracle_record in _CODE_ORACLE_STARTUP_SEAL: + _need(_CODE_ORACLE_NAMESPACE[oracle_name] is oracle_value, + 'source oracle alias identity changed') + if oracle_record is not None: + for getter, expected in zip(_FUNCTION_GETTERS, oracle_record[1]): + _need(getter(oracle_value, types.FunctionType) is expected, + 'source oracle function descriptor changed') + _need(not oracle_record[1][6], 'source oracle function dictionary changed') + for cell, expected in oracle_record[2]: + _need(_CELL_GET(cell, types.CellType) is expected, 'source oracle cell changed') + for oracle_class, class_items, class_mro in _CODE_ORACLE_CLASS_SEAL: + actual_items = _CLASS_DICT(oracle_class, type) + _need(_LEN(actual_items) == _LEN(class_items), 'source oracle class census changed') + for class_key in actual_items: + _need(_TYPE(class_key) is str, 'source oracle foreign class key') + for class_key, class_value in class_items: + _need(actual_items[class_key] is class_value, 'source oracle class binding changed') + _need(_CODE_ORACLE_MRO_GET(oracle_class, type) is class_mro, + 'source oracle class MRO changed') + namespace = _namespace(module) + _need(namespace.get('__file__') == source_pin['path'] and + sys.modules.get(namespace['__name__']) is module, 'installed actual source module differs') + tree = ast.parse(raw, filename=source_pin['path']) + code = compile(raw, source_pin['path'], 'exec', dont_inherit=True, optimize=sys.flags.optimize) + codes = {}; _codes(code, codes) + definitions = {n.targets[0].id: n.value for n in tree.body + if type(n) is ast.Assign and len(n.targets) == 1 and type(n.targets[0]) is ast.Name} + records, classes, forest = [], [], [] + for node in tree.body: + if type(node) is ast.FunctionDef: + _need(not node.decorator_list, 'top-level decorated selected function unsupported') + records.append(_defined_function(namespace[node.name], node, codes, namespace, definitions, forest)) + elif type(node) is ast.ClassDef: + cls = namespace[node.name] + _need(type(cls) is type and not node.keywords and + cls.__module__ == namespace['__name__'] and cls.__name__ == node.name and + cls.__qualname__ == node.name, 'source class/metaclass/name owner differs') + bases = [] + for base in node.bases: + _need(type(base) is ast.Name, 'unreviewed computed class base') + bases.append(namespace.get(base.id, builtins.__dict__.get(base.id))) + _need(cls.__bases__ == tuple(bases or [object]), 'actual source class bases differ') + dataclass_owned = False + if node.decorator_list: + _need(len(node.decorator_list) == 1, 'unreviewed source class decorator composition') + decorator = node.decorator_list[0] + _need(type(decorator) is ast.Call and type(decorator.func) is ast.Name and + namespace.get(decorator.func.id) is dataclasses.dataclass and not decorator.args, + 'only actual original dataclass factory admitted') + options = {kw.arg: ast.literal_eval(kw.value) for kw in decorator.keywords} + _need(options == {'frozen': True, 'slots': True} and cls.__dataclass_params__.frozen is True, + 'original dataclass constructor options differ') + fields = tuple(n.target.id for n in node.body + if type(n) is ast.AnnAssign and type(n.target) is ast.Name) + _need(tuple(cls.__dataclass_fields__) == fields and tuple(cls.__slots__) == fields, + 'actual generated dataclass fields/slots differ') + dataclass_owned = True + own = _CLASS_DICT(cls, type) + declared = set() + for item in node.body: + if type(item) is ast.FunctionDef: + method = own[item.name]; declared.add(item.name) + decorators = tuple(d.id if type(d) is ast.Name else None for d in item.decorator_list) + if decorators: + _need(decorators in (('staticmethod',), ('classmethod',)), + 'unreviewed explicit method decorator') + descriptor = staticmethod if decorators == ('staticmethod',) else classmethod + _need(namespace.get(decorators[0], builtins.__dict__[decorators[0]]) is descriptor and + type(method) is descriptor, 'actual method wrapper owner differs') + method = (_STATIC_FUNCTION(method, staticmethod) if descriptor is staticmethod + else _CLASS_FUNCTION(method, classmethod)) + elif item.name == '__new__' and type(method) is staticmethod: + method = _STATIC_FUNCTION(method, staticmethod) + elif item.name in ('__init_subclass__', '__class_getitem__') and type(method) is classmethod: + method = _CLASS_FUNCTION(method, classmethod) + records.append(_defined_function(method, item, codes, namespace, definitions, forest, cls)) + for name, method in own.items(): + if type(method) is types.FunctionType and name not in declared: + _need(dataclass_owned and name in ('__init__', '__repr__', '__eq__', '__hash__', + '__setattr__', '__delattr__', '__getstate__', '__setstate__'), + 'extra generated source method lacks the original fixed factory') + records.append(_function_record(method)) + classes.append((cls, tuple(own.items()))) + # Original authenticated-source startup seal, never a caller record. + # These native checks occur inline before new oracle callbacks. + _need(_MODULE_DICT(builtins, types.ModuleType) is _CODE_ORACLE_BUILTINS, + 'source oracle builtin owner changed') + _need(_LEN(_CODE_ORACLE_BUILTINS) == _LEN(_CODE_ORACLE_BUILTIN_ITEMS), + 'source oracle builtin census changed') + for builtin_key in _CODE_ORACLE_BUILTINS: + _need(_TYPE(builtin_key) is str, 'source oracle foreign builtin key') + for builtin_key, builtin_value in _CODE_ORACLE_BUILTIN_ITEMS: + _need(_CODE_ORACLE_BUILTINS[builtin_key] is builtin_value, + 'source oracle builtin binding changed') + for oracle_name, oracle_value, oracle_record in _CODE_ORACLE_STARTUP_SEAL: + _need(_CODE_ORACLE_NAMESPACE[oracle_name] is oracle_value, + 'source oracle alias identity changed') + if oracle_record is not None: + for getter, expected in zip(_FUNCTION_GETTERS, oracle_record[1]): + _need(getter(oracle_value, types.FunctionType) is expected, + 'source oracle function descriptor changed') + _need(not oracle_record[1][6], 'source oracle function dictionary changed') + for cell, expected in oracle_record[2]: + _need(_CELL_GET(cell, types.CellType) is expected, 'source oracle cell changed') + for oracle_class, class_items, class_mro in _CODE_ORACLE_CLASS_SEAL: + actual_items = _CLASS_DICT(oracle_class, type) + _need(_LEN(actual_items) == _LEN(class_items), 'source oracle class census changed') + for class_key in actual_items: + _need(_TYPE(class_key) is str, 'source oracle foreign class key') + for class_key, class_value in class_items: + _need(actual_items[class_key] is class_value, 'source oracle class binding changed') + _need(_CODE_ORACLE_MRO_GET(oracle_class, type) is class_mro, + 'source oracle class MRO changed') + if forest: + _code_oracle_compare_code_forest(tuple(row[0] for row in forest), tuple(row[1] for row in forest)) + return tree, tuple(records), tuple(classes), _import_bindings(tree, namespace, exact_modules) + + +def _import_namespace(module): + _need(_TYPE(module) is types.ModuleType, 'exact imported module required') + namespace = _MODULE_DICT(module, types.ModuleType) + _need(_TYPE(namespace) is dict and _LEN(namespace) <= _MAX_GLOBALS, + 'bounded imported namespace required') + for key in namespace: + _need(_TYPE(key) is str and _LEN(key) <= 256, 'foreign import namespace key') + _need(_TYPE(namespace.get('__name__')) is str, 'import module metadata differs') + return namespace + + +def _import_bindings(tree, namespace, exact_modules): + """Exact Python import semantics, no import hook or dynamic attribute lookup. + + The caller authenticates source modules before this function is invoked. + Stdlib modules are the admitted startup objects; every selected object is + also the actual sys.modules object. Parent package edges are checked and + retained, rather than treating an import alias as a name-map convention. + """ + _need(_TYPE(exact_modules) is dict and _LEN(exact_modules) <= 4096, + 'bounded exact module inventory required') + for key, value in exact_modules.items(): + _need(_TYPE(key) is str and _TYPE(value) is types.ModuleType and + sys.modules.get(key) is value, 'invented/substituted module inventory') + records, seen = [], set() + def selected(name): + _need(_TYPE(name) is str and 0 < _LEN(name) <= 256 and + all(part.isidentifier() for part in name.split('.')), 'exact absolute import name') + parts = name.split('.') + _need(_LEN(parts) <= 32, 'import package depth exceeded') + prior = None + for index in range(1, _LEN(parts) + 1): + full = '.'.join(parts[:index]) + expected = exact_modules.get(full, _STARTUP_MODULES.get(full)) + _need(expected is not None and _TYPE(expected) is types.ModuleType and + sys.modules.get(full) is expected, 'import module missing/substituted') + startup = _STARTUP_MODULES.get(full) + _need(startup is None or startup is expected, 'admitted startup import identity changed') + own = _import_namespace(expected) + _need(own['__name__'] == full or + (_STARTUP_MODULES.get(own['__name__']) is expected and + sys.modules.get(own['__name__']) is expected), 'import module canonical/real alias identity differs') + if prior is not None: + _need(prior.get(parts[index - 1]) is expected, 'package submodule edge changed') + if full not in seen: + seen.add(full) + records.append((full, expected, own, tuple(own.items()))) + prior = own + return expected + for node in tree.body: + if _TYPE(node) is ast.Import: + for alias in node.names: + submodule = selected(alias.name) + if alias.asname is None: + bound_name = alias.name.split('.')[0] + expected = selected(bound_name) + else: + bound_name, expected = alias.asname, submodule + _need(namespace.get(bound_name) is expected, 'installed exact import alias differs') + elif _TYPE(node) is ast.ImportFrom: + _need(node.level == 0 and _TYPE(node.module) is str, + 'relative import requires separately reviewed package context') + module = selected(node.module) + imported = _import_namespace(module) + for alias in node.names: + _need(alias.name != '*' and alias.name.isidentifier(), 'explicit imported symbol required') + _need(alias.name in imported, 'imported symbol absent from real namespace') + expected = imported[alias.name] + if _TYPE(expected) is types.ModuleType: + _need(selected(node.module + '.' + alias.name) is expected, + 'from-import submodule identity differs') + _need(namespace.get(alias.asname or alias.name) is expected, + 'installed from-import symbol/alias differs') + return tuple(records) + + +def _imports_unchanged(records, installed=None): + for name, module, namespace, items in records: + _need(sys.modules.get(name) is module and _import_namespace(module) is namespace and + _LEN(namespace) == _LEN(items), 'import namespace identity/census changed') + for key, value in items: + expected = value if installed is None else installed.get((name, key), value) + _need(namespace.get(key) is expected, 'import package/submodule/symbol binding changed') + + + +def _classes_unchanged(classes): + for cls, items in classes: + namespace = _CLASS_DICT(cls, type) + _need(len(namespace) == len(items), 'installed class namespace census changed') + for key, prior in items: + _need(namespace.get(key) is prior, 'installed class attribute binding changed') + + + +def prepare_binding_context(original_parent, original_unknown_owner, exact_modules, outer_manifest_pin): + """Called only by independently authenticated actual original outer parent. + + outer_manifest_pin is externally authenticated command/manifest input, not + a trust decision made by this source. It binds data without reciprocal + source hashes: source images -> plans -> schedule -> bindings -> outer pin. + """ + state = None + try: + _startup_helpers_unchanged() + _need(original_parent is parent and original_unknown_owner is parent._UNKNOWN_OWNER and + not _INSTALLATIONS and not parent._PARENTS and parent._PROCESS[0] is None, + 'actual pristine original parent/private owner required before capture') + _need(_TYPE(exact_modules) is dict and 1 <= len(exact_modules) <= MAX_MODULES and + all(_TYPE(name) is str and name.isidentifier() for name in exact_modules), 'exact finite source modules required') + state = {'owner': original_unknown_owner, 'pid': _GETPID(), 'phase': 'PREPARING', 'consumed': False, + 'modules': exact_modules, 'fds': [None, None], 'close_errors': [], 'read_records': [], 'records': [], + 'sources': {}, 'bindings': {}, 'installed': {}, 'primary': [None], 'outer_pin': outer_manifest_pin, + 'v02_protected_origin': None, 'v02_preseal_attempted': False, 'v02_preseal_io': None, 'v02_preseal_binding': None, 'v02_pre_admitted_input': None, 'v02_typed_attempted': False, 'v02_driver_handoff_input': None, 'v02_driver_handoff': None, 'v02_attempted': False, 'v02_anchor': None, 'v02_busy': False, 'v02_issued_input': None, 'v02_installing': False} + token = object(); _INSTALLATIONS.append((token, state)) + outer = _document(_read_pin(state, outer_manifest_pin)) + _exact(outer, ('schema', 'source_manifest', 'binding_plan', 'source_review_sha256', 'bootstrap_review_sha256', + 'command_review_sha256', 'root_source_sha256', 'runtime_premise_sha256')) + _need(outer['schema'] == 'h25-authenticated-pre-capture-context-v2' and + outer['root_source_sha256'] == 'f5a2d33f2b4d3651f214156a0e7094c2bb516ce2d5ab7698d18c11f98f35dee0', + 'original Root and external context differ') + for key in ('source_review_sha256', 'bootstrap_review_sha256', 'command_review_sha256', 'runtime_premise_sha256'): + _digest(outer[key]) + manifest = _document(_read_pin(state, outer['source_manifest'])) + plan = _document(_read_pin(state, outer['binding_plan'])) + _exact(manifest, ('schema', 'modules')) + _exact(plan, ('schema', 'bindings')) + _exact(manifest['modules'], tuple(exact_modules)) + _need(_TYPE(plan['bindings']) is dict and _LEN(plan['bindings']) <= MAX_MODULES and + all(_TYPE(key) is str for key in plan['bindings']), 'exact bounded gate module keys required') + _need(manifest['schema'] == 'h25-bootstrap-module-manifest-v2' and plan['schema'] == 'h25-pre-capture-bindings-v2' and + set(manifest['modules']) == set(exact_modules), 'complete bootstrap source inventory differs') + _need(set(plan['bindings']) <= set(ALLOWED_GATES) and set(plan['bindings']) <= set(exact_modules), + 'binding contains module outside fixed source enum') + total = 0 + for name, module in exact_modules.items(): + _need(_namespace(module).get('__name__') == name, 'bootstrap module name differs') + record = manifest['modules'][name] + _exact(record, ('source', 'template_inverse')) + source_pin = record['source'] + raw = _read_pin(state, source_pin) + total += len(raw); _need(total <= MAX_TOTAL, 'whole bootstrap source byte bound') + _need(record['template_inverse']['configured_sha256'] == source_pin['sha256'] and + record['template_inverse']['module'] == name, 'bootstrap configured source binding differs') + state.setdefault('inverse_work', []).append((raw, record['template_inverse'])) + tree, functions, classes, imports = _source_objects(module, source_pin, raw, exact_modules) + names = {node.targets[0].id: node.value for node in tree.body if _TYPE(node) is ast.Assign and + len(node.targets) == 1 and _TYPE(node.targets[0]) is ast.Name} + namespace = _namespace(module) + selected = plan['bindings'].get(name, {}) + _need(_TYPE(selected) is dict and set(selected) <= set(ALLOWED_GATES.get(name, ())), 'unknown gate assignment') + needed = tuple(key for key in ALLOWED_GATES.get(name, ()) if key in namespace) + _need(set(selected) == set(needed), 'complete fixed gate binding set omitted') + bound = {} + for gate, literal in selected.items(): + _need(gate in names and type(names[gate]) is ast.Constant and names[gate].value is None and + namespace[gate] is None and type(literal) is str and literal.isascii() and '\n' not in literal, + 'gate was previously configured, captured, or is not an explicit None template') + value = ast.literal_eval(literal); _literal(value, [0]) + _need(value is not None, 'installation cannot leave required gate unset') + bound[gate] = value + state['sources'][name] = source_pin + state['bindings'][name] = bound + state['records'].append((name, module, namespace, tuple(namespace.items()), functions, classes, imports)) + # Every supplied helper/function/class and its namespace is authenticated + # from outer-pinned source BEFORE the first inverse helper invocation. + _need(exact_modules.get('configured_inverse_v2') is inverse and + exact_modules.get('parent_completion_v1') is parent and + exact_modules.get('parent_closure_v1') is original_closure, + 'complete original helper source inventory required') + _startup_helpers_unchanged() + for raw, inverse_record in state['inverse_work']: + inverse.verify_configured_source(raw, inverse_record) + state['outer'] = outer + state['phase'] = 'PREPARED' + return token + except BaseException as error: + if parent._UNKNOWN_OWNER['primary'][0] is None: + parent._UNKNOWN_OWNER['primary'][0] = error + parent._UNKNOWN_OWNER['quarantine'][0] = True + if state is not None: + state['primary'][0] = error; state['phase'] = 'STOP' + raise + + +def install_before_capture(context): + state = _entry(context) + try: + _fresh(state) + _need(state['phase'] == 'PREPARED' and not state['consumed'] and not parent._PARENTS and + parent._PROCESS[0] is None, 'binding installation is one-shot before original capture') + state['consumed'] = True + state['phase'] = 'INSTALLING' + selected = state['bindings'].get('component_control_root_v1', {}).get('CONTEXT_CONFIGURATION', {}) + is_v02 = (selected.get('unit_id') == 'variant/V02/python-preflight-v1' and + selected.get('mode') == 'normal' and sys.flags.optimize == 0) + if is_v02: + _need(_TYPE(sys.modules) is dict and _LEN(sys.modules) <= 512, 'V02 finite exact module registry required') + for module_key in sys.modules: + _need(_TYPE(module_key) is str and _LEN(module_key) <= 256, 'V02 foreign module registry key') + for name, module, namespace, original, functions, classes, imports in state['records']: + _need(_namespace(module) is namespace and len(namespace) == len(original), 'pre-capture namespace changed') + for key, value in original: + _need(namespace.get(key) is value, 'pre-capture source object changed') + for function in functions: + _function_check(function) + _classes_unchanged(classes) + _imports_unchanged(imports) + _read_pin(state, state['sources'][name]) + if is_v02: + _fresh(state) + state['phase'] = 'PREPARED' + state['v02_installing'] = True + handoff_input = state['v02_driver_handoff_input'] + _need(_TYPE(handoff_input) is tuple and _LEN(handoff_input) == 2, + 'V02 retained driver handoff input absent') + _retain_v02_driver_handoff(context, handoff_input[0], handoff_input[1]) + _receive_v02_preseal(context) + _construct_v02_issued_input(context) + _register_v02_live(context) + state['v02_installing'] = False + state['phase'] = 'INSTALLING' + for name, module, namespace, original, functions, classes, imports in state['records']: + for key, value in state['bindings'][name].items(): + namespace[key] = value + state['installed'][(name, key)] = (module, value, + _capture_installed_gate(context, state, name, module, key, value)) + state['phase'] = 'SEALED' + verify_bindings(context) + return None + except BaseException as error: + if state['owner']['primary'][0] is None: + state['owner']['primary'][0] = error + state['owner']['quarantine'][0] = True + if state['primary'][0] is None: + state['primary'][0] = error + state['phase'] = 'STOP' + raise + + +def verify_bindings(context): + state = _entry(context) + try: + if state['v02_anchor'] is not None: + _need(_TYPE(sys.modules) is dict and _LEN(sys.modules) <= 512, 'V02 finite exact module registry required') + for module_key in sys.modules: + _need(_TYPE(module_key) is str and _LEN(module_key) <= 256, 'V02 foreign module registry key') + _fresh(state) + _need(state['phase'] == 'SEALED' and state['consumed'], 'final source capture requires sealed bindings') + _read_pin(state, state['outer_pin']) + for pin in (state['outer']['source_manifest'], state['outer']['binding_plan']): + _read_pin(state, pin) + for name, module, namespace, original, functions, classes, imports in state['records']: + _need(_namespace(module) is namespace and len(namespace) == len(original), 'installed namespace census changed') + for key, prior in original: + expected = state['bindings'][name].get(key, prior) + _need(namespace.get(key) is expected, 'installed source binding identity changed') + for record in functions: + _function_check(record) + _classes_unchanged(classes) + _imports_unchanged(imports, {(module_name, key): value for module_name, values in state['bindings'].items() for key, value in values.items()}) + _read_pin(state, state['sources'][name]) + for (name, key), (module, value, snapshot) in state['installed'].items(): + check_installed_gate(context, name, module, key, value, snapshot) + return None + except BaseException as error: + if state['v02_anchor'] is not None: + _v02_stop(state, error) + raise + + +def require_installed_gate(module, name, value): + """Read-only link from a receiver closure to its sealed original context.""" + _need(_TYPE(name) is str and _TYPE(module) is types.ModuleType, 'exact installed gate lookup') + matches = [] + for token, state in _INSTALLATIONS: + if state['phase'] == 'SEALED': + for (module_name, gate), row in state['installed'].items(): + if row[0] is module and gate == name: + matches.append((token, row)) + _need(len(matches) == 1 and matches[0][1][1] is value, 'gate not installed by the original sealed context') + verify_bindings(matches[0][0]) + return None + + +def stop_evidence(context): + state = _entry(context) + return state['primary'], tuple(state['read_records']), tuple(state['fds']) + + +# Exact finite gate enum, source-reviewed; no wildcard or arbitrary namespace writes. +ALLOWED_GATES = {'component_control_root_v1': ('CONTEXT_CONFIGURATION', 'CONTEXT_SOURCE_REVIEW', 'CONTEXT_EXECUTION_APPROVAL', 'CONTEXT_FUNDING'), 'epoch_copy_v5': ('COMPLETE_IO_CONFIGURATION', 'COPY_CONFIGURATION', 'COPY_EXECUTION_APPROVAL', 'COPY_FUNDING', 'CONTROL_CONFIGURATION', 'CONTROL_SOURCE_REVIEW', 'CONTROL_EXECUTION_APPROVAL', 'CONTROL_FUNDING'), 'epoch_parent_v5': ('CONFIGURATION', 'SOURCE_REVIEW', 'EXECUTION_APPROVAL', 'FUNDING'), 'epoch_stop_v5': ('STOP_CONFIGURATION', 'STOP_EXECUTION_APPROVAL', 'STOP_FUNDING'), 'fixture_parent_v2': ('CONFIGURATION', 'SOURCE_REVIEW', 'FIXTURE_PROFILE_CONFIGURATION', 'SONAME_CONSUMER_CONFIGURATION', 'STAGE_APPROVAL', 'COMMAND_APPROVAL', 'FUNDING', 'EXECUTION_APPROVAL'), 'negative_parent_v2': ('CONFIGURATION', 'SOURCE_REVIEW', 'RUNTIME_CONFIGURATION', 'KERNEL_CONFIGURATION', 'REPLAY_CONFIGURATION', 'STAGE_APPROVAL', 'COMMAND_APPROVAL', 'FUNDING', 'EXECUTION_APPROVAL'), 'original_build_provenance_v5': ('PARSER_CONFIGURATION', 'PARSER_EXECUTION_APPROVAL', 'PARSER_FUNDING'), 'owned_root_v2': ('CONFIGURATION', 'SOURCE_REVIEW', 'RUNTIME_CONFIGURATION', 'STAGE_APPROVAL', 'COMMAND_APPROVAL', 'FUNDING', 'EXECUTION_APPROVAL'), 'parent_completion_v1': ('CONFIGURATION', 'SOURCE_REVIEW', 'STAGE_APPROVAL', 'COMMAND_APPROVAL', 'FUNDING', 'EXECUTION_APPROVAL'), 'parent_orchestration_v2': ('CONFIGURATION', 'SOURCE_REVIEW', 'RUNTIME_CONFIGURATION', 'NATIVE_PROFILE_CONFIGURATION', 'FULL_UNION_CONFIGURATION', 'FULL_CALLER_CONFIGURATION', 'BOOTSTRAP_CONFIGURATION', 'STAGE_APPROVAL', 'COMMAND_APPROVAL', 'FUNDING', 'EXECUTION_APPROVAL'), 'persistent_replay_v1': ('CONFIGURATION', 'SOURCE_REVIEW', 'RUNTIME_CONFIGURATION', 'PERSISTENCE_CONFIGURATION', 'FULL_ORCHESTRATOR_CONFIGURATION', 'NATIVE_PROFILE_CONFIGURATION', 'SOURCE_CLOSURE_CONFIGURATION', 'STAGE_APPROVAL', 'COMMAND_APPROVAL', 'FUNDING', 'EXECUTION_APPROVAL'), 'policy_parent_domain_v1': ('CONFIGURATION', 'SOURCE_REVIEW', 'RUNTIME_PROFILE', 'KERNEL_EXEC_PROFILE', 'PHASED_FD_CONTRACT', 'TERMINAL_STATUS_CONTRACT', 'REPLAY_BINDING', 'STAGE_APPROVAL', 'COMMAND_APPROVAL', 'FUNDING', 'EXECUTION_APPROVAL'), 'supplemental_receivers_v2': ('CONTROL_EXECUTORS_CONFIGURATION',), 'variant_validation_v1': ('VALIDATION_CONFIGURATION', 'VALIDATION_SOURCE_REVIEW', 'VALIDATION_EXECUTION', 'VALIDATION_FUNDING')} + + +_NATIVE_UNITS = ('epoch-v4/C03/native-enoent', 'epoch-v4/C03/native-eexist', 'epoch-v4/C03/native-eloop') +_NATIVE_COPY = 'b8303732ede41dd48aa767f2c40cbbff249f34e2621f532b5484d38a218a0f69' +_PORT_COPY = 'bcc465a7c61261b58e92c06f1cf7937b134256243f1a0ff84ad859965ad0134d' +_SCHEMA = 'b89a789654be87bde40a47300f4d9702dce2b90e6ab3be9a2025f6d8041b3e9a' + + +def prepare_selected_child(lane_text, exact_modules, driver_namespace=None): + """Actual Root driver dispatch, using its authenticated unchanged argv tail. + + The original source-owned parent binds these lane bytes in immutable JOBS + and the exact whole command. This function proves checks/use, not that an + arbitrary string caller is that parent. The unchanged original fresh-Root + premise supplies that factual source/input provenance. + """ + _need(not _ENTRY_ATTEMPTS and type(lane_text) is str and len(lane_text) <= 16384, + 'selected child pre-capture entry is one-shot') + state = {'owner': parent._UNKNOWN_OWNER, 'pid': _GETPID(), 'phase': 'READING', + 'fds': [None, None], 'close_errors': [], 'read_records': [], 'primary': [None]} + _ENTRY_ATTEMPTS.append(state) # Before the first acquisition. + try: + transport = _document(lane_text.encode('ascii')) + _exact(transport, ('schema', 'plan')) + _need(transport['schema'] == 'h25-selected-child-argv-v1' and + json.dumps(transport, sort_keys=True, separators=(',', ':')) == lane_text, + 'exact canonical original-owner lane transport required') + plan = _document(_read_pin(state, transport['plan'])) + # A transport distinction only. P remains opaque data, never authority. + selected = plan.get('selection') + v02_normal = (_TYPE(selected) is dict and + selected.get('unit_id') == 'variant/V02/python-preflight-v1' and + selected.get('mode') == 'normal' and sys.flags.optimize == 0) + if v02_normal: + _exact(plan, ('schema', 'outer_context', 'entry_configuration', 'selection', 'preflight_package')) + _need(plan['schema'] == 'h25-selected-child-preparation-v02-v1', 'V02 selected preparation schema differs') + else: + _exact(plan, ('schema', 'outer_context', 'entry_configuration', 'selection')) + _need(plan['schema'] == 'h25-selected-child-preparation-v1', 'selected preparation schema differs') + selection = plan['selection'] + _exact(selection, ('unit_id', 'mode', 'kind')) + _need(selection['mode'] == ('normal' if sys.flags.optimize == 0 else 'optimized') and + sys.flags.optimize in (0, 1), 'actual selected child mode differs') + kind = 'NATIVE_PRODUCTION' if selection['unit_id'] in _NATIVE_UNITS else 'HISTORICAL_PORT' + _need(selection['kind'] == kind, 'source-owned native/port choice differs') + token = prepare_binding_context(parent, parent._UNKNOWN_OWNER, exact_modules, plan['outer_context']) + installed = _entry(token) + context = installed['bindings']['component_control_root_v1']['CONTEXT_CONFIGURATION'] + _need(context['unit_id'] == selection['unit_id'] and context['mode'] == selection['mode'], + 'installed actual context differs from selection') + source_manifest = _document(_read_pin(installed, installed['outer']['source_manifest'])) + modules = source_manifest['modules'] + _need(modules['epoch_copy_v5']['template_inverse']['template_sha256'] == + (_NATIVE_COPY if kind == 'NATIVE_PRODUCTION' else _PORT_COPY) and + modules['epoch_schema_v5']['template_inverse']['template_sha256'] == _SCHEMA, + 'actual selected production/port source differs') + _need(modules['component_control_root_v1']['template_inverse']['assignments'] == {}, + 'context must be installed before capture, never a cyclic configured source') + if v02_normal: + _need(installed['phase'] == 'PREPARED' and not installed['consumed'] and + installed['v02_issued_input'] is None, + 'V02 transport data requires unissued original PREPARED context') + package_pin = plan['preflight_package'] + # Use the existing complete-pin verified reader. Do not decode P, + # infer approval, construct live objects, or populate issuance. + package_snapshot = _data(package_pin) + package_raw = _read_pin(installed, package_pin, 1024 * 1024) + _need(_data(package_pin) == package_snapshot, 'V02 package pin changed during transport read') + installed['v02_preflight_package_data'] = (package_pin, package_snapshot, package_raw) + installed['v02_preseal_binding'] = (transport['plan'], _data(transport['plan']), + plan['entry_configuration'], _data(plan['entry_configuration']), selection, _data(selection)) + installed['v02_driver_handoff_input'] = (driver_namespace, plan['entry_configuration']['guard']['entry_source']) + install_before_capture(token) + state['token'], state['plan'], state['transport'] = token, plan, transport + state['phase'] = 'SEALED' + return plan['entry_configuration'] + except BaseException as error: + if state['primary'][0] is None: state['primary'][0] = error + if state['owner']['primary'][0] is None: state['owner']['primary'][0] = error + state['owner']['quarantine'][0] = True + state['phase'] = 'STOP' + raise + + +def require_selected_child(modules, source_policy, unit, mode): + _need(len(_ENTRY_ATTEMPTS) == 1 and _ENTRY_ATTEMPTS[0]['phase'] == 'SEALED', + 'actual selected child constructor was not reached') + state = _ENTRY_ATTEMPTS[0]; installed = _entry(state['token']) + _need(installed['modules'] is modules or all(installed['modules'].get(k) is v for k,v in modules.items()), + 'actual selected module objects differ') + _need(set(installed['sources']) == set(source_policy) and all( + _data(installed['sources'][name]) == _data(source_policy[name]) for name in source_policy), + 'receiver policy differs from actual authenticated source manifest') + selection = state['plan']['selection'] + _need(selection['unit_id'] == unit and selection['mode'] == mode, 'actual selection context differs') + verify_bindings(state['token']) + return state['token'] + + +"""INERT SOURCE CANDIDATE, not installed or integration-qualified. + +Append-only proposed chunk for exact #6885 selected_child_bindings_v1.py. +Uses its authenticated helpers; never calls a Root/provider/API function. +Initial pristine custody and P/E decisions remain external prerequisites. +This captures extant function/code/cell identity and selected mutable state; +it does not prove that an arbitrary initial object is a genuine issued object. +""" + +_V02_ROOT_SHA = 'f5a2d33f2b4d3651f214156a0e7094c2bb516ce2d5ab7698d18c11f98f35dee0' +_V02_PROVIDER_SHA = '9cbb7368f89e71d1e6cc46db5dc77efed3e03ed2a801c98c88fe316e4d9f3ef2' +_V02_ROOT_FUNCTIONS = ('_make_metadata_factory', '_scope_factory_gate', '_need', '_code_names', '_immutable_default', '_function_record', '_function_fresh', '_environment_guard', '_check_root', '_fingerprint', '_hash_regular', 'initialize', '_source_identity_scoped', 'source_identity', '_capability_state', '_validate_namespace', 'admit_provider', '_validate_capability_scoped', 'validate_capability', '_pending', '_check_spec', '_create_native', '_exec_native', '_activate_native', 'load_probe', 'load_control_module', 'preflight', 'diagnostics', 'capture_api', '_entry') +_V02_PROVIDER_FUNCTIONS = ('_need', '_fingerprint', '_hash_regular', '_profile_files', '_audit_files', '_code_names', '_function_record', '_function_fresh', '_make_guard', '_state', 'validate_binding', 'preflight_runtime', 'load_probe') +_V02_NATIVE_NAMES = (('builtins', 'type'), ('builtins', 'object'), ('builtins', 'dict'), ('builtins', 'tuple'), ('builtins', 'str'), ('builtins', 'int'), ('builtins', 'len'), ('builtins', 'id'), ('builtins', 'globals'), ('builtins', 'compile'), ('builtins', 'exec'), ('posix', 'open'), ('posix', 'read'), ('posix', 'fstat'), ('posix', 'close'), ('posix', 'getpid'), ('_hashlib', 'openssl_sha256'), ('_imp', 'create_dynamic'), ('_imp', 'exec_dynamic'), ('sys', 'gettrace'), ('sys', 'getprofile')) +_V02_COUNTERS = ('load_calls', 'native_creations', 'native_execs', 'activation_attempts', 'successful_bindings', 'deactivation_attempts', 'cleanup_failures', 'control_module_creations') + + +def _v02_mapping(mapping, key_type=None): + if key_type is None: + key_type = str + _need(_TYPE(mapping) is dict and _LEN(mapping) <= 512, 'V02 finite exact mapping required') + for key in mapping: + _need(_TYPE(key) is key_type, 'V02 foreign mapping key') + return mapping, key_type, tuple(mapping.items()) + + +def _v02_mapping_check(record): + mapping, key_type, items = record + _need(_TYPE(mapping) is dict and _LEN(mapping) == _LEN(items), 'V02 mapping census changed') + for key in mapping: + _need(_TYPE(key) is key_type, 'V02 foreign mapping key') + for key, value in items: + _need(key in mapping and mapping[key] is value, 'V02 mapping owner/value identity changed') + + +def _v02_cell(function, name): + _need(_TYPE(function) is types.FunctionType, 'V02 exact function required') + code = _FUNCTION_GETTERS[0](function, types.FunctionType) + closure = _FUNCTION_GETTERS[5](function, types.FunctionType) + _need(_TYPE(closure) is tuple and name in code.co_freevars, 'V02 named closure edge absent') + cell = closure[code.co_freevars.index(name)] + return cell, _CELL_GET(cell, types.CellType) + + +def _v02_modules(): + # Conservative source-candidate admission bound, not an observed live count. + # Membership and lookup follow this complete primitive-key walk. + modules = sys.modules + _need(_TYPE(modules) is dict and _LEN(modules) <= 512, + 'V02 exact bounded module registry required') + for key in modules: + _need(_TYPE(key) is str and _LEN(key) <= 256, 'V02 foreign module registry key') + return modules + + +def _v02_native_edges(root_namespace): + _v02_modules() + _need(root_namespace['builtins'] is builtins and root_namespace['sys'] is sys, + 'V02 Root original builtin/sys owners differ') + builtin_record = _v02_mapping(builtins.__dict__) + root_modules = root_namespace['_ROOT_MODULE_RECORDS'] + _need(_TYPE(root_modules) is tuple and _LEN(root_modules) == 5, + 'V02 Root runtime-module census differs') + for row, name in zip(root_modules, ('builtins', 'sys', 'posix', '_imp', '_hashlib')): + _need(_TYPE(row) is tuple and _LEN(row) == 2 and _TYPE(row[0]) is str and row[0] == name and + row[1] is root_namespace[name] and _TYPE(row[1]) is types.ModuleType and + sys.modules.get(name) is row[1], 'V02 Root runtime-module owner differs') + records = root_namespace['_NATIVE_NAMESPACES'] + _need(_TYPE(records) is tuple and _LEN(records) == _LEN(_V02_NATIVE_NAMES), + 'V02 native edge census differs') + for row, (module_name, function_name) in zip(records, _V02_NATIVE_NAMES): + _need(_TYPE(row) is tuple and _LEN(row) == 4, 'V02 native row shape differs') + module, namespace, name, value = row + _need(module is root_namespace[module_name] and _TYPE(module) is types.ModuleType and + _MODULE_DICT(module, types.ModuleType) is namespace and _TYPE(name) is str and + name == function_name, 'V02 native namespace/name owner differs') + # Complete primitive-key walk before lookup; no __file__ assumption for builtins. + _v02_mapping(namespace) + _need(name in namespace and namespace[name] is value, 'V02 native entry identity differs') + return builtin_record, root_modules, records + + +def _v02_native_edges_check(record): + _v02_modules() + builtin_record, root_modules, native_records = record + _v02_mapping_check(builtin_record) + for name, module in root_modules: + _need(sys.modules.get(name) is module, 'V02 runtime-module registration changed') + for module, namespace, name, value in native_records: + _need(_MODULE_DICT(module, types.ModuleType) is namespace and _LEN(namespace) <= 512, + 'V02 native namespace identity/bound changed') + for key in namespace: + _need(_TYPE(key) is str, 'V02 native namespace foreign key') + _need(name in namespace and namespace[name] is value, 'V02 native entry identity changed') + + +def _v02_capture_live_profile(root, capability, api4, root_source, provider_source): + """Pre-seal only, after genuine externally admitted pristine construction. + + Root/provider stay out of generic _source_objects. Source bytes must have + inherited authenticated custody; hashes here check the exact source pins. + """ + # Original authenticated-source startup seal, never a caller record. + # These native checks occur inline before new oracle callbacks. + _need(_MODULE_DICT(builtins, types.ModuleType) is _CODE_ORACLE_BUILTINS, + 'source oracle builtin owner changed') + _need(_LEN(_CODE_ORACLE_BUILTINS) == _LEN(_CODE_ORACLE_BUILTIN_ITEMS), + 'source oracle builtin census changed') + for builtin_key in _CODE_ORACLE_BUILTINS: + _need(_TYPE(builtin_key) is str, 'source oracle foreign builtin key') + for builtin_key, builtin_value in _CODE_ORACLE_BUILTIN_ITEMS: + _need(_CODE_ORACLE_BUILTINS[builtin_key] is builtin_value, + 'source oracle builtin binding changed') + for oracle_name, oracle_value, oracle_record in _CODE_ORACLE_STARTUP_SEAL: + _need(_CODE_ORACLE_NAMESPACE[oracle_name] is oracle_value, + 'source oracle alias identity changed') + if oracle_record is not None: + for getter, expected in zip(_FUNCTION_GETTERS, oracle_record[1]): + _need(getter(oracle_value, types.FunctionType) is expected, + 'source oracle function descriptor changed') + _need(not oracle_record[1][6], 'source oracle function dictionary changed') + for cell, expected in oracle_record[2]: + _need(_CELL_GET(cell, types.CellType) is expected, 'source oracle cell changed') + for oracle_class, class_items, class_mro in _CODE_ORACLE_CLASS_SEAL: + actual_items = _CLASS_DICT(oracle_class, type) + _need(_LEN(actual_items) == _LEN(class_items), 'source oracle class census changed') + for class_key in actual_items: + _need(_TYPE(class_key) is str, 'source oracle foreign class key') + for class_key, class_value in class_items: + _need(actual_items[class_key] is class_value, 'source oracle class binding changed') + _need(_CODE_ORACLE_MRO_GET(oracle_class, type) is class_mro, + 'source oracle class MRO changed') + _v02_modules() + r = _namespace(root) + _need(_TYPE(root_source) is bytes and _LEN(root_source) <= 262144 and + hashlib.sha256(root_source).hexdigest() == _V02_ROOT_SHA, 'V02 Root source pin') + _need(_TYPE(provider_source) is bytes and _LEN(provider_source) <= 262144 and + hashlib.sha256(provider_source).hexdigest() == _V02_PROVIDER_SHA, 'V02 provider source pin') + _need(r['_ROOT_MODULE'] is root and r['_ROOT_NAMESPACE'] is r and + sys.modules.get('_h25_probe_bootstrap_v3') is root and + r['_ROOT_MODULES'] is sys.modules, 'V02 Root real alias/namespace differs') + native_edges = _v02_native_edges(r) + registry_record = _v02_mapping(r['_CAPABILITIES'], int) + registry = registry_record[0] + _need(_TYPE(r['BootstrapCapability']) is type and _TYPE(capability) is r['BootstrapCapability'] and + _LEN(registry) == 1 and id(capability) in registry, 'V02 pristine registered capability differs') + row = registry[id(capability)] + _need(_TYPE(row) is tuple and _LEN(row) == 7 and row[0] is capability, 'V02 exact capability row differs') + provider = row[1] + p = _namespace(provider) + _need(row[6] is p and _TYPE(row[3]) is str and row[3] == _V02_PROVIDER_SHA and + row[4] is p['__file__'] and p['_BOOTSTRAP_CAPABILITY'] is capability, + 'V02 provider ownership/source differs') + _need(p['__name__'] == '_h25_source_provider_v3_0' and p['__name__'] not in sys.modules, + 'V02 source-owned provider registration differs') + for provider_name, root_name in (('_ROOT_VALIDATE', '_validate_namespace'), ('_ROOT_CREATE', '_create_native'), ('_ROOT_EXEC', '_exec_native'), ('_ROOT_ACTIVATE', '_activate_native')): + _need(p[provider_name] is r[root_name], 'V02 injected Root function owner differs') + _need(_TYPE(api4) is tuple and _LEN(api4) == 4, 'V02 exact four-API tuple required') + root_cell = r['_ROOT_CELL'] + _need(_TYPE(root_cell) is list and _LEN(root_cell) == 2, 'V02 Root guard cell shape') + factory, root_guard, provider_guard = r['_NEW_SCOPE'], root_cell[0], row[2] + _need(_v02_cell(root_guard, 'namespace')[1] is r and + _v02_cell(provider_guard, 'namespace')[1] is p, 'V02 guard namespace owner differs') + for guard in (root_guard, provider_guard): + _need(_v02_cell(guard, 'fresh')[1] is r['_function_fresh'] and + _v02_cell(guard, 'defaults_check')[1] is r['_immutable_default'] and + _v02_cell(guard, 'fresh_code')[1] is _FUNCTION_GETTERS[0](r['_function_fresh'], types.FunctionType) and + _v02_cell(guard, 'defaults_code')[1] is _FUNCTION_GETTERS[0](r['_immutable_default'], types.FunctionType) and + _v02_cell(guard, 'builtins_owner')[1] is builtins.__dict__, + 'V02 guard original checker/builtins edges differ') + shared_guard_cell, api_guard = _v02_cell(api4[0], 'guard') + _need(api_guard is root_guard, 'V02 API guard owner differs') + for function in api4[1:]: + cell, value = _v02_cell(function, 'guard') + _need(cell is shared_guard_cell and value is root_guard, 'V02 shared API guard cell differs') + shared_scope_cell, api_scope = _v02_cell(api4[0], 'new_scope') + cell, value = _v02_cell(api4[1], 'new_scope') + _need(cell is shared_scope_cell and value is api_scope, 'V02 shared API scope cell differs') + for function, name, expected in zip(api4, ('identity', 'validate', 'load', 'diagnostic'), + (r['_source_identity_scoped'], r['_validate_capability_scoped'], r['load_probe'], r['diagnostics'])): + _need(_v02_cell(function, name)[1] is expected, 'V02 API function owner differs') + scopes = (root_cell[1], p['_MAKE_METADATA_SCOPE'], _v02_cell(root_guard, 'new_scope')[1], + _v02_cell(provider_guard, 'new_scope')[1], api_scope) + for scope in scopes: + _need(_v02_cell(scope, 'factory')[1] is factory, 'V02 checked scope factory owner differs') + nested = (factory, root_guard, provider_guard) + scopes + api4 + _need(_LEN({id(function) for function in nested}) == 12, 'V02 extant nested function census differs') + root_codes, provider_codes = {}, {} + _codes(compile(root_source, r['__file__'], 'exec', dont_inherit=True, optimize=sys.flags.optimize), root_codes) + _codes(compile(provider_source, p['__file__'], 'exec', dont_inherit=True, optimize=sys.flags.optimize), provider_codes) + functions = [(r[name], root_codes, r, name) for name in _V02_ROOT_FUNCTIONS] + functions += [(p[name], provider_codes, p, name) for name in _V02_PROVIDER_FUNCTIONS] + classes, class_mros = [], [] + for namespace, codes, name, methods in ((r, root_codes, 'BootstrapCapability', ('__new__',)), + (r, root_codes, '_NativeSpec', ('__init__',)), + (p, provider_codes, 'ProbeBinding', ('__new__', 'check', 'inspect', 'counters', 'close'))): + cls = namespace[name] + _need(_TYPE(cls) is type, 'V02 exact source class required') + members = _CLASS_DICT(cls, type) + _need(_LEN(members) <= 512, 'V02 bounded class namespace required') + for key in members: + _need(_TYPE(key) is str, 'V02 foreign class key') + classes.append((cls, tuple(members.items()))) + mro = type.__dict__['__mro__'].__get__(cls, type) + _need(_LEN(mro) == 2 and mro[0] is cls and mro[1] is object, + 'V02 source class direct object base differs') + class_mros.append((cls, mro)) + for method in methods: + function = members[method] + if _TYPE(function) is staticmethod: + function = _STATIC_FUNCTION(function, staticmethod) + functions.append((function, codes, namespace, name + '.' + method)) + nested_names = ('_make_metadata_factory..new_scope', + '_environment_guard..guard', '_environment_guard..guard') + \ + ('_scope_factory_gate..checked_scope',) * 5 + \ + tuple('capture_api..' + name for name in + ('sealed_identity', 'sealed_validate', 'sealed_load', 'sealed_diagnostics')) + functions += [(function, root_codes, r, name) for function, name in zip(nested, nested_names)] + records, root_forest, provider_forest = [], [], [] + for function, codes, namespace, expected_qualname in functions: + _validate_code(function, codes, namespace, expected_qualname, + root_forest if namespace is r else provider_forest) + record = _function_record(function) + values = record[1] + _need(values[0].co_qualname == expected_qualname, 'V02 exact source function role differs') + expected_default = values[0].co_qualname in ('_check_root', '_capability_state', '_environment_guard..guard') + _need(values[4] is None and + (values[3] is None if not expected_default else + _TYPE(values[3]) is tuple and _LEN(values[3]) == 1 and values[3][0] is None), + 'V02 original source defaults differ') + _need(_TYPE(values[6]) is dict and not values[6], 'V02 pristine function dictionary differs') + records.append(record) + # Original authenticated-source startup seal, never a caller record. + # These native checks occur inline before new oracle callbacks. + _need(_MODULE_DICT(builtins, types.ModuleType) is _CODE_ORACLE_BUILTINS, + 'source oracle builtin owner changed') + _need(_LEN(_CODE_ORACLE_BUILTINS) == _LEN(_CODE_ORACLE_BUILTIN_ITEMS), + 'source oracle builtin census changed') + for builtin_key in _CODE_ORACLE_BUILTINS: + _need(_TYPE(builtin_key) is str, 'source oracle foreign builtin key') + for builtin_key, builtin_value in _CODE_ORACLE_BUILTIN_ITEMS: + _need(_CODE_ORACLE_BUILTINS[builtin_key] is builtin_value, + 'source oracle builtin binding changed') + for oracle_name, oracle_value, oracle_record in _CODE_ORACLE_STARTUP_SEAL: + _need(_CODE_ORACLE_NAMESPACE[oracle_name] is oracle_value, + 'source oracle alias identity changed') + if oracle_record is not None: + for getter, expected in zip(_FUNCTION_GETTERS, oracle_record[1]): + _need(getter(oracle_value, types.FunctionType) is expected, + 'source oracle function descriptor changed') + _need(not oracle_record[1][6], 'source oracle function dictionary changed') + for cell, expected in oracle_record[2]: + _need(_CELL_GET(cell, types.CellType) is expected, 'source oracle cell changed') + for oracle_class, class_items, class_mro in _CODE_ORACLE_CLASS_SEAL: + actual_items = _CLASS_DICT(oracle_class, type) + _need(_LEN(actual_items) == _LEN(class_items), 'source oracle class census changed') + for class_key in actual_items: + _need(_TYPE(class_key) is str, 'source oracle foreign class key') + for class_key, class_value in class_items: + _need(actual_items[class_key] is class_value, 'source oracle class binding changed') + _need(_CODE_ORACLE_MRO_GET(oracle_class, type) is class_mro, + 'source oracle class MRO changed') + _code_oracle_compare_code_forest(tuple(row[0] for row in root_forest), tuple(row[1] for row in root_forest)) + _code_oracle_compare_code_forest(tuple(row[0] for row in provider_forest), tuple(row[1] for row in provider_forest)) + _need(_LEN(records) == 62 and _LEN({id(record[0]) for record in records}) == 62, + 'V02 full extant source function census differs') + _need(_LEN({id(cell) for unused, unused2, cells in records for cell, value in cells}) == 124, + 'V02 distinct closure cell census differs') + loads, owners, counts, metadata = r['_LOADS'], p['_OWNERS'], row[5], r['_ROOT_METADATA'] + mappings = (registry_record, _v02_mapping(r), _v02_mapping(p), _v02_mapping(loads, int), + _v02_mapping(owners, int), _v02_mapping(counts), _v02_mapping(metadata)) + _need(not loads and not owners and set(counts) == set(_V02_COUNTERS) and + all(_TYPE(value) is int and value == 0 for value in counts.values()), 'V02 pre-seal pristine state required') + metadata_data = _data(metadata) + _need(metadata.get('source_sha256') == _V02_ROOT_SHA and + metadata.get('source_bytes') == _LEN(root_source), 'V02 initialized Root metadata differs') + # Exact function records, namespaces and capability row remain strongly held. + return (root, capability, api4, provider, tuple(records), tuple(classes), mappings, + root_cell, tuple(root_cell), sys.modules, p['__name__'], metadata_data, tuple(class_mros), native_edges) + + +def _v02_check_live_profile(profile, root, capability, api4): + """Repeat before EVERY receiver guard in the pre-seal phase, not just bind.""" + _v02_modules() + original_root, original_capability, original_api4, provider, records, classes, mappings, root_cell, root_items, modules, provider_name, metadata, class_mros, native_edges = profile + _need(root is original_root and capability is original_capability and api4 is original_api4, + 'V02 injected live argument identity changed') + _need(sys.modules is modules and modules.get('_h25_probe_bootstrap_v3') is root and + provider_name not in modules, 'V02 actual owner registration changed') + _v02_native_edges_check(native_edges) + for record in mappings: + _v02_mapping_check(record) + _need(_LEN(root_cell) == 2 and all(actual is expected for actual, expected in zip(root_cell, root_items)), + 'V02 Root guard cell contents changed') + for record in records: + _function_check(record) + _need(not record[1][6], 'V02 function dictionary contents changed') + _classes_unchanged(classes) + for cls, mro in class_mros: + _need(type.__dict__['__mro__'].__get__(cls, type) is mro, 'V02 source class MRO changed') + _need(_data(mappings[-1][0]) == metadata, 'V02 Root metadata contents changed') + return None + + +# Inert candidate: no issuer is provided. Concrete authenticated P/E is still absent. +_V02_CONFIG_KEYS = ('schema', 'unit_id', 'original_source', 'bootstrap_root', + 'bootstrap_capability', 'bootstrap_api', 'genuine_gate_values') + + +def _v02_stop(state, error): + if state['owner']['primary'][0] is None: + state['owner']['primary'][0] = error + if state['primary'][0] is None: + state['primary'][0] = error + state['owner']['quarantine'][0] = True + state['phase'] = 'STOP' + + +def _retain_v02_driver_handoff(context, driver_namespace, source_projection): + """Retain the original reached driver's objects, never issue authority. + + The authenticated Root/stage/argv provenance is an external existing + premise. This structural join is not a loaded-source or native-profile + oracle. In particular the guard source is a projection, not a full pin. + """ + state = _entry(context) + try: + _fresh(state) + _need(state['phase'] == 'PREPARED' and state['consumed'] is True and + state['v02_installing'] is True and state['v02_issued_input'] is None and state['v02_driver_handoff'] is None, + 'V02 driver handoff requires original unissued PREPARED context') + selected = state['bindings']['component_control_root_v1']['CONTEXT_CONFIGURATION'] + _need(_TYPE(selected) is dict and _TYPE(selected.get('unit_id')) is str and + selected['unit_id'] == 'variant/V02/python-preflight-v1' and + _TYPE(selected.get('mode')) is str and selected['mode'] == 'normal' and + sys.flags.optimize == 0, 'V02 driver handoff requires actual normal selection') + _need(_TYPE(driver_namespace) is dict, 'V02 actual driver namespace required') + # Primitive keys before any supplied namespace membership or lookup. + for key in driver_namespace: + _need(_TYPE(key) is str, 'V02 foreign driver namespace key') + registry = _v02_modules() + driver = registry.get('__main__') + _need(_TYPE(driver) is types.ModuleType and + _MODULE_DICT(driver, types.ModuleType) is driver_namespace, + 'V02 executing driver differs from registered main') + _need(_TYPE(driver_namespace.get('__name__')) is str and + driver_namespace['__name__'] == '__main__', 'V02 driver module name differs') + _exact(source_projection, ('path', 'sha256', 'bytes')) + source = source_projection + _need(_TYPE(source['path']) is str and source['path'].startswith('/') and + _TYPE(source['bytes']) is int and 0 < source['bytes'] <= MAX_IMAGE, + 'V02 driver source projection differs') + _digest(source['sha256']) + _need(_TYPE(driver_namespace.get('__file__')) is str and + driver_namespace['__file__'] == source['path'], 'V02 actual driver path differs') + main = driver_namespace.get('main') + main_record = _function_record(main) + _need(main_record[1][1] is driver_namespace and + main_record[1][0].co_filename == source['path'] and + main_record[1][0].co_name == 'main', 'V02 driver main code owner differs') + root = driver_namespace.get('bootstrap_root') + capability = driver_namespace.get('bootstrap_capability') + api = driver_namespace.get('bootstrap_api') + _need(_TYPE(root) is types.ModuleType and + registry.get('_h25_probe_bootstrap_v3') is root and capability is not None and + _TYPE(api) is tuple and _LEN(api) == 4, 'V02 driver injected object shape differs') + root_namespace = _MODULE_DICT(root, types.ModuleType) + api_records = tuple(_function_record(function) for function in api) + _need(all(record[1][1] is root_namespace for record in api_records), + 'V02 driver API functions have another globals owner') + record = (context, driver, driver_namespace, main_record, root, capability, + api, api_records, source, _data(source), registry) + state['v02_driver_handoff'] = record + _check_v02_driver_handoff(context) + return None + except BaseException as error: + _v02_stop(state, error) + raise + + +def _check_v02_driver_handoff(context): + """Recheck retained identities before use; no source read or issuance.""" + state = _entry(context) + try: + _fresh(state) + record = state['v02_driver_handoff'] + _need(_TYPE(record) is tuple and _LEN(record) == 11 and record[0] is context, + 'V02 original driver handoff absent') + unused, driver, namespace, main_record, root, capability, api, api_records, source, snapshot, registry = record + _need(_v02_modules() is registry and registry.get('__main__') is driver and + _MODULE_DICT(driver, types.ModuleType) is namespace, + 'V02 retained driver registry identity changed') + for key in namespace: + _need(_TYPE(key) is str, 'V02 foreign driver namespace key') + _need(_TYPE(namespace.get('__name__')) is str and namespace['__name__'] == '__main__' and + _TYPE(namespace.get('__file__')) is str and _data(source) == snapshot and + namespace['__file__'] == source['path'] and + namespace.get('main') is main_record[0], 'V02 retained driver source/main changed') + _function_check(main_record) + _need(namespace.get('bootstrap_root') is root and + namespace.get('bootstrap_capability') is capability and + namespace.get('bootstrap_api') is api and + registry.get('_h25_probe_bootstrap_v3') is root, + 'V02 retained driver live references changed') + for function_record in api_records: + _function_check(function_record) + return record + except BaseException as error: + _v02_stop(state, error) + raise + + + +# Adapt PR6368 _plain with a full primitive-key census before dictionary lookup. +# _same is unchanged except the function prefix. +def _v02_plain(value): + budget = [0, 0] + + def walk(item, depth): + budget[0] += 1 + if depth > 24 or budget[0] > 65536: + raise ValueError('gate tree bound') + kind = type(item) + if item is None or kind is bool: + return + if kind is int: + if not -(1 << 64) <= item < (1 << 64): + raise ValueError('gate integer bound') + return + if kind is str: + budget[1] += len(item) + if len(item) > 8192 or budget[1] > 524288: + raise ValueError('gate text bound') + return + if (kind is not list and kind is not dict) or len(item) > 1024: + raise ValueError('gate exact JSON domain') + if kind is dict: + for key in item: + if type(key) is not str: + raise ValueError('gate exact string key required') + for key in item: + walk(key, depth + 1) + walk(item[key], depth + 1) + else: + for child in item: + walk(child, depth + 1) + + walk(value, 0) + +def _v02_same(left, right): + if type(left) is not type(right): + return False + if type(left) is dict: + return (set(left) == set(right) and + all(_v02_same(left[k], right[k]) for k in left)) + if type(left) is list: + return (len(left) == len(right) and + all(_v02_same(a, b) for a, b in zip(left, right))) + return left == right + +_V02_GATE_NAMES = ('VARIANT_CONFIGURATION', 'VARIANT_SOURCE_REVIEW', + 'VARIANT_STAGE_ADMISSION', 'VARIANT_NATIVE_PROFILE', 'VARIANT_HEADER_ADMISSION', + 'VARIANT_COMMAND_ADMISSION', 'VARIANT_FUNDING', 'VARIANT_EXECUTION') +_V02_ORIGINAL_SHA = 'cdb1479253358508088f8aa0e1e92e6c75ffcc127e54552698598a02de061254' +_V02_PRODUCER_KEYS = ('additional_source_pins', 'expected_dependencies', + 'expected_preflight', 'include', 'roles', 'source_files', 'system_header_admission_sha256') + + +def _v02_pin_shape(pin, limit): + # Same complete immutable regular-file pin contract as the owning reader. + _exact(pin, ('path', 'sha256', 'bytes', 'identity')) + _need(_TYPE(pin['path']) is str and pin['path'].startswith('/') and + _LEN(pin['path']) <= 4096 and + all(c not in ('', '.', '..') for c in pin['path'].split('/')[1:]), + 'V02 complete source path differs') + _digest(pin['sha256']) + _need(_TYPE(pin['bytes']) is int and 0 < pin['bytes'] <= limit, + 'V02 complete source byte bound') + _exact(pin['identity'], ('device', 'inode', 'mode', 'links', 'uid', 'gid', 'size', 'mtime_ns', 'ctime_ns')) + _need(all(_TYPE(x) is int and x >= 0 for x in pin['identity'].values()) and + pin['identity']['links'] == 1 and pin['identity']['size'] == pin['bytes'] and + stat.S_ISREG(pin['identity']['mode']) and not pin['identity']['mode'] & 0o222, + 'V02 immutable source identity differs') + + + +def _v02_preseal_native_guard(): + """Startup-native ownership check; this does not authenticate a pipe writer.""" + registry = _v02_modules() + _need(_TYPE(_V02_PRESEAL_NATIVE) is tuple and _LEN(_V02_PRESEAL_NATIVE) == 2, + 'V02 preseal native census differs') + values = [] + for row, expected in zip(_V02_PRESEAL_NATIVE, (('select', 'select'), ('time', 'monotonic_ns'))): + _need(_TYPE(row) is tuple and _LEN(row) == 5, 'V02 preseal native row differs') + name, module, namespace, function, value = row + _need(_TYPE(name) is str and _TYPE(function) is str and (name, function) == expected and + _TYPE(module) is types.ModuleType and registry.get(name) is module and + _MODULE_DICT(module, types.ModuleType) is namespace, + 'V02 preseal native module owner differs') + _v02_mapping(namespace) + _need(namespace.get(function) is value and _TYPE(value) is types.BuiltinFunctionType and + value.__self__ is module, 'V02 preseal native function owner differs') + values.append(value) + return tuple(values) + + +def _v02_preseal_binding_check(state, record): + _need(state['v02_preseal_binding'] is record and _TYPE(record) is tuple and _LEN(record) == 6, + 'V02 preseal preparation owner differs') + for value, snapshot in ((record[0],record[1]),(record[2],record[3]),(record[4],record[5])): + _v02_plain(value) + _need(_data(value) == snapshot, 'V02 preseal preparation contents differ') + _v02_pin_shape(record[0], MAX_IMAGE) + return None + + +def _receive_v02_preseal(context): + """One protected-origin frame, then child-local objects from retained P. + + Original authoritative writer/session/sole-reader custody is an external + protected startup premise, NEVER inferred from stdin type, frame bytes, + pin equality or the later ACK. Ordinary source has no premise issuer. + No generic setter exists. Tests supply an expressly inert owning seam. + """ + state = _entry(context) + io = None + owner_primary, quarantine, local_primary = state['owner']['primary'], state['owner']['quarantine'], state['primary'] + try: + _fresh(state) + _need(state['phase'] == 'PREPARED' and state['consumed'] is True and + state['v02_installing'] is True and state['v02_preseal_attempted'] is False and + state['v02_pre_admitted_input'] is None and state['v02_issued_input'] is None, + 'V02 preseal ingress is one-shot before typed construction') + state['v02_preseal_attempted'] = True + _check_v02_driver_handoff(context) + origin = state['v02_protected_origin'] + _need(_TYPE(origin) is tuple and _LEN(origin) == 7 and origin[0] is context, + 'V02 concrete authenticated issued input absent') + unused, binding, fd_identity, deadline, expected, expected_snapshot, retained = origin + _v02_preseal_binding_check(state,binding) + _need(state['v02_preflight_package_data'] is retained and + _TYPE(retained) is tuple and _LEN(retained) == 3, + 'V02 preseal retained package owner differs') + _need(_TYPE(fd_identity) is tuple and _LEN(fd_identity) == 3 and + all(_TYPE(x) is int and x >= 0 for x in fd_identity) and + stat.S_ISFIFO(fd_identity[2]) and _TYPE(deadline) is int and deadline > 0, + 'V02 protected fd/deadline shape differs') + _v02_plain(expected) + _need(_data(expected) == expected_snapshot, 'V02 protected frame expectation changed') + _exact(expected, ('schema','preparation','preflight_package','case_id','context_id','generation', + 'unit_id','mode','stage_sha256','command_sha256','endorsement')) + _need(expected['schema'] == 'h25-v02-preseal-parent-frame-v1' and + expected['unit_id'] == 'variant/V02/python-preflight-v1' and expected['mode'] == 'normal', + 'V02 preseal frame subject differs') + for key in ('case_id','context_id','generation'): + _need(_TYPE(expected[key]) is str and 0 < _LEN(expected[key]) <= 96 and + all(32 <= ord(c) < 127 for c in expected[key]), 'V02 bounded parent subject differs') + for key in ('stage_sha256','command_sha256'): + _digest(expected[key]) + for key in ('preparation','preflight_package','endorsement'): + _v02_pin_shape(expected[key],1048576 if key != 'preparation' else MAX_IMAGE) + _need(_v02_same(expected['preparation'],binding[0]) and + _v02_same(expected['preflight_package'],retained[0]), 'V02 preseal frame pin association differs') + entry,selection=binding[2],binding[4] + _need(_TYPE(entry) is dict and _TYPE(selection) is dict and + all(entry.get(key) == expected[key] for key in ('case_id','context_id','unit_id','mode')) and + all(selection.get(key) == expected[key] for key in ('unit_id','mode')), + 'V02 preseal original case/context differs') + # Adapt the existing installer/profile function-descriptor seal BEFORE IO. + # A local checker uses captured native descriptors; a replaced global + # checker alias cannot be invoked while discovering the replacement. + namespace0 = _FUNCTION_GETTERS[1](_receive_v02_preseal, types.FunctionType) + items0 = tuple(namespace0.items()) + functions0 = tuple(_function_record(value) for key,value in items0 + if _TYPE(value) is types.FunctionType) + imports0 = tuple((_MODULE_DICT(value, types.ModuleType), + tuple(_MODULE_DICT(value, types.ModuleType).items())) + for key,value in items0 if _TYPE(value) is types.ModuleType) + import_functions0 = tuple(_function_record(value) for namespace,items in imports0 + for key,value in items if _TYPE(value) is types.FunctionType) + type0,len0,zip0,error0 = _TYPE,_LEN,zip,RuntimeError + getters0,cellget0,ftype0,ctype0 = _FUNCTION_GETTERS,_CELL_GET,types.FunctionType,types.CellType + def source_recheck(include_import_functions=False): + if type0(namespace0) is not dict or len0(namespace0) != len0(items0): + raise error0('V02 preseal retained helper namespace changed') + for key in namespace0: + if type0(key) is not str: + raise error0('V02 preseal foreign helper namespace key') + for key,value in items0: + if namespace0[key] is not value: + raise error0('V02 preseal retained helper alias changed') + for namespace,items in imports0: + if len0(namespace) != len0(items): + raise error0('V02 preseal retained import namespace changed') + for key in namespace: + if type0(key) is not str: + raise error0('V02 preseal foreign import key') + for key,value in items: + if namespace[key] is not value: + raise error0('V02 preseal retained import alias changed') + records = functions0 + import_functions0 if include_import_functions else functions0 + for function,values,cells in records: + for getter,value in zip0(getters0,values): + if getter(function,ftype0) is not value: + raise error0('V02 preseal retained helper descriptor changed') + if len0(values[6]) != 0: + raise error0('V02 preseal retained helper dictionary changed') + for cell,value in cells: + if cellget0(cell,ctype0) is not value: + raise error0('V02 preseal retained helper cell changed') + source_recheck() + # Retain ownership before fstat/select/read; fd0 is borrowed and never closed. + io = {'fd':0, 'pending':None, 'reads':0, 'parts':[], 'frame':None, 'error':None} + state['v02_preseal_io']=io + select0,clock0=_v02_preseal_native_guard() + source_recheck() + io['pending']='fstat' + info=_FSTAT(0) + source_recheck() + io['pending']=None + _need((info.st_dev,info.st_ino,info.st_mode)==fd_identity, 'V02 inherited fd0 identity differs') + while io['reads'] < 32768: + _fresh(state) + _need(state['v02_protected_origin'] is origin and state['v02_preseal_io'] is io, + 'V02 protected ingress owner changed') + current_select,current_clock=_v02_preseal_native_guard() + source_recheck() + _need(current_select is select0 and current_clock is clock0, 'V02 preseal native identities changed') + tick=clock0() + source_recheck() + remaining=(deadline-tick)/1000000000 + _need(remaining>0, 'V02 preseal deadline before read') + io['pending']='select' + ready,unused,errors=select0([0],[],[0],remaining) + source_recheck() + io['pending']=None + _need(_TYPE(ready) is list and _LEN(ready)==1 and _TYPE(ready[0]) is int and ready[0]==0 and + _TYPE(errors) is list and not errors, 'V02 preseal deadline/read readiness') + io['pending']='read' + part=_READ(0,1) + source_recheck() + io['reads']+=1 + io['pending']=None + _need(_TYPE(part) is bytes and _LEN(part)==1, 'V02 original parent frame ended early') + if part == b'\n': + break + io['parts'].append(part) + else: + raise BindingStop('V02 bounded single original frame') + raw=b''.join(io['parts']);io['frame']=raw + source_recheck(True) + frame=_document(raw);_v02_plain(frame) + _need(json.dumps(frame,sort_keys=True,separators=(',',':')).encode('ascii') == raw and + _v02_same(frame,expected), 'V02 exact protected parent frame differs') + _v02_preseal_binding_check(state,binding) + _need(state['v02_protected_origin'] is origin and state['v02_preflight_package_data'] is retained and + _data(expected)==expected_snapshot and _data(retained[0])==retained[1], + 'V02 protected ingress changed during frame read') + package=_document(retained[2]);_v02_plain(package) + _exact(package,('schema','producer_subject','original_source','root_source','provider_source','decisions')) + decisions=package['decisions'] + _need(_TYPE(decisions) is list and _LEN(decisions)==8, 'V02 preseal eight decision records required') + for decision in decisions: + _exact(decision,('name','source','value')) + gates=tuple(decision['value'] for decision in decisions) + _fresh(state);_check_v02_driver_handoff(context) + current_select,current_clock=_v02_preseal_native_guard() + source_recheck() + tick=clock0() + source_recheck(True) + _need(current_select is select0 and current_clock is clock0 and tick < deadline, + 'V02 preseal deadline/identity before installation') + _v02_preseal_binding_check(state,binding) + _need(state['v02_protected_origin'] is origin and state['v02_preflight_package_data'] is retained and + state['v02_preseal_io'] is io and _data(expected)==expected_snapshot and + _data(retained[0])==retained[1], 'V02 protected ingress changed after final native call') + state['v02_pre_admitted_input']=(context,retained,package,gates,_data(package)) + return None + except BaseException as error: + if io is not None and io['error'] is None: + io['error']=error + # No helper callback on this error path: it may be the replaced helper. + if owner_primary[0] is None: owner_primary[0]=error + if local_primary[0] is None: local_primary[0]=error + quarantine[0]=True + state['phase']='STOP' + raise + + +def _construct_v02_issued_input(context): + """Prospective owning constructor; ordinary ingress has no admission issuer. + + The private record is never decoded from P/E or provided through a setter. + Tests may model it only as an explicitly inert pre-admitted owning seam. + Its absence remains the original refusal. Representation and source custody + checks below cannot confer the missing parent decisions or launch authority. + """ + state = _entry(context) + try: + _fresh(state) + _need(state['phase'] == 'PREPARED' and state['consumed'] is True and + state['v02_installing'] is True and state['v02_typed_attempted'] is False and + state['v02_issued_input'] is None and state['v02_attempted'] is False, + 'V02 typed construction is one-shot while PREPARED') + state['v02_typed_attempted'] = True + handoff = _check_v02_driver_handoff(context) + admission = state['v02_pre_admitted_input'] + _need(_TYPE(admission) is tuple and _LEN(admission) == 5 and admission[0] is context, + 'V02 concrete authenticated issued input absent') + retained = state['v02_preflight_package_data'] + _need(_TYPE(retained) is tuple and _LEN(retained) == 3 and admission[1] is retained, + 'V02 admission retained package owner differs') + pin, snapshot, raw = retained + _v02_pin_shape(pin, 1048576) + _need(_data(pin) == snapshot and _TYPE(raw) is bytes and _LEN(raw) == pin['bytes'] and + hashlib.sha256(raw).hexdigest() == pin['sha256'], 'V02 retained package custody differs') + package, gates, admitted_snapshot = admission[2:] + _v02_plain(package) + decoded = _document(raw) + _v02_plain(decoded) + _need(_v02_same(package, decoded) and _data(package) == admitted_snapshot, + 'V02 admitted package contents differ') + _exact(package, ('schema', 'producer_subject', 'original_source', 'root_source', 'provider_source', 'decisions')) + _need(package['schema'] == 'h25-v02-typed-package-v1', 'V02 typed package schema differs') + subject = package['producer_subject'] + _exact(subject, ('source_sha256', 'mode', 'presentation')) + _need(subject['source_sha256'] == _V02_ORIGINAL_SHA and subject['mode'] == 'normal' and + subject['presentation'] == 'nonconsuming-v02-omission', 'V02 early producer subject differs') + decisions = package['decisions'] + _need(_TYPE(decisions) is list and _LEN(decisions) == 8 and + _TYPE(gates) is tuple and _LEN(gates) == 8, 'V02 eight typed decisions required') + for index, name in enumerate(_V02_GATE_NAMES): + decision = decisions[index] + _exact(decision, ('name', 'source', 'value')) + _need(decision['name'] == name and decision['value'] is gates[index] and + gates[index] is not None, 'V02 genuine decision identity/order differs') + _v02_pin_shape(decision['source'], MAX_IMAGE) + _exact(gates[0], _V02_PRODUCER_KEYS) + for field, digest, limit in (('original_source', _V02_ORIGINAL_SHA, 131072), + ('root_source', _V02_ROOT_SHA, 262144), ('provider_source', _V02_PROVIDER_SHA, 262144)): + _v02_pin_shape(package[field], limit) + _need(package[field]['sha256'] == digest, 'V02 fixed source subject differs') + root, capability, api = handoff[4:7] + namespace = _namespace(root) + _need(namespace['__file__'] == package['root_source']['path'], 'V02 Root source path differs') + registry = _v02_mapping(namespace['_CAPABILITIES'], int)[0] + _need(_LEN(registry) == 1 and id(capability) in registry, 'V02 capability custody differs') + row = registry[id(capability)] + _need(_TYPE(row) is tuple and _LEN(row) == 7 and row[0] is capability, + 'V02 capability row custody differs') + provider = _namespace(row[1]) + _need(row[6] is provider and row[4] is provider['__file__'] and + provider['__file__'] == package['provider_source']['path'] and + _TYPE(row[3]) is str and row[3] == _V02_PROVIDER_SHA and + provider['_BOOTSTRAP_CAPABILITY'] is capability, 'V02 provider source custody differs') + metadata = _v02_mapping(namespace['_ROOT_METADATA'])[0] + _need(_TYPE(metadata.get('source_sha256')) is str and metadata['source_sha256'] == _V02_ROOT_SHA and + _TYPE(metadata.get('source_bytes')) is int and metadata['source_bytes'] == package['root_source']['bytes'], + 'V02 initialized Root source custody differs') + root_source = _read_pin(state, package['root_source'], 262144) + provider_source = _read_pin(state, package['provider_source'], 262144) + _need(_data(package) == admitted_snapshot and _data(pin) == snapshot, + 'V02 package changed during source custody read') + _need(state['v02_pre_admitted_input'] is admission and + state['v02_preflight_package_data'] is retained, + 'V02 retained admission changed during source custody read') + _need(all(package['decisions'][index]['value'] is gates[index] for index in range(8)), + 'V02 genuine decision identity changed during source custody read') + _check_v02_driver_handoff(context) + _fresh(state) + configuration = dict(schema='h25-live-preflight-context-v1', + unit_id='variant/V02/python-preflight-v1', original_source=package['original_source'], + bootstrap_root=root, bootstrap_capability=capability, bootstrap_api=api, + genuine_gate_values=gates) + state['v02_issued_input'] = (context, state['modules']['component_control_root_v1'], + configuration, root_source, provider_source) + return None + except BaseException as error: + _v02_stop(state, error) + raise + + +def _register_v02_live(context): + """Source-owned one-shot registration. No profile or configuration argument. + + The issued slot is deliberately None in this artifact; no public setter or + constructor turns caller assertions into authenticated input. A future + separately reviewed owning constructor must discharge concrete P/E first. + """ + state = _entry(context) + try: + _fresh(state) + _need(state['phase'] == 'PREPARED' and state['consumed'] is True and + state['v02_installing'] is True and + state['v02_attempted'] is False and state['v02_anchor'] is None, + 'V02 registration is one-shot while PREPARED') + state['v02_attempted'] = True # consume before any fallible capture + _check_v02_driver_handoff(context) + issued = state['v02_issued_input'] + _need(_TYPE(issued) is tuple and _LEN(issued) == 5 and issued[0] is context, + 'V02 concrete authenticated issued input absent') + unused, component, configuration, root_source, provider_source = issued + _need(state['modules']['component_control_root_v1'] is component, + 'V02 issued component owner differs') + selected = state['bindings']['component_control_root_v1']['CONTEXT_CONFIGURATION'] + _need(_TYPE(selected) is dict and _TYPE(selected.get('unit_id')) is str and + selected['unit_id'] == 'variant/V02/python-preflight-v1' and + selected.get('mode') == 'normal' and sys.flags.optimize == 0, + 'V02 original selected unit differs') + namespace = _namespace(component) + _need(namespace['PREFLIGHT_CONFIGURATION'] is None, 'V02 original None slot required') + _exact(configuration, _V02_CONFIG_KEYS) + handoff = _check_v02_driver_handoff(context) + _need(configuration['bootstrap_root'] is handoff[4] and + configuration['bootstrap_capability'] is handoff[5] and + configuration['bootstrap_api'] is handoff[6], + 'V02 issued live fields differ from retained driver handoff') + _need(_TYPE(configuration['schema']) is str and + configuration['schema'] == 'h25-live-preflight-context-v1' and + _TYPE(configuration['unit_id']) is str and + configuration['unit_id'] == 'variant/V02/python-preflight-v1', 'V02 fixed context required') + gates = configuration['genuine_gate_values'] + _need(_TYPE(gates) is tuple and _LEN(gates) == 8 and all(g is not None for g in gates), + 'V02 eight original gate references required') + gate_data = tuple(_data(g) for g in gates) + original_data = _data(configuration['original_source']) + rows = tuple(row for row in _INSTALLATIONS if row[0] is context) + _need(_LEN(rows) == 1 and rows[0][1] is state, 'V02 unique original token row required') + profile = _v02_capture_live_profile(configuration['bootstrap_root'], + configuration['bootstrap_capability'], configuration['bootstrap_api'], root_source, provider_source) + _fresh(state) + _need(state['phase'] == 'PREPARED', 'V02 capture reentry requires teardown') + binder_namespace = _FUNCTION_GETTERS[1](_register_v02_live, types.FunctionType) + binder_items = tuple(binder_namespace.items()) + binder_functions = tuple(_function_record(value) for key, value in binder_items + if _TYPE(value) is types.FunctionType and + _FUNCTION_GETTERS[1](value, types.FunctionType) is binder_namespace) + anchor = ('h25-v02-token-anchor-v1', context, rows[0], state, component, + configuration, tuple(configuration.items()), gates, gate_data, profile, + binder_namespace, binder_items, binder_functions, original_data) + state['v02_anchor'] = anchor + _need('PREFLIGHT_CONFIGURATION' not in state['bindings']['component_control_root_v1'], + 'V02 live gate cannot be supplied by literal binding plan') + state['bindings']['component_control_root_v1']['PREFLIGHT_CONFIGURATION'] = configuration + return None + except BaseException as error: + _v02_stop(state, error) + raise + + +def _v02_check_anchor(context, state, anchor, module, value): + try: + _fresh(state) + _check_v02_driver_handoff(context) + _need(state['v02_busy'] is False, 'V02 verification reentry requires teardown') + state['v02_busy'] = True + _need(_TYPE(anchor) is tuple and _LEN(anchor) == 14 and + state['v02_anchor'] is anchor and anchor[1] is context and anchor[3] is state, + 'V02 original immutable token anchor differs') + rows = tuple(row for row in _INSTALLATIONS if row[0] is context) + _need(_LEN(rows) == 1 and rows[0] is anchor[2] and rows[0][1] is state, + 'V02 original token registry row differs') + _need(module is anchor[4] and value is anchor[5] and + _namespace(module)['PREFLIGHT_CONFIGURATION'] is value, + 'V02 actual installed live configuration differs') + _exact(value, _V02_CONFIG_KEYS) + for key, expected in anchor[6]: + _need(value[key] is expected, 'V02 current installed field identity differs') + actual_gates = value['genuine_gate_values'] + _need(actual_gates is anchor[7] and _TYPE(actual_gates) is tuple and _LEN(actual_gates) == 8, + 'V02 original gate tuple differs') + for gate, expected in zip(actual_gates, anchor[8]): + _need(_data(gate) == expected, 'V02 genuine gate contents changed') + _need(_data(value['original_source']) == anchor[13], 'V02 original source pin changed') + # Pass actual current fields, never tautological anchor-owned arguments. + _v02_check_live_profile(anchor[9], value['bootstrap_root'], + value['bootstrap_capability'], value['bootstrap_api']) + _fresh(state) # a suppressed inner failure cannot restore success + _need(state['v02_busy'] is True, 'V02 verification state changed') + state['v02_busy'] = False + return None + except BaseException as error: + _v02_stop(state, error) + raise + + +def _capture_installed_gate(context, state, name, module, key, value): + if name == 'component_control_root_v1' and key == 'PREFLIGHT_CONFIGURATION': + anchor = state['v02_anchor'] + _v02_check_anchor(context, state, anchor, module, value) + return anchor + return _data(value) + + +def installed_gate_snapshot(context, name, module, key, value): + state = _entry(context) + _fresh(state) + _need(state['phase'] == 'SEALED', 'installed gate snapshot requires sealed token') + row = state['installed'][(name, key)] + _need(row[0] is module and row[1] is value, 'installed gate snapshot owner differs') + check_installed_gate(context, name, module, key, value, row[2]) + return row[2] + + +def check_installed_gate(context, name, module, key, value, snapshot): + state = _entry(context) + if name == 'component_control_root_v1' and key == 'PREFLIGHT_CONFIGURATION': + _v02_check_anchor(context, state, snapshot, module, value) + return None + _need(_namespace(module)[key] is value and _data(value) == snapshot, + 'installed gate identity/content changed') + return None + + +"""Inert reusable candidate for pinned CPython 3.12 code-source comparison. + +The caller authenticates this module/native owners and supplies independently +compiled source-role-aligned roots. This does not issue authority. One call +compares one module's whole matched forest; do not reset aliases per function. +Adaptation of cache_contract_v8._constant_equal/_code_equal exact-type discipline, +with native metadata coverage, finite floats/sets, bounds and forest aliases. +""" +import marshal +import types + +_code_oracle_TYPE = type +_code_oracle_LEN = len +_code_oracle_ID = id +_code_oracle_GET = object.__getattribute__ +_code_oracle_CODE = types.CodeType +_code_oracle_DUMPS = marshal.dumps +_code_oracle_BIT_LENGTH = int.bit_length +_code_oracle_LOCAL_NAME = types.CodeType.__dict__['_varname_from_oparg'] +_code_oracle_INDEX_ERROR = IndexError + +_code_oracle_MAX_ROOTS = 1024 +_code_oracle_MAX_VISITS = 100000 +_code_oracle_MAX_DEPTH = 64 +_code_oracle_MAX_CONTAINER = 8192 +_code_oracle_MAX_ATOM_LENGTH = 1048576 +_code_oracle_MAX_INT_BITS = 4096 +_code_oracle_MAX_SERIALIZED_BOUND = 8 * 1024 * 1024 + +_code_oracle_INTEGER_FIELDS = ('co_argcount', 'co_posonlyargcount', 'co_kwonlyargcount', + 'co_nlocals', 'co_stacksize', 'co_flags', 'co_firstlineno') +_code_oracle_BYTES_FIELDS = ('co_code', 'co_linetable', 'co_exceptiontable') +_code_oracle_TEXT_FIELDS = ('co_filename', 'co_name', 'co_qualname') +_code_oracle_NAMES_FIELDS = ('co_names', 'co_varnames', 'co_cellvars', 'co_freevars') + + +class _code_oracle_CodeOracleStop(RuntimeError): + pass + + +def _code_oracle_need(condition, reason): + if not condition: + raise _code_oracle_CodeOracleStop(reason) + + +def _code_oracle_code_children(code): + """Only exact CodeType/native descriptors; no candidate lookup callbacks.""" + children = [] + for field in _code_oracle_INTEGER_FIELDS: + value = _code_oracle_GET(code, field) + _code_oracle_need(_code_oracle_TYPE(value) is int and 0 <= value <= 0x7fffffff, + 'code integer metadata type/range') + children.append(value) + for field in _code_oracle_BYTES_FIELDS: + value = _code_oracle_GET(code, field) + _code_oracle_need(_code_oracle_TYPE(value) is bytes, 'code byte metadata type') + children.append(value) + for field in _code_oracle_TEXT_FIELDS: + value = _code_oracle_GET(code, field) + _code_oracle_need(_code_oracle_TYPE(value) is str, 'code text metadata type') + children.append(value) + for field in _code_oracle_NAMES_FIELDS: + value = _code_oracle_GET(code, field) + _code_oracle_need(_code_oracle_TYPE(value) is tuple and _code_oracle_LEN(value) <= _code_oracle_MAX_CONTAINER, + 'code names metadata shape') + for name in value: + _code_oracle_need(_code_oracle_TYPE(name) is str, 'code name exact text type') + children.append(value) + constants = _code_oracle_GET(code, 'co_consts') + _code_oracle_need(_code_oracle_TYPE(constants) is tuple, 'code constants exact tuple') + children.append(constants) + # Public name tuples omit hidden-only localsplus entries. Enumerate the + # pinned native backing tuple before marshal so its size cannot evade the + # allocation bound. The native descriptor uses PyTuple_GetItem, not Python + # indexing hooks. The same count bounds the internal kinds byte array. + local_names = [] + for index in range(_code_oracle_MAX_CONTAINER + 1): + try: + name = _code_oracle_LOCAL_NAME(code, index) + except _code_oracle_INDEX_ERROR: + break + _code_oracle_need(index < _code_oracle_MAX_CONTAINER and _code_oracle_TYPE(name) is str, + 'internal local name count/type') + local_names.append(name) + children.append(tuple(local_names)) + return tuple(children), _code_oracle_LEN(local_names) + + +def _code_oracle_preflight(roots): + """Iterative expanded walk; all exact types/bounds precede any marshal. + + Walk shared subgraphs again to bound format-2's actual expansion, rather + than merely bounding unique nodes in a potentially exponential DAG. + """ + _code_oracle_need(_code_oracle_TYPE(roots) is tuple and 1 <= _code_oracle_LEN(roots) <= _code_oracle_MAX_ROOTS, + 'exact nonempty bounded root tuple') + for root in roots: + _code_oracle_need(_code_oracle_TYPE(root) is _code_oracle_CODE, 'exact code root required') + stack = [(0, root, 0) for root in reversed(roots)] + active = set() + visits = 0 + bound = 0 + peak_depth = 0 + local_slots = 0 + while stack: + exiting, value, depth = stack.pop() + if exiting: + active.remove(_code_oracle_ID(value)) + continue + visits += 1 + _code_oracle_need(visits <= _code_oracle_MAX_VISITS and depth <= _code_oracle_MAX_DEPTH, + 'expanded graph visit/depth bound') + peak_depth = max(peak_depth, depth) + kind = _code_oracle_TYPE(value) + children = None + if value is None or value is Ellipsis: + bound += 1 + elif kind is bool: + bound += 1 + elif kind is int: + bits = _code_oracle_BIT_LENGTH(value) + _code_oracle_need(bits <= _code_oracle_MAX_INT_BITS, 'integer bit bound') + bound += 8 + 2 * ((bits + 14) // 15) + elif kind is float: + # Exact floats only: finite x-x is zero, infinities/NaNs produce + # NaN and fail. No added math-module/native-owner dependency. + _code_oracle_need(value - value == 0.0, 'nonfinite float constant') + bound += 9 + elif kind is str: + _code_oracle_need(_code_oracle_LEN(value) <= _code_oracle_MAX_ATOM_LENGTH, 'text length bound') + bound += 5 + 4 * _code_oracle_LEN(value) + elif kind is bytes: + _code_oracle_need(_code_oracle_LEN(value) <= _code_oracle_MAX_ATOM_LENGTH, 'bytes length bound') + bound += 5 + _code_oracle_LEN(value) + elif kind is tuple or kind is frozenset: + _code_oracle_need(_code_oracle_LEN(value) <= _code_oracle_MAX_CONTAINER, 'container width bound') + if kind is frozenset: + for item in value: + _code_oracle_need(_code_oracle_TYPE(item) is str or _code_oracle_TYPE(item) is int, + 'frozenset restricted exact scalar members') + bound += 5 + children = value + elif kind is _code_oracle_CODE: + children, count = _code_oracle_code_children(value) + local_slots += count + # More than native fixed header/kinds overhead; public name tuples + # plus the native-name enumeration conservatively duplicate names. + bound += 128 + count + else: + raise _code_oracle_CodeOracleStop('unsupported exact graph type') + _code_oracle_need(bound <= _code_oracle_MAX_SERIALIZED_BOUND, 'expanded serialized-size bound') + if children is not None: + identity = _code_oracle_ID(value) + _code_oracle_need(identity not in active, 'cyclic code constant graph') + _code_oracle_need(_code_oracle_LEN(stack) + _code_oracle_LEN(children) + 1 <= 2 * _code_oracle_MAX_VISITS, + 'pending graph work bound') + active.add(identity) + stack.append((1, value, depth)) + # Each admitted container is bounded before materializing its + # native iterator. No foreign iterable reaches this branch. + for child in children: + stack.append((0, child, depth + 1)) + _code_oracle_need(_code_oracle_LEN(stack) <= 2 * _code_oracle_MAX_VISITS, 'pending graph work bound') + return visits, bound, peak_depth, local_slots + + +def _code_oracle_code_alias_children(code): + # These include the stable cached var/cell/free tuple views materialized + # on both sides during preflight. Their aliases with constants and other + # code roots are observable. Integer descriptors are value fields instead. + result = [_code_oracle_GET(code, field) for field in ( + 'co_code', 'co_consts', 'co_names', 'co_filename', 'co_name', + 'co_qualname', 'co_linetable', 'co_exceptiontable', + 'co_varnames', 'co_cellvars', 'co_freevars')] + for index in range(_code_oracle_MAX_CONTAINER + 1): + try: + name = _code_oracle_LOCAL_NAME(code, index) + except _code_oracle_INDEX_ERROR: + break + _code_oracle_need(index < _code_oracle_MAX_CONTAINER, 'alias internal local bound') + result.append(name) + return tuple(result) + + +def _code_oracle_aliases(actual_roots, expected_roots): + """Reciprocal constant/code graph aliases across all roots in this call.""" + actual_to_expected = {} + expected_to_actual = {} + pending = list(zip(actual_roots, expected_roots)) + visits = 0 + while pending: + actual, expected = pending.pop() + visits += 1 + _code_oracle_need(visits <= _code_oracle_MAX_VISITS, 'alias graph visit bound') + kind = _code_oracle_TYPE(actual) + _code_oracle_need(kind is _code_oracle_TYPE(expected), 'constant exact type differs') + ai, ei = _code_oracle_ID(actual), _code_oracle_ID(expected) + previous_a = expected_to_actual.get(ei) + previous_e = actual_to_expected.get(ai) + if previous_a is not None or previous_e is not None: + _code_oracle_need(previous_a == ai and previous_e == ei, + 'constant/code graph alias split or merge') + continue + expected_to_actual[ei] = ai + actual_to_expected[ai] = ei + if kind is _code_oracle_CODE: + a = _code_oracle_code_alias_children(actual) + e = _code_oracle_code_alias_children(expected) + _code_oracle_need(_code_oracle_LEN(a) == _code_oracle_LEN(e), 'code alias field arity differs') + pending.extend(zip(a, e)) + elif kind is tuple: + _code_oracle_need(_code_oracle_LEN(actual) == _code_oracle_LEN(expected), 'tuple arity differs') + pending.extend(zip(actual, expected)) + elif kind is frozenset: + _code_oracle_need(_code_oracle_LEN(actual) == _code_oracle_LEN(expected), 'frozenset arity differs') + # Complete forest preflight already proved exact str/int members + # and bounded lengths/bits. Native format-2 encodings distinguish + # these types/values and supply deterministic ordering without + # candidate comparisons or iteration callbacks. + a = sorted(actual, key=_code_oracle_scalar_key) + e = sorted(expected, key=_code_oracle_scalar_key) + pending.extend(zip(a, e)) + return visits, _code_oracle_LEN(actual_to_expected) + + +def _code_oracle_scalar_key(value): + return _code_oracle_DUMPS(value, 2) + + +def _code_oracle_compare_code_forest(actual_roots, expected_roots): + """Compare one module's source-aligned exact CodeType forest, or STOP. + + Repeated roots are allowed and their aliases are checked. Roots are never + selected by actual names, and no candidate callback or equality is used. + Return immutable diagnostics, not an authority token: + (root_count, actual_preflight, expected_preflight, + alias_visits, alias_nodes, actual_serialized_bytes, expected_bytes). + Preflight tuples are (expanded_visits, byte_upper_bound, depth, local_slots). + """ + expected_counts = _code_oracle_preflight(expected_roots) + actual_counts = _code_oracle_preflight(actual_roots) + _code_oracle_need(_code_oracle_LEN(actual_roots) == _code_oracle_LEN(expected_roots), 'source root cardinality differs') + alias_visits, alias_nodes = _code_oracle_aliases(actual_roots, expected_roots) + actual_bytes = expected_bytes = 0 + for actual, expected in zip(actual_roots, expected_roots): + a = _code_oracle_DUMPS(actual, 2) + e = _code_oracle_DUMPS(expected, 2) + actual_bytes += _code_oracle_LEN(a) + expected_bytes += _code_oracle_LEN(e) + _code_oracle_need(actual_bytes <= actual_counts[1] and expected_bytes <= expected_counts[1], + 'native serialization exceeds preflight upper bound') + _code_oracle_need(a == e, 'native code metadata or constant value differs') + return (_code_oracle_LEN(actual_roots), actual_counts, expected_counts, + alias_visits, alias_nodes, actual_bytes, expected_bytes) + + +# Captured once by authenticated source before entry; no caller setter. +_CODE_ORACLE_STARTUP_NAMES = ('_code_oracle_TYPE', '_code_oracle_LEN', '_code_oracle_ID', '_code_oracle_GET', '_code_oracle_CODE', '_code_oracle_DUMPS', '_code_oracle_BIT_LENGTH', '_code_oracle_LOCAL_NAME', '_code_oracle_INDEX_ERROR', '_code_oracle_MAX_ROOTS', '_code_oracle_MAX_VISITS', '_code_oracle_MAX_DEPTH', '_code_oracle_MAX_CONTAINER', '_code_oracle_MAX_ATOM_LENGTH', '_code_oracle_MAX_INT_BITS', '_code_oracle_MAX_SERIALIZED_BOUND', '_code_oracle_INTEGER_FIELDS', '_code_oracle_BYTES_FIELDS', '_code_oracle_TEXT_FIELDS', '_code_oracle_NAMES_FIELDS', '_code_oracle_CodeOracleStop', '_code_oracle_need', '_code_oracle_code_children', '_code_oracle_preflight', '_code_oracle_code_alias_children', '_code_oracle_aliases', '_code_oracle_scalar_key', '_code_oracle_compare_code_forest', 'marshal', 'types', 'builtins', '_TYPE', '_LEN', '_FUNCTION_GETTERS', '_CELL_GET', '_MODULE_DICT', '_CLASS_DICT', '_CODE_ORACLE_MRO_GET') +_CODE_ORACLE_NAMESPACE = globals() +_CODE_ORACLE_BUILTINS = _MODULE_DICT(builtins, types.ModuleType) +_CODE_ORACLE_BUILTIN_ITEMS = tuple(_CODE_ORACLE_BUILTINS.items()) +_CODE_ORACLE_MRO_GET = type.__dict__['__mro__'].__get__ +_CODE_ORACLE_STARTUP_SEAL = tuple((name, globals()[name], + _function_record(globals()[name]) if _TYPE(globals()[name]) is types.FunctionType else None) + for name in _CODE_ORACLE_STARTUP_NAMES) +_CODE_ORACLE_CLASS_SEAL = tuple((value, tuple(_CLASS_DICT(value, type).items()), + _CODE_ORACLE_MRO_GET(value, type)) for name, value, record in _CODE_ORACLE_STARTUP_SEAL if _TYPE(value) is type) From e74e6664479d16d69a0a50e2b2503ae56196d8ec Mon Sep 17 00:00:00 2001 From: Clear1nsight <22630354+Clear1nsight@users.noreply.github.com> Date: Wed, 11 Nov 2026 14:22:27 +1100 Subject: [PATCH 2/3] Reuse #7147 selected replay navigation for onboarding This is the exact documentation prerequisite retained by #7156. It points the onboarding check to the selected #7000/#7001 review. Credit to Rohan Arun and the source authors. (cherry picked from commit bb36fc65ee0b161229169505f4840c436c5ca2b9) --- docs/ci-verification.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/ci-verification.md b/docs/ci-verification.md index 63ba3e9aa8..52b62d0481 100644 --- a/docs/ci-verification.md +++ b/docs/ci-verification.md @@ -1,8 +1,25 @@ # CI verification -## Current selected-family replay: #6030 +## Current selected-family replay: #7000 with #7001 The [selected record](../certificates/selected-result.json) binds conditional +κ = 0.00363005817 to the [application review](research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md), +[validation receipts](research/pr-intake-evidence/pr7000-application/VALIDATION.json), +and [explicit source closure](../certificates/frontier7000-source.json). +`make frontier7000-verify` follows that exact-source selected replay. The review +reuses eleven authenticated preceding executions and records seven fresh serial +application, scalar and complete native-catalogue executions. The earlier +monolithic timeout is retained separately and is not completed coverage. +Consult the receipts for exact commands, source heads and limits. + +The five inherited framework assumptions remain. No complete uniform word, +literal multiplier execution, independent human proof or formal-kernel proof +is asserted. Routine research submissions do not need to rerun this +selected-family replay. The sections below preserve historical checkpoints. + +## Historical selected-family replay: #6030 + +The [historical checkpoint](../certificates/checkpoints/frontier6030.json) binds conditional κ = 0.003125804 to the [proof review](research/pr-intake-evidence/pr6030-audit/PROOF-REVIEW.md), [validation receipts](research/pr-intake-evidence/pr6030-audit/VALIDATION.json), and [explicit source closure](../certificates/frontier6030-source.json). From b5587eef1dd66d477a2e4d7b6f83616e07a01386 Mon Sep 17 00:00:00 2001 From: Clear1nsight <22630354+Clear1nsight@users.noreply.github.com> Date: Wed, 11 Nov 2026 21:53:51 +1100 Subject: [PATCH 3/3] Replay the historical selected check at its inspected commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PR #6292 rejection census and package plan are statements about 2485805. Load its exact sources and planner in a private sparse checkout, keeping all source hashes, 19 expected rejections, nine package selections and the empty-plan control. Subsequent edits to the live Makefile and CI guide no longer invalidate this historical check. The original audit is by unpaidmoon, building on Dennis’s historical replay gate. The pinned repository view follows the precedent of Matarener’s PR #5434. Repair prepared with substantial OpenAI Codex assistance. (cherry picked from commit d2e54af81f9dda6487636b79d4964a2385d89b2b) --- .../historical-selected-replay-gap/README.md | 6 +- .../SOURCES.json | 60 +++++++++--------- .../VERIFY.json | 31 +-------- .../historical-selected-replay-gap/verify.py | 63 ++++++++++++++----- 4 files changed, 82 insertions(+), 78 deletions(-) diff --git a/research/historical-selected-replay-gap/README.md b/research/historical-selected-replay-gap/README.md index 55d8cc3b49..36d9a873ca 100644 --- a/research/historical-selected-replay-gap/README.md +++ b/research/historical-selected-replay-gap/README.md @@ -69,7 +69,11 @@ python3 -B scripts/research_package.py --package research/historical-selected-re The direct command prints `PASS_HISTORICAL_SELECTED_REPLAY_GAP`. A registered replay prints `PASS_REGISTERED_RESEARCH_PACKAGE`. Both require Git history -containing the two inspected commits. +containing the two inspected commits and the source and manifest objects at +`2485805a6d47f36ea83ddde6327d453ac82d44dc`. The verifier uses a temporary +sparse checkout of that commit, checks the declared source digests there, and +uses its planner and manifest inventory. The recorded rejections and selection +therefore remain reproducible after later changes to the live Makefile or CI guide. ## Open next questions diff --git a/research/historical-selected-replay-gap/SOURCES.json b/research/historical-selected-replay-gap/SOURCES.json index c1010eec95..62bb8b3950 100644 --- a/research/historical-selected-replay-gap/SOURCES.json +++ b/research/historical-selected-replay-gap/SOURCES.json @@ -4,13 +4,13 @@ "files": [ { "path": "Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "0d683a06b9e7ee162496108ce9a7c5d2ee94fccf", "sha256": "4f2d4f2dcd15139ec82658a975f85ed300897385f85799218539f4c8d60567da" }, { "path": "certificates/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "eccafa830c16170c36faf93045ddf1f638f7bcd4", "sha256": "4c0b9d37e1034b2076e30a70f8e514416298c462d9ee98bc87fe6556b14df786" }, @@ -22,7 +22,7 @@ }, { "path": "docs/ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "63ba3e9aa8bdc5e942b56e34244b92b16f854085", "sha256": "c7d3027e9ad8bcbff68f07aa9576b30fb2f3c76c44d876d40c7fdbf4a3e2228a" }, @@ -34,163 +34,163 @@ }, { "path": "research/clifford-state-performance/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "6f98a0061a5104dfab82c9e806f819b41811f684", "sha256": "396d0f08df24952248140d5c65c51b8c902ef1c580892ff7ea182890530f67ee" }, { "path": "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "5e0f92af463ec12c5e1dcc3effd44081a88af647", "sha256": "07a9daeaf2bda308a92e9a4684f13d5fc766c7772d74801fceb7f4599fdab226" }, { "path": "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "9e13266bf85e627f1b7dc225e9530ea69fd2c7f0", "sha256": "421e1211fb1897c45621dc6801c276e53f2e6f335583c9c9049e535f87c0a3b1" }, { "path": "research/community-batch932-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "cc4d03eb59b9ab3f952735f7e88ff18c2d15d7af", "sha256": "184629cac91a5cfaca50330a88596008b824221433867dcf8117539c913c284a" }, { "path": "research/community-batch970-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8b9f4111badf7de5d97684799560b55110e9da79", "sha256": "23188ed920e38a54006cb883e181585620821c63bf7e8b5e05d32719417cc37e" }, { "path": "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "a5300d4e7a5381a3f443fc54c768ca6f0f236d68", "sha256": "3c820fb30e1b4d9bcfc6a7ab524375e5b2abd66b940af2c509146104f0bcd79c" }, { "path": "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "d7ff6d777b01d69b6ce84caf25d3b7e4a4d2f211", "sha256": "6b185a9902652f893f3ebd8ada92d2f11b6de6533a9a4d11718a8a4496101128" }, { "path": "research/community-hyperplane599-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "546f37d326d10a99910ae8f908e71ef768524d98", "sha256": "65099d764bfcc39bda5e4d9966783611b094c3522dbdd1435cd498d657a8ef8e" }, { "path": "research/community-k492-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "e538481e4cb16ed936d3195f2dfb5b5a9ca0a76b", "sha256": "2c0f4fa5bc150d05658af2e7c54c4d2c337dd52b7efd3d69530ae73bcbdf452a" }, { "path": "research/community-reconciliation92-audit/MANIFEST.json", - "usage": "input", + "usage": "provenance", "git_blob": "2a2e93685173d5f13cbb5abe740f5d90352e0228", "sha256": "5f501f3c118131e7d069f30ad77186eb2ad6961f9680a0ef105f4514ed41808a" }, { "path": "research/partial-swap-digest/baseline.py", - "usage": "input", + "usage": "provenance", "git_blob": "a2f0190704db83bd8ef48e46e723c49b925804fe", "sha256": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34" }, { "path": "research/r420-two-sided-basis/SOURCES.json", - "usage": "input", + "usage": "provenance", "git_blob": "5d718e11e62f4bcadecf1e02d6b61f87dbe190b0", "sha256": "d9810b0d139c5a1211fd2c1f0d142187cc1fca30026e1e7bc4f9ecfacf1596d1" }, { "path": "research/skip-clones/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8d1bb3b9c8189e35e5d8bfdfa632d7473e8be0d5", "sha256": "0b68e63e35a97ce6b0cdb6e291b88ebaa8f2dd4afb70b2498f10ee89428258dc" }, { "path": "research/split-skip/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "2ab610b6ea2edd2865fda793ef2168b0c76afb4f", "sha256": "7c2b4646a3ecfef6f881da5c43e4bd0fa9a4d1b00548b8ab458d897e16735134" }, { "path": "scripts/historical-ci-inputs/Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "aff68409021c9d401a6f8013b9dfd7dbcc30f2a8", "sha256": "ea8830dd79da493e2d75baf753d733ff7efbcf2b4794afe41fae0ac8f3055646" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "65db599ab0b1dea0312c4ca048e0bd0f44c3736f", "sha256": "96ea543e6c707424afe247e77bd86c82152f90fc76a0773c4232145da5cdf8d1" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "34820a8f24678f918f4d0e7a35380d8013fc3495", "sha256": "628391b6abfbc8674ceec1751867a4392f2cc0b5b66886243e139af86cf355ac" }, { "path": "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "c755b76e0d44ba4917aa94440ebe54daefce5b2a", "sha256": "d7fd929726b326aeeaf0a3996475adec88eee9aac09ae0bebeeaa0bc1fc8f199" }, { "path": "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "7f3c012504187917a728b9fe87043f0fc8cd006a", "sha256": "a854022e0e1d5d4db4d60e586be3ea56005013ef14a1fc06d02bc06e8529c4b0" }, { "path": "scripts/historical-ci-inputs/partial-swap-context.json", - "usage": "input", + "usage": "provenance", "git_blob": "ad65114886bf34a4fd27e79f3be502389e689faa", "sha256": "833a9642f33aeab2ffea17ec9c6b82e0a953f90192b2c82e10bef21538dccba9" }, { "path": "scripts/historical-ci-inputs/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "52075f2463f60af5e16571347f24274fce73a1ea", "sha256": "f3c4be597b2f2136da4ae2cc80c7454f63c90aa01f84e5b8131cee4dd55de815" }, { "path": "scripts/partial_swap/shared.py", - "usage": "input", + "usage": "provenance", "git_blob": "44a0e454c70f9c4b98e258b8443612e6a119904b", "sha256": "5a0646a50b9f3e8ea55168620a78e8853b0ab810517cefc8cfb8696aedee278a" }, { "path": "scripts/replay_historical_check.py", - "usage": "input", + "usage": "provenance", "git_blob": "1e92fff2782970ef71378f594f2350d245a4db26", "sha256": "5467619c78183d3adc82b0cb55af28e5c1a01fca2b0588677816244b53e2bafd" }, { "path": "scripts/research_package.py", - "usage": "input", + "usage": "provenance", "git_blob": "091b4c8f58bac9a9580d76025b887dc5c873d05f", "sha256": "e1256016e7f51827d04fa2179255989f639ae1d97afaa9c16265f85a0c6abd70" }, { "path": "scripts/run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "a96ab35b315ce492e7fbbfd6c5ae211aa066b541", "sha256": "49eb56dd0fc0d8d8ffdb209970a7adf2176223580646f575d5c22e59543b381c" }, { "path": "scripts/verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "6882a4700e410dec569b51ae2eaf1a19cc019195", "sha256": "d6b305eac5b9bdb8172c469ad30a1655a60fa0aceac8b1bf610e1b73f51babd8" }, { "path": "tests/test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "343b24abf6719b81805eba5a84c74e57634c8288", "sha256": "3a5470d0b139828b90e19bf9583ddeafcd69f8e34f2824664eb3a2958a52e34d" } diff --git a/research/historical-selected-replay-gap/VERIFY.json b/research/historical-selected-replay-gap/VERIFY.json index 98553e72ed..ab7efa3471 100644 --- a/research/historical-selected-replay-gap/VERIFY.json +++ b/research/historical-selected-replay-gap/VERIFY.json @@ -4,36 +4,7 @@ "python": "3.12", "requirements": [], "inputs": [ - "Makefile", - "certificates/partial-swap-network.json", - "docs/ci-verification.md", - "research/clifford-state-performance/SOURCE.json", - "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "research/community-batch932-audit/CONTENT-COVERAGE.json", - "research/community-batch970-audit/CONTENT-COVERAGE.json", - "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "research/community-hyperplane599-audit/SOURCE.json", - "research/community-k492-audit/SOURCE.json", - "research/community-reconciliation92-audit/MANIFEST.json", - "research/partial-swap-digest/baseline.py", - "research/r420-two-sided-basis/SOURCES.json", - "research/skip-clones/SOURCE.json", - "research/split-skip/SOURCE.json", - "scripts/historical-ci-inputs/Makefile", - "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "scripts/historical-ci-inputs/partial-swap-context.json", - "scripts/historical-ci-inputs/partial-swap-network.json", - "scripts/partial_swap/shared.py", - "scripts/replay_historical_check.py", - "scripts/research_package.py", - "scripts/run_isolated_tests.py", - "scripts/verify_selected_result.py", - "tests/test_isolated_test_runner.py" + "scripts/research_package.py" ], "commands": [ { diff --git a/research/historical-selected-replay-gap/verify.py b/research/historical-selected-replay-gap/verify.py index 83b995941a..9d266c5a4e 100644 --- a/research/historical-selected-replay-gap/verify.py +++ b/research/historical-selected-replay-gap/verify.py @@ -6,8 +6,10 @@ """ import hashlib import importlib.util +import json import subprocess import sys +import tempfile from pathlib import Path ROOT = Path(__file__).resolve().parents[2] @@ -61,31 +63,47 @@ def require(ok, message): raise SystemExit(message) -def load_checker(): - path = ROOT / "scripts/replay_historical_check.py" - spec = importlib.util.spec_from_file_location("historical_selected_replay_gap_checker", path) +def load_module(path): + spec = importlib.util.spec_from_file_location(path.stem, path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module +def checkout_snapshot(snapshot, sources, runner, env): + paths = [runner.canonical_relative_path(row["path"]) for row in sources["files"]] + git = ["git", "-c", "maintenance.auto=false", "-c", "gc.auto=0", + "-c", "core.autocrlf=false"] + subprocess.run([*git, "clone", "--quiet", "--shared", "--no-tags", "--no-checkout", + "--", str(ROOT), str(snapshot)], cwd=ROOT, env=env, check=True) + subprocess.run([*git, "update-ref", "--no-deref", "HEAD", INSPECTED], + cwd=snapshot, env=env, check=True) + # The pinned planner reads omitted manifests from the sparse HEAD/index. + patterns = "".join(f"/{path.as_posix()}\n" for path in paths) + subprocess.run([*git, "sparse-checkout", "set", "--no-cone", "--stdin"], + cwd=snapshot, env=env, input=patterns.encode("utf-8"), check=True) + subprocess.run([*git, "read-tree", "-mu", "HEAD"], cwd=snapshot, env=env, check=True) + for path, row in zip(paths, sources["files"], strict=True): + require(hashlib.sha256((snapshot / path).read_bytes()).hexdigest() == row["sha256"], + "historical checkout source digest changed: " + path.as_posix()) + + def entries(checker): for name, config in checker.CONFIG.items(): for entry in [config, *config.get("additional_inputs", [])]: yield name, entry -def reject(checker, entry): +def reject(root, checker, entry): try: - checker.authenticated_input(ROOT, entry) + checker.authenticated_input(root, entry) except ValueError as exc: return str(exc) raise SystemExit("historical input was admitted: " + entry["path"]) -def main(): - require(not sys.flags.optimize, "assertions must stay enabled") - checker = load_checker() +def check_snapshot(root, env): + checker = load_module(root / "scripts/replay_historical_check.py") selected = [entry for name, entry in entries(checker) if name == "tooling-ledger" and entry["path"] == SELECTED_PATH] require(len(selected) == 1, "selected-result checker overlay is not unique") @@ -94,7 +112,7 @@ def main(): require(entry["accepted_live_sha256"] == [SELECTED_ACCEPTED], "accepted selected-checker successors changed") frozen = (checker.INPUTS / entry["input"]).read_bytes() - live = (ROOT / SELECTED_PATH).read_bytes() + live = (root / SELECTED_PATH).read_bytes() require(hashlib.sha256(frozen).hexdigest() == SELECTED_PIN, "frozen selected checker bytes changed") require(hashlib.sha256(live).hexdigest() == SELECTED_LIVE, "live selected checker digest changed") require(SELECTED_LIVE not in (SELECTED_PIN, SELECTED_ACCEPTED), "live checker was already admitted") @@ -102,7 +120,7 @@ def main(): # live successor, not a broken comparison. require(SELECTED_PIN in (SELECTED_PIN, *entry["accepted_live_sha256"]), "pin membership control failed") - require(reject(checker, entry) == REJECTIONS[SELECTED_PATH][1], + require(reject(root, checker, entry) == REJECTIONS[SELECTED_PATH][1], "selected checker rejection text changed") counts = {path: 0 for path in REJECTIONS} @@ -110,7 +128,7 @@ def main(): for _name, item in entries(checker): if item["path"] not in REJECTIONS: continue - message = reject(checker, item) + message = reject(root, checker, item) counts[item["path"]] += 1 messages.setdefault(item["path"], message) for path, (count, message) in REJECTIONS.items(): @@ -118,20 +136,31 @@ def main(): require(messages[path] == message, "rejection text changed for " + path) require(sum(counts.values()) == 19, "rejection total changed") ci = [item for _name, item in entries(checker) if item["path"] == CI_PATH] - require(len(ci) == 1 and hashlib.sha256((ROOT / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, + require(len(ci) == 1 and hashlib.sha256((root / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, "selected CI note digest changed") diff = subprocess.check_output( - ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=ROOT, text=True) + ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=root, env=env, text=True) changed = sorted(name for name in diff.splitlines() if name) require(changed == CHANGED, "inspected commit diff changed") - sys.path.insert(0, str(ROOT / "scripts")) - from research_package import plan_details - details = plan_details(ROOT, set(changed)) + planner = load_module(root / "scripts/research_package.py") + details = planner.plan_details(root, set(changed)) require([row["package"] for row in details] == PLAN_PACKAGES, "helper plan selection changed") matched = {name for row in details for names in row["causes"].values() for name in names} require(sorted(set(changed) - matched) == UNMATCHED, "unmatched plan paths changed") - require(plan_details(ROOT, set()) == [], "empty change set selected a package") + require(planner.plan_details(root, set()) == [], "empty change set selected a package") + + +def main(): + require(not sys.flags.optimize, "assertions must stay enabled") + sources = json.loads(Path(__file__).with_name("SOURCES.json").read_bytes()) + require(sources["base_commit"] == INSPECTED, "historical checkout base changed") + runner = load_module(ROOT / "scripts/research_package.py") + env = runner.git_source_env() + with tempfile.TemporaryDirectory(prefix="historical-selected-replay-") as temporary: + snapshot = Path(temporary) / "snapshot" + checkout_snapshot(snapshot, sources, runner, env) + check_snapshot(snapshot, env) print("PASS_HISTORICAL_SELECTED_REPLAY_GAP") print("selected_checker_live=" + SELECTED_LIVE) print("rejections=19 distinct_paths=7 plan_packages=9")