From 6d4d72885351e01d0a2ce2b20419c0d84cb4949c Mon Sep 17 00:00:00 2001 From: pinterbanget Date: Thu, 22 Oct 2026 16:27:08 +0700 Subject: [PATCH] =?UTF-8?q?Endpoint-frame=20audit=20of=20#4596:=20every=20?= =?UTF-8?q?main=20output=20chart=20changes=20under=20the=20span{511}=20quo?= =?UTF-8?q?tient;=20replay=20checks=20only=20the=20word's=20own=20finals?= =?UTF-8?q?=20(no=20new=20=CE=BA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../.gitattributes | 1 + .../PR4596-QUOTIENT-WORD.json.gz | Bin 0 -> 3273 bytes .../pr4596-endpoint-frame-audit/README.md | 45 ++++++++ .../pr4596-endpoint-frame-audit/SOURCES.json | 66 ++++++++++++ .../pr4596-endpoint-frame-audit/TASK.json | 100 ++++++++++++++++++ .../pr4596-endpoint-frame-audit/VERIFY.json | 29 +++++ .../pr4596-endpoint-frame-audit/verify.py | 90 ++++++++++++++++ 7 files changed, 331 insertions(+) create mode 100644 research/pr4596-endpoint-frame-audit/.gitattributes create mode 100644 research/pr4596-endpoint-frame-audit/PR4596-QUOTIENT-WORD.json.gz create mode 100644 research/pr4596-endpoint-frame-audit/README.md create mode 100644 research/pr4596-endpoint-frame-audit/SOURCES.json create mode 100644 research/pr4596-endpoint-frame-audit/TASK.json create mode 100644 research/pr4596-endpoint-frame-audit/VERIFY.json create mode 100644 research/pr4596-endpoint-frame-audit/verify.py diff --git a/research/pr4596-endpoint-frame-audit/.gitattributes b/research/pr4596-endpoint-frame-audit/.gitattributes new file mode 100644 index 0000000000..757c25f58e --- /dev/null +++ b/research/pr4596-endpoint-frame-audit/.gitattributes @@ -0,0 +1 @@ +PR4596-QUOTIENT-WORD.json.gz -text diff --git a/research/pr4596-endpoint-frame-audit/PR4596-QUOTIENT-WORD.json.gz b/research/pr4596-endpoint-frame-audit/PR4596-QUOTIENT-WORD.json.gz new file mode 100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lZpVc9SNPUPERiD6%1UeU=pW2q(3ZpnNg0NcT0 zZlnDUZnSK)Iq^CJj0mOxhbK6ez{Z6ead6(?y}0 z!%q%DDO_A@oGx~D3XokxngGtLSK77kSr!yFz)B#!1%rfy9JYfTTj3}Pclkr|r?Ba_ z4{+AO8West6t>D|j(`qj!_AFLgCPJt={{n6dY+!A=l|&m;F0maEdTk(iG36PLzFiY z&VK&bynhF&|9)QIpW%<|U|p*1cQ4d6Ij{eeuWJaeF}{iM6;2g`AO0Mnum1fXuJA;s H$T|Q3Z{|~X literal 0 HcmV?d00001 diff --git a/research/pr4596-endpoint-frame-audit/README.md b/research/pr4596-endpoint-frame-audit/README.md new file mode 100644 index 0000000000..633ed782a2 --- /dev/null +++ b/research/pr4596-endpoint-frame-audit/README.md @@ -0,0 +1,45 @@ +# Endpoint-frame audit of #4596 (quotient of PR4470's word by span{511}) + +**Task:** independent-moment (adversarial audit). **Base:** canonical main `f626db5c`. **No κ is claimed here.** + +DaysSky's #4596 (head `406aae34`) applies the linear map `φ(v) = (v & 0xFF) ^ (0xFF if v & 0x100 else 0)`, whose kernel is `span{511}`, to every frame of PR4470's word. It then extends one helper's final frame by the ninth axis (`pad_ambient`) and prices the result as a block-8 supplier. The claimed complex supplier is 0.0121, giving an outer κ of 0.0034, up from 0.00302015. Its evidence is that the shipped literal replay returns all 632 endpoints exactly. + +This audit compares the submitted word's **main-field output frames** with PR4470's. PR4470's frames come from main's pinned constructor (`joint-helper-lattice/native_joint.py`, 7 pinned inputs). #4596's `QUOTIENT-WORD.json.gz` is vendored (blob `5bc2bdaf`, SHA256-pinned). + +## Findings + +| | PR4470 | #4596 quotient word | +|---|---|---| +| main roles 0–111 | end in the full frame `F₂⁹` | end in `F₂⁸` (low 8 bits) | +| main roles 112–223 | end in **112 distinct hyperplanes**, none containing 511 | end in the **same** `F₂⁸` | +| roles ending in `F₂⁹` | the 112 mains above | **only helper 224**, the `pad_ambient` extension | + +- **Every main output frame changed.** All 224 main fields now end in **one and the same frame**. This is forced by the map: `φ` sends `F₂⁹`, and every dimension-8 subspace avoiding 511, onto `F₂⁸`. So all 224 distinct output charts collapse into one. +- **Why the replay still passes.** The pinned `verify_buffers.py` compares a replay's final frames with the submitted word's **own** `canonical["final"]`, at its line 207. Its `expected()` rows take no frame input; they are logical scalar endpoints. A word that changes every main field's output chart, together with its own declared finals, is therefore accepted. "632/632 endpoints exact" certifies the logical linear map, not the output charts. + +## Consequence + +PR4470's word supplies its kernel by delivering each main field in its required chart. That means `C_{F₂⁹}` for mains 0–111 and the chart of a specific hyperplane for mains 112–223. The paid profile prices those transports, and the downstream ladder and consumer charges assume them. + +**If the supplier contract is PR4470's endpoint, the quotient word does not meet it.** Its lower paid profile then prices a different operator, one that never performs the full-ambient transforms, so it does not support the claimed κ. The `pad_ambient` step, which makes the frames span nine axes through one helper while no main field reaches them, keeps the block-8 ladder price without the corresponding outputs. + +Any route that does change the endpoint contract would need the consumer's, ladder's and controller's charges re-derived for the new output charts, with an operator-level, not logical-only, endpoint check. + +## Verify + +```text +python3 -B research/pr4596-endpoint-frame-audit/verify.py +``` + +This runs in about 2 s with the standard library only. + +## Limitations + +- **What is decided here.** This audit establishes the frame facts and the replay's frame-blindness. Whether a supplier may change its output charts is a contract question for the maintainers. The consequence above is stated conditionally. +- **What is not re-checked.** #4596's pricing arithmetic. The objection concerns what is priced, not the arithmetic. + +## Open next questions + +- An operator-level endpoint check for literal replays: compare each field's final frame with the certificate's required frame, not only with the word's own list. First step: add the PR4470 certificate's final frames as an independent input to `replay`. + +Credit: DaysSky (#4596), Cinna Davis (#4470) and the frame/replay lineage of `verify_buffers.py`. Prepared by Ryanson Jonathan with substantial Claude Code (Claude Opus 5.5) assistance. diff --git a/research/pr4596-endpoint-frame-audit/SOURCES.json b/research/pr4596-endpoint-frame-audit/SOURCES.json new file mode 100644 index 0000000000..fb8bac3215 --- /dev/null +++ b/research/pr4596-endpoint-frame-audit/SOURCES.json @@ -0,0 +1,66 @@ +{ + "schema_version": 1, + "base_commit": "f626db5c3a3d781d8f7695038776c621651f75e1", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "ed33caef5c5827693e9572d252a66f99cbb73d40", + "sha256": "5732707cc1e460b090b53f2463162749ad860de878a18f7408938671d295a9d9" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "64bfc5af6709ed9811171e0a2108f05e1219cb65", + "sha256": "352a6184713b8843d96fd2c2071eb7aeaa655906b7c51d45ad444912666c8a96" + }, + { + "path": "research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py", + "usage": "input", + "git_blob": "5a55034ec9e6185d981e16c28e1e2e455069e2cb", + "sha256": "106b4d5e052427230df452f0c901d5390a0583782960b80a8af94d9a984022c7" + }, + { + "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/fresh-helper-boundary/native.py", + "usage": "input", + "git_blob": "1b36f6cb5f205c33bf48811e0b1b3621c55e8154", + "sha256": "9b55a2d3c3972148fae9d112e745d9244968166bd89bd900c938f429fc76ab29" + }, + { + "path": "research/fresh-helper-boundary/CHANGES.json", + "usage": "input", + "git_blob": "45744fedd0e28967aa72586048b8bc0c72f419a9", + "sha256": "cde73b8ff5b3c0d06e69e2293b991b24fd14a16dd4ccab7ff6b3439074a94624" + }, + { + "path": "research/missing-join-frame/PATCH.json", + "usage": "input", + "git_blob": "f96d295d40014d4dd503f58eb3cdabcbb4b8e101", + "sha256": "9ab5328245ff02c9d0be21d39bcc375f50bc5d7909e9f7b9a3a9a6f812f5bd6e" + }, + { + "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" + } + ] +} diff --git a/research/pr4596-endpoint-frame-audit/TASK.json b/research/pr4596-endpoint-frame-audit/TASK.json new file mode 100644 index 0000000000..3aa726616b --- /dev/null +++ b/research/pr4596-endpoint-frame-audit/TASK.json @@ -0,0 +1,100 @@ +{ + "schema_version": 1, + "task_id": "independent-moment", + "priority_revision": 7, + "base_commit": "f626db5c3a3d781d8f7695038776c621651f75e1", + "original_card": { + "id": "independent-moment", + "question": "Does a new paid-profile or mixture-ceiling claim have independent source-bound coverage of its actual changed ledger?", + "starting_points": [ + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "research/staged544-mixed-fourth-entry/README.md", + "research/staged-fourth-mixture-ceiling/README.md", + "research/r437-two-window-carrier/README.md" + ], + "methods": [ + "Independently reconstruct one changed paid ledger or pooled dual with exact source and model binding.", + "Check a genuinely uncovered moment implication with a different enclosure method and semantic controls." + ], + "acceptance_gate": "Demonstrate independence, source binding, positive cases and semantic failure controls. Name the existing checks and the missing coverage. More digits or another equivalent evaluation of an unchanged root is not by itself new verification coverage.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Choose one uncovered implication in #4088 literal mixed fill, #4091 pooled dual/model binding or #4067 changed frame/host bill. #4091 pins an earlier #4088 head: validate word, capacity and stock equivalence before applying that ceiling to the later fill.", + "scope": "Source-binding orientation only; no scientific replay, theorem acceptance or supplier admission. Budget any heavy replay separately." + }, + "first_experiment": "Independently reconstruct one changed ledger or pooled certificate with a positive case and a semantic failure control. Compare exact sources and name what existing checks miss. Keep this separate from supplier-boundary-audit (ordinary/outer dispatch) and uniform-transfer-audit (all-size proof). Stop after the chosen implication; more digits of an unchanged root are not additional mechanism coverage.", + "bottleneck_link": "Independent pricing prevents unsupported frontier claims and can reveal genuine accounting slack.", + "allowed_variations": [ + "Reconstruct either a source ledger or a numeric enclosure with a different method." + ], + "scope_change_triggers": [ + "Importing the primary function and calling its output independent verification.", + "Calling an aggregate histogram or source archive an independently accepted physical supplier." + ], + "overlap_terms": [ + "independent moment", + "rank histogram", + "exact enclosure", + "2979", + "rank7 joint endframes", + "paired extraction", + "joint lowering", + "4088", + "4091", + "4067", + "staged544-mixed-fourth-entry", + "staged-fourth-mixture-ceiling", + "r437-two-window-carrier" + ], + "existing_checks": [ + { + "scope": "PR #4088: mixed local/owner/phase ledger and moment reported.", + "evidence": "research/staged544-mixed-fourth-entry/README.md", + "remaining": "Independent binding of changed construction to paid histogram, distinct from full admission.", + "status": "author-checked", + "source_commit": "72d7efc181edb21806a878f174847c96dd410ab0", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4091: sharp pooled ceiling proposed for fixed THREE/FOUR words and inventory.", + "evidence": "research/staged-fourth-mixture-ceiling/README.md", + "remaining": "Validate dual, exhaustive pattern scope and exact source equivalence before applying to newer fills.", + "status": "author-checked", + "source_commit": "a29bdd8f56cd18b805917775cdec09ff935eddc4", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "PR #4067: paid (2,2) to (1,3) exchange and fixed OQ4 host reported.", + "evidence": "research/r437-two-window-carrier/README.md", + "remaining": "Independent full cost delta; remaining caller/precision/stock obligations are separate.", + "status": "author-checked", + "source_commit": "a95f11c52e3ca1e4c5171b3c20d8f4b0815aee2e", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "unchanged", + "actual_scope": "Does a new paid-profile or mixture-ceiling claim have independent source-bound coverage of its actual changed ledger?", + "scope_change_reason": null, + "bottleneck_link": "Adversarial audit of the newest kappa claim (#4596): its supplier changes every main output chart, which the logical-only replay cannot detect.", + "budget_minutes": 30, + "stop_rule": "Stop at the endpoint-frame comparison.", + "outcome": "completed", + "evidence": "PR4470 mains: 112 end in F2^9, 112 in distinct 511-free hyperplanes; #4596: all 224 mains end in the same F2^8, only padded helper 224 reaches F2^9; every main output frame changed; phi collapses all to F2^8; replay checks the word's own finals (line 207) and expected() is frame-independent.", + "author": "Ryanson Jonathan, with Claude Code (Claude Opus 5.5) assistance", + "ai_assistance": "Substantial Claude Code (Claude Opus 5.5) assistance; no independent human review.", + "open_questions": [ + { + "question": "Operator-level endpoint check in literal replays.", + "why_it_matters": "Logical-only endpoints accept changed output charts.", + "first_step": "Pass the certificate's required final frames to replay independently.", + "blocked_by": "None." + } + ] +} diff --git a/research/pr4596-endpoint-frame-audit/VERIFY.json b/research/pr4596-endpoint-frame-audit/VERIFY.json new file mode 100644 index 0000000000..f18585924f --- /dev/null +++ b/research/pr4596-endpoint-frame-audit/VERIFY.json @@ -0,0 +1,29 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "certificates/selected-result.json", + "docs/research/agent-task-catalog.json", + "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-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" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Compare #4596 quotient word's main output frames with PR4470's (pinned constructor); phi collapse; replay final-frame and expected() behaviour bound to pinned verify_buffers.py." + } + ] +} diff --git a/research/pr4596-endpoint-frame-audit/verify.py b/research/pr4596-endpoint-frame-audit/verify.py new file mode 100644 index 0000000000..aee081f1da --- /dev/null +++ b/research/pr4596-endpoint-frame-audit/verify.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +"""Endpoint-frame audit of PR #4596 (DaysSky): the quotient of PR4470's word by span{511}. + +#4596 (head 406aae34; QUOTIENT-WORD.json.gz vendored, blob 5bc2bdaf, sha256-pinned) applies +phi(v) = (v & 0xFF) ^ (0xFF if v & 0x100 else 0), kernel span{511}, to every frame of PR4470's word, pads one helper's +final frame by the ninth axis, and prices the result as a block-8 supplier (complex kappa 0.0121, outer 0.0034). + +This verifier compares the submitted word's main-field output frames with PR4470's, from main's pinned #4470 +constructor (research/joint-helper-lattice/native_joint.py, run isolated), and records how the shipped literal replay +treats final frames: + * PR4470: the 112 main roles 0-111 end in the full nine-axis frame F2^9; roles 112-223 end in 112 distinct + hyperplanes, none containing 511; + * #4596: all 224 main roles end in one and the same frame, the low-8-bit space F2^8; no main role reaches F2^9; + the only role whose final frame is F2^9 is helper 224 (the pad_ambient extension); every main final frame differs + from PR4470's; + * phi maps every dimension-8 subspace avoiding 511 onto F2^8 and maps F2^9 onto F2^8 as well, which is why the 224 + distinct output charts collapse to one; + * the pinned verify_buffers.py compares a replay's final frames with the submitted word's own canonical["final"] + (its line 207) and its expected() rows carry no frame argument (logical scalar endpoints only), so the literal + replay is satisfied by a word that changes every main field's output chart. +If the native supplier must deliver each main field in PR4470's required chart (the kernel on every live array), the +quotient word does not, and its smaller paid profile does not price the same operator. No kappa is claimed here. +Ryanson Jonathan with Claude Code (Claude Opus 5.5) assistance. Apache-2.0. +""" +import gzip +import hashlib +import json +from pathlib import Path +import subprocess +import sys +import tempfile + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +WORD = HERE / "PR4596-QUOTIENT-WORD.json.gz" +WORD_SHA256 = "42bd7fb0c27d859a8731ef3d6f5f1d05daff77f3cc0dcae8ef16f0670b1815f6" +REPLAY = ROOT / "research/kappa-causal-continuation/buffer-borrowing/verify_buffers.py" + + +def need(condition, message): + if not condition: + raise AssertionError(message) + + +def span(basis): + s = {0} + for v in basis: + s |= {x ^ v for x in s} + return frozenset(s) + + +def phi(v): + return (v & 0xFF) ^ (0xFF if v & 0x100 else 0) + + +def main(): + raw = WORD.read_bytes() + need(hashlib.sha256(raw).hexdigest() == WORD_SHA256, "vendored #4596 QUOTIENT-WORD") + q = json.loads(gzip.decompress(raw)) + with tempfile.TemporaryDirectory(prefix="audit-cache-") as cache: + code = ("import json,sys;sys.path.insert(0,sys.argv[1]);import native_joint;" + "c,p,b,o,n=native_joint.construct();print(json.dumps({'c':c}))") + run = subprocess.run([sys.executable, "-I", "-B", "-X", "pycache_prefix=" + cache, "-c", code, + str(ROOT / "research/joint-helper-lattice")], capture_output=True, check=True, timeout=120) + c = json.loads(run.stdout)["c"] + full, low8 = frozenset(range(512)), frozenset(range(256)) + orig = [span(c["frames"][c["final"][r]]) for r in range(224)] + quot = [span(q["frames"][q["final"][r]]) for r in range(224)] + need(all(orig[r] == full for r in range(112)), "PR4470: mains 0-111 end in F2^9") + hyper = orig[112:] + need(all(len(f) == 256 and 511 not in f for f in hyper) and len(set(hyper)) == 112, + "PR4470: mains 112-223 end in 112 distinct hyperplanes avoiding 511") + need(all(f == low8 for f in quot), "#4596: all 224 mains end in the same low-8-bit frame F2^8") + need(all(orig[r] != quot[r] for r in range(224)), "#4596: every main output frame differs from PR4470's") + at_full = [r for r in range(len(q["final"])) if span(q["frames"][q["final"][r]]) == full] + need(at_full == [224], "#4596: only helper 224 (the padded one) ends in F2^9") + need(phi(511) == 0 and {phi(v) for v in full} == set(range(256)), "phi has kernel span{511}, image F2^8") + need(all({phi(v) for v in f} == set(range(256)) for f in hyper), "phi maps every 511-free hyperplane onto F2^8") + src = REPLAY.read_text(encoding="utf-8").splitlines() + need('[current["L", i] for i in range(n)] == canonical["final"]' in src[206], "replay checks the word's own finals") + need(any(line.startswith("def expected(role, R, backward, clean):") for line in src), "expected() has no frame input") + print(json.dumps({"status": "PASS_PR4596_ENDPOINT_FRAME_AUDIT", + "pr4470_main_finals": {"full_F2^9": 112, "distinct_hyperplanes": 112}, + "pr4596_main_finals": {"single_frame_low8": 224, "full_F2^9": 0}, + "main_output_frames_changed": 224, "roles_at_full_ambient_in_4596": at_full, + "replay_checks_own_finals_only": True, "new_kappa_claimed": False}, indent=1)) + + +if __name__ == "__main__": + sys.exit(main())