Repository navigation
Add P104 flag 0 coefficient transport audit - #3915
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 P104 flag-0 coefficient transport at Code-disjoint checks; does not import package No packaging defect in scope. What passes:
Not covered: a chronological side-correction program or cost claim (explicitly out of package scope); new κ; formal-kernel proof. This is a finite coefficient replay, not a formal proof. check.py#!/usr/bin/env python3
"""Code-disjoint audit of PR #3915 P104 flag-0 coefficient transport."""
from __future__ import annotations
import hashlib
import json
from fractions import Fraction
from itertools import combinations, product
from pathlib import Path
ROOT = Path(__file__).resolve().parent
PKG = ROOT / "pkg"
UP = ROOT / "upstream"
BASE = "20ecf2891d80b5acf18d980b2164fb44ea7faa90"
HEAD = "5a082968713ae78a563985b37eef0762961118de"
INPUTS = {
"research/p104-endpoint-geometric-budget/geometry.py",
"research/p104-joint-unit-flags/CERTIFICATE.json",
"research/p104-native-channel/inputs/LOWRANK-WITNESS.json",
"research/p104-native-channel/inputs/P104-FIXTURE.json",
}
def check(name: str, cond: bool) -> bool:
print(f"[{'PASS' if cond else 'FAIL'}] {name}")
return bool(cond)
def sha256_file(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
def up(rel: str) -> Path:
return UP / rel.replace("/", "__")
def load_json(rel: str):
return json.loads(up(rel).read_text(encoding="utf-8"))
def ports(fixture):
roots = []
for i, j in combinations(range(8), 2):
for sign in (-1, 1):
row = [0] * 8
row[i], row[j] = 2, 2 * sign
roots.append(tuple(row))
roots += [
(1, *signs)
for signs in product((-1, 1), repeat=7)
if signs.count(-1) % 2 == 0
]
section = fixture["section4_explicit_P104"]
excluded = {tuple(row) for row in section["F0"] + section["C"]}
return sorted(set(roots) - excluded)
def chronology(program, source, target):
source_events = [i for i, event in enumerate(program) if source in event]
target_events = [i for i, event in enumerate(program) if target in event]
pair_joint = sum(source in event and target in event for event in program)
assert source_events and target_events
return source_events[0], source_events[-1], target_events[0], target_events[-1], pair_joint
def trace_one_hot(program, source, target):
rows = {source: Fraction(1)}
target_adds = []
for index, event in enumerate(program):
kind = event[0]
if kind == "add":
_, dst, src, scalar, *_ = event
scalar = Fraction(scalar)
source_coefficient = rows.get(src, Fraction(0))
delta = scalar * source_coefficient
before = rows.get(dst, Fraction(0))
rows[dst] = before + delta
if dst == target and delta:
target_adds.append(
{
"event": index,
"source": src,
"scale": str(scalar),
"source_coefficient": str(source_coefficient),
"delta": str(delta),
"after": str(rows[dst]),
}
)
elif kind == "transport":
continue
elif kind in ("zero", "erase"):
rows[event[1]] = Fraction(0)
elif kind == "copy":
rows[event[1]] = rows.get(event[2], Fraction(0))
else:
raise ValueError(f"unknown event {index}: {kind}")
return rows.get(target, Fraction(0)), target_adds
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"))
committed = json.loads((PKG / "RESULT.json").read_text(encoding="utf-8"))
results.append(("D1 RESULT.json present", (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))
results.append(("D4 VERIFY.status ready", verify.get("status") == "ready"))
results.append(("D5 TASK.outcome", task.get("outcome") in ("completed", "partial", "negative-result")))
pinned = {row["path"]: row for row in sources["files"] if row["usage"] == "input"}
results.append(("P1 input inventory", set(pinned) == INPUTS))
pin_ok = all(up(p).exists() and sha256_file(up(p)) == row["sha256"] for p, row in pinned.items())
results.append(("P2 input sha256 at base", pin_ok))
geometry = up("research/p104-endpoint-geometric-budget/geometry.py").read_text(encoding="utf-8")
results.append(("P3 geometry port/path markers", "ports = sorted(roots -" in geometry and "paths[f'X{s}']" in geometry and "paths[f'Y{t}']" in geometry))
certificate = load_json("research/p104-joint-unit-flags/CERTIFICATE.json")
witness = load_json("research/p104-native-channel/inputs/LOWRANK-WITNESS.json")
fixture = load_json("research/p104-native-channel/inputs/P104-FIXTURE.json")
helpers = certificate["helpers"]
results.append(("C1 208 joint flags", len(helpers) == 208))
flag = helpers[0]
results.append(("C2 flag0 is (0,34,232)", (flag["source"], flag["target"], flag["basis"][0]) == (0, 34, 232)))
vectors = ports(fixture)
results.append(("C3 104 ports", len(vectors) == 104))
src_vec, dst_vec = vectors[0], vectors[34]
raw_dot = sum(x * y for x, y in zip(src_vec, dst_vec, strict=True))
results.append(("C4 root scales 8/8 and dot 4", sum(x * x for x in src_vec) == 8 and sum(y * y for y in dst_vec) == 8 and raw_dot == 4))
native_expected = Fraction(raw_dot, 8)
side_required = -native_expected
program = witness["program"]
results.append(("W1 program length 4058", len(program) == 4058))
source, target = "X0", "Y34"
source_first, source_last, target_first, target_last, pair_joint = chronology(program, source, target)
results.append(("W2 event cuts", target_first == 129 and source_first == 591 and target_last == 3500 and source_last == 3954))
results.append(("W3 no joint X0/Y34 events + order", pair_joint == 0 and target_first < source_first < target_last))
native_coefficient, target_adds = trace_one_hot(program, source, target)
results.append(("T1 native coeff == 1/2", native_coefficient == native_expected == Fraction(1, 2)))
expected_adds = [
{"event": 2815, "source": "D17", "scale": "-1/4", "source_coefficient": "-2", "delta": "1/2", "after": "1/2"},
{"event": 2998, "source": "D13", "scale": "1/4", "source_coefficient": "-2", "delta": "-1/2", "after": "0"},
{"event": 3369, "source": "D23", "scale": "1/4", "source_coefficient": "2", "delta": "1/2", "after": "1/2"},
]
results.append(("T2 target addition trace", target_adds == expected_adds))
controls = []
ctrl_ok = True
for value in (Fraction(1), Fraction(7, 11), Fraction(-3, 5)):
native = native_coefficient * value
correction = side_required * value
if not (native + correction == 0 and native != correction):
ctrl_ok = False
controls.append({"z": str(value), "native_y34": str(native), "required_side_addition": str(correction)})
results.append(("T3 arbitrary-z side controls", ctrl_ok))
observed = {
"status": "PASS_P104_FLAG0_COEFFICIENT_TRANSPORT",
"flag0": {"source": source, "target": target, "basis_head": 232},
"events": {
"target_first": target_first,
"source_first": source_first,
"target_last": target_last,
"source_last": source_last,
"X0_Y34_joint_events": pair_joint,
},
"raw_doubled_root_dot": raw_dot,
"native_G_over_2_coefficient": str(native_coefficient),
"required_I_minus_G_over_2_coefficient": str(side_required),
"target_additions": target_adds,
"one_hot_fixture": "x0=z; other x and dirty coefficients zero; y34=0",
"controls": controls,
"no_correction_program_or_cost_claim": True,
}
results.append(("R1 RESULT.json matches recomputation", committed == observed))
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 = sum(1 for name, cond in results if check(name, cond))
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 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.
Audit the exact native coefficient for P104 joint flag 0
Summary
Adds a bounded exact row audit for the first flag in PR #2981's 208-flag
collection: source
X0, targetY34, basis head232.The pinned doubled E8 roots have raw dot product
4and squared norm8. Thenative channel therefore contributes
+1/2to this off-diagonal entry, whilethe complementary
I-G/2term requires-1/2. A one-hotx0=zreplay throughthe pinned 4,058-event word follows the target coefficient through events
2815 (
+z/2), 2998 (-z/2), and 3369 (+z/2), finishing atY34 = z/2.This complements PR #3242's event-order scan and the pooled fixed-cover support
reviews in PRs #3259, #3803, and #3810. It checks an actual native coefficient
row for one flag; the three additions do not implement the side correction.
Reproduction
Local exact replay passed on CPython 3.14.8. The registered Python 3.12 replay
remains pending because that interpreter is unavailable in the local
environment.
Scope and limits
No correction program, arbitrary-dirty restoration, correction-frame
availability, full bill, supplier admission, new kappa, or selected-frontier
change is claimed. The one-hot fixture sets dirty coefficients to zero and uses
the coefficient-row invariant in the reviewed native-channel proof. It does not
re-run the native Clifford/all-column checker.
Credit Nick Petalas / PR #2981 for the static flag; Rohan Arun / PR #1972 and
Chafik Boukhalfa / PR #1991 for the channel; and jwr404 / PR #3242 for the
event chronology. No independent human or formal-kernel review is claimed.
Current overlap
Open PR #3882 submits a P104 correction-tail construction. This package checks one native coefficient row for flag 0 and does not construct a correction program.
Publication validation
python3.12 scripts/research_package.py --package research/p104-flag0-coefficient-transportpassed on CPython 3.12.3, andpython3.12 scripts/check_research_commit.py --package research/p104-flag0-coefficient-transport --check-source-historypassed. The registered replay left the worktree clean. This supersedes any earlier pending note above for the registered package replay; separate full selected cold-replay limits remain as stated.