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-three-role-endpoint-exchange-bound/LOCAL-PINS.json b/research/p104-three-role-endpoint-exchange-bound/LOCAL-PINS.json new file mode 100644 index 0000000000..d1709b7204 --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/LOCAL-PINS.json @@ -0,0 +1,18 @@ +{ + "PROVENANCE.json": "07564412f7b170d17b9f99c71b48f6c859f4a6af973b82dcb3be50ac78c7ef3a", + "engines/close.py": "936c68002636a09b19496f47dd1d3d113c1327ae188e0b4f1190e93a61496a88", + "engines/third_basis.py": "ce1b7bbe865478a19394951a552d4a5fc6184420ae27e497bc28d062c6c03539", + "engines/third_impulse.py": "10d4da8ccbe680be7a1f0255a3efa518a0b2d7b8d439ed42e9c267799d5d1416", + "engines/three_role.py": "c4a1219cddc193b639530a3f00e976bdc81c0815465e7d4d59929093d95d1859", + "inputs/7334-READBACK.json": "337668788fb39ec9575887f9c5faf438a880471f78d936357dabf7deeac5de82", + "inputs/7334-WORD.json.gz": "4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a", + "inputs/ADMITTED.json": "c95300e9bca27e44a25c82d794f88cbf70757c142806b0e4c590ea29feb81a13", + "inputs/PR7363-SHA256.json": "91aa157df8168be25cfda9acdeea45e097e17d4047e7b37c935061e5a2a44f47", + "inputs/PR7391-SHA256.json": "4c844c2f9d867d2ed907ad0061e1dba74a4d87d3d0394e91de15cf9c0530db58", + "inputs/R143-GEOMETRY.json.gz": "c08f63eb8a5f31e7c1a0c5dd99b176058857f08408e2e3c2c2b62235041ce57a", + "inputs/R143-PRICE.json.gz": "08d1a357fefba4b176b6e8c51319ea5b7699dc477b9cb45907183845c944bfca", + "inputs/R96-PRICE.json.gz": "088ec2baba4bef02f3a3394690017f205aba8fca4c742e4f5b69782b6d211ede", + "inputs/bank_trace.py": "681fda5cc1d4b1ac07c62601ceb052f167a51fb73d28b23f454f8f50f6a8e27b", + "inputs/reverse_span.py": "f8b48f2ed99d003e20f5b3fb2270603c4edbc3ce9a01484102816aa2710ce9ff", + "receipts/SHA256.json": "ee65d54e0e06d385dc82a888373beae0c98c4f5281924de806ea452b99c05ea7" +} diff --git a/research/p104-three-role-endpoint-exchange-bound/NOTICE b/research/p104-three-role-endpoint-exchange-bound/NOTICE new file mode 100644 index 0000000000..e9834395bc --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/NOTICE @@ -0,0 +1,3 @@ +Apache-2.0. + +#7391 supplies the exact two-role endpoint-exchange result and geometry. #7363 supplies the third helper's original endpoint cohort, #7341 the signed readback, #7355 and #7382 the exact reverse engines, and #7130 the cocharted basis precedent. #7334 and #7113 supply the exact native word and signed caller. OpenAI Codex and subagents materially assisted. diff --git a/research/p104-three-role-endpoint-exchange-bound/PROOF.md b/research/p104-three-role-endpoint-exchange-bound/PROOF.md new file mode 100644 index 0000000000..29a3f791c6 --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/PROOF.md @@ -0,0 +1,13 @@ +# Exact prefix separation with one named extra role + +Retain the paid word and exchange the productive terminals of two helpers as in #7391. At a literal common chart, grant arbitrary invertible rational mixing on the pair and existing public helper 1454. Preserve 1454's complete dirty return and original paid itinerary. Denote the old prefix by F, old suffix by S and admitted endpoint by E = SF. The suffix is observed on every public return and at every later COPY's pre-write destination. Let P exchange the two chosen endpoint roles and act trivially on the third role and the COPY guards. Let d = e_i − e_1481 on the original public inputs. + +An inserted basis L followed by suffix relabeling can preserve the exact original endpoint only if +```text +S (P L − I) F = (P − I) E. +``` +The right side has a nonzero row proportional to dᵀ because the two helper inputs are independent and returned exactly by the original endpoint. The left side factors through only the three original prefix rows at the cut. Thus dᵀ must lie in the span of those three rows, even with arbitrary rational coefficients and with the synthesis cost granted free. + +The prior input x1454 = 1, x1481 = −2 evaluates to +1 on role 1454 at every coframed cut. The new input x1251 = 1, x1481 = 4 evaluates to zero on all three prefix rows and −4 on dᵀ. All other original public coordinates are zero in each input. The literal chart census counts all 20,455 raw cuts. After splitting at contacts of all three roles, 16,494 eligible cuts fall in 15 segments with constant prefix rows. The first stage obtains the common exact separator on eight selected representatives. The continuation verifies all 478 raw cuts in the seven remaining segments. The independent exact reverse replay intersects the third role's own literal contact intervals with the inherited coframes and evaluates all 15 three-row banks. + +The complete optimistic invoice retains all 110,519 paid positions and 22,461 productive positions. It changes productive counts by T5−17, T6+17, T8+17, T9−17, preserving signed rank surplus 1,424. Every swap uses role 1481, so the compatible count is at most one. Its gross at the incumbent is below 0.026750025281436337 raw and the complete margin at the fixed moonshot target is below −139.7375598591330167. One extra raw paid rank-one position defeats even the optimistic price. Ordinary basis, restoration, phases, precision, tape and compiler would still be charged on any support survivor. No candidate or saving survives the exact prefix gate. diff --git a/research/p104-three-role-endpoint-exchange-bound/PROVENANCE.json b/research/p104-three-role-endpoint-exchange-bound/PROVENANCE.json new file mode 100644 index 0000000000..49b1f3b37f --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/PROVENANCE.json @@ -0,0 +1,78 @@ +{ + "caller": { + "commit": "07a76c5e2738882c0cb322278e56f6cae3c9885d", + "scope": "Exact retained signed caller.", + "source": "https://github.com/CrocSwap/integer-mult-bounds/pull/7113" + }, + "derived_inputs": { + "inputs/R143-GEOMETRY.json.gz": { + "compression": "gzip", + "key": "R143-GEOMETRY.json", + "receipt": "inputs/PR7391-SHA256.json" + }, + "inputs/R143-PRICE.json.gz": { + "compression": "gzip", + "key": "R143-PRICE.json", + "receipt": "inputs/PR7391-SHA256.json" + }, + "inputs/R96-PRICE.json.gz": { + "compression": "gzip", + "key": "input/price/PRICE.json", + "receipt": "inputs/PR7363-SHA256.json" + } + }, + "files": { + "inputs/7334-READBACK.json": { + "commit": "1d924a75e40cf2e775f4a5cb2539f5c294464fc1", + "git_blob": "625b508eead24b4428253bd257620b7e775800c1", + "path": "research/p104-type-a-query-cache-pair-bound/inputs/7334-READBACK.json", + "sha256": "337668788fb39ec9575887f9c5faf438a880471f78d936357dabf7deeac5de82", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/1d924a75e40cf2e775f4a5cb2539f5c294464fc1/research/p104-type-a-query-cache-pair-bound/inputs/7334-READBACK.json" + }, + "inputs/7334-WORD.json.gz": { + "commit": "aaeec8c0acf01e99a5f331ef363a698d9c084ace", + "git_blob": "73f43007192eb5a38eb5abb591b871df3e52c7cd", + "path": "research/p104-helper-319-fused-return/WORD.json.gz", + "sha256": "4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a", + "source": "https://github.com/Clear1nsight/integer-mult-bounds/blob/aaeec8c0acf01e99a5f331ef363a698d9c084ace/research/p104-helper-319-fused-return/WORD.json.gz", + "uncompress": false + }, + "inputs/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", + "uncompress": false + }, + "inputs/PR7363-SHA256.json": { + "commit": "a0502b0b30a4a4a0e9a37c08e83febbd515c5955", + "git_blob": "1db37e45efca74affe00b10d03ab924bee899ad8", + "path": "research/p104-rank-eight-fixed-paid-bank-bound/receipts/SHA256.json", + "sha256": "91aa157df8168be25cfda9acdeea45e097e17d4047e7b37c935061e5a2a44f47", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/a0502b0b30a4a4a0e9a37c08e83febbd515c5955/research/p104-rank-eight-fixed-paid-bank-bound/receipts/SHA256.json" + }, + "inputs/PR7391-SHA256.json": { + "commit": "c1660f2c0c4370b00672bf976499587652a56296", + "git_blob": "134a2ee1278e786e07f5859fa4ccfe5f8eec0b28", + "path": "research/p104-fixed-paid-endpoint-exchange-bound/receipts/SHA256.json", + "sha256": "4c844c2f9d867d2ed907ad0061e1dba74a4d87d3d0394e91de15cf9c0530db58", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/c1660f2c0c4370b00672bf976499587652a56296/research/p104-fixed-paid-endpoint-exchange-bound/receipts/SHA256.json" + }, + "inputs/bank_trace.py": { + "commit": "408d4268cabb1c15c2b24a262261b1a04ec57a9d", + "git_blob": "996cba9a52498ded0ed72f900c94cc4329fd5fcf", + "path": "research/p104-chart118-pivot635-pairing-bound/engines/r129/chart118.py", + "sha256": "681fda5cc1d4b1ac07c62601ceb052f167a51fb73d28b23f454f8f50f6a8e27b", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/408d4268cabb1c15c2b24a262261b1a04ec57a9d/research/p104-chart118-pivot635-pairing-bound/engines/r129/chart118.py" + }, + "inputs/reverse_span.py": { + "commit": "403e0d388c35e83b15eab5bba67be563b33d5a8a", + "git_blob": "5efbeac87e3963085149244304614844307c8034", + "path": "research/p104-owned-add-source-span-bound/engines/reverse.py", + "sha256": "f8b48f2ed99d003e20f5b3fb2270603c4edbc3ce9a01484102816aa2710ce9ff", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/403e0d388c35e83b15eab5bba67be563b33d5a8a/research/p104-owned-add-source-span-bound/engines/reverse.py" + } + }, + "schema_version": 1 +} diff --git a/research/p104-three-role-endpoint-exchange-bound/README.md b/research/p104-three-role-endpoint-exchange-bound/README.md new file mode 100644 index 0000000000..202d657be0 --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/README.md @@ -0,0 +1,21 @@ +# Three-role endpoint exchange with helper 1454 + +**NO VERIFIED GAIN.** The exact comparator remains #7334 `aaeec8c0acf01e99a5f331ef363a698d9c084ace` with signed #7113 `07a76c5e2738882c0cb322278e56f6cae3c9885d` at κ = 0.00364665195644. + +This extends #7391's exchange of role 1481 and an eligible 3→127 helper by granting one named existing public role, 1454, when already cocharted. Role 1454 retains its original paid itinerary and arbitrary dirty return. The original two-row separator is nonzero on that third row. A second exact input, x1251 = 1 and x1481 = 4, vanishes on all three rows and evaluates to −4 on the required helper difference. + +All 20,455 inherited raw cuts are checked. At 3,961 the third role is on another chart. The other 16,494 form 15 exact contact-separated segments, all on chart 245. Eight exact prefix tests and the seven-segment continuation exclude all 15. The continuation checks every one of its 478 raw cuts. An independent exact reverse replay reconstructs every eligible segment and all 15 separating evaluations. Zero unresolved in the three-role scope. + +Use CPython 3.12 with assertions. + +```sh +python3.12 -I -B research/p104-three-role-endpoint-exchange-bound/replay.py +``` + +The Git-free replay authenticates the exact word and public predecessor receipts, reproduces six deterministic outputs and rejects altered inputs. Add `--out fresh-directory` to retain the receipts. + +#7391 supplies the exact two-role scope and range catalogue. #7363 supplies the third helper's original endpoint cohort, #7341 the admitted signed readback, #7355/#7382 the reverse tools, and #7130 the cocharted basis precedent. #7334 and #7113 supply the exact word and caller. OpenAI Codex and subagents materially assisted. + +## Open next questions + +A wider cocharted basis may contain the required prefix difference. Freeze named extra roles and charge their ordinary synthesis and exact returns before examining more cuts. Any prefix survivor still needs a guarded suffix response, invertible legal basis, physical ownership and all-width replay. Other fields and changed paid routes remain open. diff --git a/research/p104-three-role-endpoint-exchange-bound/SOURCES.json b/research/p104-three-role-endpoint-exchange-bound/SOURCES.json new file mode 100644 index 0000000000..e8c2f265cd --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-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-three-role-endpoint-exchange-bound/TASK.json b/research/p104-three-role-endpoint-exchange-bound/TASK.json new file mode 100644 index 0000000000..f6d1e67afe --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/TASK.json @@ -0,0 +1,117 @@ +{ + "actual_scope": "Exact #7334. Add only unchanged cocharted public role 1454 to the productive endpoint exchange between role1481 and any original #7391 partner.", + "ai_assistance": "OpenAI Codex and subagents materially assisted proof, implementation, independent verification and packaging.", + "author": "P104 three-role endpoint exchange research", + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bottleneck_link": "A fixed-paid exchange balances productive ranks only if the required helper-difference row belongs to the exact cocharted prefix span.", + "budget_minutes": 10, + "evidence": "Every one of 15 exact three-role prefix segments is excluded by the same signed rational input. The continuation directly checks 478 raw cuts and the independent reverse replay checks all 16,494 eligible cuts through exact contact ranges.", + "open_questions": [ + { + "blocked_by": "All 15 fixed three-row banks that use 1454 are excluded.", + "first_step": "Price one named extra role and exact legal basis/return recipe, then freeze literal coframe and evaluate prefix support.", + "question": "Can another explicitly scoped cocharted basis or changed paid itinerary realize the helper-difference row?", + "why_it_matters": "Exact prefix membership is necessary for any signed arbitrary-input suffix exchange." + } + ], + "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": "Extends exact #7391 by allowing one extra public role with the original chart path and dirty return. The second separator is independent of the original one.", + "scope_status": "changed", + "stop_rule": "Check all 20,455 inherited raw cuts, eight exact selected prefixes, then the other seven exact segments and independent all-15 reverse replay.", + "task_id": "p104-side-correction" +} diff --git a/research/p104-three-role-endpoint-exchange-bound/VERIFICATION.md b/research/p104-three-role-endpoint-exchange-bound/VERIFICATION.md new file mode 100644 index 0000000000..6c95ca2260 --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/VERIFICATION.md @@ -0,0 +1,13 @@ +# Verification + +The package authenticates the exact #7334 word, #7391 geometry and price digests, the #7363 cohort digest and the signed #7341 readback. The two capped scientific stages reproduce both exact price and full three-role census, all eight exact first-prefix results, the seven frozen remainder keys and their exact forward replay. The independent reverse engine verifies all 15 range geometries and signed evaluations. All six deterministic receipts are keyed by distinct package names. + +Changed impulse, inherited prefix and continuation key receipts reject before native decode. CPython 3.12 and its standard library suffice for the clean Git-free replay. To run the registered package from the repository root: + +```sh +python3.12 -B scripts/research_package.py --package research/p104-three-role-endpoint-exchange-bound +``` + +This is a fixed scoped exclusion. No altered native construction or full outer theorem is claimed. + +Local CPython 3.12 passed the empty-environment Git-free replay in 1.44 seconds and registered replay in 1.89 seconds. A separately altered copy of the public #7391 manifest was rejected before native decode. diff --git a/research/p104-three-role-endpoint-exchange-bound/VERIFY.json b/research/p104-three-role-endpoint-exchange-bound/VERIFY.json new file mode 100644 index 0000000000..5b7c369f2c --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/VERIFY.json @@ -0,0 +1,19 @@ +{ + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/replay.py" + ], + "checks": "Reproduce exact three-role price, full coframe/impulse census, all 15 prefix exclusions and independent exact reverse certificates.", + "timeout_seconds": 100 + } + ], + "inputs": [], + "python": "3.12", + "requirements": [], + "schema_version": 1, + "status": "ready" +} diff --git a/research/p104-three-role-endpoint-exchange-bound/engines/close.py b/research/p104-three-role-endpoint-exchange-bound/engines/close.py new file mode 100644 index 0000000000..2a536c06ca --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/engines/close.py @@ -0,0 +1,165 @@ +"""Exact impulse on the seven frozen remaining R148 three-role bank segments.""" +from argparse import ArgumentParser +from collections import defaultdict +from fractions import Fraction as Q +from functools import cache +from gzip import decompress +from hashlib import sha256 +from json import dumps,loads +from pathlib import Path +from signal import SIGALRM,alarm,signal +from time import monotonic + +ROOT=Path(__file__).resolve().parents[1] +PINS={ + 'inputs/PRICE.json':'8b71d05eddb3aee641ffa41a57a3922292bc4d45c5eb8aae8f2e4514388f6524', + 'inputs/IMPULSE.json':'d7b30091bd881711f4de7339216368ef8de1649e35cddb00d4dd29be2185b3af', + 'inputs/PREFIX.json':'e17e9b4dfb359eed4e478ea6ae7d2cc247687867054f3991f19bbd51e4ab73d9', + 'inputs/7334-WORD.json.gz':'4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a', +} +PAYLOAD='9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac' +HEAD='aaeec8c0acf01e99a5f331ef363a698d9c084ace' +CALLER='07a76c5e2738882c0cb322278e56f6cae3c9885d' +CAP,EVENTS,SECONDS=7,76466,20 + + +def unique(items): + out=dict(items) + assert len(out)==len(items) + return out + + +def read(root,name): + b=(root/name).read_bytes() + assert sha256(b).hexdigest()==PINS[name],('changed dependency',name) + return b + + +def freeze(root): + p,g,b=(loads(read(root,'inputs/'+x+'.json'),object_pairs_hook=unique) for x in ('PRICE','IMPULSE','PREFIX')) + assert p['head']==g['head']==HEAD and p['caller']==g['caller']==CALLER + assert g['price_sha256']==PINS['inputs/PRICE.json'] and b['pins']['lead/IMPULSE.json']==PINS['inputs/IMPULSE.json'] + assert b['counts']=={'exact_rank_exclusion':8} and len(b['rows'])==8 and len(b['unvisited'])==CAP + assert all(x['proof']['separating_covector']=={'1251':'1','1481':'4'} and Q(x['proof']['separated_target'])==-4 for x in b['rows']) + lookup={} + for r in g['unresolved']: + i,j,c,_,_=r['range'] + lo,hi=(r['segment'][k] for k in ('first','last')) + lookup[i,j,1454,c,hi]=[i,j,1454,c,lo,hi] + assert len(lookup)==15 and set(lookup)=={tuple(r['key']) for r in b['rows']}|set(map(tuple,b['unvisited'])) + ranges=[lookup[tuple(k)] for k in b['unvisited']] + assert all(j==1481 and third==1454 and c==245 and i not in (1251,1481) for i,j,third,c,_,_ in ranges) + return {'head':HEAD,'caller':CALLER,'pins':PINS,'ranges':ranges,'raw_cuts':sum(hi-lo+1 for *_,lo,hi in ranges), + 'target_response':'-4','input_impulse':{'1251':'1','1481':'4'}, + 'caps':{'ranges':CAP,'events':EVENTS,'seconds':SECONDS}} + + +@cache +def q(s): + return Q(s) + + +def disposition(row): + return 'prefix excluded' if all(v==0 for v in row) else 'unresolved' + + +def controls(): + assert disposition([Q(0)]*3)=='prefix excluded' + assert disposition([Q(0),Q(0),Q(-1,2)])=='unresolved' + return ['exact three-row zero response','nonzero third response remains unresolved'] + + +def audit(word,scope,deadline,progress): + n,m,tape=(word[k] for k in ('public','owned_fields','program')) + assert (n,m,len(tape))==(1501,68,EVENTS) + state=word['initial']+[None]*m + impulse={int(j):q(v) for j,v in scope['input_impulse'].items()} + values=[impulse.get(j,Q(0)) for j in range(n+m)] + wants=defaultdict(list) + ranges=scope['ranges'] + for k,(*_,lo,hi) in enumerate(ranges): + for t in range(lo,hi+1): + wants[t].append(k) + rows=[{'range':r,'cuts_checked':0,'first_nonzero':None} for r in ranges] + fresh=set() + for t,event in enumerate(tape): + progress['first_unvisited_event']=t + if t%128==0 and monotonic()>=deadline: + raise TimeoutError('forward exact cap') + for k in wants.get(t,()): + i,j,third,c,_,_=ranges[k] + assert state[i]==state[j]==state[third]==c + assert impulse.get(i,0)-impulse[j]==q(scope['target_response']) + r=rows[k] + bank=[values[x] for x in (i,j,third)] + if r['first_nonzero'] is None and disposition(bank)=='unresolved': + r['first_nonzero']=[t,*map(str,bank)] + r['cuts_checked']+=1 + op,d,*a=event + if op=='MOVE': + old,new,owned=a + assert state[d]==old and owned==(d>=n) + state[d]=new + fresh.discard(d) + elif op=='INIT': + assert d>=n and state[d] is None + state[d],values[d]=a[0],Q(0) + fresh.add(d) + elif op=='CLEAR': + assert d>=n and state[d]==a[0] + state[d],values[d]=None,Q(0) + fresh.discard(d) + elif op=='SCALE': + assert state[d]==a[-1] + values[d]*=q(a[0]) + fresh.discard(d) + else: + assert op in ('ADD','COPY') + s,k,c=a + assert s!=d and state[s]==state[d]==c + assert op!='COPY' or d>=n and d in fresh and values[d]==0 + values[d]=(values[d] if op=='ADD' else 0)+q(k)*values[s] + fresh.discard(d) + progress['events']+=1 + assert not fresh and state==word['final']+[None]*m + assert [r['cuts_checked'] for r in rows]==[hi-lo+1 for *_,lo,hi in ranges] + progress['first_unvisited_event']=None + return [r|{'status':'prefix excluded' if r['first_nonzero'] is None else 'unresolved'} for r in rows] + + +def main(): + assert __debug__ + cli=ArgumentParser(description=__doc__) + cli.add_argument('--root',type=Path,default=ROOT) + cli.add_argument('--freeze',action='store_true') + args=cli.parse_args() + scope=freeze(args.root) + tests=controls() + if args.freeze: + print(dumps(scope,sort_keys=True,indent=2));return + key_data=(args.root/'lead/KEYS.json').read_bytes() + assert key_data==(dumps(scope,sort_keys=True,indent=2)+'\n').encode() + def stop(*_): + raise TimeoutError('hard 20-second limit') + signal(SIGALRM,stop) + alarm(SECONDS) + deadline=monotonic()+SECONDS-1 + progress={'events':0} + out={'head':HEAD,'caller':CALLER,'pins':PINS,'controls':tests,'progress':progress,'keys_sha256':sha256(key_data).hexdigest()} + try: + raw=decompress(read(args.root,'inputs/7334-WORD.json.gz')) + assert sha256(raw).hexdigest()==PAYLOAD + rows=audit(loads(raw,object_pairs_hook=unique),scope,deadline,progress) + out|={'rows':rows,'raw_cuts':sum(r['cuts_checked'] for r in rows), + 'unresolved':[r['range'] for r in rows if r['status']=='unresolved']} + except TimeoutError as e: + out|={'timeout':str(e),'unresolved':scope['ranges']} + finally: + alarm(0) + print(dumps(out,sort_keys=True,indent=2)) + if 'timeout' in out: + raise SystemExit(2) + + +if __name__=='__main__': + main() diff --git a/research/p104-three-role-endpoint-exchange-bound/engines/third_basis.py b/research/p104-three-role-endpoint-exchange-bound/engines/third_basis.py new file mode 100644 index 0000000000..aaa6d0387f --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/engines/third_basis.py @@ -0,0 +1,188 @@ +"""Exact three-role prefix and guarded suffix checks on frozen R148 segments.""" +from argparse import ArgumentParser +from collections import Counter,defaultdict +from fractions import Fraction as Q +from gzip import decompress +from hashlib import sha256 +from json import dumps,loads +from math import lcm +from pathlib import Path +from runpy import run_path +from signal import SIGALRM,alarm,signal +from time import monotonic + +ROOT=Path(__file__).resolve().parents[1] +PINS={ + 'lead/PRICE.json':'8b71d05eddb3aee641ffa41a57a3922292bc4d45c5eb8aae8f2e4514388f6524', + 'lead/IMPULSE.json':'d7b30091bd881711f4de7339216368ef8de1649e35cddb00d4dd29be2185b3af', + 'inputs/7334-WORD.json.gz':'4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a', + 'inputs/reverse_span.py':'f8b48f2ed99d003e20f5b3fb2270603c4edbc3ce9a01484102816aa2710ce9ff', +} +PAYLOAD='9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac' +EVENTS=76466 + + +def checked(root,name,pin=None): + b=(root/name).read_bytes() + assert sha256(b).hexdigest()==(pin or PINS[name]),('changed dependency',name) + return b + + +def key(row): + i,j,c,_,_=row['range'] + return [i,j,1454,c,row['segment']['last']] + + +def selection(prior): + assert prior['price_sha256']==PINS['lead/PRICE.json'] + assert prior['counts']=={'no coframe':3961,'prefix pending':16494} + all_keys=[key(r) for r in prior['unresolved']] + assert len(set(map(tuple,all_keys)))==15 + return sorted(all_keys,key=lambda r:(r[0]!=232,-r[-1],r[0],r[3])) + + +def direction(roles): + return {roles[0]:1,roles[1]:-1},1 + + +def to_int(row): + d=lcm(*(v.denominator for v in row.values())) + return {i:v.numerator*(d//v.denominator) for i,v in row.items()},d + + +def prefix(word,keys,engine,deadline): + demands=defaultdict(list) + for k,row in enumerate(keys): + for j,r in enumerate(row[:3]): + demands[row[-1]].append((r,3*k+j)) + rows=engine['transpose_prefix'](word,demands,3*len(keys),deadline) + return [(r,engine['exact_span'](list(zip(r[:3],rows[3*k:3*k+3],strict=True)),direction(r[:3]))) + for k,r in enumerate(keys)] + + +def add(row,source,q): + for j,v in source.items(): + x=row.get(j,0)+q*v + if x: + row[j]=x + else: + row.pop(j,None) + + +def suffix(word,keys,deadline): + n,m=word['public'],word['owned_fields'] + values=[{} for _ in range(n+m)] + starts=defaultdict(list) + columns=[{} for _ in range(3*len(keys))] + for k,row in enumerate(keys): + for j,r in enumerate(row[:3]): + starts[row[-1]].append((r,3*k+j)) + for t in range(min(starts),EVENTS): + if t%128==0 and monotonic()>=deadline: + raise TimeoutError('guarded suffix cap') + for r,i in starts.get(t,()): + values[r][i]=Q(1) + op,d,*a=word['program'][t] + if op=='ADD': + add(values[d],values[a[0]],Q(a[1])) + elif op=='COPY': + for j,v in values[d].items(): + columns[j][n+t]=v + values[d]={j:Q(a[1])*v for j,v in values[a[0]].items()} + elif op=='SCALE': + values[d]={j:Q(a[0])*v for j,v in values[d].items()} + elif op in ('INIT','CLEAR'): + values[d]={} + else: + assert op=='MOVE' + for r,row in enumerate(values[:n]): + for j,v in row.items(): + columns[j][r]=v + return columns + + +def local_basis(roles,a,b): + a=[Q(a.get(r,'0')) for r in roles] + b=[Q(b.get(r,'0')) for r in roles] + d=1-sum(x*y for x,y in zip(a,b,strict=True)) + rows=[[Q(i==j)-b[i]*a[j] for j in range(3)] for i in range(3)] + rows[0],rows[1]=rows[1],rows[0] + return d,[[str(q) for q in row] for row in rows] + + +def controls(engine): + roles=(2,3,7) + a,b={2:'1',3:'-1'},{2:'1',3:'-1'} + assert local_basis(roles,a,b)==(Q(-1),[['1','0','0'],['0','1','0'],['0','0','1']]) + assert local_basis(roles,{2:'1'},{2:'1'})[0]==0 + assert engine['exact_span']([(2,({2:1},1)),(3,({3:1},1)),(7,({7:1},1))],direction(roles))['status']=='exact_span' + return ['three-role bare exchange control','rank-one determinant zero control','exact three-row membership'] + + +def main(): + assert __debug__ + cli=ArgumentParser(description=__doc__) + cli.add_argument('mode',choices=('prefix','suffix','controls')) + cli.add_argument('--root',type=Path,default=ROOT) + cli.add_argument('--prefix-sha') + args=cli.parse_args() + checked(args.root,'inputs/reverse_span.py') + engine=run_path(str(args.root/'inputs/reverse_span.py')) + tests=controls(engine) + if args.mode=='controls': + print(dumps(tests));return + prior=loads(checked(args.root,'lead/IMPULSE.json'),object_pairs_hook=engine['unique']) + checked(args.root,'lead/PRICE.json') + all_keys=selection(prior) + chosen=all_keys[:8] + pending=all_keys[8:] + limit=25 + if args.mode=='suffix': + assert args.prefix_sha is not None + pre=loads(checked(args.root,'lead/PREFIX.json',args.prefix_sha),object_pairs_hook=engine['unique']) + assert pre['mode']=='prefix' and pre['pins']==PINS + positive=[r for r in pre['rows'] if r['proof']['status']=='exact_span'] + chosen=[r['key'] for r in positive[:4]] + pending=[r['key'] for r in positive[4:]] + assert chosen + limit=35 + def stop(*_): + raise TimeoutError('hard exact support cap') + signal(SIGALRM,stop) + alarm(limit) + deadline=monotonic()+limit-1 + result={'mode':args.mode,'pins':PINS,'controls':tests,'selected':chosen,'unvisited':pending,'runner_cap':limit} + rows=[] + try: + raw=decompress(checked(args.root,'inputs/7334-WORD.json.gz')) + assert sha256(raw).hexdigest()==PAYLOAD + word=loads(raw,object_pairs_hook=engine['unique']) + assert len(word['program'])==EVENTS + if args.mode=='prefix': + rows=[{'key':r,'proof':proof} for r,proof in prefix(word,chosen,engine,deadline)] + else: + cols=suffix(word,chosen,deadline) + for k,r in enumerate(chosen): + bank=[(role,to_int(cols[3*k+j])) for j,role in enumerate(r[:3])] + proof=engine['exact_span'](bank,direction(r[:3])) + row={'key':r,'proof':proof} + if proof['status']=='exact_span': + a=positive[k]['proof']['coefficients'] + b=proof['coefficients'] + det,L=local_basis(r[:3],a,b) + row|={'det':str(det),'L':L,'basis_status':'exact normalized support' if det else 'singular chosen witness'} + rows.append(row) + except TimeoutError as e: + result|={'timeout':str(e),'unvisited':pending+chosen[len(rows):]} + finally: + alarm(0) + result|={'rows':rows,'counts':Counter(r['proof']['status'] for r in rows)} + if args.prefix_sha: + result['prefix_sha256']=args.prefix_sha + print(dumps(result,indent=2,sort_keys=True)) + if 'timeout' in result: + raise SystemExit(2) + + +if __name__=='__main__': + main() diff --git a/research/p104-three-role-endpoint-exchange-bound/engines/third_impulse.py b/research/p104-three-role-endpoint-exchange-bound/engines/third_impulse.py new file mode 100644 index 0000000000..fcf1758a8e --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/engines/third_impulse.py @@ -0,0 +1,182 @@ +"""Test the unique third public role at every inherited coframe cut.""" +from argparse import ArgumentParser +from collections import Counter,defaultdict +from fractions import Fraction as Q +from functools import cache +from gzip import decompress +from hashlib import sha256 +from json import dumps,loads +from pathlib import Path +from signal import SIGALRM,alarm,signal +from time import monotonic + +ROOT=Path(__file__).resolve().parents[1] +PINS={ + 'inputs/PRICE.json':'7b0ccc8fd85240568aeddfc1e2c036ac05ab0ec6e8473522bd902a4adcc1e9eb', + 'inputs/GEOMETRY.json':'f2aa238ed8c49f0633c3837c6961bfba19482385851a5606578fa6368db79542', + 'inputs/7334-WORD.json.gz':'4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a', + 'inputs/7334-READBACK.json':'337668788fb39ec9575887f9c5faf438a880471f78d936357dabf7deeac5de82', + 'inputs/R96-PRICE.json':'a78be64c3e3ae8a0e532237c4dd3541aa9ad3fcbbc3c25d79c8a03fb7e07c525', +} +PAYLOAD='9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac' +HEAD='aaeec8c0acf01e99a5f331ef363a698d9c084ace' +CALLER='07a76c5e2738882c0cb322278e56f6cae3c9885d' +THIRD,EVENTS,RANGES,CUTS,SECONDS=1454,76466,20,20455,20 + + +def unique(items): + d=dict(items) + if len(d)!=len(items): + raise ValueError('duplicate JSON key') + return d + + +def checked(root,name): + b=(root/name).read_bytes() + assert sha256(b).hexdigest()==PINS[name],('changed dependency',name) + return b + + +def freeze(root): + p,g,r,b=(loads(checked(root,'inputs/'+x+'.json'),object_pairs_hook=unique) + for x in ('PRICE','GEOMETRY','7334-READBACK','R96-PRICE')) + assert p['head']==g['head']==r['head']==b['head']==HEAD + assert p['caller']==g['caller']==r['caller_head']==b['caller']==CALLER + assert g['price_sha256']==PINS['inputs/PRICE.json'] and p['word_sha256']==PINS['inputs/7334-WORD.json.gz'] + assert g['raw_cuts']==CUTS and len(g['ranges'])==RANGES and THIRD in b['cohort'] + assert p['whole_compatible_pair_cap']==1 and p['paid_delta']=={} + assert p['productive_delta']=={'5':-17,'6':17,'8':17,'9':-17} + assert Q(p['quote']['probe']['complete_one_margin'][0])>0 + assert Q(p['quote']['old_crossing_upper']['complete_one_margin_with_extra_rank_one'][1])<0 + assert (r['ordinary'],r['ordinary_headroom'],r['native_grid'],r['context_c'],r['context_headroom'])==(782715464,217284536,[1125,25],2430,1666) + return {'head':HEAD,'caller':CALLER,'pins':PINS,'third':THIRD,'ranges':g['ranges'],'caps':{'raw_cuts':CUTS,'ranges':RANGES,'events':EVENTS,'seconds':SECONDS}, + 'quote':p['quote'],'paid_delta':p['paid_delta'],'productive_delta':p['productive_delta'], + 'ordinary_baseline':r['ordinary'],'ordinary_headroom':r['ordinary_headroom'], + 'native_grid':r['native_grid'],'context_c':r['context_c'],'context_headroom':r['context_headroom']} + + +@cache +def q(x): + return Q(x) + + +def status(third_chart,chart,third_value): + if third_chart!=chart: + return 'no coframe' + return 'separator excludes' if not third_value else 'prefix pending' + + +def controls(): + assert status(2,3,Q(1))=='no coframe' + assert status(3,3,Q(0))=='separator excludes' + assert status(3,3,Q(-1,2))=='prefix pending' + return ['nonzero value on wrong chart ineligible','three zero donor responses exclude','nonzero third keeps key pending'] + + +def audit(word,price,deadline,progress): + n,m,tape=(word[k] for k in ('public','owned_fields','program')) + assert (n,m,len(tape))==(1501,68,EVENTS) + state=word['initial']+[None]*m + values=[Q(0)]*(n+m) + assert (word['initial'][THIRD],word['final'][THIRD])==(3,245) + values[THIRD],values[1481]=Q(1),Q(-2) + fresh=set() + expected=price['ranges'] + wants=defaultdict(list) + for k,(_,_,_,lo,hi) in enumerate(expected): + for t in range(lo,hi+1): + wants[t].append(k) + records=[{'range':r,'counts':Counter(),'subranges':[]} for r in expected] + revision=0 + for t,e in enumerate(tape): + progress['first_unvisited_event']=t + if t%128==0 and monotonic()>=deadline: + raise TimeoutError('forward impulse cap') + for k in wants.get(t,()): + i,j,chart,_,_=expected[k] + assert i not in (THIRD,1481) and j==1481 + assert state[i]==state[j]==chart and values[i]==values[j]==0 + kind=status(state[THIRD],chart,values[THIRD]) + r=records[k] + r['counts'][kind]+=1 + progress['raw_cuts_checked']+=1 + if kind!='no coframe': + sub=r['subranges'] + if sub and sub[-1]['last']+1==t and sub[-1]['revision']==revision: + assert sub[-1]['response']==str(values[THIRD]) + sub[-1]['last']=t + else: + sub.append({'first':t,'last':t,'revision':revision,'response':str(values[THIRD]),'status':kind}) + op,d,*args=e + if THIRD==d or op in ('ADD','COPY') and args[0]==THIRD: + revision+=1 + if op=='MOVE': + a,b,owned=args + assert state[d]==a and owned==(d>=n) + state[d]=b + fresh.discard(d) + elif op=='INIT': + assert d>=n and state[d] is None + state[d],values[d]=args[0],Q(0) + fresh.add(d) + elif op=='CLEAR': + assert d>=n and state[d]==args[0] + state[d],values[d]=None,Q(0) + fresh.discard(d) + elif op=='SCALE': + assert state[d]==args[-1] + values[d]*=q(args[0]) + fresh.discard(d) + else: + assert op in ('ADD','COPY') + s,coefficient,chart=args + assert s!=d and state[s]==state[d]==chart + assert op!='COPY' or d>=n and d in fresh and values[d]==0 + values[d]=(values[d] if op=='ADD' else 0)+q(coefficient)*values[s] + fresh.discard(d) + progress['events']+=1 + assert not fresh and state==word['final']+[None]*m + progress['first_unvisited_event']=None + assert progress['raw_cuts_checked']==CUTS + assert all(sum(r['counts'].values())==r['range'][-1]-r['range'][-2]+1 for r in records) + return records + + +def main(): + assert __debug__ + cli=ArgumentParser(description=__doc__) + cli.add_argument('--root',type=Path,default=ROOT) + cli.add_argument('--price-only',action='store_true') + args=cli.parse_args() + price=freeze(args.root) + tests=controls() + if args.price_only: + print(dumps(price,indent=2,sort_keys=True));return + p=(args.root/'lead/PRICE.json').read_bytes() + assert p==(dumps(price,indent=2,sort_keys=True)+'\n').encode() + def stop(*_): + raise TimeoutError('hard 20-second cap') + signal(SIGALRM,stop) + alarm(SECONDS) + progress={'events':0,'raw_cuts_checked':0} + result={'head':HEAD,'caller':CALLER,'controls':tests,'price_sha256':sha256(p).hexdigest(),'progress':progress} + try: + raw=decompress(checked(args.root,'inputs/7334-WORD.json.gz')) + assert sha256(raw).hexdigest()==PAYLOAD + rows=audit(loads(raw,object_pairs_hook=unique),price,monotonic()+SECONDS-1,progress) + counts=Counter() + for r in rows: + counts.update(r['counts']) + unresolved=[{'range':r['range'],'segment':s} for r in rows for s in r['subranges'] if s['status']=='prefix pending'] + result|={'rows':rows,'counts':counts,'unresolved':unresolved} + except TimeoutError as e: + result|={'timeout':str(e),'unresolved':'incomplete original raw cuts, no exclusion'} + finally: + alarm(0) + print(dumps(result,sort_keys=True,indent=2)) + if 'timeout' in result: + raise SystemExit(2) + + +if __name__=='__main__': + main() diff --git a/research/p104-three-role-endpoint-exchange-bound/engines/three_role.py b/research/p104-three-role-endpoint-exchange-bound/engines/three_role.py new file mode 100644 index 0000000000..c56800bd65 --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/engines/three_role.py @@ -0,0 +1,117 @@ +"""Independently intersect role 1454's contact spans and certify all reverse pairings.""" +from argparse import ArgumentParser +from fractions import Fraction +from gzip import decompress +from hashlib import sha256 +from json import dumps, loads +from pathlib import Path +from runpy import run_path +from signal import SIGALRM, alarm, signal +from time import monotonic + +PINS = { + "inputs/word.json.gz": "4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a", + "inputs/bank_trace.py": "681fda5cc1d4b1ac07c62601ceb052f167a51fb73d28b23f454f8f50f6a8e27b", + "lead/GEOMETRY.json": "f2aa238ed8c49f0633c3837c6961bfba19482385851a5606578fa6368db79542", + "third/IMPULSE.json": "d7b30091bd881711f4de7339216368ef8de1649e35cddb00d4dd29be2185b3af", + "third/PREFIX.json": "e17e9b4dfb359eed4e478ea6ae7d2cc247687867054f3991f19bbd51e4ab73d9", + "followup/KEYS.json": "ee3ad61078a0a2e5e0a0dcdab672734fa60ffd49880fd12d328f1d1e5490a065", + "followup/RESULT.json": "d2d31b2fc11f0d0388e2c0238df4bcac3d68293154ad72b3de2f6f0046d7697e", +} +THIRD, PIVOT, CASES, SECONDS = 1454, 1481, 15, 20 + + +def unique(pairs): + result = dict(pairs) + if len(result) != len(pairs): + raise ValueError("duplicate JSON keys") + return result + + +def stop(*_): + raise TimeoutError("20-second independent cap") + + +def chart_intervals(word): + chart, lo = word["initial"][THIRD], 0 + for clock, (op, dest, *args) in enumerate(word["program"]): + if dest != THIRD and not (op in ("ADD", "COPY") and args[0] == THIRD): + continue + yield lo, clock, chart + lo = clock + 1 + if op == "MOVE": + assert dest == THIRD and args[0] == chart and not args[2] + chart = args[1] + else: + assert op in ("ADD", "COPY", "SCALE") and args[-1] == chart + assert chart == word["final"][THIRD] + yield lo, len(word["program"]), chart + + +def main(): + assert __debug__ + parser = ArgumentParser(description=__doc__) + parser.add_argument("--root", type=Path, required=True) + parser.add_argument("--output", type=Path, required=True) + args = parser.parse_args() + signal(SIGALRM, stop) + alarm(SECONDS) + deadline = monotonic() + SECONDS + raw = {p: (args.root / p).read_bytes() for p in PINS} + for path, data in raw.items(): + if sha256(data).hexdigest() != PINS[path]: + raise ValueError(f"changed dependency {path}") + docs = {p: loads(v, object_pairs_hook=unique) for p, v in raw.items() if p.endswith(".json")} + payload = decompress(raw["inputs/word.json.gz"]) + assert sha256(payload).hexdigest() == "9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac" + word = loads(payload, object_pairs_hook=unique) + assert len(word["program"]) == 76466 + geometry = docs["lead/GEOMETRY.json"] + third_spans = list(chart_intervals(word)) + ranges = [] + for role, pivot, chart, lo, hi in geometry["ranges"]: + assert pivot == PIVOT and THIRD not in (role, pivot) + for a, b, other_chart in third_spans: + start, end = max(lo, a), min(hi, b) + if chart == other_chart and start <= end: + ranges.append((role, pivot, THIRD, chart, start, end)) + receipt = docs["third/IMPULSE.json"] + saved = set() + for row in receipt["unresolved"]: + role, pivot, chart, _, _ = row["range"] + segment = row["segment"] + saved.add((role, pivot, THIRD, chart, segment["first"], segment["last"])) + assert len(ranges) == CASES and set(ranges) == saved + raw_cuts = sum(hi - lo + 1 for _, _, _, _, lo, hi in ranges) + assert raw_cuts == receipt["counts"]["prefix pending"] == 16494 + assert geometry["raw_cuts"] - raw_cuts == receipt["counts"]["no coframe"] == 3961 + prefix = docs["third/PREFIX.json"] + checked = {tuple(row["key"]) for row in prefix["rows"]} + assert len(checked) == 8 + followup = docs["followup/RESULT.json"] + remaining = {tuple(row) for row in docs["followup/KEYS.json"]["ranges"]} + assert len(remaining) == 7 and {tuple(row["range"]) for row in followup["rows"]} == remaining + assert sum(row[-1] - row[-2] + 1 for row in remaining) == followup["raw_cuts"] == 478 + assert {(*row[:4], row[-1]) for row in ranges if row not in remaining} == checked + algebra = run_path(str(args.root / "inputs/bank_trace.py")) + impulse = {1251: Fraction(1), PIVOT: Fraction(4)} + rows = [] + for key in ranges: + role, pivot, third, _, _, hi = key + roles = [role, pivot, third] + bank = algebra["trace"](word, hi, roles, deadline, True) + pairing = [algebra["dot"](bank[r], impulse) for r in roles] + required = impulse.get(role, 0) - impulse[pivot] + assert pairing == [0, 0, 0] and required == -4 + rows.append(dict(key=key, support=[len(bank[r]) for r in roles], + evaluations=list(map(str, pairing)), required=str(required))) + predecessor = algebra["trace"](word, 0, [1251, PIVOT], deadline, True) + assert [algebra["dot"](predecessor[r], impulse) for r in (1251, PIVOT)] == [1, 4] + alarm(0) + result = dict(head=geometry["head"], caller=geometry["caller"], pins=PINS, cases=CASES, + coframed_raw_cuts=raw_cuts, unresolved=0, rows=rows) + args.output.write_text(dumps(result, sort_keys=True, indent=2) + "\n") + + +if __name__ == "__main__": + main() diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/7334-READBACK.json b/research/p104-three-role-endpoint-exchange-bound/inputs/7334-READBACK.json new file mode 100644 index 0000000000..625b508eea --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/inputs/7334-READBACK.json @@ -0,0 +1,188 @@ +{ + "assumptions": [ + "native_all_columns", + "owned_erasure", + "compiler", + "precision_tape", + "analytic_recovery" + ], + "bit_admitted": "12039/3125000", + "bit_claim_headroom": "3000951089/25000000000000", + "bit_premise": "376669/100000000", + "caller_head": "07a76c5e2738882c0cb322278e56f6cae3c9885d", + "claim": "91166298911/25000000000000", + "context_c": 2430, + "context_headroom": 1666, + "copies": 17, + "directed_bounds": { + "new_at_claim": [ + "347195197206460540909548691538238227127/2000000000000000000000000000000000000000000000000", + "1735975986032302704547743457691191192207/10000000000000000000000000000000000000000000000000" + ], + "new_at_old_crossing_upper": [ + "333717954993733063339209580360321337006028706669/2000000000000000000000000000000000000000000000000", + "1668589774968665316696047901801606685030143589709/10000000000000000000000000000000000000000000000000" + ], + "new_at_raw_lower": [ + "8890529086421014119/10000000000000000000000000000000000000000000000000", + "8890529086421080299/10000000000000000000000000000000000000000000000000" + ], + "new_at_raw_upper": [ + "-29866980917152322049/10000000000000000000000000000000000000000000000000", + "-29866980917152266101/10000000000000000000000000000000000000000000000000" + ], + "new_at_tested": [ + "1464673416007288863003441470091977383033/10000000000000000000000000000000000000000000000000", + "1464673416007288863003441470091977438357/10000000000000000000000000000000000000000000000000" + ], + "old_at_claim": [ + "-1668785950738799647054310634446839861363893886031/10000000000000000000000000000000000000000000000000", + "-66751438029551985882172425377873594454555753177/400000000000000000000000000000000000000000000000" + ], + "old_at_old_crossing_upper": [ + "-357270001119021587349/10000000000000000000000000000000000000000000000000", + "-357270001119021530951/10000000000000000000000000000000000000000000000000" + ] + }, + "empty_root_credits": 0, + "exact_gain": "215259997/500000000000000", + "exact_relative_percent": "21525999700/1823110718223", + "head": "aaeec8c0acf01e99a5f331ef363a698d9c084ace", + "incumbent": "1823110718223/500000000000000", + "main_boundaries": 104, + "native_grid": [ + 1125, + 25 + ], + "native_ingredient_claim": "3646017316711/1000000000000000", + "new_raw_interval": [ + "364665195644044790699554028334161/100000000000000000000000000000000000", + "182332597822022395349777014167081/50000000000000000000000000000000000" + ], + "old_raw_upper": "36462214364462343366888845568981/10000000000000000000000000000000000", + "ordinary": 782715464, + "ordinary_delta": 52088, + "ordinary_headroom": 217284536, + "outer_functional": 4, + "outer_strict": 54, + "outer_strict_slack": "299635334804355997/10000000000000000000000000000000000", + "owned_lifetimes": 73, + "owned_peak": 50, + "paid": { + "1": 68384, + "2": 14501, + "3": 14093, + "4": 3791, + "5": 5865, + "6": 238, + "7": 170, + "8": 741, + "9": 32, + "16": 416, + "24": 416, + "32": 416, + "40": 416, + "48": 416, + "56": 416, + "64": 208 + }, + "paid_delta": { + "1": -17, + "5": -17, + "6": 17 + }, + "paid_positions": 110519, + "parent": "9d0119eb12fbd9fa534b48cd37b68e7099757b91", + "path_pins": { + "dependencies/7298/pricing.py": { + "sha256": "f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182" + }, + "dependencies/7314/NATIVE-RESULT.json": { + "sha256": "336f463da5afe5b60bfd3b9f0ce8aeea5a5feb1f854613bf4218ba0b28b3371b" + }, + "dependencies/7314/PROPOSED-CLAIM.json": { + "sha256": "41a08c4b7d0b2de4af22bc778948a143027eb3065fff47b0400b6ded1cc52778" + }, + "dependencies/7314/RESULT.json": { + "sha256": "432191ca572c9221935787ebe392699e3a1ef4512b0bf4fbc704657321cc87ca" + }, + "dependencies/round65/price.json": { + "sha256": "25205ad2cf4230bd2b2b704eec9f96ec4a5486fd575b5599861b28ffdd15b00b" + }, + "receipts/EARLY-RESULT.json": { + "git_blob": "675d6cf2374f3384019dfd53b2bdffd845005f13", + "sha256": "ad1ca9b2e2febbf80d9bf8b6ceef14ff90fcc29ef9358310e551628eb1706649" + }, + "receipts/INPUTS.json": { + "git_blob": "95c53f4594287a72d9b586f10ee136d0a1686984", + "sha256": "abedac59097a1c35c27d91cbdb07207bc562a64743bc406d13c94a8bc970592d" + }, + "receipts/NATIVE-RESULT.json": { + "git_blob": "eb101307d4d0399efed96d88cf6d4c01ec9c7369", + "sha256": "c6d1b00a83185ab0062397b363258b1f3f6685d755e9c1d4f7d3e7e511240812" + }, + "receipts/PROOF.md": { + "git_blob": "7644e5571d583183ee93b686612b5ec4555f6911", + "sha256": "560de573bfd4563c16ca3c7308fa729b4188fabe802d8830f343c3873f75b59d" + }, + "receipts/PROPOSED-CLAIM.json": { + "git_blob": "6b491894580741e3e2c11a453722a0302db7b5d6", + "sha256": "6e31241944c123d2bd4aa8bc94d833b44b3d889bd6d9aafc579108f416b45f03" + }, + "receipts/README.md": { + "git_blob": "b3a055f4e0d334ce2e7df3310caaa0849eb3eba1", + "sha256": "b4db0eb83ab6a2f7151bed2da955a487f4816ec9d1976eccc21e54c2725490b0" + }, + "receipts/REFERENCE.json": { + "git_blob": "8859e243cc39546bcb1e257d95c19a658c455dc7", + "sha256": "3e66e054b803551f18b8670da0b2990a7d0eeb689dfc45b56dbcba295551da70" + }, + "receipts/REPLAY.txt": { + "git_blob": "0b8d8048c18740060f4b7f6d380a5f3a0f30ee53", + "sha256": "230984f4b8206ae4d0c0f18fbba86ff43a1a9623f8ed337cf1285360f9a67c0c" + }, + "receipts/RESULT.json": { + "git_blob": "3034a490f5b0656ae71495c99493c4ab1ac1f5c6", + "sha256": "7f2d587c59f063b01f1e8b320084a7f0943f2f05d65e3e0f5e80448c6c8e8194" + }, + "receipts/SOURCES.json": { + "git_blob": "6b97e903a6df8de437068a0e2907823885928053", + "sha256": "ac7b4473035af648d6073e78b6c39675e706e8194b346bb55ed62a0adc81d593" + }, + "receipts/VERIFY.json": { + "git_blob": "cc98ee2a5c5a79e670094a6f55c7cacda8fd330c", + "sha256": "ede7dd2dd3733b9a73f72af9dd7edfe819b49b859c5c76e227ec82cb9c220513" + }, + "receipts/construct.py": { + "git_blob": "89e923bd738dfc404ca76b7ae36f13844ac4bfbb", + "sha256": "ecb39578063d7f09153a85370a3b9bb7cbf8b36ff9891033a1cce7a2fe7f7fda" + } + }, + "physical_maps": 3037, + "productive_fields": 22461, + "rank_surplus": 1424, + "raw_strict_separation": "43051999421357030665572644351/100000000000000000000000000000000000", + "scope": "Exact receipt and directed-price readback. No native or caller execution in this audit.", + "source_archive_sha256": "0589953b3886d96eacf3bda3d38d8d574bb739fba1056af7f32f56047b6061e2", + "targets": { + "1": 306, + "2": 357, + "3": 799, + "4": 3825, + "5": 1360, + "6": 731, + "7": 323, + "8": 544, + "9": 10888, + "17": 416, + "25": 416, + "33": 416, + "41": 416, + "49": 416, + "57": 416, + "65": 416, + "73": 208, + "137": 208 + }, + "tested": "364665195644007/100000000000000000" +} diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/7334-WORD.json.gz b/research/p104-three-role-endpoint-exchange-bound/inputs/7334-WORD.json.gz new file mode 100644 index 0000000000..73f4300719 Binary files /dev/null and b/research/p104-three-role-endpoint-exchange-bound/inputs/7334-WORD.json.gz differ diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/ADMITTED.json b/research/p104-three-role-endpoint-exchange-bound/inputs/ADMITTED.json new file mode 100644 index 0000000000..464c89e45c --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/inputs/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-three-role-endpoint-exchange-bound/inputs/PR7363-SHA256.json b/research/p104-three-role-endpoint-exchange-bound/inputs/PR7363-SHA256.json new file mode 100644 index 0000000000..1db37e45ef --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/inputs/PR7363-SHA256.json @@ -0,0 +1,19 @@ +{ + "independent/FOLLOWUP.json": "53906dcd9ee8b8c7b6a3389c2d1e5ff8157a3191a07bb0e3064b0d1f32bc16f5", + "independent/RESULT.json": "95d34e468683aa64e19d3e4d62745b9fc1d4305b00d25054b34bb5a668639b4b", + "input/independent/AGREEMENT.json": "c718a2444821abd8bbb46a8660a4a1f05922a1446c81353d6ed5df86b02e36e3", + "input/independent/PAIRINGS.json": "2b729494affa110063e329b4f50418ec2ad7d2f821425741bbba43dfb049c879", + "input/independent/RESULT.json": "69c694a17e562a6e6534406e252428ca081f8e2ac6673ec01cf21e77cb468b58", + "input/lead/EXACT.json": "362a879401158678c8a30ea0dbd4f919a9a0e907db2d2247ce96ac8724f68b14", + "input/lead/GEOMETRY.json": "c6f9f018df8b58fcdf4f44356bd59bcac6d411b7845104ff4ad372ed4a95cfbd", + "input/lead/REMAINING.json": "3597499663a57702856945e91214a65e1d0f94db8643b93c0234c2bbf9291b1a", + "input/lead/RESULT.json": "45b6c8992dcff04b7252dfec809fc64812b86f094531ed3964ff967408057ed2", + "input/lead/SELECTION.json": "b95765ffa0bd426b3dae781aaafc1c21e3b25bcebc71b71a3871824f9009fd5f", + "input/lead/SUFFIX.json": "77d78eb692bf6d3f0433730b48dbf8a0178c3288eeca961f94b2aaa6683eb59a", + "input/price/PRICE.json": "a78be64c3e3ae8a0e532237c4dd3541aa9ad3fcbbc3c25d79c8a03fb7e07c525", + "lead/CONTINUATION.json": "1f1b1db497436811c3d18219a2277fff6fedc8ad19b7e3c4a486fdfc53c7907a", + "lead/EXACT.json": "d2d034cb496ddbafdfcdcfe5a4fcb1e0a08c8349d2310c397e5fcb61b670f1d4", + "lead/SELECTION.json": "53f3a3b08bd6e97514e7077e7c0b55c9d272b0527f3a1b0e415f0924514fddf1", + "modular/AGREEMENT.json": "8b7fa3c3f7812c116e652cb7eefd571eeffb495e2c750309b553c457b1dfadc2", + "modular/RESULT.json": "6710e8711907a0c8412660696cf821e69fdc42bebf7fc24689fc3385fe7aabf3" +} diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/PR7391-SHA256.json b/research/p104-three-role-endpoint-exchange-bound/inputs/PR7391-SHA256.json new file mode 100644 index 0000000000..134a2ee127 --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/inputs/PR7391-SHA256.json @@ -0,0 +1,9 @@ +{ + "INDEPENDENT.json": "0000a45561cc84dc4bbf24e10a216a800928c9005a0f7fe6079999021a9300dc", + "R143-BARE.json": "1f19c66e75543ff50f4537d99811812e96935e2c5d3e75ad3a6b23f8032b7869", + "R143-BASIS.json": "0688a6fe35487c3b79abaca48b583c6cad6a865bd7ae6b5addba846549807092", + "R143-GEOMETRY.json": "f2aa238ed8c49f0633c3837c6961bfba19482385851a5606578fa6368db79542", + "R143-PRICE.json": "7b0ccc8fd85240568aeddfc1e2c036ac05ab0ec6e8473522bd902a4adcc1e9eb", + "R146-KEYS.json": "b8566442ed245a2302d287c480cf95d647343ff4f0f141ba6072603fed5bdd6b", + "R146-RESULT.json": "9970468e3413e143eb9d328512b4e60aacb21672cbb5722ec0e5dd608fe58d14" +} diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/R143-GEOMETRY.json.gz b/research/p104-three-role-endpoint-exchange-bound/inputs/R143-GEOMETRY.json.gz new file mode 100644 index 0000000000..a8fc27b5ea Binary files /dev/null and b/research/p104-three-role-endpoint-exchange-bound/inputs/R143-GEOMETRY.json.gz differ diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/R143-PRICE.json.gz b/research/p104-three-role-endpoint-exchange-bound/inputs/R143-PRICE.json.gz new file mode 100644 index 0000000000..ab9e7de9f6 Binary files /dev/null and b/research/p104-three-role-endpoint-exchange-bound/inputs/R143-PRICE.json.gz differ diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/R96-PRICE.json.gz b/research/p104-three-role-endpoint-exchange-bound/inputs/R96-PRICE.json.gz new file mode 100644 index 0000000000..869a620d75 Binary files /dev/null and b/research/p104-three-role-endpoint-exchange-bound/inputs/R96-PRICE.json.gz differ diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/bank_trace.py b/research/p104-three-role-endpoint-exchange-bound/inputs/bank_trace.py new file mode 100644 index 0000000000..996cba9a52 --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/inputs/bank_trace.py @@ -0,0 +1,232 @@ +"""Independently certify chart-118 bank aliases and exact pairings.""" +from collections import defaultdict +from fractions import Fraction as Q +from functools import cache +from gzip import decompress +from hashlib import sha256 +from json import dumps, loads +from pathlib import Path +from signal import SIGALRM, alarm, signal +from time import monotonic + +ROOT = Path(__file__).resolve().parent +PINS = { + "inputs/R128-PRICE.json": "8083c540876bbc7c61fc05eaa8e5796cb96d58ea123638931f6cb60ce0507849", + "inputs/R89-PAIR.json": "4b8f2963ae0ef7bd357c3129e8287f79c5c1fccca6375c41e35fa01c476cb2ae", + "inputs/OLD-WITNESS.json": "5be60a09485041744919696121ae27e57a1aa9de437a2c4494d5fc569af4cdb4", + "inputs/R128-two_keys.py": "b6d97bbe22649b18e745ae70cba60542beba1d91e34f9f827b28fe29854265f2", + "inputs/7334-WORD.json.gz": "4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a", +} +PAYLOAD = "9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac" +CHART, PIVOT, CASE_CAP = 118, 635, 74 +HEAD = "aaeec8c0acf01e99a5f331ef363a698d9c084ace" +CALLER = "07a76c5e2738882c0cb322278e56f6cae3c9885d" + + +def unique(items): + result = dict(items) + if len(result) != len(items): + raise ValueError("duplicate JSON key") + return result + + +def checked(name): + raw = (ROOT / name).read_bytes() + if sha256(raw).hexdigest() != PINS[name]: + raise ValueError(f"changed dependency {name}") + return raw + + +@cache +def scalar(value): + return Q(value) + + +def axpy(row, other, q): + if q: + for j, value in other.items(): + updated = row.get(j, 0) + q*value + if updated: + row[j] = updated + else: + row.pop(j, None) + + +def dot(a, b): + return sum(value*b.get(j, 0) for j, value in a.items()) + + +def stop(): + raise TimeoutError("35-second exact cap") + + +def hard_stop(*_): + stop() + + +def cohorts(word, requests, deadline): + tape = word["program"] + n, owned = word["public"], word["owned_fields"] + state = word["initial"][:] + [None]*owned + seen, contacts, epoch = {}, [], 0 + lo, hi = min(requests), max(requests) + for t, event in enumerate(tape): + if t % 256 == 0 and monotonic() >= deadline: + stop() + if t in requests: + residents = tuple(r for r, frame in enumerate(state) if frame == CHART) + assert residents == requests[t] and PIVOT in residents and max(residents) < n + seen[t] = (epoch, residents) + if t == hi: + break + op, d, *args = event + before = state[d] + if op == "MOVE": + assert args[0] == before and args[2] == (d >= n) + after = args[1] + elif op == "INIT": + assert before is None and d >= n + after = args[0] + elif op == "CLEAR": + assert before == args[0] and d >= n + after = None + else: + after = before + assert op in ("ADD", "COPY", "SCALE") and after == args[-1] + if op in ("ADD", "COPY"): + assert state[args[0]] == before and args[0] != d + if t >= lo and CHART in (before, after): + invertible = d < n and (op == "SCALE" or (op == "ADD" and args[0] < n)) and bool(scalar(args[-2])) + if not invertible: + epoch += 1 + contacts.append({"clock": t, "event": event, "within_epoch": invertible}) + state[d] = after + assert set(seen) == set(requests) + grouped = defaultdict(list) + for t, key in seen.items(): + grouped[key].append(t) + return list(grouped.items()), contacts + + +def trace(word, cut, bank, deadline, reverse): + tape = word["program"] + n, owned = word["public"], word["owned_fields"] + values = [{} for _ in range(n+owned)] + for role in bank: + values[role] = {role: Q(1)} + clocks = range(cut-1, -1, -1) if reverse else range(cut, len(tape)) + for t in clocks: + if t % 256 == 0 and monotonic() >= deadline: + stop() + op, d, *args = tape[t] + if op in ("CLEAR", "INIT"): + values[d] = {} + elif op == "SCALE" and values[d]: + q = scalar(args[0]) + values[d] = {j:q*v for j,v in values[d].items() if q*v} + elif op in ("ADD", "COPY"): + source, factor = args[:2] + q = scalar(factor) + if reverse: + axpy(values[source], values[d], q) + if op == "COPY": + values[d] = {} + elif op == "COPY": + values[d] = {j:q*v for j,v in values[source].items() if q*v} + else: + axpy(values[d], values[source], q) + responses = {r:{} for r in bank} + for coordinate, data in enumerate(values[:n]): + for role, value in data.items(): + responses[role][coordinate] = value + return responses + + +def kernel(columns, allowed): + basis, pure = {}, [] + for role, full in columns.items(): + row = {j:v for j,v in full.items() if j not in allowed} + combo = {role:Q(1)} + for pivot, (old, old_combo) in sorted(basis.items()): + q = -row.get(pivot, 0) + axpy(row, old, q) + axpy(combo, old_combo, q) + if row: + pivot = min(row) + q = row[pivot] + basis[pivot] = ({j:v/q for j,v in row.items()}, {j:v/q for j,v in combo.items()}) + else: + image = {} + for j, q in combo.items(): + axpy(image, columns[j], q) + assert set(image) <= allowed + pure.append((combo, image)) + assert len(basis) + len(pure) == len(columns) + return len(basis), pure + + +def printed(vector): + return {j:str(v) for j,v in sorted(vector.items())} + + +def controls(old): + vectors = {k:{int(j):Q(v) for j,v in old[k].items()} for k in "abcd"} + assert (old["pivot"], old["frame"], old["cut_before"]) == (635, 118, 37473) + assert dot(vectors["a"], vectors["b"]) == dot(vectors["c"], vectors["d"]) == 1 + rank, pure = kernel({4:{0:Q(2),5:Q(1)}, 6:{5:Q(1)}}, {0}) + assert rank == 1 and pure == [({6:Q(1),4:Q(-1)}, {0:Q(-2)})] + assert dot(vectors["c"], {j:2*v for j,v in vectors["d"].items()}) == 2 + return ["historical exact unit pair", "planted exact exterior kernel", "wrong endpoint pairing"] + + +def main(): + assert __debug__ + signal(SIGALRM, hard_stop) + alarm(35) + deadline = monotonic()+32 + price, prior, old, _source, packed = map(checked, PINS) + price, prior, old = [loads(raw, object_pairs_hook=unique) for raw in (price, prior, old)] + assert price["head"] == prior["head"] == HEAD and price["caller"] == CALLER + assert Q(price["complete_probe"][0]) > 0 + tests = controls(old) + rows = [r for r in prior["results"] if r["key"][1] == CHART and PIVOT in r["pivots"]] + requests = {r["key"][0]:tuple(r["public"]) for r in rows} + keys = [r["key"] for r in price["selected"]] + price["unvisited"] + assert len(requests) == len(rows) == len(keys) == CASE_CAP + assert set(requests) == {k[0] for k in keys} and all(k[1] == CHART for k in keys) + assert all(not r["owned"] and r["disposition"] == "rank drop" for r in rows) + raw = decompress(packed) + assert sha256(raw).hexdigest() == PAYLOAD + word = loads(raw, object_pairs_hook=unique) + assert (word["public"], word["owned_fields"], len(word["program"])) == (1501,68,76466) + cohort = set(price["endpoint_cohort"]) + assert len(cohort) == 615 and PIVOT in cohort and 631 not in cohort + assert all((word["initial"][r],word["final"][r]) == (3,127) for r in cohort) + assert [len(word["frames"][r]) for r in (3,118,127)] == [0,5,9] + classes, contacts = cohorts(word, requests, deadline) + results = [] + for (_epoch, bank), aliases in classes: + cut = aliases[0] + f = trace(word,cut,bank,deadline,True) + s = trace(word,cut,bank,deadline,False) + fp, pure_f = kernel(f,cohort) + sp, pure_s = kernel(s,cohort) + local = [[str(dot(a,b)) for b,_ in pure_s] for a,_ in pure_f] + endpoint = [[str(dot(c,d)) for _,d in pure_s] for _,c in pure_f] + zero = all(v=="0" for matrix in (local,endpoint) for row in matrix for v in row) + results.append(dict(representative=[cut,CHART], keys=[[t,CHART] for t in aliases], bank=bank, + prefix_rank=fp, suffix_rank=sp, + pure_prefix=[dict(a=printed(a),c=printed(c)) for a,c in pure_f], + pure_suffix=[dict(b=printed(b),d=printed(d)) for b,d in pure_s], + local=local, endpoint=endpoint, status="zero pairing" if zero else "requires exact pairing test")) + excluded = sum(len(row["keys"]) for row in results if row["status"] == "zero pairing") + alarm(0) + print(dumps(dict(head=HEAD,caller=CALLER,pins=PINS,controls=tests,cap_cases=CASE_CAP,cap_seconds=35, + representative_count=len(results),case_count=len(requests),contacts=contacts,results=results, + excluded=excluded,unresolved=CASE_CAP-excluded, + scope="Relaxed exact rational normalized prefix and suffix pairing, original fixed paid paths."), + indent=2,sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/p104-three-role-endpoint-exchange-bound/inputs/reverse_span.py b/research/p104-three-role-endpoint-exchange-bound/inputs/reverse_span.py new file mode 100644 index 0000000000..5efbeac87e --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/inputs/reverse_span.py @@ -0,0 +1,393 @@ +"""Independent normalized reverse-contact and fraction-free donor-span gate.""" +from argparse import ArgumentParser +from collections import Counter, defaultdict +from fractions import Fraction +from functools import cache +from gzip import decompress +from hashlib import sha256 +from json import dumps, loads +from math import gcd, isqrt, lcm +from pathlib import Path +from signal import SIGALRM, alarm, signal +from time import monotonic + +HEAD = "aaeec8c0acf01e99a5f331ef363a698d9c084ace" +WORD = "4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a" +PRICE = "c9166ff18194a7e69f91a06f76329a2ff838bb65b08c4ed7a5a06038fdfa966d" +PRIME = 65521 + + +def unique(pairs): + values = dict(pairs) + assert len(values) == len(pairs), "duplicate JSON key" + return values + + +def checked(path, pin, compressed=False): + raw = path.read_bytes() + if sha256(raw).hexdigest() != pin: + raise ValueError(f"changed input {path.name}") + return loads(decompress(raw) if compressed else raw, object_pairs_hook=unique) + + +@cache +def coefficient(raw): + q = Fraction(raw) + assert q and q.denominator % PRIME, "nonunit native denominator" + return q.numerator, q.denominator + + +def normalized(values, denominator): + if not values: + return {}, 1 + divisor = gcd(denominator, *values.values()) + if divisor != 1: + return {j: a // divisor for j, a in values.items()}, denominator // divisor + return values, denominator + + +def sum_scaled(first, second, factor): + a, da = first + b, db = second + numerator, denom = factor + if not b: + return first + common = lcm(da, db * denom) + out = {j: v * (common // da) for j, v in a.items()} + weight = numerator * (common // (db * denom)) + for j, v in b.items(): + val = out.get(j, 0) + weight * v + if val: + out[j] = val + else: + out.pop(j, None) + return normalized(out, common) + + +def incidence(e): + return e[1:3] if e[0] in ("ADD", "COPY") else e[1:2] + + +def candidates(word, quote): + n = word["public"] + tape = word["program"] + stock = {} + for case in quote["candidates"]: + owner = case["owner"] + left, right = case["move_clocks"] + a, middle, c = case["chart_path"] + original, entry = case["literal_ADD"] + assert case["owner_access"] == "destination" and entry[0] == owner + assert entry[1] == case["peer"] and entry[-1] == middle + assert tape[left] == ["MOVE", owner, a, middle, True] + assert tape[right] == ["MOVE", owner, middle, c, True] + assert tape[original] == ["ADD", *entry] + assert n <= owner and left < original < right + assert [i for i in range(left + 1, right) if owner in incidence(tape[i])] == [original] + assert case["cut_windows_pre_event"] == {"entrance": [left, right], "exit": [left + 1, right]} + stock[owner, left, right] = case + assert len(stock) == 3 and len({tuple(k) for k in quote["keys"]}) == quote["case_cap"] == 33 + return stock + + +def collect(word, cuts, observations, cap): + """Forward structural pass only. Assign one ID to each requested live value.""" + n = word["public"] + chart = list(word["initial"]) + [None] * word["owned_fields"] + revisions = [0] * len(chart) + fresh = set() + starts = {} + lifetimes = {} + requests = defaultdict(list) + observation_ids = {} + bank_ids = {} + value_id = {} + paid = Counter() + + @cache + def span(f): + vectors = {0} + for v in word["frames"][f]: + assert v not in vectors + vectors.update(v ^ t for t in tuple(vectors)) + return vectors + + def request(t, role): + assert chart[role] is not None + key = role, revisions[role] + if key not in value_id: + value_id[key] = len(value_id) + requests[t].append((role, value_id[key])) + return value_id[key] + + tape = word["program"] + for t in range(len(tape) + 1): + if t % 128 == 0 and monotonic() >= cap: + raise TimeoutError("literal structural scan") + for role in observations.get(t, ()): + observation_ids[t, role] = request(t, role) + for key, chart_id, exclude in cuts.get(t, ()): + bank_ids[key] = [(r, request(t, r)) for r, c in enumerate(chart) if c == chart_id and r != exclude] + if t == len(tape): + break + op, d, *args = tape[t] + assert 0 <= d < len(chart) + if op == "INIT": + assert d >= n and chart[d] is None + chart[d], starts[d] = args[0], t + fresh.add(d) + elif op == "CLEAR": + assert d >= n and chart[d] == args[0] and d in starts + lifetimes[d, starts.pop(d)] = t + chart[d] = None + fresh.discard(d) + elif op == "MOVE": + a, b, owned = args + assert chart[d] == a and owned == (d >= n) + assert span(a) < span(b) or owned and span(b) < span(a) + paid[abs(len(word["frames"][b]) - len(word["frames"][a]))] += 1 + chart[d] = b + fresh.discard(d) + continue + elif op == "SCALE": + assert chart[d] == args[-1] + coefficient(args[-2]) + fresh.discard(d) + else: + assert op in ("ADD", "COPY") + src, coeff, f = args + assert d != src and chart[d] == chart[src] == f + coefficient(coeff) + if op == "COPY": + assert d >= n and d in fresh + fresh.discard(d) + revisions[d] += 1 + assert not starts and chart == word["final"] + [None] * word["owned_fields"] + return requests, observation_ids, bank_ids, lifetimes, dict(paid), len(value_id) + + +def transpose_prefix(word, requests, count, cap): + """Propagate all requested output covectors backward, then transpose to input rows.""" + n = word["public"] + empty = ({}, 1) + adjoint = [empty] * (n + word["owned_fields"]) + tape = word["program"] + for t in range(max(requests), -1, -1): + if t % 128 == 0 and monotonic() >= cap: + raise TimeoutError("reverse normalized prefix") + op, d, *args = tape[t] + if op in ("INIT", "CLEAR"): + adjoint[d] = empty + elif op == "SCALE": + adjoint[d] = sum_scaled(empty, adjoint[d], coefficient(args[-2])) + elif op in ("ADD", "COPY"): + src = args[0] + adjoint[src] = sum_scaled(adjoint[src], adjoint[d], coefficient(args[-2])) + if op == "COPY": + adjoint[d] = empty + else: + assert op == "MOVE" + for r, output in requests.get(t, ()): + adjoint[r] = sum_scaled(adjoint[r], ({output: 1}, 1), (1, 1)) + assert not any(d for d, _ in adjoint[n:]) + by_output = [[] for _ in range(count)] + for coord, (coeffs, d) in enumerate(adjoint[:n]): + assert d % PRIME + for i, v in coeffs.items(): + by_output[i].append((coord, v, d)) + rows = [] + for entries in by_output: + common = lcm(*(d for _, _, d in entries)) + rows.append(normalized({i: v * (common // d) for i, v, d in entries}, common)) + return rows + + +def eliminate(v, basis, record=False): + """Reverse-pivot integer elimination. All leading pivots are exact.""" + v = v.copy() + reductions = [] + multiplier = 1 + while v: + k = max(v) + if k not in basis: + break + w = basis[k] + a, b = w[k], v[k] + d = gcd(a, b) + a, b = a // d, b // d + next_v = {j: a * x for j, x in v.items()} + for j, x in w.items(): + z = next_v.get(j, 0) - b * x + if z: + next_v[j] = z + else: + next_v.pop(j, None) + assert k not in next_v + g = gcd(*next_v.values()) or 1 + v = {j: x // g for j, x in next_v.items()} + if record: + reductions.append((k, Fraction(b, a) * multiplier)) + multiplier *= Fraction(g, a) + return v, reductions, multiplier + + +def dot(row, covector): + numerator, denominator = row + return sum((numerator.get(j, 0) * v for j, v in covector.items()), Fraction(0)) / denominator + + +def exact_span(bank, target): + t, dt = target + if not t: + return dict(status="exact_span", coefficients={}) + exterior = next((j for j in sorted(t) if all(j not in row for _, (row, _) in bank)), None) + basis = {} + histories = {} + for role, (v, d) in bank: + reduced, steps, scale = eliminate(v, basis, record=True) + if reduced: + pivot = max(reduced) + basis[pivot] = reduced + histories[pivot] = (role, d, steps, scale) + if exterior is not None: + residue = t[exterior] * pow(dt, -1, PRIME) % PRIME + return dict(status="absent_exterior_coordinate", donor_rank=len(basis), augmented_rank=len(basis)+1, + coordinate=exterior, target_coefficient=str(Fraction(t[exterior], dt)), + target_residue_mod_prime=residue) + residual, steps, scale = eliminate(t, basis, record=True) + if residual: + k = max(residual) + dual = {k: Fraction(1)} + for p, v in sorted(basis.items()): + coefficient = -sum((v.get(j, 0) * c for j, c in dual.items()), Fraction(0)) / v[p] + if coefficient: + dual[p] = coefficient + target_value = dot(target, dual) + assert target_value and all(dot(v, dual) == 0 for _, v in bank) + return dict(status="exact_rank_exclusion", donor_rank=len(basis), augmented_rank=len(basis) + 1, + missing_reverse_pivot=k, residual_integer_row=residual, + separating_covector={j: str(v) for j, v in dual.items()}, separated_target=str(target_value)) + pending = dict(steps) + solution = defaultdict(Fraction) + for pivot in sorted(basis): + if pivot not in pending: + continue + weight = pending.pop(pivot) + if not weight: + continue + role, denom, reductions, factor = histories[pivot] + weight /= factor + solution[role] += weight * denom / dt + for j, scalar in reductions: + pending[j] = pending.get(j, Fraction(0)) - weight * scalar + assert not pending + check = ({}, 1) + rows = dict(bank) + for r, x in solution.items(): + check = sum_scaled(check, rows[r], (x.numerator, x.denominator)) + assert check == target, (check, target) + return dict(status="exact_span", donor_rank=len(basis), + coefficients={r: str(x) for r, x in sorted(solution.items()) if x}) + + +def controls(): + toy = {"public": 4, "owned_fields": 1, "frames": [[]], "initial": [0] * 4, "final": [0] * 4, + "program": [["INIT", 4, 0], ["COPY", 4, 0, "1/2", 0], ["ADD", 4, 1, "-3", 0], + ["ADD", 0, 2, "2", 0], ["CLEAR", 4, 0]]} + req, ids, banks, _, _, count = collect(toy, {3:[((3,), 0, 4)], 4:[((4,), 0, 4)]}, {3:[4]}, float("inf")) + rows = transpose_prefix(toy, req, count, float("inf")) + target = rows[ids[3, 4]] + before = [(r, rows[i]) for r, i in banks[3,] if r in (0, 1)] + after = [(r, rows[i]) for r, i in banks[4,] if r in (0, 1)] + assert exact_span(before, target)["coefficients"] == {0:"1/2", 1:"-3"} + assert exact_span(after, target)["status"] == "exact_rank_exclusion" + assert exact_span(before[1:], target)["status"] == "absent_exterior_coordinate" + # Nontrivial exact dependency and reconstruction after a shared pivot. + multi = [(5, ({0: 3, 1: -1}, 2)), (6, ({0: 1, 1: 4}, 3)), (7, ({0: 11, 1: 2}, 1))] + hit = exact_span(multi, ({0: 11, 1: 2}, 1)) + assert hit["status"] == "exact_span" and len(hit["coefficients"]) == 2 + return ["signed_multi_source_and_owned_COPY", "intervening_write_blocks_span", "absent_exterior_coordinate", + "dependent_donor_bank_exact_reconstruction"] + + +def audit(word, quote, cap, decisions): + assert (word["public"], word["owned_fields"], len(word["program"])) == (1501, 68, 76466) + stock = candidates(word, quote) + observed = defaultdict(set) + cuts = defaultdict(list) + for row in quote["keys"]: + key = tuple(row) + owner, left, right, side, t = key + item = stock[owner, left, right] + chart = item["chart_path"][0 if side == "entrance" else 2] + assert item["cut_windows_pre_event"][side][0] <= t <= item["cut_windows_pre_event"][side][1] + cuts[t].append((key, chart, owner)) + observed[item["literal_ADD"][0]].add(item["peer"]) + requests, refs, banks, lifetimes, paid, count = collect(word, cuts, observed, cap) + assert paid == {1:4000, 2:853, 3:829, 4:223, 5:345, 6:14, 7:10, 8:5} + for item in stock.values(): + left, right = item["owner_lifetime"] + assert lifetimes[item["owner"], left] == right + rows = transpose_prefix(word, requests, count, cap) + for entry in quote["keys"]: + if monotonic() >= cap: + raise TimeoutError("exact donor bank gate") + owner, left, right, side, t = entry + item = stock[owner, left, right] + source = item["peer"] + target_id = refs[item["literal_ADD"][0], source] + target = rows[target_id] + bank = [(r, rows[i]) for r, i in banks[tuple(entry)]] + chart = item["chart_path"][0 if side == "entrance" else 2] + decision = exact_span(bank, target) + decisions.append(dict(key=entry, proposed_chart=chart, literal_read_peer=source, + literal_read_clock=item["literal_ADD"][0], donors=len(bank), owned_donors=sum(r>=word["public"] for r,_ in bank), + target_row_id=target_id, donor_role_row_ids=banks[tuple(entry)], + donor_rowset_sha256=sha256(dumps(bank, sort_keys=True).encode()).hexdigest(), **decision)) + return rows + + +def main(): + parser = ArgumentParser(description=__doc__) + parser.add_argument("--word", type=Path) + parser.add_argument("--price", type=Path) + parser.add_argument("--controls-only", action="store_true") + args = parser.parse_args() + if args.controls_only: + print(dumps(controls())) + return + assert args.word is not None and args.price is not None and __debug__ + start = monotonic() + def stop(*_): + raise TimeoutError("hard 20-second runner cap") + signal(SIGALRM, stop) + alarm(20) + decisions = [] + keys = [] + rows = None + tests = [] + timed_out = None + try: + tests = controls() + assert all(PRIME % d for d in range(2, isqrt(PRIME)+1)) + quote = checked(args.price, PRICE) + assert quote["head"] == HEAD and quote["word_sha256"] == WORD + keys = quote["keys"] + rows = audit(checked(args.word, WORD, compressed=True), quote, start+18, decisions) + except TimeoutError as error: + timed_out = str(error) + finally: + alarm(0) + result = dict(head=HEAD, word_sha256=WORD, price_sha256=PRICE, prime=PRIME, + case_cap=33, runner_cap_seconds=20, controls=tests, distinct_requested_rows=len(rows) if rows is not None else None, + requested_integer_rows=rows, + cases=decisions, disposition_counts=dict(Counter(r["status"] for r in decisions)), + unresolved=keys[len(decisions):], timeout=timed_out, + survivors=[r for r in decisions if r["status"] == "exact_span"]) + print(dumps(result, sort_keys=True, indent=2)) + if timed_out: + raise SystemExit(2) + + +if __name__ == "__main__": + main() diff --git a/research/p104-three-role-endpoint-exchange-bound/receipts/SHA256.json b/research/p104-three-role-endpoint-exchange-bound/receipts/SHA256.json new file mode 100644 index 0000000000..3afecdcf6f --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/receipts/SHA256.json @@ -0,0 +1,8 @@ +{ + "INDEPENDENT.json": "2a6b1974fd32fd333e68711bfe7445207d12492cd33c7db0561ff295d49e4c33", + "R148-IMPULSE.json": "d7b30091bd881711f4de7339216368ef8de1649e35cddb00d4dd29be2185b3af", + "R148-PREFIX.json": "e17e9b4dfb359eed4e478ea6ae7d2cc247687867054f3991f19bbd51e4ab73d9", + "R148-PRICE.json": "8b71d05eddb3aee641ffa41a57a3922292bc4d45c5eb8aae8f2e4514388f6524", + "R150-KEYS.json": "ee3ad61078a0a2e5e0a0dcdab672734fa60ffd49880fd12d328f1d1e5490a065", + "R150-RESULT.json": "d2d31b2fc11f0d0388e2c0238df4bcac3d68293154ad72b3de2f6f0046d7697e" +} diff --git a/research/p104-three-role-endpoint-exchange-bound/replay.py b/research/p104-three-role-endpoint-exchange-bound/replay.py new file mode 100644 index 0000000000..7913b2f236 --- /dev/null +++ b/research/p104-three-role-endpoint-exchange-bound/replay.py @@ -0,0 +1,157 @@ +"""Reproduce the exact P104 role-1454 three-role endpoint-exchange exclusion.""" +from argparse import ArgumentParser +from gzip import decompress +from hashlib import sha1,sha256 +from json import dumps,loads +from pathlib import Path +from subprocess import run +import sys +from tempfile import TemporaryDirectory + +ROOT=Path(__file__).resolve().parent + + +def unique(items): + out=dict(items) + if len(out)!=len(items): + raise ValueError('duplicate JSON key') + return out + + +def decode(raw): + return loads(raw,object_pairs_hook=unique) + + +def digest(raw): + return sha256(raw).hexdigest() + + +def source(name): + path=Path(name) + if 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 verify_inputs(): + pins=decode(source('LOCAL-PINS.json')) + for name,expected in pins.items(): + if digest(source(name))!=expected: + raise ValueError('changed package dependency '+name) + p=decode(source('PROVENANCE.json')) + for name,entry in p['files'].items(): + raw=source(name) + assert digest(raw)==entry['sha256']==pins[name] + assert sha1(f'blob {len(raw)}\0'.encode()+raw).hexdigest()==entry['git_blob'] + out={} + for name,entry in p['derived_inputs'].items(): + raw=decompress(source(name)) + assert digest(raw)==decode(source(entry['receipt']))[entry['key']] + out[Path(name).stem]=raw + a=decode(source('inputs/ADMITTED.json')) + assert a['head']=='aaeec8c0acf01e99a5f331ef363a698d9c084ace' + assert a['kappa']=='0.00364665195644' + return out + + +def call(script,*args,expect_success=True): + p=run([sys.executable,'-I','-B',str(script),*args],capture_output=True,timeout=40) + if expect_success and p.returncode: + sys.stderr.write(p.stderr.decode(errors='replace')) + p.check_returncode() + return p + + +def write(path,raw): + path.parent.mkdir(parents=True,exist_ok=True) + path.write_bytes(raw) + + +def replay(root,out): + inherited=verify_inputs() + expected=decode(source('receipts/SHA256.json')) + outputs={} + def record(name,script,*args): + raw=call(script,*args).stdout + assert digest(raw)==expected[name],('changed deterministic receipt',name) + outputs[name]=raw + return decode(raw) + + r148,r150=root/'r148',root/'r150' + for stage in (r148,r150): + write(stage/'inputs/7334-WORD.json.gz',source('inputs/7334-WORD.json.gz')) + for key,name in (('R143-PRICE.json','PRICE.json'),('R143-GEOMETRY.json','GEOMETRY.json'), + ('R96-PRICE.json','R96-PRICE.json')): + write(r148/'inputs'/name,inherited[key]) + for name in ('7334-READBACK.json','reverse_span.py'): + write(r148/'inputs'/name,source('inputs/'+name)) + write(r148/'lead/impulse.py',source('engines/third_impulse.py')) + write(r148/'lead/basis.py',source('engines/third_basis.py')) + write(r150/'lead/close.py',source('engines/close.py')) + + price=record('R148-PRICE.json',r148/'lead/impulse.py','--price-only') + write(r148/'lead/PRICE.json',outputs['R148-PRICE.json']) + screen=record('R148-IMPULSE.json',r148/'lead/impulse.py') + write(r148/'lead/IMPULSE.json',outputs['R148-IMPULSE.json']) + prefix=record('R148-PREFIX.json',r148/'lead/basis.py','prefix') + for name in ('PRICE','IMPULSE','PREFIX'): + write(r150/'inputs'/f'{name}.json',outputs[f'R148-{name}.json']) + keys=record('R150-KEYS.json',r150/'lead/close.py','--freeze') + write(r150/'lead/KEYS.json',outputs['R150-KEYS.json']) + close=record('R150-RESULT.json',r150/'lead/close.py') + + reverse=r150/'independent/three_role.py' + reverse_out=r150/'independent/RESULT.json' + write(reverse,source('engines/three_role.py')) + write(r150/'inputs/word.json.gz',source('inputs/7334-WORD.json.gz')) + write(r150/'inputs/bank_trace.py',source('inputs/bank_trace.py')) + write(r150/'lead/GEOMETRY.json',inherited['R143-GEOMETRY.json']) + for name in ('IMPULSE','PREFIX'): + write(r150/'third'/f'{name}.json',outputs[f'R148-{name}.json']) + for name in ('KEYS','RESULT'): + write(r150/'followup'/f'{name}.json',outputs[f'R150-{name}.json']) + call(reverse,'--root',str(r150),'--output',str(reverse_out)) + data=reverse_out.read_bytes() + assert digest(data)==expected['INDEPENDENT.json'] + outputs['INDEPENDENT.json']=data + independent=decode(data) + + assert price['paid_delta']=={} and price['productive_delta']=={'5':-17,'6':17,'8':17,'9':-17} + assert screen['counts']=={'no coframe':3961,'prefix pending':16494} + assert len(screen['unresolved'])==15 + assert prefix['counts']=={'exact_rank_exclusion':8} and len(prefix['unvisited'])==7 + assert all(r['proof']['separating_covector']=={'1251':'1','1481':'4'} for r in prefix['rows']) + assert len(close['rows'])==len(keys['ranges'])==7 and close['raw_cuts']==478 + assert close['progress']['events']==76466 and not close['unresolved'] + assert all(r['status']=='prefix excluded' and r['first_nonzero'] is None for r in close['rows']) + assert len(independent['rows'])==15 and not independent['unresolved'] + assert set(outputs)==set(expected) + + def rejected(path,script,*args): + raw=path.read_bytes() + path.write_bytes(raw+b' ') + check=call(script,*args,expect_success=False) + assert check.returncode==1 and b'changed' in check.stderr + path.write_bytes(raw) + + rejected(r148/'lead/IMPULSE.json',r148/'lead/basis.py','prefix') + rejected(r150/'inputs/PREFIX.json',r150/'lead/close.py') + rejected(r150/'followup/KEYS.json',reverse,'--root',str(r150),'--output',str(reverse_out)) + if out is not None: + out.mkdir(parents=True) + for name,raw in outputs.items(): + write(out/name,raw) + print('PASS_P104_THREE_ROLE_ENDPOINT_EXCHANGE_BOUND segments=15 eligible_cuts=16494 unresolved=0') + + +def main(): + assert __debug__ and sys.version_info[:2]==(3,12) + parser=ArgumentParser(description=__doc__) + parser.add_argument('--out',type=Path) + args=parser.parse_args() + with TemporaryDirectory() as tmp: + replay(Path(tmp),args.out) + + +if __name__=='__main__': + main()