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") diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/LOCAL-PINS.json b/research/p104-type-a-same-clock-phase-retirement-bound/LOCAL-PINS.json new file mode 100644 index 0000000000..82d9f5a828 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/LOCAL-PINS.json @@ -0,0 +1,22 @@ +{ + "PROVENANCE.json": "46ea1741110e77d8c7b93b9cc530510c65e6e6af23b6be47f753c4339bc7301c", + "engines/anchors.py": "185a03cfd0254407bac1ec723b680754c6539db5d032b967fc4f0fd1656f72a4", + "engines/coefficients.py": "16c7d9351311ab7f1a397732aaa23d7a769070a8620c3cbffb33a28b1a37de24", + "engines/diagonal_anchors.py": "98c43945e05cc921fbb3fa5d2b54770e496a44432dbdc51dc4a41dfaed05d8dd", + "engines/literal.py": "f8e8a71e47c381effa4d9a13da2112515d58f727a360d4d46403425fc502678c", + "engines/price.py": "fba9e788487e078b0bf9f829e07560d2c1ba5abbeebccbaee061cc200bbcfe61", + "engines/quote.py": "fe6ee7c435a937e7c6ccf5126f30c4ac39462a2fdc4f3cc40a0476b74c298c6f", + "engines/replay_r164.py": "9e99b716a78afb9d90fee8cf66d6eb1ead88a45c93e89e735cd626e4471756e7", + "engines/replay_reverse.py": "76de062a6bbc42474690a4d19ed0de4d7252f6abed39e117d6bd82323b6fb295", + "inputs/7113-SHA256.json": "064e11ecfedce9937ea1782e5baee37e89b3c9eebabed5b4a9ba84f412bbe078", + "inputs/7334-ADMITTED.json": "c95300e9bca27e44a25c82d794f88cbf70757c142806b0e4c590ea29feb81a13", + "inputs/CALLER.json.gz": "7e8038559cd158f6e32ef6d1a3bf15ab6a8ecc2239af32ab1699511ac28e26d9", + "inputs/PLAN.md": "2cdb9d5c021c29dbe453b0dd592b94ddec8510f90acc86af9597abf407822cec", + "inputs/PR7362-SHA256.json": "2c90ca39b0f075cc4b3ec9e90c66fde473465e7bb50cf1db9a820d3a29556c0b", + "inputs/R92-PRICE.json.gz": "857b2776d4fb18844a08c82bb9387ddb3332d025bc7ecef2e606e6666705acf2", + "inputs/pricing.py": "f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182", + "receipts/DIAGNOSTICS.json": "82c726522d1bb62599db197bd768d9d29f4858970d9c191cb19ed9a7738804ad", + "receipts/REPLAY-CHECKS.json": "c30376544ee4ccccdf07a52b2704c9bc6202a43780430675601777b97a2e29ba", + "receipts/SHA256.json": "2c32c6acbc74ea03ac4eb327447527e338559fb2b978b046d3a68a59a0dc65f6", + "replay.py": "e8867f319836f9db6d8ac26780d01b6514f6666f1c8542f5725174d75e28cf7e" +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/NOTICE b/research/p104-type-a-same-clock-phase-retirement-bound/NOTICE new file mode 100644 index 0000000000..f25681221e --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/NOTICE @@ -0,0 +1,8 @@ +Apache-2.0. + +#7334 supplies the complete comparison witness, and #7113 supplies +the signed caller. #7309 supplies the neighboring fixed-target rank +argument, #7342 supplies formal fixed-cut pair repair evidence, and +#7316 studies the same rank-137 roots. #7362 and #7298 supply the +base invoice and directed tariff. OpenAI Codex and subagents +materially assisted. diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/PROOF.md b/research/p104-type-a-same-clock-phase-retirement-bound/PROOF.md new file mode 100644 index 0000000000..ddf56a5ceb --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/PROOF.md @@ -0,0 +1,151 @@ +# Same-clock Type A phase retirement + +The signed Type A caller from #7113 in the #7334 comparison witness +has 4,783 events, including all 17 J stages, and 36 Type A roles. +Specialize all 17 bodies to 1 and q to +1 or −1. The original +specialized endpoints are I and −I respectively. The four QUERY +indices are 1516, 1580, 1659 and 1721, zero-based in the full stream. + +A phase retirement leaves the target at I for q=+1. At q=−1 it +changes one diagonal sign of −I for each retired phase. For the +erased word, use q-even coefficients s₁,…,s₄ at the four old QUERY +clocks, so each coefficient is the same at the two signs. The +argument grants any rational values for these coefficients. Keep +all other literal specialized actions fixed. + +## Rank budget and the fixed all-plus control + +At either sign, split the corrected and erased words into products +at all correction sites. A changed factor differs from its erased +version by a matrix of rank at most one. An inserted factor uses +the identity at the corresponding erased position. Telescoping the +difference of products gives one term per correction, multiplied +on both sides by surrounding factors. The difference between target +and erased endpoints must have rank at most the number of such +corrections. This allows arbitrary correction directions and clocks +as long as erasing their differences gives the stated erased word. + +For the fixed s=(1,1,1,1) word at q=−1, the rows (0, 1, 18, 19) +and columns (2, 9, 20, 27) of target minus erased endpoint give + +```text +[-6 -2 0 0] +[-4 0 0 0] +[ 0 0 -6 -2] +[ 0 0 -4 0] +``` + +The row and column sets are disjoint, so this submatrix is common +to every diagonal target. Both 2×2 blocks have determinant −8 +and the full determinant is 64. The fixed all-plus erased word +therefore needs at least four corrections for every diagonal +target. The proposed target with roles 0 and 18 retired has +exact residual rank four for this word. + +## Reduction of arbitrary even coefficients + +Fix q and write dⱼ=sⱼ−q, with D the diagonal matrix of these four +differences. Take U to have columns equal to the original suffix +transport of the four QUERY output directions. Take V to have +rows equal to the original prefix transport of the four QUERY +source covectors. For input x, the actual QUERY source values z +satisfy z=Vx+LDz, where the strictly lower triangular matrix L +transports earlier QUERY differences to later source reads. The +difference of endpoint matrices from the original is therefore + +```text +U D (I−LD)⁻¹ V. +``` + +The inverse exists because LD is strictly lower triangular. When +U is injective and V is surjective, this expression has rank +equal to the number of nonzero dⱼ. This also holds after taking +output rows R and input columns C if U[R,:] and V[:,C] have +full rank. + +At q=+1 the opposite-constant control s=(−1,−1,−1,−1) +has full difference rank four. The independent reverse +calibration records a nonzero 4×4 determinant of 16. This +forces full rank of U and V. At q=−1 the all-plus calibration +has determinant 64 on the disjoint rows and columns above. +This forces full rank of the projected factors. A diagonal +target contributes zero on those disjoint rows and columns, +so any residual with a diagonal target has rank at least +the number of nonzero dⱼ at q=−1. + +If two corrections suffice at both signs, at most two coefficients +differ from +1 and at most two differ from −1. Each of the four +coefficients differs from at least one sign, and a coefficient +outside {−1,+1} differs from both. Therefore exactly two coefficients +are +1 and two are −1. The rational-coefficient search has six +balanced sign patterns. The residual ranks for the 0/18 target +at q=−1 are 3, 3, 3, 3, 4, 4 in the order of lexicographic +1 +position pairs. + +## All pairs from diagonal anchors + +For each of the six patterns let A=E−(−I), where E is the +q=−1 erased endpoint. Both exact engines reconstruct rank two +for each A. Let B=E−T for a proposed diagonal target T. +Then A and B agree off the diagonal. + +Fix a role i. Suppose two rows R and two columns C are disjoint, +all avoid i, and det A[R,C] is nonzero. If rank B were at most +two, the 3×3 determinants on rows (R,i) and columns (C,i) of +both A and B would vanish. Their difference is + +```text +(B[i,i]−A[i,i]) det A[R,C]. +``` + +Every other entry is off the diagonal. Thus this anchor +forces B[i,i]=A[i,i] and leaves the target at −1 on role i. + +The engines agree on the missing-anchor sets [18], [18], [18], +[0], [], [] in the six-pattern order. For each pattern there is +at most one unanchored role. Every target changing two or more +diagonal entries of −I changes an anchored entry and has residual +rank above two. In particular, all 630 distinct pairs are covered +by 216 pattern and role checks, without enumerating new literal +caller words for each pair. The directly tested alternate pair +0/17 has residual ranks 4, 4, 4, 3, 4, 4 on the same six words. + +A single unanchored role in a pattern remains open under arbitrary +rank-one differences. If every allowed correction preserves the +specialized determinant, such as a unipotent shear inserted +against identity, an odd number of sign flips is also excluded. +The target determinant would be −1. Every allowed factor product +has determinant +1. This argument needs the determinant hypothesis. + +## Directed whole-profile prices + +The two most favorable ranks are 137 and 137 at roles 0 and 18. +The next price tier is 137 and 73, checked at roles 0 and 17. +For ranks r≥1 the tariff r^(1−κ) has decreasing increments, +so retiring one phase from a higher rank loses less productive +moment. For a 137/137 edit over 96 ports the proposed changes +are ΔP1 = −192, ΔT137 = −192, ΔT136 = +192. The +signed rank surplus remains 1,424. At the upper endpoint of the +old crossing the directed gross is below 4.099242419852824 raw +units. At the inherited exact probe the relaxed complete margin +is above 4.098855957122750 raw units. An optimistic two-pair +gross relaxation is below 8.198484839705648 raw units. + +The 137/73 edit moves 96 targets from 137 to 136 and 96 from +73 to 72, and removes the same 192 paid rank-one calls. Its +directed gross is below 3.882211372694752 raw units at the old +crossing upper endpoint, and its relaxed complete margin at the +probe is above 3.881824851665655. One extra rank-one field per +port exceeds either pair's gross. Both price calculations grant +unchanged setup, routing, ownership, restoration, grid, precision +and tape costs. The quoted savings are unbuilt. + +## Scope + +All scheduled coefficient words and role checks were covered within +their caps. The result uses a necessary unit-body specialization +of the signed endpoint contract. The test leaves changed clocks, +J stages, ordinary wrappers, a different erased endpoint, or +higher-rank corrections open. Full signed bodies, arbitrary-input +physical execution, ownership and restoration would still need +independent verification for a future candidate. diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/PROVENANCE.json b/research/p104-type-a-same-clock-phase-retirement-bound/PROVENANCE.json new file mode 100644 index 0000000000..cc552445a2 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/PROVENANCE.json @@ -0,0 +1,76 @@ +{ + "caller": { + "commit": "07a76c5e2738882c0cb322278e56f6cae3c9885d", + "source": "https://github.com/CrocSwap/integer-mult-bounds/pull/7113" + }, + "derived_inputs": { + "CALLER.json": { + "compression": "gzip", + "file": "inputs/CALLER.json.gz", + "key": "expected/ODD-TYPE-AB-CALLER.json", + "manifest": "inputs/7113-SHA256.json", + "sha256": "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc" + }, + "PLAN.md": { + "file": "inputs/PLAN.md", + "relationship": "Public restatement of the three frozen endpoint gates and their preset runner caps.", + "sha256": "2cdb9d5c021c29dbe453b0dd592b94ddec8510f90acc86af9597abf407822cec" + }, + "R92-PRICE.json": { + "compression": "gzip", + "file": "inputs/R92-PRICE.json.gz", + "key": "R92-PRICE.json", + "manifest": "inputs/PR7362-SHA256.json", + "sha256": "05d7a5ebdd2eeedd6c8f534e8e2eeac22484daf9f387f4a6b88cc9eed22a6b8f" + } + }, + "files": { + "inputs/7113-SHA256.json": { + "commit": "07a76c5e2738882c0cb322278e56f6cae3c9885d", + "git_blob": "5a7d6b80dc51aa918a5d521b60d18f9a6bbbc52e", + "path": "research/signed-caller-8x9/SHA256.json", + "sha256": "064e11ecfedce9937ea1782e5baee37e89b3c9eebabed5b4a9ba84f412bbe078", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/07a76c5e2738882c0cb322278e56f6cae3c9885d/research/signed-caller-8x9/SHA256.json" + }, + "inputs/7334-ADMITTED.json": { + "commit": "349996445176e934ffb3c76813adcd230ca8f783", + "git_blob": "464c89e45c4eca230c099e8bac784a90200a5069", + "path": "research/p104-compensated-fusion-readout-bound/inputs/ADMITTED.json", + "sha256": "c95300e9bca27e44a25c82d794f88cbf70757c142806b0e4c590ea29feb81a13", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/349996445176e934ffb3c76813adcd230ca8f783/research/p104-compensated-fusion-readout-bound/inputs/ADMITTED.json" + }, + "inputs/PR7362-SHA256.json": { + "commit": "5eec7ed633dcf9b9bbc95552aa653da296f863fb", + "git_blob": "b1486e0b5cfe4535f381ed26f7bce4aee21d8a43", + "path": "research/p104-rank-two-virtual-cut-bound/receipts/SHA256.json", + "sha256": "2c90ca39b0f075cc4b3ec9e90c66fde473465e7bb50cf1db9a820d3a29556c0b", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/5eec7ed633dcf9b9bbc95552aa653da296f863fb/research/p104-rank-two-virtual-cut-bound/receipts/SHA256.json" + }, + "inputs/pricing.py": { + "commit": "c522451caf287bb3c16eaece72be4c263315dca4", + "git_blob": "40ec194017bda1d524bba4f07b188c53281419d0", + "path": "research/adjacent-owned-add-exchange-bound/pricing.py", + "sha256": "f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/c522451caf287bb3c16eaece72be4c263315dca4/research/adjacent-owned-add-exchange-bound/pricing.py" + } + }, + "predecessors": { + "7309": { + "commit": "0de5abc36b4a17c7da4f29e1c3e78f956bf33de5", + "usage": "relative phase-defect rank argument for unchanged Type A target" + }, + "7316": { + "commit": "ceb27ae824a8e7913d1d17a6430c1569704c1e15", + "usage": "rank-137 Type A roots 0 and 18 under a different fixed-paid split" + }, + "7334": { + "commit": "aaeec8c0acf01e99a5f331ef363a698d9c084ace", + "usage": "complete comparison witness" + }, + "7342": { + "commit": "b567f9a4f5699c5e447100c38b5745526b15b770", + "usage": "nearby fixed-cut relative rank-two repair and open physical two-return interface" + } + }, + "schema_version": 1 +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/README.md b/research/p104-type-a-same-clock-phase-retirement-bound/README.md new file mode 100644 index 0000000000..d00bd4f9fa --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/README.md @@ -0,0 +1,71 @@ +# Same-clock Type A phase retirement with two paid queries + +**NO VERIFIED GAIN.** The complete comparison witness is +[#7334](https://github.com/CrocSwap/integer-mult-bounds/pull/7334) +`aaeec8c0acf01e99a5f331ef363a698d9c084ace`, κ +`0.00364665195644`, with the exact signed +[#7113](https://github.com/CrocSwap/integer-mult-bounds/pull/7113) +caller at `07a76c5e2738882c0cb322278e56f6cae3c9885d`. + +Retiring two productive q factors across 96 Type A ports gives a +positive optimistic invoice if two rank-one QUERYs can be saved. +For the pinned caller, keep the four QUERY clocks, all 17 J stages +and all other literal operations. Grant arbitrary q-even rational +coefficients at those clocks and any two rank-one factor differences. +At unit bodies the required q=+1 endpoint is I. The q=−1 endpoint +cannot be diagonal with two or more entries changed from −I. This +excludes all 630 two-root phase retirements in the declared class. + +A rank reduction leaves six balanced sign patterns for the four +even coefficients. Independent forward and reverse replays agree +on 212 rank-two anchors out of 216 pattern and role checks. Each +pattern leaves at most one role unanchored, so any pair changes an +anchored diagonal. The fixed all-+1 erased endpoint also has a common +off-diagonal determinant 64 for every diagonal target and requires at +least four rank-one corrections. [Proof and directed prices](PROOF.md). + +## Replay + +From a clean checkout with CPython 3.12 and assertions enabled, run + +```sh +python3.12 -I -B research/p104-type-a-same-clock-phase-retirement-bound/replay.py +``` + +The standard-library replay authenticates one signed caller payload +and both price inputs, regenerates eight exact receipts, compares the +independent decisions, and rejects altered dependencies and duplicate +path keys. Use `--out fresh-directory` to retain the receipts. +[Source provenance](PROVENANCE.json) · [Verification](VERIFICATION.md). + +## Open next questions + +Can one changed even operation or QUERY clock preserve the same +contract and permit a pair of phase retirements with a positive +complete price? Start by pricing one literal change, then reconstruct +both unit-body endpoints and test whether each residual has rank at +most two. The four remaining single-role anchor gaps do not establish +feasibility. Changed J stages, clocks, routing and wrappers, corrections +of rank greater than one, and nondiagonal targets are outside the +proved class. The best pair cannot pay for one extra rank-one field +on each port. + +## Credit + +[#7334](https://github.com/CrocSwap/integer-mult-bounds/pull/7334) +supplies the complete comparison witness, and +[#7113](https://github.com/CrocSwap/integer-mult-bounds/pull/7113) +supplies the signed caller. +[#7309](https://github.com/CrocSwap/integer-mult-bounds/pull/7309) +supplies the neighboring relative-rank bound at the original target. +[#7342](https://github.com/CrocSwap/integer-mult-bounds/pull/7342) +supplies the nearby fixed-cut formal pair repair and its open physical +two-return gate. This package tests changed productive diagonals and +covers all pairs with the same-clock even-scalar reduction. +[#7316](https://github.com/CrocSwap/integer-mult-bounds/pull/7316) +studies the same rank-137 roots with the paid profile fixed. +[#7362](https://github.com/CrocSwap/integer-mult-bounds/pull/7362) +and [#7298](https://github.com/CrocSwap/integer-mult-bounds/pull/7298) +supply the base invoice and directed tariff. +OpenAI Codex and subagents materially assisted proof, implementation, +independent verification and packaging. diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/SOURCES.json b/research/p104-type-a-same-clock-phase-retirement-bound/SOURCES.json new file mode 100644 index 0000000000..e8c2f265cd --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/SOURCES.json @@ -0,0 +1,18 @@ +{ + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "path": "certificates/selected-result.json", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1", + "usage": "provenance" + }, + { + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "path": "docs/research/agent-task-catalog.json", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81", + "usage": "provenance" + } + ], + "schema_version": 1 +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/TASK.json b/research/p104-type-a-same-clock-phase-retirement-bound/TASK.json new file mode 100644 index 0000000000..c1204830f4 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/TASK.json @@ -0,0 +1,117 @@ +{ + "actual_scope": "One exact 4,783-event #7334/#7113 Type A caller on 36 coordinates, including 17 J stages and 96 ports. At unit bodies, keep all operations and QUERY clocks fixed, except grant arbitrary q-even rational QUERY coefficients and at most two rank-one corrections. Exclude every q=-1 diagonal target changing at least two entries of -I with q=+1 target I. The all-plus erased endpoint separately requires four corrections for any diagonal target.", + "ai_assistance": "OpenAI Codex and subagents materially assisted proof, implementation, independent verification and packaging.", + "author": "P104 Type A same-clock phase retirement research", + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bottleneck_link": "Retiring two q factors would improve the binding complex invoice if the signed caller kept both endpoints with two fewer rank-one paid queries. Every two-root phase retirement fails a necessary exact endpoint condition in this class.", + "budget_minutes": 10, + "evidence": "Forward and reverse replay agree on a common off-diagonal determinant 64, the exact rank reduction to six balanced coefficient patterns, and 212 of 216 rank-two diagonal anchors. Each pattern leaves at most one unanchored role, excluding all 630 distinct root pairs.", + "open_questions": [ + { + "blocked_by": "The fixed-clock scalar class fails for every two-root phase retirement, and an extra rank-one field on each of the 96 ports exceeds the best pair's gross allowance.", + "first_step": "Price one literal changed operation or clock, then reconstruct both unit-body endpoints and compare each residual rank with two before full signed replay.", + "question": "Can a changed even skeleton or a changed query clock make a two-root phase retirement feasible under the same complete price and signed contract?", + "why_it_matters": "Changing the erased endpoint can evade the same-clock rank and diagonal constraints and may realize a positive relaxed price." + } + ], + "original_card": { + "acceptance_gate": "An exact arbitrary-input identity, source/target frame availability and restoration at the chosen cut, plus the complete channel+correction+idle/hosting bill or an explicit favorable bound. The native channel alone is not a supplier. A scoped local result may be retained without a complete supplier. Expanding it into further construction rounds requires the family-level budget and obligation gate in research-family-status.md; an optimistic passing relaxation alone is not acceptance.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "existing_checks": [ + { + "evidence": "research/p104-literal-slot-defect/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "scope": "PR #4133: literal-slot defect", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "88666f1dee93fbd85b31fd5d6f91a219e111b5f4", + "status": "author-checked" + }, + { + "evidence": "research/p104-uniform-commutation-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "scope": "PR #4136: uniform commutation gap", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "281ce601a8be9db470de630759179c23e1dfaa88", + "status": "author-checked" + }, + { + "evidence": "research/p104-uniform-encoding-gap/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "scope": "PR #4140: uniform encoding gap", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "de25c6525aa866962309df5d107b32d55e6e5628", + "status": "author-checked" + }, + { + "evidence": "research/p104-source-chart-shortcut/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "scope": "PR #4153: source-chart shortcut exhausts its optimistic allowance", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "9123241fea53df77e51ffe30d9aca1625d4bf3a8", + "status": "author-checked" + }, + { + "evidence": "research/p104-fiber-tag-seam/README.md", + "remaining": "Independently validate the stated scope or change its producer/consumer premise and pay the complete boundary.", + "scope": "PR #4154: fiber-tag seam mismatch", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "source_commit": "4ffcdaee5d6255a9cea1fe53a5424435068089d0", + "status": "author-checked" + }, + { + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "status": "reviewed" + } + ], + "first_experiment": "Start with the selected #5599 emitted word and review pending #5718 distinct input/output bases plus #5717/#5719 coverage before claiming work. Pick one uncovered source word, helper group and cut region. Prove the arbitrary-input relation and legal entry/exit corrections, then compare full target and paid profiles. Reject if completion, owned lifetimes or consumer costs repay the gain. A static pairing rank alone is not a physical split.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "id": "p104-side-correction", + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "overlap_terms": [ + "P104", + "helper basis", + "helper split", + "5718", + "dyadic capacity" + ], + "question": "Can joint helper bases and a legal causal split improve the complete P104 productive/paid invoice?", + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "research/p104-helper-subspace-splits/README.md", + "research/dyadic-helper-channel-capacity/README.md" + ] + }, + "outcome": "negative-result", + "priority_revision": 8, + "schema_version": 1, + "scope_change_reason": "Allow arbitrary even scalars at four unchanged Type A QUERY clocks and test the changed productive endpoints rather than a fixed-target native split.", + "scope_status": "changed", + "stop_rule": "The fixed all-plus baseline uses one erased word and two signs. The coefficient reduction uses two opposite-sign calibrations and six mixed words, two signs and a 20-second solver cap per engine. The final check reuses six mixed words at q=-1, covers 216 role checks and one fallback pair within 20 solver seconds.", + "task_id": "p104-side-correction" +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/VERIFICATION.md b/research/p104-type-a-same-clock-phase-retirement-bound/VERIFICATION.md new file mode 100644 index 0000000000..c9e8d5f839 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/VERIFICATION.md @@ -0,0 +1,44 @@ +# Verification + +The fixed all-plus replay verifies original ±I endpoints, the +unchanged q=+1 erased endpoint, and a missing-query rank-one +control. Independent forward and reverse engines agree entry by +entry on the full 36-by-36 residual for roots 0/18. The common +off-diagonal minor has determinant 64. + +The even-coefficient replay verifies the two rank-four calibration +controls and six balanced sign patterns. The first forward attempt +assumed the q=−1 witness indices also gave a nonzero minor at +q=+1. That minor was zero while the full q=+1 difference had +rank four. The corrected forward and independent reverse engines +agree on both calibrations and all six cases. The reverse engine +also detects a damaged control row. + +The first independent reverse outer wrapper failed after writing +the complete scientific output because zsh reserves the name +`status`. The exact output was separately verified. The clean +package invokes that same engine directly, checks its process exit +and regenerates the receipt byte for byte. +[Diagnostic receipt](receipts/DIAGNOSTICS.json). + +The diagonal replay compares 212 exact anchors across 216 checks. +Both engines agree on all missing roles and the six residual +ranks for the prepriced alternate pair 0/17. The reverse engine +verifies the nonzero 3×3 minor after a one-coordinate change for +every anchored role. The 630 pairs follow from the anchor proof. + +The package regenerates both exact prices and six rank receipts +and matches their hashes. It authenticates the shipped payloads +against their original manifests. Altered caller, base price and +engine bytes, and duplicate dependency keys, are rejected. The +replay requires only CPython 3.12 and its standard library. + +Direct CPython 3.12.14 replay exited 0 in 1.65 seconds. A +relocated Git-free replay with a cleared environment exited 0 in +1.80 seconds and reproduced all eight receipts byte for byte. +The registered repository runner checked the pinned canonical +source provenance and exited 0 in 2.10 seconds from staging. +The committed-tree check and hosted checks apply to the exact +publication head. [Local replay checks](receipts/REPLAY-CHECKS.json). + +[Clean replay](README.md) · [Exact receipt hashes](receipts/SHA256.json). diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/VERIFY.json b/research/p104-type-a-same-clock-phase-retirement-bound/VERIFY.json new file mode 100644 index 0000000000..ceb41b21b9 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/VERIFY.json @@ -0,0 +1,19 @@ +{ + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/replay.py" + ], + "checks": "Regenerate both directed prices, independent fixed and arbitrary even-coefficient rank receipts, and both diagonal-anchor receipts. Check all 630 pairs by the common anchor argument and reject altered caller, price and replay dependencies.", + "timeout_seconds": 120 + } + ], + "inputs": [], + "python": "3.12", + "requirements": [], + "schema_version": 1, + "status": "ready" +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/engines/anchors.py b/research/p104-type-a-same-clock-phase-retirement-bound/engines/anchors.py new file mode 100644 index 0000000000..a1126d6389 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/engines/anchors.py @@ -0,0 +1,104 @@ +"""Exact rank-two diagonal completion anchors for the six Type A words.""" + +from fractions import Fraction +from hashlib import sha256 +from itertools import combinations +from json import dumps, loads +from pathlib import Path +from runpy import run_path +from signal import SIGALRM, alarm, signal + +ROOT = Path(__file__).resolve().parent +CALLER_SHA256 = "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc" +ROLES = 36 +ANCHOR_ROWS = (0, 1, 18, 19) +ANCHOR_COLS = (2, 9, 20, 27) +FLIPS = (0, 17) + + +def choose_anchor(matrix, avoid): + original_rows = tuple(i for i in ANCHOR_ROWS if i != avoid) + original_cols = tuple(i for i in ANCHOR_COLS if i != avoid) + candidates = ( + (original_rows, original_cols), + (tuple(i for i in range(ROLES) if i != avoid), None), + ) + for rows, cols in candidates: + for r, s in combinations(rows, 2): + columns = cols + if columns is None: + columns = tuple(i for i in range(ROLES) if i not in (avoid, r, s)) + first = next((i for i in columns if matrix[r][i] or matrix[s][i]), None) + if first is None: + continue + for j in columns: + det = matrix[r][first] * matrix[s][j] - matrix[r][j] * matrix[s][first] + if det: + return [r, s], [first, j], det + return None + + +def stop(*_): + raise TimeoutError("20-second exact cap") + + +def main(): + assert __debug__ + signal(SIGALRM, stop) + alarm(20) + source = ROOT / "literal.py" + engine = run_path(str(source)) + diagonal, transfer, difference, rank = ( + engine[k] for k in ("diagonal", "transfer", "difference", "rank") + ) + raw = (ROOT / "inputs/CALLER.json").read_bytes() + assert sha256(raw).hexdigest() == CALLER_SHA256 + caller = loads(raw) + alpha = Fraction(caller["types"]["A"]["alpha2"]) + events = caller["events"] + reference = diagonal(-1) + assert transfer(events, alpha, -1) == reference + changed = diagonal(-1) + for i in FLIPS: + changed[i][i] = 1 + + patterns = [] + for positive in combinations(range(4), 2): + coefficients = tuple(1 if i in positive else -1 for i in range(4)) + erased = transfer(events, alpha, -1, coefficients) + off_diagonal_reference = difference(erased, reference) + assert rank(off_diagonal_reference) == 2 + anchors = [] + missing = [] + for role in range(ROLES): + anchor = choose_anchor(off_diagonal_reference, role) + if anchor is None: + missing.append(role) + continue + rows, cols, det = anchor + assert set(rows).isdisjoint(cols) + assert role not in rows and role not in cols + anchors.append([role, rows, cols, det]) + + # Changing one anchored diagonal produces the same 2×2 block and + # a nonzero 3×3 determinant by the Schur-complement identity. + role, rows, cols, det = anchors[0] + control = [row.copy() for row in off_diagonal_reference] + control[role][role] += 2 + assert engine["minor"](control, (*rows, role), (*cols, role))["determinant"] == 2 * det + patterns.append({ + "coefficients": coefficients, "anchors": anchors, "missing_roles": missing, + "changed_pair_rank": rank(difference(erased, changed)), + }) + + alarm(0) + print(dumps({ + "pins": {"inputs/CALLER.json": CALLER_SHA256, "literal.py": sha256(source.read_bytes()).hexdigest()}, + "candidate_pair": FLIPS, "patterns": patterns, + "number_of_anchors": sum(len(x["anchors"]) for x in patterns), + "words": len(patterns), "hard_cap_seconds": 20, "controls": ["original -I", "one corrupted diagonal"], + }, indent=2, sort_keys=True, default=str)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/engines/coefficients.py b/research/p104-type-a-same-clock-phase-retirement-bound/engines/coefficients.py new file mode 100644 index 0000000000..1950d7c12b --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/engines/coefficients.py @@ -0,0 +1,85 @@ +"""Bound the four same-clock even coefficients at the Type A unit-body endpoints.""" + +from fractions import Fraction +from hashlib import sha256 +from itertools import combinations +from json import dumps, loads +from pathlib import Path +from runpy import run_path +from signal import SIGALRM, alarm, signal + +ROOT = Path(__file__).resolve().parent +CALLER_SHA256 = "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc" +FLIPS = (0, 18) +ROWS = (0, 1, 18, 19) +COLUMNS = (2, 9, 20, 27) + + +def stop(*_): + raise TimeoutError("20-second exact cap") + + +def main(): + assert __debug__ + signal(SIGALRM, stop) + alarm(20) + source = ROOT / "literal.py" + engine = run_path(str(source)) + diagonal, transfer, difference, minor, rank = [ + engine[name] for name in ("diagonal", "transfer", "difference", "minor", "rank") + ] + raw = (ROOT / "inputs/CALLER.json").read_bytes() + assert sha256(raw).hexdigest() == CALLER_SHA256 + caller = loads(raw) + events = caller["events"] + assert len(events) == 4783 + alpha = Fraction(caller["types"]["A"]["alpha2"]) + baseline_plus = diagonal(1) + baseline_minus = diagonal(-1) + assert transfer(events, alpha, 1) == baseline_plus + assert transfer(events, alpha, -1) == baseline_minus + + minus_changed = difference(transfer(events, alpha, -1, (1,) * 4), baseline_minus) + minus_minor = minor(minus_changed, ROWS, COLUMNS) + assert minus_minor["determinant"] == 64 + assert set(ROWS).isdisjoint(COLUMNS) + + plus_changed = difference(transfer(events, alpha, 1, (-1,) * 4), baseline_plus) + assert rank(plus_changed) == 4 + plus_nonzero = [ + [i, j, v] for i, row in enumerate(plus_changed) for j, v in enumerate(row) if v + ] + desired_minus = diagonal(-1) + for i in FLIPS: + desired_minus[i][i] = 1 + + results = [] + for plus_slots in combinations(range(4), 2): + coefficients = tuple(1 if i in plus_slots else -1 for i in range(4)) + plus = transfer(events, alpha, 1, coefficients) + minus = transfer(events, alpha, -1, coefficients) + assert rank(difference(plus, baseline_plus)) == 2 + assert rank(difference(minus, baseline_minus)) == 2 + residual = difference(desired_minus, minus) + results.append({ + "coefficients": coefficients, + "unchanged_plus_rank": 2, + "unchanged_minus_rank": 2, + "changed_minus_rank": rank(residual), + }) + + alarm(0) + print(dumps({ + "pins": {"inputs/CALLER.json": CALLER_SHA256, "literal.py": sha256(source.read_bytes()).hexdigest()}, + "plus_all_opposite_rank": 4, + "plus_all_opposite_nonzero_entries": plus_nonzero, + "minus_all_opposite_off_diagonal_minor": minus_minor, + "flipped_roots": FLIPS, + "tested_sign_patterns": results, + "survivors": [r["coefficients"] for r in results if r["changed_minus_rank"] <= 2], + "cases": 8, "roles": 36, "events": len(events), "hard_cap_seconds": 20, + }, indent=2, sort_keys=True, default=str)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/engines/diagonal_anchors.py b/research/p104-type-a-same-clock-phase-retirement-bound/engines/diagonal_anchors.py new file mode 100644 index 0000000000..c905c0981b --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/engines/diagonal_anchors.py @@ -0,0 +1,159 @@ +"""Check diagonal rigidity of the six remaining Type A erased endpoints.""" +import argparse +import hashlib +from itertools import combinations +import json +from pathlib import Path +import runpy +import signal + +ROOT = Path(__file__).resolve().parent +CALLER_SHA256 = "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc" +ENGINE_SHA256 = "9e99b716a78afb9d90fee8cf66d6eb1ead88a45c93e89e735cd626e4471756e7" +ANCHOR_ROWS = (0, 1, 18, 19) +ANCHOR_COLUMNS = (2, 9, 20, 27) +ROLES = 36 +LIMIT = 20 + + +def alarm_handler(_signum, _frame): + raise TimeoutError("20-second diagonal-anchor cap") + + +def read_pinned(path, expected): + raw = path.read_bytes() + if hashlib.sha256(raw).hexdigest() != expected: + raise ValueError("changed input " + path.name) + return raw + + +def determinant2(matrix, rows, columns): + i, j = rows + a, b = columns + return matrix[i][a] * matrix[j][b] - matrix[i][b] * matrix[j][a] + + +def determinant3(matrix, rows, columns): + ((a, b, c), (d, e, f), (g, h, i)) = [[matrix[r][s] for s in columns] for r in rows] + return a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g) + + +def first_anchor(matrix, row_pairs, col_pairs, root=None): + for rows in row_pairs: + if root in rows: + continue + for columns in col_pairs: + if root in columns or not set(rows).isdisjoint(columns): + continue + value = determinant2(matrix, rows, columns) + if value: + return rows, columns, value + return None + + +def choose_anchors(matrix): + main_rows = list(combinations(ANCHOR_ROWS, 2)) + main_columns = list(combinations(ANCHOR_COLUMNS, 2)) + origin = first_anchor(matrix, main_rows, main_columns) + assert origin is not None + basis_rows, basis_columns, _ = origin + + # For a rank-two matrix the anchor factors A[:,basis_columns] and + # A[basis_rows,:] have rank two. Cauchy--Binet excludes exactly the + # row or column pairs with zero determinant in their respective factors. + all_pairs = list(combinations(range(ROLES), 2)) + usable_rows = [rows for rows in all_pairs if determinant2(matrix, rows, basis_columns)] + usable_columns = [cols for cols in all_pairs if determinant2(matrix, basis_rows, cols)] + + anchors = {} + missing = [] + for root in range(ROLES): + witness = first_anchor(matrix, main_rows, main_columns, root) + if witness is None: + witness = first_anchor(matrix, usable_rows, usable_columns, root) + if witness is None: + missing.append(root) + continue + rows, cols, determinant = witness + assert root not in rows and root not in cols and set(rows).isdisjoint(cols) + r3, c3 = (*rows, root), (*cols, root) + assert determinant3(matrix, r3, c3) == 0 + # Corrupt only the new corner. Every other entry is off diagonal + # and fixed by the unchanged erased endpoint. + matrix[root][root] += 1 + assert determinant3(matrix, r3, c3) == determinant + matrix[root][root] -= 1 + anchors[str(root)] = dict(rows=rows, columns=cols, determinant=determinant) + return anchors, missing + + +def fallback_pair(matrices, rank): + pair = (0, 17) + ranks = [] + for _, matrix in matrices: + residual = [row[:] for row in matrix] + for root in pair: + residual[root][root] -= 2 + ranks.append(rank(residual)[0]) + return dict(roots=pair, evaluated=True, residual_ranks=ranks) + + +def main(): + assert __debug__ + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--caller", type=Path, default=ROOT/"inputs/CALLER.json") + parser.add_argument("--engine", type=Path, default=ROOT/"replay_r164.py") + args = parser.parse_args() + signal.signal(signal.SIGALRM, alarm_handler) + signal.alarm(LIMIT) + + read_pinned(args.engine, ENGINE_SHA256) + engine = runpy.run_path(str(args.engine)) + caller = json.loads(read_pinned(args.caller, CALLER_SHA256)) + events = caller["events"] + type_a = caller["types"]["A"] + assert len(events) == 4783 and type_a["roles"] == ROLES + assert type_a["alpha2"] == "-1" and type_a["beta2"] == "0" + assert [e[1] for e in events if e[0] == "J"] == list(range(1, 18)) + clocks = engine["QUERY_CLOCKS"] + assert tuple(i for i, e in enumerate(events) if e[:2] == ["A", "QUERY"]) == clocks + + rank = engine["rank"] + configs = [tuple(1 if i in plus else -1 for i in range(4)) for plus in combinations(range(4), 2)] + matrices = [] + cases = [] + for constants in configs: + matrix = engine["pullback"](engine["specialized"](events, -1, constants)) + for i in range(ROLES): + matrix[i][i] += 1 + assert rank(matrix)[0] == 2 + off_diagonal = [[matrix[i][j] for j in ANCHOR_COLUMNS] for i in ANCHOR_ROWS] + assert rank(off_diagonal)[0] == 2 + anchors, missing = choose_anchors(matrix) + assert len(anchors) + len(missing) == ROLES + cases.append(dict(constants=constants, full_rank=2, off_diagonal_rank=2, + anchors=anchors, missing=missing)) + matrices.append((constants, matrix)) + + total = sum(len(case["anchors"]) for case in cases) + if total < len(configs) * ROLES: + next_pair = fallback_pair(matrices, rank) + else: + next_pair = dict(roots=(0, 17), evaluated=False, reason="All diagonal entries are fixed by anchors.") + receipt = dict( + head=engine["HEAD"], caller_head=engine["CALLER_HEAD"], + pins={"inputs/CALLER.json": CALLER_SHA256, "replay_r164.py": ENGINE_SHA256}, + roles=ROLES, events=len(events), fixed_J_stages=17, zero_based_query_clocks=clocks, + unit_body=True, q=-1, words=len(configs), checks=len(configs) * ROLES, + anchors=total, missing=len(configs) * ROLES - total, cases=cases, + standard_offdiagonal_rows=ANCHOR_ROWS, standard_offdiagonal_columns=ANCHOR_COLUMNS, + next_pair=next_pair, hard_cap_seconds=LIMIT, + controls=["original minus endpoint inherited from R164", + "changing each anchored diagonal alone produces a nonzero rank-three minor"], + ) + signal.alarm(0) + print(json.dumps(receipt, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/engines/literal.py b/research/p104-type-a-same-clock-phase-retirement-bound/engines/literal.py new file mode 100644 index 0000000000..19696b1906 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/engines/literal.py @@ -0,0 +1,141 @@ +"""Forward exact Type A endpoint replay for fixed even QUERY coefficients.""" + +from fractions import Fraction +from hashlib import sha256 +from itertools import permutations +from json import dumps, loads +from math import prod +from pathlib import Path +from signal import SIGALRM, alarm, signal + +ROOT = Path(__file__).resolve().parent +CALLER_SHA256 = "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc" +QUERY_INDICES = (1516, 1580, 1659, 1721) +ROLES = 36 +FLIPS = (0, 18) + + +def diagonal(q): + return [[Fraction(q if i == j else 0) for j in range(ROLES)] for i in range(ROLES)] + + +def transfer(events, alpha, q, query_coefficient=None, omit_query=None): + rows = diagonal(1) + + def add(dest, source, coefficient): + rows[dest] = [ + a + coefficient * b for a, b in zip(rows[dest], rows[source], strict=True) + ] + + for index, event in enumerate(events): + if event[0] == "J": + _, _, (u, v, x, y), _ = event + add(v, u, q) + add(x, y, alpha * q) + continue + if event[0] == "B": + continue + kind, op, dest, *args = event + assert kind == "A" + if op == "ADD": + add(dest, args[0], Fraction(args[1])) + elif op == "QUERY": + assert index in QUERY_INDICES and args[1] == -1 + if index != omit_query: + factor = q if query_coefficient is None else query_coefficient + if isinstance(factor, tuple): + factor = factor[QUERY_INDICES.index(index)] + add(dest, args[0], factor) + elif op == "SWAP": + peer, = args + rows[dest], rows[peer] = rows[peer], rows[dest] + elif op == "SCALE": + coefficient, = args + rows[dest] = [Fraction(coefficient) * x for x in rows[dest]] + else: + # LAMBDA has q²=1 and the IDLE_ONE bodies are all unit at this test. + assert op in ("LAMBDA", "IDLE_ONE") + return rows + + +def difference(a, b): + return [[x - y for x, y in zip(u, v, strict=True)] for u, v in zip(a, b, strict=True)] + + +def rank(matrix): + rows = [r.copy() for r in matrix if any(r)] + pivot_row = 0 + for col in range(ROLES): + pivot = next((i for i in range(pivot_row, len(rows)) if rows[i][col]), None) + if pivot is None: + continue + rows[pivot_row], rows[pivot] = rows[pivot], rows[pivot_row] + for i in range(pivot_row + 1, len(rows)): + ratio = rows[i][col] / rows[pivot_row][col] + rows[i] = [a - ratio * b for a, b in zip(rows[i], rows[pivot_row], strict=True)] + pivot_row += 1 + return pivot_row + + +def minor(matrix, row_ids, col_ids): + entries = [[matrix[i][j] for j in col_ids] for i in row_ids] + size = len(entries) + determinant = sum( + (-1) ** sum(p[i] > p[j] for i in range(size) for j in range(i + 1, size)) + * prod(entries[i][p[i]] for i in range(size)) + for p in permutations(range(size)) + ) + return {"rows": row_ids, "columns": col_ids, "entries": entries, "determinant": determinant} + + +def stop(*_): + raise TimeoutError("20-second exact cap") + + +def main(): + assert __debug__ + signal(SIGALRM, stop) + alarm(20) + raw = (ROOT / "inputs/CALLER.json").read_bytes() + assert sha256(raw).hexdigest() == CALLER_SHA256 + caller = loads(raw) + events = caller["events"] + assert len(events) == 4783 + assert [event[1] for event in events if event[0] == "J"] == list(range(1, 18)) + assert [i for i, e in enumerate(events) if e[:2] == ["A", "QUERY"]] == list(QUERY_INDICES) + assert all(events[i] == ["A", "QUERY", 0, 1, -1] for i in QUERY_INDICES) + type_a = caller["types"]["A"] + assert type_a["roles"] == ROLES and len(type_a["ports"]) == 96 + alpha = Fraction(type_a["alpha2"]) + for q in (-1, 1): + assert transfer(events, alpha, q) == diagonal(q) + + erased_plus = transfer(events, alpha, 1, query_coefficient=1) + assert erased_plus == diagonal(1) + missing = transfer(events, alpha, 1, omit_query=QUERY_INDICES[0]) + assert rank(difference(missing, erased_plus)) == 1 + erased_minus = transfer(events, alpha, -1, query_coefficient=1) + target = diagonal(-1) + for i in FLIPS: + target[i][i] = 1 + residual = difference(target, erased_minus) + residual_rank = rank(residual) + universal = minor(residual, (0, 1, 18, 19), (2, 9, 20, 27)) + assert residual_rank == 4 and universal["determinant"] == 64 + assert set(universal["rows"]).isdisjoint(universal["columns"]) + entries = [[i, j, v] for i, row in enumerate(residual) for j, v in enumerate(row) if v] + alarm(0) + print(dumps({ + "caller_sha256": CALLER_SHA256, + "head": "aaeec8c0acf01e99a5f331ef363a698d9c084ace", + "caller_head": "07a76c5e2738882c0cb322278e56f6cae3c9885d", + "roles": ROLES, "events": len(events), "query_indices_zero_based": QUERY_INDICES, + "fixed_j": 17, "target_phase_retirements": FLIPS, "even_query_factor": 1, + "candidate_rank": residual_rank, "off_diagonal_minor": universal, + "nonzero_delta_entries": entries, "hard_cap_seconds": 20, + "controls": ["original +I and -I", "erased +I unchanged", "one omitted QUERY gives rank one"], + }, indent=2, sort_keys=True, default=str)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/engines/price.py b/research/p104-type-a-same-clock-phase-retirement-bound/engines/price.py new file mode 100644 index 0000000000..e062ca5e61 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/engines/price.py @@ -0,0 +1,51 @@ +"""Exact upper quote for the highest-ranked pair after roots 0/18.""" + +from collections import Counter +from fractions import Fraction +from hashlib import sha256 +from json import dumps, loads +from pathlib import Path +from runpy import run_path + +ROOT = Path(__file__).resolve().parent +PINS = { + "inputs/CALLER.json": "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc", + "inputs/R92-PRICE.json": "05d7a5ebdd2eeedd6c8f534e8e2eeac22484daf9f387f4a6b88cc9eed22a6b8f", + "inputs/pricing.py": "f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182", +} + + +def read(path): + raw = (ROOT / path).read_bytes() + assert sha256(raw).hexdigest() == PINS[path] + return raw + + +def main(): + for path in PINS: + read(path) + base = loads(read("inputs/R92-PRICE.json")) + caller = loads(read("inputs/CALLER.json")) + ranks = [1 + 8 * sum(row[2:]) for row in caller["types"]["A"]["diagonal"]] + assert sorted(ranks)[-4:] == [73, 73, 137, 137] + assert (ranks[0], ranks[17]) == (137, 73) + delta = Counter({1: 192, 72: 96, 73: -96, 136: 96, 137: -96}) + cost = run_path(str(ROOT / "inputs/pricing.py"))["cost"] + stock = Counter({int(r): n for r, n in base["old_targets"].items()}) + stock.subtract({int(r): n for r, n in base["old_paid"].items()}) + stock.update(delta) + assert sum(r * n for r, n in stock.items()) == 1424 + quote = { + "roots": [0, 17], "ranks": [137, 73], "signed_histogram_delta": delta, + "head": base["head"], "caller_head": base["caller_head"], "pins": PINS, + "gross_at_crossing_upper": cost(delta, Fraction(base["old_crossing_upper"])), + "complete_at_probe": cost(stock, Fraction(base["probe"])), + } + assert quote["gross_at_crossing_upper"][0] > 0 + assert quote["complete_at_probe"][0] > 0 + print(dumps(quote, indent=2, sort_keys=True, default=str)) + + +if __name__ == "__main__": + assert __debug__ + main() diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/engines/quote.py b/research/p104-type-a-same-clock-phase-retirement-bound/engines/quote.py new file mode 100644 index 0000000000..2fd59160f8 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/engines/quote.py @@ -0,0 +1,44 @@ +"""Price removal of two odd target factors and two Type A query calls.""" +from collections import Counter +from fractions import Fraction as Q +from hashlib import sha256 +from json import dumps, loads +from pathlib import Path +from runpy import run_path + +ROOT = Path(__file__).resolve().parent +PINS = { + "inputs/CALLER.json":"255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc", + "inputs/R92-PRICE.json":"05d7a5ebdd2eeedd6c8f534e8e2eeac22484daf9f387f4a6b88cc9eed22a6b8f", + "inputs/pricing.py":"f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182", +} +raw = {} +for name, pin in PINS.items(): + raw[name] = (ROOT/name).read_bytes() + assert sha256(raw[name]).hexdigest() == pin +base,c = (loads(raw[k]) for k in ("inputs/R92-PRICE.json","inputs/CALLER.json")) +A = c["types"]["A"] +assert len(A["ports"]) == 96 and len(A["diagonal"]) == 36 +ranks = [1+8*sum(row[2:]) for row in A["diagonal"]] +assert all(row[0:2] == [-1,0] for row in A["diagonal"]) +assert [i for i,r in enumerate(ranks) if r == max(ranks)] == [0,18] and max(ranks)==137 +assert [t for t,e in enumerate(c["events"]) if e[:2]==["A","QUERY"]]==[1516,1580,1659,1721] +p,t = (Counter({int(r):v for r,v in base[key].items()}) for key in ("old_paid","old_targets")) +stock = t.copy() +stock.subtract(p) +assert (sum(p.values()),sum(t.values()),sum(r*n for r,n in stock.items()))==(110519,22461,1424) +delta = {1:192,136:192,137:-192} +edit = stock.copy() +edit.update(delta) +assert sum(r*n for r,n in edit.items())==1424 +cost = run_path(str(ROOT/"inputs/pricing.py"))["cost"] +q = {} +for label in ("old_crossing_upper","probe","moonshot"): + k=Q(base[label]) + gross=cost(delta,k) + q[label]=dict(gross=list(map(str,gross)), complete=list(map(str,cost(edit,k))), + whole_two_pairs_relaxed_upper=str(2*gross[1])) +assert Q(q["probe"]["complete"][0]) > 0 +print(dumps(dict(head=base["head"],caller=base["caller_head"],pins=PINS,roots=[0,18],paid=110327,productive=22461, + paid_delta={1:-192},productive_delta={136:192,137:-192},quote=q,whole_compatible_relaxation=2), + indent=2,sort_keys=True)) diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/engines/replay_r164.py b/research/p104-type-a-same-clock-phase-retirement-bound/engines/replay_r164.py new file mode 100644 index 0000000000..7f39008ac5 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/engines/replay_r164.py @@ -0,0 +1,192 @@ +"""Independent exact reverse-covector replay with exact integer rank of the same-clock Type A variants.""" +import argparse +import hashlib +import json +import signal +from itertools import combinations, permutations +from math import gcd, prod +from pathlib import Path + +HEAD = "aaeec8c0acf01e99a5f331ef363a698d9c084ace" +CALLER_HEAD = "07a76c5e2738882c0cb322278e56f6cae3c9885d" +CALLER_SHA256 = "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc" +QUERY_CLOCKS = (1516, 1580, 1659, 1721) +ROOTS = (0, 18) +ROLES = 36 +LIMIT = 20 + + +def alarm_handler(_signum, _frame): + raise TimeoutError("20-second exact replay cap") + + +def specialized(events, q, constants): + """List nonidentity primal operations after every body specializes to 1.""" + operations = [] + replacements = dict(zip(QUERY_CLOCKS, constants, strict=True)) + for clock, event in enumerate(events): + if event[0] == "B": + continue + if event[0] == "J": + _, _, (u, v, x, y), _ = event + assert len({u, v, x, y}) == 4 + # The pinned Type A alpha2 is -1. + operations.extend((("ADD", v, u, q), ("ADD", x, y, -q))) + continue + family, operation, dest, *args = event + assert family == "A" + if operation == "QUERY": + assert clock in QUERY_CLOCKS and args == [1, -1] + operations.append(("ADD", dest, args[0], replacements[clock])) + elif operation == "ADD": + source, factor = args + operations.append(("ADD", dest, source, int(factor))) + elif operation == "SCALE": + operations.append(("SCALE", dest, int(args[0]))) + elif operation == "SWAP": + operations.append(("SWAP", dest, args[0])) + else: + assert operation in ("LAMBDA", "IDLE_ONE") + if operation == "LAMBDA": + # Both projectors reduce to the identity because q^2=1. + assert args == [1] or args == [-1] + return operations + + +def diagonal(signs): + return [[sign if i == j else 0 for j in range(ROLES)] for i, sign in enumerate(signs)] + + +def pullback(operations): + rows = diagonal([1] * ROLES) + for output in rows: + for operation, dest, *args in reversed(operations): + if operation == "ADD": + source, factor = args + output[source] += factor * output[dest] + elif operation == "SWAP": + peer, = args + output[dest], output[peer] = output[peer], output[dest] + else: + assert operation == "SCALE" + output[dest] *= args[0] + return rows + + +def difference(left, right): + return [[x - y for x, y in zip(a, b, strict=True)] for a, b in zip(left, right, strict=True)] + + +def rank(matrix): + """Fraction-free elimination with primitive integer row normalization.""" + rows = [row[:] for row in matrix] + ids = list(range(len(rows))) + cols = [] + for j in range(len(rows[0])): + k = len(cols) + pivot = next((i for i in range(k, len(rows)) if rows[i][j]), None) + if pivot is None: + continue + ids[k], ids[pivot] = ids[pivot], ids[k] + rows[k], rows[pivot] = rows[pivot], rows[k] + weight = rows[k][j] + for i in range(k + 1, len(rows)): + factor = rows[i][j] + if factor: + row = [weight * x - factor * y for x, y in zip(rows[i], rows[k], strict=True)] + content = gcd(*row) + rows[i] = [x // content for x in row] if content else row + cols.append(j) + return len(cols), ids[:len(cols)], cols + + +def determinant(matrix): + n = len(matrix) + return sum( + (-1) ** sum(p[i] > p[j] for i in range(n) for j in range(i + 1, n)) + * prod(matrix[i][p[i]] for i in range(n)) + for p in permutations(range(n)) + ) + + +def witness(matrix, rows, cols): + minor = [[matrix[i][j] for j in cols] for i in rows] + d = determinant(minor) + assert d + return dict(rows=rows, columns=cols, matrix=minor, determinant=d) + + +def main(): + assert __debug__ + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--caller", type=Path, default=Path(__file__).resolve().parent / "inputs/CALLER.json" + ) + args = parser.parse_args() + signal.signal(signal.SIGALRM, alarm_handler) + signal.alarm(LIMIT) + + source = args.caller.read_bytes() + if hashlib.sha256(source).hexdigest() != CALLER_SHA256: + raise ValueError("changed signed caller") + caller = json.loads(source) + events = caller["events"] + typ = caller["types"]["A"] + assert len(events) == 4783 and typ["roles"] == ROLES and typ["offset"] == 0 + assert typ["alpha2"] == "-1" and typ["beta2"] == "0" and len(typ["ports"]) == 96 + assert [e[1] for e in events if e[0] == "J"] == list(range(1, 18)) + assert tuple(i for i, e in enumerate(events) if e[:2] == ["A", "QUERY"]) == QUERY_CLOCKS + + base_plus = diagonal([1] * ROLES) + base_minus = diagonal([-1] * ROLES) + target = diagonal([1 if i in ROOTS else -1 for i in range(ROLES)]) + all_plus = (1,) * len(QUERY_CLOCKS) + all_minus = (-1,) * len(QUERY_CLOCKS) + balanced = [ + tuple(1 if i in positive else -1 for i in range(len(QUERY_CLOCKS))) + for positive in combinations(range(len(QUERY_CLOCKS)), 2) + ] + configs = [all_plus, all_minus, *balanced] + assert len(configs) == len(set(configs)) == 8 + maps = {(s, q): pullback(specialized(events, q, s)) for s in configs for q in (1, -1)} + assert maps[all_plus, 1] == base_plus and maps[all_minus, -1] == base_minus + + plus_delta = difference(base_plus, maps[all_minus, 1]) + plus_rank, plus_rows, plus_cols = rank(plus_delta) + assert plus_rank == 4 + plus_control = witness(plus_delta, plus_rows, plus_cols) + rows = (0, 1, 18, 19) + cols = (2, 9, 20, 27) + assert set(rows).isdisjoint(cols) + minus_control = witness(difference(base_minus, maps[all_plus, -1]), rows, cols) + assert minus_control["determinant"] == 64 + assert minus_control == witness(difference(target, maps[all_plus, -1]), rows, cols) + damaged = minus_control["matrix"][:-1] + [[0] * 4] + assert rank(damaged)[0] == 3 and determinant(damaged) == 0 + + cases = [] + for constants in balanced: + plus = difference(base_plus, maps[constants, 1]) + minus = difference(target, maps[constants, -1]) + minus_rank, row_ids, col_ids = rank(minus) + plus_rank = rank(plus)[0] + assert plus_rank == 2 + minor = witness(minus, row_ids[:3], col_ids[:3]) if minus_rank > 2 else None + cases.append(dict(constants=constants, residual_ranks=[plus_rank, minus_rank], minus_exclusion=minor)) + + receipt = dict( + head=HEAD, caller_head=CALLER_HEAD, pins={"inputs/CALLER.json": CALLER_SHA256}, + roots=ROOTS, events=len(events), fixed_J_stages=17, roles=ROLES, + zero_based_query_clocks=QUERY_CLOCKS, phase_signs=[1, -1], unit_body=True, + rank_one_correction_budget=2, evaluated_erased_words=len(configs), hard_cap_seconds=LIMIT, + plus_full_rank_control=plus_control, minus_offdiagonal_full_rank_control=minus_control, + balanced_cases=cases, unresolved=[c["constants"] for c in cases if max(c["residual_ranks"]) <= 2], + controls=["original +I and -I", "minus control independent of target diagonal", + "one damaged control row reduces rank from four to three"], + ) + signal.alarm(0) + print(json.dumps(receipt, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/engines/replay_reverse.py b/research/p104-type-a-same-clock-phase-retirement-bound/engines/replay_reverse.py new file mode 100644 index 0000000000..279a5e34ef --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/engines/replay_reverse.py @@ -0,0 +1,168 @@ +"""Independent exact reverse-covector replay of the fixed erased Type A caller.""" +import argparse +import hashlib +import json +import signal +from fractions import Fraction +from pathlib import Path + +HEAD = "aaeec8c0acf01e99a5f331ef363a698d9c084ace" +CALLER_HEAD = "07a76c5e2738882c0cb322278e56f6cae3c9885d" +CALLER_SHA256 = "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc" +QUERY_CLOCKS = (1516, 1580, 1659, 1721) +ROOTS = (0, 18) +ROLES = 36 +LIMIT = 20 + + +def alarm_handler(_signum, _frame): + raise TimeoutError("20-second exact replay cap") + + +def phase(q, exponent): + return q if exponent % 2 else 1 + + +def specialized(events, q, query_factor=None, omitted=None): + """List nonidentity primal operations after every body specializes to 1.""" + operations = [] + for clock, event in enumerate(events): + if event[0] == "B": + continue + if event[0] == "J": + _, _, (u, v, x, y), _ = event + assert len({u, v, x, y}) == 4 + # The pinned Type A alpha2 is -1. + operations.extend((("ADD", v, u, q), ("ADD", x, y, -q))) + continue + family, operation, dest, *args = event + assert family == "A" + if operation == "QUERY": + assert clock in QUERY_CLOCKS and args == [1, -1] + if clock != omitted: + factor = phase(q, args[1]) if query_factor is None else query_factor + operations.append(("ADD", dest, args[0], factor)) + elif operation == "ADD": + source, factor = args + operations.append(("ADD", dest, source, int(factor))) + elif operation == "SCALE": + operations.append(("SCALE", dest, int(args[0]))) + elif operation == "SWAP": + operations.append(("SWAP", dest, args[0])) + else: + assert operation in ("LAMBDA", "IDLE_ONE") + if operation == "LAMBDA": + # Both projectors reduce to the identity because q^2=1. + assert args == [1] or args == [-1] + return operations + + +def diagonal(signs): + return [[sign if i == j else 0 for j in range(ROLES)] for i, sign in enumerate(signs)] + + +def pullback(operations): + rows = diagonal([1] * ROLES) + for output in rows: + for operation, dest, *args in reversed(operations): + if operation == "ADD": + source, factor = args + output[source] += factor * output[dest] + elif operation == "SWAP": + peer, = args + output[dest], output[peer] = output[peer], output[dest] + else: + assert operation == "SCALE" + output[dest] *= args[0] + return rows + + +def difference(left, right): + return [[x - y for x, y in zip(a, b, strict=True)] for a, b in zip(left, right, strict=True)] + + +def rank_witness(matrix): + """Track original row and column IDs through exact rational elimination.""" + reduced = [list(map(Fraction, row)) for row in matrix] + ids = list(range(ROLES)) + cols = [] + for j in range(ROLES): + step = len(cols) + pivot = next((i for i in range(step, ROLES) if reduced[i][j]), None) + if pivot is None: + continue + cols.append(j) + reduced[step], reduced[pivot] = reduced[pivot], reduced[step] + ids[step], ids[pivot] = ids[pivot], ids[step] + for i in range(step + 1, ROLES): + if reduced[i][j]: + factor = reduced[i][j] / reduced[step][j] + for k in range(j, ROLES): + reduced[i][k] -= factor * reduced[step][k] + return len(cols), ids[:len(cols)], cols + + +def determinant3(rows): + (a, b, c), (d, e, f), (g, h, i) = rows + return a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g) + + +def main(): + assert __debug__ + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--caller", type=Path, default=Path(__file__).resolve().parent / "inputs" / "CALLER.json" + ) + args = parser.parse_args() + signal.signal(signal.SIGALRM, alarm_handler) + signal.alarm(LIMIT) + + source = args.caller.read_bytes() + assert hashlib.sha256(source).hexdigest() == CALLER_SHA256 + caller = json.loads(source) + events = caller["events"] + typ = caller["types"]["A"] + assert len(events) == 4783 and typ["roles"] == ROLES and typ["offset"] == 0 + assert typ["alpha2"] == "-1" and typ["beta2"] == "0" and len(typ["ports"]) == 96 + assert [e[1] for e in events if e[0] == "J"] == list(range(1, 18)) + assert tuple(i for i, e in enumerate(events) if e[:2] == ["A", "QUERY"]) == QUERY_CLOCKS + + plus = pullback(specialized(events, 1)) + minus = pullback(specialized(events, -1)) + assert plus == diagonal([1] * ROLES) and minus == diagonal([-1] * ROLES) + corrupted = pullback(specialized(events, 1, omitted=QUERY_CLOCKS[0])) + assert rank_witness(difference(plus, corrupted))[0] == 1 + + erased_plus = pullback(specialized(events, 1, query_factor=1)) + erased_minus = pullback(specialized(events, -1, query_factor=1)) + assert erased_plus == plus + target = diagonal([1 if i in ROOTS else -1 for i in range(ROLES)]) + delta = difference(target, erased_minus) + rank, row_ids, col_ids = rank_witness(delta) + witness = None + if rank >= 3: + rows = row_ids[:3] + cols = col_ids[:3] + minor = [[delta[i][j] for j in cols] for i in rows] + determinant = determinant3(minor) + assert determinant + witness = dict(rows=rows, columns=cols, matrix=minor, determinant=determinant) + + receipt = dict( + head=HEAD, caller_head=CALLER_HEAD, + pins={"inputs/CALLER.json": CALLER_SHA256}, + roles=ROLES, roots=ROOTS, phase_signs=[1, -1], + events=len(events), fixed_J_stages=17, zero_based_query_clocks=QUERY_CLOCKS, + unit_body=True, even_query_factor=1, allowed_rank_one_insertions=2, + rank=rank, pivot_rows=row_ids, pivot_columns=col_ids, witness=witness, + nonzero_delta_entries=[[i, j, x] for i, row in enumerate(delta) for j, x in enumerate(row) if x], + disposition="fixed-erased class excluded" if rank > 2 else "necessary gate passed, feasibility unresolved", + controls=["original +I and -I", "one missing QUERY changes +I by rank one", "erased +I unchanged"], + hard_cap_seconds=LIMIT, + ) + signal.alarm(0) + print(json.dumps(receipt, indent=2, sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/inputs/7113-SHA256.json b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/7113-SHA256.json new file mode 100644 index 0000000000..5a7d6b80dc --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/7113-SHA256.json @@ -0,0 +1,69 @@ +{ + "replay/supplier7108/CALLER.json": "9557f713ab4ffb91ede05e8a6d5668c694b9940fc16f2f2d657e2f2b2cac2d3f", + "replay/supplier7112/RESULT.json": "7b808ff32d9803084aaaf820cd172ddc9001c7aebbd17e0324e779abeff91b30", + "replay/supplier7112/WORD.json.gz": "fe0b1dc3049a6b72760a705af2e698e0e9998e969e19862a696eba63434eb233", + "replay/supplier7112/short-caller/DATA-PHASES.json": "c5916ff312678f12aba403847643fbbc29f643acec60bdf836fa56cd3e8251fa", + "replay/supplier7112/short-caller/ODD-LOCALIZED-GROUPING.json": "8aac6b3d9e528bffbcf411bbd300c8e0f0b7bf75da45ab12badf3f3530ffcbe2", + "replay/supplier7112/short-caller/ODD-UNIT-DYADIC-TAPES.json": "c3195057f7a6723a81172ed540d0f1c4ba699ff3cb8dc37cbde7bb481d9b976c", + "replay/supplier7112/short-caller/ODD-UNIT-PREFIX-CLOSURES.json": "3b953e5d3e83e7573a3e908a5a23edb78773d4d22816aca54f766f0f0e9f5403", + "replay/supplier7112/short-caller/SHORT-ADMISSION-PARTIAL.json": "7977815fe72382738727e3d550eea3bc735923c9c57968872d4f863cb39cd401", + "replay/supplier7112/short-caller/SHORT-CALLER-RAW-PRICE.json": "a4f83d65d250efb40f6506658374d7414afdde11c96eb88b7d2fbb182aa090c1", + "replay/supplier7112/short-caller/SHORT-CATALOGUE-0-1000.log": "a916a76627fb79bf606b22f857ca93db6342891fb2c85b20658b5002c359e422", + "replay/supplier7112/short-caller/SHORT-CATALOGUE-1000-2000.log": "da633bfa408e98a2f2a958262a09d5e4274a9b25f7b4a6a73df5a97f37338f79", + "replay/supplier7112/short-caller/SHORT-CATALOGUE-2000-3047.log": "e8d500c0261a4a9e0cf3da2838d82806ed497ab9cf57cb8620ca6debfb98525c", + "replay/supplier7112/short-caller/SHORT-PRECISION.json": "68a00d2b83ee2eb944d2e05fc7f32bc9aa37282c45b968f0ab6fd500659ac028", + "replay/supplier7112/short-caller/SHORT-TYPE-A-ROOT.json": "e9812d720942d8149c219dfa28c1081ff1d353529e5282ca4624a04233f38f88", + "replay/supplier7112/short-caller/admission-source/ARCHIVE-CHAIN.json": "6de95c4eb396e69883fbeeb3989782bbbe232c22644af1c804050badca10f456", + "replay/supplier7112/short-caller/admission-source/FULL-RESULT.json": "d9ba709fa5dcefffe3f3abdcf34600ce188224703cfd743e6db8b58ba4816cb7", + "replay/supplier7112/short-caller/admission-source/INDEPENDENT-NOTICE.md": "cadbc642ca84311d2c7a6cf704c7828cb4cf77e3c784b66e4c6e8a5c28002fb8", + "replay/supplier7112/short-caller/admission-source/INDEPENDENT-SOURCES.json": "dced1457df5230466ba6202fd6d4595bc2b7fb2a65302806bf2720b1837ff350", + "replay/supplier7112/short-caller/admission-source/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "replay/supplier7112/short-caller/admission-source/NATIVE-INPUTS.json": "9bb6c1567783661334d6c1d23f715ce5635cbbb513678819ab9e020a34c7e4c0", + "replay/supplier7112/short-caller/admission-source/NOTICE": "da12736e2e824167ff56f2ecb623a5f88f75a270410360890f61dffc33bab249", + "replay/supplier7112/short-caller/admission-source/data/bit-admission.json": "a46b6c6040f75184cab5467656811ad988c216e3bc8e44d595a5015b6e49620b", + "replay/supplier7112/short-caller/admission-source/data/caller.json": "3828d53e80ea97e8b866320f081af20b6b93bfebd58b95b56b85a7afe151af5e", + "replay/supplier7112/short-caller/admission-source/data/final.json.gz": "2b94953dc14a122e3ef089633f05b58ec689ec5156feb7c784ed3e137dc01883", + "replay/supplier7112/short-caller/admission-source/frozen/clifford_exact.py": "2982ead07721e83358dc67c6f49c2b4c16a236a6bebdfd72f58221be1f5d0962", + "replay/supplier7112/short-caller/admission-source/frozen/native_verify.py": "3049471905b47b385c88378a1a3be7a18b8858aadd035b8a6da2f4a03b470f38", + "replay/supplier7112/short-caller/admission-source/frozen/physical.py": "4e995d1158033d83bf69b671f23dc7924d66edbbe07623ba063ba7421234ea20", + "replay/supplier7112/short-caller/admission-source/frozen/verify_host3_odd.py": "e75ad2096ba2587d1dc9c8982b2c2eb7c6fd2636a80adcd943314ef2cf6fd258", + "replay/supplier7112/short-caller/admission-source/independent.py": "21f46a8340331abb1486b50bd4e04453f1968b0a5950d86ff7780dd368590874", + "replay/supplier7112/short-caller/admission-source/interval_gate.py": "60a743d13f668ef86db4b8215b4d5d04430a671ba6f1fe06d9c1c4c3dfe86da5", + "replay/supplier7112/short-caller/admission-source/precision_replay.py": "850d9098c5946ab27ef5228acc54d59df2196e72259d3e21588ec0c319c8f5ee", + "replay/supplier7112/short-caller/admission-source/retained/odd-native-common-grid/independent_bounds.py": "198521def614fe78fa728f1dde2b7fb820c0c0e0ac3ad0c9224dccbf51eac0d5", + "replay/supplier7112/short-caller/admission-source/retained/query-only-precision-envelope/envelopes.py": "783da6b5b450fc07434946cb9ec86070dfee01df6b5fa1c385cb024def2c9a9f", + "replay/supplier7112/short-caller/admission-source/retained/query-only-precision-envelope/source_binding.py": "624c459311c58f3847b7713b818bfd340153abf42919f02ac9aa8892ed52a2bd", + "replay/supplier7112/short-caller/assemble_odd_application.py": "6cdac39ab196a70c53ba2283c2555cd8dee30644dcc4769628b46fb53bd55a1f", + "replay/supplier7112/short-caller/candidate_gate.py": "e71097ca81a082afd7c647324a6c94cb357aeb1084693a095a0f3e0b45a9b11a", + "replay/supplier7112/short-caller/check_odd_caller_exact_grid.py": "abd5a5fd011b71e5b382cbc058855594d4f2fe7b049f375506675c0303180f54", + "replay/supplier7112/short-caller/check_odd_fixed_tape_counts.py": "e6246e9f8fbeae3077d82e585eafd3647c1a8758c58f33c7c13e7efa6c1e42bb", + "replay/supplier7112/short-caller/check_odd_partial_admission.py": "4416b1ea5f07f8a91028a2e500116588fbdfaed95a8ef9bac7a46bcb44b9478e", + "replay/supplier7112/short-caller/check_odd_physical_binding.py": "5c80c3b0415a7f91d216395248dd6f13297eed637732098e1ca8fb0548951b98", + "replay/supplier7112/short-caller/check_odd_precision.py": "b2d9c13577158157a587ace766d9dadb7819a0164b372722329d9754e1be6c61", + "replay/supplier7112/short-caller/connected.py": "469537b46fb92c5aca926d3b1497da5425408673b0a73ba1427f23d872b414e7", + "replay/supplier7112/short-caller/cut_library.py": "7ccb81af19db54ec7cdb44849af018d4ca8893f80f17277914f8566715985133", + "replay/supplier7112/short-caller/emit_odd_type_ab.py": "7a7993648433c6febad8c07b315aec1b96598835a3f587b62040423c33c3b71f", + "replay/supplier7112/short-caller/emit_odd_type_b.py": "d1fa8b67d98beacd6bb574b3d5fcbc94b8646a7ffbce91d2a6fd4d690d3c5329", + "replay/supplier7112/short-caller/host34.py": "bded1a8626d65ee40c4ba3b25780fc03f0fa08906f3c83f631892df072d9a9b7", + "replay/supplier7112/short-caller/independent.py": "21f46a8340331abb1486b50bd4e04453f1968b0a5950d86ff7780dd368590874", + "replay/supplier7112/short-caller/interval_gate.py": "60a743d13f668ef86db4b8215b4d5d04430a671ba6f1fe06d9c1c4c3dfe86da5", + "replay/supplier7112/short-caller/lower.py": "67345fdfc8e5bb816e24b37dfafad0396372c48ec4e1b95b8b69f019a8fdfdee", + "replay/supplier7112/short-caller/mirrored.py": "55dd441a3a7f504b351857d45fd701994a0950ae1baec6c4c2b4b0166fb69db3", + "replay/supplier7112/short-caller/odd_unit_dyadic_tapes.py": "3cdafa35635360a487ce400ec8d585f6134dd7c58209543528e98e7db178bbc7", + "replay/supplier7112/short-caller/screen.py": "01e3eaba4b710a080e6e393e53157e6a119fdf312620eed26e9185ca91f6bea6", + "replay/supplier7112/short-caller/short_dyadic_seam.py": "6e588b365618ab2df4fa2d1f16073d09a953a7cd6e826e1f96bbf87f950b672b", + "replay/supplier7112/short-caller/short_native_catalogue.py": "775695c379f407801910531565cc371012cee501b2cec5f5d718ecdccf06b64d", + "replay/supplier7112/short-caller/signed_child.py": "ef03444360f02225138be9b38e2f9a85f313eeaa910d63a365de0f16d228cb8b", + "replay/supplier7112/short-caller/signed_model.py": "f88c798b9a22c656ea0b755b4f32be411c1f80687dff1a1ac9e9c2a0b5f4203e", + "replay/supplier7112/short-caller/stage.py": "0ab5546e926dd98d3ad833909b534840b7d8d0467c4790ca09bc2b14b37313f5", + "replay/supplier7112/short-caller/upstream_application.py": "d98987db98553dc55bfc80e3ca47abfcd51c57af6f8cda61101391d8eae94184", + "replay/supplier7112/short-caller/upstream_native_catalogue.py": "6120e1ea1e07eeba757694d209437a38f121b0a377cc466889a30fa52c561472", + "expected/ODD-8X9-APPLICATION-CHECKS.json": "10512d62f540fe7bb839ec94b6a21bbdf4a3dfadf56b4ec9095d4b242bda19b8", + "expected/ODD-ADMISSION-PARTIAL.json": "75ec76e4393ef1622fcff9e2727dc411921076af4a506d97506665add140fa86", + "expected/ODD-CALLER-EXACT-GRID.json": "87d25d9fa3778bf4784e3a9e17f32ce5ba372663c6e97392cc62b87e6719042c", + "expected/ODD-FIXED-TAPE-COUNTS.json": "1a8bf36a966edca8c61f3be803cdbe136307095dec40245cdc93e79a9062fe99", + "expected/ODD-PHYSICAL-BINDING.json": "ade5f8cbb2e30677b1d48d23a1aa270b3d0b72e2504472ab9fdb71d124b075b5", + "expected/ODD-PRECISION.json": "9c03607288cc2afb80cb02c197f93360978233036418b32b09ad91be16f9c153", + "expected/ODD-TYPE-AB-CALLER.json": "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc", + "expected/ODD-TYPE-AB-REPLAY.json": "71fd0a7ad8b743266c6a75100f3543b48ea7d6fcbe45f008d3b61270e3b660a0" +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/inputs/7334-ADMITTED.json b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/7334-ADMITTED.json new file mode 100644 index 0000000000..464c89e45c --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/7334-ADMITTED.json @@ -0,0 +1,58 @@ +{ + "assumptions": [ + "native_all_columns", + "owned_erasure", + "compiler", + "precision_tape", + "analytic_recovery" + ], + "base": "e54523517d0f03e58352e647c403a5af3e525a57", + "caller": "07a76c5e2738882c0cb322278e56f6cae3c9885d", + "caller_sha256": "255d89f38cd45e38e5770f559bc43dc217e989032359768cdc7e8cdfd64b47bc", + "crossing": [ + "0.00364665195644044790699554028334161", + "0.00364665195644044790699554028334162" + ], + "end": "2026-11-11T23:04:43Z", + "exit": 0, + "head": "aaeec8c0acf01e99a5f331ef363a698d9c084ace", + "hosted_at_admission": "plan and historical success; candidate replay in progress", + "inputs": { + "EARLY-RESULT.json": "ad1ca9b2e2febbf80d9bf8b6ceef14ff90fcc29ef9358310e551628eb1706649", + "INPUTS.json": "abedac59097a1c35c27d91cbdb07207bc562a64743bc406d13c94a8bc970592d", + "NATIVE-RESULT.json": "c6d1b00a83185ab0062397b363258b1f3f6685d755e9c1d4f7d3e7e511240812", + "PROPOSED-CLAIM.json": "6e31241944c123d2bd4aa8bc94d833b44b3d889bd6d9aafc579108f416b45f03", + "RESULT.json": "7f2d587c59f063b01f1e8b320084a7f0943f2f05d65e3e0f5e80448c6c8e8194", + "SOURCES.json": "ac7b4473035af648d6073e78b6c39675e706e8194b346bb55ed62a0adc81d593", + "VERIFY.json": "ede7dd2dd3733b9a73f72af9dd7edfe819b49b859c5c76e227ec82cb9c220513", + "WORD.json.gz": "4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a" + }, + "kappa": "0.00364665195644", + "ours": "0", + "peer_gain": "0.000000430519994", + "prior_kappa": "0.003646221436446", + "receipt": { + "peer-prep/IDENTITIES.json": "f4d3f6ca2d87f8cd68c01ac9f77b69bd5a796f92bd567cea8afe3ac7c72e8e4b", + "peer-prep/STATIC.json": "500cc563b7dac8b1de1faf1dee9b820e73152dfddc15a650cd1191edd39e8c79", + "peer-price/RANK-STOCK.json": "4a7841699dd17688f6aada5c902a2a91e94558b2b1b4460c46b0e55aa95b3f9f", + "peer-price/READBACK.json": "337668788fb39ec9575887f9c5faf438a880471f78d936357dabf7deeac5de82", + "peer/COMMAND.txt": "714bfab024155d8216f3ef99f3ee7627ddc35ab341c486ac6bd53c476b757130", + "peer/COMMIT.stdout": "597470d8132a3812deb3624a859546c0c13d52b094fd6fc61e7416941130bd70", + "peer/END-UTC.txt": "9c46923c616c14da5b8ed503e1652021d7bd409a10ec91a78a03263013fba08a", + "peer/METADATA.stdout": "5873404cb4424dca918a00d503569f3c29a3190fd029a007e1afb2006399f647", + "peer/RUN.exit": "9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa", + "peer/RUN.stderr": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "peer/RUN.stdout": "d589626c7581fbb9928bc615364cfee49deb62dfc0a39a903417ca62be89cf8c", + "peer/START-UTC.txt": "5b78fd6d42a2b42206891318c08e6014de57d7ca46b0201cd11a166f452210f7" + }, + "source_history": "exact anchored base and recursive package provenance, sparse shallow stock wrapper not executed", + "stages": { + "caller": "PASS_HELPER_319_FUSED_CALLER 91166298911/25000000000000", + "early": "PASS_HELPER_319_EXACT_NATIVE_AND_SIGNED_PRICE 0.00364665195644", + "frontier": "PASS_HELPER_319_FUSED_FRONTIER_PROPOSAL 91166298911/25000000000000", + "native": "PASS_HELPER_319_FUSED_NATIVE 3646017316711/1000000000000000" + }, + "start": "2026-11-11T22:54:48Z", + "status": "independently_reproduced_comparable", + "tree": "fa98712a459b20c10240450097c87de433f8a750" +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/inputs/CALLER.json.gz b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/CALLER.json.gz new file mode 100644 index 0000000000..2479c3a615 Binary files /dev/null and b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/CALLER.json.gz differ diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/inputs/PLAN.md b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/PLAN.md new file mode 100644 index 0000000000..87cc897477 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/PLAN.md @@ -0,0 +1,9 @@ +# Same-clock Type A phase retirement gates + +Pin complete #7334 `aaeec8c0acf01e99a5f331ef363a698d9c084ace` and signed caller #7113 `07a76c5e2738882c0cb322278e56f6cae3c9885d`. + +Price the 137/137 roots 0 and 18 across 96 Type A ports before testing. Grant two saved rank-one paid fields while preserving all body factors and every unchanged literal operation. + +1. Check one all-plus erased word on 36 roles at unit bodies and q=±1. Verify the known-good ±I endpoints and the missing-query control. Stop at 20 solver seconds per engine. +2. To grant arbitrary q-even coefficients at the four fixed clocks, verify the two opposite-sign calibration words and six mixed words. Use a 20-second solver cap per engine. A rank above two excludes an endpoint in the two-rank-one class. +3. Reuse only the six balanced words for up to 216 diagonal anchor checks. If any anchor is missing, check one prepriced alternate pair 0/17 on the same matrices. Stop at 20 solver seconds per engine. An unresolved two-root case would require a complete signed-body, ownership, restoration and price check before a build. diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/inputs/PR7362-SHA256.json b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/PR7362-SHA256.json new file mode 100644 index 0000000000..b1486e0b5c --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/PR7362-SHA256.json @@ -0,0 +1,11 @@ +{ + "R92-COMPARE.json": "92bd567e3203a2cbc2e0c508bf921966c59ead267c1f373f7534a4a50cb208ac", + "R92-GEOMETRY.json": "e9f93f3271855012b2de705c70f186f78c31a369d28110e92c5f2ffadae209b3", + "R92-GUARDS.json": "c23e9c74b3479e4af6c452eeb73e000878148ec385560a0642433a1c5bac4a07", + "R92-PRICE.json": "05d7a5ebdd2eeedd6c8f534e8e2eeac22484daf9f387f4a6b88cc9eed22a6b8f", + "R92-REVERSE.json": "f8e56b109352e07dfb8203bdbe42a10cb94374246b4cd419421e4f52e2730c4a", + "R93-COMPARE.json": "8a1f52179e5d457aa729714b0b79577894c1e22ab74a8b2f700838f471ffceb1", + "R93-MODULAR.json": "01ad2a656e69699b80b56d63cdf82448e424cd1c6e67636d53c079a6f03f55a5", + "R93-PRICE.json": "c108a061c6c03306a99a6fbafe919208954a7479ae28fb8a8fbf45d9832e6144", + "R93-RATIONAL.json": "2800af56efe23f7420a12f0713a659cd4fa4a3fb7c58449749ef697097ccccbf" +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/inputs/R92-PRICE.json.gz b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/R92-PRICE.json.gz new file mode 100644 index 0000000000..5aabb0ff2e Binary files /dev/null and b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/R92-PRICE.json.gz differ diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/inputs/pricing.py b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/pricing.py new file mode 100644 index 0000000000..40ec194017 --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/inputs/pricing.py @@ -0,0 +1,82 @@ +"""Directed interval arithmetic and the retained signed BIT invoice.""" +from collections import Counter +from fractions import Fraction +from functools import cache + +TARGET = "10018846261809/2500000000000000" +SCALE = 10**49 + + +def rounded(x, upper): + scaled = SCALE*x + if upper: + return Fraction(-((-scaled.numerator) // scaled.denominator), SCALE) + return Fraction(scaled.numerator // scaled.denominator, SCALE) + + +@cache +def log_bounds(x): + z = (x-1)/(x+1) + terms = 60 + exact_partial = 2*sum(z**(2*i+1)/(2*i+1) for i in range(terms)) + tail = 2*z**(2*terms+1)/((2*terms+1)*(1-z*z)) + return rounded(exact_partial, False), rounded(exact_partial+tail, True) + + +@cache +def power_bounds(rank, k): + binary = 2**(rank.bit_length()-1) + shift = binary.bit_length()-1 + l2, u2 = log_bounds(Fraction(2)) + lo, hi = log_bounds(Fraction(rank, binary)) + lo, hi = k*(lo+shift*l2), k*(hi+shift*u2) + assert 0 <= lo <= hi < 1 + + def exponential(z, terms): + total = term = Fraction(1) + for i in range(1, terms+1): + term *= -z/i + total += term + return total + + return rounded(rank*exponential(hi, 35), False), rounded(rank*exponential(lo, 34), True) + + +def cost(hist, k): + lower = upper = Fraction(0) + for r, n in hist.items(): + a, b = (n*x for x in power_bounds(r, k)) + lower += min(a, b) + upper += max(a, b) + return lower, upper + + +def profile(invoice, native, word, ranks): + copies = invoice["native_calls"] + assert copies == len(invoice["native_instances"]) == 36 + assert {tuple((r["stage"], r["copy"])) for r in invoice["native_instances"]} == { + (stage, which) for stage in range(1, 19) for which in (0, 1) + } + assert all(r["ports"] == 111 for r in invoice["native_instances"]) + assert native == Counter({int(r): n for r, n in invoice["native_paid"].items()}) + assert sum(native.values()) == 2871 + caller_paid = {1: 444, **{r: 444 for r in range(7, 57, 7)}} + assert invoice["event_counts"]["QUERY"]*111 == caller_paid[1] + assert invoice["event_counts"]["IDLE_ONE"]*111 == 8*444 + full_paid = Counter({r: copies*n for r, n in native.items()}) + full_paid.update(caller_paid) + + helpers = Counter(ranks[word["final"][j]]-ranks[word["start"][j]] + for j in range(222, word["public"])) + assert helpers == Counter({int(r): n for r, n in invoice["native_helpers"].items()}) + caller_targets = {**{r: 444 for r in range(8, 65, 7)}, 127: 222} + full_targets = Counter({r: copies*n for r, n in helpers.items()}) + full_targets.update(caller_targets) + assert full_paid == Counter({int(r): n for r, n in invoice["paid"].items()}) + assert full_targets == Counter({int(r): n for r, n in invoice["targets"].items()}) + assert sum(full_paid.values()) == invoice["paid_jobs"] + assert sum(full_targets.values()) == invoice["productive_fields"] + signed = full_targets.copy() + signed.subtract(full_paid) + assert sum(r*n for r, n in signed.items()) == invoice["rank_surplus"] + return signed, copies diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/receipts/DIAGNOSTICS.json b/research/p104-type-a-same-clock-phase-retirement-bound/receipts/DIAGNOSTICS.json new file mode 100644 index 0000000000..5e6b00259d --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/receipts/DIAGNOSTICS.json @@ -0,0 +1,19 @@ +{ + "same_clock_initial_forward": { + "exit_code": 1, + "failed_script_sha256": "661e195584eab2eb505b41588dd954bc85fcda575eb9f02f2969cb06fd132f5e", + "failure": "The q=-1 off-diagonal witness indices gave a zero q=+1 minor. The complete q=+1 difference still had rank four.", + "resolution": "Use full q=+1 rank and a separately selected nonzero minor, which the reverse engine records with determinant 16.", + "stderr_sha256": "cfd0397538d06a023bc7501477e96b69803627979b6598139b19fa565a744de2", + "stdout_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "same_clock_initial_reverse": { + "captured_receipt_sha256": "e2b679cd4908f65dfb71f0a29cae890508907b44a6469a3b31e663d6daf433ce", + "failure": "The outer zsh wrapper assigned to its readonly variable status after the Python output was written.", + "python_exit_code_captured": false, + "resolution": "The clean package reruns the same frozen reverse engine directly through subprocess and checks its return code and exact receipt.", + "separate_output_verification": "PASS_INDEPENDENT_R164_REVERSE_FRACTION_FREE_MATCH", + "wrapper_exit_code": 1, + "wrapper_note_sha256": "9d3385a7bb6e4b8539782f1140e805d4558a09de2b21c4c32cf83b572ac65095" + } +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/receipts/REPLAY-CHECKS.json b/research/p104-type-a-same-clock-phase-retirement-bound/receipts/REPLAY-CHECKS.json new file mode 100644 index 0000000000..de950dbbad --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/receipts/REPLAY-CHECKS.json @@ -0,0 +1,32 @@ +{ + "checks": { + "direct": { + "command": "python3.12 -I -B research/p104-type-a-same-clock-phase-retirement-bound/replay.py --out fresh", + "command_scope": "The run invoked replay.py directly by its package path.", + "elapsed_seconds": "1.65", + "exit_code": 0, + "stdout": "PASS_P104_TYPE_A_SAME_CLOCK_PHASE_RETIREMENT_BOUND words=8 roles=36 anchors=212 pairs_excluded=630", + "stdout_sha256": "5278d53e166e7d28fd289ae688a45141ecd6148fba59fe36c1511f8dcc1b042c" + }, + "registered_staging": { + "checker_commit": "f4872bebf9298436d1a68b1ed6ab20311ee39cdb", + "checker_sha256": "e1256016e7f51827d04fa2179255989f639ae1d97afaa9c16265f85a0c6abd70", + "command": "python3.12 -B scripts/research_package.py --package research/p104-type-a-same-clock-phase-retirement-bound", + "elapsed_seconds": "2.10", + "exit_code": 0, + "source_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "stdout": "CHECK Regenerate both directed prices, independent fixed and arbitrary even-coefficient rank receipts, and both diagonal-anchor receipts. Check all 630 pairs by the common anchor argument and reject altered caller, price and replay dependencies.\nPASS_P104_TYPE_A_SAME_CLOCK_PHASE_RETIREMENT_BOUND words=8 roles=36 anchors=212 pairs_excluded=630\nPASS_REGISTERED_RESEARCH_PACKAGE research/p104-type-a-same-clock-phase-retirement-bound outcome=negative-result", + "stdout_sha256": "6a3f596c9395cefe3b9989057268faa536724c98d91dfb132ec422f726a08463" + }, + "relocated_clear_environment": { + "command": "PYTHON312=$(command -v python3.12)\nenv -i PATH=/usr/bin:/bin \"$PYTHON312\" -I -B research/p104-type-a-same-clock-phase-retirement-bound/replay.py --out fresh", + "command_scope": "The run supplied an absolute interpreter path while clearing the environment.", + "elapsed_seconds": "1.80", + "exit_code": 0, + "stdout": "PASS_P104_TYPE_A_SAME_CLOCK_PHASE_RETIREMENT_BOUND words=8 roles=36 anchors=212 pairs_excluded=630", + "stdout_sha256": "5278d53e166e7d28fd289ae688a45141ecd6148fba59fe36c1511f8dcc1b042c" + } + }, + "python": "CPython 3.12.14", + "receipts_byte_identical": 8 +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/receipts/SHA256.json b/research/p104-type-a-same-clock-phase-retirement-bound/receipts/SHA256.json new file mode 100644 index 0000000000..d81f90549c --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/receipts/SHA256.json @@ -0,0 +1,10 @@ +{ + "ANCHOR-FORWARD.json": "71490c66105554b3a2f97b7f5fa56997132e3a97cd0b4965a6067fe7af7ccf70", + "ANCHOR-REVERSE.json": "09b7e45b161b153120a0980322e9ac22818c5a097c708be81f8e9a16c130bcb7", + "EVEN-FORWARD.json": "13ee349d0ffd32ddea781f72a9f02399f9aa7286422b13dd87e038cfe11188a3", + "EVEN-REVERSE.json": "e2b679cd4908f65dfb71f0a29cae890508907b44a6469a3b31e663d6daf433ce", + "FORWARD.json": "f74438dc4d5af21a446ff204aeafcf44e78055a565a26a949b87072eb457acff", + "NEXT-PRICE.json": "6692f5cc417638d82bd411240d5c19f141b83866e9262a8d03854caf9f6ea3e8", + "PRICE.json": "f391ce52c393bd9366795028a66e3874622c8b942029c0de5acbbeb750fc49a7", + "REVERSE.json": "e80009066d13d8fd6f5f948ecd5e2e69bff8f633321e077941381b241fbfd0fa" +} diff --git a/research/p104-type-a-same-clock-phase-retirement-bound/replay.py b/research/p104-type-a-same-clock-phase-retirement-bound/replay.py new file mode 100644 index 0000000000..4a8d2d757d --- /dev/null +++ b/research/p104-type-a-same-clock-phase-retirement-bound/replay.py @@ -0,0 +1,236 @@ +"""Replay the same-clock Type A phase retirement bounds with two exact engines.""" +import argparse +import gzip +import hashlib +import json +from fractions import Fraction +from pathlib import Path, PurePosixPath +import subprocess +import sys +import tempfile + +ROOT = Path(__file__).resolve().parent +ROWS = (0, 1, 18, 19) +COLUMNS = (2, 9, 20, 27) +ENGINES = { + "PRICE.json": "quote.py", + "FORWARD.json": "literal.py", + "REVERSE.json": "replay_reverse.py", + "EVEN-FORWARD.json": "coefficients.py", + "EVEN-REVERSE.json": "replay_r164.py", + "ANCHOR-FORWARD.json": "anchors.py", + "ANCHOR-REVERSE.json": "diagonal_anchors.py", + "NEXT-PRICE.json": "price.py", +} +MISSING_ANCHORS = [[18], [18], [18], [0], [], []] +EVEN_RANKS = [3, 3, 3, 3, 4, 4] +NEXT_RANKS = [4, 4, 4, 3, 4, 4] + + +def unique(pairs): + out = dict(pairs) + if len(out) != len(pairs): + raise ValueError("duplicate JSON key") + return out + + +def decode(raw): + return json.loads(raw, object_pairs_hook=unique) + + +def digest(raw): + return hashlib.sha256(raw).hexdigest() + + +def source(name): + path = PurePosixPath(name) + if not path.parts or path.is_absolute() or ".." in path.parts or path.as_posix() != name: + raise ValueError("invalid package-relative path " + name) + return (ROOT / path).read_bytes() + + +def materialize(directory): + pins = decode(source("LOCAL-PINS.json")) + for name, expected in pins.items(): + if digest(source(name)) != expected: + raise ValueError("changed package dependency " + name) + provenance = decode(source("PROVENANCE.json")) + for name, entry in provenance["files"].items(): + raw = source(name) + assert digest(raw) == entry["sha256"] == pins[name] + blob = hashlib.sha1(f"blob {len(raw)}\0".encode() + raw).hexdigest() + assert blob == entry["git_blob"] + + admitted = decode(source("inputs/7334-ADMITTED.json")) + assert admitted["head"] == "aaeec8c0acf01e99a5f331ef363a698d9c084ace" + assert admitted["kappa"] == "0.00364665195644" + inputs = directory / "inputs" + inputs.mkdir() + for name, entry in provenance["derived_inputs"].items(): + raw = source(entry["file"]) + if entry.get("compression") == "gzip": + raw = gzip.decompress(raw) + assert digest(raw) == entry["sha256"] + if "manifest" in entry: + manifest = decode(source(entry["manifest"])) + assert digest(raw) == manifest[entry["key"]] + (inputs / name).write_bytes(raw) + (inputs / "pricing.py").write_bytes(source("inputs/pricing.py")) + for name in ENGINES.values(): + (directory / name).write_bytes(source("engines/" + name)) + + +def invoke(script): + return subprocess.run([sys.executable, "-I", "-B", str(script)], capture_output=True, timeout=25) + + +def verify_receipts(receipts): + price, forward, reverse = (receipts[name] for name in ("PRICE.json", "FORWARD.json", "REVERSE.json")) + assert price["head"] == forward["head"] == reverse["head"] == "aaeec8c0acf01e99a5f331ef363a698d9c084ace" + assert price["caller"] == forward["caller_head"] == reverse["caller_head"] == "07a76c5e2738882c0cb322278e56f6cae3c9885d" + assert forward["caller_sha256"] == reverse["pins"]["inputs/CALLER.json"] == price["pins"]["inputs/CALLER.json"] + assert forward["roles"] == reverse["roles"] == 36 + assert forward["events"] == reverse["events"] == 4783 + assert forward["fixed_j"] == reverse["fixed_J_stages"] == 17 + assert forward["hard_cap_seconds"] == reverse["hard_cap_seconds"] == 20 + assert forward["even_query_factor"] == reverse["even_query_factor"] == 1 + assert forward["target_phase_retirements"] == reverse["roots"] == price["roots"] == [0, 18] + assert forward["query_indices_zero_based"] == reverse["zero_based_query_clocks"] == [1516, 1580, 1659, 1721] + assert forward["candidate_rank"] == reverse["rank"] == 4 + assert price["paid_delta"] == {"1": -192} and price["productive_delta"] == {"136": 192, "137": -192} + assert Fraction(price["quote"]["old_crossing_upper"]["gross"][1]) < Fraction("4.099242419852824") + assert Fraction(price["quote"]["probe"]["complete"][0]) > Fraction("4.098855957122750") + + reverse_entries = {(i, j): Fraction(value) for i, j, value in reverse["nonzero_delta_entries"]} + forward_entries = {(i, j): Fraction(value) for i, j, value in forward["nonzero_delta_entries"]} + assert len(reverse_entries) == len(reverse["nonzero_delta_entries"]) + assert len(forward_entries) == len(forward["nonzero_delta_entries"]) + assert reverse_entries == forward_entries + assert set(ROWS).isdisjoint(COLUMNS) + minor = [[reverse_entries.get((i, j), 0) for j in COLUMNS] for i in ROWS] + assert minor == [[-6, -2, 0, 0], [-4, 0, 0, 0], [0, 0, -6, -2], [0, 0, -4, 0]] + determinant = (minor[0][0] * minor[1][1] - minor[0][1] * minor[1][0]) * ( + minor[2][2] * minor[3][3] - minor[2][3] * minor[3][2] + ) + assert determinant == 64 + forward_minor = forward["off_diagonal_minor"] + assert forward_minor["rows"] == list(ROWS) and forward_minor["columns"] == list(COLUMNS) + assert [list(map(Fraction, row)) for row in forward_minor["entries"]] == minor + assert Fraction(forward_minor["determinant"]) == determinant + + +def verify_coefficients(receipts): + forward = receipts["EVEN-FORWARD.json"] + reverse = receipts["EVEN-REVERSE.json"] + assert forward["cases"] == reverse["evaluated_erased_words"] == 8 + assert forward["events"] == reverse["events"] == 4783 + assert forward["roles"] == reverse["roles"] == 36 + assert forward["hard_cap_seconds"] == reverse["hard_cap_seconds"] == 20 + assert forward["flipped_roots"] == reverse["roots"] == [0, 18] + assert forward["plus_all_opposite_rank"] == 4 + plus = reverse["plus_full_rank_control"] + entries = {(i, j): Fraction(value) for i, j, value in forward["plus_all_opposite_nonzero_entries"]} + assert len(entries) == len(forward["plus_all_opposite_nonzero_entries"]) + assert [[-entries.get((i, j), 0) for j in plus["columns"]] for i in plus["rows"]] == plus["matrix"] + assert plus["determinant"] == 16 + minus_forward = forward["minus_all_opposite_off_diagonal_minor"] + minus_reverse = reverse["minus_offdiagonal_full_rank_control"] + assert minus_forward["rows"] == minus_reverse["rows"] == list(ROWS) + assert minus_forward["columns"] == minus_reverse["columns"] == list(COLUMNS) + assert [[-Fraction(v) for v in row] for row in minus_forward["entries"]] == minus_reverse["matrix"] + assert Fraction(minus_forward["determinant"]) == minus_reverse["determinant"] == 64 + assert not forward["survivors"] and not reverse["unresolved"] + for rank, direct, other in zip(EVEN_RANKS, forward["tested_sign_patterns"], reverse["balanced_cases"], strict=True): + assert direct["coefficients"] == other["constants"] + assert direct["unchanged_plus_rank"] == direct["unchanged_minus_rank"] == 2 + assert direct["changed_minus_rank"] == rank and other["residual_ranks"] == [2, rank] + assert other["minus_exclusion"]["determinant"] + + +def verify_anchors(receipts): + forward = receipts["ANCHOR-FORWARD.json"] + reverse = receipts["ANCHOR-REVERSE.json"] + even = receipts["EVEN-FORWARD.json"] + price = receipts["NEXT-PRICE.json"] + assert forward["words"] == reverse["words"] == 6 + assert reverse["checks"] == 216 and reverse["missing"] == 4 + assert forward["number_of_anchors"] == reverse["anchors"] == 212 + assert forward["hard_cap_seconds"] == reverse["hard_cap_seconds"] == 20 + assert price["head"] == reverse["head"] == receipts["PRICE.json"]["head"] + assert price["caller_head"] == reverse["caller_head"] == receipts["PRICE.json"]["caller"] + assert price["roots"] == forward["candidate_pair"] == reverse["next_pair"]["roots"] == [0, 17] + assert price["ranks"] == [137, 73] + assert price["signed_histogram_delta"] == {"1": 192, "72": 96, "73": -96, "136": 96, "137": -96} + assert Fraction(price["gross_at_crossing_upper"][1]) < Fraction("3.882211372694752") + assert Fraction(price["complete_at_probe"][0]) > Fraction("3.881824851665655") + assert reverse["next_pair"]["evaluated"] and reverse["next_pair"]["residual_ranks"] == NEXT_RANKS + for missing, rank, direct, other, coefficients in zip( + MISSING_ANCHORS, NEXT_RANKS, forward["patterns"], reverse["cases"], + even["tested_sign_patterns"], strict=True, + ): + assert direct["coefficients"] == other["constants"] == coefficients["coefficients"] + assert direct["missing_roles"] == other["missing"] == missing + assert direct["changed_pair_rank"] == rank + assert other["full_rank"] == other["off_diagonal_rank"] == 2 + direct_roles = {role for role, _, _, _ in direct["anchors"]} + other_roles = {int(role) for role in other["anchors"]} + assert len(direct_roles) == len(direct["anchors"]) + assert direct_roles == other_roles == set(range(36)) - set(missing) + for role, rows, columns, determinant in direct["anchors"]: + assert set(rows).isdisjoint(columns) and role not in rows and role not in columns + assert Fraction(determinant) + + +def replay(directory): + materialize(directory) + expected = decode(source("receipts/SHA256.json")) + raw_receipts = {} + for receipt, name in ENGINES.items(): + result = invoke(directory / name) + if result.returncode: + sys.stderr.buffer.write(result.stderr) + result.check_returncode() + assert digest(result.stdout) == expected[receipt], ("changed receipt", receipt) + raw_receipts[receipt] = result.stdout + receipts = {name: decode(raw) for name, raw in raw_receipts.items()} + verify_receipts(receipts) + verify_coefficients(receipts) + verify_anchors(receipts) + for filename, scripts in ( + ("inputs/CALLER.json", (("literal.py", b"AssertionError"), ("replay_reverse.py", b"AssertionError"), + ("replay_r164.py", b"changed signed caller"))), + ("inputs/R92-PRICE.json", (("quote.py", b"AssertionError"), ("price.py", b"AssertionError"))), + ("replay_r164.py", (("diagonal_anchors.py", b"changed input replay_r164.py"),)), + ): + path = directory / filename + raw = path.read_bytes() + path.write_bytes(raw + b" ") + for script, expected_error in scripts: + check = invoke(directory / script) + assert check.returncode == 1 and expected_error in check.stderr + path.write_bytes(raw) + try: + decode(b'{"inputs/CALLER.json":1,"inputs/CALLER.json":2}') + except ValueError as error: + assert str(error) == "duplicate JSON key" + else: + raise AssertionError("duplicate dependency key accepted") + return raw_receipts + + +def main(): + assert __debug__ and sys.version_info[:2] == (3, 12) + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--out", type=Path) + args = parser.parse_args() + with tempfile.TemporaryDirectory() as temporary: + raw_receipts = replay(Path(temporary)) + if args.out is not None: + args.out.mkdir(parents=True) + for name, raw in raw_receipts.items(): + (args.out / name).write_bytes(raw) + print("PASS_P104_TYPE_A_SAME_CLOCK_PHASE_RETIREMENT_BOUND words=8 roles=36 anchors=212 pairs_excluded=630") + + +if __name__ == "__main__": + main()