diff --git a/research/selected-control-reservations/PROOF.md b/research/selected-control-reservations/PROOF.md new file mode 100644 index 0000000000..43f42d58ba --- /dev/null +++ b/research/selected-control-reservations/PROOF.md @@ -0,0 +1,172 @@ +# Selected raw145 routes inside complete compact reservations + +This is a source-bound refinement of an existing layout argument. It is not a +new compact-control primitive, a physical execution, or a final-template proof. +The source plan has SHA256 +`a02e79fb4615f4f987e3b3617c2b42eea2c1d7415cc66fa702a8b0cd28e6387e`. +The current selected value remains conditional κ=0.003027288235. + +## Proposition and quantified boundary + +Fix the authenticated `WHOLECALLER-PLAN-v1` with ambient145. Let integers +`d>=D>0`, `K,G,f>=1`, `q0>=1` and `lead>=0` be given. Put + +``` +H=dG, qF=ceil(2H/K), qB=ceil(H/K), +o=(q0+qF+lead)K, z=(D-qB)K. +``` + +Assume `(f-1)G<=H` and `o+145fK<=z`. Assume the current stream is a complete +Cartesian product of its row index, the front/back fields, all active and +spectator coordinates, and its record suffix. The source compact-control +primitive, including repair and restoration, is an inherited hypothesis. + +Then every literal main/helper/IDLE coordinate route in this plan has the +following placement: source axis `a`, column `j`, selected position `rho` +is the address bit + +``` +phi(a,j,rho)=o+(af+j)K+rho, +0<=a<145, 0<=j {0,...,L-1} × {0,...,U-1} × Omega, +``` + +where Omega is the entire within-row rectangle, including both front fields, +active slots, back field, spectators and record suffix. No compact or active +bit participates in the row quotient. Consequently each role receives all of +Omega; address completeness is independent of the payload's dirty values. +Repeated legal divisions use mixed-radix row digits, and the inverse formula +restores every original row. A parent/child packet may be correlated with other +owners; this does not change its complete address set. + +For each actual IDLE permutation p, the child prefix labels are +`(p[a],j)` for `a=P, +then `R'=ceil(R/P)P<2R`. Added rows contain the whole Omega and zero payload; +no partial front/back field is padded. They can be removed only after the +assumed complete linear invocation returns each zero row to zero. Our checker +tests mixed-radix boundary values, including huge integers, but neither assigns +final P nor proves the mathematical endpoint that makes padded rows deletable. +The generic bijection is predecessor work; the contribution is its explicit +join to these source routes and their actual child complements. + +## Exact remaining final-compiler obligation + +This result concerns the raw145-axis plan, not the exponentially larger +compiled program. `V16-APPLICATION-PROOF-v3` §§5–6 constructs a finite template +with enlarged N,W,P,O and source-style stock products. Its §4 raw145 route bill +cannot supply the final template's actual coordinate injection or row divisor. +In particular10928 is the raw productive count, not a certified final W; +418 is raw private inventory, not a certified final O. The numerical row controls +in this package using10928 and419 are arbitrary-divisor controls only. + +To promote this check to that program, supply a source-derived occurrence map +for every chronological product/completion/split/compiler wrapper. It must bind: + +1. its actual final-template active slots and rank-child complement; +2. its complete q0/qF/qB ranges, using final W/O/N and the full simultaneous + stock product, with each whole-row divisor legal; +3. the current parent/child descriptors and inverse return placement; +4. the restored-control and spectator premises at every call boundary. + +A lazy source-derived generator plus an induction/certificate may suffice; +materializing the astronomical template is not demanded. This package supplies +neither that generator nor its proof. It does not refute the selected written +specialization, whose retained assumptions remain unchanged. It supplies a +reusable raw occurrence lemma and identifies exactly where source binding stops. + +## Provenance and coverage + +Douglas Colkitt supplies compact reservations, dirty repair and row splitting. +John-Michael Smith, Hanson Sun and Aaron Wang supply retained guard/repair audits. +Jose Manuel supplies PR3055's encoded Compact and the older73-axis physical +controller/row-return implementation. Chris R / Clear1nsight and the selected +PR5413 contributor chain supply the actual145-axis plan and precision/compiler +specialization; all original plan/native/provider credits remain theirs. +PR5445 motivates the actual reservation binding; its first proposed raw-rotation +follow-up is already covered by the retained packages and is not repeated. + +New source binding and this scoped proof: JoyboyBrian, with substantial OpenAI +Codex assistance; Apache-2.0. No independent human or proof-kernel acceptance. diff --git a/research/selected-control-reservations/README.md b/research/selected-control-reservations/README.md new file mode 100644 index 0000000000..2ff556a541 --- /dev/null +++ b/research/selected-control-reservations/README.md @@ -0,0 +1,74 @@ +# Selected5413 control-reservation binding + +**Scoped positive raw-caller binding; final compiled-template placement remains +open. No new κ.** The selected145-axis plan's119 main/helper/IDLE routes, +16,748 literal swaps,18 local planes and16 central translations fit complete +front/back compact reservations under an explicit parametric address map. + +[PROOF.md](PROOF.md) proves the source-bound implication for every positive +column width in the stated complete-field domain. Main/helper pre words and +IDLE pre words use opposite coordinate directions; the verifier retains this +difference. It also binds the15 actual IDLE child prefixes and their full +spectator complements to whole-row division/reassembly. + +This does not execute the compact primitive, re-prove its guard, or rerun the +selected Gaussian identity. Those already have substantial retained coverage. +It does not infer final compiler row stock from raw width10928/private count418. +The [precise final-compiler obligation](PROOF.md#exact-remaining-final-compiler-obligation) +requires the expanded occurrence injections and actual W/O/N/stock product. + +## Reproduce + +Python3.12+, standard library only: + +```sh +python3 -I -B research/selected-control-reservations/verify.py +python3 -I -O -B research/selected-control-reservations/verify.py +python3.12 -B scripts/research_package.py --package research/selected-control-reservations +``` + +Direct replay works without Git or network and authenticates every declared +source input. [RESULT.json](RESULT.json) records the exact census, six interval +families (including f=10^30 without materialization), literal lifted-coordinate +checks,45 IDLE child cases, whole-row boundary controls and eight rejecting +semantic mutations. Source-byte and portable replay controls are recorded separately in +[VALIDATION.json](VALIDATION.json). The fixed q0=11, G=3, K=64 interval fixtures are synthetic address controls, +not production row-stock or physical-tariff instances. Finite executions corroborate the written +quantified proposition; they are not proof-assistant verification. + +## Scope and prior coverage + +Base32890bc5de034ab8fc93ac88ead7279a6a416d04, priority7; selected conditional +κ=.003027288235. Source pins are in [SOURCES.json](SOURCES.json). Canonical +investigation: [Discussion5477](https://github.com/CrocSwap/integer-mult-bounds/discussions/5477). +The complete fresh overlap snapshot contained342 open PRs and4736 Discussion +records; root coordination owns publication. #5442 covers all-width caller +algebra, while #5445 explicitly leaves actual control reservations open. + +The earlier proposed generic four-update audit was withdrawn after finding +`compact-carry-repair-audit`, `compact-late-guard-audit-seed73`, +`compact-agreement-set-seed29`, and PR3055 `physical-complex-compact`. +`test_compact_control_layer.py` already checks generic toy row splits; +`physical-complex-controller` handles an older73-axis caller. We reuse their +boundaries and target this exact selected source, not a new generic repair. + +## Open next questions + +- Bind the unmaterialized final compiler's occurrence maps to this address ABI, + using actual N/W/O and full stock products. Start with one chronological + product occurrence and its rank-child embedding; the missing source-derived + map is the blocker, not another raw-route census. +- Join the actual selected packet to the encoded physical controller while + preserving descriptors, parent return and compact-field restoration. Begin + with one IDLE packet. This package proves address placement under those + inherited execution premises; it does not implement that join or price it. + +## Credit + +Prepared for **JoyboyBrian**, with substantial **OpenAI Codex assistance**. +Apache-2.0. Retain Douglas Colkitt's compact/row arguments; John-Michael Smith, +Hanson Sun and Aaron Wang's prior audits; Jose Manuel's physical implementation; +Chris R / Clear1nsight's PR5413 caller, Dillon's provider, Ali Romman's relations, +Cao Yifan's native word, Cinna Davis's controller, zxv's compiler and Jacob Alan +Sussman's recursion, plus the original source notices and cumulative lineage. +No independent human review, kernel proof, selected promotion or paid gain. diff --git a/research/selected-control-reservations/RESULT.json b/research/selected-control-reservations/RESULT.json new file mode 100644 index 0000000000..28658389b7 --- /dev/null +++ b/research/selected-control-reservations/RESULT.json @@ -0,0 +1,70 @@ +{ + "central_translations": 16, + "idle_child_cases": 45, + "literal_lift_coordinates": 207060, + "local_planes": 18, + "placement_families": [ + { + "active_end": 60992, + "f": 1, + "origin": 6848, + "q0": 11, + "qB": 47, + "qF": 94 + }, + { + "active_end": 121984, + "f": 2, + "origin": 12864, + "q0": 11, + "qB": 94, + "qF": 188 + }, + { + "active_end": 182976, + "f": 3, + "origin": 18880, + "q0": 11, + "qB": 141, + "qF": 282 + }, + { + "active_end": 426944, + "f": 7, + "origin": 42880, + "q0": 11, + "qB": 329, + "qF": 657 + }, + { + "active_end": 1890944, + "f": 31, + "origin": 186880, + "q0": 11, + "qB": 1454, + "qF": 2907 + }, + { + "active_end": 61000000000000000000000000000000000, + "f": 1000000000000000000000000000000, + "origin": 6000000000000000000000000000000832, + "q0": 11, + "qB": 46875000000000000000000000000000, + "qF": 93750000000000000000000000000000 + } + ], + "routes": 119, + "row_boundary_cases": 21, + "scope": "raw5413 route/reservation binding; expanded compiler injection and stock unverified", + "semantic_controls": [ + "IDLE_wrong_pre_direction", + "route_out_of_template", + "stage_private_axis_collision", + "omitted_central_translation", + "active_slot_in_front_control", + "missing_child_spectator", + "nondivisible_row_stock", + "undersized_active_region" + ], + "swaps": 16748 +} diff --git a/research/selected-control-reservations/SOURCES.json b/research/selected-control-reservations/SOURCES.json new file mode 100644 index 0000000000..78733fa100 --- /dev/null +++ b/research/selected-control-reservations/SOURCES.json @@ -0,0 +1,54 @@ +{ + "schema_version": 1, + "base_commit": "32890bc5de034ab8fc93ac88ead7279a6a416d04", + "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": "notes/compact-control-layout.tex", + "usage": "input", + "git_blob": "16f4d233471a7d189163ae7e7902becadecbba64", + "sha256": "2bc28e50f3eb092195294cafa81213e520f6d42e7935e9905ad8a6199e2a7c87" + }, + { + "path": "notes/compact-control-movement.tex", + "usage": "input", + "git_blob": "06b6a9ef24245ac7b724c53a204635415b402357", + "sha256": "b963c3d2f4e1b7059aa289bb4b4ac89b688920bcf42f5b20d7698cdef0132cc6" + }, + { + "path": "research/coupled-helper-neutral-completion/capsule/workspace/swarm-coupled-caller-sol-high-20261024/agents/challenge/WHOLECALLER-PLAN-v1.json", + "usage": "input", + "git_blob": "b868fe46ce7ff96a51f7b612758685a23014d31d", + "sha256": "a02e79fb4615f4f987e3b3617c2b42eea2c1d7415cc66fa702a8b0cd28e6387e" + }, + { + "path": "research/coupled-helper-neutral-completion/reports/proofs/V16-APPLICATION-PROOF-v3.md", + "usage": "input", + "git_blob": "574c1d0bd75cd85f720991d815272738aa3e5b8f", + "sha256": "cda8f596f7854f42a228f757d5f8e68f6b2256a19c5ae3771fb40753cedc5b39" + }, + { + "path": "research/physical-complex-controller/PROOF.md", + "usage": "input", + "git_blob": "c505caecc7ced19a4efc35c423efedda9427bea5", + "sha256": "471185621c0ecce295ffd327b1244aed234efe5ff05a804aaaa11316f1a8319e" + }, + { + "path": "tests/test_compact_control_layer.py", + "usage": "input", + "git_blob": "bca34c9e796ce5483f99ae1bf31acc6b74d32d8c", + "sha256": "c39797d9a2bc7eb4b9c7ffc458be04b64806636a3ef544de3a273f11ebfbcea1" + } + ] +} diff --git a/research/selected-control-reservations/TASK.json b/research/selected-control-reservations/TASK.json new file mode 100644 index 0000000000..6433b4ad5f --- /dev/null +++ b/research/selected-control-reservations/TASK.json @@ -0,0 +1,101 @@ +{ + "schema_version": 1, + "task_id": "formal-interface-lemma", + "priority_revision": 7, + "base_commit": "32890bc5de034ab8fc93ac88ead7279a6a416d04", + "original_card": { + "id": "formal-interface-lemma", + "question": "Can one uncovered interface implication be formalized with exact caller and certificate bindings?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/gate-operand-parity-lean/README.md", + "research/staged544-certified-endpoint/README.md", + "research/unconditional-batched-crt/README.md" + ], + "methods": [ + "Formalize a missing boundary lemma identified by the selected review.", + "Audit a formal theorem-to-certificate binding independently." + ], + "acceptance_gate": "State the exact formalized proposition and remaining assumptions; avoid duplicate arithmetic formalizations already present.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Inventory the gate-operand parity lemma (#3807) and certified endpoint arithmetic (#3857). Neither is a full multiplication proof. For #4100, audit the compact-switch statement and its hypotheses before formalizing it.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Write one missing statement with quantified hypotheses, actual caller and existing coverage. A compact-switch lemma is a candidate only after its mathematical contract is reviewed. Establish a bounded proof plan before a separately budgeted proof-assistant build; do not rerun large Lean jobs as orientation.", + "bottleneck_link": "A missing interface proof can reduce the conditional gap even if it does not change kappa.", + "allowed_variations": [ + "Narrow to one formal lemma or one theorem-to-certificate binding." + ], + "scope_change_triggers": [ + "Formalizing already-covered arithmetic and claiming the full multiplication theorem." + ], + "overlap_terms": [ + "hyperplane end", + "formal interface", + "Lean binding", + "3807", + "3857", + "4100", + "gate-operand-parity-lean", + "staged544-certified-endpoint", + "unconditional-batched-crt" + ], + "existing_checks": [ + { + "scope": "PR #3807: scoped gate-operand parity formalization.", + "evidence": "research/gate-operand-parity-lean/README.md", + "remaining": "Exact theorem-to-caller binding and genuinely uncovered interface lemmas.", + "status": "author-checked", + "source_commit": "4c3530f42a6abcc48e7a6bcffd6c901911dc8269", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #3857: certified real-power moment/endpoint arithmetic.", + "evidence": "research/staged544-certified-endpoint/README.md", + "remaining": "Uniform algorithmic implications, not another endpoint digit.", + "status": "author-checked", + "source_commit": "ef4315b8caa605e47a2515004845eb2d2ed71a86", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4100: compact-switch formalization proposed as future validation.", + "evidence": "research/unconditional-batched-crt/README.md", + "remaining": "Audit the statement and assumptions before a formal proof campaign.", + "status": "author-checked", + "source_commit": "337d04939571a637aeab54a0f58f54fde811663a", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "refined", + "actual_scope": "Source-bound raw5413 145-axis route placement inside complete compact reservations and whole-row/IDLE-child boundaries; explicit final-compiler binding handoff.", + "scope_change_reason": "Current all-width algebra and generic compact repair are covered. Refine to the actual selected145-axis geometry requested by PR5445; written quantified implication, not a Lean theorem.", + "bottleneck_link": "Makes the remaining physical native_all_columns reservation interface checkable for the raw caller, while preserving the unmaterialized final-template obligation.", + "budget_minutes": 60, + "stop_rule": "Complete the exact119-route binding or return the first source mismatch; do not substitute raw arities for final compiler stock.", + "outcome": "completed", + "evidence": "PROOF.md; RESULT.json; verify.py; independent source/export controls recorded in VALIDATION.json", + "author": "JoyboyBrian, with substantial OpenAI Codex assistance", + "ai_assistance": "Substantial OpenAI Codex assistance in source research, mathematics, implementation and writing; no human or formal-kernel acceptance.", + "open_questions": [ + { + "question": "Bind the final compiler occurrence maps and actual N/W/O stock to the reservation ABI.", + "why_it_matters": "The raw145-axis census cannot establish placement of the enormous completed/compiled template.", + "first_step": "Extract one chronological product occurrence with its source-derived rank-child injection and actual row divisor.", + "blocked_by": "No source-derived expanded occurrence map is supplied by this package." + }, + { + "question": "Join the selected raw packet to the encoded physical controller.", + "why_it_matters": "Address placement alone does not execute compact repair, child descent or tape restoration.", + "first_step": "Instantiate one actual IDLE child packet in the credited physical engine.", + "blocked_by": "Descriptor/owner and complete-return implementation binding." + } + ] +} diff --git a/research/selected-control-reservations/VALIDATION.json b/research/selected-control-reservations/VALIDATION.json new file mode 100644 index 0000000000..f93d784dbb --- /dev/null +++ b/research/selected-control-reservations/VALIDATION.json @@ -0,0 +1,45 @@ +{ + "schema_version": 1, + "status": "passed-scoped-raw-binding", + "platform": "macOS-27.0-arm64-arm-64bit-Mach-O", + "tested_interpreters": [ + "CPython3.14 direct normal", + "CPython3.12.2 registered normal/optimized and portability" + ], + "proof_sha256": "a553e04c0529875f170d8725465047d9ea5b1b4d9ab72f6f7301e929c0165d0d", + "checks": [ + { + "command": "python3.12 -B scripts/research_package.py --package research/selected-control-reservations", + "result": "PASS_REGISTERED_RESEARCH_PACKAGE;3 commands, approximately3.90seconds" + }, + { + "command": "python3 -I -B research/selected-control-reservations/test_package.py", + "result": "PASS_PORTABLE_RESERVATION_CONTROLS; normal/O empty-PATH replay, source-hash rejection, changed/missing receipt rejection and bool/int receipt rejection" + } + ], + "scientific_counts": { + "routes": 119, + "swaps": 16748, + "local_planes": 18, + "central_translations": 16, + "literal_lift_coordinates": 207060, + "idle_child_cases": 45, + "row_boundary_cases": 21, + "semantic_mutations": 8 + }, + "limitations": [ + "No final compiled occurrence map or final W/O/N stock certificate.", + "Synthetic interval fixtures do not establish production parameter thresholds or physical costs.", + "No selected full replay, tape execution, Gaussian endpoint replay, Lean build or independent human review." + ], + "publication_checks": "Committed-byte/source-history and final export outcomes are separate publication evidence, not mathematical acceptance.", + "review": { + "reviewer": "independent OpenAI Codex agent r15_analytic", + "scope": "raw119 route orientations, all-f interval/child proof, raw/final-compiler distinction and source/receipt trust boundaries", + "findings_resolved": [ + "Missing RESULT.json now fails closed.", + "Canonical JSON comparison distinguishes bool/int receipt substitutions." + ], + "human_or_formal_kernel_review": false + } +} diff --git a/research/selected-control-reservations/VERIFY.json b/research/selected-control-reservations/VERIFY.json new file mode 100644 index 0000000000..b29414d82e --- /dev/null +++ b/research/selected-control-reservations/VERIFY.json @@ -0,0 +1,47 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "notes/compact-control-layout.tex", + "notes/compact-control-movement.tex", + "research/coupled-helper-neutral-completion/capsule/workspace/swarm-coupled-caller-sol-high-20261024/agents/challenge/WHOLECALLER-PLAN-v1.json", + "research/coupled-helper-neutral-completion/reports/proofs/V16-APPLICATION-PROOF-v3.md", + "research/physical-complex-controller/PROOF.md", + "tests/test_compact_control_layer.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 30, + "checks": "Authenticated actual route census, parametric interval obligations, column lift and semantic controls" + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 30, + "checks": "Same evidence with assertions disabled" + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/test_package.py" + ], + "timeout_seconds": 30, + "checks": "Portable empty-PATH normal/optimized replay and altered source/receipt rejection" + } + ] +} diff --git a/research/selected-control-reservations/test_package.py b/research/selected-control-reservations/test_package.py new file mode 100644 index 0000000000..51329e38aa --- /dev/null +++ b/research/selected-control-reservations/test_package.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +"""Git-free source/receipt controls for the raw reservation binding. + +JoyboyBrian, with substantial OpenAI Codex assistance. Apache-2.0. +""" +from pathlib import Path +from tempfile import TemporaryDirectory +import json +import os +import shutil +import subprocess +import sys + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parent.parent + + +def require(ok, message): + if not ok: + raise RuntimeError(message) + + +def run(script, optimized): + env = dict(os.environ, PATH='', PYTHONDONTWRITEBYTECODE='1') + args = [sys.executable, '-I', '-B'] + (['-O'] if optimized else []) + [str(script)] + return subprocess.run(args, cwd='/', env=env, capture_output=True, text=True, timeout=15) + + +def main(): + checks = [] + with TemporaryDirectory(prefix='selected-controls-') as directory: + root = Path(directory) + package = root / 'research' / PACKAGE.name + shutil.copytree(PACKAGE, package) + manifest = json.loads((PACKAGE / 'VERIFY.json').read_text()) + for name in manifest['inputs']: + target = root / name + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(ROOT / name, target) + script = package / 'verify.py' + for optimized in (False, True): + result = run(script, optimized) + require(result.returncode == 0 and 'PASS_SELECTED_CONTROL_RESERVATIONS' in result.stdout, + 'portable replay failed: '+result.stderr) + checks.append('git_free_empty_PATH_' + ('optimized' if optimized else 'normal')) + source = root / next(x for x in manifest['inputs'] if x.endswith('WHOLECALLER-PLAN-v1.json')) + original = source.read_bytes() + source.write_bytes(original + b'\n') + for optimized in (False, True): + result = run(script, optimized) + require(result.returncode != 0 and 'source hash:' in result.stderr, 'source mutation survived') + checks.append('source_hash_rejection_' + ('optimized' if optimized else 'normal')) + source.write_bytes(original) + receipt = package / 'RESULT.json' + data = json.loads(receipt.read_text());data['swaps'] -= 1 + receipt.write_text(json.dumps(data)) + for optimized in (False, True): + result = run(script, optimized) + require(result.returncode != 0 and 'receipt changed' in result.stderr, 'receipt mutation survived') + checks.append('receipt_rejection_' + ('optimized' if optimized else 'normal')) + receipt.unlink() + for optimized in (False, True): + result = run(script, optimized) + require(result.returncode != 0 and 'missing result receipt' in result.stderr, 'missing receipt accepted') + checks.append('missing_receipt_rejection_' + ('optimized' if optimized else 'normal')) + data = json.loads((PACKAGE / 'RESULT.json').read_text()) + data['placement_families'][0]['f'] = True + receipt.write_text(json.dumps(data)) + for optimized in (False, True): + result = run(script, optimized) + require(result.returncode != 0 and 'receipt changed' in result.stderr, 'bool/int receipt accepted') + checks.append('typed_receipt_rejection_' + ('optimized' if optimized else 'normal')) + print(json.dumps({'status': 'PASS_PORTABLE_RESERVATION_CONTROLS', 'checks': checks}, indent=2)) + + +if __name__ == '__main__': + main() diff --git a/research/selected-control-reservations/verify.py b/research/selected-control-reservations/verify.py new file mode 100644 index 0000000000..abbea3f769 --- /dev/null +++ b/research/selected-control-reservations/verify.py @@ -0,0 +1,228 @@ +#!/usr/bin/env python3 +"""Source-bound raw5413 address placement, not final compiler admission. + +JoyboyBrian, with substantial OpenAI Codex assistance. Apache-2.0. +""" +from copy import deepcopy +from hashlib import sha256 +from pathlib import Path +import json + +PACKAGE = Path(__file__).resolve().parent +ROOT = PACKAGE.parent.parent +PLAN = 'research/coupled-helper-neutral-completion/capsule/workspace/swarm-coupled-caller-sol-high-20261024/agents/challenge/WHOLECALLER-PLAN-v1.json' + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def authenticate(): + sources = json.loads((PACKAGE / 'SOURCES.json').read_text()) + for row in sources['files']: + if row.get('usage') == 'input': + need(sha256((ROOT / row['path']).read_bytes()).hexdigest() == row['sha256'], + 'source hash: ' + row['path']) + return json.loads((ROOT / PLAN).read_text()) + + +def word_image(word, axes): + image = list(range(axes)) + for event in word: + need(len(event) == 3 and event[0] == 'SWAP_BITS', 'unsupported route') + a, b = event[1:] + need(type(a) is int and type(b) is int and 0 <= a < axes and 0 <= b < axes and a != b, + 'route axis outside active template') + image[a], image[b] = image[b], image[a] + return image + + +def census(plan): + need(plan['ambient_axes'] == 145, 'wrong ambient') + base = list(range(145)) + swaps = 0 + routes = [] + for family in ('main_targets', 'helper_targets', 'idle_jobs'): + for index, row in enumerate(plan[family]): + p, inv = row['permutation'], row['inverse_permutation'] + need(sorted(p) == base and sorted(inv) == base, 'not a permutation') + need([p[inv[a]] for a in base] == base, 'wrong inverse') + need(p[:row['rank']] == row['active_axes'], 'active-prefix mismatch') + need(row['absolute_phase'] == 0 and row['affine_translation'] == [], 'non-pure route') + pre, post = word_image(row['pre_word'], 145), word_image(row['post_word'], 145) + expected_pre, expected_post = (p, inv) if family == 'idle_jobs' else (inv, p) + need(pre == expected_pre and post == expected_post, 'source route direction') + need([pre[post[a]] for a in base] == base, 'route round trip') + swaps += len(row['pre_word']) + len(row['post_word']) + routes.append((family, index, row)) + need([len(plan[k]) for k in ('main_targets', 'helper_targets', 'idle_jobs')] == [32, 72, 15], 'route count') + need(swaps == 16748, 'literal swap count') + stages = {r['stage']: r['local_axes'] for r in plan['stage_embeddings']} + need(len(stages) == 18 and len(plan['locals']) == 18, 'local stage count') + private = [] + for row in plan['stage_embeddings']: + axes = row['local_axes'] + need(len(axes) == 9 and axes[0] == 0 and len(set(axes)) == 9, 'local plane') + need(row['same_for_all649_local_fields'] is True and row['spectators'] == 'identity', 'local full-field contract') + private.extend(axes[1:]) + need(sorted(private) == list(range(1, 145)), 'private plane collision') + for row in plan['locals']: + need(row['local_axes'] == stages[row['stage']], 'local stage binding') + central = 0 + for row in plan['main_targets']: + need(row['q_exponent'] in (-1, 1), 'Q exponent') + need(row['central_X_after_LEFT'] == (row['q_exponent'] == -1), 'central correction') + central += row['central_X_after_LEFT'] + need(central == 16, 'central correction count') + return routes, {'routes': len(routes), 'swaps': swaps, 'local_planes': 18, 'central_translations': central} + + +def reservation(d, D, K, G, q0, f, lead=0): + need(all(type(x) is int for x in (d, D, K, G, q0, f, lead)), 'noninteger dimensions') + need(d >= D > 0 and min(K, G, q0, f) > 0 and lead >= 0, 'invalid dimensions') + H = d * G + qF, qB = (2 * H + K - 1) // K, (H + K - 1) // K + start, end = (q0 + qF) * K, (D - qB) * K + origin = start + lead * K + need(origin + 145 * f * K <= end, 'no raw145 active block: use source fallback') + fields = ((0, q0 * K), (q0 * K, q0 * K + H), + (q0 * K + H, q0 * K + 2 * H), (end, end + H)) + need(fields[2][1] <= start and fields[3][1] <= D * K, 'reservation capacity') + need((f - 1) * G <= H, 'insufficient compact field') + return {'origin': origin, 'end': end, 'K': K, 'f': f, 'fields': fields, + 'D': D, 'q0': q0, 'qF': qF, 'qB': qB, 'H': H} + + +def selected_bit(layout, axis, column, rho): + need(0 <= axis < 145 and 0 <= column < layout['f'] and 0 <= rho < layout['K'], 'bad selected coordinate') + return layout['origin'] + (axis * layout['f'] + column) * layout['K'] + rho + + +def check_placement(routes, plan, layout): + # Endpoint inequalities certify complete integer intervals, not sampled columns. + origin, f, K = layout['origin'], layout['f'], layout['K'] + need(origin >= layout['fields'][2][1] and origin + 145*f*K <= layout['end'], 'control overlap') + for _, _, row in routes: + for word in (row['pre_word'], row['post_word']): + for _, a, b in word: + for axis in (a, b): + lo, hi = selected_bit(layout, axis, 0, 0), selected_bit(layout, axis, f-1, K-1) + need(origin <= lo <= hi < layout['end'], 'route escapes active region') + need(all(hi < left or right <= lo for left, right in layout['fields']), 'route uses row or control bit') + for row in plan['stage_embeddings']: + spans = [(origin + a*f*K, origin + (a+1)*f*K) for a in row['local_axes']] + need(len(set(spans)) == 9 and all(origin <= lo < hi <= layout['end'] for lo, hi in spans), 'local physical plane') + + +def literal_lift(routes): + # Independent interleaved-column oracle; includes every axis, not tensor payloads. + checks = 0 + for _, _, row in routes: + for f in (1, 2, 3): + for name, scalar_image in (('pre_word', word_image(row['pre_word'], 145)), + ('post_word', word_image(row['post_word'], 145))): + labels = [(a, j) for a in range(145) for j in range(f)] + for _, a, b in row[name]: + for j in range(f): + labels[a*f+j], labels[b*f+j] = labels[b*f+j], labels[a*f+j] + need(labels == [(scalar_image[a], j) for a in range(145) for j in range(f)], 'column-lift disagreement') + checks += 145*f + return checks + + +def child_packet(row, f, drop_spectator=False): + # Only IDLE pre_inverseJ puts its actual child on a canonical prefix. + pre = word_image(row['pre_word'], 145) + prefix = [(a, j) for a in pre[:row['rank']] for j in range(f)] + after = [(a, j) for a in pre[row['rank']:] for j in range(f)] + if drop_spectator: + after = after[:-1] + need(prefix == [(a, j) for a in row['active_axes'] for j in range(f)], 'child active prefix') + need(sorted(prefix + after) == [(a, j) for a in range(145) for j in range(f)], 'child loses spectator') + need(len(prefix) == row['rank']*f and len(after) == (145-row['rank'])*f, 'child extent') + return len(prefix), len(after) + + +def split_row(row, divisors, initial_rows): + need(initial_rows > 0 and 0 <= row < initial_rows, 'row range') + total, current, digits = initial_rows, row, [] + for width in divisors: + need(type(width) is int and width > 0 and total % width == 0, 'nonintegral row split') + current, w = divmod(current, width) + digits.append(w) + total //= width + restored = current + for width, w in reversed(list(zip(divisors, digits))): + restored = restored*width + w + need(restored == row, 'row return') + return current, tuple(digits) + + +def expect_failure(name, action): + try: + action() + except ValueError: + return name + raise ValueError('mutation survived: ' + name) + + +def verify(): + plan = authenticate() + routes, result = census(plan) + families = [] + for f in (1, 2, 3, 7, 31, 10**30): + layout = reservation(1000*f, 1000*f, 64, 3, 11, f, 2) + check_placement(routes, plan, layout) + families.append({'f': f, 'origin': layout['origin'], 'active_end': layout['end'], + 'q0': layout['q0'], 'qF': layout['qF'], 'qB': layout['qB']}) + result['placement_families'] = families + result['literal_lift_coordinates'] = literal_lift(routes) + result['idle_child_cases'] = 0 + for row in plan['idle_jobs']: + for f in (1, 2, 7): + child_packet(row, f) + result['idle_child_cases'] += 1 + # Actual final compiler arities are deliberately not replaced by raw10928. + # These are universal-law boundary controls with arbitrary legal divisors. + row_cases = 0 + for divisors in ((3, 5), (10928, 418+1), (10**40+7, 10**30+9)): + stock = 1 + for width in divisors: + stock *= width + original = stock+1 + padded = ((original+stock-1)//stock)*stock + need(original <= padded < 2*original, 'whole-row padding') + for row in sorted({0, 1, divisors[0]-1, divisors[0], original-1, original, padded-1}): + split_row(row, divisors, padded) + row_cases += 1 + result['row_boundary_cases'] = row_cases + mutations = [] + bad = deepcopy(plan); bad['idle_jobs'][0]['pre_word'] = list(reversed(bad['idle_jobs'][0]['pre_word'])) + mutations.append(expect_failure('IDLE_wrong_pre_direction', lambda: census(bad))) + bad_axis = deepcopy(plan); bad_axis['main_targets'][0]['pre_word'][0][1] = 145 + mutations.append(expect_failure('route_out_of_template', lambda: census(bad_axis))) + bad_plane = deepcopy(plan); bad_plane['stage_embeddings'][1]['local_axes'][1] = 1 + mutations.append(expect_failure('stage_private_axis_collision', lambda: census(bad_plane))) + bad_central = deepcopy(plan); bad_central['main_targets'][0]['central_X_after_LEFT'] = False + mutations.append(expect_failure('omitted_central_translation', lambda: census(bad_central))) + layout = reservation(2000, 2000, 64, 3, 11, 2) + bad_layout = dict(layout, origin=layout['fields'][1][0]) + mutations.append(expect_failure('active_slot_in_front_control', lambda: check_placement(routes, plan, bad_layout))) + mutations.append(expect_failure('missing_child_spectator', lambda: child_packet(plan['idle_jobs'][0], 2, True))) + mutations.append(expect_failure('nondivisible_row_stock', lambda: split_row(0, (3, 5), 16))) + mutations.append(expect_failure('undersized_active_region', lambda: reservation(145, 145, 64, 3, 11, 1))) + result['semantic_controls'] = mutations + result['scope'] = 'raw5413 route/reservation binding; expanded compiler injection and stock unverified' + expected = PACKAGE / 'RESULT.json' + need(expected.is_file(), 'missing result receipt') + frozen = json.loads(expected.read_text()) + need(json.dumps(result, sort_keys=True, separators=(',', ':')) == + json.dumps(frozen, sort_keys=True, separators=(',', ':')), 'receipt changed') + print(json.dumps(result, indent=2, sort_keys=True)) + print('PASS_SELECTED_CONTROL_RESERVATIONS') + return result + + +if __name__ == '__main__': + verify()