From 85cd24c361dc55876de150ab9172ab25a6087975 Mon Sep 17 00:00:00 2001 From: Wentao Li Date: Thu, 15 Oct 2026 05:26:03 +0000 Subject: [PATCH 1/3] Tooling: ship Clifford gate-table zero_state into production multicold evaluator Wire the proved exact permutation/phase tables from research/clifford-state-performance/ into the multicold clifford_exact.py used by scripts/verify_cold617_interface.py. Vendor pairwise-era bytes as baseline.py; demote the opt-in live pin; honestly refresh research/clifford-reciprocal-basis-obstruction's clifford_exact pin. Prepared by Wentao Li with substantial AI assistance. --- .../CERTIFICATE.json | 2 +- .../SOURCES.json | 5 +- research/clifford-state-performance/README.md | 8 +- .../clifford-state-performance/SOURCE.json | 10 +- .../clifford-state-performance/baseline.py | 149 +++++++++++ research/clifford-state-performance/common.py | 10 +- research/clifford-state-performance/run.py | 4 +- research/clifford-state-production/NOTICE.md | 17 ++ research/clifford-state-production/README.md | 99 ++++++++ .../clifford-state-production/SOURCES.json | 80 ++++++ research/clifford-state-production/TASK.json | 70 ++++++ .../clifford-state-production/VERIFY.json | 30 +++ .../clifford-state-production/baseline.py | 149 +++++++++++ .../clifford-state-production/benchmark.py | 171 +++++++++++++ research/clifford-state-production/verify.py | 234 ++++++++++++++++++ .../vendor/clifford/clifford_exact.py | 50 +++- tests/test_clifford_state_production.py | 40 +++ 17 files changed, 1115 insertions(+), 13 deletions(-) create mode 100644 research/clifford-state-performance/baseline.py create mode 100644 research/clifford-state-production/NOTICE.md create mode 100644 research/clifford-state-production/README.md create mode 100644 research/clifford-state-production/SOURCES.json create mode 100644 research/clifford-state-production/TASK.json create mode 100644 research/clifford-state-production/VERIFY.json create mode 100644 research/clifford-state-production/baseline.py create mode 100644 research/clifford-state-production/benchmark.py create mode 100644 research/clifford-state-production/verify.py create mode 100644 tests/test_clifford_state_production.py diff --git a/research/clifford-reciprocal-basis-obstruction/CERTIFICATE.json b/research/clifford-reciprocal-basis-obstruction/CERTIFICATE.json index c4fbc9aa55..1194143c0e 100644 --- a/research/clifford-reciprocal-basis-obstruction/CERTIFICATE.json +++ b/research/clifford-reciprocal-basis-obstruction/CERTIFICATE.json @@ -2,7 +2,7 @@ "schema_version": 1, "scope": "Written all-size characteristic-zero proof; finite evidence is not a kernel theorem or physical supplier.", "source_sha256": { - "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "9b360d58055de706a27abe5211a14115225e47f0c6096e4fb8818e99a4772abd", "research/selector-batching/README.md": "e50bae87f9bfa2dee515468aeb56d47676410ca3adfdf0e83d11bf0e31fadf2d" }, "uniform": { diff --git a/research/clifford-reciprocal-basis-obstruction/SOURCES.json b/research/clifford-reciprocal-basis-obstruction/SOURCES.json index 5b3151ca64..314cfaa0d8 100644 --- a/research/clifford-reciprocal-basis-obstruction/SOURCES.json +++ b/research/clifford-reciprocal-basis-obstruction/SOURCES.json @@ -17,8 +17,9 @@ { "path": "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", "usage": "input", - "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", - "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + "git_blob": "e17f3426fb50fbbaa7e89c4b81a4297b91defd0c", + "sha256": "9b360d58055de706a27abe5211a14115225e47f0c6096e4fb8818e99a4772abd", + "note": "Honest refresh after research/clifford-state-production/ gate-table zero_state; receipts unchanged." }, { "path": "research/selector-batching/README.md", diff --git a/research/clifford-state-performance/README.md b/research/clifford-state-performance/README.md index 797b54ced7..e7f6fe4eed 100644 --- a/research/clifford-state-performance/README.md +++ b/research/clifford-state-performance/README.md @@ -4,9 +4,15 @@ This optional adapter accelerates the complete selected helper-interface check b Seven alternating pairs give median times of **1.289 seconds** and **0.460 seconds**. Every output receipt matches the original byte for byte. +After `research/clifford-state-production/`, the multicold production +`clifford_exact.py` ships the same gate-table `zero_state`. This package vendors +the pairwise-era bytes as `baseline.py` and pins production separately so +opt-in differential replay does not fail working-source drift. + The change affects verification speed only. The selected conditional bound remains `51110230636731/31250000000000000`. -No frozen source, selected certificate, circuit, or default verification command changes. +No selected certificate, circuit, or default verification command changes beyond +the production evaluator wiring above. ## Reproduce diff --git a/research/clifford-state-performance/SOURCE.json b/research/clifford-state-performance/SOURCE.json index 6f98a0061a..743b358d3c 100644 --- a/research/clifford-state-performance/SOURCE.json +++ b/research/clifford-state-performance/SOURCE.json @@ -1,13 +1,15 @@ { "base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60", - "clifford": "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", + "clifford": "research/clifford-state-performance/baseline.py", + "production_clifford": "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", "checker": "scripts/verify_cold617_interface.py", "runs": [ "research/community-k492-audit/pr622/replay/ck-local", "research/community-k492-audit/pr622/replay/jp8-local" ], "files": { - "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "research/clifford-state-performance/baseline.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "9b360d58055de706a27abe5211a14115225e47f0c6096e4fb8818e99a4772abd", "scripts/verify_cold617_interface.py": "95d7a9094c05ad975fb72f5ab7605593003245a503c8456764987e512028fa6a", "scripts/verify_hpe_lean_binding.py": "52aa1d23641e4c716b43c98f6b883ad042087dd03a9d01369e8e6a735b07aa03", "research/hyperplane-end-lean/HyperplaneEnd/Exact.lean": "eebf3a3982af7ab9be45777b272a6aaa523206fa7667ceb6df63ad6589fd8183", @@ -17,5 +19,9 @@ "research/community-k492-audit/pr622/replay/jp8-local/CANONICAL-WORD.json.gz": "7a3fec1022d3b2b1bd986302a327735ec521d17b043f4a5acb96253a56f6193c", "research/community-k492-audit/pr622/replay/jp8-local/RESIDUAL-ADAPTERS.json": "bdb44cf523636f307ebb3617da548f2e3a8af74321eabe24aef40186e280a917" }, + "provenance_sha256": { + "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py@pre-production": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + "note": "After research/clifford-state-production/, working multicold clifford_exact.py is the gate-table production source. baseline.py vendors the pairwise-era bytes; the opt-in adapter compares baseline vs fast_state / production without re-transforming production.", "expected_receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c" } diff --git a/research/clifford-state-performance/baseline.py b/research/clifford-state-performance/baseline.py new file mode 100644 index 0000000000..166841a037 --- /dev/null +++ b/research/clifford-state-performance/baseline.py @@ -0,0 +1,149 @@ +"""Small exact Gaussian-dyadic Clifford compiler, independent of gx internals. +Paulis use i^p X^x Z^z. State vectors use integer Gaussian numerators / 2^d. +The tableau is supplemented by a literal circuit, so global phases are kept. +""" +from dataclasses import dataclass + +def parity(x):return x.bit_count()&1 +def rank(rows): + p={} + for x in rows: + while x: + b=x.bit_length()-1 + if b not in p:p[b]=x;break + x^=p[b] + return len(p) +def transpose(rows,n):return tuple(sum(((rows[j]>>i)&1)<>j&1);a[j],a[k]=a[k],a[j] + for i in range(n): + if i!=j and a[i]>>j&1:a[i]^=a[j] + assert [r&((1<>n for r in a) +def basis_extend(cols,n): + out=[] + for x in list(cols)+[1<len(out):out.append(x) + assert len(out)==n + return tuple(out) +def nullspace(rows,n): + a=list(rows);p=[];k=0 + for j in range(n): + t=next((i for i in range(k,len(a)) if a[i]>>j&1),None) + if t is None:continue + a[t],a[k]=a[k],a[t] + for i in range(len(a)): + if i!=k and a[i]>>j&1:a[i]^=a[k] + p.append(j);k+=1 + return tuple((1<>j)&1)<>i&1:out=pmul(out,T[i]) + for i in range(n): + if z>>i&1:out=pmul(out,T[n+i]) + return out +def compose(A,B):return tuple(apply(A,p) for p in B) +def inverse(T): + n=len(T)//2;cols=[x|(z<>n;u,v,p=apply(T,(x,z,0));assert (u,v)==identity(n)[j][:2];out.append((x,z,(-p)%4)) + return tuple(out) +def qvalue(Q,alpha,x,n): + return (sum(alpha[i] for i in range(n) if x>>i&1)+2*sum(parity((Q[i]>>(i+1))&(x>>(i+1))) for i in range(n) if x>>i&1))%4 +def mul_i(a,p): + x,y=a;p%=4 + return [(x,y),(-y,x),(-x,-y),(y,-x)][p] +@dataclass +class Op: + n:int + tab:tuple + circuit:list + def then(self,b): + assert self.n==b.n + return Op(self.n,compose(b.tab,self.tab),self.circuit+b.circuit) + def adjoint(self): + circ=[] + for e in reversed(self.circuit): + if e[0]=='P':circ.append(('P',inv(e[1],self.n))) + elif e[0]=='D':circ.append(('D',e[1],tuple((-x)%4 for x in e[2]))) + elif e[0]=='C':circ.append(('C',e[1],-e[2])) + elif e[0]=='phase':circ.append(('phase',(-e[1])%4)) + else:circ.append(e) + return Op(self.n,inverse(self.tab),circ) + def zero_state(self,basis=0): + N=1<>i)&1 for i in range(n)) + assert all(alpha[i]%2==(Q[i]>>i)&1 for i in range(n)) + return Op(n,tuple([(1<>i&1 else 0,1<>i&1 else 0) for i in range(n)]),[('C',q,sgn)]) +def xgate(n,b):return Op(n,tuple([(1<>i)&1)) for i in range(n)]),[('X',b)]) +def fourier(n,axes=None): + out=ident(n) + for i in range(n) if axes is None else axes:out=out.then(cgate(n,1<len(selected):picks.append(j);selected.append(x) + assert len(picks)==r and all(x>>r==0 for x in Bcols) + Br=transpose(selected,r);Bi=inv(Br,r);Dr=transpose([Dcols[j]&((1<>i)&1)<>j&1);a[j],a[k]=a[k],a[j] + for i in range(n): + if i!=j and a[i]>>j&1:a[i]^=a[j] + assert [r&((1<>n for r in a) +def basis_extend(cols,n): + out=[] + for x in list(cols)+[1<len(out):out.append(x) + assert len(out)==n + return tuple(out) +def nullspace(rows,n): + a=list(rows);p=[];k=0 + for j in range(n): + t=next((i for i in range(k,len(a)) if a[i]>>j&1),None) + if t is None:continue + a[t],a[k]=a[k],a[t] + for i in range(len(a)): + if i!=k and a[i]>>j&1:a[i]^=a[k] + p.append(j);k+=1 + return tuple((1<>j)&1)<>i&1:out=pmul(out,T[i]) + for i in range(n): + if z>>i&1:out=pmul(out,T[n+i]) + return out +def compose(A,B):return tuple(apply(A,p) for p in B) +def inverse(T): + n=len(T)//2;cols=[x|(z<>n;u,v,p=apply(T,(x,z,0));assert (u,v)==identity(n)[j][:2];out.append((x,z,(-p)%4)) + return tuple(out) +def qvalue(Q,alpha,x,n): + return (sum(alpha[i] for i in range(n) if x>>i&1)+2*sum(parity((Q[i]>>(i+1))&(x>>(i+1))) for i in range(n) if x>>i&1))%4 +def mul_i(a,p): + x,y=a;p%=4 + return [(x,y),(-y,x),(-x,-y),(y,-x)][p] +@dataclass +class Op: + n:int + tab:tuple + circuit:list + def then(self,b): + assert self.n==b.n + return Op(self.n,compose(b.tab,self.tab),self.circuit+b.circuit) + def adjoint(self): + circ=[] + for e in reversed(self.circuit): + if e[0]=='P':circ.append(('P',inv(e[1],self.n))) + elif e[0]=='D':circ.append(('D',e[1],tuple((-x)%4 for x in e[2]))) + elif e[0]=='C':circ.append(('C',e[1],-e[2])) + elif e[0]=='phase':circ.append(('phase',(-e[1])%4)) + else:circ.append(e) + return Op(self.n,inverse(self.tab),circ) + def zero_state(self,basis=0): + N=1<>i)&1 for i in range(n)) + assert all(alpha[i]%2==(Q[i]>>i)&1 for i in range(n)) + return Op(n,tuple([(1<>i&1 else 0,1<>i&1 else 0) for i in range(n)]),[('C',q,sgn)]) +def xgate(n,b):return Op(n,tuple([(1<>i)&1)) for i in range(n)]),[('X',b)]) +def fourier(n,axes=None): + out=ident(n) + for i in range(n) if axes is None else axes:out=out.then(cgate(n,1<len(selected):picks.append(j);selected.append(x) + assert len(picks)==r and all(x>>r==0 for x in Bcols) + Br=transpose(selected,r);Bi=inv(Br,r);Dr=transpose([Dcols[j]&((1< dict: + image = BASELINE if engine == "baseline" else PRODUCTION + original = PRODUCTION.read_bytes() + PRODUCTION.write_bytes(image.read_bytes()) + try: + start = time.perf_counter() + proc = subprocess.run( + [ + sys.executable, + "-B", + str(CHECKER), + str(RUNS[0]), + str(RUNS[1]), + "--entering", + "36", + "--cold", + "22", + "--out", + str(out), + ], + cwd=ROOT, + env=clean_env(), + capture_output=True, + text=True, + ) + elapsed = time.perf_counter() - start + finally: + PRODUCTION.write_bytes(original) + if proc.returncode != 0: + raise SystemExit(f"{engine} failed\n{proc.stderr}\n{proc.stdout}") + receipt = out.read_bytes() + digest = sha256(receipt).hexdigest() + if digest != RECEIPT_SHA256: + raise SystemExit(f"{engine} receipt digest {digest} != {RECEIPT_SHA256}") + return {"elapsed": elapsed, "receipt_sha256": digest, "receipt_bytes": len(receipt)} + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--rounds", type=int, default=5) + parser.add_argument( + "--write-result", + action="store_true", + help="write RESULT.json (default prints only; use explicitly to refresh the artifact)", + ) + parser.add_argument("--out", type=Path, help="optional explicit RESULT.json path") + args = parser.parse_args(argv) + if args.rounds < 3: + raise SystemExit("Use at least three alternating rounds") + + records = [] + with __import__("tempfile").TemporaryDirectory(prefix="clifford-state-bench-") as tmp: + tmp_path = Path(tmp) + for pair in range(args.rounds): + order = ("baseline", "production") if pair % 2 == 0 else ("production", "baseline") + outputs = {} + for engine in order: + row = run_workload(engine, tmp_path / f"{pair}-{engine}.json") + records.append( + { + "pair": pair, + "engine": engine, + "seconds": row["elapsed"], + "receipt_sha256": row["receipt_sha256"], + } + ) + outputs[engine] = row["receipt_sha256"] + print( + f"pair={pair} engine={engine} seconds={row['elapsed']:.6f}", + flush=True, + ) + if outputs["baseline"] != outputs["production"]: + raise SystemExit(f"pair {pair} receipts differ") + + medians = { + engine: statistics.median(r["seconds"] for r in records if r["engine"] == engine) + for engine in ("baseline", "production") + } + speedup = medians["baseline"] / medians["production"] + result = { + "status": "PASS_IDENTICAL_CLIFFORD_STATE_PRODUCTION_RECEIPTS", + "no_new_kappa": True, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "fixture": { + "checker": "scripts/verify_cold617_interface.py", + "runs": [str(p.relative_to(ROOT)) for p in RUNS], + "entering": 36, + "cold": 22, + "receipt_sha256": RECEIPT_SHA256, + }, + "production": str(PRODUCTION.relative_to(ROOT)), + "baseline": str(BASELINE.relative_to(PACKAGE)), + "rounds": args.rounds, + "alternating_order": True, + "medians_seconds": medians, + "speedup": speedup, + "samples": records, + "environment": { + "python": sys.version, + "platform": platform.platform(), + "executable": sys.executable, + }, + } + text = json.dumps(result, indent=2, sort_keys=True) + "\n" + print( + f"PASS_IDENTICAL_CLIFFORD_STATE_PRODUCTION_RECEIPTS " + f"median {medians['baseline']:.6f} -> {medians['production']:.6f} " + f"({speedup:.3f}×)", + flush=True, + ) + if args.write_result or args.out: + target = args.out or (PACKAGE / "RESULT.json") + if target.exists() and not args.write_result: + raise SystemExit(f"refusing to overwrite {target} without --write-result") + target.write_text(text, encoding="utf-8") + print(f"wrote {target}", flush=True) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/clifford-state-production/verify.py b/research/clifford-state-production/verify.py new file mode 100644 index 0000000000..6b730c7e01 --- /dev/null +++ b/research/clifford-state-production/verify.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +"""Equivalence, rejection and receipt controls for production Clifford gate tables. + +Read-only by default. Timing is not a pass gate; see benchmark.py / RESULT.json. +""" +from __future__ import annotations + +import argparse +from hashlib import sha256 +import importlib.util +import json +import os +from pathlib import Path +import subprocess +import sys +import tempfile + +ROOT = Path(__file__).resolve().parents[2] +PACKAGE = Path(__file__).resolve().parent +PRODUCTION = ( + ROOT + / "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py" +) +BASELINE = PACKAGE / "baseline.py" +CHECKER = ROOT / "scripts/verify_cold617_interface.py" +RUNS = [ + ROOT / "research/community-k492-audit/pr622/replay/ck-local", + ROOT / "research/community-k492-audit/pr622/replay/jp8-local", +] + +BASE_COMMIT = "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2" +ORIGINAL_BLOB = "166841a037f069249f6f7f6dedb89248812f59e2" +ORIGINAL_SHA256 = "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" +OPTIMIZED_SHA256 = "9b360d58055de706a27abe5211a14115225e47f0c6096e4fb8818e99a4772abd" +RECEIPT_SHA256 = "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c" + + +def require(condition, message): + if not condition: + raise AssertionError(message) + + +def digest_file(path: Path) -> str: + return sha256(path.read_bytes()).hexdigest() + + +def unique_object(pairs): + out = {} + for key, value in pairs: + require(key not in out, f"duplicate JSON key: {key}") + out[key] = value + return out + + +def load_module(path: Path, name: str): + spec = importlib.util.spec_from_file_location(name, path) + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +def check_baseline_bytes() -> None: + original = subprocess.check_output( + [ + "git", + "show", + f"{BASE_COMMIT}:research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", + ], + cwd=ROOT, + ) + require(sha256(original).hexdigest() == ORIGINAL_SHA256, "base clifford_exact.py sha256 drift") + blob = ( + subprocess.check_output( + [ + "git", + "rev-parse", + f"{BASE_COMMIT}:research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", + ], + cwd=ROOT, + ) + .decode() + .strip() + ) + require(blob == ORIGINAL_BLOB, "base clifford_exact.py blob drift") + require(BASELINE.read_bytes() == original, "baseline.py must equal the base-commit clifford_exact.py") + require( + digest_file(PRODUCTION) == OPTIMIZED_SHA256, + "production clifford_exact.py does not match the claimed optimized digest", + ) + require(PRODUCTION.read_bytes() != original, "production must differ from the pairwise baseline") + + +def sample_ops(clifford): + ops = [clifford.ident(n) for n in (1, 2, 3, 4)] + for n in (2, 3, 4): + ops.append(clifford.perm(n, tuple(1 << i for i in range(n)))) + ops.append(clifford.diag(n, tuple(1 << i for i in range(n)))) + ops.append(clifford.cgate(n, 1)) + ops.append(clifford.xgate(n, 1)) + ops.append(clifford.hadamard(n, [0])) + ops.append(clifford.canonical_frame(n, [1])) + ops.append(clifford.fourier(n)) + return ops + + +def check_state_equivalence() -> dict: + baseline = load_module(BASELINE, "clifford_state_production_baseline") + production = load_module(PRODUCTION, "clifford_state_production_live") + comparisons = 0 + for op in sample_ops(baseline): + twin = production.Op(op.n, op.tab, list(op.circuit)) + for basis in range(min(1 << op.n, 4)): + require(op.zero_state(basis) == twin.zero_state(basis), "zero_state mismatch") + comparisons += 1 + # Exercise paths that call zero_state inside the compiler helpers. + for n in (2, 3): + frame = baseline.canonical_frame(n, [1]) + twin = production.Op(frame.n, frame.tab, list(frame.circuit)) + require(frame.zero_state() == twin.zero_state(), "canonical_frame state mismatch") + comparisons += 1 + return {"state_comparisons": comparisons} + + +def clean_env(): + env = {k: v for k, v in os.environ.items() if k != "PYTHONOPTIMIZE"} + env["PYTHONDONTWRITEBYTECODE"] = "1" + env["MULTICOLD_SOURCE"] = str(ROOT / "research/complex-multicold") + return env + + +def run_helper_interface(clifford_bytes: bytes, out: Path) -> bytes: + """Run the helper-interface checker against an on-disk clifford_exact image. + + Launches an asserting child (`python -B`, never `-O` / PYTHONOPTIMIZE) so + package gates under `-O` still exercise the historical checker asserts. + Note: this host's CPython `-I` omits the script directory from ``sys.path``, + so sibling imports inside ``scripts/`` require a non-isolated child. + """ + original = PRODUCTION.read_bytes() + PRODUCTION.write_bytes(clifford_bytes) + try: + proc = subprocess.run( + [ + sys.executable, + "-B", + str(CHECKER), + str(RUNS[0]), + str(RUNS[1]), + "--entering", + "36", + "--cold", + "22", + "--out", + str(out), + ], + cwd=ROOT, + env=clean_env(), + capture_output=True, + text=True, + ) + require( + proc.returncode == 0, + f"helper-interface failed\n{proc.stderr}\n{proc.stdout}", + ) + return out.read_bytes() + finally: + PRODUCTION.write_bytes(original) + + +def check_helper_receipts() -> dict: + with tempfile.TemporaryDirectory(prefix="clifford-state-prod-") as tmp: + base_out = Path(tmp) / "base.json" + prod_out = Path(tmp) / "prod.json" + base_receipt = run_helper_interface(BASELINE.read_bytes(), base_out) + prod_receipt = run_helper_interface(PRODUCTION.read_bytes(), prod_out) + require(base_receipt == prod_receipt, "helper-interface receipts differ") + require(sha256(prod_receipt).hexdigest() == RECEIPT_SHA256, "helper-interface receipt digest drift") + payload = json.loads(prod_receipt.decode(), object_pairs_hook=unique_object) + require( + payload["status"] == "PASS_FINITE_MULTI_TAIL_AND_EXACT_WRAPPER_BINDING", + "unexpected helper-interface status", + ) + require(len(payload["instances"]) == 2, "expected ck and jp8 instances") + return { + "receipt_sha256": RECEIPT_SHA256, + "instances": len(payload["instances"]), + "status": payload["status"], + } + + +def check_temp_corruption_rejection() -> dict: + """On-disk foil that skips permutation remapping must diverge.""" + honest = None + with tempfile.TemporaryDirectory(prefix="clifford-state-prod-honest-") as tmp: + honest = run_helper_interface(PRODUCTION.read_bytes(), Path(tmp) / "honest.json") + text = PRODUCTION.read_text(encoding="utf-8") + needle = " for x,a in enumerate(vec):v[mapping[x]]=a\n" + require(needle in text, "permutation remap site missing for corruption control") + foil = " for x,a in enumerate(vec):v[x]=a\n" + with tempfile.TemporaryDirectory(prefix="clifford-state-prod-foil-") as tmp: + mutant_path = Path(tmp) / "clifford_exact.py" + mutant_path.write_text(text.replace(needle, foil, 1), encoding="utf-8") + require(mutant_path.read_bytes() != PRODUCTION.read_bytes(), "mutant must differ on disk") + try: + bad = run_helper_interface(mutant_path.read_bytes(), Path(tmp) / "bad.json") + except Exception as exc: # includes AssertionError from require() inside checker + return {"rejected": True, "mode": "subprocess_failure", "detail": str(exc)[:240]} + require(bad != honest, "identity-permutation foil must change the helper receipt") + return {"rejected": True, "mode": "receipt_divergence"} + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.parse_args(argv) + # -O policy: require() raises remain active; helper-interface children always use -I -B. + check_baseline_bytes() + states = check_state_equivalence() + receipts = check_helper_receipts() + corruption = check_temp_corruption_rejection() + require(corruption["rejected"], "corruption control must reject") + print( + "PASS_CLIFFORD_STATE_PRODUCTION " + f"states={states['state_comparisons']} " + f"instances={receipts['instances']} " + f"corruption={corruption['mode']} " + "certs=1 no_new_kappa", + flush=True, + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py b/research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py index 166841a037..e17f3426fb 100644 --- a/research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py +++ b/research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py @@ -1,6 +1,10 @@ """Small exact Gaussian-dyadic Clifford compiler, independent of gx internals. Paulis use i^p X^x Z^z. State vectors use integer Gaussian numerators / 2^d. The tableau is supplemented by a literal circuit, so global phases are kept. + +Production exact gate-table zero_state (identical receipts): +research/clifford-state-performance/ and research/clifford-state-production/. +Prepared by Wentao Li with substantial AI assistance. """ from dataclasses import dataclass @@ -61,6 +65,29 @@ def qvalue(Q,alpha,x,n): def mul_i(a,p): x,y=a;p%=4 return [(x,y),(-y,x),(-x,-y),(y,-x)][p] + +from functools import lru_cache + +@lru_cache(maxsize=64) +def _permutation_table(n, rows): + """Compute Gx from G(x xor lowbit(x)) xor G(lowbit(x)).""" + columns=[sum(((row>>j)&1)< Date: Thu, 15 Oct 2026 05:31:46 +0000 Subject: [PATCH 2/3] Evidence: pin RESULT and demote reciprocal clifford_exact live pin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Record pinned-CPU 3.15× helper-interface medians for clifford-state-production. Restore live-file swap + perm-foil corruption control. Demote clifford-reciprocal-basis-obstruction's multicold clifford_exact pin to provenance (drop from VERIFY inputs) so research-packages CI does not see working-source drift after the production gate-table rewrite. Prepared by Wentao Li with substantial AI assistance. --- .../CERTIFICATE.json | 1 - .../README.md | 11 ++- .../SOURCES.json | 8 +- .../VERIFY.json | 1 - .../test_verify.py | 19 +++- .../verify.py | 4 +- research/clifford-state-production/README.md | 13 ++- .../clifford-state-production/RESULT.json | 91 +++++++++++++++++++ research/clifford-state-production/TASK.json | 2 +- .../clifford-state-production/benchmark.py | 5 + research/clifford-state-production/verify.py | 26 +++--- 11 files changed, 150 insertions(+), 31 deletions(-) create mode 100644 research/clifford-state-production/RESULT.json diff --git a/research/clifford-reciprocal-basis-obstruction/CERTIFICATE.json b/research/clifford-reciprocal-basis-obstruction/CERTIFICATE.json index 1194143c0e..7265413a08 100644 --- a/research/clifford-reciprocal-basis-obstruction/CERTIFICATE.json +++ b/research/clifford-reciprocal-basis-obstruction/CERTIFICATE.json @@ -2,7 +2,6 @@ "schema_version": 1, "scope": "Written all-size characteristic-zero proof; finite evidence is not a kernel theorem or physical supplier.", "source_sha256": { - "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "9b360d58055de706a27abe5211a14115225e47f0c6096e4fb8818e99a4772abd", "research/selector-batching/README.md": "e50bae87f9bfa2dee515468aeb56d47676410ca3adfdf0e83d11bf0e31fadf2d" }, "uniform": { diff --git a/research/clifford-reciprocal-basis-obstruction/README.md b/research/clifford-reciprocal-basis-obstruction/README.md index 6aff66509d..07f948ad0f 100644 --- a/research/clifford-reciprocal-basis-obstruction/README.md +++ b/research/clifford-reciprocal-basis-obstruction/README.md @@ -6,6 +6,11 @@ higher-rank tensor Clifford child into independent equal-width children with the same direction. This holds for every invertible linear basis, including nonmonomial bases, and for arbitrary dirty padding that must be restored. +**Status note:** production multicold `clifford_exact.py` now ships gate-table +`zero_state` (`research/clifford-state-production/`). This package keeps the +pairwise-era digest as provenance only and drops that path from VERIFY inputs; +`dense.py` still loads the working oracle for native column cross-checks. + The direction premise is essential: two opposite-direction width-f lanes are similar to a phase times a width-(f+1) tensor child exactly when f is odd. We give actual rational encoding/decoding matrices. Even with those conversions @@ -20,8 +25,10 @@ Work over any characteristic-zero field K containing i, with i²=-1. Let `C = ((1+i)I + (1-i)X)/2`, `X = [[0,1],[1,0]]`, and `C_f = C^⊗f`. Thus C has eigenvalues 1 and i, C²=X and C⁴=I. An inverse child is C_f⁻¹. -The source kernel in [SOURCES.json](SOURCES.json) implements this convention; -the dense checker compares its complete matrices in both directions. +The multicold `clifford_exact.py` oracle implements this convention; after +`research/clifford-state-production/` it is provenance in [SOURCES.json](SOURCES.json) +(not a live VERIFY pin). The dense checker still loads the working oracle and +compares its complete matrices in both directions. For integers f,h,q,t≥1 and d≥0, the desired full-space map is diff --git a/research/clifford-reciprocal-basis-obstruction/SOURCES.json b/research/clifford-reciprocal-basis-obstruction/SOURCES.json index 314cfaa0d8..de424dc9ce 100644 --- a/research/clifford-reciprocal-basis-obstruction/SOURCES.json +++ b/research/clifford-reciprocal-basis-obstruction/SOURCES.json @@ -16,10 +16,10 @@ }, { "path": "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", - "usage": "input", - "git_blob": "e17f3426fb50fbbaa7e89c4b81a4297b91defd0c", - "sha256": "9b360d58055de706a27abe5211a14115225e47f0c6096e4fb8818e99a4772abd", - "note": "Honest refresh after research/clifford-state-production/ gate-table zero_state; receipts unchanged." + "usage": "provenance", + "git_blob": "166841a037f069249f6f7f6dedb89248812f59e2", + "sha256": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "note": "Pairwise-era digest at this package base_commit. After research/clifford-state-production/, working multicold clifford_exact.py ships gate-table zero_state; dense.py still loads the working oracle for native column cross-checks, but the path is not a live VERIFY pin." }, { "path": "research/selector-batching/README.md", diff --git a/research/clifford-reciprocal-basis-obstruction/VERIFY.json b/research/clifford-reciprocal-basis-obstruction/VERIFY.json index fd0f29b79c..30e4fc73e4 100644 --- a/research/clifford-reciprocal-basis-obstruction/VERIFY.json +++ b/research/clifford-reciprocal-basis-obstruction/VERIFY.json @@ -4,7 +4,6 @@ "python": "3.12", "requirements": [], "inputs": [ - "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", "research/selector-batching/README.md" ], "commands": [ diff --git a/research/clifford-reciprocal-basis-obstruction/test_verify.py b/research/clifford-reciprocal-basis-obstruction/test_verify.py index 3c3b3d165a..d18f80b988 100644 --- a/research/clifford-reciprocal-basis-obstruction/test_verify.py +++ b/research/clifford-reciprocal-basis-obstruction/test_verify.py @@ -17,8 +17,15 @@ class VerificationTests(unittest.TestCase): @classmethod def setUpClass(cls): - cls.scratch = V.ROOT.parent / 'contribution1319-test-temp' - cls.scratch.mkdir(exist_ok=True) + # Prefer a sibling of the repo (historical layout); fall back to /tmp when + # that parent is not writable (common in containerized checkouts). + preferred = V.ROOT.parent / 'contribution1319-test-temp' + try: + preferred.mkdir(exist_ok=True) + cls.scratch = preferred + except OSError: + cls.scratch = Path(tempfile.gettempdir()) / 'contribution1319-test-temp' + cls.scratch.mkdir(exist_ok=True) def export(self, directory): root = Path(directory) / 'export' @@ -26,7 +33,8 @@ def export(self, directory): package.mkdir(parents=True) for name in ('verify.py','dense.py','SOURCES.json','CERTIFICATE.json','DENSE.json'): shutil.copy2(V.PKG / name, package / name) - for name in V.INPUTS: + # Live inventory pins plus the demoted runtime oracle used by dense.py. + for name in sorted(V.INPUTS | {V.KERNEL}): dest = root / name dest.parent.mkdir(parents=True, exist_ok=True) shutil.copy2(V.ROOT / name, dest) @@ -73,9 +81,10 @@ def test_invalid_integer_domains_and_duplicate_json(self): json.loads('{"a":1,"a":2}',object_pairs_hook=V.unique_object) def test_source_and_inventory_corruption_reject_both_engines(self): + live = sorted(V.INPUTS)[0] with tempfile.TemporaryDirectory(dir=self.scratch) as directory: root, package = self.export(directory) - source = root / V.KERNEL + source = root / live original = source.read_bytes() source.write_bytes(original+b'\n# source drift\n') for script in ('verify.py','dense.py'): @@ -84,7 +93,7 @@ def test_source_and_inventory_corruption_reject_both_engines(self): self.assertIn('source SHA256 mismatch',result.stdout+result.stderr) source.write_bytes(original) manifest = V.read_json(package / 'SOURCES.json') - manifest['files'] = [r for r in manifest['files'] if r['path'] != V.KERNEL] + manifest['files'] = [r for r in manifest['files'] if r['path'] != live] (package / 'SOURCES.json').write_text(json.dumps(manifest),encoding='utf-8') for script in ('verify.py','dense.py'): result = self.run_cli(root,script) diff --git a/research/clifford-reciprocal-basis-obstruction/verify.py b/research/clifford-reciprocal-basis-obstruction/verify.py index 14302aa324..4a15db4b78 100644 --- a/research/clifford-reciprocal-basis-obstruction/verify.py +++ b/research/clifford-reciprocal-basis-obstruction/verify.py @@ -12,8 +12,10 @@ PKG = Path(__file__).resolve().parent ROOT = PKG.parents[1] +# Runtime native oracle for dense.py; demoted from live SOURCES/VERIFY pins after +# research/clifford-state-production/ rewrote the working multicold evaluator. KERNEL = 'research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py' -INPUTS = {KERNEL, 'research/selector-batching/README.md'} +INPUTS = {'research/selector-batching/README.md'} def require(ok, message): diff --git a/research/clifford-state-production/README.md b/research/clifford-state-production/README.md index 90a87b0fdb..a91a5fa4fd 100644 --- a/research/clifford-state-production/README.md +++ b/research/clifford-state-production/README.md @@ -12,8 +12,9 @@ used by `scripts/verify_cold617_interface.py`. Historical inventories under `research/complex-multicold/**/MANIFEST.json` and `SOURCE-PINS.json` without a registered VERIFY matrix are left as provenance. `research/clifford-state-performance/` vendors pairwise-era bytes as -`baseline.py`. `research/clifford-reciprocal-basis-obstruction/` honestly -refreshes its live `clifford_exact.py` pin. Selected frontier untouched. +`baseline.py`. `research/clifford-reciprocal-basis-obstruction/` demotes its +`clifford_exact.py` pin to provenance (and drops it from VERIFY inputs). +Selected frontier untouched. ## Reproduce @@ -43,9 +44,11 @@ obligations were not rerun for this isolated historical-evaluator change. ## Result -On Linux / CPython 3.12.3, five alternating fresh-process pairs gave median wall -time recorded in [`RESULT.json`](RESULT.json). Timing is host-descriptive and is -not a correctness gate. Every helper-interface receipt matches digest +On Linux / CPython 3.12.3 with `taskset -c 0`, five alternating fresh-process +pairs gave median wall time **1.202 → 0.382 s +(3.15×)**. Timing is host-descriptive and is not a correctness gate; all +samples and environment pins are in [`RESULT.json`](RESULT.json). Every +helper-interface receipt matches digest `8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c`. ## Why the gate tables are equivalent diff --git a/research/clifford-state-production/RESULT.json b/research/clifford-state-production/RESULT.json new file mode 100644 index 0000000000..487efd9541 --- /dev/null +++ b/research/clifford-state-production/RESULT.json @@ -0,0 +1,91 @@ +{ + "alternating_order": true, + "base_commit": "0fdd7d82de03e43c9e5a1000dfbcd380d1b687d2", + "baseline": "baseline.py", + "environment": { + "executable": "/usr/bin/python3.12", + "platform": "Linux-6.12.94+-x86_64-with-glibc2.39", + "python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]" + }, + "fixture": { + "checker": "scripts/verify_cold617_interface.py", + "cold": 22, + "entering": 36, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "runs": [ + "research/community-k492-audit/pr622/replay/ck-local", + "research/community-k492-audit/pr622/replay/jp8-local" + ] + }, + "medians_seconds": { + "baseline": 1.2024670450000485, + "production": 0.382035725000037 + }, + "no_new_kappa": true, + "production": "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py", + "rounds": 5, + "samples": [ + { + "engine": "baseline", + "pair": 0, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 1.4701892190000763 + }, + { + "engine": "production", + "pair": 0, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 0.44696984799998063 + }, + { + "engine": "production", + "pair": 1, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 0.4883271460000742 + }, + { + "engine": "baseline", + "pair": 1, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 1.4149907999999414 + }, + { + "engine": "baseline", + "pair": 2, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 1.1509182329999703 + }, + { + "engine": "production", + "pair": 2, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 0.3647747669999717 + }, + { + "engine": "production", + "pair": 3, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 0.382035725000037 + }, + { + "engine": "baseline", + "pair": 3, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 1.03816710600006 + }, + { + "engine": "baseline", + "pair": 4, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 1.2024670450000485 + }, + { + "engine": "production", + "pair": 4, + "receipt_sha256": "8e775e5927b2f05c1671902680e25995adba6a2d2236f5dc116683b18ac4a42c", + "seconds": 0.3736550309999984 + } + ], + "speedup": 3.147525130012205, + "status": "PASS_IDENTICAL_CLIFFORD_STATE_PRODUCTION_RECEIPTS" +} diff --git a/research/clifford-state-production/TASK.json b/research/clifford-state-production/TASK.json index 213208ae28..aca429ac0c 100644 --- a/research/clifford-state-production/TASK.json +++ b/research/clifford-state-production/TASK.json @@ -48,7 +48,7 @@ "budget_minutes": 60, "stop_rule": "Ship an equivalence-preserving production clifford_exact.py change with frozen baseline, identical helper-interface receipts, corruption controls, pin discipline, registered replay and a measured before/after median. Do not invent kappa or reopen leave-alone objects.", "outcome": "completed", - "evidence": "PASS_CLIFFORD_STATE_PRODUCTION via research/clifford-state-production/verify.py (also under -O); PASS_REGISTERED_RESEARCH_PACKAGE; PASS_IDENTICAL_CLIFFORD_STATE_PRODUCTION_RECEIPTS via benchmark.py --rounds 5; research/clifford-state-performance demotes the pairwise-era working-source pin; research/clifford-reciprocal-basis-obstruction honestly refreshes its live clifford_exact pin.", + "evidence": "PASS_CLIFFORD_STATE_PRODUCTION via research/clifford-state-production/verify.py (also under -O); PASS_REGISTERED_RESEARCH_PACKAGE; PASS_IDENTICAL_CLIFFORD_STATE_PRODUCTION_RECEIPTS via pinned-CPU benchmark.py --rounds 5 (median 1.202\u21920.382 s, 3.148\u00d7); research/clifford-state-performance demotes the pairwise-era working-source pin; research/clifford-reciprocal-basis-obstruction demotes clifford_exact to provenance and drops it from VERIFY inputs.", "author": "Wentao Li", "github": "VictorLiwentao", "email": "wentaol4@illinois.edu", diff --git a/research/clifford-state-production/benchmark.py b/research/clifford-state-production/benchmark.py index 40b741d748..2ef26589ee 100644 --- a/research/clifford-state-production/benchmark.py +++ b/research/clifford-state-production/benchmark.py @@ -49,6 +49,11 @@ def unique_object(pairs): def run_workload(engine: str, out: Path) -> dict: + """Swap the live production evaluator for the timed image, then restore it. + + The helper-interface checker hardcodes MULTICOLD_SOURCE to the repository + multicold tree, so temporary overlay trees are ignored. + """ image = BASELINE if engine == "baseline" else PRODUCTION original = PRODUCTION.read_bytes() PRODUCTION.write_bytes(image.read_bytes()) diff --git a/research/clifford-state-production/verify.py b/research/clifford-state-production/verify.py index 6b730c7e01..d01f55acf6 100644 --- a/research/clifford-state-production/verify.py +++ b/research/clifford-state-production/verify.py @@ -132,10 +132,9 @@ def clean_env(): def run_helper_interface(clifford_bytes: bytes, out: Path) -> bytes: """Run the helper-interface checker against an on-disk clifford_exact image. - Launches an asserting child (`python -B`, never `-O` / PYTHONOPTIMIZE) so - package gates under `-O` still exercise the historical checker asserts. - Note: this host's CPython `-I` omits the script directory from ``sys.path``, - so sibling imports inside ``scripts/`` require a non-isolated child. + ``scripts/verify_cold617_interface.py`` overwrites ``MULTICOLD_SOURCE`` to the + repository multicold tree, so the only way to substitute an evaluator image is + to briefly replace the live production file. Always restore it in ``finally``. """ original = PRODUCTION.read_bytes() PRODUCTION.write_bytes(clifford_bytes) @@ -190,14 +189,18 @@ def check_helper_receipts() -> dict: def check_temp_corruption_rejection() -> dict: - """On-disk foil that skips permutation remapping must diverge.""" - honest = None + """On-disk foil that breaks ``perm`` must fail closed or change the receipt. + + ``wrapped_ok`` decodes recipes through ``perm``/``diag``/``xgate``. Foiling + ``perm`` to the identity makes those products disagree with the + ``canonical_frame`` targets. + """ with tempfile.TemporaryDirectory(prefix="clifford-state-prod-honest-") as tmp: honest = run_helper_interface(PRODUCTION.read_bytes(), Path(tmp) / "honest.json") text = PRODUCTION.read_text(encoding="utf-8") - needle = " for x,a in enumerate(vec):v[mapping[x]]=a\n" - require(needle in text, "permutation remap site missing for corruption control") - foil = " for x,a in enumerate(vec):v[x]=a\n" + needle = "def perm(n,G):\n cols=transpose(G,n);gi=inv(G,n)\n return Op(n,tuple([(a,0,0) for a in cols]+[(0,a,0) for a in gi]),[('P',tuple(G))])\n" + require(needle in text, "perm() site missing for corruption control") + foil = "def perm(n,G):\n return ident(n)\n" with tempfile.TemporaryDirectory(prefix="clifford-state-prod-foil-") as tmp: mutant_path = Path(tmp) / "clifford_exact.py" mutant_path.write_text(text.replace(needle, foil, 1), encoding="utf-8") @@ -206,14 +209,15 @@ def check_temp_corruption_rejection() -> dict: bad = run_helper_interface(mutant_path.read_bytes(), Path(tmp) / "bad.json") except Exception as exc: # includes AssertionError from require() inside checker return {"rejected": True, "mode": "subprocess_failure", "detail": str(exc)[:240]} - require(bad != honest, "identity-permutation foil must change the helper receipt") + require(bad != honest, "identity-perm foil must change the helper receipt") return {"rejected": True, "mode": "receipt_divergence"} def main(argv: list[str] | None = None) -> int: parser = argparse.ArgumentParser(description=__doc__) parser.parse_args(argv) - # -O policy: require() raises remain active; helper-interface children always use -I -B. + # -O policy: require() raises remain active; helper-interface children use -B + # with PYTHONOPTIMIZE cleared (host CPython -I omits the script directory). check_baseline_bytes() states = check_state_equivalence() receipts = check_helper_receipts() From 68a7161a610f175dc8e7b22f95acd033191450d9 Mon Sep 17 00:00:00 2001 From: Wentao Li Date: Thu, 15 Oct 2026 05:39:19 +0000 Subject: [PATCH 3/3] Honesty: disclose live clifford_exact swap; demote cold-wrapper pin VERIFY/README no longer claim a read-only default: helper-interface runs briefly swap the live production evaluator under try/finally restore. Move cold-wrapper-amplitude-audit's pairwise clifford_exact digest to provenance_sha256 (audit does not import that module). Prepared by Wentao Li with substantial AI assistance. --- research/clifford-state-production/README.md | 16 ++++++++++------ research/clifford-state-production/VERIFY.json | 2 +- research/cold-wrapper-amplitude-audit/README.md | 2 ++ .../cold-wrapper-amplitude-audit/SOURCES.json | 7 +++++-- research/cold-wrapper-amplitude-audit/verify.py | 1 + 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/research/clifford-state-production/README.md b/research/clifford-state-production/README.md index a91a5fa4fd..e118a33290 100644 --- a/research/clifford-state-production/README.md +++ b/research/clifford-state-production/README.md @@ -35,12 +35,16 @@ PASS_REGISTERED_RESEARCH_PACKAGE research/clifford-state-production outcome=comp PASS_IDENTICAL_CLIFFORD_STATE_PRODUCTION_RECEIPTS ``` -Default verify is read-only. Temp-copy permutation-foil rejects via receipt -mismatch or subprocess failure. Package gates under `-O` still launch asserting -helper-interface children (`python -B` with `PYTHONOPTIMIZE` cleared; this -host's CPython `-I` omits the script directory from `sys.path`). Full -`make verify`, selected cold replay, Lean, and multiplication-theorem -obligations were not rerun for this isolated historical-evaluator change. +Helper-interface receipt and benchmark runs briefly **swap the live** +production `clifford_exact.py` under `try`/`finally` restore: `scripts/verify_cold617_interface.py` +overwrites `MULTICOLD_SOURCE` to the repository multicold tree, so temporary +overlay paths are ignored. The working tree is restored after every run. +Permutation-foil rejects via receipt mismatch or subprocess failure. Package +gates under `-O` still launch asserting helper-interface children (`python -B` +with `PYTHONOPTIMIZE` cleared; this host's CPython `-I` omits the script +directory from `sys.path`). Full `make verify`, selected cold replay, Lean, and +multiplication-theorem obligations were not rerun for this isolated +historical-evaluator change. ## Result diff --git a/research/clifford-state-production/VERIFY.json b/research/clifford-state-production/VERIFY.json index c9b22f7267..fe86f5c34f 100644 --- a/research/clifford-state-production/VERIFY.json +++ b/research/clifford-state-production/VERIFY.json @@ -19,7 +19,7 @@ { "argv": ["{python}", "-I", "-B", "{package}/verify.py"], "timeout_seconds": 180, - "checks": "Exact baseline copy of the base-commit clifford_exact.py; production equals the gate-table transform; identical helper-interface receipts; temp-copy permutation-foil corruption control; duplicate JSON-key check; read-only default." + "checks": "Exact baseline copy of the base-commit clifford_exact.py; production equals the gate-table transform; identical helper-interface receipts; helper-interface runs briefly swap the live production clifford_exact.py under try/finally restore (verify_cold617_interface forces MULTICOLD_SOURCE to the repo tree); permutation-foil corruption control; duplicate JSON-key check; tree restored after verify." }, { "argv": ["{python}", "-I", "-O", "-B", "{package}/verify.py"], diff --git a/research/cold-wrapper-amplitude-audit/README.md b/research/cold-wrapper-amplitude-audit/README.md index 6cf73530ad..f8c3271443 100644 --- a/research/cold-wrapper-amplitude-audit/README.md +++ b/research/cold-wrapper-amplitude-audit/README.md @@ -174,3 +174,5 @@ wrappers or supplier moments. The inherited common-label/mutable-basis, pooled hosting, all-size, precision, tape and analytic assumptions remain. There is no new multiplication kappa, practical speedup or novelty claim about Clifford algebra. See `NOTICE.md`, `CLAIM.json` and `VALIDATION.md`. + +After `research/clifford-state-production/`, the multicold `clifford_exact.py` digest is recorded under `provenance_sha256` only (this audit does not import that module). diff --git a/research/cold-wrapper-amplitude-audit/SOURCES.json b/research/cold-wrapper-amplitude-audit/SOURCES.json index cb6b4a991e..4ec64bbee0 100644 --- a/research/cold-wrapper-amplitude-audit/SOURCES.json +++ b/research/cold-wrapper-amplitude-audit/SOURCES.json @@ -8,7 +8,6 @@ "files": { "research/complex-k492-owner-repair/data/SPEC.json": "2a2577ac526535826fed9d5f7f83f6e2e0ec058a146c64f7286720b995fa2323", "research/complex-k492-owner-repair/code/hpe_adapters_local.py": "eb0b5c6c7161e18dc22168da3211448d321586edd15bcfb4b4741174d36993cf", - "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", "research/hyperplane-end-lean/PROOF.md": "1cbce5cf0ff0152f71e8ae7bef25841d1ce13010af248ff7209182d2328c21c9", "scripts/verify_cold617_interface.py": "95d7a9094c05ad975fb72f5ab7605593003245a503c8456764987e512028fa6a", "docs/research/community-k492-review.md": "3b731d30e80010b15408a289b0b32192700885474c8b36d48ee3320a7a8c5c47" @@ -34,5 +33,9 @@ "canonical_json_sha256": "99e1873464e8e718ea25fd80df5aaed0e5508b83e9bf2bdd094ea5c95fdf87c9" } } - } + }, + "provenance_sha256": { + "research/complex-multicold/vendor/pr558/vendor/pr552/complex-global/vendor531/vendor/clifford/clifford_exact.py@pre-clifford-state-production": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962" + }, + "note": "After research/clifford-state-production/, working clifford_exact.py is the gate-table evaluator. The pairwise-era digest is retained under provenance_sha256; this audit does not import that module." } diff --git a/research/cold-wrapper-amplitude-audit/verify.py b/research/cold-wrapper-amplitude-audit/verify.py index 379e13dfd9..8c1cb7c703 100644 --- a/research/cold-wrapper-amplitude-audit/verify.py +++ b/research/cold-wrapper-amplitude-audit/verify.py @@ -168,6 +168,7 @@ def read_inputs(root): for path, wanted in sources["files"].items(): require(hashlib.sha256((root / path).read_bytes()).hexdigest() == wanted, "Source hash mismatch: " + path) + # provenance_sha256 entries are historical only (not live working-tree pins). spec = json.loads((root / SPEC).read_text()) unique, providers = {}, {} for provider, artifacts in sources["artifacts"].items():