diff --git a/research/p104-free-endpoint-contract-audit/PROOF.md b/research/p104-free-endpoint-contract-audit/PROOF.md new file mode 100644 index 0000000000..bee55f26aa --- /dev/null +++ b/research/p104-free-endpoint-contract-audit/PROOF.md @@ -0,0 +1,53 @@ +# Why free helper endpoints are the audited P104 contract + +## Setting +A P104 local word has 735 public registers: 104 X sources r, 104 Y targets r+112, and 527 helpers. +Frames are subspaces F of F_2^9 with native charts T_F. Each helper h has an initial frame A_h and a +final frame B_h with A_h ⊂ B_h. A MOVE F → G applies T_G T_F⁻¹ and is paid at rank dim G − dim F. An +ADD/COPY/SCALE requires its registers to sit in one common frame. + +## Lemma 1 (chart invariant) +Let x_k be the independent inputs. If every register r starts with physical content T_{A_r}(x_r), then +after every event its physical content is T_{cur(r)}(row_r · x). Here row_r is the exact rational row +replayed by `local.replay`. + +*Proof.* MOVE: T_G T_F⁻¹ T_F(v) = T_G(v). Same-chart ADD: T_f(u) + q·T_f(v) = T_f(u + q v), by linearity of T_f. +COPY and SCALE are the same. INIT/CLEAR of owned fields set the row and the content to zero. ∎ + +## Lemma 2 (helper autonomy) +`local.replay` requires every helper row to end as {h:1}, every main row to have the literal expected +form, and every owned row to end at zero. By Lemma 1, the module therefore maps a helper input +y = T_{A_h}(x_h) to T_{B_h}(x_h) = T_{B_h} T_{A_h}⁻¹ y. It does not contaminate any other output. ∎ + +## Proposition (delivered target) +`native()` lowers U_h = T_{B_h} T_{A_h}⁻¹ = M_left · G_r · M_right. Here M_left and M_right are Clifford +monomials and G_r is the canonical rank-r native Gaussian with r = dim B_h − dim A_h. Exact signed-Pauli images and a dense +phase anchor are checked; the independent #5550 checker repeats both checks. Feed the module M_right⁻¹ z for an +arbitrary fresh z, and apply M_left⁻¹ to its helper output. The composite is then G_r z. So every helper +delivers one productive rank-r Gaussian on an arbitrary fresh input. The two monomials are ordinary +routes, priced in `local_routes` and bounded by #5550's ordinary census. + +The proposition does not depend on A_h being the zero frame. A higher start reduces the credited rank r +by exactly the dimension of the removed climb. Nothing beyond the paid MOVEs and the two priced +monomials enters the delivered target. + +## Consequence for #5561 +The #5561 words change only helper initial/final frames, frame labels and MOVE stops. Their legality +against the #5551 word is #5561's own `retime.py`. The unmodified `local.py` replay and native maps +accept them, and #5561's verifier passes. The #5550 checker, with only its input lines swapped, binds all 527 +helper endpoints by exact native checks. It reproduces the invoice from MOVEs and native ranks, and fits the +ordinary census inside the retained allowance (`verify.py`). Hence hypothesis (c) adds nothing to the +contract under which #5545 was audited. + +## Precedent +- #5545 (audited by #5550): 192 nonzero helper starts and 65 below-FULL finals. +- T74 entering helpers: S_E = T_FULL T_E⁻¹ = L_E (C_[w] ⊗ I) R_E, with paid wrappers (#458, Lemma A). +- Hyperplane-ended helpers: residual T_U T_E⁻¹ with pair wrappers R_(E,U), L_(E,U) (#591 review). +- The one recorded failure of an entering helper (PR2478 audit of T74) came from that emitter's separate + zero-frame precondition phase, which ran before the entry adapters. A P104 word is a single chronology + checked by Lemma 1, and it has no such phase. + +## Not covered +Retime legality, pricing, strictification and outer funding of #5561. Validity of the #5551 parent. +Inherited local all-input native semantics and the five framework assumptions. Human or proof-kernel +acceptance. diff --git a/research/p104-free-endpoint-contract-audit/README.md b/research/p104-free-endpoint-contract-audit/README.md new file mode 100644 index 0000000000..8846bce172 --- /dev/null +++ b/research/p104-free-endpoint-contract-audit/README.md @@ -0,0 +1,89 @@ +# Free helper endpoints of #5561 under the audited P104 endpoint contract + +**Result (scoped audit, no new κ).** The "free helper start and final frames" hypothesis (c) of +[#5561](https://github.com/CrocSwap/integer-mult-bounds/pull/5561) is the general helper-endpoint +contract that the unmodified P104 `local.py` already implements. Chris R's independent caller audit +[#5550](https://github.com/CrocSwap/integer-mult-bounds/pull/5550) checked that contract on the +[#5545](https://github.com/CrocSwap/integer-mult-bounds/pull/5545) word. The same checker passes on +both #5561 words when only the word and its invoice are swapped in. + +Base: canonical main `5e0052ca0aa3036a3afa8b0438927377c8d97d53`. Audited source: #5561 head +`452d27dde67ee9f772dbbd3be129db97a8ecb9c1`. The words are byte copies in `inputs/` (SHA-256 in SOURCES.json). + +## What is checked + +| Check | Result | +|---|---| +| #5545 word (audited by #5550) | 192 of 527 helpers start at a nonzero frame (dims 1, 4, 5); 65 end below FULL; 40 distinct endpoint pairs | +| Positive control | The patched #5550 checker on the #5545 word and invoice reproduces #5550's complete frozen output, SHA-256 `b51a7d19c10faea7d569a48e9536db8ba1e7418f8dd8dfb25646cc87cc9c4009`, byte for byte | +| #5561 headline word | PASS: 527 helper endpoints, 272 exact signed-Pauli and phase-anchor checks, invoice 66,852 paid / 12,814 productive, ordinary passes 124,232,680 ≤ 184,647,552 | +| #5561 starts-only word | PASS: 278 exact checks, invoice 67,374 / 12,814, ordinary passes 124,754,680 ≤ 184,647,552 | +| Negative controls | Changed helper endpoint rejected; changed invoice rejected; all ten #5550 controls reject on each word | + +For comparison, the #5561 headline word has fewer nonzero helper starts (58) than the already audited #5545 word (192). +Its 44 below-FULL finals are also fewer than #5545's 65. The starts-only word has 59 and 65. + +## Why this is the existing contract + +`native()` in `research/p104-productive-controller/local.py` credits each helper with the rank of +`chart(initial)⁻¹·chart(final)` for any nested pair of frames. It also charges two normalizers per helper as +ordinary routes. #5550 ([PROOF.md](../p104-caller-independent-audit/PROOF.md), "Helpers, scratch and +paid jobs") makes the mechanism explicit. Each endpoint lowers to U = M_left·G_r·M_right. M_right⁻¹ acts on the +fresh helper input before its LOCAL call and M_left⁻¹ after it. This relies on the local all-input ABI, which +`replay()` checks row by row. A helper from E to B therefore delivers the native Gaussian G_r, with +r = dim B − dim E, on an arbitrary fresh input. Only r is credited. Starting higher lowers the credited rank by +exactly the climb it removes. + +The same wrapper mechanism appears in the T74 lineage. Entering helpers use paid residual wrappers +R_E⁻¹/L_E⁻¹ (#458, Lemma A in `hpe_emit_local.py`). Hyperplane-ended helpers use pair wrappers R_(E,U), L_(E,U) +([review](../../docs/research/community-hyperplane599-review.md)). The canonical start rule cited in #5561 belongs to the +#4610/#5413 neutral caller, whose helper adapters J are pure coordinate permutations. It is not a +predicate of the P104 contract. [PROOF.md](PROOF.md) gives the argument. + +## What the verifier changes + +`verify.py` copies the authenticated #5550 capsule to a temporary directory. It then replaces exactly four literal lines of +its checker, each of which must occur once: + +1. Read the word from the given path, not the pinned #5545 word. +2. Take the expected helper profile as a parameter, not the #5545 literal. +3. Take the invoice from `inputs/INVOICE.json`, a byte extract of #5561's `RESULT.json`. The checker + recounts paid MOVEs and native target ranks and requires equality. +4. Recompute `local_routes` from the MOVE count with the source formula (paid + 2·527 + 208 + 4·104 + 4·8)·1000. + +The canonical capsule is never edited. The positive control shows the four changes are faithful. + +## Reproduce + +Python 3.12+, standard library only: + +```sh +python3 -B research/p104-free-endpoint-contract-audit/verify.py +``` + +The run takes about three minutes and should end with the marker `PASS_P104_FREE_ENDPOINT_CONTRACT_AUDIT`. `RESULT.json` holds the complete result. + +## Scope and limits + +This addresses only hypothesis (c) of #5561, and therefore also the mid-frame start hypothesis of +[#5553](https://github.com/CrocSwap/integer-mult-bounds/pull/5553). It does not check the retime +legality (#5561's own `retime.py`), the pricing or strictification, the outer conjunction, or the +validity of the #5551 parent word. Those checks belong to #5561's verifier and the pending #5551 admission. +The certified endpoints of the source are its checker constants KAPPA = .00308142 (headline) and +.003076879 (starts-only), as noted in the intake record. Inherited local all-input native semantics, +the five framework assumptions and maintainer acceptance remain. This is an agent check, not human +or proof-kernel acceptance. + +## Open next questions + +- Admission of the #5551 parent word, on which #5561 and #5553 build (pending, with #5548/#5550/#5557 support). +- Correction of #5561's claim lines to its certified endpoints .00308142 and .003076879. +- A deterministic generator for the #5561 retime, so that a checker is not the only reproduction route. + +## Credit + +Chris R / Clear1nsight (#5550 checker, used unchanged except the four input lines). DreamingOfClouds +(#5561, #5553). thu-nmrc (#5551). Ali Romman (#5544/#5545 and the P104 caller). chafreaky (#458 +wrappers). The P104 lineage (#2305, #2152, #2219) and all retained native, Clifford, compiler and analytic +contributors are credited in the cited packages. This package was prepared for Matarener with Claude (Anthropic), via +Claude Code. Apache-2.0. diff --git a/research/p104-free-endpoint-contract-audit/RESULT.json b/research/p104-free-endpoint-contract-audit/RESULT.json new file mode 100644 index 0000000000..ecdda8483b --- /dev/null +++ b/research/p104-free-endpoint-contract-audit/RESULT.json @@ -0,0 +1,77 @@ +{ + "headline": { + "census": { + "below_full_finals": 44, + "distinct_endpoint_pairs": 32, + "final_dims": { + "4": 27, + "5": 5, + "8": 12, + "9": 483 + }, + "helpers": 527, + "nonzero_starts": 58, + "start_dims": { + "0": 469, + "1": 2, + "5": 56 + } + }, + "certified_kappa_of_source": "154071/50000000", + "exact_native_checks": 272, + "ordinary_allowance": 184647552, + "ordinary_passes": 124232680, + "output_sha256": "e7bc506894359007b38552e99c93346a67fc3c754b8982595c7ae79b678bb3f4", + "paid_jobs": 66852, + "productive_fields": 12814 + }, + "negative_controls": { + "changed_helper_endpoint": "rejected", + "changed_invoice": "rejected" + }, + "pr5545_census": { + "below_full_finals": 65, + "distinct_endpoint_pairs": 40, + "final_dims": { + "4": 27, + "5": 4, + "8": 34, + "9": 462 + }, + "helpers": 527, + "nonzero_starts": 192, + "start_dims": { + "0": 335, + "1": 136, + "4": 32, + "5": 24 + } + }, + "starts_only": { + "census": { + "below_full_finals": 65, + "distinct_endpoint_pairs": 35, + "final_dims": { + "4": 27, + "5": 4, + "8": 34, + "9": 462 + }, + "helpers": 527, + "nonzero_starts": 59, + "start_dims": { + "0": 468, + "1": 2, + "4": 1, + "5": 56 + } + }, + "certified_kappa_of_source": "3076879/1000000000", + "exact_native_checks": 278, + "ordinary_allowance": 184647552, + "ordinary_passes": 124754680, + "output_sha256": "a4d61875640bad3ca3c82ea08c764381f275bb6fa798b5c2c6db3f4d80275e60", + "paid_jobs": 67374, + "productive_fields": 12814 + } +} diff --git a/research/p104-free-endpoint-contract-audit/SOURCES.json b/research/p104-free-endpoint-contract-audit/SOURCES.json new file mode 100644 index 0000000000..255d538d0b --- /dev/null +++ b/research/p104-free-endpoint-contract-audit/SOURCES.json @@ -0,0 +1,87 @@ +{ + "schema_version": 1, + "base_commit": "5e0052ca0aa3036a3afa8b0438927377c8d97d53", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "fc3d4ba105e1f097d0d7d051a308281e86ab1446", + "sha256": "66974efdced4083c00025f97d95d83909a226cdf801edb9301c195c6641f6903" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "research/p104-caller-independent-audit/CAPSULE-INVENTORY.json", + "usage": "input", + "git_blob": "07c7b818f02c2aabab4798c3e8203ffd2fe1e827", + "sha256": "c3e525f5d42ad5b274b039db42f97a2b6e372b583d382c73f59dcb3142f1960d" + }, + { + "path": "research/p104-caller-independent-audit/expected/caller.json.gz", + "usage": "input", + "git_blob": "812ef403ffb149c6230e4a58f29bea75c38f9ba2", + "sha256": "383509fce75e2d364138775a4fc96181c9c4cf2608eda0819a7c0c6236faa679" + }, + { + "path": "research/p104-full-frame-contact/WORD.json.gz", + "usage": "input", + "git_blob": "1ce96b0130daeea46ef53fdbd32bca2727aa6b35", + "sha256": "a1e416add9d2bb44fce923111ebc50513e5d845e56aabe214f2f0bc7d5f2b45d" + }, + { + "path": "research/p104-native-channel/vendor/clifford_exact.py", + "usage": "input", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + { + "path": "research/p104-native-channel/vendor/native_verify.py", + "usage": "input", + "git_blob": "2c209dfa9cfade3bc20ac5fc9d876b433a147f8c", + "sha256": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38" + }, + { + "path": "research/pr4359-p7-padding/native_inventory.py", + "usage": "input", + "git_blob": "8d2d96e3998254c2333c43fe47cdfd074cbd811e", + "sha256": "65539acaf45bdfe8c5aee6830f9c9b3d1107c442a60842ef803fdd7688de8f32" + }, + { + "path": "research/kappa-0023-productive-jobs/dependencies/kappa-next-regime/direct-decoder/sources/DATA-PHASES.json", + "usage": "input", + "git_blob": "d9a4f84211182ca200c081ea061d724c8a2cfb70", + "sha256": "c5916ff312678f12aba403847643fbbc29f643acec60bdf836fa56cd3e8251fa" + }, + { + "path": "research/p104-caller-independent-audit/PROOF.md", + "usage": "provenance", + "git_blob": "3a74b71a55753a6e7cb372d98b0074cf98dc8708", + "sha256": "d73ff9587a85db8063391919ffc4a17521ccd5759cdaf6338ba036703239d839" + }, + { + "path": "research/p104-productive-controller/local.py", + "usage": "provenance", + "git_blob": "dbb3d56a4f5b733bb0c32a91249d1f6a7e1ab5d2", + "sha256": "878734dfd64c4b9d362d0ae476cc5c2a19fe93e48b7378763b23f3e0dd0a5a71" + } + ], + "package_inputs": { + "INVOICE.json": "703d91eb2bb19caa22367c3b84dc7f7c666b3b94341981284e46cf998bbe7d84", + "pr5561-WORD.json.gz": "b3701d78bee3661382ebe5414e678dfc9ee292e254cb9dc56339c2d2f45fdf44", + "pr5561-WORD-STARTS-ONLY.json.gz": "c9d978ba90a3ddf6d50529a010ddb5dadc56554c99a15c36378b999deb6d6a20" + }, + "external_sources": { + "pr5561": { + "head": "452d27dde67ee9f772dbbd3be129db97a8ecb9c1", + "files": { + "research/p104-free-endpoint-retime/WORD.json.gz": "inputs/pr5561-WORD.json.gz", + "research/p104-free-endpoint-retime/WORD-STARTS-ONLY.json.gz": "inputs/pr5561-WORD-STARTS-ONLY.json.gz", + "research/p104-free-endpoint-retime/RESULT.json": "inputs/INVOICE.json (extract)" + } + } + } +} diff --git a/research/p104-free-endpoint-contract-audit/TASK.json b/research/p104-free-endpoint-contract-audit/TASK.json new file mode 100644 index 0000000000..f1508dff3d --- /dev/null +++ b/research/p104-free-endpoint-contract-audit/TASK.json @@ -0,0 +1,112 @@ +{ + "schema_version": 1, + "task_id": "scalar-to-moment", + "priority_revision": 7, + "base_commit": "5e0052ca0aa3036a3afa8b0438927377c8d97d53", + "original_card": { + "id": "scalar-to-moment", + "question": "Can a changed frame itinerary remove a paid transition beyond the already covered scalar A2 contractions?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/staged544-a2-graph-rewrite/README.md", + "research/staged544-separated-a2/README.md", + "research/staged544-a2-composition-audit/README.md", + "research/staged544-a1858-contraction-audit/README.md" + ], + "methods": [ + "Derive the changed legal frame itinerary and exact child histogram.", + "Prove a scoped obstruction showing why that scalar gain cannot change the paid contract." + ], + "acceptance_gate": "An unchanged histogram is not a kappa gain; record any separate runtime or proof benefit explicitly.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read the A2 and separated-A2 constructions and their composition/contraction audits. Scalar contractions can preserve the complete recursive histogram; fewer ADDs alone do not justify further scans.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Identify an actual paid transition to remove and construct a legal replacement frame itinerary, charging restoration, source windows and changed helpers. Compare complete before/after histograms. Stop if only scalar count changes; report that benefit honestly, without expanding the same scalar-only census.", + "bottleneck_link": "A legal change to the histogram, not addition count alone, is the bridge to an exponent gain.", + "allowed_variations": [ + "One existing scalar simplification and one proposed frame-path change." + ], + "scope_change_triggers": [ + "Submitting only another scalar count as completion of a paid-profile task." + ], + "overlap_terms": [ + "scalar simplification", + "paid profile", + "R439", + "3998", + "4019", + "4112", + "4152", + "staged544-a2-graph-rewrite", + "staged544-separated-a2", + "staged544-a2-composition-audit", + "staged544-a1858-contraction-audit" + ], + "existing_checks": [ + { + "scope": "PR #3998: consecutive A2 scalar contraction", + "evidence": "research/staged544-a2-graph-rewrite/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "389268a6b5e0373a3125d5c6fcd6995f4ea324f5", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4019: separated A2 sites with unchanged recursive histogram", + "evidence": "research/staged544-separated-a2/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "f408e09df300b575235f7f77f81948071397e16d", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4112: composition audit", + "evidence": "research/staged544-a2-composition-audit/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "205b7380656ba4b6316a8a493b1a3c679b8f7a0e", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4152: A1858 contraction audit", + "evidence": "research/staged544-a1858-contraction-audit/README.md", + "remaining": "A genuinely changed paid itinerary or a distinct independent audit; no default scalar-only expansion.", + "status": "author-checked", + "source_commit": "caaa14cde5962adc372fdca71f63d0f29e73c8b2", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "refined", + "actual_scope": "Audit hypothesis (c) of PR5561 (free helper start/final frames) against the P104 helper-endpoint contract audited in PR5550; rerun the PR5550 checker on both PR5561 words.", + "scope_change_reason": "Audit of a changed frame itinerary already proposed in PR5561; no new itinerary or kappa.", + "bottleneck_link": "PR5561 removes paid MOVE stops (69,912 -> 66,852 paid calls) by retiming helper endpoints; this audit decides whether that changed itinerary needs an extra premise.", + "budget_minutes": 120, + "stop_rule": "Stop after the PR5550 checker passes or fails on both PR5561 words with positive and negative controls.", + "outcome": "completed", + "evidence": "research/p104-free-endpoint-contract-audit/RESULT.json", + "author": "Matarener", + "ai_assistance": "Prepared with Claude (Anthropic) via Claude Code.", + "open_questions": [ + { + "question": "Is the PR5551 parent word admitted?", + "why_it_matters": "PR5561 and PR5553 build on it; this audit takes it as given.", + "first_step": "Follow the pending PR5551 admission with PR5548/PR5550/PR5557 support.", + "blocked_by": "Maintainer admission queue" + }, + { + "question": "Do PR5561 claim lines match its certified endpoints?", + "why_it_matters": "Intake records KAPPA=.00308142 and .003076879 as certified, not the raw crossings.", + "first_step": "Author correction of README/receipt claims.", + "blocked_by": "PR5561 author" + } + ] +} diff --git a/research/p104-free-endpoint-contract-audit/VERIFY.json b/research/p104-free-endpoint-contract-audit/VERIFY.json new file mode 100644 index 0000000000..9f5a551cdb --- /dev/null +++ b/research/p104-free-endpoint-contract-audit/VERIFY.json @@ -0,0 +1,26 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/p104-caller-independent-audit/CAPSULE-INVENTORY.json", + "research/p104-caller-independent-audit/expected/caller.json.gz", + "research/p104-full-frame-contact/WORD.json.gz", + "research/p104-native-channel/vendor/clifford_exact.py", + "research/p104-native-channel/vendor/native_verify.py", + "research/pr4359-p7-padding/native_inventory.py", + "research/kappa-0023-productive-jobs/dependencies/kappa-next-regime/direct-decoder/sources/DATA-PHASES.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 600, + "checks": "Authenticated PR5550 capsule; PR5545 endpoint census; patched checker reproduces the complete PR5550 output on PR5545 byte for byte; PASS on both PR5561 words; changed endpoint and changed invoice rejected; result equals RESULT.json." + } + ] +} diff --git a/research/p104-free-endpoint-contract-audit/inputs/INVOICE.json b/research/p104-free-endpoint-contract-audit/inputs/INVOICE.json new file mode 100644 index 0000000000..acd57323b4 --- /dev/null +++ b/research/p104-free-endpoint-contract-audit/inputs/INVOICE.json @@ -0,0 +1,107 @@ +{ + "note": "Byte-for-byte extract of paid, targets and nonrecursive from the author receipt; the checker recounts paid MOVEs and native target ranks itself and requires equality.", + "parts": { + "headline": { + "kappa": "154071/50000000", + "nonrecursive": { + "fixed_scalar_growth_bound": "At most 2^(16*26000) before native factors; a declared constant, not an attained norm.", + "local_routes": 5164000, + "local_scalar": 217428, + "peak_owned_fields": 1, + "raw_budget": 1000000000, + "raw_scalar_upper": 184647552, + "tensor_native_growth_bound": "Each rank-r Gaussian has row l1 norm at most 2^(rf); sum of local ranks is 5894." + }, + "paid": { + "1": 41340, + "16": 416, + "2": 8262, + "24": 416, + "3": 8928, + "32": 416, + "4": 1674, + "40": 416, + "48": 416, + "5": 2952, + "56": 416, + "6": 324, + "64": 416, + "7": 252, + "72": 208 + }, + "raw_root_interval": [ + "15407121669/5000000000000", + "308142433381/100000000000000" + ], + "targets": { + "145": 208, + "17": 416, + "25": 416, + "33": 416, + "4": 1494, + "41": 416, + "49": 416, + "5": 90, + "57": 416, + "65": 416, + "73": 208, + "8": 252, + "9": 7650 + } + }, + "starts_only": { + "kappa": "3076879/1000000000", + "nonrecursive": { + "fixed_scalar_growth_bound": "At most 2^(16*26000) before native factors; a declared constant, not an attained norm.", + "local_routes": 5193000, + "local_scalar": 217428, + "peak_owned_fields": 1, + "raw_budget": 1000000000, + "raw_scalar_upper": 184647552, + "tensor_native_growth_bound": "Each rank-r Gaussian has row l1 norm at most 2^(rf); sum of local ranks is 5894." + }, + "paid": { + "1": 42204, + "16": 416, + "2": 8442, + "24": 416, + "3": 8442, + "32": 416, + "4": 1638, + "40": 416, + "48": 416, + "5": 2970, + "56": 416, + "6": 306, + "64": 416, + "7": 252, + "72": 208 + }, + "raw_root_interval": [ + "76922002003/25000000000000", + "307688008013/100000000000000" + ], + "targets": { + "145": 208, + "17": 416, + "25": 416, + "33": 416, + "4": 1494, + "41": 416, + "49": 416, + "5": 90, + "57": 416, + "65": 416, + "7": 18, + "73": 208, + "8": 612, + "9": 7272 + } + } + }, + "schema": "p104-free-endpoint-invoice/1", + "source_head": "452d27dde67ee9f772dbbd3be129db97a8ecb9c1", + "source_path": "research/p104-free-endpoint-retime/RESULT.json", + "source_pr": 5561, + "source_sha256": "8a97218d94c149e7d5b62654cbf84ee8647bff99a9f8f6bd795b29ba0b02e70b" +} diff --git a/research/p104-free-endpoint-contract-audit/inputs/pr5561-WORD-STARTS-ONLY.json.gz b/research/p104-free-endpoint-contract-audit/inputs/pr5561-WORD-STARTS-ONLY.json.gz new file mode 100644 index 0000000000..b0c13f48e9 Binary files /dev/null and b/research/p104-free-endpoint-contract-audit/inputs/pr5561-WORD-STARTS-ONLY.json.gz differ diff --git a/research/p104-free-endpoint-contract-audit/inputs/pr5561-WORD.json.gz b/research/p104-free-endpoint-contract-audit/inputs/pr5561-WORD.json.gz new file mode 100644 index 0000000000..c367d865a1 Binary files /dev/null and b/research/p104-free-endpoint-contract-audit/inputs/pr5561-WORD.json.gz differ diff --git a/research/p104-free-endpoint-contract-audit/verify.py b/research/p104-free-endpoint-contract-audit/verify.py new file mode 100644 index 0000000000..5e40382376 --- /dev/null +++ b/research/p104-free-endpoint-contract-audit/verify.py @@ -0,0 +1,180 @@ +#!/usr/bin/env python3 +"""Free helper endpoints of PR5561 under the audited P104 endpoint contract. Apache-2.0. + +Prepared for Matarener with Claude (Anthropic), via Claude Code. +The scientific checker is Chris R / Clear1nsight's byte-pinned PR5550 caller and +target-binding audit (research/p104-caller-independent-audit, substantial OpenAI +Codex assistance). This file changes only four literal input lines of a temporary +copy and never edits the canonical capsule. + +Steps: + 1. authenticate every input by SHA-256 (canonical PR5550 capsule, PR5545 word, + package-local PR5561 words and invoice extract); + 2. census of nonzero helper starts and below-FULL helper finals in the PR5545 word; + 3. positive control: the patched checker on the PR5545 word with the PR5545 invoice + reproduces PR5550's complete frozen scientific output byte for byte; + 4. the patched checker on both PR5561 words (headline and starts-only); + 5. negative controls: a changed helper endpoint and a changed invoice are rejected. +""" +from collections import Counter +from pathlib import Path +import gzip +import hashlib +import json +import os +import shutil +import subprocess +import sys +import tempfile + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +AUDIT = ROOT/'research/p104-caller-independent-audit' +CAPSULE = AUDIT/'capsule' +CHECK = 'outputs/p104-caller-route-audit-v2-20261025/check.py' +PR5545_WORD = ROOT/'research/p104-full-frame-contact/WORD.json.gz' +EXPECTED_5550 = 'b51a7d19c10faea7d569a48e9536db8ba1e7418f8dd8dfb25646cc87cc9c4009' + +REPLACEMENTS = ( + (" word = read(PRIOR/'sources/contact/WORD.json.gz')\n", + " word = read(Path(os.environ['P104_WORD']))\n" + " FREE = json.loads(Path(os.environ['P104_INVOICE']).read_text())\n"), + ("helper_profile == Counter({4:51, 5:36, 7:24, 8:122, 9:294})", + "helper_profile == Counter({int(k):v for k,v in json.loads(os.environ['P104_PROFILE']).items()})"), + (" costs = source['complete_cost']\n", + " costs = FREE\n"), + ("nr['local_routes'] == 5334000 and sum(paid_local.values()) == 3624", + "nr['local_routes'] == (sum(paid_local.values())+2*527+208+4*104+4*8)*1000 and sum(paid_local.values()) == int(os.environ['P104_MOVES'])"), +) + +PARTS = { + 'headline': {'word': 'pr5561-WORD.json.gz', 'moves': 3454, 'paid': 66852, 'pairs': 32, + 'profile': {4: 83, 5: 5, 8: 14, 9: 425}}, + 'starts_only': {'word': 'pr5561-WORD-STARTS-ONLY.json.gz', 'moves': 3483, 'paid': 67374, 'pairs': 35, + 'profile': {4: 83, 5: 5, 7: 1, 8: 34, 9: 404}}, +} + + +def need(ok, why): + if not ok: + raise ValueError(why) + + +def sha(path): + return hashlib.sha256(Path(path).read_bytes()).hexdigest() + + +def read(path): + raw = Path(path).read_bytes() + return json.loads(gzip.decompress(raw) if str(path).endswith('.gz') else raw) + + +def authenticate(): + pins = json.loads((HERE/'SOURCES.json').read_text()) + for row in pins['files']: + need(sha(ROOT/row['path']) == row['sha256'], 'source pin '+row['path']) + for name, digest in pins['package_inputs'].items(): + need(sha(HERE/'inputs'/name) == digest, 'package input '+name) + inventory = json.loads((AUDIT/'CAPSULE-INVENTORY.json').read_text())['files'] + for name, digest in inventory.items(): + if name.startswith('capsule/'): + need(sha(AUDIT/name) == digest, 'PR5550 capsule byte '+name) + + +def endpoint_census(word): + frames = word['frames'] + main = set(word['live']) | {r+112 for r in word['live']} + helpers = [r for r in range(word['public']) if r not in main] + starts = Counter(len(frames[word['initial'][r]]) for r in helpers) + finals = Counter(len(frames[word['final'][r]]) for r in helpers) + pairs = {(word['initial'][r], word['final'][r]) for r in helpers} + return {'helpers': len(helpers), 'start_dims': dict(sorted(starts.items())), 'final_dims': dict(sorted(finals.items())), + 'nonzero_starts': sum(n for d, n in starts.items() if d), 'below_full_finals': sum(n for d, n in finals.items() if d < 9), + 'distinct_endpoint_pairs': len(pairs)} + + +def run(work, word_path, invoice, profile, moves): + inv = work/'invoice.json' + inv.write_text(json.dumps(invoice)) + env = dict(os.environ, PYTHONDONTWRITEBYTECODE='1', P104_WORD=str(word_path), P104_INVOICE=str(inv), + P104_PROFILE=json.dumps(profile), P104_MOVES=str(moves)) + env.pop('P104_TRACE_FILE', None) + command = [sys.executable, '-X', 'pycache_prefix='+str(work/'bytecode')] + (['-O'] if sys.flags.optimize else []) + \ + ['-B', str(work/'capsule'/'outputs/p104-caller-route-audit-v2-20261025/check_free.py')] + done = subprocess.run(command, cwd=work/'capsule', env=env, capture_output=True, timeout=300) + return done.returncode, done.stdout, done.stderr.decode(errors='replace') + + +def main(): + authenticate() + print('PASS authenticated canonical PR5550 capsule, PR5545 word and PR5561 inputs', flush=True) + base = read(PR5545_WORD) + census_5545 = endpoint_census(base) + need((census_5545['nonzero_starts'], census_5545['below_full_finals'], census_5545['distinct_endpoint_pairs']) == (192, 65, 40), + 'PR5545 already has 192 nonzero helper starts, 65 below-FULL finals and 40 endpoint pairs') + print('PASS PR5545 endpoint census', census_5545, flush=True) + invoice = json.loads((HERE/'inputs/INVOICE.json').read_text()) + results = {'pr5545_census': census_5545} + with tempfile.TemporaryDirectory(prefix='p104-free-endpoint-contract-') as tmp: + work = Path(tmp) + shutil.copytree(CAPSULE, work/'capsule') + text = (work/'capsule'/CHECK).read_text() + need(hashlib.sha256(text.encode()).hexdigest() == sha(CAPSULE/CHECK), 'pinned PR5550 checker') + for old, new in REPLACEMENTS: + need(text.count(old) == 1, 'literal present once: '+old.strip()[:60]) + text = text.replace(old, new) + (work/'capsule'/CHECK).with_name('check_free.py').write_text(text) + # Positive control: the PR5545 word and invoice give PR5550's frozen output byte for byte. + source = read(CAPSULE/'outputs/p104-contact-reassessment-20261025/sources/contact/RESULT.json') + code, out, err = run(work, CAPSULE/'outputs/p104-contact-reassessment-20261025/sources/contact/WORD.json.gz', + source['complete_cost'], {4: 51, 5: 36, 7: 24, 8: 122, 9: 294}, 3624) + need(code == 0 and not err, 'positive control failed: '+err[-2000:]) + need(hashlib.sha256(out).hexdigest() == EXPECTED_5550 == hashlib.sha256(gzip.decompress((AUDIT/'expected/caller.json.gz').read_bytes())).hexdigest(), + 'patched checker reproduces the complete PR5550 output on PR5545') + print('PASS positive control: patched checker reproduces PR5550 output', EXPECTED_5550, flush=True) + for part, spec in PARTS.items(): + word_path = HERE/'inputs'/spec['word'] + word = read(word_path) + census = endpoint_census(word) + need(census['distinct_endpoint_pairs'] == spec['pairs'], part+' endpoint pairs') + code, out, err = run(work, word_path, invoice['parts'][part], spec['profile'], spec['moves']) + need(code == 0 and not err, part+' checker failed: '+err[-2000:]) + res = json.loads(out) + need(res['status'] == 'PASS_SCOPED_CALLER_AND_TARGET_BINDING' and res['kappa_claim'] is None, part+' scoped status') + need(sum(res['paid'].values()) == spec['paid'] and sum(res['targets'].values()) == 12814, part+' invoice') + need(len(res['helper_normalizers']) == 527 and res['native_checks']['fresh_helpers'] == 9486, part+' helper coverage') + need(len(res['controls']) == 10, part+' all ten PR5550 controls reject') + o = res['ordinary'] + need(o['abstract_address_phase_scalar_pass_upper'] <= o['retained_raw_scalar_upper'], part+' ordinary allowance') + results[part] = {'census': census, 'paid_jobs': spec['paid'], 'productive_fields': 12814, + 'exact_native_checks': res['native_checks']['distinct_signed_Pauli_and_independent_phase_anchors'], + 'ordinary_passes': o['abstract_address_phase_scalar_pass_upper'], 'ordinary_allowance': o['retained_raw_scalar_upper'], + 'certified_kappa_of_source': invoice['parts'][part]['kappa'], 'output_sha256': hashlib.sha256(out).hexdigest()} + print('PASS', part, results[part], flush=True) + # Negative controls on the headline word. + word = read(HERE/'inputs/pr5561-WORD.json.gz') + main_regs = set(word['live']) | {r+112 for r in word['live']} + h = next(r for r in range(735) if r not in main_regs and len(word['frames'][word['initial'][r]])) + zero = next(i for i, f in enumerate(word['frames']) if not f) + bad = json.loads(json.dumps(word)) + bad['initial'][h] = zero + bad_path = work/'bad-endpoint.json.gz' + bad_path.write_bytes(gzip.compress(json.dumps(bad).encode(), mtime=0)) + code, _, err = run(work, bad_path, invoice['parts']['headline'], PARTS['headline']['profile'], 3454) + need(code != 0 and 'ValueError' in err, 'changed helper endpoint rejected') + wrong = json.loads(json.dumps(invoice['parts']['headline'])) + wrong['paid']['1'] += 1 + code, _, err = run(work, HERE/'inputs/pr5561-WORD.json.gz', wrong, PARTS['headline']['profile'], 3454) + need(code != 0 and 'complete unchanged paid/target invoice' in err, 'changed invoice rejected') + results['negative_controls'] = {'changed_helper_endpoint': 'rejected', 'changed_invoice': 'rejected'} + print('PASS negative controls', results['negative_controls'], flush=True) + expected = json.loads((HERE/'RESULT.json').read_text()) + if '--write' in sys.argv: + (HERE/'RESULT.json').write_text(json.dumps(results, indent=1, sort_keys=True)+'\n') + else: + need(json.loads(json.dumps(results)) == expected, 'complete result equals RESULT.json') + print('PASS_P104_FREE_ENDPOINT_CONTRACT_AUDIT') + + +if __name__ == '__main__': + main()