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-fixed-peer-two-add-retime-bound/LOCAL-PINS.json b/research/p104-fixed-peer-two-add-retime-bound/LOCAL-PINS.json new file mode 100644 index 0000000000..e1bf2e4a99 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/LOCAL-PINS.json @@ -0,0 +1,18 @@ +{ + "PROVENANCE.json": "7f8e94e73ead556c22d55561ec3aa4b6ff1216de299890681886a5b18403b4d6", + "engines/compare.py": "02ddd19ff71ddca84823be1c76fc2b9f2aadaa5ea36110ac244ed32e42fa178d", + "engines/quote.py": "4096f91f206bdcaa5ad35c2fa08c2b5f9ec6d8c81cf7d3d05c9f4ce7c44482cc", + "engines/reverse_intervals.py": "f480ded9277bd6dff41ed3442c95aa5d88ea324b18fa11e5485afc6dfc1e4bff", + "engines/reverse_routes.py": "a81a41c1cd33de0a612b568cbf470003d933a344396bc6dc53b85a91888dfe27", + "engines/walk.py": "f3e8fc8a588ae51efdced6d40ab3107ab8ba7844202d64452c2d145c2b79986c", + "inputs/7334-WORD.json.gz": "4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a", + "inputs/PR7362-SHA256.json": "2c90ca39b0f075cc4b3ec9e90c66fde473465e7bb50cf1db9a820d3a29556c0b", + "inputs/PR7365-SHA256.json": "f8418b2b07e4ecb6d49d8839015e9ceab2224816d7863edd59cb03f29de34566", + "inputs/R100-GEOMETRY.json.gz": "ca159a989afa5c4ae67a2e77de2faadf5db5bc535d6c1e15bb080abc49e0866c", + "inputs/R100-PRICE.json.gz": "8ced8ba518250f652856ebf72ee8733532289d62450511e94d4ba17dc6eaae99", + "inputs/R92-PRICE.json.gz": "857b2776d4fb18844a08c82bb9387ddb3332d025bc7ecef2e606e6666705acf2", + "inputs/pricing.py": "f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182", + "receipts/AGREEMENT.json": "0d94d589c7b9fe02e25a56da858ecaf91b29d3d3ee194873408e6206291870f9", + "receipts/SHA256.json": "230a925ec2533b23ee92e2b69d9e6c5eca7e36f0b5e5370808cd865b948991e3", + "replay.py": "41c29a135c73de8cbdb1697d788c214e57bc616f66bd25c91e5d0d8ed6ac8fc9" +} diff --git a/research/p104-fixed-peer-two-add-retime-bound/NOTICE b/research/p104-fixed-peer-two-add-retime-bound/NOTICE new file mode 100644 index 0000000000..cce88a5f75 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/NOTICE @@ -0,0 +1,7 @@ +Apache-2.0. + +#7334 and #7113 supply the exact native word and signed caller. +#7338 supplies prior inventory of the same four paid pairs. +#7365, #7362 and #7298 supply contact, stock and price inputs. +#7003, #7004, #7312, #7366 and #7368 supply chronology precedents. +OpenAI Codex and subagents materially assisted. diff --git a/research/p104-fixed-peer-two-add-retime-bound/PROOF.md b/research/p104-fixed-peer-two-add-retime-bound/PROOF.md new file mode 100644 index 0000000000..3aed99f839 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/PROOF.md @@ -0,0 +1,77 @@ +# Fixed-peer signed two-ADD chronology + +The exact predecessor contact receipt freezes four public mover +paths A→B→C. Each path has only two contacts between its paid +MOVEs, at the next two literal clocks after the first MOVE. +The same fixed public peer participates in both ADDs and each +ADD writes a different operand. In mover/peer order, the +first two windows have normalized matrix +`[[1,−1],[1/2,1/2]]` and the last two have +`[[1/2,−1/2],[1,1]]`. Both exact determinants are one. + +| Mover | Paid MOVE clocks | A, B, C | Peer | Inclusive candidate cuts | +|---:|---|---|---:|---| +| 1305 | 41321, 44605 | 856, 983, 207 | 1488 | 41324–44605 | +| 1303 | 43854, 44615 | 854, 984, 207 | 1302 | 43857–44615 | +| 654 | 44564, 44617 | 856, 983, 207 | 1449 | 44567–44617 | +| 652 | 44585, 44619 | 854, 984, 207 | 1450 | 44588–44619 | + +A cut c is the state after exactly c original events, before event +c when it exists. The old signed pair ends immediately before +the first cut. Placing the direct A→C MOVE at the old second +MOVE puts the mover on A for the retimed pair. The unchanged +peer is already on B at the old pair. Its public moves strictly +ascend, so it cannot meet the mover at A after the pair. This +excludes all 4,124 low-endpoint typed cuts. + +Placing the direct MOVE at the old first clock puts the mover +on C for the retimed pair. The public peer must occupy that +exact chart and the corridor must be clear of all scalar and +lifetime contacts of either operand. Both source and destination +contacts of ADD and COPY count. A MOVE into a chart at clock t +first changes the chart at pre-event cut t+1. An ADD at t first +counts as a crossed event at cut t+1. This convention includes +the old second MOVE clock itself as a cut. All other paths and +the original signed ADD order stay fixed. + +The forward walk classifies each late cut. The independent +reverse walk reconstructs exact chart and contact intervals. +Both agree on all four windows, every peer chart and relevant +MOVE, and the first blocking contact. None of the 4,124 late +cuts has the peer in C. Of these, 2,364 have clean scalar +corridors and 1,760 cross a scalar contact. The first three +windows first cross an ADD at 43649, 43859 and 44569 respectively. +The last window has 32 clean cuts, all in the wrong chart. Since +even a clear corridor cannot supply the required peer chart, +no exact signed prototype was necessary. + +The same four keys are present in +[#7338](https://github.com/CrocSwap/integer-mult-bounds/pull/7338) +at exact head `349996445176e934ffb3c76813adcd230ca8f783`. Its +R69 geometry labels each `missing_low_or_high_stock` under +the maximal-component virtual-owned fusion guard. The +[published manifest](https://github.com/CrocSwap/integer-mult-bounds/blob/349996445176e934ffb3c76813adcd230ca8f783/research/p104-compensated-fusion-readout-bound/receipts/SHA256.json) +pins that geometry. This replay supplies the separate exact +high-endpoint obstruction for the specified public peers. + +## Complete signed price + +Each possible contraction replaces two rank-one paid calls by +one rank-two call. Across all 17 signed caller copies this +would change the paid histogram by {1:−34, 2:+17}. Paid +positions would change from 110,519 to 110,502 for one +edit or to 110,451 for four. Productive positions stay at +22,461 and signed rank surplus at 1,424. The priced resource +cap counts the eight distinct paid clocks and eight distinct +public operands only once. The compatible relaxation gives +about 0.08583213854035211 raw per edit and 0.34332855416140845 +for four at the incumbent crossing upper. The complete fixed +target margin upper is about −139.38966768429373 at +κ = 0.0040075385047236. One added raw rank-one paid position +would exceed the entire optimistic credit. + +The proof retains the native all-column, owned-erasure, compiler, +precision/tape and analytic recovery premises. Changed peer +itineraries, different windows and alternative scalar transports +remain outside the test. No new supplier, full changed-caller +replay or κ claim is asserted. diff --git a/research/p104-fixed-peer-two-add-retime-bound/PROVENANCE.json b/research/p104-fixed-peer-two-add-retime-bound/PROVENANCE.json new file mode 100644 index 0000000000..4ff3073de2 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/PROVENANCE.json @@ -0,0 +1,50 @@ +{ + "derived_gzip": { + "R100-GEOMETRY": { + "key": "r100/lead/GEOMETRY.json", + "receipt": "inputs/PR7365-SHA256.json" + }, + "R100-PRICE": { + "key": "r100/lead/PRICE.json", + "receipt": "inputs/PR7365-SHA256.json" + }, + "R92-PRICE": { + "key": "R92-PRICE.json", + "receipt": "inputs/PR7362-SHA256.json" + } + }, + "files": { + "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/PR7362-SHA256.json": { + "commit": "5eec7ed633dcf9b9bbc95552aa653da296f863fb", + "git_blob": "b1486e0b5cfe4535f381ed26f7bce4aee21d8a43", + "path": "research/p104-rank-two-virtual-cut-bound/receipts/SHA256.json", + "sha256": "2c90ca39b0f075cc4b3ec9e90c66fde473465e7bb50cf1db9a820d3a29556c0b", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/5eec7ed633dcf9b9bbc95552aa653da296f863fb/research/p104-rank-two-virtual-cut-bound/receipts/SHA256.json", + "uncompress": false + }, + "inputs/PR7365-SHA256.json": { + "commit": "98be9db1f28cdc5fa8962c7da065bc0174db9744", + "git_blob": "2c2e083626e3e3227dcc8cb2864e61222b273d3f", + "path": "research/p104-changed-public-move-contraction-bound/receipts/SHA256.json", + "sha256": "f8418b2b07e4ecb6d49d8839015e9ceab2224816d7863edd59cb03f29de34566", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/98be9db1f28cdc5fa8962c7da065bc0174db9744/research/p104-changed-public-move-contraction-bound/receipts/SHA256.json" + }, + "inputs/pricing.py": { + "commit": "c522451caf287bb3c16eaece72be4c263315dca4", + "git_blob": "40ec194017bda1d524bba4f07b188c53281419d0", + "path": "research/adjacent-owned-add-exchange-bound/pricing.py", + "sha256": "f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/c522451caf287bb3c16eaece72be4c263315dca4/research/adjacent-owned-add-exchange-bound/pricing.py", + "uncompress": false + } + }, + "schema_version": 1 +} diff --git a/research/p104-fixed-peer-two-add-retime-bound/README.md b/research/p104-fixed-peer-two-add-retime-bound/README.md new file mode 100644 index 0000000000..457be6ac0c --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/README.md @@ -0,0 +1,70 @@ +# Fixed-peer two-ADD retiming of P104 helper paths + +**NO VERIFIED GAIN.** Exact Δκ = 0 relative to the independently +reproduced conditional κ = `0.00364665195644` on +[#7334](https://github.com/CrocSwap/integer-mult-bounds/pull/7334) +`aaeec8c0acf01e99a5f331ef363a698d9c084ace`, with exact signed +[#7113](https://github.com/CrocSwap/integer-mult-bounds/pull/7113) +`07a76c5e2738882c0cb322278e56f6cae3c9885d`. + +Replace one public 1+1 paid ascent by a direct rank-two ascent. +Retain both signed ADDs in order, with a fixed public peer and +its complete paid path. Four frozen windows contain 8,248 typed +retiming cuts. Strict ascent excludes all 4,124 low-endpoint cuts. +Two opposite-direction literal walks agree on all 4,124 +high-endpoint cuts. The peer never occupies the high endpoint, +including the 2,364 cuts free of crossed scalar/lifetime events. +The other 1,760 also cross an ADD. There are no survivors or +unresolved cuts. [Exact interval and blocker agreement](receipts/AGREEMENT.json). + +The directed one-edit upper is about 0.08583213854035211 raw. +The optimistic four-edit upper is about 0.34332855416140845 +with all ancillary work granted free. One extra raw rank-one +paid call defeats that whole envelope. [Proof and price](PROOF.md). + +## Replay + +From a clean checkout, use CPython 3.12 with assertions enabled: + +```sh +python3.12 -I -B research/p104-fixed-peer-two-add-retime-bound/replay.py +``` + +The standard-library replay authenticates the exact word and +published predecessor receipts, rebuilds the price, and compares +all four intervals, chart IDs, peer MOVE records and first +blockers. It rejects modified price and word inputs. Use +`--out fresh-directory` to retain all four regenerated receipts. +The package needs no Git metadata, network or previous temporary +state. [Provenance](PROVENANCE.json) · [Path-keyed hashes](LOCAL-PINS.json). + +## Open next questions + +For the 32 scalar-clean cuts of the role-652 window, can an +explicit change to peer 1450's paid path create a chart-207 +meeting? First freeze and price one such change, then test +signed arbitrary-input forward and adjoint action, restoration, +precision and tape only if the complete price survives. The +present exclusion retains the original peer itinerary. + +## Credit + +[#7334](https://github.com/CrocSwap/integer-mult-bounds/pull/7334) +supplies the exact native word and comparator, and +[#7113](https://github.com/CrocSwap/integer-mult-bounds/pull/7113) +the signed caller. [#7338](https://github.com/CrocSwap/integer-mult-bounds/pull/7338) +already inventories these four paid pairs under the +maximal-component virtual-owned fusion mechanism. +[#7365](https://github.com/CrocSwap/integer-mult-bounds/pull/7365) +supplies the changed-role contact and pricing inputs, +[#7362](https://github.com/CrocSwap/integer-mult-bounds/pull/7362) +the complete stock receipt and [#7298](https://github.com/CrocSwap/integer-mult-bounds/pull/7298) +the exact tariff. [#7003](https://github.com/CrocSwap/integer-mult-bounds/pull/7003) +and [#7004](https://github.com/CrocSwap/integer-mult-bounds/pull/7004) +supply the earlier commuting-contact and changed-peer-itinerary +precedents. [#7312](https://github.com/CrocSwap/integer-mult-bounds/pull/7312), +[#7366](https://github.com/CrocSwap/integer-mult-bounds/pull/7366) and +[#7368](https://github.com/CrocSwap/integer-mult-bounds/pull/7368) +supply neighboring sole-ADD chronology tests. OpenAI Codex and +subagents materially assisted the proof, implementation, independent +verification and packaging. diff --git a/research/p104-fixed-peer-two-add-retime-bound/SOURCES.json b/research/p104-fixed-peer-two-add-retime-bound/SOURCES.json new file mode 100644 index 0000000000..e8c2f265cd --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-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-fixed-peer-two-add-retime-bound/TASK.json b/research/p104-fixed-peer-two-add-retime-bound/TASK.json new file mode 100644 index 0000000000..790f4d83dd --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/TASK.json @@ -0,0 +1,117 @@ +{ + "actual_scope": "Exact #7334, four changed-role public mover paths with two consecutive signed ADDs and one fixed public peer. Exhaust the 8,248 typed A/C retiming cuts while preserving all other itineraries.", + "ai_assistance": "OpenAI Codex and subagents materially assisted proof, implementation, independent verification and packaging.", + "author": "P104 fixed-peer two-ADD retiming research", + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bottleneck_link": "A direct rank-two ascent can reduce the binding complex paid cost only if the original peer meets the moved helper on an endpoint chart and the two signed ADDs may be retimed.", + "budget_minutes": 8, + "evidence": "All 4,124 A-side cuts fail strict ascent. Two literal walks agree on all 4,124 C-side cuts, chart intervals, peer MOVE clocks and first blockers. No original peer reaches C within a window.", + "open_questions": [ + { + "blocked_by": "The original peer never occupies the required endpoint chart in the stated window.", + "first_step": "Freeze one changed itinerary for the 32 scalar-clean role-652 cuts and price all affected paid, ordinary, restoration, precision and tape costs.", + "question": "Can a separately priced change to peer 1450 create a chart-207 meeting?", + "why_it_matters": "A valid fixed-bill meeting would unlock the priced rank-two contraction." + } + ], + "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": "Tests an invertible two-ADD block with a fixed public peer, distinct from the predecessor sole-ADD and maximal-component owned fusion scopes.", + "scope_status": "changed", + "stop_rule": "Freeze four windows and the complete price, then at most 76,466 literal events, 4,124 C-side cuts and 20 seconds per engine. Skip construction if the chart or chronology gate excludes every cut.", + "task_id": "p104-side-correction" +} diff --git a/research/p104-fixed-peer-two-add-retime-bound/VERIFICATION.md b/research/p104-fixed-peer-two-add-retime-bound/VERIFICATION.md new file mode 100644 index 0000000000..83439c1155 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/VERIFICATION.md @@ -0,0 +1,17 @@ +# Verification + +Both exact CPython 3.12 literal walks exhaust the 76,466-event +native tape within the 20-second per-engine limit. The reverse +research run took 0.08 seconds with exit 0. Both methods classify +all 4,124 late cuts. The replay also verifies the strict-ascent +certificate for all 4,124 early typed cuts. + +The direct package run took 0.53 seconds with exit 0. The +relocated, Git-free replay with an empty inherited environment +took 0.76 seconds with exit 0 and reproduced all four receipts +byte-for-byte. Altered price and native-word inputs both reject +with exit 1. The checkout-relative command and exact receipts +are in [README.md](README.md) and [receipts/SHA256.json](receipts/SHA256.json). + +No prototype or changed-caller replay was needed because both +endpoint gates exhausted the frozen scope. diff --git a/research/p104-fixed-peer-two-add-retime-bound/VERIFY.json b/research/p104-fixed-peer-two-add-retime-bound/VERIFY.json new file mode 100644 index 0000000000..3854ebcc4c --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/VERIFY.json @@ -0,0 +1,19 @@ +{ + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/replay.py" + ], + "checks": "Authenticate pinned receipts and native input, regenerate complete price and both chronology walks, compare every exact interval, MOVE and blocker, reject changed price and word.", + "timeout_seconds": 100 + } + ], + "inputs": [], + "python": "3.12", + "requirements": [], + "schema_version": 1, + "status": "ready" +} diff --git a/research/p104-fixed-peer-two-add-retime-bound/engines/compare.py b/research/p104-fixed-peer-two-add-retime-bound/engines/compare.py new file mode 100644 index 0000000000..d54321ffdd --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/engines/compare.py @@ -0,0 +1,71 @@ +"""Reconcile every frozen early and late typed cut from the R116 receipts.""" +from collections import Counter +from hashlib import sha256 +from json import dumps,loads +from pathlib import Path +import sys + +PINS={ + "plan/PRICE.json":"8226a2b9c9240455d6fcdaf3a38929e3336e89f35aed3f15b81564f07ed8387f", + "lead/RESULT.json":"1d7d7b122757d4345cfea3fa7d1c8525211939b913e900e9974fb93fc5b18e5e", + "independent/RESULT.json":"f777aaa05cbcb9f6067d9b04220abe9aab01f8eaac5c407b078e0c295ca1f2b7", +} + + +def unique(items): + value=dict(items) + if len(value)!=len(items): + raise ValueError("duplicate JSON key") + return value + + +def main(root): + docs=[] + for rel,expected in PINS.items(): + raw=(root/rel).read_bytes() + if sha256(raw).hexdigest()!=expected: + raise ValueError(f"changed dependency: {rel}") + docs.append(loads(raw,object_pairs_hook=unique)) + price,lead,reverse=docs + assert reverse["head"]==price["head"] and reverse["caller"]==price["caller"] + assert lead["pins"]["plan/PRICE.json"]==reverse["pins"]["inputs/PRICE.json"]==PINS["plan/PRICE.json"] + assert lead["pins"]["inputs/7334-WORD.json.gz"]==reverse["pins"]["inputs/7334-WORD.json.gz"]==price["word_sha256"] + assert lead["completed_literal_events"]==reverse["progress"]["events_replayed"]==76466 + assert lead["timeout"] is None and reverse["timeout"] is None and reverse["complete"] + assert not lead["unresolved_late_cut_intervals"] and not lead["unresolved_late_count"] and not reverse["unvisited"] + counts=Counter() + windows=[] + for p,a,b in zip(price["cases"],lead["windows"],reverse["rows"],strict=True): + assert a["key"]==b["key"]==p["key"] and a["peer"]==b["peer"]==p["peer"] + assert a["charts"]==p["charts"] and b["target_chart"]==p["charts"][2] + assert b["original_pair"]==p["original_pair"] and b["window"]==p["late_pre_event_cuts"] + assert a["first_crossed_scalar"]==b["first_scalar_or_lifetime_contact"] + assert a["first_peer_scalars_in_corridor"][:1]==([] if b["first_scalar_or_lifetime_contact"] is None else [b["first_scalar_or_lifetime_contact"]]) + intervals=[[l,h,chart,clean,clean and at_c] for l,h,chart,at_c,clean in b["intervals"]] + assert intervals==a["late_intervals"] + first,last=b["window"] + assert intervals[0][0]==first and intervals[-1][1]==last + assert all(x[1]+1==y[0] for x,y in zip(intervals,intervals[1:])) + assert all(chart!=p["charts"][0] for _,_,chart,_,_ in intervals) + assert a["early_excluded"]==a["late_tested"]==last-first+1 + assert a["late_peer_at_c"]==b["chart_C_cut_count"]==0 + assert not a["survivors"] and not b["survivors"] + trajectory=b["peer_chart_path"] + moves=[[l[1],["MOVE",p["peer"],l[2],r[2],False]] + for l,r in zip(trajectory,trajectory[1:]) if first<=l[1]0>Q(q["extra_rank_one_upper"]) + old=Counter({int(k):n for k,n in prior["old_targets"].items()}) + old.subtract({int(k):n for k,n in prior["old_paid"].items()}) + delta={1:-34,2:17} + assert q["paid_delta"]=={str(k):v for k,v in delta.items()} + changed=old.copy() + changed.subtract({k:4*v for k,v in delta.items()}) + assert sum(k*v for k,v in old.items())==sum(k*v for k,v in changed.items())==1424 + cost=run_path(str(ROOT/"inputs/pricing.py"))["cost"] + at,probe,target=[Q(price[k]) for k in ("old_crossing_upper","probe","fixed_target")] + credit={k:-v for k,v in delta.items()} + assert cost(credit,at)[1]==Q(q["net"][1]) and cost(changed,probe)[0]>0 + assert 4*cost(credit,at)[1]<1 + print(dumps(dict(head=price["head"],caller=price["caller_head"],kappa=price["kappa"], + word_sha256=price["word_sha256"],payload_sha256=price["word_payload_sha256"],pins=PINS, + cases=rows,old_paid=110519,one_new_paid=110502,optimistic_all_four_paid=110451,productive=22461, + rank_surplus=1424,paid_delta=delta,compatible_paid_delta={k:4*v for k,v in delta.items()}, + one_upper=q["net"][1],whole_upper=str(4*cost(credit,at)[1]), + complete_four_probe=list(map(str,cost(changed,probe))),fixed_target_complete_upper=str(cost(changed,target)[1]), + caps=dict(windows=4,typed_cuts=2*candidates,late_cuts=candidates,runner_seconds=20,prototypes=1), + scope="Receipt-only: original adjacent signed pair, both public paths held fixed except one contracted mover route."), + indent=2,sort_keys=True)) + + +if __name__=="__main__": + main() diff --git a/research/p104-fixed-peer-two-add-retime-bound/engines/reverse_intervals.py b/research/p104-fixed-peer-two-add-retime-bound/engines/reverse_intervals.py new file mode 100644 index 0000000000..0273396012 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/engines/reverse_intervals.py @@ -0,0 +1,203 @@ +"""Verify four frozen C-side two-ADD retiming windows by reverse intervals.""" +from argparse import ArgumentParser +from collections import Counter +from fractions import Fraction as Q +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 +import sys + +ROOT=Path(__file__).resolve().parent +HEAD="aaeec8c0acf01e99a5f331ef363a698d9c084ace" +CALLER="07a76c5e2738882c0cb322278e56f6cae3c9885d" +WORD="4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a" +PAYLOAD="9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac" +PINS={ + "inputs/PRICE.json":"8226a2b9c9240455d6fcdaf3a38929e3336e89f35aed3f15b81564f07ed8387f", + "inputs/7334-WORD.json.gz":WORD, + "inputs/reverse_routes.py":"a81a41c1cd33de0a612b568cbf470003d933a344396bc6dc53b85a91888dfe27", +} +EVENTS,WINDOWS,CUTS,SECONDS=76466,4,4124,20 + + +def unique(items): + value=dict(items) + if len(value)!=len(items): + raise ValueError("duplicate JSON key") + return value + + +def authenticate(root): + raw={} + for name,digest in PINS.items(): + data=(root/name).read_bytes() + if sha256(data).hexdigest()!=digest: + raise ValueError(f"changed dependency: {name}") + raw[name]=data + return raw + + +def frame_span(vectors): + span={0} + for vector in vectors: + assert type(vector) is int and 0right: + continue + if first_block is None or right<=first_block: + clip.append([left,right,c,c==target,True]) + elif first_block=deadline: + raise TimeoutError("frozen window cap") + first,last,mover=case["key"] + a,b,c=case["charts"] + peer=case["peer"] + pair=[tuple(r) for r in case["original_pair"]] + t0,t1=(t for t,_ in pair) + lo,hi=case["late_pre_event_cuts"] + assert first+1==t0 and t0+1==t1 and (lo,hi)==(t1+1,last) + assert 0<=mover0 and q>0 + return result | dict(status="both paid MOVEs adjacent", clocks=[f,g], charts=[a,b,c], ranks=[p,q]) + + +def controls(): + move_in=["MOVE",1,4,5,False] + add=["ADD",2,1,"-1/2",5] + move_out=["MOVE",1,5,7,False] + assert operands(add)==(2,1) + assert operands(["COPY",7,1,"1",5])==(7,1) + before,after=neighboring([(1,move_in),(4,add),(7,move_out)],4) + assert decode_route(before,after,1,5,list(range(8)))["ranks"]==[1,2] + blocker=["ADD",3,1,"1",5] + before,after=neighboring([(1,move_in),(3,blocker),(4,add),(7,move_out)],4) + assert decode_route(before,after,1,5,list(range(8)))["status"]=="adjacent contact is not MOVE" + return ["ADD/COPY source counts as a contact","immediate signed adjacent paid MOVE pair", + "intervening read prevents route"] + + +def walk(word, targets, deadline, progress): + tape = word["program"] + public, owned = word["public"], word["owned_fields"] + assert (len(tape),public,owned)==(EVENTS,1501,68) + active = word["final"] + [None]*owned + contacts=defaultdict(list) + for t in range(EVENTS-1,-1,-1): + progress["first_unvisited_event"]=t + if t%128==0 and monotonic()>=deadline: + raise TimeoutError("reverse event cap") + op,r,*args=event=tape[t] + if op=="MOVE": + old,new,is_owned=args + assert active[r]==new and is_owned==(r>=public) + active[r]=old + elif op in ("INIT","CLEAR"): + assert r>=public and active[r]==(args[0] if op=="INIT" else None) + active[r]=None if op=="INIT" else args[0] + else: + assert op in ("ADD","COPY","SCALE") and active[r]==args[-1] + if op!="SCALE": + assert r!=args[0] and active[args[0]]==active[r] + assert op!="COPY" or r>=public + for role in operands(event): + if role in targets: + contacts[role].append((t,event)) + progress["events_replayed"]+=1 + assert active==word["initial"]+[None]*owned + progress["first_unvisited_event"]=None + return {role:list(reversed(contacts[role])) for role in targets} + + +def examine(word, anchors, contacts, deadline, rows): + dimensions=list(map(len,word["frames"])) + for anchor in anchors: + if monotonic()>=deadline: + raise TimeoutError("anchor case cap") + clock,event=anchor["contact"] + first,last,mover=anchor["key"] + peer=anchor["peer"] + assert first= public + if op == "MOVE": + before, after, recorded_owned = args + assert before == current and recorded_owned == owned + assert spans[before] < spans[after] or owned and spans[after] < spans[before] + state[destination] = after + if destination in moves: + moves[destination].append((clock, event)) + elif op in ("INIT", "CLEAR"): + assert owned + if op == "INIT": + assert current is None + state[destination] = args[0] + else: + assert current == args[0] + state[destination] = None + else: + assert op in ("ADD", "COPY", "SCALE") + assert current == args[-1] and Fraction(args[-2]) + if op in ("ADD", "COPY"): + assert args[0] != destination and state[args[0]] == current + if op != "MOVE": + for role in contacts(event): + if role in scalar: + scalar[role].append((clock, event)) + assert state == word["final"] + [None] * word["owned_fields"] + return initial, moves, scalar + + +def classify(case, program, initial, moves, scalar): + f, g, mover = case["key"] + a, b, c = case["charts"] + peer = case["peer"] + low, high = case["late_pre_event_cuts"] + assert (low, high) == (f + 3, g) + assert program[f] == ["MOVE", mover, a, b, False] + assert program[g] == ["MOVE", mover, b, c, False] + pair = [[i, program[i]] for i in (f + 1, f + 2)] + assert pair == case["original_pair"] + assert signed_action(pair, [mover, peer]) == case["normalized_matrix"] + assert [(t, e) for t, e in moves[mover] if f <= t <= g] == [ + (f, program[f]), (g, program[g]) + ] + assert [[t, e] for t, e in scalar[mover] if f < t < g] == pair + assert pre_chart(f + 1, moves[peer], initial[peer]) == b + assert pre_chart(f + 2, moves[peer], initial[peer]) == b + peer_contacts = [(t, e) for t, e in scalar[peer] if low <= t < high] + first = peer_contacts[0] if peer_contacts else None + cuts = [] + for cut in range(low, high + 1): + chart = pre_chart(cut, moves[peer], initial[peer]) + assert chart != a + clean = first is None or first[0] >= cut + cuts.append((cut, chart, clean, chart == c and clean)) + return { + "key": case["key"], "peer": peer, "charts": [a, b, c], + "early_excluded": len(cuts), "late_tested": len(cuts), + "first_crossed_scalar": first, + "peer_moves_through_window": [(t, e) for t, e in moves[peer] if low <= t < high], + "first_peer_scalars_in_corridor": peer_contacts[:2], + "late_intervals": intervals(cuts), + "late_peer_at_c": sum(chart == c for _, chart, _, _ in cuts), + "late_peer_at_c_with_exactly_one_crossed_scalar": sum( + chart == c and first is not None and first[0] < cut + and (len(peer_contacts) < 2 or cut <= peer_contacts[1][0]) + for cut, chart, _, _ in cuts + ), + "survivors": [cut for cut, _, _, passed in cuts if passed], + } + + +def timeout(*_): + raise TimeoutError("20-second replay cap") + + +def main(): + assert __debug__ + signal(SIGALRM, timeout) + alarm(20) + cases, windows = [], [] + reason = None + events = None + try: + price = loads(checked("plan/PRICE.json"), object_pairs_hook=unique) + cases = price["cases"] + assert price["caps"] == {"late_cuts": 4124, "prototypes": 1, "runner_seconds": 20, + "typed_cuts": 8248, "windows": 4} + assert price["word_sha256"] == PINS["inputs/7334-WORD.json.gz"] + raw = decompress(checked("inputs/7334-WORD.json.gz")) + assert sha256(raw).hexdigest() == price["payload_sha256"] == WORD_PAYLOAD + word = loads(raw, object_pairs_hook=unique) + program = word["program"] + assert len(program) == 76466 and word["public"] == 1501 + assert len(cases) == 4 and sum(r["per_endpoint_typed_count"] for r in cases) == 4124 + roles = {role for row in cases for role in (row["key"][2], row["peer"])} + assert len(roles) == 8 and min(roles) >= 0 and max(roles) < word["public"] + initial, moves, scalar = trace(word, roles) + events = len(program) + for case in cases: + windows.append(classify(case, program, initial, moves, scalar)) + except TimeoutError as exc: + reason = str(exc) + finally: + alarm(0) + counts = Counter() + for row in windows: + counts.update({key: row[key] for key in ( + "early_excluded", "late_tested", "late_peer_at_c", + "late_peer_at_c_with_exactly_one_crossed_scalar" + )}) + counts["survivors"] += len(row["survivors"]) + print(dumps({ + "pins": PINS, "word_payload_sha256": WORD_PAYLOAD, "controls": controls(), + "completed_literal_events": events, "windows": windows, "counts": counts, + "unresolved_late_cut_intervals": [r["late_pre_event_cuts"] for r in cases[len(windows):]], + "unresolved_late_count": 4124 - counts["late_tested"], "timeout": reason, + }, indent=2, sort_keys=True)) + if reason: + raise SystemExit(124) + + +if __name__ == "__main__": + main() diff --git a/research/p104-fixed-peer-two-add-retime-bound/inputs/7334-WORD.json.gz b/research/p104-fixed-peer-two-add-retime-bound/inputs/7334-WORD.json.gz new file mode 100644 index 0000000000..73f4300719 Binary files /dev/null and b/research/p104-fixed-peer-two-add-retime-bound/inputs/7334-WORD.json.gz differ diff --git a/research/p104-fixed-peer-two-add-retime-bound/inputs/PR7362-SHA256.json b/research/p104-fixed-peer-two-add-retime-bound/inputs/PR7362-SHA256.json new file mode 100644 index 0000000000..b1486e0b5c --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/inputs/PR7362-SHA256.json @@ -0,0 +1,11 @@ +{ + "R92-COMPARE.json": "92bd567e3203a2cbc2e0c508bf921966c59ead267c1f373f7534a4a50cb208ac", + "R92-GEOMETRY.json": "e9f93f3271855012b2de705c70f186f78c31a369d28110e92c5f2ffadae209b3", + "R92-GUARDS.json": "c23e9c74b3479e4af6c452eeb73e000878148ec385560a0642433a1c5bac4a07", + "R92-PRICE.json": "05d7a5ebdd2eeedd6c8f534e8e2eeac22484daf9f387f4a6b88cc9eed22a6b8f", + "R92-REVERSE.json": "f8e56b109352e07dfb8203bdbe42a10cb94374246b4cd419421e4f52e2730c4a", + "R93-COMPARE.json": "8a1f52179e5d457aa729714b0b79577894c1e22ab74a8b2f700838f471ffceb1", + "R93-MODULAR.json": "01ad2a656e69699b80b56d63cdf82448e424cd1c6e67636d53c079a6f03f55a5", + "R93-PRICE.json": "c108a061c6c03306a99a6fbafe919208954a7479ae28fb8a8fbf45d9832e6144", + "R93-RATIONAL.json": "2800af56efe23f7420a12f0713a659cd4fa4a3fb7c58449749ef697097ccccbf" +} diff --git a/research/p104-fixed-peer-two-add-retime-bound/inputs/PR7365-SHA256.json b/research/p104-fixed-peer-two-add-retime-bound/inputs/PR7365-SHA256.json new file mode 100644 index 0000000000..2c2e083626 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/inputs/PR7365-SHA256.json @@ -0,0 +1,10 @@ +{ + "r100/independent/AGREEMENT.json": "ef797676d7550c65ca1780e5c7f8cc568f53f9c80ce764a659754c0cbcdc13e3", + "r100/independent/RESULT.json": "5462d132a6610dc8953332cadcad0c9b2096fa7db2bc131af3dbd80614b52d25", + "r100/lead/GEOMETRY.json": "075301daf545c8021800c36af19d05517e3c4136dac4e2114cb85204d0b31c64", + "r100/lead/PRICE.json": "7109125bbf60e3015c8c0ac7b10b24b7de61f358c1508d06604ebccd89ef6343", + "r101/independent/AGREEMENT.json": "9618ff9dc2282bee0068866879d900f881dc440234c5d12cb0dcf983c21eb6f3", + "r101/independent/RESULT.json": "526deef9465a563146100282ccb84bcc3d7613333354c48ec9452d97ff7d3d20", + "r101/lead/PRICE.json": "ac5ecb17f0e9f3c068423998b350a78c1a4769b6f61b50838be5f3e0d0b1a00c", + "r101/lead/SUPPORT.json": "b7700e618ce3c69cbe7544842f265e980f87903dea30121df118861d104b2c51" +} diff --git a/research/p104-fixed-peer-two-add-retime-bound/inputs/R100-GEOMETRY.json.gz b/research/p104-fixed-peer-two-add-retime-bound/inputs/R100-GEOMETRY.json.gz new file mode 100644 index 0000000000..fe9a6f6919 Binary files /dev/null and b/research/p104-fixed-peer-two-add-retime-bound/inputs/R100-GEOMETRY.json.gz differ diff --git a/research/p104-fixed-peer-two-add-retime-bound/inputs/R100-PRICE.json.gz b/research/p104-fixed-peer-two-add-retime-bound/inputs/R100-PRICE.json.gz new file mode 100644 index 0000000000..8b1113438c Binary files /dev/null and b/research/p104-fixed-peer-two-add-retime-bound/inputs/R100-PRICE.json.gz differ diff --git a/research/p104-fixed-peer-two-add-retime-bound/inputs/R92-PRICE.json.gz b/research/p104-fixed-peer-two-add-retime-bound/inputs/R92-PRICE.json.gz new file mode 100644 index 0000000000..5aabb0ff2e Binary files /dev/null and b/research/p104-fixed-peer-two-add-retime-bound/inputs/R92-PRICE.json.gz differ diff --git a/research/p104-fixed-peer-two-add-retime-bound/inputs/pricing.py b/research/p104-fixed-peer-two-add-retime-bound/inputs/pricing.py new file mode 100644 index 0000000000..40ec194017 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/inputs/pricing.py @@ -0,0 +1,82 @@ +"""Directed interval arithmetic and the retained signed BIT invoice.""" +from collections import Counter +from fractions import Fraction +from functools import cache + +TARGET = "10018846261809/2500000000000000" +SCALE = 10**49 + + +def rounded(x, upper): + scaled = SCALE*x + if upper: + return Fraction(-((-scaled.numerator) // scaled.denominator), SCALE) + return Fraction(scaled.numerator // scaled.denominator, SCALE) + + +@cache +def log_bounds(x): + z = (x-1)/(x+1) + terms = 60 + exact_partial = 2*sum(z**(2*i+1)/(2*i+1) for i in range(terms)) + tail = 2*z**(2*terms+1)/((2*terms+1)*(1-z*z)) + return rounded(exact_partial, False), rounded(exact_partial+tail, True) + + +@cache +def power_bounds(rank, k): + binary = 2**(rank.bit_length()-1) + shift = binary.bit_length()-1 + l2, u2 = log_bounds(Fraction(2)) + lo, hi = log_bounds(Fraction(rank, binary)) + lo, hi = k*(lo+shift*l2), k*(hi+shift*u2) + assert 0 <= lo <= hi < 1 + + def exponential(z, terms): + total = term = Fraction(1) + for i in range(1, terms+1): + term *= -z/i + total += term + return total + + return rounded(rank*exponential(hi, 35), False), rounded(rank*exponential(lo, 34), True) + + +def cost(hist, k): + lower = upper = Fraction(0) + for r, n in hist.items(): + a, b = (n*x for x in power_bounds(r, k)) + lower += min(a, b) + upper += max(a, b) + return lower, upper + + +def profile(invoice, native, word, ranks): + copies = invoice["native_calls"] + assert copies == len(invoice["native_instances"]) == 36 + assert {tuple((r["stage"], r["copy"])) for r in invoice["native_instances"]} == { + (stage, which) for stage in range(1, 19) for which in (0, 1) + } + assert all(r["ports"] == 111 for r in invoice["native_instances"]) + assert native == Counter({int(r): n for r, n in invoice["native_paid"].items()}) + assert sum(native.values()) == 2871 + caller_paid = {1: 444, **{r: 444 for r in range(7, 57, 7)}} + assert invoice["event_counts"]["QUERY"]*111 == caller_paid[1] + assert invoice["event_counts"]["IDLE_ONE"]*111 == 8*444 + full_paid = Counter({r: copies*n for r, n in native.items()}) + full_paid.update(caller_paid) + + helpers = Counter(ranks[word["final"][j]]-ranks[word["start"][j]] + for j in range(222, word["public"])) + assert helpers == Counter({int(r): n for r, n in invoice["native_helpers"].items()}) + caller_targets = {**{r: 444 for r in range(8, 65, 7)}, 127: 222} + full_targets = Counter({r: copies*n for r, n in helpers.items()}) + full_targets.update(caller_targets) + assert full_paid == Counter({int(r): n for r, n in invoice["paid"].items()}) + assert full_targets == Counter({int(r): n for r, n in invoice["targets"].items()}) + assert sum(full_paid.values()) == invoice["paid_jobs"] + assert sum(full_targets.values()) == invoice["productive_fields"] + signed = full_targets.copy() + signed.subtract(full_paid) + assert sum(r*n for r, n in signed.items()) == invoice["rank_surplus"] + return signed, copies diff --git a/research/p104-fixed-peer-two-add-retime-bound/receipts/AGREEMENT.json b/research/p104-fixed-peer-two-add-retime-bound/receipts/AGREEMENT.json new file mode 100644 index 0000000000..9122851bce --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/receipts/AGREEMENT.json @@ -0,0 +1,239 @@ +{ + "early_excluded": 4124, + "head": "aaeec8c0acf01e99a5f331ef363a698d9c084ace", + "late_chart_matches": 0, + "late_counts": { + "other blocked": 1760, + "other clean": 2364 + }, + "late_tested": 4124, + "matching_windows": 4, + "pins": { + "independent/RESULT.json": "f777aaa05cbcb9f6067d9b04220abe9aab01f8eaac5c407b078e0c295ca1f2b7", + "lead/RESULT.json": "1d7d7b122757d4345cfea3fa7d1c8525211939b913e900e9974fb93fc5b18e5e", + "plan/PRICE.json": "8226a2b9c9240455d6fcdaf3a38929e3336e89f35aed3f15b81564f07ed8387f" + }, + "survivors": 0, + "total_excluded": 8248, + "unresolved": 0, + "windows": [ + { + "charts": [ + 856, + 983, + 207 + ], + "early_excluded": 3282, + "first_scalar_blocker": [ + 43649, + [ + "ADD", + 1488, + 951, + "-1", + 197 + ] + ], + "key": [ + 41321, + 44605, + 1305 + ], + "late_intervals": [ + [ + 41324, + 43647, + 983, + true, + false + ], + [ + 43648, + 43649, + 197, + true, + false + ], + [ + 43650, + 44605, + 197, + false, + false + ] + ], + "peer": 1488, + "peer_moves": [ + [ + 43647, + [ + "MOVE", + 1488, + 983, + 197, + false + ] + ] + ], + "window": [ + 41324, + 44605 + ] + }, + { + "charts": [ + 854, + 984, + 207 + ], + "early_excluded": 759, + "first_scalar_blocker": [ + 43859, + [ + "ADD", + 1302, + 958, + "-1", + 203 + ] + ], + "key": [ + 43854, + 44615, + 1303 + ], + "late_intervals": [ + [ + 43857, + 43857, + 984, + true, + false + ], + [ + 43858, + 43859, + 203, + true, + false + ], + [ + 43860, + 44615, + 203, + false, + false + ] + ], + "peer": 1302, + "peer_moves": [ + [ + 43857, + [ + "MOVE", + 1302, + 984, + 203, + false + ] + ] + ], + "window": [ + 43857, + 44615 + ] + }, + { + "charts": [ + 856, + 983, + 207 + ], + "early_excluded": 51, + "first_scalar_blocker": [ + 44569, + [ + "ADD", + 187, + 1449, + "1", + 197 + ] + ], + "key": [ + 44564, + 44617, + 654 + ], + "late_intervals": [ + [ + 44567, + 44568, + 983, + true, + false + ], + [ + 44569, + 44569, + 197, + true, + false + ], + [ + 44570, + 44617, + 197, + false, + false + ] + ], + "peer": 1449, + "peer_moves": [ + [ + 44568, + [ + "MOVE", + 1449, + 983, + 197, + false + ] + ] + ], + "window": [ + 44567, + 44617 + ] + }, + { + "charts": [ + 854, + 984, + 207 + ], + "early_excluded": 32, + "first_scalar_blocker": null, + "key": [ + 44585, + 44619, + 652 + ], + "late_intervals": [ + [ + 44588, + 44619, + 984, + true, + false + ] + ], + "peer": 1450, + "peer_moves": [], + "window": [ + 44588, + 44619 + ] + } + ] +} diff --git a/research/p104-fixed-peer-two-add-retime-bound/receipts/SHA256.json b/research/p104-fixed-peer-two-add-retime-bound/receipts/SHA256.json new file mode 100644 index 0000000000..1a9014bf80 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/receipts/SHA256.json @@ -0,0 +1,6 @@ +{ + "AGREEMENT.json": "0d94d589c7b9fe02e25a56da858ecaf91b29d3d3ee194873408e6206291870f9", + "FORWARD.json": "1d7d7b122757d4345cfea3fa7d1c8525211939b913e900e9974fb93fc5b18e5e", + "PRICE.json": "8226a2b9c9240455d6fcdaf3a38929e3336e89f35aed3f15b81564f07ed8387f", + "REVERSE.json": "f777aaa05cbcb9f6067d9b04220abe9aab01f8eaac5c407b078e0c295ca1f2b7" +} diff --git a/research/p104-fixed-peer-two-add-retime-bound/replay.py b/research/p104-fixed-peer-two-add-retime-bound/replay.py new file mode 100644 index 0000000000..0ea161e1e4 --- /dev/null +++ b/research/p104-fixed-peer-two-add-retime-bound/replay.py @@ -0,0 +1,133 @@ +"""Replay the four exact fixed-peer two-ADD retiming windows.""" +from argparse import ArgumentParser +from fractions import Fraction +from gzip import decompress +from hashlib import sha1,sha256 +from json import dumps,loads +from pathlib import Path,PurePosixPath +from shutil import copyfile +from subprocess import run +import sys +from tempfile import TemporaryDirectory + +ROOT=Path(__file__).resolve().parent +HEAD="aaeec8c0acf01e99a5f331ef363a698d9c084ace" + + +def unique(items): + result=dict(items) + if len(result)!=len(items): + raise ValueError("duplicate JSON key") + return result + + +def decode(raw): + return loads(raw,object_pairs_hook=unique) + + +def digest(raw): + return sha256(raw).hexdigest() + + +def relative(name): + path=PurePosixPath(name) + if path.is_absolute() or path.as_posix()!=name or ".." in path.parts: + raise ValueError(f"invalid relative path: {name}") + return path + + +def authenticate(): + pins=decode((ROOT/"LOCAL-PINS.json").read_bytes()) + for name,expected in pins.items(): + if digest((ROOT/relative(name)).read_bytes())!=expected: + raise ValueError(f"changed package dependency: {name}") + provenance=decode((ROOT/"PROVENANCE.json").read_bytes()) + for name,record in provenance["files"].items(): + raw=(ROOT/relative(name)).read_bytes() + assert digest(raw)==record["sha256"]==pins[name] + assert sha1(f"blob {len(raw)}\0".encode()+raw).hexdigest()==record["git_blob"] + inputs={} + for name,record in provenance["derived_gzip"].items(): + raw=decompress((ROOT/"inputs"/f"{name}.json.gz").read_bytes()) + published=decode((ROOT/relative(record["receipt"])).read_bytes()) + assert digest(raw)==published[record["key"]] + inputs[name]=raw + return inputs + + +def command(script,*args,timeout=25,check=True): + response=run([sys.executable,"-I","-B",str(script),*map(str,args)],capture_output=True,timeout=timeout) + if check and response.returncode: + sys.stderr.write(response.stderr.decode(errors="replace")) + response.check_returncode() + return response + + +def replay(root,out): + inputs=authenticate() + expected=decode((ROOT/"receipts/SHA256.json").read_bytes()) + actual={} + for folder in ("plan/inputs","inputs","lead","independent/inputs"): + (root/folder).mkdir(parents=True) + for name,target in (("quote","plan/quote.py"),("walk","lead/walk.py"), + ("reverse_intervals","independent/reverse_intervals.py"), + ("reverse_routes","independent/inputs/reverse_routes.py"), + ("compare","independent/compare.py")): + copyfile(ROOT/"engines"/f"{name}.py",root/target) + for name,raw in inputs.items(): + (root/"plan/inputs"/f"{name}.json").write_bytes(raw) + copyfile(ROOT/"inputs/pricing.py",root/"plan/inputs/pricing.py") + copyfile(ROOT/"inputs/7334-WORD.json.gz",root/"inputs/7334-WORD.json.gz") + copyfile(root/"inputs/7334-WORD.json.gz",root/"independent/inputs/7334-WORD.json.gz") + + def record(name,result,target=None): + raw=result.stdout + assert digest(raw)==expected[name],("changed receipt",name) + actual[name]=raw + if target: + target.write_bytes(raw) + return decode(raw) + + price=record("PRICE.json",command(root/"plan/quote.py"),root/"plan/PRICE.json") + assert price["head"]==HEAD and price["paid_delta"]=={"1":-34,"2":17} + assert price["compatible_paid_delta"]=={"1":-136,"2":68} + assert (price["old_paid"],price["one_new_paid"],price["optimistic_all_four_paid"])==(110519,110502,110451) + assert price["productive"]==22461 and price["rank_surplus"]==1424 + assert Fraction(price["whole_upper"])==4*Fraction(price["one_upper"])<1 + assert Fraction(price["fixed_target_complete_upper"])<0 + copyfile(root/"plan/PRICE.json",root/"independent/inputs/PRICE.json") + lead=record("FORWARD.json",command(root/"lead/walk.py"),root/"lead/RESULT.json") + rev=record("REVERSE.json",command(root/"independent/reverse_intervals.py"),root/"independent/RESULT.json") + agreement=record("AGREEMENT.json",command(root/"independent/compare.py",root)) + assert actual["AGREEMENT.json"]==(ROOT/"receipts/AGREEMENT.json").read_bytes() + assert lead["completed_literal_events"]==rev["progress"]["events_replayed"]==76466 + assert agreement["total_excluded"]==8248 and agreement["survivors"]==agreement["unresolved"]==0 + assert agreement["late_counts"]=={"other blocked":1760,"other clean":2364} + + for file,script in (("independent/inputs/PRICE.json","independent/reverse_intervals.py"), + ("inputs/7334-WORD.json.gz","lead/walk.py")): + victim=root/file + victim.write_bytes(victim.read_bytes()+b"\n") + changed=command(root/script,check=False) + assert changed.returncode==1 and not changed.stdout + assert b"changed dependency" in changed.stderr and victim.name.encode() in changed.stderr + + assert set(actual)==set(expected) + if out is not None: + out.mkdir(parents=True) + for name,raw in actual.items(): + (out/relative(name)).write_bytes(raw) + print("PASS_FIXED_PEER_TWO_ADD_RETIME windows=4 early_excluded=4124 late_excluded=4124 chart_C=0 unresolved=0") + + +def main(): + assert __debug__ and sys.version_info[:2]==(3,12) + p=ArgumentParser(description=__doc__) + p.add_argument("--out",type=Path,help="new directory for the four regenerated receipts") + args=p.parse_args() + with TemporaryDirectory() as tmp: + replay(Path(tmp),args.out) + + +if __name__=="__main__": + main()