From 9b09455d05349732f54704859dd3a31e1f747a77 Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Wed, 11 Nov 2026 09:10:18 +0000 Subject: [PATCH 1/2] feat(research): classify rational header Hurwitz orbits --- .../rational-header-orbit-lattice/PROOF.md | 158 ++++++++++++ .../rational-header-orbit-lattice/README.md | 138 ++++++++++ .../SOURCES.json | 52 ++++ .../rational-header-orbit-lattice/TASK.json | 109 ++++++++ .../rational-header-orbit-lattice/VERIFY.json | 34 +++ .../rational-header-orbit-lattice/verify.py | 238 ++++++++++++++++++ 6 files changed, 729 insertions(+) create mode 100644 research/rational-header-orbit-lattice/PROOF.md create mode 100644 research/rational-header-orbit-lattice/README.md create mode 100644 research/rational-header-orbit-lattice/SOURCES.json create mode 100644 research/rational-header-orbit-lattice/TASK.json create mode 100644 research/rational-header-orbit-lattice/VERIFY.json create mode 100644 research/rational-header-orbit-lattice/verify.py diff --git a/research/rational-header-orbit-lattice/PROOF.md b/research/rational-header-orbit-lattice/PROOF.md new file mode 100644 index 0000000000..2478c1db3c --- /dev/null +++ b/research/rational-header-orbit-lattice/PROOF.md @@ -0,0 +1,158 @@ +# Rational header orbits retain their integer lattice + +This scoped proof was produced by Nick Petalas. Apache-2.0. + +## Contract and cited inputs + +Fix an even integer n >= 2, V = Q^n, and a nondegenerate alternating +rational form omega. A normalized saturated header is an ordered tuple +T = ((x_i,y_i)) for i = 0,...,n, with + +```text +y_i = omega(x_i, .), +y_i x_j = sgn(i-j), +U_i = I - 2 x_i y_i, +U_n ... U_0 = -I. +``` + +The form and ambient rational coordinates are fixed. Allowed equivalence +is a finite sequence of the normalized Hurwitz moves + +```text +mu_i^+ : (x_i,x_(i+1)) -> (x_(i+1), 2x_(i+1)-x_i), +mu_i^- : (x_i,x_(i+1)) -> (2x_i-x_(i+1), x_i), +``` + +with the corresponding covectors obtained from the same fixed omega. +There are no additional rational changes of frame or rescalings in this +equivalence relation. A simultaneous global sign may be quotiented out +without changing the result below, since it changes neither invariant. + +We cite DreamingOfClouds's #6842, `p104-header-braid-classification`, +Theorems 1, 3 and 4, for the normalized header structure, the moves and +the integral-frame classification. In particular the unique relation is +sum_i (-1)^i x_i = 0, the first n vectors are a basis, and in a fixed +integral unimodular frame two integral normalized headers are equivalent +exactly when their vector multisets modulo 2 agree. These results are +premises here, not results independently checked by this package. + +The integral sufficiency input in dimensions n >= 4 uses the pure braid +image theorem, Brendle and Margalit, *The level four braid group*, +[Theorem 3.3(1)](https://arxiv.org/pdf/1410.7416), which states the +surjectivity for genus g >= 2 and credits A'Campo. We do not reprove it. +For n = 2 the elementary argument at the end of the next section suffices. + +## The lattice and the classification + +Define L(T) = sum_i Z x_i inside V. This is an embedded integer lattice, +not the rational span and not the 2-local span. Define C(T) to be the +multiset of the classes x_i + 2L(T) in the intrinsic quotient L(T)/2L(T). +Comparing C(T) and C(T') is meaningful as an equality in the same quotient +only after L(T) = L(T') has been established. + +**Theorem.** For two normalized rational headers in the same fixed form, + +```text +T ~ T' iff L(T) = L(T') and C(T) = C(T'). +``` + +Thus the missing rational invariant is the embedded integer lattice. +Once that lattice is fixed, the remaining classification is exactly the +predecessor's integral one, evaluated intrinsically in that lattice. + +**Proof.** Let B have columns x_0,...,x_(n-1). The cited alternating +relation expresses x_n as an integral combination of these columns. +Consequently L(T) = B Z^n. Its Gram matrix is + +```text +B^T omega B = S, S_ij = sgn(i-j), 0 <= i,j < n. +``` + +It is an integral unimodular alternating matrix, by the cited header +structure. In particular L(T) is an integral unimodular symplectic lattice +even when its embedding in the original coordinate lattice is rational. + +A forward move replaces two generators a,b by b,2b-a. Conversely +a = 2b-(2b-a), so the integer span is unchanged. An inverse move gives +the same conclusion. Modulo 2L the move just exchanges the two classes, +so the multiset C is also unchanged. This proves necessity without any +braid-image theorem. + +For sufficiency suppose L(T') = L(T) = L. Choose the single lattice basis +B from T, and express both entire headers in its coordinates. Both vector +tuples are integral; their covectors are integral because the form S is +integral. The form is the same fixed unimodular S for both tuples. Their +ambient integral residue multisets in these coordinates are exactly C(T) +and C(T'). Apply #6842's integral classification to obtain a finite +Hurwitz word connecting them. Every move is an integer linear formula, +so changing coordinates back by B carries that same literal word from T +to T'. This proves sufficiency. No rational frame change has been added +to the allowed operations; the single coordinate chart is only used in +the proof. + +For n = 2, the three residue vectors of a normalized header are exactly +the three nonzero elements of L/2L. The two differences +d_0 = x_0-x_1 and d_1 = x_1-x_2 = x_0 are an integer basis with pairing +-1. The two move transformations are the transvections along d_0,d_1, +which in that basis are the two elementary unipotent generators of +SL_2(Z), up to inverse and sign conventions. They generate SL_2(Z) by +the integer Euclidean algorithm. Rigidity gives a symplectic integral +transition between any two headers on L, so all of them are connected. +This establishes the required dimension-two sufficiency directly. QED. + +The theorem is independent of a chosen basis of L: changing the common +basis applies one invertible linear map to both intrinsic multisets. +Using a separately chosen basis for each header and comparing the two +coordinate lists would discard the invariant and is not the criterion. + +## An infinite obstruction invisible modulo 2 + +Take n = 2, omega = [[0,-1],[1,0]], and for each positive odd integer m set + +```text +x_0(m) = (1/m, 0), +x_1(m) = (0, m), +x_2(m) = (-1/m, m), +y_i(m) = x_i(m)^T omega. +``` + +These are the conjugates of the normalized header at m = 1 by the +symplectic rational matrix G_m = diag(1/m,m), so they are normalized +headers in the same fixed omega. Equivalently, their covectors are +(0,-1/m), (m,0), (m,1/m); their pairings give the required sign Gram, +and multiplying the three literal units gives -I. + +All coordinates lie in Z_(2), the rationals with odd denominators. +Reduction of any odd integer or its inverse modulo 2 is 1. Hence every +tuple has the identical ambient reduction + +```text +{(1,0), (0,1), (1,1)} in F_2^2. +``` + +But L_m = (1/m)Z e_0 + m Z e_1. Its first-coordinate projection is +(1/m)Z, so equality L_m = L_k for positive m,k implies m = k. +Necessity in the theorem therefore proves that these headers occupy +pairwise different Hurwitz orbits. Each lattice has covolume one and +the same unimodular form; neither covolume nor ambient mod-2 data detects +the obstruction. In dimension two the lattice alone is also sufficient, +as established above. + +This conclusion does not contradict #6842's integral theorem, whose +integral ambient-frame hypothesis forces L = Z^n. It shows why replacing +that hypothesis by 2-local integrality while keeping only ambient mod-2 +data would lose information. It excludes connecting distinct L_m by +Hurwitz moves, not connecting them by an explicitly paid rational frame +change or by a larger operation alphabet. + +## Evidence boundary + +The theorem and the infinite family follow from the written argument. +The new standalone checker corroborates rational instances, literal +Hurwitz walks, both invariants, and the full product on each checked +tuple. It also supplies a same-lattice pair with different intrinsic +residue multisets, demonstrating the need for both parts in dimension +four. This is not a census of rational headers or an independent replay +of #6842. Native implementation, site-mask legality, compiler closure, +physical frame changes, precision, storage and complete pricing remain +outside scope. No multiplication theorem or new kappa follows. diff --git a/research/rational-header-orbit-lattice/README.md b/research/rational-header-orbit-lattice/README.md new file mode 100644 index 0000000000..42bf3e88cf --- /dev/null +++ b/research/rational-header-orbit-lattice/README.md @@ -0,0 +1,138 @@ +# Rational header orbits need an integer-lattice invariant + +This contribution was produced by Nick Petalas. Apache-2.0. + +Claim type: scoped written proof with exact finite corroboration. +For normalized saturated headers on Q^n, n even, in one fixed rational +symplectic form, the exact Hurwitz-equivalence criterion is + +```text +T ~ T' iff L(T) = L(T') and C(T) = C(T'), +L(T) = sum_i Z x_i, +C(T) = multiset {x_i + 2L(T)} in L(T)/2L(T). +``` + +The integer lattice is embedded in the original rational coordinate +space. The two residue multisets must be compared in that same lattice. +Rational changes of frame are not allowed as extra equivalences. + +DreamingOfClouds's [#6842](https://github.com/CrocSwap/integer-mult-bounds/pull/6842) +classifies the integral case and explicitly leaves non-integral frames +outside its scope. Its structure and integral classification are cited +premises. The new step is the embedded-lattice invariant, the transport of +that classification to rational headers, and an infinite counterexample +to using only ambient mod-2 data in the 2-local domain. + +For every positive odd integer m, in the fixed form [[0,-1],[1,0]], take + +```text +x_0 = (1/m,0), x_1 = (0,m), x_2 = (-1/m,m), +y_i = x_i^T omega, U_i = I-2x_i y_i. +``` + +These are normalized headers with U_2 U_1 U_0 = -I. All have the same +ambient reduction {(1,0),(0,1),(1,1)} modulo 2 and covolume one. +Their lattices (1/m)Z e_0 + m Z e_1 are pairwise distinct, so their +Hurwitz orbits are pairwise distinct. In dimension two the lattice alone +is also sufficient. [PROOF.md](PROOF.md) gives the universal argument. + +## Evidence and reproduction + +The standalone exact checker enumerates new rational instances only: + +- Twelve rational initial headers, dimensions 2, 4, 6 and 8, followed + through 16 literal Hurwitz moves each. All 192 steps preserve the + lattice and intrinsic residues and pass the full header product. +- Sixteen odd-denominator headers, m = 1,3,...,31. All 120 pairs have + distinct embedded lattices despite identical ambient mod-2 data. +- One rational dimension-four pair has the same lattice but different + intrinsic residue multisets. This demonstrates why the second + invariant is still required when the lattice is fixed. +- Five rejection controls cover singular bases, even denominators, + vectors outside the chosen lattice, an invalid move and an altered + normalized header. + +From the worktree root, with CPython 3.12 and its standard library: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -W error -B research/rational-header-orbit-lattice/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -I -O -W error -B research/rational-header-orbit-lattice/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/rational-header-orbit-lattice +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/rational-header-orbit-lattice --check-source-history +``` + +Another CPython 3.12 path may be substituted. The direct marker is +`PASS_RATIONAL_HEADER_ORBIT_LATTICE`; the registered runner prints +`PASS_REGISTERED_RESEARCH_PACKAGE`. The final command checks committed +publication bytes and source history. The verifier accepts no arguments, +writes no files and prints a generated receipt bound to SHA256 hashes of +all six package files. There is no handwritten or committed receipt. +It also runs in a Git-free export of these six files. + +## Scope, provenance and credit + +Base is canonical main e54523517d0f03e58352e647c403a5af3e525a57, priority +revision 8. The selected #7000 record, not the older narrative checkpoint, +is the baseline. Its cheap binding orientation passed; its scientific +replay was not run. The formal-interface-lemma card changes scope to this +algebraic side result. It does not discharge a selected assumption. + +[The advance CLAIM](https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19538524) +records the rational-header question. Live PRs, recent account submissions, +handoffs, local reservations, distinctive main README searches and merged +searches were checked. The overlap snapshot covered 477 open PRs and +7,129 Discussion records with complete pagination; sparse local notes +were incomplete. These checks do not establish absence of unpublished work. +No open PR studying this rational-header equivalence was found. + +Credit DreamingOfClouds #6842 for normalized header structure, Hurwitz +action, the integral theorem and this excluded domain; #6832/#6833/#6836, +CubeJerry #6839/#6840 and zxv #6726 retain its root lineage. Brendle and +Margalit's *The level four braid group*, Theorem 3.3(1), supplies the +cited higher-dimensional pure braid image, with A'Campo credited there. +The dimension-two elementary-generation argument is written here. +Lattice transport and the Euclidean algorithm are classical; no +literature-wide priority is claimed. SOURCES.json pins predecessor texts +as provenance. No predecessor code is imported or scientifically replayed. +All predecessor files and credit lines remain unchanged. + +The classification assumes normalized headers, the same rational form, +exactly n+1 square-zero rank-one units and only the stated Hurwitz moves. +It is not an orbit classification under rational conjugacy, a bounded +word-length result or a constructive braid-synthesis algorithm. Its +sufficiency cites the integral theorem; the lattice obstruction itself +does not need that input. The finite checks corroborate the new instances; +the written proof supplies the universal and infinite claims. + +No new kappa, native supplier, legal site-mask program, physical frame +conversion, complete paid/target bill, compiler closure, precision/tape +or stock bound follows. No selected cold replay, Lean, Docker or complete +multiplication theorem was run or claimed. Independent human and formal +proof-kernel review are unclaimed. + +## Open next questions + +Can a physically legal rational frame change join two distinct header +lattices at a favorable complete cost? Begin with one literal root and +conversion, charging dirty restoration, every native conversion, movement +and target effect. The present invariant rules out a Hurwitz-only route; +it does not price a changed operation alphabet. TASK.json records the +first step and the missing physical contract. Research stops at the +classification and explicit infinite family. + +## Verifier constraints + +Power of Ten inspection covers the single new Python file. Functions +are below 60 lines. The fixed computation has matrices of dimension at +most nine, 12 walks of exactly 16 steps and 16 family members. There is +no recursion, subprocess, network, dynamic code execution or external +scientific dependency. State is local, checks use explicit exceptions, +and warning-strict normal and optimized modes are registered. Six hash +reads are capped at 256 KiB each, and the verifier rejects CLI inputs. + +Rule 3 has a managed-runtime deviation. CPython allocates exact integers, +Fractions and containers dynamically; the fixed fixtures and bounded +walks bound algorithmic collections. Interpreter allocation has not been +instrumented, and a fixed-storage implementation would require separate +work. Rule 10 uses the registered warning-strict executions and AST +inspection; no separate static type checker or proof assistant is claimed. diff --git a/research/rational-header-orbit-lattice/SOURCES.json b/research/rational-header-orbit-lattice/SOURCES.json new file mode 100644 index 0000000000..2932410caa --- /dev/null +++ b/research/rational-header-orbit-lattice/SOURCES.json @@ -0,0 +1,52 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/p104-header-braid-classification/PROOF.md", + "usage": "provenance", + "git_blob": "d565a4831291c88cfae2d2e3c39068cf75dc5523", + "sha256": "0bc551ef8f418ac250534bdbe66f05d0579e28093e900c557bfc667658d754ec" + }, + { + "path": "research/p104-header-braid-classification/README.md", + "usage": "provenance", + "git_blob": "1a6023cd067135fba4f4415934d7611139e4dc7f", + "sha256": "e45d4088a932e236e0bf66624375e3b5b2505bd2376b8b233d627c0aa3056371" + }, + { + "path": "docs/research/current-priorities.md", + "usage": "provenance", + "git_blob": "6f5d40d13d8f3bdc12ce7954c8c3eb4ab1f8be91", + "sha256": "70f61c8d140ae6e892f2b8f065bba4eae3e76f7a8f55f632fd4e2f9f34039bdc" + }, + { + "path": "docs/research/research-family-status.md", + "usage": "provenance", + "git_blob": "3c19b18ef7225b47f0abcd9d51ae7c83d0cdfd15", + "sha256": "92c8010dfd9fc33e921f70526231f8689e06ea784f1b1387d895344b227f36d7" + } + ], + "external_citation": { + "title": "The level four braid group", + "authors": [ + "Tara E. Brendle", + "Dan Margalit" + ], + "url": "https://arxiv.org/pdf/1410.7416", + "version": "v3, 21 April 2021", + "use": "Theorem 3.3(1), genus at least two, cited input behind the predecessor integral classification; not a runtime dependency." + } +} diff --git a/research/rational-header-orbit-lattice/TASK.json b/research/rational-header-orbit-lattice/TASK.json new file mode 100644 index 0000000000..e9aa627d1c --- /dev/null +++ b/research/rational-header-orbit-lattice/TASK.json @@ -0,0 +1,109 @@ +{ + "schema_version": 1, + "task_id": "formal-interface-lemma", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "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_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.", + "scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse." + }, + "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": "changed", + "actual_scope": "Classify normalized rational saturated-header Hurwitz orbits in a fixed rational form by their embedded integer lattice and intrinsic mod-2 multiset; exhibit infinitely many 2-locally integral orbits with the same ambient mod-2 data.", + "scope_change_reason": "An algebraic side result extends the explicitly excluded non-integral domain of DreamingOfClouds PR6842. This is a written proof, not an audit, proof-assistant formalization, selected assumption discharge or supplier improvement.", + "bottleneck_link": "Rational helper/root frame changes need their own implementation and price. The new invariant prevents treating equality of ambient mod-2 headers as a sufficient rational Hurwitz connection. No full signed invoice gain is claimed.", + "budget_minutes": 60, + "stop_rule": "Stop at the first proved lattice classification and explicit infinite counterexample family; package it without extending to priced frame changes.", + "outcome": "completed", + "evidence": "PROOF.md gives the universal argument; verify.py checks new rational headers, literal walks, distinct lattices and semantic controls. Its stdout is a generated hash-bound receipt.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Can one physically legal rational frame change join distinct header lattices at a favorable complete cost?", + "why_it_matters": "The obstruction applies to Hurwitz moves, while a paid frame change may alter the lattice and enable a new native root.", + "first_step": "Pin one root and proposed rational frame change, then charge all native conversions, dirty restoration, movement and target effects.", + "blocked_by": "No physical conversion or complete price is provided by the algebraic classification." + } + ], + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19538524", + "predecessor": { + "pr": 6842, + "author": "DreamingOfClouds", + "package": "research/p104-header-braid-classification", + "use": "Cited structure, Hurwitz action and integral classification; no predecessor scientific replay." + }, + "playbook": "autonomous local run", + "environment": { + "python": "CPython 3.12.15", + "platform": "macOS arm64", + "dependencies": "standard library only" + }, + "claim_type": "scoped written proof with exact finite corroboration" +} diff --git a/research/rational-header-orbit-lattice/VERIFY.json b/research/rational-header-orbit-lattice/VERIFY.json new file mode 100644 index 0000000000..7f73d42648 --- /dev/null +++ b/research/rational-header-orbit-lattice/VERIFY.json @@ -0,0 +1,34 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "New rational header full products and normalized pairings; integer-lattice and intrinsic-residue invariance on literal walks; odd-denominator family with identical ambient reductions and pairwise distinct lattices; same-lattice distinct-residue example; five rejection controls; generated package-file hashes. All checks remain active under optimization." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "New rational header full products and normalized pairings; integer-lattice and intrinsic-residue invariance on literal walks; odd-denominator family with identical ambient reductions and pairwise distinct lattices; same-lattice distinct-residue example; five rejection controls; generated package-file hashes. All checks remain active under optimization." + } + ] +} diff --git a/research/rational-header-orbit-lattice/verify.py b/research/rational-header-orbit-lattice/verify.py new file mode 100644 index 0000000000..35db2a1acc --- /dev/null +++ b/research/rational-header-orbit-lattice/verify.py @@ -0,0 +1,238 @@ +#!/usr/bin/env python3 +"""Exact corroboration of rational header lattice invariants. Apache-2.0.""" + +from collections import Counter +from fractions import Fraction as F +from hashlib import sha256 +from itertools import combinations +import json +from pathlib import Path +import sys + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def identity(n): + require(1 <= n <= 8, "matrix dimension") + return [[F(i == j) for j in range(n)] for i in range(n)] + + +def transpose(a): + return [list(row) for row in zip(*a)] + + +def multiply(a, b): + require(1 <= len(a) <= 9 and len(a[0]) == len(b) <= 9, "matrix shape") + require(1 <= len(b[0]) <= 9, "matrix width") + return [[sum(x * y for x, y in zip(row, col)) + for col in zip(*b)] for row in a] + + +def inverse(a): + n = len(a) + aug = [list(row) + tail for row, tail in zip(a, identity(n))] + for j in range(n): + pivot = next((i for i in range(j, n) if aug[i][j]), None) + require(pivot is not None, "singular matrix") + aug[j], aug[pivot] = aug[pivot], aug[j] + scale = aug[j][j] + aug[j] = [x / scale for x in aug[j]] + for i in range(n): + if i != j: + scale = aug[i][j] + aug[i] = [x - scale * y for x, y in zip(aug[i], aug[j])] + return [row[n:] for row in aug] + + +def sign_form(n): + require(n in (2, 4, 6, 8), "even dimension") + return [[F((i > j) - (i < j)) for j in range(n)] for i in range(n)] + + +def canonical(n): + return identity(n) + [[F(-((-1) ** i)) for i in range(n)]] + + +def apply(a, vectors): + return transpose(multiply(a, transpose(vectors))) + + +def basis(vectors): + n = len(vectors[0]) + require(len(vectors) == n + 1, "saturated tuple") + return transpose(vectors[:n]) + + +def same_lattice(a, b): + ab = multiply(inverse(a), b) + ba = multiply(inverse(b), a) + return all(x.denominator == 1 for m in (ab, ba) for row in m for x in row) + + +def residues(vectors, lattice_basis): + coords = apply(inverse(lattice_basis), vectors) + require(all(x.denominator == 1 for row in coords for x in row), + "vector outside lattice") + return Counter(tuple(x.numerator % 2 for x in row) for row in coords) + + +def ambient_residues(vectors): + require(all(x.denominator % 2 for row in vectors for x in row), + "not 2-locally integral") + return Counter(tuple(x.numerator % 2 for x in row) for row in vectors) + + +def move(vectors, index, direction): + require(direction in (-1, 1) and 0 <= index < len(vectors) - 1, + "Hurwitz move") + result = [list(row) for row in vectors] + a, b = result[index:index + 2] + if direction == 1: + result[index:index + 2] = [b, [2 * y - x for x, y in zip(a, b)]] + else: + result[index:index + 2] = [[2 * x - y for x, y in zip(a, b)], a] + return result + + +def check_header(vectors, omega): + n = len(omega) + require(n in (2, 4, 6, 8) and len(vectors) == n + 1, "header shape") + rows = multiply(vectors, omega) + gram = multiply(rows, transpose(vectors)) + expected = [[F((i > j) - (i < j)) for j in range(n + 1)] + for i in range(n + 1)] + require(gram == expected, "normalized Gram") + product = identity(n) + for x, y in zip(vectors, rows): + unit = [[F(i == j) - 2 * x[i] * y[j] for j in range(n)] + for i in range(n)] + product = multiply(unit, product) + require(product == [[F(-(i == j)) for j in range(n)] for i in range(n)], + "full header product") + b = basis(vectors) + require(multiply(multiply(transpose(b), omega), b) == sign_form(n), + "intrinsic integral frame") + + +def rational_transvection(omega, vector, parameter): + row = multiply([vector], omega)[0] + n = len(vector) + return [[F(i == j) + parameter * vector[i] * row[j] for j in range(n)] + for i in range(n)] + + +def rational_walks(): + fixtures = steps = 0 + for n in (2, 4, 6, 8): + omega = sign_form(n) + for denominator in (3, 5, 7): + v = [F((i % 3) - 1) for i in range(n)] + g = rational_transvection(omega, v, F(1, denominator)) + start = apply(g, canonical(n)) + check_header(start, omega) + b = basis(start) + invariant = residues(start, b) + fixtures += 1 + current = start + for k in range(16): + index, direction = (3 * k + 1) % n, (-1 if k % 3 == 0 else 1) + following = move(current, index, direction) + check_header(following, omega) + require(same_lattice(b, basis(following)), "changed lattice") + require(residues(following, b) == invariant, "changed intrinsic residues") + require(move(following, index, -direction) == current, "inverse move") + current = following + steps += 1 + return {"rational_fixtures": fixtures, "literal_walk_steps": steps} + + +def odd_denominator_family(): + omega = sign_form(2) + family = [] + for m in range(1, 32, 2): + g = [[F(1, m), F(0)], [F(0), F(m)]] + vectors = apply(g, canonical(2)) + check_header(vectors, omega) + require(ambient_residues(vectors) == ambient_residues(canonical(2)), + "ambient reduction differs") + require(residues(vectors, g) == residues(canonical(2), identity(2)), + "intrinsic reference coordinates") + family.append((m, vectors, g)) + pairs = 0 + for (_, _, a), (_, _, b) in combinations(family, 2): + require(not same_lattice(a, b), "family lattices coincide") + require(a[0][0] * a[1][1] == b[0][0] * b[1][1] == 1, + "covolume control") + pairs += 1 + return {"odd_denominator_headers": len(family), "distinct_lattice_pairs": pairs} + + +def intrinsic_counterexample(): + omega = sign_form(4) + g = rational_transvection(omega, [F(1), F(0), F(1), F(0)], F(1, 3)) + start = apply(g, canonical(4)) + h = rational_transvection(omega, [F(1), F(0), F(0), F(0)], F(1)) + other = apply(multiply(g, h), canonical(4)) + check_header(start, omega) + check_header(other, omega) + require(same_lattice(basis(start), basis(other)), "same-lattice control") + require(residues(start, basis(start)) != residues(other, basis(start)), + "intrinsic residue obstruction absent") + return {"same_lattice_different_residue_pairs": 1} + + +def rejection_controls(): + caught = 0 + try: + inverse([[F(1), F(2)], [F(2), F(4)]]) + except ValueError: + caught += 1 + try: + ambient_residues([[F(1, 2), F(0)]]) + except ValueError: + caught += 1 + try: + residues([[F(1, 3), F(0)]], identity(2)) + except ValueError: + caught += 1 + try: + move(canonical(2), 2, 1) + except ValueError: + caught += 1 + altered = canonical(2) + altered[2][0] += 1 + try: + check_header(altered, sign_form(2)) + except ValueError: + caught += 1 + require(caught == 5, "rejection controls") + return {"rejection_controls": caught} + + +def source_hashes(): + root = Path(__file__).resolve().parent + names = ("README.md", "PROOF.md", "TASK.json", "SOURCES.json", "VERIFY.json", "verify.py") + result = {} + for name in names: + with (root / name).open("rb") as source: + raw = source.read(256 * 1024 + 1) + require(len(raw) <= 256 * 1024, "package file size") + result[name] = sha256(raw).hexdigest() + return result + + +def main(): + require(len(sys.argv) == 1, "no command-line arguments accepted") + result = {"status": "PASS_RATIONAL_HEADER_ORBIT_LATTICE", "no_new_kappa": True} + for counts in (rational_walks(), odd_denominator_family(), + intrinsic_counterexample(), rejection_controls()): + result.update(counts) + result["source_sha256"] = source_hashes() + print(json.dumps(result, sort_keys=True, indent=2)) + + +if __name__ == "__main__": + main() From 15530dd48bc7fde748b409ec897d9f5183ec79eb Mon Sep 17 00:00:00 2001 From: Nick Petalas Date: Tue, 17 Nov 2026 22:30:37 +0000 Subject: [PATCH 2/2] fix(ci): sync CI verification doc and historical replay-gap verifier --- docs/ci-verification.md | 19 +++++- .../historical-selected-replay-gap/README.md | 6 +- .../SOURCES.json | 60 +++++++++--------- .../VERIFY.json | 31 +-------- .../historical-selected-replay-gap/verify.py | 63 ++++++++++++++----- 5 files changed, 100 insertions(+), 79 deletions(-) diff --git a/docs/ci-verification.md b/docs/ci-verification.md index 63ba3e9aa8..52b62d0481 100644 --- a/docs/ci-verification.md +++ b/docs/ci-verification.md @@ -1,8 +1,25 @@ # CI verification -## Current selected-family replay: #6030 +## Current selected-family replay: #7000 with #7001 The [selected record](../certificates/selected-result.json) binds conditional +κ = 0.00363005817 to the [application review](research/pr-intake-evidence/pr7000-application/PROOF-REVIEW.md), +[validation receipts](research/pr-intake-evidence/pr7000-application/VALIDATION.json), +and [explicit source closure](../certificates/frontier7000-source.json). +`make frontier7000-verify` follows that exact-source selected replay. The review +reuses eleven authenticated preceding executions and records seven fresh serial +application, scalar and complete native-catalogue executions. The earlier +monolithic timeout is retained separately and is not completed coverage. +Consult the receipts for exact commands, source heads and limits. + +The five inherited framework assumptions remain. No complete uniform word, +literal multiplier execution, independent human proof or formal-kernel proof +is asserted. Routine research submissions do not need to rerun this +selected-family replay. The sections below preserve historical checkpoints. + +## Historical selected-family replay: #6030 + +The [historical checkpoint](../certificates/checkpoints/frontier6030.json) binds conditional κ = 0.003125804 to the [proof review](research/pr-intake-evidence/pr6030-audit/PROOF-REVIEW.md), [validation receipts](research/pr-intake-evidence/pr6030-audit/VALIDATION.json), and [explicit source closure](../certificates/frontier6030-source.json). diff --git a/research/historical-selected-replay-gap/README.md b/research/historical-selected-replay-gap/README.md index 55d8cc3b49..36d9a873ca 100644 --- a/research/historical-selected-replay-gap/README.md +++ b/research/historical-selected-replay-gap/README.md @@ -69,7 +69,11 @@ python3 -B scripts/research_package.py --package research/historical-selected-re The direct command prints `PASS_HISTORICAL_SELECTED_REPLAY_GAP`. A registered replay prints `PASS_REGISTERED_RESEARCH_PACKAGE`. Both require Git history -containing the two inspected commits. +containing the two inspected commits and the source and manifest objects at +`2485805a6d47f36ea83ddde6327d453ac82d44dc`. The verifier uses a temporary +sparse checkout of that commit, checks the declared source digests there, and +uses its planner and manifest inventory. The recorded rejections and selection +therefore remain reproducible after later changes to the live Makefile or CI guide. ## Open next questions diff --git a/research/historical-selected-replay-gap/SOURCES.json b/research/historical-selected-replay-gap/SOURCES.json index c1010eec95..62bb8b3950 100644 --- a/research/historical-selected-replay-gap/SOURCES.json +++ b/research/historical-selected-replay-gap/SOURCES.json @@ -4,13 +4,13 @@ "files": [ { "path": "Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "0d683a06b9e7ee162496108ce9a7c5d2ee94fccf", "sha256": "4f2d4f2dcd15139ec82658a975f85ed300897385f85799218539f4c8d60567da" }, { "path": "certificates/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "eccafa830c16170c36faf93045ddf1f638f7bcd4", "sha256": "4c0b9d37e1034b2076e30a70f8e514416298c462d9ee98bc87fe6556b14df786" }, @@ -22,7 +22,7 @@ }, { "path": "docs/ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "63ba3e9aa8bdc5e942b56e34244b92b16f854085", "sha256": "c7d3027e9ad8bcbff68f07aa9576b30fb2f3c76c44d876d40c7fdbf4a3e2228a" }, @@ -34,163 +34,163 @@ }, { "path": "research/clifford-state-performance/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "6f98a0061a5104dfab82c9e806f819b41811f684", "sha256": "396d0f08df24952248140d5c65c51b8c902ef1c580892ff7ea182890530f67ee" }, { "path": "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "5e0f92af463ec12c5e1dcc3effd44081a88af647", "sha256": "07a9daeaf2bda308a92e9a4684f13d5fc766c7772d74801fceb7f4599fdab226" }, { "path": "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "9e13266bf85e627f1b7dc225e9530ea69fd2c7f0", "sha256": "421e1211fb1897c45621dc6801c276e53f2e6f335583c9c9049e535f87c0a3b1" }, { "path": "research/community-batch932-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "cc4d03eb59b9ab3f952735f7e88ff18c2d15d7af", "sha256": "184629cac91a5cfaca50330a88596008b824221433867dcf8117539c913c284a" }, { "path": "research/community-batch970-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8b9f4111badf7de5d97684799560b55110e9da79", "sha256": "23188ed920e38a54006cb883e181585620821c63bf7e8b5e05d32719417cc37e" }, { "path": "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "a5300d4e7a5381a3f443fc54c768ca6f0f236d68", "sha256": "3c820fb30e1b4d9bcfc6a7ab524375e5b2abd66b940af2c509146104f0bcd79c" }, { "path": "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "usage": "input", + "usage": "provenance", "git_blob": "d7ff6d777b01d69b6ce84caf25d3b7e4a4d2f211", "sha256": "6b185a9902652f893f3ebd8ada92d2f11b6de6533a9a4d11718a8a4496101128" }, { "path": "research/community-hyperplane599-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "546f37d326d10a99910ae8f908e71ef768524d98", "sha256": "65099d764bfcc39bda5e4d9966783611b094c3522dbdd1435cd498d657a8ef8e" }, { "path": "research/community-k492-audit/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "e538481e4cb16ed936d3195f2dfb5b5a9ca0a76b", "sha256": "2c0f4fa5bc150d05658af2e7c54c4d2c337dd52b7efd3d69530ae73bcbdf452a" }, { "path": "research/community-reconciliation92-audit/MANIFEST.json", - "usage": "input", + "usage": "provenance", "git_blob": "2a2e93685173d5f13cbb5abe740f5d90352e0228", "sha256": "5f501f3c118131e7d069f30ad77186eb2ad6961f9680a0ef105f4514ed41808a" }, { "path": "research/partial-swap-digest/baseline.py", - "usage": "input", + "usage": "provenance", "git_blob": "a2f0190704db83bd8ef48e46e723c49b925804fe", "sha256": "81e9af92cdf38243a540cdcff2062778e449467848d444da37a9553c12ca4c34" }, { "path": "research/r420-two-sided-basis/SOURCES.json", - "usage": "input", + "usage": "provenance", "git_blob": "5d718e11e62f4bcadecf1e02d6b61f87dbe190b0", "sha256": "d9810b0d139c5a1211fd2c1f0d142187cc1fca30026e1e7bc4f9ecfacf1596d1" }, { "path": "research/skip-clones/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "8d1bb3b9c8189e35e5d8bfdfa632d7473e8be0d5", "sha256": "0b68e63e35a97ce6b0cdb6e291b88ebaa8f2dd4afb70b2498f10ee89428258dc" }, { "path": "research/split-skip/SOURCE.json", - "usage": "input", + "usage": "provenance", "git_blob": "2ab610b6ea2edd2865fda793ef2168b0c76afb4f", "sha256": "7c2b4646a3ecfef6f881da5c43e4bd0fa9a4d1b00548b8ab458d897e16735134" }, { "path": "scripts/historical-ci-inputs/Makefile", - "usage": "input", + "usage": "provenance", "git_blob": "aff68409021c9d401a6f8013b9dfd7dbcc30f2a8", "sha256": "ea8830dd79da493e2d75baf753d733ff7efbcf2b4794afe41fae0ac8f3055646" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "65db599ab0b1dea0312c4ca048e0bd0f44c3736f", "sha256": "96ea543e6c707424afe247e77bd86c82152f90fc76a0773c4232145da5cdf8d1" }, { "path": "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "34820a8f24678f918f4d0e7a35380d8013fc3495", "sha256": "628391b6abfbc8674ceec1751867a4392f2cc0b5b66886243e139af86cf355ac" }, { "path": "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "c755b76e0d44ba4917aa94440ebe54daefce5b2a", "sha256": "d7fd929726b326aeeaf0a3996475adec88eee9aac09ae0bebeeaa0bc1fc8f199" }, { "path": "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "usage": "input", + "usage": "provenance", "git_blob": "7f3c012504187917a728b9fe87043f0fc8cd006a", "sha256": "a854022e0e1d5d4db4d60e586be3ea56005013ef14a1fc06d02bc06e8529c4b0" }, { "path": "scripts/historical-ci-inputs/partial-swap-context.json", - "usage": "input", + "usage": "provenance", "git_blob": "ad65114886bf34a4fd27e79f3be502389e689faa", "sha256": "833a9642f33aeab2ffea17ec9c6b82e0a953f90192b2c82e10bef21538dccba9" }, { "path": "scripts/historical-ci-inputs/partial-swap-network.json", - "usage": "input", + "usage": "provenance", "git_blob": "52075f2463f60af5e16571347f24274fce73a1ea", "sha256": "f3c4be597b2f2136da4ae2cc80c7454f63c90aa01f84e5b8131cee4dd55de815" }, { "path": "scripts/partial_swap/shared.py", - "usage": "input", + "usage": "provenance", "git_blob": "44a0e454c70f9c4b98e258b8443612e6a119904b", "sha256": "5a0646a50b9f3e8ea55168620a78e8853b0ab810517cefc8cfb8696aedee278a" }, { "path": "scripts/replay_historical_check.py", - "usage": "input", + "usage": "provenance", "git_blob": "1e92fff2782970ef71378f594f2350d245a4db26", "sha256": "5467619c78183d3adc82b0cb55af28e5c1a01fca2b0588677816244b53e2bafd" }, { "path": "scripts/research_package.py", - "usage": "input", + "usage": "provenance", "git_blob": "091b4c8f58bac9a9580d76025b887dc5c873d05f", "sha256": "e1256016e7f51827d04fa2179255989f639ae1d97afaa9c16265f85a0c6abd70" }, { "path": "scripts/run_isolated_tests.py", - "usage": "input", + "usage": "provenance", "git_blob": "a96ab35b315ce492e7fbbfd6c5ae211aa066b541", "sha256": "49eb56dd0fc0d8d8ffdb209970a7adf2176223580646f575d5c22e59543b381c" }, { "path": "scripts/verify_selected_result.py", - "usage": "input", + "usage": "provenance", "git_blob": "6882a4700e410dec569b51ae2eaf1a19cc019195", "sha256": "d6b305eac5b9bdb8172c469ad30a1655a60fa0aceac8b1bf610e1b73f51babd8" }, { "path": "tests/test_isolated_test_runner.py", - "usage": "input", + "usage": "provenance", "git_blob": "343b24abf6719b81805eba5a84c74e57634c8288", "sha256": "3a5470d0b139828b90e19bf9583ddeafcd69f8e34f2824664eb3a2958a52e34d" } diff --git a/research/historical-selected-replay-gap/VERIFY.json b/research/historical-selected-replay-gap/VERIFY.json index 98553e72ed..ab7efa3471 100644 --- a/research/historical-selected-replay-gap/VERIFY.json +++ b/research/historical-selected-replay-gap/VERIFY.json @@ -4,36 +4,7 @@ "python": "3.12", "requirements": [], "inputs": [ - "Makefile", - "certificates/partial-swap-network.json", - "docs/ci-verification.md", - "research/clifford-state-performance/SOURCE.json", - "research/community-batch1047-audit/CONTENT-COVERAGE.json", - "research/community-batch1099-audit/CONTENT-COVERAGE.json", - "research/community-batch932-audit/CONTENT-COVERAGE.json", - "research/community-batch970-audit/CONTENT-COVERAGE.json", - "research/community-frontier741-audit/CONTENT-COVERAGE.json", - "research/community-frontier890-audit/CONTENT-COVERAGE.json", - "research/community-hyperplane599-audit/SOURCE.json", - "research/community-k492-audit/SOURCE.json", - "research/community-reconciliation92-audit/MANIFEST.json", - "research/partial-swap-digest/baseline.py", - "research/r420-two-sided-basis/SOURCES.json", - "research/skip-clones/SOURCE.json", - "research/split-skip/SOURCE.json", - "scripts/historical-ci-inputs/Makefile", - "scripts/historical-ci-inputs/ledger-batch932-run_isolated_tests.py", - "scripts/historical-ci-inputs/ledger-batch932-test_isolated_test_runner.py", - "scripts/historical-ci-inputs/ledger-batch970-verify_selected_result.py", - "scripts/historical-ci-inputs/ledger-frontier741-ci-verification.md", - "scripts/historical-ci-inputs/partial-swap-context.json", - "scripts/historical-ci-inputs/partial-swap-network.json", - "scripts/partial_swap/shared.py", - "scripts/replay_historical_check.py", - "scripts/research_package.py", - "scripts/run_isolated_tests.py", - "scripts/verify_selected_result.py", - "tests/test_isolated_test_runner.py" + "scripts/research_package.py" ], "commands": [ { diff --git a/research/historical-selected-replay-gap/verify.py b/research/historical-selected-replay-gap/verify.py index 83b995941a..9d266c5a4e 100644 --- a/research/historical-selected-replay-gap/verify.py +++ b/research/historical-selected-replay-gap/verify.py @@ -6,8 +6,10 @@ """ import hashlib import importlib.util +import json import subprocess import sys +import tempfile from pathlib import Path ROOT = Path(__file__).resolve().parents[2] @@ -61,31 +63,47 @@ def require(ok, message): raise SystemExit(message) -def load_checker(): - path = ROOT / "scripts/replay_historical_check.py" - spec = importlib.util.spec_from_file_location("historical_selected_replay_gap_checker", path) +def load_module(path): + spec = importlib.util.spec_from_file_location(path.stem, path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module +def checkout_snapshot(snapshot, sources, runner, env): + paths = [runner.canonical_relative_path(row["path"]) for row in sources["files"]] + git = ["git", "-c", "maintenance.auto=false", "-c", "gc.auto=0", + "-c", "core.autocrlf=false"] + subprocess.run([*git, "clone", "--quiet", "--shared", "--no-tags", "--no-checkout", + "--", str(ROOT), str(snapshot)], cwd=ROOT, env=env, check=True) + subprocess.run([*git, "update-ref", "--no-deref", "HEAD", INSPECTED], + cwd=snapshot, env=env, check=True) + # The pinned planner reads omitted manifests from the sparse HEAD/index. + patterns = "".join(f"/{path.as_posix()}\n" for path in paths) + subprocess.run([*git, "sparse-checkout", "set", "--no-cone", "--stdin"], + cwd=snapshot, env=env, input=patterns.encode("utf-8"), check=True) + subprocess.run([*git, "read-tree", "-mu", "HEAD"], cwd=snapshot, env=env, check=True) + for path, row in zip(paths, sources["files"], strict=True): + require(hashlib.sha256((snapshot / path).read_bytes()).hexdigest() == row["sha256"], + "historical checkout source digest changed: " + path.as_posix()) + + def entries(checker): for name, config in checker.CONFIG.items(): for entry in [config, *config.get("additional_inputs", [])]: yield name, entry -def reject(checker, entry): +def reject(root, checker, entry): try: - checker.authenticated_input(ROOT, entry) + checker.authenticated_input(root, entry) except ValueError as exc: return str(exc) raise SystemExit("historical input was admitted: " + entry["path"]) -def main(): - require(not sys.flags.optimize, "assertions must stay enabled") - checker = load_checker() +def check_snapshot(root, env): + checker = load_module(root / "scripts/replay_historical_check.py") selected = [entry for name, entry in entries(checker) if name == "tooling-ledger" and entry["path"] == SELECTED_PATH] require(len(selected) == 1, "selected-result checker overlay is not unique") @@ -94,7 +112,7 @@ def main(): require(entry["accepted_live_sha256"] == [SELECTED_ACCEPTED], "accepted selected-checker successors changed") frozen = (checker.INPUTS / entry["input"]).read_bytes() - live = (ROOT / SELECTED_PATH).read_bytes() + live = (root / SELECTED_PATH).read_bytes() require(hashlib.sha256(frozen).hexdigest() == SELECTED_PIN, "frozen selected checker bytes changed") require(hashlib.sha256(live).hexdigest() == SELECTED_LIVE, "live selected checker digest changed") require(SELECTED_LIVE not in (SELECTED_PIN, SELECTED_ACCEPTED), "live checker was already admitted") @@ -102,7 +120,7 @@ def main(): # live successor, not a broken comparison. require(SELECTED_PIN in (SELECTED_PIN, *entry["accepted_live_sha256"]), "pin membership control failed") - require(reject(checker, entry) == REJECTIONS[SELECTED_PATH][1], + require(reject(root, checker, entry) == REJECTIONS[SELECTED_PATH][1], "selected checker rejection text changed") counts = {path: 0 for path in REJECTIONS} @@ -110,7 +128,7 @@ def main(): for _name, item in entries(checker): if item["path"] not in REJECTIONS: continue - message = reject(checker, item) + message = reject(root, checker, item) counts[item["path"]] += 1 messages.setdefault(item["path"], message) for path, (count, message) in REJECTIONS.items(): @@ -118,20 +136,31 @@ def main(): require(messages[path] == message, "rejection text changed for " + path) require(sum(counts.values()) == 19, "rejection total changed") ci = [item for _name, item in entries(checker) if item["path"] == CI_PATH] - require(len(ci) == 1 and hashlib.sha256((ROOT / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, + require(len(ci) == 1 and hashlib.sha256((root / CI_PATH).read_bytes()).hexdigest() == CI_LIVE, "selected CI note digest changed") diff = subprocess.check_output( - ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=ROOT, text=True) + ["git", "diff", "--name-only", PARENT, INSPECTED], cwd=root, env=env, text=True) changed = sorted(name for name in diff.splitlines() if name) require(changed == CHANGED, "inspected commit diff changed") - sys.path.insert(0, str(ROOT / "scripts")) - from research_package import plan_details - details = plan_details(ROOT, set(changed)) + planner = load_module(root / "scripts/research_package.py") + details = planner.plan_details(root, set(changed)) require([row["package"] for row in details] == PLAN_PACKAGES, "helper plan selection changed") matched = {name for row in details for names in row["causes"].values() for name in names} require(sorted(set(changed) - matched) == UNMATCHED, "unmatched plan paths changed") - require(plan_details(ROOT, set()) == [], "empty change set selected a package") + require(planner.plan_details(root, set()) == [], "empty change set selected a package") + + +def main(): + require(not sys.flags.optimize, "assertions must stay enabled") + sources = json.loads(Path(__file__).with_name("SOURCES.json").read_bytes()) + require(sources["base_commit"] == INSPECTED, "historical checkout base changed") + runner = load_module(ROOT / "scripts/research_package.py") + env = runner.git_source_env() + with tempfile.TemporaryDirectory(prefix="historical-selected-replay-") as temporary: + snapshot = Path(temporary) / "snapshot" + checkout_snapshot(snapshot, sources, runner, env) + check_snapshot(snapshot, env) print("PASS_HISTORICAL_SELECTED_REPLAY_GAP") print("selected_checker_live=" + SELECTED_LIVE) print("rejections=19 distinct_paths=7 plan_packages=9")