diff --git a/research/native-warp-event-binding/README.md b/research/native-warp-event-binding/README.md new file mode 100644 index 0000000000..fce1e43f39 --- /dev/null +++ b/research/native-warp-event-binding/README.md @@ -0,0 +1,131 @@ +# Native warp events must carry their declared frames + +This package reproduces the event-to-frame gap reported by jwr404 in +[issue #4571](https://github.com/CrocSwap/integer-mult-bounds/issues/4571) +and supplies an independent prerequisite checker. It checks **2,880 actual warp +events** in twelve oriented programs. It establishes no new κ and does not +change the frozen evaluators or automatically guard their callers. + +## Result and scope + +The frozen buffer replay accepts the reported two-label mutation in both +orientations of the selected PR4470 word: two inverse warps on `L273` are +relabelled from `0 → 0 → 0` to `0 → 1 → 0`, where frame 1 has dimension nine. +The formal operator words still cancel, all endpoint rows pass, and the paid +profile stays `{1:2237, 2:388, 3:494, 4:147, 5:36, 8:8}`. This is a reproduced +acceptance gap, not a counterexample to the selected multiplication claim. +The mutant is rejected by the additional check at event 3 in both directions. + +`warp_frames.py` reads the actual event's signed operator, old frame and new +frame. It checks exact equality of binary subspaces, rather than only their +dimensions. It also rejects singular maps, duplicate operator IDs, dependent +frame bases, missing frames and unknown/zero operators. Equivalent bases for +the same subspace are accepted. `RESULT.json` records the fixtures, the legacy +counterexample and thirteen rejection controls, including a non-involutive +order-three map that distinguishes positive and negative operators. + +All six pinned fixtures pass, each with 72 operators and 240 warp events per +orientation: + +| Fixture | Source and status | +| --- | --- | +| THREE-base, THREE-extra, FOUR-base, FOUR-extra | Retained converted native words and their canonical tables | +| PR4470 | Current selected constructor at the pinned main commit | +| PR4610 | Actual word retained by PR4616; frame transport acceptance only | + +The last fixture shows that the checker accepts a changed, valid operator +table. It does not require the maps to equal the selected table. It does not +admit PR4610's operator substitutions, phases, endpoint identity or κ claim. +Only the buffer evaluator's legacy acceptance is rerun; the corresponding +`native_extensions.py` finding remains attributed to the original issue. + +## Exact implication + +Let `U_f` be the span over F₂ of frame `f`, and let `G_k` be the binary map +whose columns are the canonical table's `G_columns` for positive operator `k`. +The native frame declaration for an event `['warp', role, op, old, new]` is + +``` +op > 0: G_op(U_old) = U_new +op < 0: G_|op|^(-1)(U_old) = U_new. +``` + +The checker enumerates the 512 images of each nine-bit map and requires all +images to be distinct. The map is therefore invertible. For negative `op`, +applying `G_|op|` to both sides makes the second condition equivalent to +`G_|op|(U_new) = U_old`. Both checks are finite exact set equalities. Checking +each event separately is needed even when the canonical table's own +`from_frame` and `to_frame` declarations are valid: those declarations do not +constrain the frame labels supplied by a different emitted word. + +This proves the stated binary frame-transport condition for each accepted +event, with the supplied canonical maps. It does not establish Clifford +absolute phases, frame chronology between events, scalar actions, dirty-state +restoration, paid tariffs, all-column validity, or a multiplication theorem. +The ordinary literal and physical checks remain separate obligations. + +## Reproduce and reuse + +From the repository root, using Python 3.12 and no third-party packages: + +```sh +python3 -B scripts/research_package.py --package research/native-warp-event-binding --check-only +python3 -B scripts/research_package.py --package research/native-warp-event-binding +``` + +The registered run authenticates all declared live inputs, constructs the +selected word in an isolated interpreter with a private empty bytecode cache, +checks the fixtures and controls, and compares the deterministic receipt. +`verify.py --write` regenerates `RESULT.json` using the same checks. + +For a word with separate canonical and program JSON files, including `.gz`: + +```sh +python3 -B research/native-warp-event-binding/warp_frames.py canonical.json.gz native-word.json.gz +``` + +Alternatively, import `audit(canonical, programs)` from `warp_frames.py` before +the existing literal replay. `programs` maps orientation names to event lists. +An invalid transport raises `ValueError` with the orientation, event index, +role, operator and frame IDs. The CLI checks supplied data; it does not +authenticate those files against repository provenance. The registered audit +does authenticate its declared inputs. A pass is only the frame prerequisite. + +## Provenance and overlap + +Scientific baseline: main `b91956876e5b4122fd89179f1b57557ff8378f15`, priority +revision 7, selected κ `60403/20000000`. Exact blobs and SHA256 pins are in +`SOURCES.json`. The catalogue and selected record are historical provenance; +the explicit inputs are authenticated live dependencies. + +The overlap refresh on 2026-10-23 at 05:05 UTC covered 319 open PRs and 4,077 +discussion records with complete remote pagination. The sparse local search +did not cover all 6,636 tracked notes. The directly relevant existing +`pr4610-warp-substitution-check` and `complex-cover-lift-audit/native_warps.py` +were inspected: they check canonical maps/classes, while this package checks +every emitted event's labels. This is bounded overlap evidence, not a novelty +certificate. The original task card is changed from historical four-provider +admission to this prerequisite in the current native caller; see `TASK.json`. + +## Open next questions + +1. Install this prerequisite in a new caller that admits caller-supplied native + words, preserving the frozen predecessor files. First identify its exact + mutable-word entrance and invoke the audit before any profile acceptance. + The integration needs that caller's complete endpoint and physical checks. +2. Independently check phase-corrected physical lowering for changed valid + warp tables. Start with a single substituted map from PR4610 and retain + spectator and absolute-phase obligations. Binary transport alone is + insufficient. These questions are also structured in `TASK.json`. + +## Credit + +jwr404 (James Reed) reported the gap, supplied the two-label counterexample and +proposed the span-image check in issue #4571. Ryanson Jonathan's PR4616 checks +PR4610's canonical map substitutions; intqwq supplied that candidate word. +The retained native/caller lineage includes Cinna Davis's PR4470, the credited +fresh-helper-boundary and missing-join-frame predecessors, and the authors +retained in their frozen source files. This package adds event-level checking +and executable controls; it does not claim the original discovery. + +Prepared by 1337isnot1337 with substantial OpenAI Codex assistance. Apache-2.0. diff --git a/research/native-warp-event-binding/RESULT.json b/research/native-warp-event-binding/RESULT.json new file mode 100644 index 0000000000..2b4d5a01eb --- /dev/null +++ b/research/native-warp-event-binding/RESULT.json @@ -0,0 +1,103 @@ +{ + "fixtures": { + "FOUR-base": { + "distinct_signed_frame_classes": 180, + "operators": 72, + "warp_events": { + "backward": 240, + "forward": 240 + } + }, + "FOUR-extra": { + "distinct_signed_frame_classes": 180, + "operators": 72, + "warp_events": { + "backward": 240, + "forward": 240 + } + }, + "THREE-base": { + "distinct_signed_frame_classes": 180, + "operators": 72, + "warp_events": { + "backward": 240, + "forward": 240 + } + }, + "THREE-extra": { + "distinct_signed_frame_classes": 180, + "operators": 72, + "warp_events": { + "backward": 240, + "forward": 240 + } + }, + "archived-PR4610": { + "distinct_signed_frame_classes": 180, + "operators": 72, + "warp_events": { + "backward": 240, + "forward": 240 + } + }, + "selected-PR4470": { + "distinct_signed_frame_classes": 180, + "operators": 72, + "warp_events": { + "backward": 240, + "forward": 240 + } + } + }, + "issue_4571": { + "backward": { + "legacy_mutant_accepted": true, + "legacy_original_accepted": true, + "new_audit_rejection": "backward[3], role ['L', 273]: G does not carry frame 0 to 1 for signed operator -59", + "paid_profile_unchanged": { + "1": 2237, + "2": 388, + "3": 494, + "4": 147, + "5": 36, + "8": 8 + } + }, + "forward": { + "legacy_mutant_accepted": true, + "legacy_original_accepted": true, + "new_audit_rejection": "forward[3], role ['L', 273]: G does not carry frame 0 to 1 for signed operator -59", + "paid_profile_unchanged": { + "1": 2237, + "2": 388, + "3": 494, + "4": 147, + "5": 36, + "8": 8 + } + } + }, + "limits": [ + "No frozen verifier changed or automatically guarded", + "No full Clifford phase, all-column, endpoint or paid-profile admission", + "Archived PR4610 transport acceptance is not supplier admission" + ], + "new_kappa_claimed": false, + "rejection_controls": { + "boolean_operator": "warp event: unknown or zero warp operator True", + "dependent_basis": "Dependent frame basis 4", + "duplicate_operator": "Warp operators must have distinct positive integer IDs", + "missing_frame": "warp event: invalid frame ID 99", + "negative_frame": "warp event: invalid frame ID -1", + "same_dimension_wrong_subspace": "warp event: G does not carry frame 1 to 3 for signed operator 1", + "singular_G": "Singular G for operator 1", + "truncated_event": "program[0]: invalid warp event shape", + "unknown_operator": "warp event: unknown or zero warp operator 2", + "wrong_canonical_transport": "canonical warp declaration: G does not carry frame 1 to 3 for signed operator 1", + "wrong_negative_sign": "warp event: G does not carry frame 1 to 2 for signed operator -1", + "wrong_positive_sign": "warp event: G does not carry frame 2 to 1 for signed operator 1", + "zero_operator": "warp event: unknown or zero warp operator 0" + }, + "status": "PASS_NATIVE_WARP_EVENT_BINDING", + "total_warp_events": 2880 +} diff --git a/research/native-warp-event-binding/SOURCES.json b/research/native-warp-event-binding/SOURCES.json new file mode 100644 index 0000000000..e508aac46b --- /dev/null +++ b/research/native-warp-event-binding/SOURCES.json @@ -0,0 +1,120 @@ +{ + "schema_version": 1, + "base_commit": "b91956876e5b4122fd89179f1b57557ff8378f15", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "c35482cd9035843b15a634cc8276a7e1e40e8395", + "sha256": "6fe0a099b89aa2aed796a13c3a21dafc63f3388ebf397464e44e0451893b9375" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "f126dd2e2dad2b669e75d1d0d0bd05c600725602", + "sha256": "f7a48bfa2659b88378282a8eee7d9fe52cdf505594124c4d1686b58510fffd72" + }, + { + "path": "research/fresh-helper-boundary/CHANGES.json", + "usage": "input", + "git_blob": "45744fedd0e28967aa72586048b8bc0c72f419a9", + "sha256": "cde73b8ff5b3c0d06e69e2293b991b24fd14a16dd4ccab7ff6b3439074a94624" + }, + { + "path": "research/fresh-helper-boundary/native.py", + "usage": "input", + "git_blob": "1b36f6cb5f205c33bf48811e0b1b3621c55e8154", + "sha256": "9b55a2d3c3972148fae9d112e745d9244968166bd89bd900c938f429fc76ab29" + }, + { + "path": "research/joint-helper-lattice/PATCH.json", + "usage": "input", + "git_blob": "51304a6601061ed4e698f910b09135ef109555e3", + "sha256": "296d0e8c58cc70febe042c681ef30d6bb469818c0835fbcaac8aa8d330f5b727" + }, + { + "path": "research/joint-helper-lattice/native_joint.py", + "usage": "input", + "git_blob": "0315f80e2fdef5e0eef13e3e9b8f72066238164d", + "sha256": "50869b1bcad7493e6b4cb2a4cd5d2fd9a193a5921100483fa2c3f2c999ddfd46" + }, + { + "path": "research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py", + "usage": "input", + "git_blob": "5a55034ec9e6185d981e16c28e1e2e455069e2cb", + "sha256": "106b4d5e052427230df452f0c901d5390a0583782960b80a8af94d9a984022c7" + }, + { + "path": "research/kappa-native-resume/native-source/rebased-core/converted/FOUR-base-CANONICAL.json.gz", + "usage": "input", + "git_blob": "c3eb094570a2e175f9de12a58bd360df4c4a147f", + "sha256": "71f03fe085db07399cdfeffadbb65f1910bbdb5b7b0873562fb228e4cb292c8b" + }, + { + "path": "research/kappa-native-resume/native-source/rebased-core/converted/FOUR-base-NATIVE-WORD.json.gz", + "usage": "input", + "git_blob": "c3c3c77ece298d0e51b6f1c3fb65b9efd310b4bb", + "sha256": "57d7c53bacc42c6d403d3f2ced05c7e277ade034a2cb2db9b07e20962cc0b0d6" + }, + { + "path": "research/kappa-native-resume/native-source/rebased-core/converted/FOUR-extra-CANONICAL.json.gz", + "usage": "input", + "git_blob": "b84ba97bddadc60f99b4ebbfa6681c036e21769c", + "sha256": "d67623412d0de8aab251702d708e9c48421b2721938657193370ee7065322e25" + }, + { + "path": "research/kappa-native-resume/native-source/rebased-core/converted/FOUR-extra-NATIVE-WORD.json.gz", + "usage": "input", + "git_blob": "c3c3c77ece298d0e51b6f1c3fb65b9efd310b4bb", + "sha256": "57d7c53bacc42c6d403d3f2ced05c7e277ade034a2cb2db9b07e20962cc0b0d6" + }, + { + "path": "research/kappa-native-resume/native-source/rebased-core/converted/THREE-base-CANONICAL.json.gz", + "usage": "input", + "git_blob": "fbdc18bfae45f3aea662f1f2b45a9de59da2f1a4", + "sha256": "4526f0c379c0a4e4ae7731b7086a15382c1d1e3960bdf73245f7121299a7ac73" + }, + { + "path": "research/kappa-native-resume/native-source/rebased-core/converted/THREE-base-NATIVE-WORD.json.gz", + "usage": "input", + "git_blob": "33c89dbc1730056bbf2f6ad3f5e7168f2e7a7591", + "sha256": "bde29d4ac306aa528a1237c8b7197291f29f1733f50058ca13f72c2ae328dccf" + }, + { + "path": "research/kappa-native-resume/native-source/rebased-core/converted/THREE-extra-CANONICAL.json.gz", + "usage": "input", + "git_blob": "052bcf3d6784cfc388ef217dfdabbe93c9984adc", + "sha256": "6d214cd24e00a2af5b237df8acadd6bd8d3e77bf307fafd0e3e8451c66d93203" + }, + { + "path": "research/kappa-native-resume/native-source/rebased-core/converted/THREE-extra-NATIVE-WORD.json.gz", + "usage": "input", + "git_blob": "33c89dbc1730056bbf2f6ad3f5e7168f2e7a7591", + "sha256": "bde29d4ac306aa528a1237c8b7197291f29f1733f50058ca13f72c2ae328dccf" + }, + { + "path": "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-CANONICAL.json.gz", + "usage": "input", + "git_blob": "4a8c4ed26e53a72362d571c972e65aff546be784", + "sha256": "6418ec3da24d548a57f5c3fe5b9062c26c9478e638504a61c387f5cfb5f4ed61" + }, + { + "path": "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-NATIVE.json.gz", + "usage": "input", + "git_blob": "b46d44c6ee624968dd57be928b0c15d9d45f3b2c", + "sha256": "c54b0a3e129d28e6dbf74fa731fc3bb70fe3c6705f07256750fbecddcc842d39" + }, + { + "path": "research/missing-join-frame/PATCH.json", + "usage": "input", + "git_blob": "f96d295d40014d4dd503f58eb3cdabcbb4b8e101", + "sha256": "9ab5328245ff02c9d0be21d39bcc375f50bc5d7909e9f7b9a3a9a6f812f5bd6e" + }, + { + "path": "research/pr4610-warp-substitution-check/PR4610-ACTUAL-WORD.json.gz", + "usage": "input", + "git_blob": "79dad65b9c9bd05956183492090d5439a269fc08", + "sha256": "d578875344095047c383ef513e69b9deb9d99d2b75abe14f7359d06365a924ac" + } + ] +} diff --git a/research/native-warp-event-binding/TASK.json b/research/native-warp-event-binding/TASK.json new file mode 100644 index 0000000000..2acd69d7b2 --- /dev/null +++ b/research/native-warp-event-binding/TASK.json @@ -0,0 +1,104 @@ +{ + "schema_version": 1, + "task_id": "supplier-boundary-audit", + "priority_revision": 7, + "base_commit": "b91956876e5b4122fd89179f1b57557ff8378f15", + "original_card": { + "id": "supplier-boundary-audit", + "question": "Can the #4088 four-provider dispatch satisfy the complete ordinary/outer admission contract?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/staged544-mixed-fourth-entry/README.md", + "research/scatter-boundary-decision/README.md" + ], + "methods": [ + "Trace one hypothesis through the source, checker and complete caller.", + "Construct one semantically invalid but superficially well-formed fixture and test rejection." + ], + "acceptance_gate": "Pin the current sources and one obligation; the historical owner audit is an example, not evidence of a current bug.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read #4088 Scope and Open next questions: local words, native receipts and literal fill do not include a rerun of the mixed four-provider ordinary/outer engine. #3801 is the newer scatter-boundary decision; do not restart #2977 as if untouched.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Pin the provider registry, four native source closures and dispatch. Make a bounded acceptance coverage map or one registry adapter preserving every inherited admission predicate and rejection control (including an omitted fourth provider). Record remaining ordinary/outer obligations and a resource estimate before heavy execution. Stop at unresolved source/caller dependencies; no selected-result promotion from a local pass.", + "bottleneck_link": "Closing a current acceptance gap or proof obligation strengthens reliability even without changing kappa.", + "allowed_variations": [ + "One provider-registry, dispatch, native-closure or admission-predicate obligation; separate branches must name distinct coverage." + ], + "scope_change_triggers": [ + "Reporting the historical timing-only diagnostic as a new current acceptance bug.", + "Calling a malformed mutant a failure of the selected construction, or importing an opt-in repair without testing the exporter boundary.", + "Running another root enclosure instead of validating dispatch or weakening an inherited predicate to make mixed admission pass." + ], + "overlap_terms": [ + "owner boundary", + "bridge omission", + "hosting", + "2977", + "scatter export", + "duplicate index", + "parity semantics", + "4088", + "3801", + "staged544-mixed-fourth-entry", + "scatter-boundary-decision" + ], + "existing_checks": [ + { + "scope": "PR #4088: author-checked local words, native receipts, owner/phase fill and exact moment.", + "evidence": "research/staged544-mixed-fourth-entry/README.md", + "remaining": "Rebind and validate ordinary/outer admission with all four providers; full mixed release not established.", + "status": "author-checked", + "source_commit": "72d7efc181edb21806a878f174847c96dd410ab0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #3801: successor scatter-boundary decision package.", + "evidence": "research/scatter-boundary-decision/README.md", + "remaining": "Consult its exact acceptance scope before any new exporter audit; not proof of a selected failure.", + "status": "author-checked", + "source_commit": "911f8800ba7a4b03603ef62c5ffc6240e53cb5fd", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Audit the event-to-binary-frame prerequisite in issue #4571 on the four retained words, selected PR4470 and archived PR4610; reproduce the buffer replay counterexample.", + "scope_change_reason": "The historical supplier-boundary-audit card asks for four-provider ordinary/outer admission. This task instead isolates an actual event-to-operator binding gap in the current native caller before any such admission.", + "bottleneck_link": "A literal free-operator endpoint replay cannot alone authorize a frame-changing event or its paid profile. This audit supplies a necessary finite prerequisite, without claiming supplier admission or a new exponent.", + "budget_minutes": 60, + "stop_rule": "Finish after the six source-bound fixtures and signed/subspace rejection controls pass and the legacy counterexample is reproduced in both orientations. Do not expand into a phase, all-column or full supplier replay.", + "outcome": "completed", + "evidence": "README.md exact implication; RESULT.json deterministic twelve-program receipt, 2880 warp events, thirteen rejection controls and both-direction legacy acceptance counterexample.", + "author": "1337isnot1337", + "ai_assistance": "Substantial OpenAI Codex assistance; no delegated agents.", + "open_questions": [ + { + "question": "Where should the frame prerequisite guard caller-supplied native words?", + "why_it_matters": "A standalone checker does not automatically protect frozen evaluators or future callers.", + "first_step": "Identify one mutable-word entrance and call audit before deriving or accepting its paid profile, then rerun that caller\u2019s complete checks.", + "blocked_by": "Caller integration and its full endpoint/physical validation are outside this package." + }, + { + "question": "Do changed valid binary warp maps have the required phase-corrected physical lowering?", + "why_it_matters": "Correct binary frame transport is necessary but does not prove absolute phases or supplier admissibility.", + "first_step": "Independently lower one substituted PR4610 map with spectators and absolute phases retained.", + "blocked_by": "Requires the exact retained Clifford lowering contract and separately scoped physical validation." + } + ], + "upstream_checkpoint": { + "commit": "b91956876e5b4122fd89179f1b57557ff8378f15", + "priority_revision": 7, + "overlap_utc": "2026-10-23T05:05:20Z", + "open_prs": 319, + "discussion_records": 4077, + "local_coverage": "Sparse local inventory incomplete; directly relevant warp audits inspected." + } +} diff --git a/research/native-warp-event-binding/VERIFY.json b/research/native-warp-event-binding/VERIFY.json new file mode 100644 index 0000000000..1c71d84b7e --- /dev/null +++ b/research/native-warp-event-binding/VERIFY.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/fresh-helper-boundary/CHANGES.json", + "research/fresh-helper-boundary/native.py", + "research/joint-helper-lattice/PATCH.json", + "research/joint-helper-lattice/native_joint.py", + "research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py", + "research/kappa-native-resume/native-source/rebased-core/converted/FOUR-base-CANONICAL.json.gz", + "research/kappa-native-resume/native-source/rebased-core/converted/FOUR-base-NATIVE-WORD.json.gz", + "research/kappa-native-resume/native-source/rebased-core/converted/FOUR-extra-CANONICAL.json.gz", + "research/kappa-native-resume/native-source/rebased-core/converted/FOUR-extra-NATIVE-WORD.json.gz", + "research/kappa-native-resume/native-source/rebased-core/converted/THREE-base-CANONICAL.json.gz", + "research/kappa-native-resume/native-source/rebased-core/converted/THREE-base-NATIVE-WORD.json.gz", + "research/kappa-native-resume/native-source/rebased-core/converted/THREE-extra-CANONICAL.json.gz", + "research/kappa-native-resume/native-source/rebased-core/converted/THREE-extra-NATIVE-WORD.json.gz", + "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-CANONICAL.json.gz", + "research/kappa-rebuild/complex/full-identity-certificates/THREE-base-FULL-IDENTITY-NATIVE.json.gz", + "research/missing-join-frame/PATCH.json", + "research/pr4610-warp-substitution-check/PR4610-ACTUAL-WORD.json.gz" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Authenticate 17 live inputs; 2880 event-to-G frame transports across twelve programs; thirteen signed/subspace/schema rejection controls; legacy counterexample accepted in both directions but rejected by new audit; deterministic receipt." + } + ] +} diff --git a/research/native-warp-event-binding/verify.py b/research/native-warp-event-binding/verify.py new file mode 100644 index 0000000000..735588793d --- /dev/null +++ b/research/native-warp-event-binding/verify.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python3 +"""Source-bound warp-event audit and controls for issue #4571. + +Apache-2.0. Prepared by 1337isnot1337 with substantial OpenAI Codex assistance. +The original report is by jwr404; canonical-map audit credit is retained in README. +""" +from collections import Counter +from copy import deepcopy +import argparse +import hashlib +import importlib.util +import json +from pathlib import Path +import subprocess +import sys +import tempfile + +from warp_frames import WarpFrameAudit, audit, need, read_json + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +CORE = ROOT / "research/kappa-native-resume/native-source/rebased-core/converted" +TAGS = ("THREE-base", "THREE-extra", "FOUR-base", "FOUR-extra") + + +def authenticate(): + manifest = read_json(HERE / "SOURCES.json") + for row in manifest["files"]: + if row["usage"] == "input": + path = ROOT / row["path"] + need(hashlib.sha256(path.read_bytes()).hexdigest() == row["sha256"], + "Changed live source: " + row["path"]) + + +def load(path, name): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def rejected(action, expected): + try: + action() + except ValueError as error: + need(expected in str(error), "Control failed for an unintended reason: " + str(error)) + return str(error) + raise ValueError("Invalid warp unexpectedly accepted: " + expected) + + +def selected_word(): + # Authenticate first, then import retained modules only in an isolated child + # with an empty bytecode-cache namespace. No native phase replay is launched. + code = ("import json,sys;sys.path.insert(0,sys.argv[1]);import native_joint;" + "c,p,*_=native_joint.construct();print(json.dumps({'canonical':c,'programs':p}))") + with tempfile.TemporaryDirectory(prefix="warp-constructor-cache-") as cache: + run = subprocess.run( + [sys.executable, "-I", "-B", "-X", "pycache_prefix=" + cache, + "-c", code, str(ROOT / "research/joint-helper-lattice")], + capture_output=True, text=True, check=True, timeout=120) + result = json.loads(run.stdout) + return result["canonical"], result["programs"] + + +def signed_controls(): + # G has order three: e0 -> e1 -> e2 -> e0. Thus testing its sign is + # meaningful, unlike a sign control built from an involutive permutation. + canonical = {"h": 9, "frames": [[], [1], [2], [4], [1, 2]], + "warps": [{"op": 1, "G_columns": [2, 4, 1, 8, 16, 32, 64, 128, 256], + "from_frame": 1, "to_frame": 2}]} + checker = WarpFrameAudit(canonical) + checker.check(1, 1, 2) + checker.check(-1, 2, 1) + controls = {} + controls["wrong_positive_sign"] = rejected(lambda: checker.check(1, 2, 1), "G does not carry") + controls["wrong_negative_sign"] = rejected(lambda: checker.check(-1, 1, 2), "G does not carry") + controls["same_dimension_wrong_subspace"] = rejected(lambda: checker.check(1, 1, 3), "G does not carry") + for label, operator, old, new, message in ( + ("zero_operator", 0, 1, 2, "unknown or zero"), + ("unknown_operator", 2, 1, 2, "unknown or zero"), + ("negative_frame", 1, -1, 2, "invalid frame ID"), + ("missing_frame", 1, 1, 99, "invalid frame ID"), + ("boolean_operator", True, 1, 2, "unknown or zero"), + ): + controls[label] = rejected(lambda: checker.check(operator, old, new), message) + bad = deepcopy(canonical) + bad["warps"][0]["G_columns"][1] = bad["warps"][0]["G_columns"][0] + controls["singular_G"] = rejected(lambda: WarpFrameAudit(bad), "Singular G") + bad = deepcopy(canonical) + bad["warps"].append(deepcopy(bad["warps"][0])) + controls["duplicate_operator"] = rejected(lambda: WarpFrameAudit(bad), "distinct positive") + bad = deepcopy(canonical) + bad["frames"][4] = [1, 1] + controls["dependent_basis"] = rejected(lambda: WarpFrameAudit(bad), "Dependent frame basis") + bad = deepcopy(canonical) + bad["warps"][0]["to_frame"] = 3 + controls["wrong_canonical_transport"] = rejected(lambda: WarpFrameAudit(bad), "G does not carry") + controls["truncated_event"] = rejected( + lambda: checker.program([["warp", ["L", 0], 1, 1]]), "invalid warp event shape") + # Relabeling/rebasing a space is allowed; equality concerns spans, not lists. + equivalent = {"h": 9, "frames": [[1, 2], [3, 1]], + "warps": [{"op": 1, "G_columns": [1 << i for i in range(9)], + "from_frame": 0, "to_frame": 1}]} + WarpFrameAudit(equivalent).check(-1, 1, 0) + return controls + + +def legacy_counterexample(canonical, programs): + legacy = load(ROOT / "research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py", + "frozen_buffer_replay") + result = {} + for direction, program in programs.items(): + rebound = deepcopy(canonical) + rebound["local_profile"] = dict(Counter(e[-1] for e in program + if e[0] in ("climb", "center"))) + original = legacy.replay(program, rebound, [], direction == "backward", False) + mutant = deepcopy(program) + need(mutant[3] == ["warp", ["L", 273], -59, 0, 0] and + mutant[4] == ["warp", ["L", 273], 59, 0, 0], "Pinned issue #4571 probe") + mutant[3][4] = 1 + mutant[4][3] = 1 + accepted = legacy.replay(mutant, rebound, [], direction == "backward", False) + need(original["free_warp_operator_endpoint_matches"] and + accepted["free_warp_operator_endpoint_matches"], "Legacy endpoint control") + need(original["paid_profile"] == accepted["paid_profile"], "Legacy profile unchanged") + error = rejected(lambda: audit(canonical, {direction: mutant}), "G does not carry") + result[direction] = {"legacy_original_accepted": True, "legacy_mutant_accepted": True, + "paid_profile_unchanged": accepted["paid_profile"], + "new_audit_rejection": error} + return result + + +def run(): + authenticate() + fixtures = {} + for tag in TAGS: + canonical = read_json(CORE / (tag + "-CANONICAL.json.gz")) + programs = read_json(CORE / (tag + "-NATIVE-WORD.json.gz")) + fixtures[tag] = audit(canonical, programs) + canonical, programs = selected_word() + fixtures["selected-PR4470"] = audit(canonical, programs) + candidate = read_json(ROOT / "research/pr4610-warp-substitution-check/PR4610-ACTUAL-WORD.json.gz") + fixtures["archived-PR4610"] = audit(candidate["canonical"], candidate["programs"]) + need(all(row["operators"] == 72 and row["warp_events"] == {"forward": 240, "backward": 240} + for row in fixtures.values()), "Pinned fixture coverage") + return {"status": "PASS_NATIVE_WARP_EVENT_BINDING", "fixtures": fixtures, + "total_warp_events": sum(sum(row["warp_events"].values()) for row in fixtures.values()), + "rejection_controls": signed_controls(), + "issue_4571": legacy_counterexample(canonical, programs), + "new_kappa_claimed": False, + "limits": ["No frozen verifier changed or automatically guarded", + "No full Clifford phase, all-column, endpoint or paid-profile admission", + "Archived PR4610 transport acceptance is not supplier admission"]} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--write", action="store_true", help="regenerate the scoped JSON receipt") + args = parser.parse_args() + result = json.loads(json.dumps(run())) + if args.write: + (HERE / "RESULT.json").write_text(json.dumps(result, indent=2, sort_keys=True) + "\n") + expected = read_json(HERE / "RESULT.json") + need(result == expected, "Deterministic warp-event audit receipt") + print(json.dumps(result, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/native-warp-event-binding/warp_frames.py b/research/native-warp-event-binding/warp_frames.py new file mode 100644 index 0000000000..e5d6f12380 --- /dev/null +++ b/research/native-warp-event-binding/warp_frames.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 +"""Bind each native warp event to its exact binary frame transport. + +This is an additional prerequisite for a literal replay, not an endpoint, +Clifford-phase, chronology, or paid-profile verifier. Apache-2.0. +Prepared by 1337isnot1337 with substantial OpenAI Codex assistance. +""" +import argparse +import gzip +import json +from pathlib import Path + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def read_json(path): + path = Path(path) + raw = path.read_bytes() + return json.loads(gzip.decompress(raw) if path.suffix == ".gz" else raw) + + +def span(basis): + result = {0} + for vector in basis: + result |= {x ^ vector for x in tuple(result)} + return frozenset(result) + + +def apply(columns, vector): + result = 0 + for bit, column in enumerate(columns): + if (vector >> bit) & 1: + result ^= column + return result + + +class WarpFrameAudit: + """Nine-bit native frame prerequisite, independent of the legacy evaluator. + + For op > 0 require G_op(span(old)) = span(new). For op < 0 + require G_|op|(span(new)) = span(old), equivalent to the inverse + transport because the constructor first checks that G is invertible. + """ + + def __init__(self, canonical): + need(type(canonical.get("h")) is int and canonical["h"] == 9, + "This audit requires the retained nine-bit native model") + frames = canonical.get("frames") + need(isinstance(frames, list) and frames, "Missing native frames") + self.spaces = [] + for index, basis in enumerate(frames): + need(isinstance(basis, list) and len(basis) <= 9, + f"Invalid frame basis {index}") + need(all(type(x) is int and 0 <= x < 512 for x in basis), + f"Non-binary or out-of-range vector in frame {index}") + space = span(basis) + need(len(space) == 1 << len(basis), f"Dependent frame basis {index}") + self.spaces.append(space) + warps = canonical.get("warps") + need(isinstance(warps, list), "Missing canonical warp table") + self.maps = {} + self.checked_classes = set() + for warp in warps: + op = warp["op"] + need(type(op) is int and op > 0 and op not in self.maps, + "Warp operators must have distinct positive integer IDs") + columns = warp["G_columns"] + need(isinstance(columns, list) and len(columns) == 9 and + all(type(x) is int and 0 <= x < 512 for x in columns), + f"Invalid binary G columns for operator {op}") + images = tuple(apply(columns, x) for x in range(512)) + need(len(set(images)) == 512, f"Singular G for operator {op}") + self.maps[op] = images + for warp in warps: + self.check(warp["op"], warp["from_frame"], warp["to_frame"], + "canonical warp declaration") + + def check(self, operator, old, new, context="warp event"): + need(type(operator) is int and operator != 0 and abs(operator) in self.maps, + f"{context}: unknown or zero warp operator {operator!r}") + for frame in (old, new): + need(type(frame) is int and 0 <= frame < len(self.spaces), + f"{context}: invalid frame ID {frame!r}") + key = (operator, old, new) + if key in self.checked_classes: + return + source, target = (old, new) if operator > 0 else (new, old) + images = self.maps[abs(operator)] + actual = frozenset(images[x] for x in self.spaces[source]) + need(actual == self.spaces[target], + f"{context}: G does not carry frame {old} to {new} " + f"for signed operator {operator}") + self.checked_classes.add(key) + + def program(self, program, direction="program"): + count = 0 + for index, event in enumerate(program): + need(isinstance(event, list) and event, f"{direction}[{index}]: invalid event") + if event[0] == "warp": + context = f"{direction}[{index}]" + need(len(event) == 5, f"{context}: invalid warp event shape") + _, role, operator, old, new = event + self.check(operator, old, new, f"{context}, role {role!r}") + count += 1 + return count + + +def audit(canonical, programs): + checker = WarpFrameAudit(canonical) + need(isinstance(programs, dict) and programs, "Missing native programs") + counts = {direction: checker.program(program, direction) + for direction, program in programs.items()} + return {"operators": len(checker.maps), "warp_events": counts, + "distinct_signed_frame_classes": len(checker.checked_classes)} + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("canonical", type=Path) + parser.add_argument("word", type=Path) + args = parser.parse_args() + result = audit(read_json(args.canonical), read_json(args.word)) + print(json.dumps({"status": "PASS_NATIVE_WARP_EVENT_FRAMES", **result}, sort_keys=True)) + + +if __name__ == "__main__": + main()