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-paid-endpoint-exchange-bound/LOCAL-PINS.json b/research/p104-fixed-paid-endpoint-exchange-bound/LOCAL-PINS.json new file mode 100644 index 0000000000..6a6ffbd249 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/LOCAL-PINS.json @@ -0,0 +1,18 @@ +{ + "PROVENANCE.json": "e11bec3be462569dd0f71a961159351dca71ee6a1fb0d6c877a74f268a466a21", + "engines/geometry.py": "e9f375d1f1be860e12205a68adf888f94586a5bfefdbc42541f5e91141fc1a56", + "engines/impulse.py": "c4cc05b30b027c2a5e31f0b3ab802b930e6666536a75bd1eb0213f82936ec3fc", + "engines/independent_reverse.py": "f91f4b7c6d57c2740fd0f1292e96a8552e46694f97a5b6eee7309ee9da2d65a0", + "engines/quote.py": "9d91d7d93f41a1099850870c93a16af83d1b5f8b928e04c5f69f3b7060f36fd9", + "engines/support.py": "c11ea95f3ce2ab5d783d7c79ef639bb8da8aae34804b11559c518fe8bbef363c", + "inputs/7334-WORD.json.gz": "4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a", + "inputs/ADMITTED.json": "c95300e9bca27e44a25c82d794f88cbf70757c142806b0e4c590ea29feb81a13", + "inputs/PR7362-SHA256.json": "2c90ca39b0f075cc4b3ec9e90c66fde473465e7bb50cf1db9a820d3a29556c0b", + "inputs/PR7370-SHA256.json": "ea5a3157a967c01b94fd57ca26f8ace1bfa2c6e8165271af917846eb14f9c0d9", + "inputs/R115-PRICE.json.gz": "1b4c154c531377a917b00cb147276a70e2a12dbef2f57b08f20495b220a5c99d", + "inputs/R92-PRICE.json.gz": "2274f514fb12f9ced0c24abe0c02a76c16cfee4c61f909e37a5ad89b07852371", + "inputs/bank_trace.py": "681fda5cc1d4b1ac07c62601ceb052f167a51fb73d28b23f454f8f50f6a8e27b", + "inputs/pricing.py": "f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182", + "inputs/reverse_span.py": "f8b48f2ed99d003e20f5b3fb2270603c4edbc3ce9a01484102816aa2710ce9ff", + "receipts/SHA256.json": "4c844c2f9d867d2ed907ad0061e1dba74a4d87d3d0394e91de15cf9c0530db58" +} diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/NOTICE b/research/p104-fixed-paid-endpoint-exchange-bound/NOTICE new file mode 100644 index 0000000000..3bb3acf2ee --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/NOTICE @@ -0,0 +1,3 @@ +Apache-2.0. + +#7334 and #7113 supply the exact native word and caller. #7370 and #7362 supply the endpoint cohorts and full bill, #7130 the cocharted basis precedent, #7124 the output rechart precedent, #7355 the reverse row engine, #7382 the exact bank trace, #7338 the comparator admission, and #7298 the directed tariff. OpenAI Codex and subagents materially assisted. diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/PROOF.md b/research/p104-fixed-paid-endpoint-exchange-bound/PROOF.md new file mode 100644 index 0000000000..0288ff57ff --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/PROOF.md @@ -0,0 +1,15 @@ +# Exact fixed-paid endpoint exchange obstruction + +Let i be a public helper in the exact 3→127 cohort and j be public helper 1481. Their original productive endpoints are 3→127 and 745→245. The charts form a strict chain by exact binary spans, with dimensions 0, 3, 8 and 9. The crossed endpoints 3→245 and 745→127 therefore have ranks 8 and 6. This preserves both positive productive fields and total rank. At one common chart, relabel both roles throughout the suffix and exchange their final labels. The two physical paid paths retain their original clock, rank, and chart map. Any compiler binding, ownership, precision, routing or tape change on a support survivor would still need complete verification. + +Let F be the normalized prefix and S the normalized suffix observations, including all public outputs and future COPY zero guards. Let E = SF be the original arbitrary-input endpoint. The admitted public helper outputs reproduce their corresponding normalized independent inputs, with all other public outputs independent of these helper coordinates. Let P transpose i,j and let d = e_i − e_j. Then (P−I)E is the rank-one map −ddᵀ on the public pair and zero in every guard row. + +For the bare suffix rename the changed map is P S P F with the public-output transposition applied after S. With an arbitrary cocharted two-role basis L inserted at the cut it is P S P L F, taking the identity action of output P on COPY guards. Equality to E therefore requires +```text +S (P L − I) F = (P − I) E. +``` +The operator P L−I has support on the two chosen roles. Every row of its composed response belongs to the rowspace of the two live prefix rows. Thus the normalized helper difference dᵀ must belong to that two-row span for any basis, even granting arbitrary rational coefficients and ignoring its synthesis cost. For L = I, the exact stronger identity also requires reciprocal nonzero prefix and suffix factors along d. The package first performs that narrower bare test and then the general prefix test. + +The exact separator is the arbitrary original input x1454 = 1 and x1481 = −2, with all other input coordinates zero. Both live bank rows evaluate zero at every tested cut, while dᵀ evaluates +2. This is sufficient to exclude the entire two-role basis family without testing suffixes. Each contiguous range has one exact coframe and no event incident on either selected role between its first and last pre-event cut. Consequently its prefix bank is constant. The continuation checks 5,080 raw cuts directly and the independent reverse verification checks every range. + +Across all 17 native copies this edit has ΔP = 0 and ΔT5 = −17, ΔT6 = +17, ΔT8 = +17, ΔT9 = −17. There are 110,519 paid positions and 22,461 productive positions with signed rank surplus 1,424. Directed exact arithmetic gives a gross upper below 0.026750025281436337 raw at the incumbent crossing. At most one pair is compatible because every pair shares role 1481. Even one additional raw paid rank-one position defeats the optimistic change. At the fixed moonshot target the complete margin upper is below −139.7375598591330167. No edit survives exact support and κ is unchanged. diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/PROVENANCE.json b/research/p104-fixed-paid-endpoint-exchange-bound/PROVENANCE.json new file mode 100644 index 0000000000..a59e64f97f --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/PROVENANCE.json @@ -0,0 +1,74 @@ +{ + "caller": { + "commit": "07a76c5e2738882c0cb322278e56f6cae3c9885d", + "scope": "Exact retained signed caller.", + "source": "https://github.com/CrocSwap/integer-mult-bounds/pull/7113" + }, + "derived_inputs": { + "inputs/R115-PRICE.json.gz": { + "compression": "gzip", + "key": "R115-PRICE.json", + "receipt": "inputs/PR7370-SHA256.json" + }, + "inputs/R92-PRICE.json.gz": { + "compression": "gzip", + "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/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/PR7362-SHA256.json": { + "commit": "5eec7ed633dcf9b9bbc95552aa653da296f863fb", + "git_blob": "b1486e0b5cfe4535f381ed26f7bce4aee21d8a43", + "path": "research/p104-rank-two-virtual-cut-bound/receipts/SHA256.json", + "sha256": "2c90ca39b0f075cc4b3ec9e90c66fde473465e7bb50cf1db9a820d3a29556c0b", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/5eec7ed633dcf9b9bbc95552aa653da296f863fb/research/p104-rank-two-virtual-cut-bound/receipts/SHA256.json" + }, + "inputs/PR7370-SHA256.json": { + "commit": "a41edc3ae92332a7a1f1ba90e9ea4901d0530185", + "git_blob": "695c7c46ca319b0a6b7ca6154a32021121b22e6a", + "path": "research/p104-rank-five-catalogue-bound/receipts/SHA256.json", + "sha256": "ea5a3157a967c01b94fd57ca26f8ace1bfa2c6e8165271af917846eb14f9c0d9", + "source": "https://github.com/CrocSwap/integer-mult-bounds/blob/a41edc3ae92332a7a1f1ba90e9ea4901d0530185/research/p104-rank-five-catalogue-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/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 + }, + "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-fixed-paid-endpoint-exchange-bound/README.md b/research/p104-fixed-paid-endpoint-exchange-bound/README.md new file mode 100644 index 0000000000..ec395005a3 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/README.md @@ -0,0 +1,21 @@ +# Fixed-paid productive endpoint exchange for role 1481 + +**NO VERIFIED GAIN.** Exact #7334 `aaeec8c0acf01e99a5f331ef363a698d9c084ace` and signed #7113 `07a76c5e2738882c0cb322278e56f6cae3c9885d` remain the comparable construction at κ = 0.00364665195644. + +Exchange the terminal charts of productive helper 1481, originally 745→245, and one existing 3→127 helper. The proposed edit changes target ranks 5 and 9 to 6 and 8 while retaining the paid rank stock. It relabels the two existing helper suffixes from one same-chart cut, allowing an arbitrary invertible linear change on the two cocharted public rows. + +The literal census covers all 615 partners and 76,466 events. Six partners have a shared chart at 20 exact ranges containing 20,455 pre-event cuts. All required helper-difference rows are outside their two-row prefix banks. One exact input, x1454 = 1 and x1481 = −2, separates the required row from both live rows. The continuation directly checks all 5,080 raw cuts in the 12 ranges left by the first bounded basis gate. An independent exact reverse replay checks all 20 prefix banks and the literal range conditions. Zero unresolved. + +Use CPython 3.12 with assertions from a clean checkout. + +```sh +python3.12 -I -B research/p104-fixed-paid-endpoint-exchange-bound/replay.py +``` + +The Git-free command authenticates the exact word, inherited rank-stock and rank-five manifests, reconstructs the directed quote and all geometry and support receipts, and rejects altered inputs. Add `--out fresh-directory` to retain the receipts. + +#7370 supplies the exact rank-five catalogue and #7362 the 3→127 cohort and full signed bill. #7130 supplies the cocharted basis precedent, #7124 the output rechart precedent, #7355 the exact reverse-row engine, #7382 the exact bank trace, #7338 the comparator admission and #7298 the directed tariff. #7334 and #7113 supply the current word and caller. OpenAI Codex and subagents materially assisted. + +## Open next questions + +At the same 20 archived ranges, grant exactly role 1454 where it is already cocharted and preserve its itinerary and dirty return. A single weighted forward pass checks the 20,455 raw cuts in at most 20 seconds. Test at most eight exact surviving three-row prefix banks, then at most four suffix responses with zero projection on the third role and all future guards. The charged basis, physical wrapper and tape would still need verification. Other endpoint pairs and paid-itinerary changes remain outside the tested family. diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/SOURCES.json b/research/p104-fixed-paid-endpoint-exchange-bound/SOURCES.json new file mode 100644 index 0000000000..e8c2f265cd --- /dev/null +++ b/research/p104-fixed-paid-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-fixed-paid-endpoint-exchange-bound/TASK.json b/research/p104-fixed-paid-endpoint-exchange-bound/TASK.json new file mode 100644 index 0000000000..9d8afabea6 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/TASK.json @@ -0,0 +1,117 @@ +{ + "actual_scope": "Exact #7334. Exchange the two productive terminal charts of role1481 and one of 615 exact 3\u2192127 helpers by suffix relabel at their existing common chart, optionally with any invertible same-chart linear two-role change.", + "ai_assistance": "OpenAI Codex and subagents materially assisted proof, implementation, independent verification and packaging.", + "author": "P104 fixed-paid endpoint exchange research", + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "bottleneck_link": "A fixed-paid exchange balances two productive target ranks and raises their signed moment only if the exact helper-difference row survives the arbitrary-input prefix.", + "budget_minutes": 10, + "evidence": "Six coframed partners and 20 representative ranges. Exact rational separators reject all prefix banks, including 5,080 direct raw-cut checks in the continuation.", + "open_questions": [ + { + "blocked_by": "All 20 two-role banks for role1481 are excluded.", + "first_step": "Freeze one different exact pair or one additional already available public role, reprice its complete fixed-paid endpoint exchange, and test the exact enlarged prefix span before any suffix.", + "question": "Can another endpoint pair or an additional cocharted independent role realize the helper-difference row?", + "why_it_matters": "A prefix witness is necessary to build an exact same-width native reassignment." + } + ], + "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": "Reassigns two productive terminals without modifying paid rank stock or introducing an independent split helper.", + "scope_status": "changed", + "stop_rule": "One 76,466-event coframe census, 16 bare and eight basis cases initially, then 12 remaining basis ranges and an independent full 20-range support check.", + "task_id": "p104-side-correction" +} diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/VERIFICATION.md b/research/p104-fixed-paid-endpoint-exchange-bound/VERIFICATION.md new file mode 100644 index 0000000000..f2de4cb34a --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/VERIFICATION.md @@ -0,0 +1,13 @@ +# Replay and coverage + +The first bound regenerates the entire complete 17-copy directed invoice before reading the word. It then exhausts the 615-partner geometry. Six partners and 20 exact coframe ranges remain, representing 20,455 raw cuts. The initial scientific gates check 16 bare representatives and the eight prioritized general-basis representatives. The continuation's frozen set difference finds the other 12 ranges and samples each of their 5,080 raw cuts directly. + +The reverse exact replay checks each of the 20 endpoint-difference bank tests and the literal interval alias conditions. The standard-library wrapper regenerates seven deterministic artifacts and checks three altered predecessor receipts before native decode. The frozen manifest keys all dependencies by relative path or distinct stage output name. This is a bounded source-specific exclusion with no supplier or full theorem claim. + +Run the registered command after placing the package in the repository. + +```sh +python3.12 -B scripts/research_package.py --package research/p104-fixed-paid-endpoint-exchange-bound +``` + +Local CPython 3.12 passed the empty-environment Git-free replay in 1.54 seconds and the registered replay in 2.12 seconds. A separately changed copy of the published #7370 manifest was rejected before native decoding. The exact scientific receipts remain deterministic. diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/VERIFY.json b/research/p104-fixed-paid-endpoint-exchange-bound/VERIFY.json new file mode 100644 index 0000000000..95f3a698b2 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/VERIFY.json @@ -0,0 +1,19 @@ +{ + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/replay.py" + ], + "checks": "Regenerate exact fixed-paid price, coframe ranges, bare/basis support, raw-cut continuation and independent prefix closure.", + "timeout_seconds": 100 + } + ], + "inputs": [], + "python": "3.12", + "requirements": [], + "schema_version": 1, + "status": "ready" +} diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/engines/geometry.py b/research/p104-fixed-paid-endpoint-exchange-bound/engines/geometry.py new file mode 100644 index 0000000000..76d43a6e96 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/engines/geometry.py @@ -0,0 +1,157 @@ +"""Exact coframe ranges for one fixed-paid endpoint exchange.""" +from argparse import ArgumentParser +from collections import defaultdict +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] +PRICE='7b0ccc8fd85240568aeddfc1e2c036ac05ab0ec6e8473522bd902a4adcc1e9eb' +WORD='4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a' +PAYLOAD='9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac' +HEAD='aaeec8c0acf01e99a5f331ef363a698d9c084ace' +CALLER='07a76c5e2738882c0cb322278e56f6cae3c9885d' +PIVOT,EVENTS,CASES,SECONDS=1481,76466,615,25 + + +def checked(root,name,expected): + raw=(root/name).read_bytes() + assert sha256(raw).hexdigest()==expected,('changed input',name) + return raw + + +def unique(items): + o=dict(items) + assert len(o)==len(items) + return o + + +def space(basis): + out={0} + for x in basis: + assert x not in out + out|={x^u for u in out} + return out + + +def ranges(program,state,pivot,roles,deadline,progress): + roles=set(roles) + charts=defaultdict(set) + for r in roles: + charts[state[r]].add(r) + opened={r:0 for r in charts[state[pivot]]} + result=[] + last_scalar={r:-1 for r in roles|{pivot}} + for t,e in enumerate(program): + progress['first_unvisited']=t + if t%128==0 and monotonic()>=deadline: + raise TimeoutError('literal geometry cap') + op,d,*a=e + touched={d,a[0]} if op in ('ADD','COPY') else {d} + impacted=set(opened) if pivot in touched else opened.keys()&touched + for r in impacted: + result.append([r,pivot,state[pivot],opened.pop(r),t]) + if op=='MOVE': + old,new,owned=a + assert state[d]==old + if d in roles: + charts[old].remove(d) + charts[new].add(d) + state[d]=new + elif op in ('INIT','CLEAR'): + assert not (touched & (roles|{pivot})) + state[d]=a[0] if op=='INIT' else None + else: + assert op in ('ADD','COPY','SCALE') + assert all(state[r]==a[-1] for r in touched) + for r in touched & last_scalar.keys(): + last_scalar[r]=t + affected=charts[state[pivot]] if pivot in touched else touched & charts[state[pivot]] + for r in affected: + assert r not in opened + opened[r]=t+1 + progress['events']+=1 + for r,lo in opened.items(): + result.append([r,pivot,state[pivot],lo,len(program)]) + progress['first_unvisited']=None + ordered=sorted(result) + assert all(a<=b for _,_,_,a,b in ordered) + return ordered,last_scalar + + +def priority(rows,last): + def key(row): + i,j,c,a,b=row + late=int(b>last[i])+int(b>last[j]) + return -late,-b,c,i,a + return sorted(rows,key=key) + + +def controls(): + events=[['MOVE',0,0,1,False],['SCALE',2,'-1',1],['ADD',0,1,'-2',1], + ['MOVE',0,1,2,False]] + result,last=ranges(events,[0,1,1],1,[0],float('inf'),{'events':0}) + assert result==[[0,1,1,1,2],[0,1,1,3,3]] + assert last=={0:2,1:2} + assert priority(result,last)[0]==[0,1,1,3,3] + return ['exact coframe begins after MOVE','disjoint scalar aliases','incident signed ADD splits the cut range'] + + +def main(): + assert __debug__ + parser=ArgumentParser(description=__doc__) + parser.add_argument('--root',type=Path,default=ROOT) + parser.add_argument('--controls-only',action='store_true') + args=parser.parse_args() + price=loads(checked(args.root,'lead/PRICE.json',PRICE),object_pairs_hook=unique) + assert price['head']==HEAD and price['caller']==CALLER and price['word_sha256']==WORD + assert price['one_fixed_helper']==PIVOT and price['whole_compatible_pair_cap']==1 + assert len(price['other_role_cohort'])==CASES + tests=controls() + if args.controls_only: + print(dumps(tests)) + return + def stop(*_): + raise TimeoutError('hard 25-second cap') + signal(SIGALRM,stop) + alarm(SECONDS) + deadline=monotonic()+SECONDS-1 + progress={'events':0} + out={'head':HEAD,'caller':CALLER,'price_sha256':PRICE,'word_sha256':WORD, + 'caps':{'events':EVENTS,'partners':CASES,'seconds':SECONDS},'controls':tests,'progress':progress} + try: + raw=decompress(checked(args.root,'inputs/7334-WORD.json.gz',WORD)) + assert sha256(raw).hexdigest()==PAYLOAD + w=loads(raw,object_pairs_hook=unique) + roles=price['other_role_cohort'] + assert len(w['program'])==EVENTS and w['public']==1501 and w['owned_fields']==68 + for role in roles: + assert (w['initial'][role],w['final'][role])==(3,127) + assert (w['initial'][PIVOT],w['final'][PIVOT])==(745,245) + fixed=set(w['live'])|{r+112 for r in w['live']}|set(w['hosted']['X2'])|set(w['hosted']['Y2']) + assert fixed.isdisjoint(set(roles)|{PIVOT}) + a,b,c,d=(space(w['frames'][z]) for z in (3,745,245,127)) + assert (len(a),len(b),len(c),len(d))==(1,8,256,512) and a=deadline: + raise TimeoutError('forward impulse cap') + for k in wants.get(t,()): + i,j,chart,_,_=ranges[k] + assert state[i]==state[j]==chart + success,target=evaluate(i,j,values[i],values[j],impulse) + assert target==q(price['target_response']) + if not success: + first_failure.setdefault(k,[t,str(values[i]),str(values[j])]) + observed[k]+=1 + op,d,*args=event + 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]=args[0] + values[d]=Q(0) + fresh.add(d) + elif op=='CLEAR': + assert d>=n and state[d]==args[0] + state[d]=None + values[d]=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,coeff,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(coeff)*values[s] + fresh.discard(d) + progress['events']+=1 + assert not fresh and state==word['final']+[None]*m + progress['first_unvisited']=None + assert observed==[b-a+1 for _,_,_,a,b in ranges] + return [{'range':r,'raw_cuts':observed[k],'first_nonzero':first_failure.get(k), + 'status':'prefix excluded' if k not in first_failure else 'unresolved'} for k,r in enumerate(ranges)] + + +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() + price=freeze(args.root) + tests=controls() + if args.freeze: + print(dumps(price,indent=2,sort_keys=True));return + stored=(args.root/'lead/KEYS.json').read_bytes() + assert stored==(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} + out={'head':HEAD,'caller':CALLER,'controls':tests,'progress':progress,'keys_sha256':sha256(stored).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),price,monotonic()+SECONDS-1,progress) + out|={'rows':rows,'raw_cuts':sum(r['raw_cuts'] for r in rows), + 'unresolved':[r['range'] for r in rows if r['status']=='unresolved']} + except TimeoutError as exc: + out|={'timeout':str(exc),'unresolved':price['ranges']} + finally: + alarm(0) + print(dumps(out,indent=2,sort_keys=True)) + if 'timeout' in out: + raise SystemExit(2) + + +if __name__=='__main__': + main() diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/engines/independent_reverse.py b/research/p104-fixed-paid-endpoint-exchange-bound/engines/independent_reverse.py new file mode 100644 index 0000000000..19592e7816 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/engines/independent_reverse.py @@ -0,0 +1,123 @@ +"""Rebuild all eligible cochart intervals and certify a backward separating pairing.""" +from argparse import ArgumentParser +from collections import defaultdict +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/PRICE.json": "7b0ccc8fd85240568aeddfc1e2c036ac05ab0ec6e8473522bd902a4adcc1e9eb", + "lead/GEOMETRY.json": "f2aa238ed8c49f0633c3837c6961bfba19482385851a5606578fa6368db79542", + "lead/BARE.json": "1f19c66e75543ff50f4537d99811812e96935e2c5d3e75ad3a6b23f8032b7869", + "lead/BASIS.json": "0688a6fe35487c3b79abaca48b583c6cad6a865bd7ae6b5addba846549807092", + "followup/KEYS.json": "b8566442ed245a2302d287c480cf95d647343ff4f0f141ba6072603fed5bdd6b", + "followup/RESULT.json": "9970468e3413e143eb9d328512b4e60aacb21672cbb5722ec0e5dd608fe58d14", +} +PIVOT, CAP, SECONDS = 1481, 20, 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 intervals(word, roles): + tape = word["program"] + charts = {role: word["initial"][role] for role in roles} + starts = dict.fromkeys(roles, 0) + stays = defaultdict(list) + for clock, (op, dest, *args) in enumerate(tape): + touched = {dest, args[0]} if op in ("ADD", "COPY") else {dest} + for role in touched & roles: + stays[role].append((starts[role], clock, charts[role])) + starts[role] = clock + 1 + if op == "MOVE": + assert args[0] == charts[role] and args[2] is False + charts[role] = args[1] + else: + assert op in ("ADD", "COPY", "SCALE") and args[-1] == charts[role] + for role in roles: + assert charts[role] == word["final"][role] + stays[role].append((starts[role], len(tape), charts[role])) + ranges = [] + for role in roles - {PIVOT}: + i = j = 0 + a, b = stays[role], stays[PIVOT] + while i < len(a) and j < len(b): + al, ar, ac = a[i] + bl, br, bc = b[j] + lo, hi = max(al, bl), min(ar, br) + if ac == bc and lo <= hi: + ranges.append((role, PIVOT, ac, lo, hi)) + i += ar <= br + j += br <= ar + return sorted(ranges) + + +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 = {path: (args.root / path).read_bytes() for path in PINS} + for path, payload in raw.items(): + if sha256(payload).hexdigest() != PINS[path]: + raise ValueError(f"changed dependency {path}") + saved = {path: loads(data, object_pairs_hook=unique) for path, data in raw.items() if path.endswith(".json")} + payload = decompress(raw["inputs/word.json.gz"]) + assert sha256(payload).hexdigest() == "9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac" + word = loads(payload, object_pairs_hook=unique) + price = saved["lead/PRICE.json"] + roles = set(price["other_role_cohort"]) + assert len(roles) == 615 and PIVOT not in roles + for role in roles: + assert (word["initial"][role], word["final"][role]) == (3, 127) + ranges = intervals(word, roles | {PIVOT}) + geometry = saved["lead/GEOMETRY.json"] + assert ranges == [tuple(row) for row in geometry["ranges"]] and len(ranges) == CAP + assert sum(hi - lo + 1 for _, _, _, lo, hi in ranges) == geometry["raw_cuts"] == 20455 + basis = {tuple(row["key"]) for row in saved["lead/BASIS.json"]["rows"]} + bare = {tuple(row["key"]) for row in saved["lead/BARE.json"]["rows"]} + supplement = {tuple(row) for row in saved["followup/KEYS.json"]["ranges"]} + closure = saved["followup/RESULT.json"] + assert not closure["unresolved"] and {tuple(row["range"]) for row in closure["rows"]} == supplement + assert len(basis) == 8 and len(bare) == 16 and basis <= bare and len(supplement) == 12 + assert {(*row[:3], row[-1]) for row in ranges if row not in supplement} == basis + algebra = run_path(str(args.root / "inputs/bank_trace.py")) + impulse = {1454: Fraction(1), PIVOT: Fraction(-2)} + rows = [] + for role, pivot, chart, lo, hi in ranges: + bank = algebra["trace"](word, hi, [role, pivot], deadline, True) + pairing = [algebra["dot"](bank[r], impulse) for r in (role, pivot)] + required = impulse.get(role, 0) - impulse[pivot] + assert pairing == [0, 0] and required == 2 + rows.append(dict(key=[role, pivot, chart, lo, hi], support=[len(bank[role]), len(bank[pivot])], + evaluations=list(map(str, pairing)), required=str(required))) + control = algebra["trace"](word, 0, [1454, PIVOT], deadline, True) + assert [algebra["dot"](control[r], impulse) for r in (1454, PIVOT)] == [1, -2] + assert algebra["dot"]({PIVOT: Fraction(-1)}, impulse) == 2 + alarm(0) + result = dict(head=price["head"], caller=price["caller"], scope=CAP, raw_cuts=geometry["raw_cuts"], + unresolved=0, pins=PINS, rows=rows, controls=["nonzero initial coordinates", "required direction"]) + args.output.write_text(dumps(result, sort_keys=True, indent=2) + "\n") + + +if __name__ == "__main__": + main() diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/engines/quote.py b/research/p104-fixed-paid-endpoint-exchange-bound/engines/quote.py new file mode 100644 index 0000000000..09dbd7c3b8 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/engines/quote.py @@ -0,0 +1,64 @@ +"""Predecode directed quote for one fixed-paid endpoint swap with role 1481.""" +from collections import Counter +from fractions import Fraction as Q +from hashlib import sha256 +from json import dumps,loads +from pathlib import Path +from runpy import run_path + +ROOT=Path(__file__).resolve().parent +PINS={ + 'inputs/R92-PRICE.json':'05d7a5ebdd2eeedd6c8f534e8e2eeac22484daf9f387f4a6b88cc9eed22a6b8f', + 'inputs/R115-PRICE.json':'c04adfb199f6dbc25806d6062562c7d707b8fda8ad73f3ed818901248d25ffbf', + 'inputs/pricing.py':'f4d0b6c9314b838d882d6d06020f24881c19a3fda97a7c00df87b1e920785182', +} + +def unique(items): + obj=dict(items) + if len(obj)!=len(items): + raise ValueError('duplicate key') + return obj + +def main(): + assert __debug__ + raw={} + for path,digest in PINS.items(): + data=(ROOT/path).read_bytes() + assert sha256(data).hexdigest()==digest,('changed input',path) + raw[path]=data + base,roles=(loads(raw[f'inputs/R{x}-PRICE.json'],object_pairs_hook=unique) for x in (92,115)) + assert base['head']==roles['head']=='aaeec8c0acf01e99a5f331ef363a698d9c084ace' + assert base['caller_head']==roles['caller']=='07a76c5e2738882c0cb322278e56f6cae3c9885d' + assert base['word_sha256']==roles['word_sha256'] + old=[g for g in roles['groups'] if g['roles']==[1481]] + assert old==[{'endpoints':[745,245],'roles':[1481]}] + cohort=base['endpoint_cohort'] + assert len(set(cohort))==615 and 1481 not in cohort + p,t=(Counter({int(r):n for r,n in base[k].items()}) for k in ('old_paid','old_targets')) + old_profile=t.copy() + old_profile.subtract(p) + delta={5:-17,6:17,8:17,9:-17} + changed=old_profile.copy() + changed.update(delta) + assert (sum(p.values()),sum(t.values()),sum(r*n for r,n in old_profile.items()))==(110519,22461,1424) + assert sum(delta.values())==sum(r*n for r,n in delta.items())==0 + cost=run_path(str(ROOT/'inputs/pricing.py'))['cost'] + quotes={} + for label in ('old_crossing_upper','probe','moonshot'): + k=Q(base[label]) + old_v,gain,new=(cost(x,k) for x in (old_profile,delta,changed)) + quotes[label]={'kappa':str(k),'old_margin':list(map(str,old_v)),'whole_one_gross':list(map(str,gain)), + 'complete_one_margin':list(map(str,new)), + 'complete_one_margin_with_extra_rank_one':list(map(str,(new[0]-1,new[1]-1)))} + assert Q(quotes['probe']['complete_one_margin'][0])>0 + assert Q(quotes['old_crossing_upper']['complete_one_margin_with_extra_rank_one'][1])<0 + assert Q(quotes['moonshot']['complete_one_margin'][1])<0 + print(dumps({'head':base['head'],'caller':base['caller_head'],'pins':PINS,'word_sha256':base['word_sha256'], + 'quote':quotes,'old_paid':p,'old_targets':t,'productive_delta':delta,'paid_delta':{}, + 'one_fixed_helper':1481,'old_endpoints':[[745,245],[3,127]],'new_endpoints':[[745,127],[3,245]], + 'old_rank_pair':[5,9],'new_rank_pair':[6,8],'other_role_cohort':cohort, + 'potential_unordered_pairs':615,'whole_compatible_pair_cap':1,'native_copies':17, + 'expected_chart_dimensions':{'3':0,'745':3,'245':8,'127':9}},indent=2,sort_keys=True)) + +if __name__=='__main__': + main() diff --git a/research/p104-fixed-paid-endpoint-exchange-bound/engines/support.py b/research/p104-fixed-paid-endpoint-exchange-bound/engines/support.py new file mode 100644 index 0000000000..a239c2eb48 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/engines/support.py @@ -0,0 +1,216 @@ +"""Exact signed two-sided support for a fixed-paid endpoint exchange.""" +from argparse import ArgumentParser +from collections import defaultdict +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 + +ROOT=Path(__file__).resolve().parents[1] +PINS={ + 'lead/PRICE.json':'7b0ccc8fd85240568aeddfc1e2c036ac05ab0ec6e8473522bd902a4adcc1e9eb', + 'lead/GEOMETRY.json':'f2aa238ed8c49f0633c3837c6961bfba19482385851a5606578fa6368db79542', + 'inputs/7334-WORD.json.gz':'4b9fd1187b34ed97c3ac0c760d73531735a5d0ebc5b4d4ab4377160b20d9bb2a', + 'inputs/reverse_span.py':'f8b48f2ed99d003e20f5b3fb2270603c4edbc3ce9a01484102816aa2710ce9ff', +} +PAYLOAD='9aa8d6b054ba7eb2289d052c1079b16be518d2f0fbfb244569fa18e3733acdac' +EVENTS=76466 + + +def checked(root,name,expected=None): + b=(root/name).read_bytes() + assert sha256(b).hexdigest()==(expected or PINS[name]),('changed input',name) + return b + + +def scaled(row,q): + return {j:v*q for j,v in row.items() if v*q} + + +def add(dst,src,q): + for j,v in src.items(): + x=dst.get(j,0)+q*v + if x: + dst[j]=x + else: + dst.pop(j,None) + + +def difference(left,right): + result=left.copy() + add(result,right,Q(-1)) + return result + + +def compact(row): + return {j:str(v) for j,v in sorted(row.items())} + + +def parallel(value,target): + if not value: + return None + first=next(iter(target)) + factor=value.get(first,0)/target[first] + return factor if factor and scaled(target,factor)==value else None + + +def as_int(row): + from math import lcm + den=lcm(*(x.denominator for x in row.values())) + return {j:x.numerator*(den//x.denominator) for j,x in row.items()},den + + +def prefix(word,keys,engine,deadline): + req=defaultdict(list) + for k,(i,j,_,t) in enumerate(keys): + req[t].extend([(i,2*k),(j,2*k+1)]) + raw=engine['transpose_prefix'](word,req,2*len(keys),deadline) + return [{j:Q(v,d) for j,v in row.items()} for row,d in raw] + + +def suffix(word,keys,deadline): + n,m=word['public'],word['owned_fields'] + values=[{} for _ in range(n+m)] + start=defaultdict(list) + for k,(i,j,_,t) in enumerate(keys): + start[t].extend([(i,2*k),(j,2*k+1)]) + guards=[{} for _ in range(2*len(keys))] + begin=min(start) + for t in range(begin,EVENTS): + if t%128==0 and monotonic()>=deadline: + raise TimeoutError('suffix sweep cap') + for r,k in start.get(t,()): + values[r][k]=Q(1) + op,d,*a=word['program'][t] + if op=='ADD': + add(values[d],values[a[0]],Q(a[1])) + elif op=='COPY': + for k,v in values[d].items(): + guards[k][n+t]=v + values[d]=scaled(values[a[0]],Q(a[1])) + elif op=='SCALE': + values[d]=scaled(values[d],Q(a[0])) + elif op in ('INIT','CLEAR'): + values[d]={} + else: + assert op=='MOVE' + for r,row in enumerate(values[:n]): + for k,v in row.items(): + guards[k][r]=v + return guards + + +def controls(engine): + d={0:Q(1),1:Q(-1)} + assert parallel(scaled(d,Q(-2,3)),d)==Q(-2,3) + assert parallel({0:Q(1),1:Q(-1),2:Q(1)},d) is None + assert engine['exact_span']([(0,({0:1},1)),(1,({1:1},1))],as_int(d))['coefficients']=={0:'1',1:'-1'} + assert engine['exact_span']([(0,({0:1,2:1},1)),(1,({1:1},1))],as_int(d))['status']!='exact_span' + return ['negative exact transposition scale','extra guard/output rejects','two-row basis witness','exterior axis blocks basis'] + + +def main(): + assert __debug__ + cli=ArgumentParser(description=__doc__) + cli.add_argument('mode',choices=('bare','basis','controls')) + cli.add_argument('--root',type=Path,default=ROOT) + cli.add_argument('--bare-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 + g=loads(checked(args.root,'lead/GEOMETRY.json'),object_pairs_hook=engine['unique']) + assert g['price_sha256']==PINS['lead/PRICE.json'] + checked(args.root,'lead/PRICE.json') + if args.mode=='bare': + keys=g['selected'] + limit,seconds=16,25 + else: + if args.bare_sha is None: + cli.error('--bare-sha is required for basis mode') + bare=loads(checked(args.root,'lead/BARE.json',args.bare_sha),object_pairs_hook=engine['unique']) + assert bare['pins']==PINS and bare['mode']=='bare' + keys=[r['key'] for r in sorted(bare['rows'],key=lambda r:(r['missing_own_input'],r['prefix_exterior_count'],-r['key'][3]))[:8]] + limit,seconds=8,35 + assert 0= 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-fixed-paid-endpoint-exchange-bound/inputs/pricing.py b/research/p104-fixed-paid-endpoint-exchange-bound/inputs/pricing.py new file mode 100644 index 0000000000..40ec194017 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-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-paid-endpoint-exchange-bound/inputs/reverse_span.py b/research/p104-fixed-paid-endpoint-exchange-bound/inputs/reverse_span.py new file mode 100644 index 0000000000..5efbeac87e --- /dev/null +++ b/research/p104-fixed-paid-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-fixed-paid-endpoint-exchange-bound/receipts/SHA256.json b/research/p104-fixed-paid-endpoint-exchange-bound/receipts/SHA256.json new file mode 100644 index 0000000000..134a2ee127 --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/receipts/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-fixed-paid-endpoint-exchange-bound/replay.py b/research/p104-fixed-paid-endpoint-exchange-bound/replay.py new file mode 100644 index 0000000000..b958e6f4ba --- /dev/null +++ b/research/p104-fixed-paid-endpoint-exchange-bound/replay.py @@ -0,0 +1,167 @@ +"""Reproduce the exact fixed-paid P104 two-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) + + r143,r146=root/'r143',root/'r146' + for name,raw in inherited.items(): + write(r143/'scout/inputs'/name,raw) + write(r143/'scout/inputs/pricing.py',source('inputs/pricing.py')) + for stage in (r143,r146): + write(stage/'inputs/7334-WORD.json.gz',source('inputs/7334-WORD.json.gz')) + write(r143/'inputs/reverse_span.py',source('inputs/reverse_span.py')) + write(r143/'scout/quote.py',source('engines/quote.py')) + for name in ('geometry.py','support.py'): + write(r143/'lead'/name,source('engines/'+name)) + write(r146/'lead/impulse.py',source('engines/impulse.py')) + + price=record('R143-PRICE.json',r143/'scout/quote.py') + write(r143/'lead/PRICE.json',outputs['R143-PRICE.json']) + g=record('R143-GEOMETRY.json',r143/'lead/geometry.py') + write(r143/'lead/GEOMETRY.json',outputs['R143-GEOMETRY.json']) + bare=record('R143-BARE.json',r143/'lead/support.py','bare') + write(r143/'lead/BARE.json',outputs['R143-BARE.json']) + basis=record('R143-BASIS.json',r143/'lead/support.py','basis','--bare-sha',expected['R143-BARE.json']) + write(r143/'lead/BASIS.json',outputs['R143-BASIS.json']) + + for name in ('PRICE','GEOMETRY','BASIS'): + write(r146/'inputs'/f'{name}.json',outputs[f'R143-{name}.json']) + keys=record('R146-KEYS.json',r146/'lead/impulse.py','--freeze') + write(r146/'lead/KEYS.json',outputs['R146-KEYS.json']) + close=record('R146-RESULT.json',r146/'lead/impulse.py') + + reverse=r143/'independent/reverse.py' + reverse_out=r143/'independent/RESULT.json' + write(reverse,source('engines/independent_reverse.py')) + for name in ('bank_trace.py','word.json.gz'): + actual='7334-WORD.json.gz' if name=='word.json.gz' else name + write(r143/'inputs'/name,source('inputs/'+actual)) + for name in ('KEYS','RESULT'): + write(r143/'followup'/f'{name}.json',outputs[f'R146-{name}.json']) + call(reverse,'--root',str(r143),'--output',str(reverse_out)) + data=reverse_out.read_bytes() + assert digest(data)==expected['INDEPENDENT.json'] + outputs['INDEPENDENT.json']=data + independent=decode(data) + assert independent['scope']==20 and independent['raw_cuts']==20455 and independent['unresolved']==0 + assert len(independent['rows'])==20 + assert all(r['evaluations']==['0','0'] and r['required']=='2' for r in independent['rows']) + assert [r['key'] for r in independent['rows']]==g['ranges'] + + + assert price['old_rank_pair']==[5,9] and price['new_rank_pair']==[6,8] + assert price['potential_unordered_pairs']==615 and price['whole_compatible_pair_cap']==1 + assert len(g['exact_pairs'])==6 and len(g['ranges'])==20 and g['raw_cuts']==20455 + assert len(bare['rows'])==16 and len(basis['rows'])==8 + assert all(r['decision']=='prefix excluded' for r in bare['rows']+basis['rows']) + assert all(r['prefix']['separating_covector']=={'1454':'1','1481':'-2'} for r in basis['rows']) + assert len(close['rows'])==len(keys['ranges'])==12 and close['raw_cuts']==5080 + 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']) + covered={tuple(r['key']) for r in basis['rows']}|{(*r[:3],r[-1]) for r in keys['ranges']} + assert covered=={(*r[:3],r[-1]) for r in g['ranges']} + + 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(r143/'lead/GEOMETRY.json',r143/'lead/support.py','bare') + rejected(r146/'inputs/BASIS.json',r146/'lead/impulse.py') + rejected(r143/'followup/KEYS.json',reverse,'--root',str(r143),'--output',str(reverse_out)) + assert set(outputs)==set(expected) + + if out is not None: + out.mkdir(parents=True) + for name,raw in outputs.items(): + write(out/name,raw) + print('PASS_P104_FIXED_PAID_ENDPOINT_EXCHANGE_BOUND partners=6 ranges=20 raw_cuts=20455 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()