Repository navigation
Audit Q8 dirty spectator restoration boundary - #3906
Draft
1337isnot1337 wants to merge 1 commit into
Draft
1337isnot1337 wants to merge 1 commit into
1337isnot1337 wants to merge 1 commit into
Conversation
Contributor
|
Independent scoped audit of the Q8 dirty spectator restoration boundary at Code-disjoint checks; does not import package Defect found:
What still passes:
Not covered: new κ; formal-kernel proof; larger dirty rings beyond F₂[Q8]. This is a finite algebraic replay, not a formal proof. Adding a committed check.py#!/usr/bin/env python3
"""Code-disjoint audit of PR #3906 Q8 dirty spectator restoration boundary."""
from __future__ import annotations
import hashlib
import json
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
PKG = ROOT / "pkg"
HEAD = "c0e26ee878ffb168b3fc824cd2a3e12d68eb083f"
BASE = "20ecf2891d80b5acf18d980b2164fb44ea7faa90"
PASS_TOKEN = "PASS_Q8_DIRTY_RESTORATION_BOUNDARY"
# Quaternion basis as (sign, axis) with axes 0=1,1=i,2=j,3=k.
E1 = (1, 0)
EI = (1, 1)
EJ = (1, 2)
EK = (1, 3)
ENI = (-1, 1)
ENJ = (-1, 2)
EN1 = (-1, 0)
GROUP = tuple((s, a) for s in (1, -1) for a in range(4))
def mul_q(a, b):
sa, xa = a
sb, xb = b
s = sa * sb
if xa == 0:
return s, xb
if xb == 0:
return s, xa
if xa == xb:
return -s, 0
cycle = {(1, 2): 3, (2, 3): 1, (3, 1): 2}
if (xa, xb) in cycle:
return s, cycle[(xa, xb)]
return -s, cycle[(xb, xa)]
def xor_fs(x, y):
return x ^ y
def mul_ring(x, y):
out = set()
for p in x:
for q in y:
r = mul_q(p, q)
if r in out:
out.remove(r)
else:
out.add(r)
return frozenset(out)
def id_mat(n):
one = frozenset({E1})
z = frozenset()
return tuple(tuple(one if i == j else z for j in range(n)) for i in range(n))
def mat_mul(A, B):
n = len(A)
C = [[frozenset() for _ in range(n)] for _ in range(n)]
for i in range(n):
for k in range(n):
for j in range(n):
C[i][j] = xor_fs(C[i][j], mul_ring(A[i][k], B[k][j]))
return tuple(tuple(row) for row in C)
def mat_vec(A, v):
out = []
for row in A:
acc = frozenset()
for coef, entry in zip(row, v):
acc = xor_fs(acc, mul_ring(coef, entry))
out.append(acc)
return tuple(out)
def paid(label, u, v):
n = len(u)
assert n == len(v) and n > 0
assert sum(x * y for x, y in zip(v, u)) % 2 == 1
M = [list(r) for r in id_mat(n)]
plus = frozenset({E1, label})
for i in range(n):
for j in range(n):
if u[i] and v[j]:
M[i][j] = xor_fs(M[i][j], plus)
return tuple(tuple(r) for r in M)
def run_word(word, n):
S = id_mat(n)
for lab, u, v in word:
S = mat_mul(paid(lab, u, v), S)
return S
def want_diag(targets, n):
one = frozenset({E1})
z = frozenset()
rows = []
for i in range(n):
row = []
for j in range(n):
if i != j:
row.append(z)
elif i < len(targets):
row.append(frozenset({targets[i]}))
else:
row.append(one)
rows.append(tuple(row))
return tuple(rows)
def evec(n, at):
return tuple(1 if i == at else 0 for i in range(n))
def build_witness(targets, spectators):
n = len(targets) + spectators
w = []
for idx, t in enumerate(targets):
lab = EI if t == ENI else EJ
e = evec(n, idx)
w.extend((lab, e, e) for _ in range(3))
return n, tuple(w)
def check(name, cond):
status = "PASS" if cond else "FAIL"
print(f"[{status}] {name}")
return bool(cond)
def sha256_file(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
def main() -> int:
results: list[tuple[str, bool]] = []
sources = json.loads((PKG / "SOURCES.json").read_text(encoding="utf-8"))
task = json.loads((PKG / "TASK.json").read_text(encoding="utf-8"))
verify = json.loads((PKG / "VERIFY.json").read_text(encoding="utf-8"))
readme = (PKG / "README.md").read_text(encoding="utf-8")
results.append(("D1 RESULT.json absent (packaging)", not (PKG / "RESULT.json").exists()))
results.append(("D2 SOURCES.base_commit", sources.get("base_commit") == BASE))
results.append(("D3 TASK.base_commit", task.get("base_commit") == BASE))
cmds = verify.get("commands") or []
results.append(("D4 VERIFY.status ready + verify.py command", verify.get("status") == "ready" and any("verify.py" in " ".join(c.get("argv") or []) for c in cmds)))
vp = subprocess.run([sys.executable, "-I", "-B", str(PKG / "verify.py")], capture_output=True, text=True, timeout=120)
results.append(("D5 package verify.py emits PASS token", vp.returncode == 0 and PASS_TOKEN in vp.stdout))
results.append(("D6 TASK.outcome is partial", task.get("outcome") == "partial"))
results.append(("D7 README mentions dirty restoration / Q8", "Q8" in readme and "dirty" in readme.lower()))
# Algebra sanity (independent of package verify.py)
ok_inj = len(set(GROUP)) == 8
ok_id = all(mul_q(E1, g) == g and mul_q(g, E1) == g for g in GROUP)
ok_close = all(mul_q(a, b) in GROUP for a in GROUP for b in GROUP)
ok_assoc = all(
mul_q(mul_q(a, b), c) == mul_q(a, mul_q(b, c))
for a in GROUP for b in GROUP for c in GROUP
)
ok_neg = mul_q(mul_q(EI, EI), EI) == ENI and mul_q(mul_q(EJ, EJ), EJ) == ENJ
ok_sq = mul_q(EI, EI) == EN1 and mul_q(EJ, EJ) == EN1
results.append(("A1 Q8 injective encoding", ok_inj))
results.append(("A2 Q8 identity", ok_id))
results.append(("A3 Q8 closure", ok_close))
results.append(("A4 Q8 associativity", ok_assoc))
results.append(("A5 negative generator cubes", ok_neg))
results.append(("A6 squares to -1", ok_sq))
families = ((ENI,), (ENJ,), (ENI, ENI), (ENI, ENJ), (ENJ, ENI), (ENJ, ENJ))
case_ok = 0
for targets in families:
for spectators in range(4):
n, word = build_witness(targets, spectators)
got = run_word(word, n)
want = want_diag(targets, n)
if len(word) == 3 * len(targets) and got == want:
case_ok += 1
results.append(("C1 full-matrix endpoints 24/24", case_ok == 24))
u = (1, 1)
v = (1, 0)
leak_word = tuple((EI, u, v) for _ in range(3))
leaked = run_word(leak_word, 2)
desired = want_diag((ENI,), 2)
diag_match = all(leaked[i][i] == desired[i][i] for i in range(2))
results.append(("N1 diagonal fools checker", diag_match and leaked != desired))
results.append(("N2 leak support [1]+[zi] at (1,0)", leaked[1][0] == frozenset({E1, ENI})))
results.append(("N3 upper-right stays zero", leaked[0][1] == frozenset()))
dirty_ok = True
for h in GROUP:
initial = (frozenset({E1}), frozenset({h}))
got = mat_vec(leaked, initial)
want = mat_vec(desired, initial)
if got[0] != want[0] or got[1] == want[1]:
dirty_ok = False
break
results.append(("N4 dirty spectator not restored for all 8 basis", dirty_ok))
# Hash package files for ARTIFACTS line
digests = {p.name: sha256_file(p) for p in sorted(PKG.iterdir()) if p.is_file()}
(ROOT / "digests.json").write_text(json.dumps(digests, indent=2) + "\n", encoding="utf-8")
passed = 0
for name, cond in results:
if check(name, cond):
passed += 1
total = len(results)
print(f"SUMMARY {passed}/{total}")
(ROOT / "summary.txt").write_text(f"{passed}/{total}\n", encoding="utf-8")
return 0 if passed == total else 1
if __name__ == "__main__":
raise SystemExit(main())James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor). |
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an independent exact audit of the dirty-state boundary in the mixed-negative Q8 attainment proposal from PR #3697, pinned at
b5fa8645bff6db3ff219815e6fc820a4f08b0572.N = e_a e_a^Tmakes each three-call witness a full diagonal operator overF2[Q8]. Every non-target register remains exactly[1]for any role count.([zi],[1]), but its lower-left entry is[1]+[zi]. It passes a diagonal-only check and fails full-matrix equality; each of the eight dirty Q8 basis values changes when the target input is[1].This is a scoped verification result. It does not re-prove the inherited PR #3589 lower bound, claim a new minimum, or establish a physical supplier, invoice, or kappa change. Attribution to Nick Petalas and the PR #3570/#3578/#3589 lineage is retained in the package.
Verification
python3 scripts/research_package.py --package research/q8-dirty-restoration-boundary-audit --check-only—PASS_PACKAGE_METADATA_AND_PINS.python3.12 scripts/research_package.py --package research/q8-dirty-restoration-boundary-audit— registered replay passed, 24 exact endpoint cases and the negative control.python3 -O -B research/q8-dirty-restoration-boundary-audit/verify.py— passed under optimized Python.python3 -B scripts/check_research_commit.py --package research/q8-dirty-restoration-boundary-audit— committed-byte check passed for all five files.--check-source-historymode could not run because this sparse worktree does not contain full Git history.Base:
20ecf2891d80b5acf18d980b2164fb44ea7faa90; priority revision 6. Local commit:c0e26ee878ffb168b3fc824cd2a3e12d68eb083f.Publication validation
The registered package replay passed on CPython 3.12.3 with
python3.12 scripts/research_package.py --package research/q8-dirty-restoration-boundary-audit. The optional--check-source-historypreflight could not run because this MacBook checkout is shallow and the checker requires full Git history. This package's source manifest pins only files at its exact base commit20ecf2891d80b5acf18d980b2164fb44ea7faa90; it contains nohead:source pins. Any earlier pending note above refers to the state before this publication-time replay.