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-10shortcut-child-tariff/INPUTS.json b/research/p104-10shortcut-child-tariff/INPUTS.json new file mode 100644 index 0000000000..a119f15fd6 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/INPUTS.json @@ -0,0 +1,137 @@ +{ + "files": { + "LICENSE": { + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "size": 11357, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/LICENSE" + }, + "RESULT.json": { + "sha256": "a674764a45ce4b974bfaaf80d17695b5a91590fa78e0008f4a2e2fc1bafed722", + "size": 21226 + }, + "source/domain/ASSEMBLY.json": { + "sha256": "fb712dd3ea6c929dec956bc8351271aec1297bf7e33c9f24ab6fd203c51ada3c", + "size": 2383 + }, + "source/domain/CONTRACTION-SCREEN.json": { + "sha256": "74791c2561cd37925d6b72c2b4e6696371583a34811ed0558827d240ac3f7029", + "size": 4251 + }, + "source/domain/PREIMAGE.json": { + "sha256": "112293072412fd884f8c5b75f8d0d1170dd2988acd8a9824e704a7ef0344e80d", + "size": 12495 + }, + "source/domain/SCREEN.json": { + "sha256": "cb0c087e9814d17af15fae513e739dc03b21a1c8978adc02f5ee541cdb2ae23c", + "size": 1410 + }, + "source/domain/assemble.py": { + "sha256": "3b5cba1405bbf43769e054a3a5008889433d29b46013e20b369bd66a47f69ae7", + "size": 9111 + }, + "source/domain/edits.py": { + "sha256": "36bc3940e87f60054668a14bacbe7b35611d3f530c3901ef35497a3f52a53e36", + "size": 15643 + }, + "source/peer8097/NOTICE.md": { + "git_blob": "2ba199f0d115fa8ab06652c0f8cd98728b4ba352", + "sha256": "ff2f77f937170cf4f708d46d170867cc5c517f602d4923b7ccb8ee2614792e52", + "size": 1933, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/NOTICE.md" + }, + "source/peer8097/PEER-SOURCE.json": { + "git_blob": "6f84b3aef4b8c5026e348d88700bc9401514ccab", + "sha256": "798c2e6394c258986484a116198cc542a6d2b4c1f289e5816de2cfecf5141c51", + "size": 11897, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/PEER-SOURCE.json" + }, + "source/peer8097/RESULT.json": { + "git_blob": "dbc05f63a5ec457258cdfa7f927b2e4696747aad", + "sha256": "f3ff96fb44169735871b27c1a22dd3f499e20a77401896fe53845f546aa1c9f5", + "size": 20939, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/RESULT.json" + }, + "source/peer8097/SETUP-28BIT.md": { + "git_blob": "7db268bd4842ff7388f8be8394334de0e232d44f", + "sha256": "1fb9a0897f42f5a2080793f4ee88eddc2e7e8dd3dd6c9806329dba82c3b8ae9e", + "size": 2948, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/SETUP-28BIT.md" + }, + "source/peer8097/check_cutoff.py": { + "git_blob": "9e36d10a94aa23df3248a7b2f21e2fd5cc88116a", + "sha256": "e0c7e48d4469844de861e1e4ba83eed9c5ccd58e5c9f480c4a6a82da7524e31c", + "size": 3338, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/check_cutoff.py" + }, + "source/peer8097/check_ordinary_floor.py": { + "git_blob": "63af07cb6e4648d6393f78a5852dbd9d39826091", + "sha256": "9c60d0ff1d88a0981625ae1c998638a8ad28d7ce0d3ffa01eba141cbbb99c3a8", + "size": 13319, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/check_ordinary_floor.py" + }, + "source/peer8097/check_stage_seam.py": { + "git_blob": "8aa3a1341c228da2de17f258de59e0821bfb1c7d", + "sha256": "f65ba986ef88b58c2e88fd43fdf40043d9b47f9952a83cb8277881776c914183", + "size": 16620, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/check_stage_seam.py" + }, + "source/peer8097/check_w5664.py": { + "git_blob": "8db5aa2c12e6c9deea9b32a03cef610fe72d79d2", + "sha256": "e2c878d9805c79859c134b2a0d545e13650320720197a40efa16a49a4decd4cf", + "size": 7034, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/check_w5664.py" + }, + "source/peer8097/peer8057.tar.gz": { + "git_blob": "3a3ded828f6bbf9b6e6a76ba255d480452f4d269", + "sha256": "0e0d559bdb15e7b647f88a2b5e27fcdc9e28e81d8f4145459876ba6da2e9314c", + "size": 2504361, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/peer8057.tar.gz" + }, + "source/peer8097/prepare.py": { + "git_blob": "969b8f875c2956f10055b17f3e2e81ee09bc5f6c", + "sha256": "5c54f3b1f1156eb4710038b1d0124d83db9241c80cb06c59abe1f0d132f8a55b", + "size": 55044, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/prepare.py" + }, + "source/peer8097/verify.py": { + "git_blob": "0d44eca8263398f82b2aea12689576270d111afc", + "sha256": "19820110cacbabd1436937092da5059fc641d7fafad0588fd5a901b5d7c817f4", + "size": 3959, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/verify.py" + }, + "source/peer8097/w5664_shortcut10.json.gz": { + "git_blob": "170aabc9f00f917e96f60c358884342ac3160953", + "sha256": "ce395afbf5c32be64c4e62389acaf9ce8cf8a9aaaa2fb7a278135bcfa0e635aa", + "size": 1316977, + "source": "e1c251401fe254909ac7e7bf2c773b921a1b6b57:research/p104-10shortcut-3type-28bit-6stage/w5664_shortcut10.json.gz" + }, + "source/transfer/ASSEMBLY.json": { + "sha256": "457ee19688c033bea32fcdb5a61a5cc5bd7bba97227799e09f220ae85e60d8df", + "size": 2278 + }, + "source/transfer/PREIMAGE.json": { + "sha256": "48fe570b5c7ad6099cd6e886df880a959a3fe6582cb18dad44509d26e2757291", + "size": 12476 + }, + "source/transfer/SCREEN.json": { + "sha256": "923a6c8fc1e15f6ca087b4de5d93e40bc49a889708f97e2dc7718f66053747ca", + "size": 1224 + }, + "source/transfer/assemble.py": { + "sha256": "397c8e1325d5cc7a4a62615dac591ad8f22f9447dafb84f06606e8de04f7e8c4", + "size": 8202 + }, + "source/transfer/check_installed.py": { + "sha256": "20a63ef679cce81cd52eba16c52b724325f2c19534e46d2ed23ea8e3e34f7c92", + "size": 7282 + }, + "source/transfer/edits.py": { + "sha256": "622ce1c5018e294d693c0621b0ccae70b88e0b923009ec81fa8420256205d290", + "size": 8754 + } + }, + "peer_head": "e1c251401fe254909ac7e7bf2c773b921a1b6b57", + "price_fixture_scope": "Observed Round 436 literal receipt", + "schema_version": 1 +} diff --git a/research/p104-10shortcut-child-tariff/LICENSE b/research/p104-10shortcut-child-tariff/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/p104-10shortcut-child-tariff/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/p104-10shortcut-child-tariff/NOTICE.md b/research/p104-10shortcut-child-tariff/NOTICE.md new file mode 100644 index 0000000000..a2d7b99fdc --- /dev/null +++ b/research/p104-10shortcut-child-tariff/NOTICE.md @@ -0,0 +1,13 @@ +# Attribution + +SYLforge’s [#8097 at e1c251401fe254909ac7e7bf2c773b921a1b6b57](https://github.com/CrocSwap/integer-mult-bounds/pull/8097) supplied the ten-shortcut w5664 graph, three-type Gaussian producer, periodic-integral ordinary and Gaussian pricing, and exact 28-bit six-stage resource profile. The #8097 discussion proposed combining an earlier lower tariff with its own full-reserve price. SYLforge also supplied the [#8052 K7 word](https://github.com/CrocSwap/integer-mult-bounds/pull/8052). floration supplied the [#8088 five-shortcut word and re-encodings](https://github.com/CrocSwap/integer-mult-bounds/pull/8088), [#8090 profile](https://github.com/CrocSwap/integer-mult-bounds/pull/8090), and [#8094 predecessor profile and verification patterns](https://github.com/CrocSwap/integer-mult-bounds/pull/8094). [Original #8097 source notice](https://github.com/SYLforge/integer-mult-bounds/blob/e1c251401fe254909ac7e7bf2c773b921a1b6b57/research/p104-10shortcut-3type-28bit-6stage/NOTICE.md) + +Ali Romman supplied the [#8042 exact quotient receiver and two-moment clock](https://github.com/CrocSwap/integer-mult-bounds/pull/8042), [#8055 serial setup](https://github.com/CrocSwap/integer-mult-bounds/pull/8055) and [#8057 signed construction and compiler](https://github.com/CrocSwap/integer-mult-bounds/commit/cbe847a953b971f9c6c5a0a6661e2008acd29086). The comparison retains [#8076’s charged recursive clock](https://github.com/CrocSwap/integer-mult-bounds/pull/8076) and the expanded installer argument of Clear1nsight’s [#8081](https://github.com/CrocSwap/integer-mult-bounds/pull/8081). The campaign’s [Round 414 route trace](https://github.com/ToikY/integer-mult-bounds/blob/a5d5fd437a3bb3d0a78f3fb4f6412db8a04bb42a/paired-768/r414/proof-first/README.md) and [#8095](https://github.com/CrocSwap/integer-mult-bounds/pull/8095) established the earlier charged tariff. [Round 431](https://github.com/ToikY/integer-mult-bounds/blob/e2fa80a0d48fbdacb2d6b3d4e3cf0d2787d9f541/paired-768/r431/INDEPENDENT.md) supplied the exact N≥9 tariff on [#8096’s earlier signed resource point](https://github.com/CrocSwap/integer-mult-bounds/pull/8096). [Round 435](https://github.com/ToikY/integer-mult-bounds/blob/347d6f8b40cd6dec90378b92d9cf38fee9ce2763/paired-768/r435/REPLAY.md) supplied the full-reserve transfer and reproducible price screen. Jerry Jiaheng Chen supplied the [#7257 separately scoped historical CI repair](https://github.com/CrocSwap/integer-mult-bounds/pull/7257). + +This package applies the exact child tariff to #8097’s construction under the same signed premises. It carries the old recursive clock budget and full ordinary reserve, and records the expanded ten-recipe setup charge. OpenAI Codex materially assisted source inspection, proof, implementation and verification. The #8097 submission discloses its own AI assistance. + +The installed-domain extension builds on [the preceding exact #8098 head](https://github.com/CrocSwap/integer-mult-bounds/commit/c7d4441c5e4406bff4a79576cf6b2ce0a596390a) and the [Round 438 fully directed comparison](https://github.com/ToikY/integer-mult-bounds/blob/ff72b51797253eb33db8f4e6a2db78cc8fee2a80/paired-768/r438/REPLAY.md). It uses the stronger installed domain of the same #8042 quotient function and replays the same signed callers. + +The charged-clock step reuses [#8076’s clock](https://github.com/CrocSwap/integer-mult-bounds/pull/8076) and [the original #8097 contraction](https://github.com/CrocSwap/integer-mult-bounds/commit/e1c251401fe254909ac7e7bf2c773b921a1b6b57) within the budget already paid by [the preceding exact #8098 head](https://github.com/CrocSwap/integer-mult-bounds/commit/517eac577bc12a1519eaf346a6816ad91bc9df90). [Round 441](https://github.com/ToikY/integer-mult-bounds/blob/603b8fce6c9024ba00b1d7cc7b3e8e69a6e49a8b/paired-768/r441/REPLAY.md) independently priced the combination. + +The retained archives and notices carry their original terms. [License](LICENSE) diff --git a/research/p104-10shortcut-child-tariff/PROOF.md b/research/p104-10shortcut-child-tariff/PROOF.md new file mode 100644 index 0000000000..580676626c --- /dev/null +++ b/research/p104-10shortcut-child-tariff/PROOF.md @@ -0,0 +1,42 @@ +# Exact installed-domain K7 tariff at the paid recursion budget + +The signed construction uses [#8097’s ten-shortcut profile](https://github.com/CrocSwap/integer-mult-bounds/commit/e1c251401fe254909ac7e7bf2c773b921a1b6b57) and the [independently reproduced #8098 head](https://github.com/CrocSwap/integer-mult-bounds/commit/517eac577bc12a1519eaf346a6816ad91bc9df90). The authenticated overlay reuses their signed word, caller, physical machine and charged resource profile. The installed edit changes the terminal selector with a matching price certificate. [First tariff assembly](source/transfer/ASSEMBLY.json) · [Current assembly](source/domain/ASSEMBLY.json) + +## Ordinary child term + +The direct receiver emits one same-stage child. The canonical equal-volume quotient receiver visits each low packet once with its true source width and high cardinality. The central call and the two calls for each corner exchange have the volume-weighted child mean from #8042. Both paths use child width `floor(c/N)` for parent width c. The invoice pays for source access, routing, stopped residuals and restoration. All eight priced ordinary stages use N=2^H with H≥3000. Hence the N≥16 proof domain applies wherever the tariff is used. [Physical receiver](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/RECEIVER.md) · [Two-moment clock](https://github.com/aliromman/integer-mult-bounds/blob/dfd25d553a843a946ca0b94130a5ff8943e98fdd/research/retimed-native-multiplier/ORDINARY-CLOCK.md) + +The quotient upper mean is `(21x+3)/(9x−1)`, x=3^(N−2), with derivative `−48/(9x−1)^2`. Its bound at N=16 is B=6277647/2690420, covering the direct case. Keep the existing paid geometric budget of 2401. For a nonnegative contraction ρ, `1/(1−ρ)≤2401` is equivalent to `ρ≤2400/2401`. Buying at `τ=B/(2400/2401)=5024210149/2152336000` uses that exact maximum. It gives the smallest tariff from adjusting contraction alone at this fixed B and budget. Both inherited width moments are bounded by the same contraction. At `s=t=1−(c_B−d/H)`, the paid moment inequality gives `τF(N)1 and 1->2) on w5664 and verify all owner returns." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "product" + ], + "timeout_seconds": 160, + "checks": "Execute the exact signed product and independently verify coefficients and restoration." + }, + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py", + "setup" + ], + "timeout_seconds": 100, + "checks": "Check canonical serial division, Bezout, fixed native setup tape bound, and full w5664 3-prime linear/transpose + 25M-term literal_grid + Clifford catalogue verification." + } + ] +} diff --git a/research/p104-10shortcut-child-tariff/source/domain/ASSEMBLY.json b/research/p104-10shortcut-child-tariff/source/domain/ASSEMBLY.json new file mode 100644 index 0000000000..42c51cfb82 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/domain/ASSEMBLY.json @@ -0,0 +1,39 @@ +{ + "baseline_terminal_kappa": "0.003900862349161", + "candidate_RESULT": "not generated", + "candidate_installation_sha256": "2d55f0269164878a6507c6756f2f27ccd6b3a6d2cbd5b3232e89ebc8e1b7a422", + "changed": { + "research/frequency-weighted-native-multiplier/SOURCES.json": { + "after": "fc44126841019e6356387c2f938171ce74f69a2f713d2cf3ce659c1a6f4f4fa4", + "before": "a8b3a3cf67ce3448b5115a75250532888a8e91fc9ce60d804d2b91889648180f" + }, + "research/frequency-weighted-native-multiplier/check_stage_seam.py": { + "after": "0e0d9f2986c77285f1704a97f0afd8a24b420c48816dc9680df1335c42678e62", + "before": "408e1980656a3a986343fd344ad4960f80e0bf04ee3ce9b62d94462ff86c430b" + }, + "research/frequency-weighted-native-multiplier/independent_price.py": { + "after": "f6d3533e7bae8f7cb7b4d6d8e70885ff79186398c72c96c100254c673f102cdc", + "before": "12481437e296aebf3172b1eeda8d73ff85b9e87cb7c221d4a618e726ec0319d7" + }, + "research/frequency-weighted-native-multiplier/receipt.py": { + "after": "7720731fde6b8c2793bcd64d58d5d00e60eb05a22197fde12a9da927d89999bd", + "before": "05976149ac2399da4da52a394c4f8b7e13af5c97f92419fd2bfc58cb96dfd880" + }, + "research/frequency-weighted-native-multiplier/runtime.patch": { + "after": "81223960c0d5cddbca86cba29498c436bb58ac9b327897e535b245fa7dacdd39", + "before": "b3702cbac622d3803b8761832c4c741f323c97fdd4c2f815011a418cbce55462" + } + }, + "comparator_result_sha256": "4ae4c5332a66396a63c0732c5fb1f797f96ebae0e397665de382a3ea31861fa6", + "comparison_head": "517eac577bc12a1519eaf346a6816ad91bc9df90", + "complete_preimage_manifest_sha256": "112293072412fd884f8c5b75f8d0d1170dd2988acd8a9824e704a7ef0344e80d", + "contraction_screen_sha256": "74791c2561cd37925d6b72c2b4e6696371583a34811ed0558827d240ac3f7029", + "installation_preimage_sha256": "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df", + "old_installation_sha256": "d34b860c4c35aeb302767216bf58dd9da627fe2b1b2b646fd70d6a544563648e", + "peer_head": "c7d4441c5e4406bff4a79576cf6b2ce0a596390a", + "preimage_terminal_kappa": "0.003900862339776", + "projected_delta": "7/1000000000000000", + "projected_terminal_kappa": "0.003900862349168", + "scope": "Frozen source assembly and exact selector image only. Installed replay unrun.", + "screen_sha256": "cb0c087e9814d17af15fae513e739dc03b21a1c8978adc02f5ee541cdb2ae23c" +} diff --git a/research/p104-10shortcut-child-tariff/source/domain/CONTRACTION-SCREEN.json b/research/p104-10shortcut-child-tariff/source/domain/CONTRACTION-SCREEN.json new file mode 100644 index 0000000000..94a4b0e6d2 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/domain/CONTRACTION-SCREEN.json @@ -0,0 +1,126 @@ +{ + "scope": "Fixed envelope and N>=16 mean, one contraction under the existing paid clock. No installed replay.", + "head": "517eac577bc12a1519eaf346a6816ad91bc9df90", + "inputs_sha256": { + "package/RESULT.json": "4ae4c5332a66396a63c0732c5fb1f797f96ebae0e397665de382a3ea31861fa6", + "peer8097/RESULT.json": "f3ff96fb44169735871b27c1a22dd3f499e20a77401896fe53845f546aa1c9f5", + "round440/SCREEN.json": "b198cd1e358dc3566ee9dccf2ef29468d095bc3cfefadbecd6cc461d8dd03619", + "handoff/r427/check_fringe.py": "63c8b56140e5f42f504ac98bb4824934e90e4a5ff26fa3065fe10c8e199640c4", + "handoff/r431/check_tariff.py": "f5e258d3fe81b2a220e4458846c733649dd607fa3d0b07d1c1d4ff2a57d3cc8f" + }, + "mean": "6277647/2690420", + "tariff": "5024210149/2152336000", + "ratio_to_r440_limiting_tariff": "171540889373/171541179200", + "contraction": "2400/2401", + "retained_recursive_budget": 2401, + "retained_reserve": "256/255", + "denominator": 1048576, + "directed_dyadic_prices": { + "112": { + "funded_tick": 1411927, + "rejected_preceding_tick": 1411926, + "charge": [ + 13203886006761410412486032117159922, + 13203886006761410412486032117160366 + ], + "probes": [ + { + "tick": 1411923, + "funded": false, + "allowance": [ + 13203857517521722318527493759801482, + 13203857517521722318527493759801544 + ] + }, + { + "tick": 1411924, + "funded": false, + "allowance": [ + 13203866245758527053189986150738812, + 13203866245758527053189986150738866 + ] + }, + { + "tick": 1411925, + "funded": false, + "allowance": [ + 13203874974001101474295885698039294, + 13203874974001101474295885698039354 + ] + }, + { + "tick": 1411926, + "funded": false, + "allowance": [ + 13203883702249445585659167938798640, + 13203883702249445585659167938798700 + ] + }, + { + "tick": 1411927, + "funded": true, + "allowance": [ + 13203892430503559391093810931291034, + 13203892430503559391093810931291102 + ] + } + ] + }, + "192": { + "funded_tick": 1411927, + "rejected_preceding_tick": 1411926, + "charge": [ + 15962518712822171179759995704910169327559595075934800526261, + 15962518712822171179759995704910169327559595075934800526596 + ], + "probes": [ + { + "tick": 1411923, + "funded": false, + "allowance": [ + 15962484271444731053148743269572769504568258107518470126018, + 15962484271444731053148743269572769504568258107518470126084 + ] + }, + { + "tick": 1411924, + "funded": false, + "allowance": [ + 15962494823235564007572658506004193526463275775350065683538, + 15962494823235564007572658506004193526463275775350065683600 + ] + }, + { + "tick": 1411925, + "funded": false, + "allowance": [ + 15962505375033372084909089153709437851383013238439620643406, + 15962505375033372084909089153709437851383013238439620643474 + ] + }, + { + "tick": 1411926, + "funded": false, + "allowance": [ + 15962515926838155289768848714862064427674321348363838681542, + 15962515926838155289768848714862064427674321348363838681612 + ] + }, + { + "tick": 1411927, + "funded": true, + "allowance": [ + 15962526478649913626762753739553416506158734518467241017010, + 15962526478649913626762753739553416506158734518467241017086 + ] + } + ] + } + }, + "old_ordinary_ceiling": "9369558483551777597159040818267598241/2401919792316416000000000000000000000000", + "new_ordinary_ceiling": "9369558483568853482515080195691818401/2401919792316416000000000000000000000000", + "gaussian_ceiling": "2138026285702664495874749/548090675200000000000000000", + "provisional_kappa": "243803896823/62500000000000", + "provisional_delta": "7/1000000000000000", + "complete_log2_C": 171810078109 +} diff --git a/research/p104-10shortcut-child-tariff/source/domain/PREIMAGE.json b/research/p104-10shortcut-child-tariff/source/domain/PREIMAGE.json new file mode 100644 index 0000000000..3661d4b9c1 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/domain/PREIMAGE.json @@ -0,0 +1,99 @@ +{ + "source_only": true, + "head": "c7d4441c5e4406bff4a79576cf6b2ce0a596390a", + "files": { + "TRANSFER-ASSEMBLY.json": "457ee19688c033bea32fcdb5a61a5cc5bd7bba97227799e09f220ae85e60d8df", + "research/frequency-weighted-native-multiplier/FINITE-LOSS.md": "12c6069437a0cbb61c80804f89f027ef9709c186e67d26fb0584ad6e71048052", + "research/frequency-weighted-native-multiplier/GaussianFiniteLoss.lean": "9d247f73d9da2748399b821612b30f20140783c08d761b6d4ef7d3c7c3d07064", + "research/frequency-weighted-native-multiplier/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/frequency-weighted-native-multiplier/MEASUREMENTS.json": "9ea26ae002146ae21291ecc0a6b224e5cccb9e3b5d199522558a645863da4f7b", + "research/frequency-weighted-native-multiplier/NOTICE.md": "02e69a1d57e2208ce49b3362a5672136887c1968d66de83a8f358e6d4a9353df", + "research/frequency-weighted-native-multiplier/PROOF.md": "4dbb38cdbe5b691edf4845fe8cf2a99be5d43455cc73199ab7e305abaa91acca", + "research/frequency-weighted-native-multiplier/README.md": "173313f895d9f810e5c32853ff383c8ee962e475dead35e5634047aa9c8a1453", + "research/frequency-weighted-native-multiplier/SOURCES.json": "a8b3a3cf67ce3448b5115a75250532888a8e91fc9ce60d804d2b91889648180f", + "research/frequency-weighted-native-multiplier/TASK.json": "9db85415d252a595907a8c1ddf8ce64acc5c0aa67dc8f6b4656139053bb40a52", + "research/frequency-weighted-native-multiplier/VERIFICATION.md": "58568a8f5e097a1d828aeff33ea33c63863c4b28dd1a87fd7dca9adebb5d6c1f", + "research/frequency-weighted-native-multiplier/VERIFY.json": "4f5506a41e62585e34c80c6838922d33b04d42e010fab310690f340a5be3721e", + "research/frequency-weighted-native-multiplier/WeightedNumerical.lean": "2017bae8064554efb13c564503d8f88c4615e9f733a74aa5eaf4047e5bd8af94", + "research/frequency-weighted-native-multiplier/bootstrap.py": "19a16cf5b6207995b1314ad9dc9b118a2654edff34af96e5d9ea1a2d5c0ee154", + "research/frequency-weighted-native-multiplier/check_calendar.py": "ecc3015664f45232689ca937570279ccc5d2487a236292fe7512ad0830f7166f", + "research/frequency-weighted-native-multiplier/check_cutoff.py": "e0c7e48d4469844de861e1e4ba83eed9c5ccd58e5c9f480c4a6a82da7524e31c", + "research/frequency-weighted-native-multiplier/check_exterior.py": "b29a035c90587fc75b4c8a4050a9eacf263929d201272dc635dd1d3d872e16b1", + "research/frequency-weighted-native-multiplier/check_lean.py": "32e49adef4502f193b5ded2cc4e7f8cea6a285283fda4db2152570a4b68098cb", + "research/frequency-weighted-native-multiplier/check_nested.py": "a976b80dfaf1360586f7d7b54350a6af857a36f580e1b506d0febf4ca85cf3eb", + "research/frequency-weighted-native-multiplier/check_ordinary_floor.py": "9c60d0ff1d88a0981625ae1c998638a8ad28d7ce0d3ffa01eba141cbbb99c3a8", + "research/frequency-weighted-native-multiplier/check_ownership.py": "dd1e4251f87b1b0a1d9a82cb1f47534bf97274db8160f8f2a01cf6f8f2aa960e", + "research/frequency-weighted-native-multiplier/check_placement.py": "96fb5ca7b5472ff02b3d8062673895aae517211080f72d386ec8e4a3892428a2", + "research/frequency-weighted-native-multiplier/check_raw.py": "ce6d00c50fcf816436555b882bc0e428e7cfea8be86a530e1c3d46862690914a", + "research/frequency-weighted-native-multiplier/check_stage_seam.py": "408e1980656a3a986343fd344ad4960f80e0bf04ee3ce9b62d94462ff86c430b", + "research/frequency-weighted-native-multiplier/check_w5664.py": "e2c878d9805c79859c134b2a0d545e13650320720197a40efa16a49a4decd4cf", + "research/frequency-weighted-native-multiplier/grades.py": "8f8ec926213345e38e73110c2230e0bf03a2282252e924b5710cf212ca514be7", + "research/frequency-weighted-native-multiplier/independent_price.py": "12481437e296aebf3172b1eeda8d73ff85b9e87cb7c221d4a618e726ec0319d7", + "research/frequency-weighted-native-multiplier/measure_setup.py": "cbfe019024fbeee428c415549db10180af69995078825b6341bc9021f3d08723", + "research/frequency-weighted-native-multiplier/portable/EVIDENCE.json": "3bfffdda94bbc6a14282399eca69b8619c96bd587c7957b3bdf854e03ef89427", + "research/frequency-weighted-native-multiplier/portable/NOTICE.md": "57d7e187fb48df97838976a7942e41dc381f00daeff7c2b5c392fb1a6f252517", + "research/frequency-weighted-native-multiplier/portable/README.md": "141d07df12c9e5352a8f83a03a033dd2c41cc5d0d6e0edb3532cab462536a974", + "research/frequency-weighted-native-multiplier/portable/STACK-LOCALITY.md": "0211732aaa6083a305e861f8172b581b0a9c98e10191d8432d546ee224c0bf5f", + "research/frequency-weighted-native-multiplier/portable/TRACE-CLOCK.md": "9f2b0d125cc35f91bb037363505d027331c79153211ea21de838405ae01a1a2a", + "research/frequency-weighted-native-multiplier/portable/bounded_wasi.py": "8232cc247e5910aab7a0fecb03426088c8f851fd93cbf8fb3587a4a5d7ee143d", + "research/frequency-weighted-native-multiplier/portable/compare.py": "7a906b2b871011595f66882897e7ff0fa79f007fc7887ae0c21b555d778a75c8", + "research/frequency-weighted-native-multiplier/portable/compiler_state.py": "11f371903410a53aa138bb9b9c49e9441393a34092fff922716a78b5521e1870", + "research/frequency-weighted-native-multiplier/portable/consumer.py": "411cc1052a70f7084de81f6f1e54636737d5e5155d0756b8271d5d82c268d3b3", + "research/frequency-weighted-native-multiplier/portable/fixed_directory.py": "c99e9945295b954b453f4995474db4ec8da9e7d8d6ba1a564456213d066e5904", + "research/frequency-weighted-native-multiplier/portable/guest_opcodes.py": "9b2a1b128939cc8d2ef379199c09af74c52ed4b696640fce01606c431d931db6", + "research/frequency-weighted-native-multiplier/portable/module_census.py": "f22218fc37012f5c14b17afba3e8b868fd7268f25931836397f00fbdd319f6f7", + "research/frequency-weighted-native-multiplier/portable/producer.py": "5a76b94efb0bb59a686255f212b532a0f44a586649befda07dbfc5fe86c6a8b7", + "research/frequency-weighted-native-multiplier/portable/record_census.py": "8132c345cfcc5e7d89494fa437685673273f878f2dc40e0187bf2b84eee17e08", + "research/frequency-weighted-native-multiplier/portable/run.py": "6a1e17556326107cac9e70f446b2a90c35e9b4b07bfb7c4b31e5fe9b081f7d9b", + "research/frequency-weighted-native-multiplier/portable/signed.py": "7620e713be7a8064c5b9f83e6573cfabab801b627f0133b7998fdb51a6bac449", + "research/frequency-weighted-native-multiplier/portable/source_image.py": "e354c3fb2bb05eb36dc2438d89c30b18b7973638c51af526d8e55b56803c73ba", + "research/frequency-weighted-native-multiplier/portable/tape_directory.py": "70bf289334f724cabf1cfa9e074199e6be93ef0aeba8193f279e5ef1336de97b", + "research/frequency-weighted-native-multiplier/portable/verify_receipt.py": "8b42d3c5f35d6810321eb000e10b4e5593d543296cc670c3c8847e7051c1b30c", + "research/frequency-weighted-native-multiplier/positive_debit.py": "2d79420b6bc76f7a96a0686c37fd53c5beb3383a1e6f8ff7c27e519a1d18b825", + "research/frequency-weighted-native-multiplier/receipt.py": "05976149ac2399da4da52a394c4f8b7e13af5c97f92419fd2bfc58cb96dfd880", + "research/frequency-weighted-native-multiplier/runtime.patch": "b3702cbac622d3803b8761832c4c741f323c97fdd4c2f815011a418cbce55462", + "research/frequency-weighted-native-multiplier/typed_raw.py": "41f7e353bbf1914ed54f2c1c087476561dbcc06d1d5d4c828e20ebdd5bd8f28d", + "research/frequency-weighted-native-multiplier/typed_transport.py": "8968c44fb4349b3e0404c7b47dafad51e373d0ad1d290323674d6ad3cfa04348", + "research/frequency-weighted-native-multiplier/verify.py": "050ce49cc5a9b2c8a75e4d8da65fa4bd621c2be7200dfa5f477c3ec259d0dcaf", + "research/frequency-weighted-native-multiplier/w5664_shortcut10.json.gz": "ce395afbf5c32be64c4e62389acaf9ce8cf8a9aaaa2fb7a278135bcfa0e635aa", + "research/tiered-native-multiplier/CLOCK.md": "cf71e4a3216df23eb7e4fa8a8d9de3735e6257c65ca8a60a5085d9f3c90c4ecb", + "research/tiered-native-multiplier/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/tiered-native-multiplier/MEASUREMENTS.json": "a1083bc55178baf0015ef83ef169f45df61475fcc648f487e03c852c871f1f00", + "research/tiered-native-multiplier/NOTICE.md": "c386dabe3fd1d046bddc782c671219757c7708e9ec874a6ede55b540edc95f2c", + "research/tiered-native-multiplier/NUMERICAL.md": "14b86724db522393981ed54b540a35f27bd952f3d95d6e6d14c5b23896811dc9", + "research/tiered-native-multiplier/README.md": "d2c214591f03313dece24592cde3193deffb2f1057b891604597b5e8c6d020ca", + "research/tiered-native-multiplier/RESULT.json": "661e16fcb533b69b97ad2dc91ab81bed79c44e7fdce01306ce573cb6f0ed7fa7", + "research/tiered-native-multiplier/SERIAL-SETUP.md": "1ca7e23ae113647605a31fa309c3bbdde2baf2d442913247fcda4c8a1eef7e7c", + "research/tiered-native-multiplier/SETUP.md": "6951a98f2f8a0bf73c8d60b16ebbbd66bf87584251df8afbefe4e3a0330bfbf3", + "research/tiered-native-multiplier/SOURCES.json": "7a10012734132909e99b0c6160d68d0b8647e1607d25679efb1f5315cf8e23de", + "research/tiered-native-multiplier/ScaledEntrance.lean": "e404be78622db98e9c3b490a15d0e9f002a2cf1eee9ecbd0a9516efbd0db5329", + "research/tiered-native-multiplier/TASK.json": "2cfe7fe1ea4ee8cd07d24048d45e543fdb8a6fa6585ebdc20b1ede55982a16a7", + "research/tiered-native-multiplier/TierCost.lean": "668a248d1060dd4fe97a0edb6652cb3782b8ba4ccc0d00ec73ee6ae253eb9945", + "research/tiered-native-multiplier/VERIFICATION.md": "343f4b2de9b49c1536d35046eee086898bad48023b7da528c5096ca43a1358d0", + "research/tiered-native-multiplier/VERIFY.json": "c684d5b86039809900c85fb0ce64d531db23c62e06bfcf210d6b2cc349480492", + "research/tiered-native-multiplier/bootstrap.py": "74ac8f1d3af21f86cda48a3d50084d6fa5faf84b44ec2e5929b587f40f5bcfd1", + "research/tiered-native-multiplier/check_gaussian.py": "383a3385bc9763d6eb557163ee62aa9ab999b0d98c719a004db87abfee063d24", + "research/tiered-native-multiplier/check_lean.py": "0d53ee2a814887bb53e78f62f2d2e73544641f2cac470dbecec93cdb0aa17203", + "research/tiered-native-multiplier/check_phase_passes.py": "6afd65da931476680d88cb54336ffedf531c3063af181f75403d511e24e83b94", + "research/tiered-native-multiplier/check_placement.py": "d416329ba75727d8f968abc39caded0c1a1fd3f21ffc9286274c5b834aab7154", + "research/tiered-native-multiplier/check_serial_setup.py": "11d1c3209cb523a360ab9abaefb3122507fdf5cb469169890fe2dac636812c47", + "research/tiered-native-multiplier/grades.py": "340684fdd5ca0e611836b0e7301f1c339282ba532bf9e3ec8055944d8981f3c8", + "research/tiered-native-multiplier/independent_price.py": "0b2ecc4a1845a2807782644b6b2675e2fcb194fcbb3ae80b50af9a775363e952", + "research/tiered-native-multiplier/installations.py": "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df", + "research/tiered-native-multiplier/measure_setup.py": "896349b654c7b8195e9823beaee080d2d30b3f72a562de90c7b6e2554bdd20bb", + "research/tiered-native-multiplier/receipt.py": "3d0219eb2262ea64ccf2dc8da4d2877e32c519c4670d99577703f8bfc236ba61", + "research/tiered-native-multiplier/runtime.patch": "6c93961841be2abc3629928074e2c7917d264e94187276fc88a33f922a3c62e4", + "research/tiered-native-multiplier/serial_setup.py": "61b5058d394ed74e943303e4bdbf21d58ccf5d8bb39fc4b02e97bc135d7bdbbc", + "research/tiered-native-multiplier/source/INSTALLER-NOTICE.md": "c6b1753ad6ebda2a2143b1a9efc80fadad6c1b27552c3ec8bc7bfdb431fb8eeb", + "research/tiered-native-multiplier/source/K7-NOTICE.md": "9c5ae9750012d305d917e625d14a33cc880e810e801e73364725bcdc24bffdb5", + "research/tiered-native-multiplier/source/K7-STACK-LEDGER.json": "a0c0d5b241e6861a5c49a287617e48fba56b09824f5ef4fcb7f03152edf37e8e", + "research/tiered-native-multiplier/source/activation.py": "6e7f89d40a4d10ecd40a50e5b96334dfc64db90841ece7e3ef12eeca5ee5093b", + "research/tiered-native-multiplier/source/check_binary_k7.py": "5eeb8f818725249cbabf215c323c3f8351b1c4ed3c127119341e6ed09f490dd6", + "research/tiered-native-multiplier/source/installer.tar.gz": "6696459e2e3552f802e7caaaf93dc86c9bb6b62ee38631702bff2e3a8a9a481a", + "research/tiered-native-multiplier/source/ordinary_clock.py": "91dcf0ef72dddbde998b80f3d8b30c8036de9ce97e06e2bbd9c4159bf292020d", + "research/tiered-native-multiplier/source/outer_budget.py": "ca4438db28a447ed5c43d87d43f0ac10a0cb2b4e183342ac93139d517b9d4d02", + "research/tiered-native-multiplier/source/outer_clock.py": "63363c3da673365f3ac5e1b7e318c6938005f1e9c9896799504cc598efbf96fa", + "research/tiered-native-multiplier/source/strong-bit-k7.json.gz": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "research/tiered-native-multiplier/verify.py": "d6cf9085e87743db14932a21cf895f8bd4d0f126b6c0bb7220d3255268dba39a" + } +} diff --git a/research/p104-10shortcut-child-tariff/source/domain/SCREEN.json b/research/p104-10shortcut-child-tariff/source/domain/SCREEN.json new file mode 100644 index 0000000000..2eb4294571 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/domain/SCREEN.json @@ -0,0 +1,48 @@ +{ + "scope": "Fixed #8098 ordinary envelope and two tariffs only. No signed or full candidate replay.", + "pinned_inputs": { + "package/verify.py": "7bc8a5a2a6b90bdacc3dd89c57f14b380eea3530a7eaaa5e1be7e10ae6f5d3b2", + "package/RESULT.json": "30f83c4820557c0ca3461928c5000da6a0c9fc4b98b3bf6539df8bdb18fb0d93", + "handoff/paired-768/r437/SCREEN.json": "17f22f78bb86bc7d6dd152179fbdea96f0c344b96402b8e4fb61049f2c19f51b" + }, + "tariffs": { + "peer8098": "10981863/4703998", + "N_at_least_16": "15009853977/6430103800" + }, + "kept_ordinary_reserve": "256/255", + "charged_geometric_budget": 2401, + "histogram_counts": [ + 18906, + 104652, + 24 + ], + "maximum_probes_per_precision": 32, + "debit_denominator": 1048576, + "directed_results": { + "112": { + "peer8098": { + "first_funded_tick": 1412105, + "preceding_tick_rejected": 1412104, + "bisection_probes": 14 + }, + "N_at_least_16": { + "first_funded_tick": 1411929, + "preceding_tick_rejected": 1411928, + "bisection_probes": 14 + } + }, + "192": { + "peer8098": { + "first_funded_tick": 1412105, + "preceding_tick_rejected": 1412104, + "bisection_probes": 14 + }, + "N_at_least_16": { + "first_funded_tick": 1411929, + "preceding_tick_rejected": 1411928, + "bisection_probes": 14 + } + } + }, + "distinct_funded_ticks": 176 +} diff --git a/research/p104-10shortcut-child-tariff/source/domain/assemble.py b/research/p104-10shortcut-child-tariff/source/domain/assemble.py new file mode 100644 index 0000000000..2e6785007b --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/domain/assemble.py @@ -0,0 +1,195 @@ +"""Apply the narrower quotient domain and paid contraction in one layer.""" + +from argparse import ArgumentParser +from hashlib import sha256 +import json +import os +from pathlib import Path +import runpy +import shutil +import signal +from subprocess import run +from tempfile import TemporaryDirectory + + +HERE = Path(__file__).resolve().parent +PEER = Path("research/frequency-weighted-native-multiplier") +INSTALLATIONS = Path("research/tiered-native-multiplier/installations.py") +PINS = { + "receipt.py": "05976149ac2399da4da52a394c4f8b7e13af5c97f92419fd2bfc58cb96dfd880", + "independent_price.py": "12481437e296aebf3172b1eeda8d73ff85b9e87cb7c221d4a618e726ec0319d7", + "check_stage_seam.py": "408e1980656a3a986343fd344ad4960f80e0bf04ee3ce9b62d94462ff86c430b", + "runtime.patch": "b3702cbac622d3803b8761832c4c741f323c97fdd4c2f815011a418cbce55462", + "SOURCES.json": "a8b3a3cf67ce3448b5115a75250532888a8e91fc9ce60d804d2b91889648180f" +} +PEER_HEAD = "c7d4441c5e4406bff4a79576cf6b2ce0a596390a" +FULL_PREIMAGE = "112293072412fd884f8c5b75f8d0d1170dd2988acd8a9824e704a7ef0344e80d" +SCREEN = "cb0c087e9814d17af15fae513e739dc03b21a1c8978adc02f5ee541cdb2ae23c" +PREIMAGE = "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df" +OLD_IMAGE = "d34b860c4c35aeb302767216bf58dd9da627fe2b1b2b646fd70d6a544563648e" +OLD_RATE = "0.003900862339776" +NEW_RATE = "0.003900862349168" +PREVIOUS_RATE = "0.003900862349161" +COMPARISON_HEAD = "517eac577bc12a1519eaf346a6816ad91bc9df90" +CONTRACTION_SCREEN = "74791c2561cd37925d6b72c2b4e6696371583a34811ed0558827d240ac3f7029" +SELECTOR = b'TERMINAL = Profile((8192, 63614, 1005821, 15903360, 251454111, 268435455), 52270, Q(".003900862339776"), Q(1, 256))' +NEW_SELECTOR = SELECTOR.replace(b".003900862339776", b".003900862349168") + + +def digest(data): + return sha256(data).hexdigest() + + +def authenticated(path, expected): + raw = path.read_bytes() + if digest(raw) != expected: + raise ValueError(f"Unexpected frozen source at {path.name!r}") + return raw + + +def unique_object(pairs): + result = {} + for key, value in pairs: + if key in result: + raise ValueError(f"Duplicate manifest key {key!r}") + result[key] = value + return result + + +def replace_unique(text, before, after): + if text.count(before) != 1: + raise ValueError(f"Expected one source anchor, found {text.count(before)}: {before[:110]!r}") + return text.replace(before, after, 1) + + +def image(preimage, patch, stage): + with TemporaryDirectory(prefix="selector-", dir=stage) as temporary: + target = Path(temporary) / "installations.py" + target.write_bytes(preimage) + env = dict(os.environ, GIT_CEILING_DIRECTORIES=str(stage)) + run(["git", "apply", "--no-index", "--include=installations.py", "--whitespace=nowarn", "-"], + cwd=temporary, env=env, input=patch, check=True, timeout=10) + return target.read_bytes() + + +def inventory(root): + files = {} + for path in root.rglob("*"): + if path.is_symlink(): + raise ValueError(f"A source symlink is outside this assembly: {path.relative_to(root)}") + if path.is_file(): + files[path.relative_to(root).as_posix()] = digest(path.read_bytes()) + return files + + +def materialize(frozen, stage): + prior = {name: authenticated(frozen / PEER / name, pin) for name, pin in PINS.items()} + frozen_manifest = json.loads(authenticated(HERE / "PREIMAGE.json", FULL_PREIMAGE), + object_pairs_hook=unique_object) + before = inventory(frozen) + if frozen_manifest["head"] != PEER_HEAD or not frozen_manifest["source_only"] or before != frozen_manifest["files"] or len(before) != 93: + raise ValueError("The complete materialized #8098 source inventory differs") + screen = json.loads(authenticated(HERE / "SCREEN.json", SCREEN), object_pairs_hook=unique_object) + for bits in ("112", "192"): + directed = screen["directed_results"][bits] + expected = {"peer8098": (1412105, 1412104), "N_at_least_16": (1411929, 1411928)} + for name, endpoints in expected.items(): + row = directed[name] + if (row["first_funded_tick"], row["preceding_tick_rejected"]) != endpoints: + raise ValueError("The exact directed tariff screen differs") + contraction = json.loads(authenticated(HERE / "CONTRACTION-SCREEN.json", CONTRACTION_SCREEN), + object_pairs_hook=unique_object) + if (contraction["head"], contraction["tariff"], contraction["contraction"]) != ( + COMPARISON_HEAD, "5024210149/2152336000", "2400/2401" + ): + raise ValueError("The exact paid contraction screen differs") + for bits in ("112", "192"): + row = contraction["directed_dyadic_prices"][bits] + if (row["funded_tick"], row["rejected_preceding_tick"]) != (1411927, 1411926): + raise ValueError("The exact paid contraction debit endpoints differ") + preimage = authenticated(frozen / INSTALLATIONS, PREIMAGE) + baseline = image(preimage, prior["runtime.patch"], stage) + if digest(baseline) != OLD_IMAGE: + raise ValueError("The installed #8098 image differs") + patch = replace_unique(prior["runtime.patch"], b"+" + SELECTOR, b"+" + NEW_SELECTOR) + installed = image(preimage, patch, stage) + if installed != replace_unique(baseline, SELECTOR, NEW_SELECTOR): + raise ValueError("The selector patch made another change to installations.py") + compile(installed, "installations.py", "exec") + manifest = json.loads(prior["SOURCES.json"], object_pairs_hook=unique_object) + pins = manifest["runtime_images"]["installations.py"] + if pins != {"before": PREIMAGE, "after": OLD_IMAGE} or manifest["local_sources"]["runtime.patch"] != PINS["runtime.patch"]: + raise ValueError("The old selector pins differ") + pins["after"] = digest(installed) + manifest["local_sources"]["runtime.patch"] = digest(patch) + edits = runpy.run_path(str(HERE / "edits.py"))["EDITS"] + changed = { + "runtime.patch": patch, + "SOURCES.json": (json.dumps(manifest, indent=2) + "\n").encode(), + } + for name, replacements in edits.items(): + text = prior[name].decode() + for anchor, replacement in replacements: + text = replace_unique(text, anchor, replacement) + compile(text, name, "exec") + changed[name] = text.encode() + if set(changed) != set(PINS): + raise ValueError("The changed source inventory differs") + old_result = (PEER / "RESULT.json").as_posix() + candidate = stage / "candidate" + shutil.copytree(frozen, candidate) + for name, raw in changed.items(): + (candidate / PEER / name).write_bytes(raw) + after = inventory(candidate) + differences = {p for p in before.keys() | after.keys() if before.get(p) != after.get(p)} + expected = {(PEER / name).as_posix() for name in changed} + if differences != expected or old_result in after: + raise ValueError("An unexpected source changed or a stale receipt survived") + return candidate, { + "scope": "Frozen source assembly and exact selector image only. Installed replay unrun.", + "peer_head": PEER_HEAD, + "complete_preimage_manifest_sha256": FULL_PREIMAGE, + "screen_sha256": SCREEN, + "preimage_terminal_kappa": OLD_RATE, + "comparison_head": COMPARISON_HEAD, + "baseline_terminal_kappa": PREVIOUS_RATE, + "contraction_screen_sha256": CONTRACTION_SCREEN, + "projected_terminal_kappa": NEW_RATE, + "projected_delta": "7/1000000000000000", + "comparator_result_sha256": contraction["inputs_sha256"]["package/RESULT.json"], + "installation_preimage_sha256": PREIMAGE, + "old_installation_sha256": OLD_IMAGE, + "candidate_installation_sha256": digest(installed), + "changed": {p: {"before": before[p], "after": after[p]} for p in sorted(expected)}, + "candidate_RESULT": "not generated", + } + + +def timeout(_signal, _frame): + raise TimeoutError("Source assembly reached the 45-second cap") + + +def main(): + if not __debug__: + raise RuntimeError("Run with assertions enabled") + parser = ArgumentParser(description=__doc__) + parser.add_argument("--frozen", type=Path, required=True) + parser.add_argument("--output", type=Path, required=True) + args = parser.parse_args() + frozen, output = args.frozen.resolve(), args.output.resolve() + if args.output.is_symlink() or output.exists() or output.is_relative_to(frozen): + parser.error("--output must be a fresh path outside the frozen tree") + signal.signal(signal.SIGALRM, timeout) + signal.alarm(45) + try: + with TemporaryDirectory(prefix="narrower-tariff-domain-source-", dir=output.parent) as temporary: + candidate, receipt = materialize(frozen, Path(temporary)) + (candidate / "DOMAIN-ASSEMBLY.json").write_text(json.dumps(receipt, indent=2, sort_keys=True) + "\n") + candidate.rename(output) + print(json.dumps(receipt, indent=2, sort_keys=True)) + finally: + signal.alarm(0) + + +if __name__ == "__main__": + main() diff --git a/research/p104-10shortcut-child-tariff/source/domain/edits.py b/research/p104-10shortcut-child-tariff/source/domain/edits.py new file mode 100644 index 0000000000..e01c583544 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/domain/edits.py @@ -0,0 +1,207 @@ +"""Single domain assembly including the paid contraction and predecessor controls.""" + +EDITS = {'receipt.py': (('ORDINARY_DEBIT = Q(1414569, 2**20)', 'ORDINARY_DEBIT = Q(1411929, 2**20)'), + ('CHILD_TARIFF = Q(10981863, 4703998)', 'CHILD_TARIFF = Q(15009853977, 6430103800)'), + ('def tape_factor_periodic(ambient, rate, lower, paid, cells):\n delta', + 'def tape_factor_periodic(ambient, rate, lower, paid, cells, *, upper=True):\n' + ' hi, lo = (1, 0) if upper else (0, 1)\n' + ' delta'), + ('Q(intervals(k, rate)[0], intervals(r, rate)[1])', + 'Q(intervals(k, rate)[lo], intervals(r, rate)[hi])'), + ('Q(intervals(r, t)[1], intervals(k, t)[0])', + 'Q(intervals(r, t)[hi], intervals(k, t)[lo])'), + ('Q(power_interval(lower * r, t)[0], power_interval(lower * k + 4 * r, t)[1])', + 'Q(power_interval(lower * r, t)[lo], power_interval(lower * k + 4 * r, t)[hi])'), + ('Q(power_interval(scale * lower, rate)[1], UNIT)', + 'Q(power_interval(scale * lower, rate)[hi], UNIT)'), + (' contraction = exact_mean / CHILD_TARIFF', + ' peer_tariff = Q(10981863, 4703998)\n' + ' peer_debit = Q(1414569, 2**20)\n' + ' assert exact_mean / peer_tariff == Q(2390, 2391)\n' + ' x16 = 3**14\n' + ' mean16 = Q(21*x16 + 3, 9*x16 - 1)\n' + ' assert 1 < mean16 == Q(6277647, 2690420) < exact_mean\n' + ' contraction = mean16 / CHILD_TARIFF'), + (' ratio = CHILD_TARIFF / old_tariff\n' + ' assert ratio == Q(5622713856, 5647149599)\n' + ' new_lo, new_hi = (2*Q(p, UNIT) for p in power_interval(2, ORDINARY_DEBIT - 1))\n' + ' # Keep the directed full old proof, including the entire 256/255 reserve.\n' + ' assert full_factor * CHILD_TARIFF < old_upper * ratio < new_lo <= new_hi < ' + 'old_upper', + ' ratio = peer_tariff / old_tariff\n' + ' assert ratio == Q(5622713856, 5647149599)\n' + ' peer_lo, peer_hi = (2*Q(p, UNIT) for p in power_interval(2, peer_debit - 1))\n' + ' assert full_factor*peer_tariff < old_upper*ratio < peer_lo <= peer_hi < old_upper\n' + ' assert CHILD_TARIFF / peer_tariff == Q(20592774709, 20595165100)\n' + ' factor_lower = tape_factor_periodic(134, BINARY_C, ORDINARY_FLOOR, paid, ' + 'bit_cells, upper=False)\n' + ' assert 0 < factor_lower <= full_factor\n' + ' for tariff, tick in ((peer_tariff, 1412105), (CHILD_TARIFF, 1411929)):\n' + ' allowance = 2*Q(power_interval(2, Q(tick, 2**20) - 1)[0], UNIT)\n' + ' rejected = 2*Q(power_interval(2, Q(tick - 1, 2**20) - 1)[1], UNIT)\n' + ' assert rejected < factor_lower*tariff <= full_factor*tariff < allowance'), + ('== (268290493, 52270)', '== (268290534, 52270)'), + (' previous = Q(".003900862325217")\n' + ' gain = TERMINAL.kappa - previous\n' + ' assert TERMINAL.kappa == Q(".003900862339776")\n' + ' assert previous - older == Q(5057431, 10**15)\n' + ' assert gain == Q(14559, 10**15)', + ' peer8097 = Q(".003900862325217")\n' + ' previous = Q(".003900862339776")\n' + ' repriced = Q(".003900862348535")\n' + ' gain = TERMINAL.kappa - previous\n' + ' assert TERMINAL.kappa == Q(".003900862349161")\n' + ' assert peer8097 - older == Q(5057431, 10**15)\n' + ' assert previous - peer8097 == Q(14559, 10**15)\n' + ' assert gain == Q(9385, 10**15) and TERMINAL.kappa - repriced == Q(626, 10**15)'), + (' assert previous < old_ceiling <= previous + Q(1, 10**15)\n' + ' assert old_ceiling < TERMINAL.kappa < new_ceiling < gaussian_ceiling\n' + ' assert new_ceiling <= TERMINAL.kappa + Q(1, 10**15)', + ' grid = Q(1, 10**15)\n' + ' actual_previous = guarded_ordinary(peer_debit)\n' + ' tight_previous = guarded_ordinary(Q(1412105, 2**20))\n' + ' assert peer8097 < old_ceiling <= peer8097 + grid\n' + ' assert previous < actual_previous <= previous + grid\n' + ' assert repriced < tight_previous <= repriced + grid\n' + ' assert old_ceiling < actual_previous < tight_previous < TERMINAL.kappa < ' + 'new_ceiling < gaussian_ceiling\n' + ' assert new_ceiling <= TERMINAL.kappa + grid'), + (' previous_rate=str(previous),', + ' previous_rate=str(previous),\n' + ' previous_repriced_rate=str(repriced),\n' + ' previous_8097_rate=str(peer8097),'), + ('ORDINARY_DEBIT = Q(1411929, 2**20)', 'ORDINARY_DEBIT = Q(1411927, 2**20)'), + ('CHILD_TARIFF = Q(15009853977, 6430103800)', 'CHILD_TARIFF = Q(5024210149, 2152336000)'), + (' contraction = mean16 / CHILD_TARIFF', + ' domain_tariff = Q(15009853977, 6430103800)\n' + ' assert mean16/domain_tariff == Q(2390, 2391) and 1/(1 - Q(2390, 2391)) == 2391\n' + ' contraction = mean16 / CHILD_TARIFF'), + ('assert contraction == Q(2390, 2391) and geometric_sum == 2391 < RECURSIVE_CLOCK_BUDGET', + 'assert contraction == Q(2400, 2401) and geometric_sum == RECURSIVE_CLOCK_BUDGET == ' + '2401'), + ('assert CHILD_TARIFF / peer_tariff == Q(20592774709, 20595165100)', + 'assert domain_tariff / peer_tariff == Q(20592774709, 20595165100)\n' + ' assert CHILD_TARIFF/domain_tariff == Q(573839, 573840)'), + ('for tariff, tick in ((peer_tariff, 1412105), (CHILD_TARIFF, 1411929)):', + 'for tariff, tick in ((peer_tariff, 1412105), (domain_tariff, 1411929), (CHILD_TARIFF, ' + '1411927)):'), + ('== (268290534, 52270)', '== (268290528, 52270)'), + (' gain = TERMINAL.kappa - previous\n' + ' assert TERMINAL.kappa == Q(".003900862349161")', + ' domain = Q(".003900862349161")\n' + ' gain = TERMINAL.kappa - domain\n' + ' assert TERMINAL.kappa == Q(".003900862349168")'), + (' assert gain == Q(9385, 10**15) and TERMINAL.kappa - repriced == Q(626, 10**15)', + ' assert domain - previous == Q(9385, 10**15) and domain - repriced == Q(626, ' + '10**15)\n' + ' assert gain == Q(7, 10**15)'), + (' assert old_ceiling < actual_previous < tight_previous < TERMINAL.kappa < ' + 'new_ceiling < gaussian_ceiling', + ' domain_ceiling = guarded_ordinary(Q(1411929, 2**20))\n' + ' assert domain < domain_ceiling <= domain + grid\n' + ' assert old_ceiling < actual_previous < tight_previous < domain_ceiling < ' + 'TERMINAL.kappa < new_ceiling < gaussian_ceiling'), + (' previous_rate=str(previous),', + ' previous_rate=str(domain),\n' + ' previous_8098_transfer_rate=str(previous),')), + 'independent_price.py': ((' print("PASS_EXACT_TARIFF_TRANSFER", str(tariff), "ord=1414569/2^20", ' + '"reserve=256/255", "clock_budget=2401", flush=True)', + ' print("PASS_EXACT_TARIFF_TRANSFER", str(tariff), "ord=1414569/2^20", ' + '"reserve=256/255", "clock_budget=2401", flush=True)\n' + '\n' + ' psi_hi = sum(bp[r] * sh * r * (powers(Q(k, r), c)[1] - 1) / c for (r, ' + 'k), sh in cells.items())\n' + ' num_lo = sum(\n' + ' bp[r] * sh * ((9*k - 8*r)*powers(Q(r, k), t)[0] - ' + 'r*powers(Q(lower*r, lower*k + 4*r), t)[1] + r*delta)\n' + ' for (r, k), sh in cells.items()\n' + ' )\n' + ' assert 0 < num_lo <= num and 0 < psi <= psi_hi\n' + ' fringe_lo = num_lo/(t*psi_hi)\n' + ' factor_lo = (lo/child_tariff)*(1 + fringe_lo/lower + delta)/(1 + ' + 'fringe/lower + delta)\n' + ' factor_hi = hi/child_tariff\n' + ' x16 = 3**14\n' + ' mean16 = Q(21*x16 + 3, 9*x16 - 1)\n' + ' tighter = mean16/contraction\n' + ' assert mean16 == Q(6277647, 2690420) and tighter == Q(15009853977, ' + '6430103800)\n' + ' for candidate, tick in ((tariff, 1412105), (tighter, 1411929)):\n' + ' accepted = 2*powers(2, Q(tick, 2**20) - 1)[0]\n' + ' rejected = 2*powers(2, Q(tick - 1, 2**20) - 1)[1]\n' + ' assert rejected < factor_lo*candidate <= factor_hi*candidate < ' + 'accepted\n' + ' print("PASS_MINIMAL_TARIFF_DEBITS", "1412105", "1411929", "2^20", ' + 'flush=True)'), + (' assert TERMINAL.kappa - peer_8097 == Q(14559, 10**15)', + ' peer_8098 = Q(".003900862339776")\n' + ' assert peer_8098 - peer_8097 == Q(14559, 10**15)\n' + ' assert TERMINAL.kappa - peer_8098 == Q(9385, 10**15)\n' + ' assert TERMINAL.kappa - Q(".003900862348535") == Q(626, 10**15)'), + (' for candidate, tick in ((tariff, 1412105), (tighter, 1411929)):', + ' paid_contraction = Q(2400, 2401)\n' + ' paid_tariff = mean16/paid_contraction\n' + ' assert paid_tariff == Q(5024210149, 2152336000) and 1/(1 - ' + 'paid_contraction) == 2401\n' + ' for candidate, tick in ((tariff, 1412105), (tighter, 1411929), ' + '(paid_tariff, 1411927)):'), + (' print("PASS_MINIMAL_TARIFF_DEBITS", "1412105", "1411929", "2^20", ' + 'flush=True)', + ' print("PASS_MINIMAL_TARIFF_DEBITS", "1412105", "1411929", "1411927", ' + '"2^20", flush=True)'), + (' assert TERMINAL.kappa - peer_8098 == Q(9385, 10**15)\n' + ' assert TERMINAL.kappa - Q(".003900862348535") == Q(626, 10**15)', + ' domain = Q(".003900862349161")\n' + ' assert domain - peer_8098 == Q(9385, 10**15)\n' + ' assert domain - Q(".003900862348535") == Q(626, 10**15)\n' + ' assert TERMINAL.kappa - domain == Q(7, 10**15)')), + 'check_stage_seam.py': ((' ORDINARY = Q(1414569, 2**20) # exact tariff, same L=1156 and full ' + '256/255 reserve', + ' PEER8098_ORDINARY = Q(1414569, 2**20)\n' + ' PEER8098_TIGHT = Q(1412105, 2**20)\n' + ' PEER8098_KAPPA = Q(".003900862339776")\n' + ' PEER8098_REPRICED = Q(".003900862348535")\n' + ' ORDINARY = Q(1411929, 2**20) # N>=16, same L=1156 and full 256/255 ' + 'reserve'), + ('assert TERMINAL.kappa == Q(".003900862339776")', + 'assert TERMINAL.kappa == Q(".003900862349161")'), + (' assert old_upper < paid < ordinary_upper(ranks) < ' + 'gaussian_upper(TERMINAL.complex_log)', + ' peer8098 = ordinary_upper(ranks, debit=PEER8098_ORDINARY)\n' + ' peer8098_tight = ordinary_upper(ranks, debit=PEER8098_TIGHT)\n' + ' assert PEER8098_KAPPA < peer8098 - 5*STOP <= PEER8098_KAPPA + Q(1, ' + '10**15)\n' + ' assert PEER8098_REPRICED < peer8098_tight - 5*STOP <= PEER8098_REPRICED + ' + 'Q(1, 10**15)\n' + ' assert old_upper < peer8098 < peer8098_tight < paid < ' + 'ordinary_upper(ranks) < gaussian_upper(TERMINAL.complex_log)'), + (' rejected(lambda: require_funding(ranks, TERMINAL.complex_log, ' + 'kappa=TERMINAL.kappa + Q(1, 10**15)),', + ' rejected(lambda: require_funding(ranks, TERMINAL.complex_log, ' + 'debit=PEER8098_ORDINARY),\n' + ' "peer8098-booked-debit-at-new-rate"),\n' + ' rejected(lambda: require_funding(ranks, TERMINAL.complex_log, ' + 'debit=PEER8098_TIGHT),\n' + ' "peer8098-tight-debit-at-new-rate"),\n' + ' rejected(lambda: require_funding(ranks, TERMINAL.complex_log, ' + 'kappa=TERMINAL.kappa + Q(1, 10**15)),'), + (' ORDINARY = Q(1411929, 2**20) # N>=16, same L=1156 and full 256/255 ' + 'reserve', + ' DOMAIN_ORDINARY = Q(1411929, 2**20)\n' + ' DOMAIN_KAPPA = Q(".003900862349161")\n' + ' ORDINARY = Q(1411927, 2**20) # N>=16, paid 2401 clock and full reserve'), + ('assert TERMINAL.kappa == Q(".003900862349161")', + 'assert TERMINAL.kappa == Q(".003900862349168")'), + (' assert old_upper < peer8098 < peer8098_tight < paid < ' + 'ordinary_upper(ranks) < gaussian_upper(TERMINAL.complex_log)', + ' domain = ordinary_upper(ranks, debit=DOMAIN_ORDINARY)\n' + ' assert DOMAIN_KAPPA < domain - 5*STOP <= DOMAIN_KAPPA + Q(1, 10**15)\n' + ' assert old_upper < peer8098 < peer8098_tight < domain < paid < ' + 'ordinary_upper(ranks) < gaussian_upper(TERMINAL.complex_log)'), + (' rejected(lambda: require_funding(ranks, TERMINAL.complex_log, ' + 'kappa=TERMINAL.kappa + Q(1, 10**15)),', + ' rejected(lambda: require_funding(ranks, TERMINAL.complex_log, ' + 'debit=DOMAIN_ORDINARY),\n' + ' "domain-only-debit-at-new-rate"),\n' + ' rejected(lambda: require_funding(ranks, TERMINAL.complex_log, ' + 'kappa=TERMINAL.kappa + Q(1, 10**15)),'))} diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/NOTICE.md b/research/p104-10shortcut-child-tariff/source/peer8097/NOTICE.md new file mode 100644 index 0000000000..2ba199f0d1 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/NOTICE.md @@ -0,0 +1,11 @@ +# Attribution + +Ali Romman supplied `#8042`, `#8057`, and `#8055`; SYLforge supplied `#8052` (the retimed K7 binary circuit setting `BINARY_C = 4391986206293/2^50`); ToikY supplied `#8073` (`0.003898219753506`) and `#8076` (`CHILD_TARIFF = 2401/1024`, contraction `2400/2401`, geometric sum `2401`, entry `+5` / terminal `+3m` clock bounds); Clear1nsight supplied `#8081`/`#8084` (`eta = 1/256` and the 25-bit setup lemma) and `#8089` (`kappa = 0.0039` with full `256/255` reserve); floration supplied `#8088` (`w5669_shortcut5.json.gz`, 5 chart-3 relay shortcuts and 44 chart-3 re-encodings), `#8090` (`0.003900826966095`), and `#8094` (27-bit 5-stage `0.003900857267786`). + +This package contributes: +1. Five additional exact pure-identity chart-3 relay shortcuts (`104494..104498`) unlocked by `#8088`'s 44 chart-3 re-encodings, producing `w5664_shortcut10.json.gz` (`5664` moves, independently checked via 3-prime forward/transpose equivalence, 25M-term exact `literal_grid`, and 2,961-pair Clifford catalogue). +2. A 3-type `(1, 2, 3)` Gaussian producer with weights `(1, 45, 2025)` on `w5664`, lifting `GAUSSIAN_C` to `17166573920/2^42 = 0.003903227006958` while keeping `actual_roles = 1,002,096 < 2^20` and `grade_count = 72 < 2^8`. +3. The exact periodic-integral `(1 - delta)` matched-interval suffix theorem paired with `#8076`'s `2401/1024` child tariff while **retaining the full `256/255` summation reserve** (no `#8082` reserve drop), lowering `ORDINARY_DEBIT` to `1418665/2^20` (`< #8094`'s `1420718/2^20`). +4. A 6-stage `eta = 1/256` schedule reaching the exact sharp `w = 2^38` fixed datum ceiling (`H < 2^28`, [`SETUP-28BIT.md`](SETUP-28BIT.md)), achieving conditional **`kappa = 0.003900862325217`** (`complete_log2_C = 171,810,078,109`, `G = 52,270`) and strictly beating `#8073`, `#8076`, `#8088`, `#8089`, `#8090`, and `#8094` at every matched tier. + +The archived source and notices retain their original license. diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/PEER-SOURCE.json b/research/p104-10shortcut-child-tariff/source/peer8097/PEER-SOURCE.json new file mode 100644 index 0000000000..6f84b3aef4 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/PEER-SOURCE.json @@ -0,0 +1,94 @@ +{ + "archive_sha256": "0e0d559bdb15e7b647f88a2b5e27fcdc9e28e81d8f4145459876ba6da2e9314c", + "files_sha256": { + "research/frequency-weighted-native-multiplier/FINITE-LOSS.md": "12c6069437a0cbb61c80804f89f027ef9709c186e67d26fb0584ad6e71048052", + "research/frequency-weighted-native-multiplier/GaussianFiniteLoss.lean": "9d247f73d9da2748399b821612b30f20140783c08d761b6d4ef7d3c7c3d07064", + "research/frequency-weighted-native-multiplier/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/frequency-weighted-native-multiplier/MEASUREMENTS.json": "9ea26ae002146ae21291ecc0a6b224e5cccb9e3b5d199522558a645863da4f7b", + "research/frequency-weighted-native-multiplier/NOTICE.md": "02e69a1d57e2208ce49b3362a5672136887c1968d66de83a8f358e6d4a9353df", + "research/frequency-weighted-native-multiplier/PROOF.md": "4dbb38cdbe5b691edf4845fe8cf2a99be5d43455cc73199ab7e305abaa91acca", + "research/frequency-weighted-native-multiplier/README.md": "173313f895d9f810e5c32853ff383c8ee962e475dead35e5634047aa9c8a1453", + "research/frequency-weighted-native-multiplier/RESULT.json": "2f4faa6648592f589df22a8a0a07ba6856d20786294a44a7776c7d6e0efa14a5", + "research/frequency-weighted-native-multiplier/SOURCES.json": "01d9e6b6b28cd174800cadfb59f4f064b3844575da297d82e16eb19a0d11c868", + "research/frequency-weighted-native-multiplier/TASK.json": "9db85415d252a595907a8c1ddf8ce64acc5c0aa67dc8f6b4656139053bb40a52", + "research/frequency-weighted-native-multiplier/VERIFICATION.md": "58568a8f5e097a1d828aeff33ea33c63863c4b28dd1a87fd7dca9adebb5d6c1f", + "research/frequency-weighted-native-multiplier/VERIFY.json": "4f5506a41e62585e34c80c6838922d33b04d42e010fab310690f340a5be3721e", + "research/frequency-weighted-native-multiplier/WeightedNumerical.lean": "2017bae8064554efb13c564503d8f88c4615e9f733a74aa5eaf4047e5bd8af94", + "research/frequency-weighted-native-multiplier/bootstrap.py": "a824c0ba9bb5efe5ad5b6c9b891b363b6d2ac31b0a57b9e27b68a6c2bca6f7ee", + "research/frequency-weighted-native-multiplier/check_calendar.py": "1c51b8bd75ef2d9d8847b2ebf88d7dbcc44d89954146c2bdede8854915392b8c", + "research/frequency-weighted-native-multiplier/check_exterior.py": "aee4fd29eb2fa021f806c987e0db23ecb7148e5dc846581f62d3ba39ed7ef725", + "research/frequency-weighted-native-multiplier/check_lean.py": "32e49adef4502f193b5ded2cc4e7f8cea6a285283fda4db2152570a4b68098cb", + "research/frequency-weighted-native-multiplier/check_nested.py": "9b2eaf387abbeeef43dd9bb31081ba73f3423e8233fb3446d61fce802a1c6b5b", + "research/frequency-weighted-native-multiplier/check_ownership.py": "a1fdaf5eaaa4215bc90051db48e17d0bf9cf7fe03f67a4d2bdf4e328f3c1a73a", + "research/frequency-weighted-native-multiplier/check_placement.py": "e4317a1eb36f692912ca4739364859118711620838705d8e33b1eabec32b0990", + "research/frequency-weighted-native-multiplier/check_raw.py": "d62d50279969bfecf23d2e14412949fa643394c1539ccb87db7dac5f79e2d97e", + "research/frequency-weighted-native-multiplier/grades.py": "8d2e3d14ac2149f985d7f6a75bf36182d7f68aadf8df6595fc0774224d4951ac", + "research/frequency-weighted-native-multiplier/independent_price.py": "448811cdb4a2bdefd4f736c2bad81c2a833bde634bcf65498e05267b5ee7ead0", + "research/frequency-weighted-native-multiplier/measure_setup.py": "cbfe019024fbeee428c415549db10180af69995078825b6341bc9021f3d08723", + "research/frequency-weighted-native-multiplier/portable/EVIDENCE.json": "3bfffdda94bbc6a14282399eca69b8619c96bd587c7957b3bdf854e03ef89427", + "research/frequency-weighted-native-multiplier/portable/NOTICE.md": "57d7e187fb48df97838976a7942e41dc381f00daeff7c2b5c392fb1a6f252517", + "research/frequency-weighted-native-multiplier/portable/README.md": "141d07df12c9e5352a8f83a03a033dd2c41cc5d0d6e0edb3532cab462536a974", + "research/frequency-weighted-native-multiplier/portable/STACK-LOCALITY.md": "0211732aaa6083a305e861f8172b581b0a9c98e10191d8432d546ee224c0bf5f", + "research/frequency-weighted-native-multiplier/portable/TRACE-CLOCK.md": "9f2b0d125cc35f91bb037363505d027331c79153211ea21de838405ae01a1a2a", + "research/frequency-weighted-native-multiplier/portable/bounded_wasi.py": "8232cc247e5910aab7a0fecb03426088c8f851fd93cbf8fb3587a4a5d7ee143d", + "research/frequency-weighted-native-multiplier/portable/compare.py": "7a906b2b871011595f66882897e7ff0fa79f007fc7887ae0c21b555d778a75c8", + "research/frequency-weighted-native-multiplier/portable/compiler_state.py": "11f371903410a53aa138bb9b9c49e9441393a34092fff922716a78b5521e1870", + "research/frequency-weighted-native-multiplier/portable/consumer.py": "411cc1052a70f7084de81f6f1e54636737d5e5155d0756b8271d5d82c268d3b3", + "research/frequency-weighted-native-multiplier/portable/fixed_directory.py": "c99e9945295b954b453f4995474db4ec8da9e7d8d6ba1a564456213d066e5904", + "research/frequency-weighted-native-multiplier/portable/guest_opcodes.py": "9b2a1b128939cc8d2ef379199c09af74c52ed4b696640fce01606c431d931db6", + "research/frequency-weighted-native-multiplier/portable/module_census.py": "f22218fc37012f5c14b17afba3e8b868fd7268f25931836397f00fbdd319f6f7", + "research/frequency-weighted-native-multiplier/portable/producer.py": "5a76b94efb0bb59a686255f212b532a0f44a586649befda07dbfc5fe86c6a8b7", + "research/frequency-weighted-native-multiplier/portable/record_census.py": "8132c345cfcc5e7d89494fa437685673273f878f2dc40e0187bf2b84eee17e08", + "research/frequency-weighted-native-multiplier/portable/run.py": "6a1e17556326107cac9e70f446b2a90c35e9b4b07bfb7c4b31e5fe9b081f7d9b", + "research/frequency-weighted-native-multiplier/portable/signed.py": "7620e713be7a8064c5b9f83e6573cfabab801b627f0133b7998fdb51a6bac449", + "research/frequency-weighted-native-multiplier/portable/source_image.py": "e354c3fb2bb05eb36dc2438d89c30b18b7973638c51af526d8e55b56803c73ba", + "research/frequency-weighted-native-multiplier/portable/tape_directory.py": "70bf289334f724cabf1cfa9e074199e6be93ef0aeba8193f279e5ef1336de97b", + "research/frequency-weighted-native-multiplier/portable/verify_receipt.py": "8b42d3c5f35d6810321eb000e10b4e5593d543296cc670c3c8847e7051c1b30c", + "research/frequency-weighted-native-multiplier/positive_debit.py": "7320b6a4ef1320d765e9b41a9b1e286db83a1d36d96f46bee0bef37974e8b8d9", + "research/frequency-weighted-native-multiplier/receipt.py": "82d921fdc33006e2d356d8bf78f3c85777722322d716be44b42bc763a04c8095", + "research/frequency-weighted-native-multiplier/runtime.patch": "f35d37cc1746b5a7ac137a3f6de6de887a24f3af578283c24a64c8a25ccc584b", + "research/frequency-weighted-native-multiplier/typed_raw.py": "0c268432c9d48798c17d927f2d900b5e69dfc6585166cd71f253913e389c3b47", + "research/frequency-weighted-native-multiplier/typed_transport.py": "b76b9ad3dc0dd91473026c079585f830387eaa3c34c25a7820ee5057d5cbf941", + "research/frequency-weighted-native-multiplier/verify.py": "07730c6859c26de43b8621bf7e5b778187f41ac17419569ada7c6e10f5d04d4a", + "research/tiered-native-multiplier/CLOCK.md": "cf71e4a3216df23eb7e4fa8a8d9de3735e6257c65ca8a60a5085d9f3c90c4ecb", + "research/tiered-native-multiplier/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/tiered-native-multiplier/MEASUREMENTS.json": "a1083bc55178baf0015ef83ef169f45df61475fcc648f487e03c852c871f1f00", + "research/tiered-native-multiplier/NOTICE.md": "c386dabe3fd1d046bddc782c671219757c7708e9ec874a6ede55b540edc95f2c", + "research/tiered-native-multiplier/NUMERICAL.md": "14b86724db522393981ed54b540a35f27bd952f3d95d6e6d14c5b23896811dc9", + "research/tiered-native-multiplier/README.md": "d2c214591f03313dece24592cde3193deffb2f1057b891604597b5e8c6d020ca", + "research/tiered-native-multiplier/RESULT.json": "661e16fcb533b69b97ad2dc91ab81bed79c44e7fdce01306ce573cb6f0ed7fa7", + "research/tiered-native-multiplier/SERIAL-SETUP.md": "1ca7e23ae113647605a31fa309c3bbdde2baf2d442913247fcda4c8a1eef7e7c", + "research/tiered-native-multiplier/SETUP.md": "6951a98f2f8a0bf73c8d60b16ebbbd66bf87584251df8afbefe4e3a0330bfbf3", + "research/tiered-native-multiplier/SOURCES.json": "7a10012734132909e99b0c6160d68d0b8647e1607d25679efb1f5315cf8e23de", + "research/tiered-native-multiplier/ScaledEntrance.lean": "e404be78622db98e9c3b490a15d0e9f002a2cf1eee9ecbd0a9516efbd0db5329", + "research/tiered-native-multiplier/TASK.json": "2cfe7fe1ea4ee8cd07d24048d45e543fdb8a6fa6585ebdc20b1ede55982a16a7", + "research/tiered-native-multiplier/TierCost.lean": "668a248d1060dd4fe97a0edb6652cb3782b8ba4ccc0d00ec73ee6ae253eb9945", + "research/tiered-native-multiplier/VERIFICATION.md": "343f4b2de9b49c1536d35046eee086898bad48023b7da528c5096ca43a1358d0", + "research/tiered-native-multiplier/VERIFY.json": "c684d5b86039809900c85fb0ce64d531db23c62e06bfcf210d6b2cc349480492", + "research/tiered-native-multiplier/bootstrap.py": "74ac8f1d3af21f86cda48a3d50084d6fa5faf84b44ec2e5929b587f40f5bcfd1", + "research/tiered-native-multiplier/check_gaussian.py": "383a3385bc9763d6eb557163ee62aa9ab999b0d98c719a004db87abfee063d24", + "research/tiered-native-multiplier/check_lean.py": "0d53ee2a814887bb53e78f62f2d2e73544641f2cac470dbecec93cdb0aa17203", + "research/tiered-native-multiplier/check_phase_passes.py": "6afd65da931476680d88cb54336ffedf531c3063af181f75403d511e24e83b94", + "research/tiered-native-multiplier/check_placement.py": "d416329ba75727d8f968abc39caded0c1a1fd3f21ffc9286274c5b834aab7154", + "research/tiered-native-multiplier/check_serial_setup.py": "11d1c3209cb523a360ab9abaefb3122507fdf5cb469169890fe2dac636812c47", + "research/tiered-native-multiplier/grades.py": "340684fdd5ca0e611836b0e7301f1c339282ba532bf9e3ec8055944d8981f3c8", + "research/tiered-native-multiplier/independent_price.py": "0b2ecc4a1845a2807782644b6b2675e2fcb194fcbb3ae80b50af9a775363e952", + "research/tiered-native-multiplier/installations.py": "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df", + "research/tiered-native-multiplier/measure_setup.py": "896349b654c7b8195e9823beaee080d2d30b3f72a562de90c7b6e2554bdd20bb", + "research/tiered-native-multiplier/receipt.py": "3d0219eb2262ea64ccf2dc8da4d2877e32c519c4670d99577703f8bfc236ba61", + "research/tiered-native-multiplier/runtime.patch": "6c93961841be2abc3629928074e2c7917d264e94187276fc88a33f922a3c62e4", + "research/tiered-native-multiplier/serial_setup.py": "61b5058d394ed74e943303e4bdbf21d58ccf5d8bb39fc4b02e97bc135d7bdbbc", + "research/tiered-native-multiplier/source/INSTALLER-NOTICE.md": "c6b1753ad6ebda2a2143b1a9efc80fadad6c1b27552c3ec8bc7bfdb431fb8eeb", + "research/tiered-native-multiplier/source/K7-NOTICE.md": "9c5ae9750012d305d917e625d14a33cc880e810e801e73364725bcdc24bffdb5", + "research/tiered-native-multiplier/source/K7-STACK-LEDGER.json": "a0c0d5b241e6861a5c49a287617e48fba56b09824f5ef4fcb7f03152edf37e8e", + "research/tiered-native-multiplier/source/activation.py": "6e7f89d40a4d10ecd40a50e5b96334dfc64db90841ece7e3ef12eeca5ee5093b", + "research/tiered-native-multiplier/source/check_binary_k7.py": "5eeb8f818725249cbabf215c323c3f8351b1c4ed3c127119341e6ed09f490dd6", + "research/tiered-native-multiplier/source/installer.tar.gz": "6696459e2e3552f802e7caaaf93dc86c9bb6b62ee38631702bff2e3a8a9a481a", + "research/tiered-native-multiplier/source/ordinary_clock.py": "91dcf0ef72dddbde998b80f3d8b30c8036de9ce97e06e2bbd9c4159bf292020d", + "research/tiered-native-multiplier/source/outer_budget.py": "ca4438db28a447ed5c43d87d43f0ac10a0cb2b4e183342ac93139d517b9d4d02", + "research/tiered-native-multiplier/source/outer_clock.py": "63363c3da673365f3ac5e1b7e318c6938005f1e9c9896799504cc598efbf96fa", + "research/tiered-native-multiplier/source/strong-bit-k7.json.gz": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "research/tiered-native-multiplier/verify.py": "d6cf9085e87743db14932a21cf895f8bd4d0f126b6c0bb7220d3255268dba39a" + }, + "head": "cbe847a953b971f9c6c5a0a6661e2008acd29086" +} diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/RESULT.json b/research/p104-10shortcut-child-tariff/source/peer8097/RESULT.json new file mode 100644 index 0000000000..dbc05f63a5 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/RESULT.json @@ -0,0 +1,185 @@ +{ + "gaussian": { + "trial": "536455435/137438953472", + "weights": [ + 1, + 45, + 2025 + ], + "scales": [ + 1, + 2, + 3 + ], + "real_targets": [ + 52608, + 52608, + 52608 + ], + "real_loans": [ + 282096, + 281088, + 281088 + ], + "weighted_targets": 108951168, + "weighted_loans": 582134256, + "directed_margin": "29461331379876606314997663827/489798159865062681782538947080269350378067", + "grade_cells": 71, + "typed_cells": 125, + "min_individual_share": "106310237435259142634643931099378330758233254195070506966459232428141528687797923/14638049576134022422218779954515769220776704330098489118891108212007093437789744125222112", + "raw_loss": "32401/262144", + "finite_loss": { + "debit": "32401/262144", + "lower_band": 1164, + "upper_divisor": 1724, + "upper_scale": 395658, + "weighted_target_axes": 4604078208, + "fringe": "7159912897642539128886144441165961183399933786769263707925841884841865801127269914659432617051802197027203215035429148878136703417089795138980632908846574483763552762051728457228869677010915856772507298026616575567521917354681769703525117032461609906033262107125456958619160251947706636458954311869321965095941300436000097481727879456106401018877199510182898674891183478685998112106945293520367408710561305463665954015311091141601783977470115380107643382072440768501158872015477448675606647210468879044551728540276584916271461526274360386172568542689255262288639525927880774002622642350810869704969486288010488037645910235459654751158190385111006763355805674152647904014046024053625816845899718885740373085566270325303426520157643523858615253905999371540579147740097378013902418515423691321675014899955901296551701807492893298070443051082654575711026516868573408223136492618891960157922494256793732010879387156304175470764620740746137644607325211153039162068018739703184773368355464971557135480880498104952224701092821061447183269723873399750369469751402984428797364276694736137911615679150638932641398704124435592747414012107575025649134813877361433434699276242050443831318021942266119222584416902386467317567995412207916544483972872494372998037066463234460078885270071033530413267547600609747631472324479523312424899632534221164307440471009303656592735673268272786402963638631073618902839945432205449411355069075476933416216172355569093143956507073669003449102565798520796819107699748292843750648120663529280048799037675088314591915495393971035133621789104864067555992747146908815974659553129185833931980202247572043788487115545182518485758841882439981875191566713003494819580669362988319087990119122499728114527582323320056460254923492043291337099547143315179991821522122244510507251809730879338992421630485696818317660462757879840121673317162662068980406606625238605975866153435448282885431166072420153540777252971693428175122179263072269426345354581981620781247346875685075856963114749678026903751185117742554782485116755064830630069801095197304533036323687573274908399685619019931987234528867955167427423290657179763685506793248135846130840303478324648094291760450857059652402403607862480703724602833606464638875149880122493624581672508628244178160218095434810736289526743106623685408082291617849712883865261265224208137066775159787159371286524531843278155052251379867497939921018958899162605723320800222084302436091305232285535774769817221758461404720005396958903465587435066850912790894323070748776286895625139288071385549472909195463333607764600244896445430217469989941338072098051123151455547766468951493623529589000528308054971074792103940689236755369473974031626565960561109881604527632238215093030021014584807879694665723428902621458036648829394074696956491874161853905855696771437491347014176992880160974243169538683310602647939305980457676380586368883680413473633417070827207072228070415525089177366813994810536753056874844034623341596935475757406987513268595877706407091075558504311055114388138111637014122902704604509448055515106348961865921916797472198142552500401144211490927704063028512303724854358875045202881029623569550650479900039165683898824201174449013548932758972649967478667468414368967765433482978256635860106250227358029608325580767340926141966967774788070309484275890697604486576265756639292207885468457466930370985998060934601745065913834450679448675663126352830178057712832441460191325057911026211747199184620749558610202452612860204749849551409952789549159161965011187613547107587639811768320/1571483403499111087068934429895764326180382574973304740076802468739967172309892246544495557819745277457018437668087950642498659828113233520546452704571064126413523604830098010111880713835349899380305329532834002124497913246052099241315475619778135892381584412571554957412873940972102228575121498169529134643364078576656622756742417323508393864355963632581246086332507113490106083582977481345663813813840683641619207082535053231469459603034317361290698470946428567356233568994214710972663431187434971939897563931682886834075855898112265285128518036998532040723454816453752848650142836439248657783141539421462681760779611263931053347165547163335971974599085622264432805778076361815487379061319004100109119443237754923305376508016736671335372270398599442206110388610835436293023801849154860973944885177755384444730750180271835927213877690375529643833945327600856069110357709226492019608805354211283538064323818827408001491041932494687761966356630752807090214305054083960078760342038198709186275647255463672439470364958978202222515571315878789843166170779537084474262527628057264382374304249100008396803903645986823872237478666034648711669348513230936379908231341884906557184817194413663162320089584912743518965337922707933323882371425468191149237793831058585260892459557513951433549624582517704140867721642187588437539731383981023634399049104083457257686201493672989906433336783726855696355721029423285695557625482229021729618990442923210809610499130568172926408763858656017679157678576328035469938485489631955978323020515852819923116211767548618694756918386490282874748388046933281467819042036516502696941071996053859615909372740278305864960377630228093957954151719395077971882501698499562419788453126267737893847503119051598976552962285149260464522695035332344700867005434660633087353418916126499120595504088187582455951324488051382707943560685575627943150849883352079631671570690683181536060735322762547279216391470416820461375220245250647787400085467834646149413344463768135480316276324804295100273143801052064067044422841231316843197473161924766877194393472134919297358404747983005547540250364979923968788363710294384611674581441703667625276415459059620081764124906418280890730713917640740833599265771609950382386293859597757795894371010587176762810479433919347179930758455318402334854878567219086670907246268670175378229731761672532364527222253898136727558032025495414054396263271877198923526524448158229529192866971675099520615644114321972893211886829213260646916912308248149548563359136113508366897308518695850341546449092338728472555660503834760791548988253646562147225551750174543973286126217530828581076892006933273608421352950047856809099585340745648992251652920291148488612525984590523741326494940185487366351917302436845152115458646774652943365105276474077841513776256722087703070058915140766548111966870547508381240603648582905285801232224354713968372002354781246954342315867196747823859572254462753808273605210722581932012037965940059269546952030266428114993414042683047449962982431350427155497128544547453135109141602747639627701278370131340244498652372361097124231402202645086499025254540418638124028969947731115529562658476119174788946190647278153887439134054609472829134904431550528119676972509409496673534641847543869075423129348268424271280657643218667479453805450061752803365198717577304182624739966250642653502766112473879276104638070840199837783305643919276584108648060916503456827507882063214962221006273887680282594196820854110468181948521960550723100715165571254343018220176242861218732642444751792023", + "psi_lower": "15971337143262961905896291018353644234718676134943015787979118740136043701432412796408773388125824238626055039301808136668629942209659285046768649119477066418062021644317814847374971132836477966853952216217202449846790651837692429334973176372294683926212639436194102141217217763167038857818374248981503229305064927906452230294556667341123902879208777676358518765471369215977701988561928331337339602267446722470474314375000341930003658108476413584146465626497499922130861577233125934743/2537711439152796198067638515832965139098715856300646499451174887361616181533529013789610303027512190421671474534260354766959155523701389252795959855538662529978176804162221798034676294812977334381469715682254134892878019749273132862711386276436171442619244078557343526624089755312537317762622056406134674093072004247411091863940227032923425506414242380671909878107205297471677027114454705461641962191311312767096079925533659381510109265364445406295228886263559428940549324800", + "upper_factor": "146830131726146074836229892229900416910023435266669544605387595880581790920163288425121971071957596263241457690801234318393582351135298506021969141225036918604425590898614656304828325425358788364960925925612650340316110545073183812234651847850949086300901719390286533464831839568333530747324328937636511588287961050060064384774018929974906044186588768119803752378825478865239617983361644800479965528593069316942928029668592870165276997355561742208163605403466981615092358136673924995982521651400767599405111645317369237534660309720830890066168556116248053255785142507875258457248023048149031357741145331132536115886787750958762514192659387214402753543158582697128073253456814765163668398964603133126507460390476684825189927078767626171443745903784207814753901461079690884685713176282932217712435711918868788199390710469083834723351904746064154453436849624965254989300386502235048824402018842847250698402896693103671452781868686449213828210723162345428227305506689428502401450790545290872663552041509953614681829233135495563930809342395894875668210664159130880921264357378705218377534522916782543023740086481329051607651740329844995728697827370044203742263273603335694081009968719624955495543312854552272041228500253991894945308213923184798766696233222607504732728578334506694888341483580016299169839621803752436612857434705504100483859451620866920384843450648790065315124972713206603904761105534859140731427454632583782721452358228249846716395241723826221219430558529554869670870514592852654085359462390000748611499755095513142461297421150879844401849677287223134118623618377968205868871807075778015434701097063187297789919439443514306058782125814768286409373845758360509746831305630613738195050554055571751697978413039016089831262446294400813735415156909986263693010306856390056250019151897317368342676473723085904097579974825428138308203397931337318621952236298548511999488967888140634619724872794413195686552533623448612272414407940159200054234938131678705700097486498840925851590699654890790941599235528006938975754073517427436784142824137578005620352026916647258643390658422074781648832437231952000119098519346621680779882656411729525613219249220634894124313779040435097955884362722420145579998592343537630504609523534082934516334142491505377760358099625923814877620848891106515878537826597171511638115664225299423986104394029666083344097020119036920288455961689728749163433168617716240016493861154033663867562305177256035004933633659136740459975240427757450024435437874164246051773570748052540392612218807139212169262738458869210106076379534024514061191719477473136651496748814578795011023213961615235540051275444096943413045739189245269577128556867005197663372158591732674370466336553774819906373537772842682355101831149551448774077698227107505246959525088896081846299407345935387889890803452117035915030041329656416322225313187222082773939992310640521163475278487504821366970945748364682999064885722036444741844544331562236050037180345472680486629206850094192623123195402826570697561285162328100830592112250848059004709852189028577420613490923586840730291522913368139073376932569856986380841946203571436152575184831778975435100942059280096063132098288512963382942438909251211986656661088263562679113011752796406540631143344921116839858974277807407043366756920871840417129671951664150700630730097115179155836441602273329111088351418850004584706996044247074201237440409984453916207775536158134135112016727780069466669368483039953314350366371233467531052835319508708314683403396121360511385306389343844838800048305361005420763891091172202429889298205878891677316587340208703059395467353237452735157505704426186468418176125529742794335873466338829617501199918184882347653483559124992/134774588339916040504046570917852183611815443935491775090175187203194520831162047902888717549216354292852288817825168047614178532510064431722385751003797821659375529355870723409543669494349379526865955868732617835565118532605409159418377243152377553350714387418617242906506937032232985071183081406180270388579889734481264785373221614398012025476303182832822061477901248239021541344099676153568885486352977094066561890040432932375042263486484903267278636267737055680464801388244297439901913164283460007337580608820518474073826036007704330555168113704346347831094761282973105787114375979872109048678912378447024088299589580139344073821156434346918594017213259261457898076098194382898117219899996615296881304272670178018205052638175366015664407872556639845740031173241038857742197752056767173822380027747071946087883582783869148242821598905799716380072630282588070671669892479075107665241429575031081991708907071431695818054859352557781505280458396873388178567860462742933539844911001307805710969958912649766160636664442091212054911617155634772556698313644512212896638683320434089914229883478149894078165144616711579961408096301481203374929722989949577464441883930555517497748994970645200840746738045185312030866627064914915638332254489627622742973416972471200418279510182228609281601463623199095922993573493925865640236057369226981287339020647735417843551923251071156245267618888913242101062028281037227453538294723726937917577210084248763487369310650567189118573017771943305377973416126808531168929691837496777558951108820091057621848403700845850791799968511649325958355535303609504020677448813943925541647453576854551682975397694499884849667542945914878129935315495791293957412343737119394213790884017044211639203385888397223949960072191007364995680908794111827641032377334463476304140030740895326647878485919560231944892622957673745457757253566528144512676576138429586069473892163403181411768114586194783486612706202078933030479352246338005627552160343072474666638128730000455407899476581690266306868274807967722479172867123634637508118294193939509399987554971436113687062392449740898770848201408828240977516193802019460025829263706347885310132920339804831515165453439661063095875915964476306397160373147926082258647569305603275945598241931773137589567973801924259776070576781085096259492212243249626068703306483545347412393520100374392669775598125689717181765234161193493040064887808629616926904738832863736235603690009574625478267909723991309695470646658480918424870982100367317947910579246279682478705276175809327515294387462907001470290528780171362415398249972814519107662670166329424829825317793184505271640030600512454012971059337937288677921715907650663578037186677344578485689585769991324948156545553231537262472400573665387234444078285327798049559022164834750289860064459734379505208454620216631391308885231925660754766846839186216398840309162522254003588302868721406722210691416554149316933981618066861360688189820672537179380452883538915271847053257183294003573767015576513571229690014441394549681931953475183856520221000844907455853105751129342586466056178389817563987942556633337589226088288063128482248345646353764482159920581051475269544808993006931774384938347120353467363411057599208628362571164403828417443806163493519270868783422225670370381948020065961816597724617314627596537887411409035307782782279813651801048763783851286547683339418274998256950780808363265486408714962562600563229016003629119962697558655608355273929615204492095997753388725638913077322033293278193930474263146433115254911585387679549255685615893348624469822870005415995583251151715399880623663691231050819470830684264632800682095780854117369863436445934825447304564370732647039677176276844320625" + }, + "capacity_cut": { + "3type": [ + "29443626051637402979527742379719189595/324518553658426726783156020576256", + "14721813025818701489763871199873339283/162259276829213363391578010288128" + ] + } + }, + "entry": { + "kappa": "69/20000", + "ordinary_H": [ + 3000, + 3080 + ], + "numerical_H": 1024, + "ordinary_rates": [ + "3436086366381819771/1000000000000000000000", + "690000000000001/200000000000000000" + ], + "gaussian_rate": "519866123/137438953472", + "signed": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/10000000000000000000", + "ordinary_margin": "1/1000000000000000000", + "positive_margin": "34867655579833460087/104857600000000000000000" + }, + "stock": { + "binary_cuts": [ + 3077, + 6221 + ], + "public_exponent_A": 7437, + "first_public_offset": 4, + "initial_s": 7438, + "stage_and_outer_fixed_log_overhead": 1964, + "retimed_first_stripe_margin": 1701, + "retimed_all_size_margin_floor": 1635, + "absolute_log2_private_control_envelope": 3153922, + "storage_upper": "6.2 p T < 297.6 n bits" + }, + "geometry": { + "public_offset_above_2_to_A": 4, + "first_extent_bits_minus_b": -7433, + "last_extent_bits_minus_b": -7432, + "minimum_width": 3809536, + "log2_axis_count": 7412, + "largest_axis_width": 5592406, + "private_clock_log2_upper": 5734316302, + "actual_dense_root_entry_log2": 11184812 + }, + "binary_surcharges": [ + 0, + 25818582 + ], + "log2_B": 125433364, + "log2_C": 125660246 + }, + "terminal": { + "kappa": "3900862325217/1000000000000000", + "ordinary_H": [ + 8192, + 63614, + 1005821, + 15903360, + 251454111, + 268435455 + ], + "numerical_H": 52270, + "ordinary_rates": [ + "465096271676051831/125000000000000000000", + "1939482011371623867/500000000000000000000", + "243715001291493271/62500000000000000000", + "975194231522124623/250000000000000000000", + "1950430823660962391/500000000000000000000", + "780172465043401/200000000000000000" + ], + "gaussian_rate": "14011769065981/3591967048990720", + "signed": { + "strict": 54, + "functional": 4, + "smallest_margin": "1/10000000000000000000", + "ordinary_margin": "1/1000000000000000000", + "positive_margin": "20012236979356349/548090675200000000000000000" + }, + "stock": { + "binary_cuts": [ + 8290, + 71968, + 1077853, + 16981277, + 268435452, + 536870971 + ], + "public_exponent_A": 536923552, + "first_public_offset": 2, + "initial_s": 536923553, + "stage_and_outer_fixed_log_overhead": 1980, + "retimed_first_stripe_margin": 268459674, + "retimed_all_size_margin_floor": 260070362, + "absolute_log2_private_control_envelope": 274877905923, + "storage_upper": "6.2 p T < 297.6 n bits" + }, + "geometry": { + "public_offset_above_2_to_A": 2, + "first_extent_bits_minus_b": -536923548, + "last_extent_bits_minus_b": -536923547, + "minimum_width": 274904860416, + "log2_axis_count": 536923511, + "largest_axis_width": 366503875926, + "private_clock_log2_upper": 375850315658657, + "actual_dense_root_entry_log2": 733007751852 + }, + "binary_surcharges": [], + "log2_B": 171798577106, + "log2_C": 171810078108 + }, + "previous_rate": "1950428633893/500000000000000", + "previous_8090_rate": "780165393219/200000000000000", + "previous_8073_rate": "1949109876753/500000000000000", + "previous_8089_rate": "39/10000", + "previous_2type_G_inf_rate": "17145637307/4398046511104", + "rate_delta": "5057431/1000000000000000", + "rate_delta_vs_8073": "2642571711/1000000000000000", + "complete_log2_C": 171810078109, + "ordinary_floor": 1156, + "ordinary_matched_suffix_proof": "periodic-integral-disjoint-intervals", + "ordinary_finite_debit": "1418665/1048576", + "ordinary_reserve": "256/255", + "ordinary_child_tariff": "2401/1024", + "ordinary_child_contraction": "2400/2401", + "ordinary_child_geometric_sum": 2401, + "ordinary_entry_clock_extra": 5, + "ordinary_terminal_clock_extra": 18, + "entry_price_surcharge": 242079, + "fixed_funding_height_floors": [ + 268290534, + 52270 + ], + "log2_fixed_setup_upper": 228, + "native_setup_transition_upper": 217364570380528137475793294892811967875864032914108887556978854854656, + "native_setup_grade_actions": 269139072, + "actual_roles": 1002096, + "grade_count": 72, + "max_native_H": 268435455 +} diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/SETUP-28BIT.md b/research/p104-10shortcut-child-tariff/source/peer8097/SETUP-28BIT.md new file mode 100644 index 0000000000..7db268bd48 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/SETUP-28BIT.md @@ -0,0 +1,22 @@ +# Fixed installer bound at 28-bit ordinary heights and ten recipes + +This note extends the 25-bit fixed-installer lemma of [#8081](https://github.com/CrocSwap/integer-mult-bounds/pull/8081) (`research/p104-expanded-budget-25bit/SETUP-PROOF.md`) and the 27-bit extension of [#8094](https://github.com/CrocSwap/integer-mult-bounds/pull/8094) (`SETUP-27BIT.md`) directly up to the sharp `w = 2^38` individual datum ceiling at `H < 2^28`. The encoding argument is unchanged; only the explicit numerical bounds below change. As in `#8081` and `#8094`, this is an encoding and action-count bound on the fixed installer constructors, not a rate-admission condition by itself. + +**Scope.** The installed profiles contain 2 entry ordinary recipes, 6 terminal ordinary recipes, and 2 Gaussian recipes, totaling **10 height records** (`len(low) + len(high) == 10`, with `1 <= len(TERMINAL.rank_logs) <= 7`). Every ordinary height satisfies `8192 <= H < 2^28` (`max_native_H = 2^28 - 1 = 268435455`). Both Gaussian heights remain tiny (`ENTRY.complex_log = 1024`, `TERMINAL.complex_log = 52270 < 2^16 < 2^25`). The 128-bit scalar-encoding guard on `kappa`, `eta`, and `positive_stop_denominator` remains enforced (`assert all(abs(x).bit_length() <= 128 ...)`). + +**Height-dependent paths & sharp `w = 2^38` ceiling.** As established in `#8081`, `Recipe.__init__` and `WeightedRecipe.__init__` record `H` and `92H` and defer constructing large calendars until caller invocation. For `H <= 2^28 - 1`: +- `92H <= 92 * (2^28 - 1) = 24696061860 < 2^35 < 2^38` (lazily materialized `2^(92H)` stays strictly below the source datum width bound `w = 2^38`). +- The fixed native control exponent `1024 * H + (m + 1).bit_length() <= 1024 * (2^28 - 1) + 3 = 274877905923 < 2^38 = 274877906944`. Note that `H = 2^28` gives `1024 * 2^28 + 3 = 274877906947 > 2^38`, making **28 bits (`H < 2^28`) the exact sharp upper limit** compatible with the inherited datum bound `w = 2^38` without lifting `w`. +- Each Gaussian carrier `1 << G` uses at most `G + 1 = 52271 < 2^16` bits (`<< 2^25`), keeping all Gaussian carrier arithmetic far smaller than `#8094` (`G = 208653`). + +**Count.** Charging two maximal Gaussian carriers at `2^25` plus `2^24` elementary transitions per recipe across all 10 height records gives: + +``` +2 * 2048 * (2^25 + 1) + 10 * 2^24 = 137,606,729,728 < 2^40, +``` + +leaving `#8081`'s separate `< 2^40` setup carrier allowance and `< 2^228` complete transition bound intact (`assert setup["all_setup"] < 2**228` in `receipt.py`). + +**Cuts and entrance logs.** Stage entrance cuts `(8290, 71968, 1077853, 16981277, 268435452, 536870971)` are computed as unbounded Python integers by `entrance_logs` and `activation` (just as cuts exceed `2^26` in `#8090` and `2^28` in `#8094`), while no fixed-width constructor descriptor stores a cut. + +**What is not covered.** Heights `H >= 2^28` violate `1024 * H + 3 < 2^38` under the inherited datum bound and are excluded here. diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/check_cutoff.py b/research/p104-10shortcut-child-tariff/source/peer8097/check_cutoff.py new file mode 100644 index 0000000000..9e36d10a94 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/check_cutoff.py @@ -0,0 +1,78 @@ +"""Check the literal upper fence, 3-type integer cutoff births and timed returns.""" +from fractions import Fraction as Q +from pathlib import Path +import sys + +sys.path.insert(0, str(Path(sys.argv[1]).resolve())) +from upstream import install + +install() +import grades +from grades import LOWER, SCALES, UPPER_DIVISOR, WEIGHTS, numerical_recipe +from installations import ENTRY, GAUSSIAN_C, TERMINAL +from transport import Measure, ceil +from typed_transport import NativeType, TypedPlan, column_header, decode_header + +assert LOWER == 1164 and SCALES == (1, 2, 3) and WEIGHTS == (1, 45, 2025) +assert UPPER_DIVISOR == 1724 + + +def verify_constructor_call(height): + recipe = numerical_recipe(height) + carrier = 1 << height + + def verify(n, types, cells, t, lower, upper, volume, ticks, rounds, **options): + assert (n, lower, t) == (carrier, LOWER, 1 - GAUSSIAN_C) + assert upper == 2 * (carrier // (1724 * 459)) + assert upper > 2 * (carrier // (2048 * 459)) + assert upper % 2 == 0 and 4 * 387 * (upper - 8) < n + assert len(cells) == 125 and tuple(word.multiplicity for word in types) == WEIGHTS + assert (volume, ticks, rounds) == (carrier**6, carrier**82, carrier**2) + assert options == {"width": 1 << (92 * height), "delay_base": 1 << 19} + return True + + original = grades.TypedPlan + try: + grades.TypedPlan = verify + assert recipe.open() + finally: + grades.TypedPlan = original + + +heights = (ENTRY.complex_log, TERMINAL.complex_log) +assert heights == (1024, 52270) +for height in heights: + verify_constructor_call(height) +print("PASS_LITERAL_UPPER_FENCE", UPPER_DIVISOR, LOWER, heights, flush=True) + +for band, expected in ((LOWER, (4, 8, 12)), (LOWER + 2, (6, 12, 18))): + widths = [] + for kind, scale in enumerate(SCALES): + header = column_header(band - 8, kind) + cols, decoded_kind = decode_header(header) + assert (cols, decoded_kind) == (band - 8, kind) and (header & 3) == kind + widths.append(cols * scale) + assert tuple(width % 24 for width in widths) == expected +assert (LOWER - 8, 2 * (LOWER - 8), 3 * (LOWER - 8)) == (1156, 2312, 3468) + +native = tuple(NativeType((2,), (1,), weight) for weight in WEIGHTS) +shares = {(a, 1, b, 2): Q(w, sum(WEIGHTS)) for a in range(3) for b, w in enumerate(WEIGHTS)} +t = 1 - GAUSSIAN_C +n, volume = 65536, 2**34 +plan = TypedPlan(n, native, shares, t, LOWER, 4126, volume, 3, 16, delay_base=3, padding=1) +mass = Measure(t, volume, 64 * n.bit_length()) +assert plan.bands.start == LOWER and (LOWER - 2, 0) not in plan.count +for band in plan.bands: + for kind, weight in enumerate(WEIGHTS): + assert plan.count[band, kind] == ceil(weight * mass.mass(band, band + 2)[1]) +assert {(a, link.kind) for (_, a, _), ls in plan.send.items() for link in ls} == { + (a, b) for a in range(3) for b in range(3) +} +grants = [] +for recipient in range(3): + for link in plan.receive[LOWER, recipient, 0]: + assert link.band in (2 * LOWER, 2 * LOWER + 2) and plan.delay[LOWER] < plan.delay[link.band] + assert link.count > 0 + grants.append((recipient, link.kind, link.band, link.count)) +assert len(grants) == 18 and plan.source_width > 0 and plan.leaves_per_epoch > 0 +print("PASS_LITERAL_LOWER_CUTOFF", LOWER, (1156, 2312, 3468), grants, plan.leaves_per_epoch, flush=True) diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/check_ordinary_floor.py b/research/p104-10shortcut-child-tariff/source/peer8097/check_ordinary_floor.py new file mode 100644 index 0000000000..63af07cb6e --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/check_ordinary_floor.py @@ -0,0 +1,352 @@ +"""Check the literal ordinary floor, periodic-integral suffix envelope, and finite replay.""" +from collections import Counter +from dataclasses import dataclass +from fractions import Fraction as Q +from hashlib import sha256 +import json +from math import gcd +from pathlib import Path +import sys + +RUNTIME = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(RUNTIME)) +from upstream import install + +install() +LOWER = 1156 + + +def ceil(x): + return -(-x.numerator // x.denominator) + + +def all_size_stock(word, c, intervals, unit): + """Discharge the parameterized TRANSFER.md hypotheses with the periodic-integral suffix bound.""" + from strict_moment import power_interval + + t = 1 - c + targets, paid = Counter(word.targets), Counter(word.paid) + assert max(targets) <= 134 and min(paid) >= 1 + assert all(5 * r <= 4 * k for r, k in word.cells) + assert all(sum(p for (u, k), p in word.cells.items() if u == r) == 1 for r in paid) + t_lower = {k: intervals(k, t)[0] for k in targets} + p_upper = {r: intervals(r, t)[1] for r in paid} + t_hi = sum(n * intervals(k, t)[1] for k, n in targets.items()) + p_lo = sum(n * intervals(r, t)[0] for r, n in paid.items()) + assert sum(targets[k] * v for k, v in t_lower.items()) > sum(paid[r] * v for r, v in p_upper.items()) + assert 100 * p_lo > 99 * t_hi + for k, n in targets.items(): + load = sum(paid[r] * p * p_upper[r] for (r, s), p in word.cells.items() if s == k) + assert 0 < load <= n * t_lower[k] + + psi = sum( + paid[r] * p * r * (Q(intervals(k, c)[0], intervals(r, c)[1]) - 1) / c + for (r, k), p in word.cells.items() + ) + target_axes = sum(k * n for k, n in targets.items()) + assert target_axes == 286098 and target_axes < 2**25 + + H = 1024 + N = 1 << H + V = N**6 + ambient = 134 + U = 2 * (N // (2048 * ambient)) + delta = Q(1, 2**128) + assert LOWER % 2 == 0 and 8 < LOWER and 24 * (LOWER + 2) < 25 * LOWER + assert (LOWER - 8, LOWER - 6) == (1148, 1150) + assert max(Q(k, r) for r, k in word.cells) * LOWER < U + assert max(Q(k, r) for r, k in word.cells) * (U + 2) < N + assert 4 * max(targets) * (U - 8) < N and U * ambient <= Q(N, 1024) + assert U * 1024 * ambient >= (1 - delta) * N + assert 1270 <= delta * U + + periodic_num = Q(0) + for (r, k), p in word.cells.items(): + rk_hi = Q(intervals(r, t)[1], intervals(k, t)[0]) + rkl_lo = Q(power_interval(LOWER * r, t)[0], power_interval(LOWER * k + 4 * r, t)[1]) + assert Q(power_interval(LOWER, t)[1], power_interval(U, t)[0]) < delta + term = (9 * k - 8 * r) * rk_hi - r * rkl_lo + r * delta + assert term > 0 + periodic_num += paid[r] * p * term + fringe = periodic_num / (t * psi) + assert 0 < fringe < Q("4.53") and psi > 1 + + assert Q(6, 5) ** 4 > 2 and Q(6, 5) ** 73 > 2**19 + assert len(word.paid) < 2**19 + assert 2**19 * Q(1, 1024 * ambient * LOWER) ** 77 + Q(1, N**77) < 1 + lower_power = Q(intervals(LOWER, t)[0], unit) + assert lower_power > 1024 and Q(1, t * lower_power) + Q(2, N**5) < 2 + assert c.denominator.bit_length() - 1 <= 60 and Q(1, N) - Q(1, 2 ** (64 * (H + 1))) > Q(1, 512 * N) + grid_error_bits = 397 + 31 * H + 6 * H + 3 - 64 * (H + 1) + assert grid_error_bits < -132 + assert c > 0 and 1 < LOWER and U <= N + suffix_birth_error = Q(20 * U * target_axes, V) / psi + integer_mass_error = Q(2**46, N**4) + delay_end_error = Q(2**20, N**4) + assert suffix_birth_error < Q(2**30, N**5) < Q(1, 2**132) + assert integer_mass_error < Q(1, 2**132) and delay_end_error < Q(1, 2**132) + assert 4 * Q(1, 2**132) < delta + assert 4096 * 2 * len(word.targets) < N**2 + assert (1 - delta) * psi - Q(1, 2**130) > 1 + assert (1 - Q(1, N)) / Q(257, 256) > Q(1, 2) + return { + "fringe_upper_1e9": ceil(fringe * 10**9), + "psi_lower_floor": int(psi), + "grid_absolute_error_exponent_at_H1024": grid_error_bits, + "suffix_target_axes": target_axes, + "suffix_birth_error_upper_at_H1024": "2^30/N^5", + "normalized_error_allowance": "2^-128", + "birth_bound": "2V", + "copy_group_bound": "3N^3", + "whole_field_width": "N^92", + "first_two_columns": [LOWER - 8, LOWER - 6], + "minimum_positive_scale_h_guard": 1024, + } + + +@dataclass(frozen=True) +class Pow2: + """Symbolic exact power of two 2**exp.""" + + exp: int + + def __pow__(self, power): + assert type(power) is int and power >= 0 + return Pow2(self.exp * power) + + def __floordiv__(self, divisor): + assert type(divisor) is int and divisor > 0 + return FloorPow2(self.exp, divisor) + + +@dataclass(frozen=True) +class FloorPow2: + """Symbolic exact quotient (2**exp) // divisor.""" + + exp: int + divisor: int + + def __rmul__(self, factor): + assert type(factor) is int and factor > 0 + return TimesFloorPow2(factor, self.exp, self.divisor) + + +@dataclass(frozen=True) +class TimesFloorPow2: + """Symbolic exact product factor * ((2**exp) // divisor).""" + + factor: int + exp: int + divisor: int + + +class ShiftCount(int): + """Exponent wrapper intercepting 1 << height inside unmodified Recipe.open().""" + + def __rlshift__(self, base): + assert base == 1 + return Pow2(int(self)) + + +def realize(value): + """Evaluate symbolic power-of-two expressions back to exact Python integers.""" + if isinstance(value, Pow2): + return 1 << value.exp + if isinstance(value, FloorPow2): + return (1 << value.exp) // value.divisor + if isinstance(value, TimesFloorPow2): + return value.factor * ((1 << value.exp) // value.divisor) + return value + + +def bound_recipe(old, lower): + """Pass the proposed literal cutoff through the unmodified Recipe.open seam.""" + import transport + + H = old.rank_log + assert old.level_floor == lower and old.width_log == 92 * H + expected_divisor = 2048 * old.ambient + + def call_arguments(symbolic): + real_plan = transport.Plan + old_rank, old_width = old.rank_log, old.width_log + try: + if symbolic: + old.rank_log, old.width_log = ShiftCount(H), ShiftCount(92 * H) + transport.Plan = lambda *args, **kwargs: (args, kwargs) + return old.open() + finally: + old.rank_log, old.width_log, transport.Plan = old_rank, old_width, real_plan + + sym_args, sym_kw = call_arguments(True) + n, targets, paid, cells, t, l, u, volume, ticks, rounds = sym_args + assert n == Pow2(H) and (l, u) == (lower, TimesFloorPow2(2, H, expected_divisor)) and t == 1 - old.trial + assert targets is old.targets and paid is old.paid and cells is old.cells + assert (volume, ticks, rounds) == (Pow2(6 * H), Pow2(82 * H), Pow2(2 * H)) + assert sym_kw == {"width": Pow2(92 * H), "delay_base": 1 << 19} + + literal_cross_checked = H <= 2_000_000 + if literal_cross_checked: + lit_args, lit_kw = call_arguments(False) + assert tuple(map(realize, sym_args)) == lit_args + assert {k: realize(v) for k, v in sym_kw.items()} == lit_kw + + return { + "height": H, + "lower": lower, + "ambient": old.ambient, + "first_columns": lower - 8, + "plan_arguments_checked": True, + "literal_cross_checked": literal_cross_checked, + "trace": "symbolic-exact-operator-interception", + } + + +def finite_plan(word, c): + """Replay a two-port cut fixture on one occupied K7 edge and verify pointwise + periodic suffix bounds.""" + from transport import Measure, Plan + from strict_moment import UNIT + from unpowered_price import intervals + + r, k = max(word.cells, key=lambda edge: Q(edge[0], edge[1])) + hi = 2 * ceil(Q((LOWER + 4) * k, 2 * r)) + 4 + n = 1 << (4 * k * hi - 1).bit_length() + volume = 8 * hi**2 + ticks, radix = 5, 4 + t = 1 - c + plan = Plan(n, (k,), (r,), {(r, k): Q(1)}, t, LOWER, hi, volume, ticks, n, delay_base=radix) + assert plan.bands.start == LOWER and LOWER - 2 not in plan.count + mass = Measure(t, volume, 64 * n.bit_length()) + contacts = [] + suffix_bound_unit = (volume / t) * ( + (9 * k - 8 * r) * Q(UNIT, intervals(Q(LOWER * k, r), t)[0]) + - r * Q(UNIT, intervals(Q(LOWER * k, r) + 4, t)[1]) + + r * Q(UNIT, intervals(hi, t)[0]) + ) + empirical_suffix = 0 + for d in range(LOWER, hi, 2): + for i in range(1): + for link in plan.receive.get((d, i), ()): + e = link.band + dif = r * (e - 8) - k * (d - 8) + assert 0 <= dif <= 10 * k - 8 * r - 2 * gcd(r, k) + empirical_suffix += link.count * dif + assert empirical_suffix <= ticks * suffix_bound_unit + + for d in (LOWER, LOWER + 2): + assert plan.count[d] == ceil(mass.mass(d, d + 2)[1]) + grants = [] + for i in range(1): + assert plan.receive[d, i] + for link in plan.receive[d, i]: + e = link.band + a, b = max(e, Q(d * k, r)), min(e + 2, Q((d + 2) * k, r)) + grant = mass.mass(a, b)[0] + assert link.count == grant.numerator // grant.denominator + assert 0 < grant and 2 * plan.delay[d] < plan.delay[e] + assert 0 <= r * (e - 8) - k * (d - 8) <= 10 * k - 8 * r - 2 * gcd(r, k) + grants.append((i, link.port, e, link.count)) + contacts.append((d, plan.count[d], grants)) + + live, pending, held = {}, {}, Counter() + axes = opens = closes = loans = 0 + first_counts = Counter() + for op, frame, *args in plan.events(): + if op == 0: + assert frame not in live + columns, *bindings = args + size = k * columns + parents = [] + cursor = iter(bindings) + for kind in cursor: + if kind == 1: + sender, prefix = pending.pop(next(cursor)) + assert sender in live and prefix == size + held[sender] += 1 + parents.append(sender) + loans += 1 + if columns in (LOWER - 8, LOWER - 6): + first_counts[columns] += 1 + elif kind == 2: + _, width, period = next(cursor), next(cursor), next(cursor) + assert width == size and period % 4 == 0 + else: + assert kind == 0 and next(cursor) == size + live[frame] = parents + opens += 1 + elif op == 1: + serial, size, selected = args + assert frame in live and held[frame] == 0 + axes += size - selected + if selected: + assert serial not in pending + pending[serial] = (frame, selected) + else: + assert op == 2 and held[frame] == 0 + for sender in live.pop(frame): + held[sender] -= 1 + assert held[sender] >= 0 and sender in live + closes += 1 + assert not live and not pending and not any(held.values()) and opens == closes + assert axes == plan.leaves_per_epoch and len(first_counts) == 2 + return { + "tested_occupied_K7_grade": [r, k], + "lower": LOWER, + "upper": hi, + "carrier": n, + "first_band_contacts": contacts, + "native_opens": opens, + "native_closes": closes, + "returned_paid_prefixes": loans, + "paid_singletons": axes, + "lower_return_counts": dict(first_counts), + "empirical_suffix_axes": empirical_suffix, + "periodic_suffix_bound": float(ticks * suffix_bound_unit), + "extent": "complete fixture event stream", + } + + +def check(): + from band_product import prepare_native + from installations import BINARY_C, ENTRY, TERMINAL + from raw_binary_stage import binary_word + from strict_moment import UNIT + from unpowered_price import intervals + + stage = (RUNTIME / "raw_binary_stage.py").read_bytes() + assert ( + sha256(stage).hexdigest() + == "934d2ae0b305caa364f155cc407c0e8ca479837ba70b906b8f516f67a5cc17b6" + ) + assert ( + sha256((RUNTIME / "transport.py").read_bytes()).hexdigest() + == "9eb8f0d77a4c53fc4fddffdfe198cab930b6d1f49e2b6d43c970397051bb7818" + ) + assert TERMINAL.rank_logs == (8192, 63614, 1005821, 15903360, 251454111, 268435455) and TERMINAL.complex_log == 52270 + word = binary_word() + assert (len(word.targets), len(word.paid), len(word.cells)) == (18906, 104652, 24) + a, b = prepare_native() + ordinary = (*a[:-1], *b[:-1]) + assert tuple(recipe.rank_log for recipe in ordinary) == (*ENTRY.rank_logs, *TERMINAL.rank_logs) + assert (a[-1].rank_log, b[-1].rank_log) == (1024, 52270) + openings = [bound_recipe(recipe, LOWER) for recipe in ordinary] + stock = all_size_stock(word, BINARY_C, intervals, UNIT) + finite = finite_plan(word, BINARY_C) + assert finite["tested_occupied_K7_grade"] == [49, 64] + assert finite["native_opens"] > 0 and finite["returned_paid_prefixes"] > 0 + print( + "PASS_LITERAL_ORDINARY_FLOOR", + json.dumps( + { + "new_binary_openings": openings, + "binary_all_size": stock, + "binary_integer_fixture": finite, + }, + sort_keys=True, + ), + flush=True, + ) + + +if __name__ == "__main__": + check() diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/check_stage_seam.py b/research/p104-10shortcut-child-tariff/source/peer8097/check_stage_seam.py new file mode 100644 index 0000000000..8aa3a1341c --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/check_stage_seam.py @@ -0,0 +1,363 @@ +"""Replay 6-stage 28-bit ordinary dispatch, all comparator controls, and bounded signed bank returns.""" +from dataclasses import replace +from fractions import Fraction as Q +from hashlib import sha256 +from io import BytesIO +from itertools import product +import json +from pathlib import Path +import sys + +RUNTIME = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(RUNTIME)) +from upstream import install + +install() + + +class DyadicWidth(int): + """Speed up exact exponentiation of a mathematically dyadic test width.""" + + def __pow__(self, exponent): + assert self.bit_count() == 1 and exponent >= 0 + return 1 << ((self.bit_length() - 1) * exponent) + + +def verify_stage(profile, cuts, number, log_width): + import ordinary_carrier as carrier + + calls = [] + base = DyadicWidth(1 << log_width) + prev = 1 << cuts[number - 2] + power = 1 << (log_width // 250) + eta = profile.eta + assert log_width % 10000 == 0 and log_width * eta.numerator % eta.denominator == 0 and log_width % 250 == 0 + width = max(prev + 1, power) + component = 1 << (log_width * eta.numerator // eta.denominator) + count = -(-width // component) + short, longer = divmod(width, count) + expected_layout = (longer, short + 1, count - longer, short) + rank = 1 << profile.rank_logs[number - 1] + expect_direct = -(-base // width) <= 1 << (8 * profile.rank_logs[number - 1]) + + def root(value, degree): + assert value.bit_count() == 1 + quotient, remainder = divmod(value.bit_length() - 1, degree) + assert not remainder + return 1 << quotient + + def receiver(dimension, layout, previous, *, direct, profile): + assert dimension == rank and layout == expected_layout and direct == expect_direct + assert previous.func is carrier.ternary + assert previous.keywords == {"maximum": number - 1, "profile": profile} + return number + + def body(source, target, digits, prefix, gap, suffix, backend): + assert digits == base and (prefix, gap, suffix) == (1, 3, 5) and backend == number + calls.append((digits.bit_length() - 1, backend)) + + actual = carrier.ceil_root, carrier.Receiver, carrier.root_body + try: + carrier.ceil_root, carrier.Receiver, carrier.root_body = root, receiver, body + carrier.ternary(None, None, base, 1, 3, 5, maximum=number, profile=profile) + finally: + carrier.ceil_root, carrier.Receiver, carrier.root_body = actual + assert calls == [(log_width, number)] + return { + "stage": number, + "scanned_log": log_width, + "rank_log": rank.bit_length() - 1, + "predecessor_cut": cuts[number - 2], + "direct": expect_direct, + "component_log": component.bit_length() - 1, + } + + +def verify_tape(width, u, v): + from five_exchange import same_order_line + from growing_binary import Weighted + from same_order_body import SameOrderBody + from streaming_routes import cold_swap_tape + from ternary_leaf import select_pivot + + class Core(SameOrderBody, Weighted): + def __init__(self): + super().__init__(2, (1, width, 0, 0), cold_swap_tape) + self.stock = self.owners + self.calls = 0 + + def weighted(self, *args, **kwargs): + assert kwargs["atoms"] == 1 < self.n + self.calls += 1 + return super().weighted(*args, **kwargs) + + core = Core() + modulus = core.modulus + assert modulus == 3**width and core.atom == modulus + assert sum(a * b for a, b in zip(u, v, strict=True)) % modulus == 1 + weight = lambda row, j: (2, 4)[j] + inverse = tuple(pow(weight(0, j), -1, modulus) for j in range(2)) + + def dense(sign): + out = bytearray(len(raw)) + size = modulus**4 + for x0, x1, y0, y1 in product(range(modulus), repeat=4): + delta = sum(v[j] * (y - inverse[j] * x) for j, (x, y) in enumerate(zip((x0, x1), (y0, y1), strict=True))) % modulus + target = ( + (x0 + sign * 2 * u[0] * delta) % modulus, + (x1 + sign * 4 * u[1] * delta) % modulus, + (y0 - sign * u[0] * delta) % modulus, + (y1 - sign * u[1] * delta) % modulus, + ) + i = ((x0 * modulus + x1) * modulus + y0) * modulus + y1 + k = 0 + for value in target: + k = k * modulus + value + assert 0 <= k < size + out[4 * k : 4 * k + 4] = raw[4 * i : 4 * i + 4] + return bytes(out) + + raw = b"".join(i.to_bytes(4, "little") for i in range(modulus**4)) + source, destination = BytesIO(raw), BytesIO() + same_order_line( + core, + source, + destination, + pivot=select_pivot(u, v), + factors=lambda _: (u, v), + f=1, + unused=1, + heights=1, + older=1, + gap=1, + suffix=4, + weight=weight, + ) + assert source.getvalue() == raw and source.tell() == len(raw) + assert destination.getvalue() == dense(1) + assert destination.getvalue() != dense(-1), "wrong signed return was accepted" + assert 1 <= core.calls <= 5 + return { + "component_width": width, + "modulus": modulus, + "records": modulus**4, + "paid_exchanges": core.calls, + "wrong_signed_return_rejected": True, + } + + +def check(): + sys.path.append(str(Path(__file__).resolve().parent.parent / "tiered-native-multiplier" / "source")) + from activation import full_entrance, resource_receipt + from band_product import prepare_native + from installations import BINARY_C, ENTRY, GAUSSIAN_C, TERMINAL, activation + from outer_budget import qualify + from raw_binary_stage import binary_word + from staged_carriers import entrance_logs + + ORDINARY = Q(1418665, 2**20) # periodic-integral suffix at L=1156, 2401/1024 tariff, FULL 256/255 reserve + GAUSSIAN = Q(32401, 262144) # w5664 10-shortcut + 3-type (1, 45, 2025) + STOP = Q(1, 10**18) + TOTAL = 171810078109 + PREMIUM = 242079 + BITS = 28 + TOP = (1 << BITS) - 1 + ranks = tuple(TERMINAL.rank_logs) + last = len(ranks) - 1 + assert ranks == (8192, 63614, 1005821, 15903360, 251454111, TOP) and TERMINAL.complex_log == 52270 + assert GAUSSIAN_C == Q(17166573920, 2**42) + assert TERMINAL.kappa == Q(".003900862325217") + + def ordinary_upper(heights, debit=ORDINARY, eta=TERMINAL.eta): + r = Q(0) + for i, h in enumerate(heights): + u = min(eta, (249 * (BINARY_C - debit / h) + r) / 250) + r = u if i == len(heights) - 1 else Q((u * 10**21).__floor__() - 1, 10**21) + return r + + def gaussian_upper(h): + return GAUSSIAN_C - GAUSSIAN / h + + def rejected(function, label): + try: + function() + except (AssertionError, ArithmeticError, ValueError): + return label + raise AssertionError(f"Negative control {label} was not rejected") + + paid = TERMINAL.kappa + 5 * STOP + assert TERMINAL.ordinary == paid + assert ordinary_upper(ranks) > paid and gaussian_upper(TERMINAL.complex_log) > paid + assert TERMINAL.kappa <= ordinary_upper(ranks) - 5 * STOP < TERMINAL.kappa + Q(1, 10**15) + assert all(8192 <= h < 2**BITS for h in ranks) and 1024 <= TERMINAL.complex_log < 2**25 + assert TERMINAL.eta == Q(1, 256) and paid < TERMINAL.eta < Q(1, 250) and TERMINAL.eta * 8192 - 1 > 30 + assert 2 * TERMINAL.eta > Q(1, 250) and TERMINAL.eta > Q(1, 258) + assert all(ordinary_upper(ranks[:i]) < TERMINAL.eta for i in range(1, len(ranks))) + assert all(-(-(2 * h + 64) * 256 // 255) < 3 * h for h in ranks) + assert 2660000 * (30 + 2) < 2**30 and 17**16 * 10 ** (21 * 16) < 2**1182 + + stock = resource_receipt(TERMINAL) + cuts = tuple(stock["binary_cuts"]) + assert tuple(entrance_logs(ranks)) == cuts + assert all(cuts[i - 1] + 2 < ranks[i] for i in range(1, len(ranks))) + assert activation(TERMINAL) == stock["public_exponent_A"] + assert stock["retimed_first_stripe_margin"] > 1024 and stock["retimed_all_size_margin_floor"] > 1024 + signed = qualify(TERMINAL.kappa, STOP, paid, gaussian_upper(TERMINAL.complex_log)) + assert (signed["strict"], signed["functional"]) == (54, 4) + + logB = 128 + 3 * len(ranks) + 320 * sum(ranks) + late = 1602 + 220 * TERMINAL.complex_log + logB + conversion = ((TERMINAL.kappa - ENTRY.kappa) * activation(TERMINAL)).__ceil__() + assert conversion == PREMIUM and logB == 171798577106 + assert 1 + max(125660246 + conversion, late) == TOTAL + assert TOTAL > 318292011 + + def at(index, delta): + return tuple(h + (delta if j == index else 0) for j, h in enumerate(ranks)) + + def require_funding(proposed, gaussian, eta=TERMINAL.eta): + if ordinary_upper(proposed, eta=eta) <= paid or gaussian_upper(gaussian) <= paid: + raise ArithmeticError("Profile does not fund the terminal price") + + def require_budget(cap): + if 1 + max(125660246 + conversion, late) > cap: + raise ArithmeticError("The full recurring invoice exceeds the declared cap") + + prev_8094 = ((31808, 502922, 7951907, 125730703, 134217727), 208653) + prev_8090 = ((125432, 1988432, 31439868, 33554431), 198527) + capped_20bit = ((62350, 985843, 1048575), 33856) + five_stage_28 = ((63614, 1005841, 15903840, 251461645, TOP), TERMINAL.complex_log) + assert ordinary_upper(five_stage_28[0]) < ordinary_upper(ranks) + + DROPS = (861, 231, 232, 232, 232, 2) + for i, d in enumerate(DROPS): + require_funding(at(i, -(d - 1)), TERMINAL.complex_log) + + controls = [ + rejected(lambda i=i, d=d: require_funding(at(i, -d), TERMINAL.complex_log), f"ordinary-height-{i}-minus-{d}") + for i, d in enumerate(DROPS) + ] + controls += [ + rejected(lambda i=i: resource_receipt(replace(TERMINAL, rank_logs=at(i, 1))), f"ordinary-height-{i}-plus-one-breaks-prefix") + for i in range(last) + ] + controls += [ + rejected(lambda: (_ for _ in ()).throw(AssertionError()) if min(at(0, -1)) < 8192 else None, "first-ordinary-height-below-8192"), + rejected(lambda: require_funding(*five_stage_28), "five-stage-28bit-profile-at-new-rate"), + rejected(lambda: require_funding(*prev_8094), "pr8094-27bit-profile-at-new-rate"), + rejected(lambda: require_funding(*prev_8090), "pr8090-25bit-profile-at-new-rate"), + rejected(lambda: require_funding(*capped_20bit, eta=Q(39, 10000)), "capped-20bit-profile-at-new-rate"), + rejected(lambda: require_funding(ranks, TERMINAL.complex_log - 1), "gaussian-height-minus-one"), + rejected(lambda: require_funding(ranks, TERMINAL.complex_log) or require_budget(318292011), "inherited-cap-318292011"), + rejected(lambda: qualify(TERMINAL.kappa, STOP, paid - STOP, gaussian_upper(TERMINAL.complex_log)), "outer-ordinary-margin-removed"), + rejected(lambda: resource_receipt(replace(TERMINAL, rank_logs=(ranks[0], cuts[0] + 2, *ranks[2:]))), "prefix-height-at-previous-cut"), + rejected(lambda: require_budget(TOTAL - 1), "recurring-bound-minus-one"), + rejected(lambda: (_ for _ in ()).throw(AssertionError()) if min(Q(39, 10000), ordinary_upper(ranks)) <= paid else None, "old-eta-39/10000"), + ] + assert ranks[last] == TOP and TOP.bit_length() == BITS and 1024 * (TOP + 1) + 3 >= 2**38 + + # Local optimality of free prefix with h5 pinned at 2^28 - 1 and h4 pinned by cut prefix rule. + def max_penultimate(prefix): + lo, hi = prefix[-1], TOP + while hi - lo > 1: + mid = (lo + hi) // 2 + try: + resource_receipt(replace(TERMINAL, rank_logs=(*prefix, mid, TOP))) + lo = mid + except AssertionError: + hi = mid + return lo + + free = ranks[: last - 1] + assert max_penultimate(free) == ranks[last - 1] + neighbours = [] + for i in range(len(free)): + for s in (-16, 16): + t = list(free) + t[i] += s + if t[0] >= 8192: + neighbours.append(ordinary_upper((*t, max_penultimate(t), TOP))) + assert all(n <= ordinary_upper(ranks) for n in neighbours) + + # Verify all five comparator control tiers under our exact debits (retaining FULL 256/255): + def check_control(c_ranks, c_G, c_kappa, c_eta, c_cap=None, tight_floor=True): + c_paid = c_kappa + 5 * STOP + u = ordinary_upper(c_ranks, eta=c_eta) + assert u > c_paid and gaussian_upper(c_G) > c_paid + if tight_floor: + assert u - Q(1, 10**15) <= c_paid + else: + assert ordinary_upper(c_ranks[:-1] + (c_ranks[-1] - 1,), eta=c_eta) <= c_paid + assert gaussian_upper(c_G - 1) <= c_paid + assert entrance_logs(c_ranks) and all(entrance_logs(c_ranks)[i - 1] + 2 < c_ranks[i] for i in range(1, len(c_ranks))) + c_A = full_entrance(entrance_logs(c_ranks)[-1], c_G) + c_prem = ((c_kappa - ENTRY.kappa) * c_A).__ceil__() + c_late = 1602 + 220 * c_G + 128 + 3 * len(c_ranks) + 320 * sum(c_ranks) + c_tot = 1 + max(125660246 + c_prem, c_late) + if c_cap is not None: + assert c_tot <= c_cap + return c_tot, c_prem + + cap_tot, cap_prem = check_control((26960, 426219, 524288), 25003, Q(".003898283457829"), Q(39, 10000), 318291911) + bit20_tot, bit20_prem = check_control((62350, 985843, 1048575), 33856, Q(".003899576196608"), Q(39, 10000)) + t39_tot, t39_prem = check_control((8192, 106000, 1656186), 38302, Q("0.0039"), Q(1, 256), tight_floor=False) + bit25_tot, bit25_prem = check_control((125432, 1988431, 31439869, 33554431), 51501, Q(".003900827024476"), Q(1, 256)) + bit27_tot, bit27_prem = check_control((31808, 502922, 7951910, 125730700, 134217727), 52158, Q(".003900857282381"), Q(1, 256)) + assert cap_tot == 318291840 and cap_prem == 450 + assert bit20_tot == 678415820 and bit20_tot < 685495960 + assert t39_tot == 574949140 and t39_tot < 593252820 + assert bit25_tot == 21485944123 and bit25_tot < 21518289843 + assert bit27_tot == 85910697946 and bit27_tot < 85945126846 + + assert sha256((RUNTIME / "strong-bit.json.gz").read_bytes()).hexdigest() == "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362" + assert sha256((RUNTIME / "w5664_shortcut10.json.gz").read_bytes()).hexdigest() == "ce395afbf5c32be64c4e62389acaf9ce8cf8a9aaaa2fb7a278135bcfa0e635aa" + old = replace(TERMINAL, rank_logs=(62350, 985843, 1048575), complex_log=33856, kappa=Q(".003899576196608"), eta=Q(39, 10000)) + old_native, new_native = prepare_native(old), prepare_native(TERMINAL) + word = binary_word() + assert (len(word.targets), len(word.paid), len(word.cells)) == (18906, 104652, 24) + assert old_native[-1].targets is new_native[-1].targets and old_native[-1].cells is new_native[-1].cells + assert all( + v.level_floor == 1156 and v.targets is word.targets and v.paid is word.paid and v.cells is word.cells + for v in (*old_native[:-1], *new_native[:-1]) + ) + + def round_up(n): + return ((n + 159999) // 160000) * 160000 # lcm(10000, 250, 256) + + direct = [verify_stage(TERMINAL, cuts, i, round_up(cuts[i - 1])) for i in range(2, len(ranks) + 1)] + compiled = [verify_stage(TERMINAL, cuts, i, round_up(9 * ranks[i - 1])) for i in range(2, len(ranks) + 1)] + assert all(x["direct"] for x in direct) and not any(x["direct"] for x in compiled) + tape = [verify_tape(1, [0, 1], [2, 1]), verify_tape(2, [1, 7], [3, 1])] + print( + "PASS_10SHORTCUT_3TYPE_28BIT_6STAGE_SEAM", + json.dumps( + { + "kappa": str(TERMINAL.kappa), + "heights": ranks, + "gaussian_height": TERMINAL.complex_log, + "binary_cuts": cuts, + "signed": signed, + "conversion_bits": conversion, + "log2_B": logB, + "complete_log2_C": TOTAL, + "comparators": { + "strict_cap": {"kappa": "0.003898283457829", "log2_C": cap_tot, "G": 25003}, + "20bit": {"kappa": "0.003899576196608", "log2_C": bit20_tot, "G": 33856}, + "8089_0039": {"kappa": "0.0039", "log2_C": t39_tot, "G": 38302}, + "25bit_4stage": {"kappa": "0.003900827024476", "log2_C": bit25_tot, "G": 51501}, + "27bit_5stage": {"kappa": "0.003900857282381", "log2_C": bit27_tot, "G": 52158}, + }, + "controls": controls, + "direct_stage_seams": direct, + "compiled_stage_seams": compiled, + "signed_tape": tape, + }, + sort_keys=True, + default=str, + ), + flush=True, + ) + + +if __name__ == "__main__": + check() diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/check_w5664.py b/research/p104-10shortcut-child-tariff/source/peer8097/check_w5664.py new file mode 100644 index 0000000000..8db5aa2c12 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/check_w5664.py @@ -0,0 +1,188 @@ +"""Verify the 10-shortcut Gaussian word w5664_shortcut10.json.gz from #8027 by exact replay.""" +from collections import defaultdict +from fractions import Fraction as Q +import gzip +from hashlib import sha256 +import json +from math import gcd, prod +from pathlib import Path +import random +import sys + +RUNTIME = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(RUNTIME)) +from upstream import install + +install() +from charts import native_catalogue as verify_catalogue +from check_complex import all_images +from phase_atlas import catalogue as phase_catalogue +from spool import short_divisors +from strong_complex import DYADIC, GRID, LAYOUT, ODD, WORD, digest + +W5664_GZ_SHA = "ce395afbf5c32be64c4e62389acaf9ce8cf8a9aaaa2fb7a278135bcfa0e635aa" +W5664_DIGEST = "668125b34a34c9a59a97bd66a236118d1d32f19b60dcd872b29f7dd690be0c3e" +CAT_DIGEST = "34eef62b6701db0565dce3471f165f4224194ff2782be822774f9c1255553a8d" + + +def reconstruct_g0(inputs_dir): + source = inputs_dir / "complex-source" + for name, pin in json.loads((inputs_dir / "complex-source.json").read_bytes()).items(): + if sha256((source / name).read_bytes()).hexdigest() != pin: + raise ValueError(f"Complex source differs at {name}") + sys.path.insert(0, str(source)) + from sparse_helpers import rebuild + from verify_split_helpers import read, reconstruct + + parent, layout = rebuild() + g0, _ = reconstruct(parent, read("BANK-FACTORS.json.gz")) + assert digest(g0) == WORD and digest(layout) == LAYOUT + return g0, layout + + +def verify_linear_maps(g0, w10): + n_in = len(g0["initial"]) + n_out = len(g0["final"]) + assert len(w10["initial"]) == n_in and len(w10["final"]) == n_out + for key in ("initial", "final", "frames", "first_output"): + assert w10[key] == g0[key], f"Changed field {key}" + assert (len(g0["moves"]), len(w10["moves"])) == (5674, 5664) + for P in (1000000007, 1000000009, 998244353): + rng = random.Random(P) + x = {~i: rng.randrange(1, P) for i in range(n_in)} + y_w = [rng.randrange(1, P) for _ in range(n_out)] + + def fwd(g): + fm = { + fid: [(d, (Q(q).numerator * pow(Q(q).denominator, -1, P)) % P) for d, q in terms] + for fid, terms in g["forms"] + } + val = dict(x) + for fid in g["schedule"]: + val[fid] = sum(c * val[d] for d, c in fm[fid]) % P + fo = g["first_output"] + return [val[fo + i] for i in range(n_out)] + + def trans(g): + fm = { + fid: [(d, (Q(q).numerator * pow(Q(q).denominator, -1, P)) % P) for d, q in terms] + for fid, terms in g["forms"] + } + adj = defaultdict(int) + fo = g["first_output"] + for i, w in enumerate(y_w): + adj[fo + i] = w + for fid in reversed(g["schedule"]): + af = adj.get(fid, 0) + if af: + for d, c in fm[fid]: + adj[d] = (adj[d] + af * c) % P + return [adj[~i] for i in range(n_in)] + + fg = fwd(w10) + tg = trans(w10) + assert fwd(g0) == fg + assert trans(g0) == tg + assert sum(w * v for w, v in zip(y_w, fg)) % P == sum(x[~i] * t for i, t in enumerate(tg)) % P + + +def verify_literal_grid(graph, layout): + size = len(graph["initial"]) + stocks = {~i: {i: GRID} for i in range(size)} + moves = {k for k, _, _ in graph["moves"]} + rows = {k: [(s, Q(q)) for s, q in row] for k, row in graph["forms"]} + masses = {~i: Q(1) for i in range(size)} + expected = [{i: GRID} for i in range(size)] + hosted = layout["hosted"] + for i, x in enumerate(layout["live"]): + y = x + 112 + if i in hosted["Dports"]: + expected[y][x] = GRID + else: + expected[x][y] = -GRID + expected[y] = {x: GRID // 2, y: GRID // 2} + for x, y in zip(hosted["X2"], hosted["Y2"], strict=True): + expected[x][y] = -GRID + + peak = Q(1) + largest_limb = maximum_literal = products = nontrivial = 0 + common = GRID + literals = set() + for node in graph["schedule"]: + values, mass = {}, Q(0) + for src, coeff in rows[node]: + a, b = coeff.numerator, coeff.denominator + literals.add(coeff) + mass += abs(coeff) * masses[src] + for i, old in stocks[src].items(): + q, rem = divmod(old, b) + assert rem == 0, "inexact term before multiplication" + term = a * q + if common != 1: + common = gcd(common, term) + values[i] = values.get(i, 0) + term + products += len(stocks[src]) + nontrivial += (b != 1) * len(stocks[src]) + peak = max(peak, mass) + result = {i: v for i, v in values.items() if v} + if node in moves: + stocks[node] = result + masses[node] = mass + else: + assert result == expected[node - graph["first_output"]], "wrong inverse endpoint" + + for coeff in literals | {Q(1, ODD), Q(ODD)}: + factors = short_divisors(coeff.denominator) + assert prod(factors) == coeff.denominator and all(1 < v < 2**24 for v in factors) + maximum_literal = max(maximum_literal, coeff.numerator.bit_length(), coeff.denominator.bit_length()) + largest_limb = max(largest_limb, *factors, 0) + assert common == 1 and (ODD << DYADIC) == GRID and ODD % 2 == 1 + assert products == 25142049 and nontrivial == 17229517 + assert ( + str(peak) + == "205356183613811630452617549443093585249505045823/1621896683681232672237748224000" + ) + assert len(literals) == 60189 and largest_limb == 16641408 and maximum_literal == 87 + + +def main(): + if not __debug__: + raise RuntimeError("Enable assertions for w5664 checks") + gz_path = RUNTIME / "w5664_shortcut10.json.gz" + raw_gz = gz_path.read_bytes() + assert sha256(raw_gz).hexdigest() == W5664_GZ_SHA + w10 = json.loads(gzip.decompress(raw_gz).decode("utf-8")) + assert digest(w10) == W5664_DIGEST + g0, layout = reconstruct_g0(RUNTIME / "inputs") + verify_linear_maps(g0, w10) + cat = phase_catalogue(w10, layout) + assert digest(cat) == CAT_DIGEST and len(cat["pairs"]) == 2961 + checked = verify_catalogue(w10, layout, cat) + imgs = all_images(checked) + assert imgs == { + "factor_occurrences": 6130, + "distinct_factors": 3783, + "basis_images": 1936896, + "maximum_factor_records": 93, + } + verify_literal_grid(w10, layout) + print( + "PASS_W5664_SHORTCUT10", + json.dumps( + { + "gz_sha256": W5664_GZ_SHA, + "word_digest": W5664_DIGEST, + "catalogue_digest": CAT_DIGEST, + "moves": len(w10["moves"]), + "images": imgs, + "products": 25142049, + "nontrivial": 17229517, + }, + sort_keys=True, + ), + flush=True, + ) + + +if __name__ == "__main__": + main() diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/peer8057.tar.gz b/research/p104-10shortcut-child-tariff/source/peer8097/peer8057.tar.gz new file mode 100644 index 0000000000..3a3ded828f Binary files /dev/null and b/research/p104-10shortcut-child-tariff/source/peer8097/peer8057.tar.gz differ diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/prepare.py b/research/p104-10shortcut-child-tariff/source/peer8097/prepare.py new file mode 100644 index 0000000000..969b8f875c --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/prepare.py @@ -0,0 +1,1451 @@ +"""Materialize 10-shortcut w5664 + 3-type (1, 2, 3) + periodic-integral suffix + 28-bit 6-stage proofs on #8057.""" +from hashlib import sha256 +import json + +NEW_INSTALLATION = "cbf85060a63dc4433c706d71ec582b0ebe6a09bbe26963ff78acb4c08e5edd92" +RAW_FLOOR_IMAGES = { + "before": "0c805a525322acf4eb03f083c2c763f3046c3d488e1f993beb484a3e2c2ff4a9", + "after": "934d2ae0b305caa364f155cc407c0e8ca479837ba70b906b8f516f67a5cc17b6", +} +SHORTCUT_FILE = "w5664_shortcut10.json.gz" +SHORTCUT_SHA = "ce395afbf5c32be64c4e62389acaf9ce8cf8a9aaaa2fb7a278135bcfa0e635aa" +SHORTCUT_IMAGES = { + "before": "b0f18924be837173ccbbd1b7814a7a9a27228d68ff0dcbaf44a90a2065d0574c", + "after": "2e87911b30d2d6467ceca95c4455f71ac010d7d258af3ff167320763fbccfd84", +} +SHORTCUT_PATCH = """--- a/strong_complex.py ++++ b/strong_complex.py +@@ -8,6 +8,7 @@ + import json + + WORD = "38d2b3a2311a9ba5fee091cc7aa204c7ed95651aec95d75184b2391df090cbfb" ++SHORTCUT_WORD = "668125b34a34c9a59a97bd66a236118d1d32f19b60dcd872b29f7dd690be0c3e" + LAYOUT = "0ce3f9e383fc4bfdd22612b9e34fc9759d97204215937b82d23aec2cedd9b8ee" + ADDITIONAL = "6ff19e063214b1698165d9da1fcd6182d9b837ac2d6e61aa71658b629aabbc95" + GRID = 154113755636630124932500335624192000 +@@ -42,7 +43,14 @@ + graph, _ = reconstruct(parent, read("BANK-FACTORS.json.gz")) + if digest(graph) != WORD or digest(layout) != LAYOUT: + raise ValueError("The reconstructed Gaussian graph or its owner layout differs") +- return graph, layout ++ shortcut = json.loads(gzip.decompress((Path(__file__).resolve().parent / "w5664_shortcut10.json.gz").read_bytes())) ++ if digest(shortcut) != SHORTCUT_WORD: ++ raise ValueError("The shortcut Gaussian graph differs") ++ if any(shortcut[key] != graph[key] for key in ("initial", "final", "frames", "first_output")): ++ raise ValueError("The shortcut word changed an endpoint, chart or output") ++ if (len(graph["moves"]), len(shortcut["moves"])) != (5674, 5664): ++ raise ValueError("The shortcut word does not remove exactly ten transfers") ++ return shortcut, layout + + + def required_pairs(graph, layout): +@@ -85,7 +93,7 @@ + + graph, layout = load_changed(data) + catalogue = native_catalogue(graph, layout) +- if digest(catalogue) != "8a9ff9558bf5fa3854699937fe063f98c86467d5d32a4488bfc878d2be081e70": ++ if digest(catalogue) != "34eef62b6701db0565dce3471f165f4224194ff2782be822774f9c1255553a8d": + raise ValueError("The generated all-column Clifford catalogue differs") + tables = Path(grade) / "retained/data" + bases = read_json(tables / "CALLER-PHASE-BASES.json")["by_q"] +""" +RAW_FLOOR_PATCH = """--- a/raw_binary_stage.py ++++ b/raw_binary_stage.py +@@ -45,7 +45,7 @@ + @cache + def binary_recipe(height): + word = binary_word() +- return Recipe(height, word.tagged.ambient, word.targets, word.paid, word.cells, BINARY_C) ++ return Recipe(height, word.tagged.ambient, word.targets, word.paid, word.cells, BINARY_C, level_floor=1156) +""" + " \n \n def run(recipe, fields, machine):\n" + + +def replace(path, replacements): + source = path.read_text() + for old, new in replacements: + if source.count(old) != 1: + raise ValueError(f"Expected one change point for {old!r} in {path.name}") + source = source.replace(old, new) + path.write_text(source) + + +POSITIVE_DEBIT_PY = '''"""Price the 3-type (1, 2, 3) Gaussian calendar using the exact periodic-integral suffix theorem.""" + +from fractions import Fraction as Q + +from grades import UPPER_DIVISOR, WEIGHTS +from strict_moment import UNIT, power_interval +from unpowered_price import intervals + +BAND_LOWER = 1164 +POSITIVE_DEBIT = Q(32401, 262144) +DELTA = Q(1, 2**128) + + +def certify_loss(recipe, lower): + """Return the exact finite price for this three-type numerical recipe.""" + c = recipe.trial + t = 1 - c + targets = recipe.targets.histogram + paid = recipe.paid.histogram + cells = recipe.cells + assert lower == BAND_LOWER and recipe.ambient == 459 + assert max(targets) == 387 and min(paid) == Q(1, 2) + assert all(w > 0 and 5 * r <= 4 * k for (r, k), w in cells.items()) + assert all(sum(w for (p, k), w in cells.items() if p == r) == 1 for r in paid) + + psi = Q(0) + for (r, k), share in cells.items(): + floor = intervals(k, c)[0] * UNIT // intervals(r, c)[1] + assert floor > UNIT + psi += paid[r] * share * r * (Q(floor, UNIT) - 1) / c + target_axes = sum(count * k for k, count in targets.items()) + assert target_axes == 746688 * (WEIGHTS[0] + 2 * WEIGHTS[1] + 3 * WEIGHTS[2]) + + M = 2**1024 + scale = UPPER_DIVISOR * recipe.ambient // 2 + upper = 2 * (M // (2 * scale)) + assert 4 * max(targets) * (upper - 8) < M and 774 * (upper + 2) < M + assert 7740 <= DELTA * upper + assert (1 - DELTA) * M <= scale * upper + assert upper > 774 * lower and M * DELTA >= 1 + assert t > Q(996, 1000) and power_interval(lower, t)[0] > 1024 * UNIT + assert sum(WEIGHTS) / (t * Q(power_interval(lower, t)[0], UNIT)) + Q(2, M**5) < 2 + assert 2**46 < Q(M**4, 2**132) + assert 2**20 < Q(M**4, 2**132) + assert 2 * 52608 < M + assert 4 * (lower + 2) * 6 < 5 * lower * 5 + assert 2**19 * (upper + lower) ** 77 + lower**77 < (M * lower) ** 77 + + periodic_num = Q(0) + for (r, k), share in cells.items(): + rk_hi = Q(intervals(r, t)[1], intervals(k, t)[0]) + lr2 = int(2 * lower * r) + lkr2 = int(2 * lower * k + 8 * r) + assert Q(lr2, 2) == lower * r and Q(lkr2, 2) == lower * k + 4 * r + rkl_lo = Q(power_interval(lr2, t)[0], power_interval(lkr2, t)[1]) + assert Q(power_interval(lower, t)[1], power_interval(upper, t)[0]) < DELTA + term = (9 * k - 8 * r) * rk_hi - r * rkl_lo + r * DELTA + assert term > 0 + periodic_num += paid[r] * share * term + fringe = periodic_num / (t * psi) + assert fringe < Q("4.55615") + + finite_factor = ( + (1 + DELTA) + * (1 + Q(4 * max(targets), scale)) + * Q(power_interval(scale * lower, c)[1], UNIT) + * (1 + fringe / lower + DELTA) + / (1 - DELTA) ** 4 + ) + assert UNIT * finite_factor < power_interval(2, POSITIVE_DEBIT)[0] + assert UNIT * finite_factor >= power_interval(2, POSITIVE_DEBIT - Q(1, 524288))[1] + return { + "debit": str(POSITIVE_DEBIT), + "lower_band": lower, + "upper_divisor": UPPER_DIVISOR, + "upper_scale": scale, + "weighted_target_axes": target_axes, + "fringe": str(fringe), + "psi_lower": str(psi), + "upper_factor": str(finite_factor), + } +''' + + +RECEIPT_PY = '''"""Compute both signed invoices from the installed 3-type + periodic-suffix source.""" + +from collections import Counter, defaultdict +from fractions import Fraction as Q +import json +from pathlib import Path +import sys + +HERE = Path(__file__).resolve().parent +runtime = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(runtime)) +from upstream import HERE as RAW_DIR, install + +install() +sys.path.append(str(HERE.parent / "tiered-native-multiplier" / "source")) +sys.path.append(str(HERE.parent / "tiered-native-multiplier")) +from activation import resource_receipt +from band_product import prepare_native +from grades import LOWER, SCALES, WEIGHTS +from independent_binary_price import raw_moments +from installations import BINARY_C, GAUSSIAN_C, ENTRY, TERMINAL, activation, at_public +from linear_geometry import entrance_geometry +from ordinary_carrier import stage_for_width_log +from ordinary_clock import first_stage_bound, polynomial_to_fibre_bound +from outer_budget import qualify +from outer_clock import financial_checks +from strict_moment import UNIT, power_interval +from staged_carriers import entrance_logs +from strong_binary import graph, caller +from strong_complex import load_changed, word +from transport import ceil +from unpowered_price import certify, intervals +from check_serial_setup import clock as native_clock + +sys.path.append(str(HERE)) +from positive_debit import certify_loss + +DEBIT = Q(32401, 2**18) +ORDINARY_DEBIT = Q(1418665, 2**20) +ORDINARY_FLOOR = 1156 +CHILD_TARIFF = Q(2401, 1024) + + +def tape_factor_periodic(ambient, rate, lower, paid, cells): + delta = Q(1, 2**128) + t = 1 - rate + psi = sum( + paid[r] * sh * r * (Q(intervals(k, rate)[0], intervals(r, rate)[1]) - 1) / rate + for (r, k), sh in cells.items() + ) + num = Q(0) + for (r, k), sh in cells.items(): + rk_hi = Q(intervals(r, t)[1], intervals(k, t)[0]) + rkl_lo = Q(power_interval(lower * r, t)[0], power_interval(lower * k + 4 * r, t)[1]) + term = (9 * k - 8 * r) * rk_hi - r * rkl_lo + r * delta + num += paid[r] * sh * term + fringe = num / (t * psi) + M = 1 << 1024 + scale = 1024 * ambient + U = 2 * (M // (2 * scale)) + assert 1270 <= delta * U + return ( + Q(256, 255) + * Q(4097, 4096) + * Q(1028, 1024) + * Q(power_interval(scale * lower, rate)[1], UNIT) + * (1 + fringe / lower + delta) + / ((1 - delta) * (1 - delta) ** 3) + ) + + +def raw_counts(base, weights=WEIGHTS, scales=SCALES, splits=1008): + targets = Counter(port.rank for port in base.targets) + paid = Counter(port.rank for port in base.paid) + t, p = Counter(), Counter() + for s, w in zip(scales, weights, strict=True): + for grade, entry in targets.items(): + t[s * grade] += w * entry + for grade, entry in paid.items(): + p[s * grade] += w * entry + p[1] -= splits * weights[0] + p[Q(1, 2)] += 2 * splits * weights[0] + return t, p + + +def total_interval(counts, trial=GAUSSIAN_C): + ends = [0, 0] + for grade, count in counts.items(): + for i, value in enumerate(intervals(grade, 1 - trial)): + ends[i] += count * value + return tuple(Q(value, UNIT) for value in ends) + + +def check_numerical(recipe): + assert SCALES == (1, 2, 3) and WEIGHTS == (1, 45, 2025) + base = word(*load_changed(RAW_DIR / "inputs")) + t, p = raw_counts(base, WEIGHTS, SCALES) + assert (recipe.targets.histogram, recipe.paid.histogram) == (t, p) + types = recipe.types() + for variant, target, paid in zip( + types, recipe.targets.variants, recipe.paid.variants, strict=True + ): + assert Counter(variant.targets) == target.histogram + assert Counter(variant.paid) == paid.histogram + t_lo, t_hi = total_interval(t) + p_lo, p_hi = total_interval(p) + assert t_lo > p_hi and p_lo / t_hi > Q(99, 100) and p_lo > 10 + assert 1 - GAUSSIAN_C > Q(996, 1000) and Q( + power_interval(max(t), GAUSSIAN_C)[1], UNIT + ) < Q(106, 100) + margin, cells = certify(GAUSSIAN_C, (t, p)) + assert margin > 0 and cells == recipe.cells and len(cells) == 71 + prices = recipe.typed_cells() + rows, loads = defaultdict(Q), defaultdict(Q) + min_share = 1 + for (a, r, b, k), share in prices.items(): + count = recipe.targets.variants[b].histogram[k] + unit_share = share / count + assert 5 * r <= 4 * k + rows[a, r] += share + loads[b, k] += ( + WEIGHTS[a] + * recipe.paid.variants[a].histogram[r] + * unit_share + * Q(intervals(r, 1 - GAUSSIAN_C)[1], UNIT) + ) + min_share = min(min_share, unit_share) + assert all( + rows[a, r] == 1 for a, v in enumerate(recipe.paid.variants) for r in v.histogram + ) + for b, variant in enumerate(recipe.targets.variants): + for k in variant.histogram: + assert ( + 0 < loads[b, k] <= WEIGHTS[b] * Q(intervals(k, 1 - GAUSSIAN_C)[0], UNIT) + ) + assert min_share > Q(1, 2**28) + assert prices[2, 168, 2, 387] / recipe.targets.variants[2].histogram[387] == Q( + 1, 624 + ) + assert ( + max( + max(v.numerator.bit_length(), v.denominator.bit_length()) + for v in cells.values() + ) + <= 280 + ) + assert recipe.ambient == 459 and LOWER == 1164 + finite_loss = certify_loss(recipe, LOWER) + assert Q(finite_loss["debit"]) == DEBIT + + # Negative controls: #8073/#8089/#8090 2-type (5, 451) fails new GAUSSIAN_C; and capacity-cut control + old_t, old_p = raw_counts(base, (5, 451), (1, 2)) + try: + old_margin, _ = certify(GAUSSIAN_C, (old_t, old_p)) + except AssertionError: + old_margin = -1 + assert old_margin is None or old_margin <= 0 + assert total_interval(old_t)[1] < total_interval(old_p)[0] + high = total_interval({k: n for k, n in t.items() if k > 2}) + required = total_interval({r: n for r, n in p.items() if 5 * r > 8}) + assert high[0] - required[1] > 90000 + cuts = {"3type": [str(high[0] - required[1]), str(high[1] - required[0])]} + return dict( + trial=str(GAUSSIAN_C), + weights=list(WEIGHTS), + scales=list(SCALES), + real_targets=[len(w.targets) for w in types], + real_loans=[len(w.paid) for w in types], + weighted_targets=t.total(), + weighted_loans=p.total(), + directed_margin=str(margin), + grade_cells=len(cells), + typed_cells=len(prices), + min_individual_share=str(min_share), + raw_loss=str(DEBIT), + finite_loss=finite_loss, + capacity_cut=cuts, + ) + + +def bank(profile): + heights = profile.rank_logs + booked, rates = Q(0), [] + for stage, height in enumerate(heights): + assert height >= 3000 + upper = min(profile.eta, (249 * (BINARY_C - ORDINARY_DEBIT / height) + booked) / 250) + selected = ( + profile.ordinary + if stage + 1 == len(heights) + else Q(int(upper * 10**21) - 1, 10**21) + ) + assert booked < selected < upper + rates.append(str(selected)) + booked = selected + gaussian = GAUSSIAN_C - DEBIT / profile.complex_log + signed = qualify( + profile.kappa, + Q(1, profile.positive_stop_denominator), + profile.ordinary, + gaussian, + ) + stock = resource_receipt(profile) + assert activation(profile) == stock["public_exponent_A"] + cuts = tuple(stock["binary_cuts"]) + assert entrance_logs(heights) == cuts + for i, cut in enumerate(cuts, 1): + assert stage_for_width_log(cut - 1, len(heights), heights) == i - 1 + assert stage_for_width_log(cut, len(heights), heights) == i + assert stage_for_width_log(cut, i - 1, heights) == i - 1 + if min(heights) >= 8192: + assert 1 <= len(heights) <= 7 + # #8076: per-stage envelope grows by 3 per stage for CHILD_TARIFF 2401/1024. + bound = 128 + 3 * len(heights) + 320 * sum(heights) + additions = [] + else: + assert heights == ENTRY.rank_logs + costs = (first_stage_bound(profile.eta), polynomial_to_fibre_bound()) + additions = [ + max(0, e - 944 * h) for e, h in zip(costs, profile.rank_logs, strict=True) + ] + # #8076: charge the square of the new geometric child sum 2401 (+5 entry bits). + bound = 40 + 22 + 16384 * sum(heights) + sum(additions) + expense = max(84500001, 1602 + 220 * profile.complex_log + bound) + return dict( + kappa=str(profile.kappa), + ordinary_H=list(heights), + numerical_H=profile.complex_log, + ordinary_rates=rates, + gaussian_rate=str(gaussian), + signed=signed, + stock=stock, + geometry=entrance_geometry(activation(profile)), + binary_surcharges=additions, + log2_B=bound, + log2_C=expense, + ) + + +def check(): + low, high = prepare_native() + assert low[-1].cells is high[-1].cells and low[-1].targets is high[-1].targets + assert ( + low[0].cells is high[0].cells and low[-1].trial == high[-1].trial == GAUSSIAN_C + ) + target, paid = raw_moments(graph(), caller()) + for profile, recipes in zip((ENTRY, TERMINAL), (low, high), strict=True): + assert tuple(v.rank_log for v in recipes) == ( + *profile.rank_logs, + profile.complex_log, + ) + for ordinary in recipes[:-1]: + assert ordinary.ambient == 134 and ordinary.trial == BINARY_C + assert ordinary.level_floor == ORDINARY_FLOOR + assert (Counter(ordinary.targets), Counter(ordinary.paid)) == (target, paid) + bit_margin, bit_cells = certify(BINARY_C, (target, paid)) + assert bit_margin > 0 and high[0].cells == bit_cells + ordinary_upper = Q("2.5543284") + assert tape_factor_periodic(134, BINARY_C, ORDINARY_FLOOR, paid, bit_cells) * CHILD_TARIFF < ordinary_upper + assert ordinary_upper**1048576 < 2**1418665 + assert Q(75, 32) / CHILD_TARIFF == Q(2400, 2401) + gaussian = check_numerical(high[-1]) + early, late = bank(ENTRY), bank(TERMINAL) + A = activation(TERMINAL) + threshold = (1 << A) + (-pow(2, A, 6)) % 6 + assert at_public(threshold - 6) is ENTRY and at_public(threshold) is TERMINAL + premium = ceil((TERMINAL.kappa - ENTRY.kappa) * A) + cost = 1 + max(early["log2_C"] + premium, late["log2_C"]) + assert cost == 171810078109 and premium == 242079 + assert early["log2_C"] == 125660246 and late["log2_B"] == 171798577106 + ordinary_floor = ORDINARY_DEBIT / (BINARY_C - TERMINAL.ordinary) + positive_floor = DEBIT / (GAUSSIAN_C - TERMINAL.ordinary) + assert (ceil(ordinary_floor), ceil(positive_floor)) == (268290534, 52270) + older = Q(".003900857267786") + ref_8090 = Q(".003900826966095") + ref_8073 = Q(".003898219753506") + ref_8089 = Q("0.0039") + old_gaussian_inf = Q(17145637307, 2**42) + gain = TERMINAL.kappa - older + assert gain == Q(5057431, 10**15) + assert TERMINAL.kappa > older > ref_8090 > ref_8089 > ref_8073 and TERMINAL.kappa > old_gaussian_inf + assert financial_checks()["early_log2_C_bound"] == 84500000 + setup = native_clock() + grade_count = len(low[-1].paid.histogram) + len(low[-1].targets.histogram) + actual_roles = sum(len(v.targets) + len(v.paid) for v in high[-1].types()) + assert actual_roles == 1002096 < 2**20 and grade_count == 72 < 2**8 + assert len(low) + len(high) == 10 and 1 <= len(TERMINAL.rank_logs) <= 7 + assert max(h.bit_length() for h in (*ENTRY.rank_logs, ENTRY.complex_log, *TERMINAL.rank_logs, TERMINAL.complex_log)) == 28 + assert TERMINAL.complex_log < 2**25 and ENTRY.complex_log < 2**25 + # 28-bit indexed setup (see SETUP-28BIT.md): 92*H and 1024*H+(m+1).bit_length() stay strictly below w=2^38. + assert 92 * (2**28 - 1) < 2**38 and 1024 * (2**28 - 1) + (len(TERMINAL.rank_logs) + 1).bit_length() == 274877905923 < 2**38 + assert 2 * 2048 * (2**25 + 1) + 10 * 2**24 == 137606729728 < 2**40 + assert TERMINAL.eta == Q(1, 256) and all(abs(x).bit_length() <= 128 for x in (TERMINAL.eta.numerator, TERMINAL.eta.denominator, TERMINAL.kappa.numerator, TERMINAL.kappa.denominator)) + grade_actions = 2**20 * 256 + 2**8 * 256 * 8 + 32 * (grade_count + 2)**2 + 2**12 + assert grade_actions < 2**32 and setup["all_setup"] < 2**228 + return dict( + gaussian=gaussian, + entry=early, + terminal=late, + previous_rate=str(older), + previous_8090_rate=str(ref_8090), + previous_8073_rate=str(ref_8073), + previous_8089_rate=str(ref_8089), + previous_2type_G_inf_rate=str(old_gaussian_inf), + rate_delta=str(gain), + rate_delta_vs_8073=str(TERMINAL.kappa - ref_8073), + complete_log2_C=cost, + ordinary_floor=ORDINARY_FLOOR, + ordinary_matched_suffix_proof="periodic-integral-disjoint-intervals", + ordinary_finite_debit=str(ORDINARY_DEBIT), + ordinary_reserve="256/255", + ordinary_child_tariff=str(CHILD_TARIFF), + ordinary_child_contraction="2400/2401", + ordinary_child_geometric_sum=2401, + ordinary_entry_clock_extra=5, + ordinary_terminal_clock_extra=3 * len(TERMINAL.rank_logs), + entry_price_surcharge=premium, + fixed_funding_height_floors=[ceil(ordinary_floor), ceil(positive_floor)], + log2_fixed_setup_upper=setup["setup_exponent"], + native_setup_transition_upper=setup["all_setup"], + native_setup_grade_actions=grade_actions, + actual_roles=actual_roles, + grade_count=grade_count, + max_native_H=max(*TERMINAL.rank_logs, ENTRY.complex_log, TERMINAL.complex_log), + ) + + +if __name__ == "__main__": + print(json.dumps(check(), indent=2)) +''' + + +INDEPENDENT_PRICE_PY = '''"""Independently verify 3-type Gaussian & K7 periodic-integral debits on a 192-bit dyadic grid.""" + +from collections import Counter +from fractions import Fraction as Q +from math import ceil, isqrt +from pathlib import Path +import sys + +IMAGE = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(IMAGE)) +from upstream import install + +install() +from band_product import prepare_native +from grades import LOWER, SCALES, UPPER_DIVISOR, WEIGHTS +from independent_binary_price import raw_moments +from installations import BINARY_C, TERMINAL +from strong_binary import caller, graph +from strong_complex import load_changed, word +from unpowered_price import certify + +GRID = 1 << 192 + + +def powers(base, exponent): + assert base > 0 and 0 < exponent < 1 + assert exponent.denominator.bit_count() == 1 + number = Q(base) * GRID + low, high = number.__floor__(), ceil(number) + lower_result = upper_result = GRID + for bit in range(exponent.denominator.bit_length() - 2, -1, -1): + low = isqrt(low * GRID) + high = isqrt(high * GRID - 1) + 1 + if exponent.numerator >> bit & 1: + lower_result = lower_result * low // GRID + upper_result = ceil(Q(upper_result * high, GRID)) + return Q(lower_result, GRID), Q(upper_result, GRID) + + +def weighted(): + recipe = prepare_native(TERMINAL)[-1] + c = recipe.trial + t = 1 - c + assert SCALES == (1, 2, 3) and WEIGHTS == (1, 45, 2025) and LOWER == 1164 + psi = sum( + recipe.paid.histogram[r] * share * r * (powers(Q(k, r), c)[0] - 1) / c + for (r, k), share in recipe.cells.items() + ) + delta = Q(1, 2**128) + num = Q(0) + for (r, k), share in recipe.cells.items(): + rk_hi = powers(Q(r, k), t)[1] + rkl_lo = powers(Q(LOWER * r, LOWER * k + 4 * r), t)[0] + num += recipe.paid.histogram[r] * share * ((9 * k - 8 * r) * rk_hi - r * rkl_lo + r * delta) + fringe = num / (t * psi) + assert psi > Q("6293598593") and fringe < Q("4.55615") + scale = UPPER_DIVISOR * recipe.ambient // 2 + upper = ( + (1 + delta) + * (1 + Q(4 * 387, scale)) + * powers(scale * LOWER, c)[1] + * (1 + fringe / LOWER + delta) + / (1 - delta) ** 4 + ) + lower = powers(2, Q(32401, 262144))[0] + finer_upper = powers(2, Q(64801, 524288))[1] + assert lower > upper and upper >= finer_upper + # Negative control: naive 10*k suffix charge at (LOWER=1164, scale=395658) fails 32401/262144 + axes = sum(k * n for k, n in recipe.targets.histogram.items()) + naive_fringe = 10 * axes / (t * sum(recipe.paid.histogram[r] * sh * r * (powers(Q(k, r), c)[1] - 1) / c for (r, k), sh in recipe.cells.items())) + naive_lo = ((1 + delta) * (1 + Q(4 * 387, scale)) * powers(scale * LOWER, c)[0] * (1 + naive_fringe / LOWER + delta) / (1 - delta) ** 4) + assert naive_lo > powers(2, Q(32401, 262144))[1] + + +def ordinary_debit(): + bt, bp = raw_moments(graph(), caller()) + margin, cells = certify(BINARY_C, (bt, bp)) + assert margin > 0 + c = BINARY_C + t = 1 - c + delta = Q(1, 2**128) + lower = 1156 + psi = sum(bp[r] * sh * r * (powers(Q(k, r), c)[0] - 1) / c for (r, k), sh in cells.items()) + num = sum( + bp[r] * sh * ((9 * k - 8 * r) * powers(Q(r, k), t)[1] - r * powers(Q(lower * r, lower * k + 4 * r), t)[0] + r * delta) + for (r, k), sh in cells.items() + ) + fringe = num / (t * psi) + child_tariff = Q(2401, 1024) + predecessor_tariff = Q(47, 20) + hi = ( + child_tariff + * Q(256, 255) + * Q(4097, 4096) + * Q(1028, 1024) + * powers(1024 * 134 * lower, c)[1] + * (1 + fringe / lower + delta) + / ((1 - delta) ** 4) + ) + lo = ( + child_tariff + * Q(256, 255) + * Q(4097, 4096) + * Q(1028, 1024) + * powers(1024 * 134 * lower, c)[0] + * (1 + fringe / lower + delta) + / ((1 - delta) ** 4) + ) + allowance_lo = 2 * powers(2, Q(370089, 2**20))[0] # 1418665/2^20 = 1 + 370089/2^20 + finer_hi = 2 * powers(2, Q(370088, 2**20))[1] # 1418664/2^20 fails! + assert allowance_lo - hi > 0 and lo > finer_hi + assert Q(75, 32) / child_tariff == Q(2400, 2401) + assert Q(1418665, 2**20) < Q(1420718, 2**20) < Q(1424116, 2**20) < Q(1430037, 2**20) < Q(11178, 8192) < Q(11204, 8192) + assert Q(1, 1 - Q(75, 32) / predecessor_tariff) == 376 and Q(1, 1 - Q(75, 32) / child_tariff) == 2401 + print("PASS_INDEPENDENT_PERIODIC_DEBITS", "ord=1418665/2^20", "pos=32401/262144", "2400/2401", "reserve=256/255", flush=True) + + +def rounded_peer(): + raw = word(*load_changed(IMAGE / "inputs")) + + def scales(ports): + single = Counter(port.rank for port in ports) + combined = single.copy() + combined.update({8 * rank: count for rank, count in single.items()}) + return combined + + targets, paid = scales(raw.targets), scales(raw.paid) + paid[1] -= 1006 + paid[Q(1, 4)] += 1006 + paid[Q(3, 4)] += 1006 + assert (targets.total(), paid.total()) == (105216, 563182) + c = Q(4286126377, 2**40) + endpoints = {r: powers(r, 1 - c) for r in (targets | paid)} + + def mass(rows, index): + return sum(n * endpoints[r][index] for r, n in rows) + + tlo, thi = (mass(targets.items(), i) for i in (0, 1)) + plo, phi = (mass(paid.items(), i) for i in (0, 1)) + assert tlo > phi and plo / thi > Q(99, 100) + for rank in sorted(paid)[1:]: + load = mass(((r, n) for r, n in paid.items() if r >= rank), 1) + cap = mass(((k, n) for k, n in targets.items() if 5 * rank <= 4 * k), 0) + assert load <= cap * plo / thi + delta, lower = Q(1, 2**128), 32768 + factor = ( + Q(256, 255) + * Q(4097, 4096) + * Q(1028, 1024) + * powers(1024 * 1224 * lower, c)[1] + * (1 + Q(64, lower) + delta) + / ((1 - Q(10, lower)) * (1 - delta) ** 3) + ) + assert factor**256 < 2**39 + peer_8073 = Q(".003898219753506") + peer_8088 = Q(".003899574328473") + peer_8089 = Q("0.0039") + peer_8090 = Q(".003900826966095") + peer_8094 = Q(".003900857267786") + inf_8073 = Q(17145637307, 2**42) + assert TERMINAL.kappa - peer_8094 == Q(5057431, 10**15) + assert TERMINAL.kappa - peer_8073 == Q(2642571711, 10**15) + assert TERMINAL.kappa > peer_8094 > peer_8090 > peer_8089 > peer_8088 > inf_8073 > peer_8073 + + +if __name__ == "__main__": + if not __debug__: + raise ValueError("Run with assertions enabled") + weighted() + ordinary_debit() + rounded_peer() + print("PASS_INDEPENDENT_3TYPE_AND_PERIODIC_PRICES") +''' + + +CHECK_PLACEMENT_PY = '''"""Check the true 3-type weighted Gaussian exterior owner [2, 168, 2, 387] at both installed ranks.""" + +from fractions import Fraction as Q +from itertools import islice +import json +from pathlib import Path +import sys + +RUNTIME = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(RUNTIME)) +from upstream import install + +install() +from upstream import HERE + +_, _, _, source = install() +from strong_complex import artifacts +from clock_ports import clock_word +from grades import numerical_recipe, LOWER, UPPER_DIVISOR, WEIGHTS +from installations import ENTRY, TERMINAL, GAUSSIAN_C +from unpowered_price import certify +from periodic import Job +from raw48 import ComplexRaw +from transport import axes, ceil + +A = artifacts(source / "research/grade14-native-realization", HERE / "inputs") +w = clock_word(A) +recipe = numerical_recipe(TERMINAL.complex_log) +targets, paid = recipe.targets, recipe.paid +c = GAUSSIAN_C +margin, flows = certify(c, (targets.histogram, paid.histogram)) +assert margin > 0 and flows == recipe.cells and flows[168, 387] == 1 +assert paid.variants[0].histogram[168] == 0 and paid.variants[1].histogram[168] == 0 and paid.variants[2].histogram[168] > 0 +assert ( + targets.variants[0].histogram[387] == 0 + and targets.variants[1].histogram[387] == 0 + and targets.variants[2].histogram[387] == 624 +) +pi = flows[168, 387] * WEIGHTS[2] / targets.histogram[387] +assert pi == Q(1, 624) +roots = tuple( + p.tag for p in w.targets if p.rank == 129 and p.tag[:2] == ("root", "rotated") +) +assert len(roots) == 384 + + +class Column: + window = 1 + swap = None + + +class Field: + def __init__(self): + self.swaps = [] + + def swap(self, l, r, n, service): + self.swaps.append((l, r, n)) + + +out = [] +for H in (ENTRY.complex_log, TERMINAL.complex_log): + M = 1 << H + scale = UPPER_DIVISOR * recipe.ambient // 2 + assert UPPER_DIVISOR == 1724 and scale == 395658 + U = 2 * (M // (2 * scale)) + e = 2 * (3 * U // 8) + lo, hi = Q(e * 387, 168), Q((e + 2) * 387, 168) + assert LOWER < e < U < lo < hi < M + assert WEIGHTS[2] * (hi - lo) * M * pi > 4 + size = 387 * (e - 8) + period = 4 * ceil(Q(M, 4 * size)) + tickets = tuple(islice(axes(M, size, period, 0), 3)) + f = Field() + raw = ComplexRaw(A, {}, Column(), low=0, bundle=1, slots=M) + raw.align(f, Job(0, tickets), tuple(range(3))) + assert period == 1364 and tickets == (0, 272, 545) and f.swaps[0] == (1, 272, 1) + out.append( + dict( + H=H, + cell=[2, 168, 2, 387], + share=str(pi), + rotated_roots=len(roots), + first_root=roots[0], + period=period, + tickets=tickets, + first_swap=f.swaps[0], + ) + ) +print(json.dumps(out, indent=2)) +''' + + +CHECK_CALENDAR_PY = '''"""Exercise 3-type cross-type loans across all three kinds on real dirty finite chart records.""" + +from fractions import Fraction as Q +from random import Random +from pathlib import Path +import sys + +RUNTIME = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(RUNTIME)) +from upstream import install + +install() +from check_band import Chart, ChartJob +from periodic import Rule +from typed_transport import NativeType, TypedPlan, decode_header + + +def run(): + a = Rule(2, (2,), (1, 1)) + b = Rule(2, (2, 2), (1, 1, 1, 1)) + c = Rule(2, (2,), (1, 1)) + types = tuple(NativeType(s.targets, s.paid, m) for s, m in ((a, 1), (b, 2), (c, 3))) + shares = { + (0, 1, 1, 2): Q(1), + (1, 1, 0, 2): Q(1, 7), + (1, 1, 1, 2): Q(3, 7), + (1, 1, 2, 2): Q(3, 7), + (2, 1, 0, 2): Q(1, 7), + (2, 1, 1, 2): Q(3, 7), + (2, 1, 2, 2): Q(3, 7), + } + p = TypedPlan( + 192, + types, + shares, + Q(1), + 10, + 30, + 1200, + 5, + 16, + delay_base=4, + scale_step=Q(2), + padding=1, + ) + edges = {(kind, r.kind) for (e, kind, j), xs in p.send.items() for r in xs} + assert (0, 1) in edges and (1, 2) in edges and (2, 0) in edges + ca = Chart(a, ((1, 1),), p.n) + cb = Chart(b, ((1, 1), (1, 1)), p.n) + cc = Chart(c, ((1, 1),), p.n) + cb.data, cb.chart = ca.data, ca.chart + cc.data, cc.chart = ca.data, ca.chart + + class Machine: + zero = staticmethod(ca.zero) + leaf = staticmethod(ca.leaf) + retire_zero = staticmethod(ca.retire_zero) + + @staticmethod + def native(ports, tagged): + cols, kind = decode_header(tagged) + return (ca, cb, cc)[kind].native(ports, cols) + + rand = Random(8582) + rows = [] + initial = {} + for i in range(p.width): + row = ChartJob(i, tuple(rand.sample(range(p.n), p.n)), 0) + rows.append(row) + initial[i] = [rand.randrange(17) for _ in range(p.n)] + ca.data[i] = initial[i].copy() + ca.chart[i] = 0 + p.run(rows, Machine()) + assert ca.data == {i: [(4 * x) % 17 for x in row] for i, row in initial.items()} + assert ( + not any(ca.chart.values()) + and ca.freed == ca.serial + and ca.raw + and cb.raw + and cc.raw + and ca.noncommuting + and cb.noncommuting + and cc.noncommuting + ) + z = -(-p.width // p.source_width) + assert ca.leaves == z * p.rounds * p.leaves_per_epoch + assert p.width != p.source_width + print( + "PASS_THREE_NATIVE_TYPES", + p.width, + p.source_width, + z, + (ca.raw, cb.raw, cc.raw), + ca.leaves, + (ca.noncommuting, cb.noncommuting, cc.noncommuting), + ca.freed, + sorted(edges), + ) + + +if __name__ == "__main__": + run() +''' + + +CHECK_OWNERSHIP_PY = '''"""Check independent 3-type source numbering, deadlines and return of all borrowed owners.""" + +from fractions import Fraction as Q +from collections import Counter +import json +from pathlib import Path +import sys + +RUNTIME = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(RUNTIME)) +from upstream import install + +install() +from typed_transport import TypedPlan, NativeType, decode_header + + +def run(w0, w1, w2, ticks, lower, upper, volume, n, rounds, delay): + types = ( + NativeType((2,), (1, 1), w0), + NativeType((2, 2), (1, 1, 1, 1), w1), + NativeType((2,), (1, 1), w2), + ) + rem = 2 * w1 + w2 + shares = { + (0, 1, 1, 2): Q(1), + (1, 1, 0, 2): Q(w0, rem), + (1, 1, 1, 2): Q(2 * w1 - w0, rem), + (1, 1, 2, 2): Q(w2, rem), + (2, 1, 0, 2): Q(w0, rem), + (2, 1, 1, 2): Q(2 * w1 - w0, rem), + (2, 1, 2, 2): Q(w2, rem), + } + p = TypedPlan( + n, + types, + shares, + Q(1), + lower, + upper, + volume, + ticks, + rounds, + delay_base=delay, + scale_step=Q(2), + padding=1, + ) + M = max(p.count.values()) + bands = len(p.bands) + + def frame_info(ident): + packed, rep = divmod(ident, M) + packed, typ = divmod(packed, len(types)) + birth, offset = divmod(packed, bands) + band = lower + 2 * offset + assert rep < p.count[(band, typ)] + return typ, birth, band, rep + + ext = sorted( + (src.base, src.base + src.count * ticks * (rounds // src.period), src) + for group in p.sources.values() + for src in group + if rounds // src.period + ) + end = 0 + for lo, hi, src in ext: + assert lo == end and lo < hi + end = hi + assert end == p.source_width + opened = {} + borrowers = {} + serials = {} + kinds = Counter() + transfers = Counter() + flats = external = zero = last = peak = depth = close_on_due = child_tail = 0 + periods = Counter() + for rec in p.events(): + op, ident, *xs = rec + kind, birth, e, rep = frame_info(ident) + w = types[kind] + step = p.delay[e] + if op == 0: + assert ident not in opened + cols, dkind = decode_header(xs[0]) + assert (cols, dkind) == (e - 8, kind) + tick = birth + it = iter(xs[1:]) + origins = [] + d = 1 + for k in w.targets: + tag = next(it) + if tag == 1: + par, expected, t0, pkind = serials.pop(next(it)) + assert ( + t0 == tick and par not in borrowers and expected == k * (e - 8) + ) + borrowers[par] = ident + origins.append(par) + d = max(d, opened[par][2] + 1) + transfers[pkind, kind] += 1 + elif tag == 2: + base, size, period = next(it), next(it), next(it) + assert size == k * (e - 8) and period == 4 * (-(-n // (4 * size))) + assert 0 <= base <= base + rounds // period <= p.source_width + if rounds >= period: + external += 1 + periods[period] += 1 + else: + assert tag == 0 and next(it) == k * (e - 8) + zero += 1 + assert next(it, None) is None + opened[ident] = [0, origins, d] + peak = max(peak, len(opened)) + depth = max(depth, d) + elif op == 1: + j, parents, d = opened[ident] + tick = birth + step * j + assert ident not in borrowers + serial, size, sel = xs + assert size == (e - 8) * w.paid[j] and sel <= size + if sel: + serials[serial] = (ident, sel, tick, kind) + flats += size - sel + if tick >= ticks: + child_tail += int(sel != 0) + opened[ident][0] += 1 + else: + j, parents, d = opened.pop(ident) + assert j == len(w.paid) and ident not in borrowers + tick = birth + step * j + for par in parents: + assert borrowers.pop(par) == ident + pk, pb, pe, pr = frame_info(par) + assert p.delay[pe] >= step + due = pb + opened[par][0] * p.delay[pe] + assert tick <= due + close_on_due += int(tick == due) + kinds[kind] += 1 + assert tick >= last, (tick, last, op, e, kind) + last = tick + assert flats == p.leaves_per_epoch and not ( + opened or borrowers or serials or child_tail + ) + assert kinds == Counter( + {a: ticks * sum(v for (e, b), v in p.count.items() if b == a) for a in range(len(types))} + ) + assert depth <= 1 + max(b.bit_length() for b in p.bands) + return dict( + weights=(w0, w1, w2), + raw_frames=sum(kinds.values()), + directed_bindings={str(k): v for k, v in transfers.items()}, + depth=depth, + peak_simultaneous_frames=peak, + external_opens=external, + zeros=zero, + external_rows=end, + positive_periods=sorted(periods), + leaf_axes=flats, + same_tick_return_before_next_loan=close_on_due, + ) + + +out = [ + run(1, 3, 5, 12, 10, 82, 1700, 1024, 96, 4), + run(1, 45, 2025, 8, 10, 42, 450, 384, 32, 4), +] +print(json.dumps(out, indent=2)) +''' + + +CHECK_EXTERIOR_PY = '''"""Run all three first independent exterior births through the actual 3-type decoder and Raw48.""" + +from collections import Counter, defaultdict +from functools import cache +from fractions import Fraction as Q +from pathlib import Path +import sys + +RUNTIME = Path(sys.argv[1]).resolve() +sys.path.insert(0, str(RUNTIME)) +from upstream import install + +install() +from band_product import production_supplier +from installations import GAUSSIAN_C +from periodic import Job +from transport import Measure, Source, ceil, axes +from unpowered_price import certify +from typed_transport import TypedPlan +from typed_raw import TypedRaw + +sys.path.append(str(Path(__file__).resolve().parent)) +from check_raw import Axes, WitnessRaw, RayField, basis, final_ray, rot + + +def run(): + M = 8192 + L = 10 + U = 12 + V = 2**48 + R = M + K = 1 + c = GAUSSIAN_C + dens = Measure(1 - c, V, 64 * M.bit_length()) + producer = production_supplier(1024, 10**18) + a, w = producer.physical, producer.word + types = producer.recipe.types() + assert len(types) == 3 + hist_t = Counter() + hist_p = Counter() + ids = defaultdict(list) + for t, spec in enumerate(types): + for i, k in enumerate(spec.targets): + hist_t[k] += spec.multiplicity + ids[t, k].append(i) + for r in spec.paid: + hist_p[r] += spec.multiplicity + _, cells = certify(c, (hist_t, hist_p)) + assert cells == producer.recipe.cells + assert 4 * U < 5 * L + + class FirstReplicas(TypedPlan): + """Project three independent exterior births from the single test bin.""" + + def __init__(self): + self.n, self.types, self.ticks, self.rounds, self.bands = ( + M, + types, + K, + R, + range(L, U, 2), + ) + self.delay = {L: 1} + self.count = {(L, kind): 1 for kind in range(len(types))} + self.sources, self.receive, self.send = {}, {}, {} + + p = FirstReplicas() + full_counts = tuple(ceil(spec.multiplicity * dens.mass(L, U)[1]) for spec in types) + first = set() + base = 0 + for kind, spec in enumerate(types): + chunks = {r: [] for r in set(spec.paid)} + for (r, k), share in cells.items(): + if r not in chunks: + continue + left = max(U, Q(L * k, r)) + right = Q(U * k, r) + mass = dens.mass(left, right)[0] + for b, other in enumerate(types): + if not ids[b, k]: + continue + grant = int( + spec.multiplicity * mass * share * other.multiplicity / hist_t[k] + ) + size = (L - 8) * k + period = 4 * ceil(Q(M, 4 * size)) + if grant: + chunks[r].append((b, k, grant, period)) + sizes = { + r: sum(len(ids[b, k]) * grant * (R // period) for b, k, grant, period in cs) + for r, cs in chunks.items() + } + for r in spec.paid: + if any((b, k) not in first for b, k, grant, period in chunks[r]): + current = base + for b, k, grant, period in chunks[r]: + for i in ids[b, k] if (b, k) not in first else (): + p.sources[L, b, i] = [Source(0, grant, current, period)] + current += grant * (R // period) + if (b, k) in first: + current += len(ids[b, k]) * grant * (R // period) + first.add((b, k)) + assert current == base + sizes[r] + base += sizes[r] + assert len(p.sources) == sum(len(s.targets) for s in types) + p.source_width = base + p.width = 1 << (4096 * base - 1).bit_length() + assert min(full_counts) > 1 + clock, call = next( + (i, row[1]) for i, row in enumerate(a.instructions()) if row[0] == "NATIVE" + ) + pawn = next( + i for i, tag in enumerate(w.targets) if tag.tag == ("helper", clock, call, 1544) + ) + true = {} + stock = [0, 0] + fields = {} + for kind, s in enumerate(types): + for i, k in enumerate(s.targets): + [ext] = p.sources[L, kind, i] + owner = ext.base + assert owner not in fields + fields[owner] = RayField(stock) + true[owner] = (2 * k, ext.period) + + @cache + def placement(size, period): + seq = tuple(axes(M, size, period, 0)) + claimed = set(seq) + assert len(claimed) == size + reverse = [0] * M + for j, q in enumerate(seq): + reverse[q] = j + pos = size + for q in range(M): + if q not in claimed: + reverse[q] = pos + pos += 1 + assert pos == M + return tuple(reverse) + + class Rows: + def __getitem__(self, i): + return Job(i, placement(*true[i])) + + expected = {} + for kind, s in enumerate(types): + cols = 2 * (1 + kind) + [e] = p.sources[L, kind, pawn] + origins = tuple((37 * i + 11 + 17 * kind) % 512 for i in range(cols)) + z = ((3 if not kind else -7 + kind) << 2048, (5 if not kind else 2 + kind) << 2048) + fields[e.base].data = z, tuple(basis(i) for i in origins) + output = tuple(final_ray(i) for i in origins) + z = rot(z, sum(phase for v, phase in output)) + expected[e.base] = ( + (z[0] // 16**cols, z[1] // 16**cols), + tuple(v for v, phase in output), + ) + physical = WitnessRaw(a, fields, Axes(), low=0, bundle=1, slots=M) + adapter = TypedRaw(w, physical) + bills = [0, 0] + + class Machine: + native = staticmethod(adapter.native) + + def leaf(self, job): + (i,) = job.axes + bills[0] += 1 + f = fields[job.owner] + if f.data is not None: + f.paid(i) + bills[1] += 1 + + @staticmethod + def zero(exemplar): + raise AssertionError( + "All tested genuine first replicas received exterior fields" + ) + + retire_zero = staticmethod(physical.retire) + + p.decode(Rows(), 0, 0, Machine(), p.events()) + assert ( + bills[0] == p.leaves_per_epoch + and {i: f.data for i, f in fields.items() if f.data is not None} == expected + ) + assert len(fields) == sum(len(s.targets) for s in types) and all( + f.writes and f.live for f in fields.values() + ) + for f in fields.values(): + f.retire() + assert stock[0] == 0 + print( + "PASS_EXTERIOR_3TYPE_RAW", + full_counts, + p.source_width.bit_length(), + len(fields), + sum(len(s.paid) for s in types), + bills, + stock, + flush=True, + ) + + +if __name__ == "__main__": + run() +''' + + +EDITS = { + "bootstrap.py": ( + ( + 'for name in ("grades.py", "typed_raw.py", "typed_transport.py"):', + 'for name in ("grades.py", "typed_raw.py", "typed_transport.py", "w5664_shortcut10.json.gz"):', + ), + ), + "runtime.patch": ( + ("+GAUSSIAN_C = Q(17145637167, 2**42)", "+GAUSSIAN_C = Q(17166573920, 2**42)"), + ('+TERMINAL = Profile((8192, 129414, 524288), 483871, Q(".00389821"))', + '+TERMINAL = Profile((8192, 63614, 1005821, 15903360, 251454111, 268435455), 52270, Q(".003900862325217"), Q(1, 256))'), + ), + "typed_transport.py": ( + ( + '''def column_header(columns, kind): + """Write the type in the low bit of a positive even column count.""" + if columns < 2 or columns % 2 or kind not in (0, 1): + raise ValueError("Invalid two-type column descriptor") + return columns + kind''', + '''def column_header(columns, kind): + """Pack type kind (0, 1, or 2) into the low two bits of a positive even column count.""" + if columns < 2 or columns % 2 or kind not in (0, 1, 2): + raise ValueError("Invalid typed column descriptor") + return (columns << 1) + kind + + +def decode_header(header): + """Recover columns and native type kind from a packed column header.""" + kind = header & 3 + columns = (header >> 2) << 1 + if columns < 2 or kind not in (0, 1, 2): + raise ValueError("Invalid packed typed column header") + return columns, kind''', + ), + ( + "if len(types) != 2 or lower <= 8 or upper <= lower or lower % 2 or upper % 2:", + "if len(types) not in (2, 3) or lower <= 8 or upper <= lower or lower % 2 or upper % 2:", + ), + ( + " (birth * span + (e - self.bands.start) // 2) * 2 + a", + " (birth * span + (e - self.bands.start) // 2) * len(self.types) + a", + ), + ), + "typed_raw.py": ( + ( + """ kind = header % 2 + columns = header - kind + if columns <= 0 or len(ports) != len(self.word.targets): + raise ValueError("Every raw type needs a complete positive even-width job") + if len({p.owner for p in ports}) != len(ports): + raise ValueError("Two productive ports share a live field") + width = columns * (1 + kind)""", + """ kind = header & 3 + columns = (header >> 2) << 1 + if columns <= 0 or columns % 2 or kind not in (0, 1, 2) or len(ports) != len(self.word.targets): + raise ValueError("Every raw type needs a complete positive even-width job") + if len({p.owner for p in ports}) != len(ports): + raise ValueError("Two productive ports share a live field") + width = columns * (1 + kind)""", + ), + ), + "grades.py": ( + ("WEIGHTS = (1, 90)", "WEIGHTS = (1, 45, 2025)"), + ("SCALES = (1, 2)", "SCALES = (1, 2, 3)"), + ("LOWER = 2048", "LOWER = 1164\nUPPER_DIVISOR = 1724"), + ( + """ self.variants = ( + GradeVariant(ports, raw, 1, splits), + GradeVariant(ports, raw, 2, 0), + )""", + " self.variants = tuple(GradeVariant(ports, raw, s, splits if s == 1 else 0) for s in SCALES)", + ), + ("2048 * self.ambient", "UPPER_DIVISOR * self.ambient"), + ( + "return WeightedRecipe(rank_log, 2 * word.ambient, targets, paid, cells, GAUSSIAN_C)", + "return WeightedRecipe(rank_log, max(SCALES) * word.ambient, targets, paid, cells, GAUSSIAN_C)", + ), + ), + "check_raw.py": ( + ("from typed_raw import TypedRaw", "from typed_raw import TypedRaw\nfrom typed_transport import column_header"), + ( + "for kind, (spec, cols) in enumerate(zip(types, (2, 4))):", + "for kind, (spec, cols) in enumerate(zip(types, (2, 4, 6))):", + ), + ( + "raw = WitnessRaw(a, fields, Axes(), low=0, bundle=1, slots=2 * 306)", + "raw = WitnessRaw(a, fields, Axes(), low=0, bundle=1, slots=2 * 459)", + ), + ( + "it = TypedRaw(w, raw).native(jobs, 2 + kind)", + "it = TypedRaw(w, raw).native(jobs, column_header(2, kind))", + ), + ), + "check_nested.py": ( + ("from typed_raw import TypedRaw", "from typed_raw import TypedRaw\nfrom typed_transport import column_header"), + ( + " * cells[1, 2]\n * 90", + " * cells[1, 2]\n * types[0].multiplicity\n * types[1].multiplicity", + ), + ( + "share == cells[1, 2] * 90 / t[2]", + "share == cells[1, 2] * types[1].multiplicity / t[2]", + ), + ( + "and grant.numerator // grant.denominator == 899557645", + "and 400_000_000 < grant.numerator // grant.denominator < 500_000_000", + ), + ( + "assert cells[1, 2] > Q(99, 100) and 24 * 1 == 12 * 2", + "assert cells[1, 2] > Q(1, 2) and cells[1, 3] > Q(2, 5) and 24 * 1 == 12 * 2 == 8 * 3", + ), + ( + " op = method.native(rows, P)", + " op = method.native(rows, column_header(P, 0))", + ), + ( + " call2 = method.native(cr, S // 2 + 1)", + " call2 = method.native(cr, column_header(S // 2, 1))", + ), + ( + ' assert stock[0] == 0 and uses[1] > 0', + ' # Exercise second cross-type loan: Type 1 (cols=8 -> width=16) -> Type 2 (k=3, S=24 -> cols=8, kind=2)\n' + ' grant12 = Measure(1 - C, 2**48, 64 * n.bit_length()).mass(24, 26)[0] * cells[2, 3] * types[1].multiplicity * types[2].multiplicity / t[3]\n' + ' assert grant12 > 0 and system.recipe.typed_cells()[1, 2, 2, 3] > 0\n' + ' child2 = next(i for i, k in enumerate(word.targets) if k.rank == 1 and k.tag == ("helper", 9977, 0, 1315))\n' + ' assert child2 == 10611\n' + ' big1, small2 = types[1], types[2]\n' + ' rows3 = [Job(i, range(8 * k)) for i, k in enumerate(big1.targets)]\n' + ' fields3 = {i: ProductField(stock) for i in range(2 * len(word.targets))}\n' + ' fields3[pawn].data = z, (initial(x0),) * lanes\n' + ' exp3 = fields3[pawn].copy()\n' + ' for i in range(8 * 16):\n' + ' exp3.paid(i)\n' + ' phys3 = ComplexRaw(art, fields3, Axes(), low=0, bundle=1, slots=n)\n' + ' meth3 = TypedRaw(word, phys3)\n' + ' op3 = meth3.native(rows3, column_header(8, 1))\n' + ' u3 = [0, 0]\n' + ' lent3 = False\n' + ' for r3 in big1.paid:\n' + ' job3 = next(op3)\n' + ' f3 = fields3[job3.owner]\n' + ' if lent3 or r3 < 4 or f3.data is None:\n' + ' for ax in job3.axes:\n' + ' f3.paid(ax)\n' + ' continue\n' + ' lent3 = True\n' + ' assert len(job3.axes) == 8 * r3 and tuple(job3.axes[:24]) == tuple(range(24))\n' + ' for ax in job3.axes[24:]:\n' + ' f3.paid(ax)\n' + ' pref3 = job3.select(range(24))\n' + ' due3 = f3.copy()\n' + ' for ax in pref3.axes:\n' + ' due3.paid(ax)\n' + ' cr3 = [Job(i + len(word.targets), range(8 * k)) for i, k in enumerate(small2.targets)]\n' + ' cr3[child2] = pref3\n' + ' call3 = meth3.native(cr3, column_header(8, 2))\n' + ' for g3 in small2.paid:\n' + ' ln3 = next(call3)\n' + ' ow3 = fields3[ln3.owner]\n' + ' assert len(ln3.axes) == 8 * g3\n' + ' if ow3.data is not None:\n' + ' u3[1] += 1\n' + ' for ax in ln3.axes:\n' + ' ow3.paid(ax)\n' + ' u3[0] += 1\n' + ' assert next(call3, None) is None and f3.data == due3.data\n' + ' due3.retire()\n' + ' assert next(op3, None) is None and lent3 and fields3[pawn].data == exp3.data and u3[1] > 0\n' + ' exp3.retire()\n' + ' for f3 in fields3.values():\n' + ' f3.retire()\n' + ' assert stock[0] == 0 and uses[1] > 0', + ), + ), + "verify.py": ( + ( + '("check_calendar.py", "check_ownership.py")', + '("check_calendar.py", "check_ownership.py", "check_cutoff.py", "check_stage_seam.py", "check_ordinary_floor.py")', + ), + ( + "recipe.ambient == 306\n and len(recipe.cells) == 51", + "recipe.ambient == 459\n and len(recipe.cells) == 71", + ), + ), +} + + +def materialize(package): + from pathlib import Path + + word_bytes = (Path(__file__).resolve().parent / SHORTCUT_FILE).read_bytes() + if sha256(word_bytes).hexdigest() != SHORTCUT_SHA: + raise ValueError("The shortcut word archive differs") + (package / SHORTCUT_FILE).write_bytes(word_bytes) + for name, replacements in EDITS.items(): + replace(package / name, replacements) + (package / "positive_debit.py").write_text(POSITIVE_DEBIT_PY) + (package / "receipt.py").write_text(RECEIPT_PY) + (package / "independent_price.py").write_text(INDEPENDENT_PRICE_PY) + (package / "check_placement.py").write_text(CHECK_PLACEMENT_PY) + (package / "check_calendar.py").write_text(CHECK_CALENDAR_PY) + (package / "check_ownership.py").write_text(CHECK_OWNERSHIP_PY) + (package / "check_exterior.py").write_text(CHECK_EXTERIOR_PY) + with (package / "runtime.patch").open("a") as patch: + patch.write(RAW_FLOOR_PATCH) + patch.write(SHORTCUT_PATCH) + path = package / "SOURCES.json" + pins = json.loads(path.read_bytes()) + pins["runtime_images"]["installations.py"]["after"] = NEW_INSTALLATION + pins["runtime_images"]["raw_binary_stage.py"] = RAW_FLOOR_IMAGES + pins["runtime_images"]["strong_complex.py"] = SHORTCUT_IMAGES + for name in ("runtime.patch", "typed_raw.py", "typed_transport.py", "grades.py", SHORTCUT_FILE): + pins["local_sources"][name] = sha256((package / name).read_bytes()).hexdigest() + pins["runtime_images"]["grades.py"]["after"] = pins["local_sources"]["grades.py"] + path.write_text(json.dumps(pins, indent=2) + "\n") diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/verify.py b/research/p104-10shortcut-child-tariff/source/peer8097/verify.py new file mode 100644 index 0000000000..0d44eca826 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/peer8097/verify.py @@ -0,0 +1,86 @@ +"""Restore authenticated public inputs, apply 10-shortcut w5664 + 3-type + periodic-suffix + 28-bit 6-stage edits, and replay a signed mode.""" +from argparse import ArgumentParser +from hashlib import sha256 +import json +from pathlib import Path +import runpy +from subprocess import run +import sys +import tarfile +from tempfile import TemporaryDirectory + +HERE = Path(__file__).resolve().parent +HEAD = "cbe847a953b971f9c6c5a0a6661e2008acd29086" +SOURCE_SHA = "798c2e6394c258986484a116198cc542a6d2b4c1f289e5816de2cfecf5141c51" + + +def unique_object(pairs): + result = {} + for name, value in pairs: + if name in result: + raise ValueError(f"Repeated source key {name}") + result[name] = value + return result + + +def restore(tree): + source = (HERE / "PEER-SOURCE.json").read_bytes() + if sha256(source).hexdigest() != SOURCE_SHA: + raise ValueError("Peer source manifest differs") + pins = json.loads(source, object_pairs_hook=unique_object) + archive = HERE / "peer8057.tar.gz" + if pins["head"] != HEAD or sha256(archive.read_bytes()).hexdigest() != pins["archive_sha256"]: + raise ValueError("Unexpected source archive") + seen = set() + with tarfile.open(archive) as bundle: + for item in bundle: + path = Path(item.name) + if path.is_absolute() or ".." in path.parts or str(path) != item.name: + raise ValueError(f"Invalid source path {item.name}") + if item.isdir(): + continue + if not item.isfile() or item.name in seen or item.name not in pins["files_sha256"]: + raise ValueError(f"Unexpected or repeated peer file {item.name}") + data = bundle.extractfile(item).read() + if sha256(data).hexdigest() != pins["files_sha256"][item.name]: + raise ValueError(f"Source differs at {item.name}") + destination = tree / path + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(data) + seen.add(item.name) + if seen != pins["files_sha256"].keys(): + raise ValueError("Source archive is missing a file") + return tree / "research" / "frequency-weighted-native-multiplier" + + +def main(): + modes = ("price", "calendar", "raw", "exterior", "nested", "product", "setup", "regenerate") + parser = ArgumentParser(description=__doc__) + parser.add_argument("mode", choices=modes) + args = parser.parse_args() + with TemporaryDirectory(prefix="p104-10shortcut-3type-28bit-") as temporary: + tree = Path(temporary) + peer = restore(tree) + runpy.run_path(str(HERE / "prepare.py"))["materialize"](peer) + for name in ("check_cutoff.py", "check_stage_seam.py", "check_ordinary_floor.py", "check_w5664.py"): + (peer / name).write_bytes((HERE / name).read_bytes()) + if args.mode == "regenerate": + runtime = tree / "runtime" + run([sys.executable, "-IB", str(peer / "bootstrap.py"), str(runtime)], check=True) + result = run([sys.executable, "-IB", str(peer / "receipt.py"), str(runtime)], check=True, capture_output=True, text=True) + print(json.dumps(json.loads(result.stdout), indent=2)) + return + if args.mode == "setup": + serial = peer.parent / "tiered-native-multiplier" / "check_serial_setup.py" + run([sys.executable, "-IB", str(serial)], check=True) + runtime = tree / "runtime-w5664" + run([sys.executable, "-IB", str(peer / "bootstrap.py"), str(runtime)], check=True) + run([sys.executable, "-IB", str(peer / "check_w5664.py"), str(runtime)], check=True) + else: + (peer / "RESULT.json").write_bytes((HERE / "RESULT.json").read_bytes()) + run([sys.executable, "-IB", str(peer / "verify.py"), args.mode], check=True) + print("PASS_10SHORTCUT_3TYPE_28BIT_6STAGE", args.mode, flush=True) + + +if __name__ == "__main__": + main() diff --git a/research/p104-10shortcut-child-tariff/source/peer8097/w5664_shortcut10.json.gz b/research/p104-10shortcut-child-tariff/source/peer8097/w5664_shortcut10.json.gz new file mode 100644 index 0000000000..170aabc9f0 Binary files /dev/null and b/research/p104-10shortcut-child-tariff/source/peer8097/w5664_shortcut10.json.gz differ diff --git a/research/p104-10shortcut-child-tariff/source/transfer/ASSEMBLY.json b/research/p104-10shortcut-child-tariff/source/transfer/ASSEMBLY.json new file mode 100644 index 0000000000..fb8a5ca9f1 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/transfer/ASSEMBLY.json @@ -0,0 +1,37 @@ +{ + "baseline_terminal_kappa": "0.003900862325217", + "candidate_RESULT": "not generated", + "candidate_installation_sha256": "d34b860c4c35aeb302767216bf58dd9da627fe2b1b2b646fd70d6a544563648e", + "changed": { + "research/frequency-weighted-native-multiplier/SOURCES.json": { + "after": "a8b3a3cf67ce3448b5115a75250532888a8e91fc9ce60d804d2b91889648180f", + "before": "f5690dee0461295b8312f0611805dc5c837a4929fd8b6e4df51a9068fcaa2b0d" + }, + "research/frequency-weighted-native-multiplier/check_stage_seam.py": { + "after": "408e1980656a3a986343fd344ad4960f80e0bf04ee3ce9b62d94462ff86c430b", + "before": "f65ba986ef88b58c2e88fd43fdf40043d9b47f9952a83cb8277881776c914183" + }, + "research/frequency-weighted-native-multiplier/independent_price.py": { + "after": "12481437e296aebf3172b1eeda8d73ff85b9e87cb7c221d4a618e726ec0319d7", + "before": "b250c6169229b33b7a50bb6921a48cda3a47ad4fa1d0e88fe7289d4f469da79b" + }, + "research/frequency-weighted-native-multiplier/receipt.py": { + "after": "05976149ac2399da4da52a394c4f8b7e13af5c97f92419fd2bfc58cb96dfd880", + "before": "57bbecc48227e3bf938920221d0ec4b260452031c9afbb18ee28fbccda096c7b" + }, + "research/frequency-weighted-native-multiplier/runtime.patch": { + "after": "b3702cbac622d3803b8761832c4c741f323c97fdd4c2f815011a418cbce55462", + "before": "3a7653a0a3a508587870712076737467501b9e69a5ec8b9ffbf4ac50399e5379" + } + }, + "comparator_result_sha256": "f3ff96fb44169735871b27c1a22dd3f499e20a77401896fe53845f546aa1c9f5", + "complete_preimage_manifest_sha256": "48fe570b5c7ad6099cd6e886df880a959a3fe6582cb18dad44509d26e2757291", + "inherited_archive_result_sha256": "2f4faa6648592f589df22a8a0a07ba6856d20786294a44a7776c7d6e0efa14a5", + "installation_preimage_sha256": "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df", + "old_installation_sha256": "cbf85060a63dc4433c706d71ec582b0ebe6a09bbe26963ff78acb4c08e5edd92", + "peer_head": "e1c251401fe254909ac7e7bf2c773b921a1b6b57", + "projected_delta": "14559/1000000000000000", + "projected_terminal_kappa": "0.003900862339776", + "scope": "Frozen source assembly and exact selector image only. Installed replay unrun.", + "screen_sha256": "923a6c8fc1e15f6ca087b4de5d93e40bc49a889708f97e2dc7718f66053747ca" +} diff --git a/research/p104-10shortcut-child-tariff/source/transfer/PREIMAGE.json b/research/p104-10shortcut-child-tariff/source/transfer/PREIMAGE.json new file mode 100644 index 0000000000..c21948a32e --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/transfer/PREIMAGE.json @@ -0,0 +1,98 @@ +{ + "source_only": true, + "files": { + "research/frequency-weighted-native-multiplier/FINITE-LOSS.md": "12c6069437a0cbb61c80804f89f027ef9709c186e67d26fb0584ad6e71048052", + "research/frequency-weighted-native-multiplier/GaussianFiniteLoss.lean": "9d247f73d9da2748399b821612b30f20140783c08d761b6d4ef7d3c7c3d07064", + "research/frequency-weighted-native-multiplier/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/frequency-weighted-native-multiplier/MEASUREMENTS.json": "9ea26ae002146ae21291ecc0a6b224e5cccb9e3b5d199522558a645863da4f7b", + "research/frequency-weighted-native-multiplier/NOTICE.md": "02e69a1d57e2208ce49b3362a5672136887c1968d66de83a8f358e6d4a9353df", + "research/frequency-weighted-native-multiplier/PROOF.md": "4dbb38cdbe5b691edf4845fe8cf2a99be5d43455cc73199ab7e305abaa91acca", + "research/frequency-weighted-native-multiplier/README.md": "173313f895d9f810e5c32853ff383c8ee962e475dead35e5634047aa9c8a1453", + "research/frequency-weighted-native-multiplier/RESULT.json": "2f4faa6648592f589df22a8a0a07ba6856d20786294a44a7776c7d6e0efa14a5", + "research/frequency-weighted-native-multiplier/SOURCES.json": "f5690dee0461295b8312f0611805dc5c837a4929fd8b6e4df51a9068fcaa2b0d", + "research/frequency-weighted-native-multiplier/TASK.json": "9db85415d252a595907a8c1ddf8ce64acc5c0aa67dc8f6b4656139053bb40a52", + "research/frequency-weighted-native-multiplier/VERIFICATION.md": "58568a8f5e097a1d828aeff33ea33c63863c4b28dd1a87fd7dca9adebb5d6c1f", + "research/frequency-weighted-native-multiplier/VERIFY.json": "4f5506a41e62585e34c80c6838922d33b04d42e010fab310690f340a5be3721e", + "research/frequency-weighted-native-multiplier/WeightedNumerical.lean": "2017bae8064554efb13c564503d8f88c4615e9f733a74aa5eaf4047e5bd8af94", + "research/frequency-weighted-native-multiplier/bootstrap.py": "19a16cf5b6207995b1314ad9dc9b118a2654edff34af96e5d9ea1a2d5c0ee154", + "research/frequency-weighted-native-multiplier/check_calendar.py": "ecc3015664f45232689ca937570279ccc5d2487a236292fe7512ad0830f7166f", + "research/frequency-weighted-native-multiplier/check_cutoff.py": "e0c7e48d4469844de861e1e4ba83eed9c5ccd58e5c9f480c4a6a82da7524e31c", + "research/frequency-weighted-native-multiplier/check_exterior.py": "b29a035c90587fc75b4c8a4050a9eacf263929d201272dc635dd1d3d872e16b1", + "research/frequency-weighted-native-multiplier/check_lean.py": "32e49adef4502f193b5ded2cc4e7f8cea6a285283fda4db2152570a4b68098cb", + "research/frequency-weighted-native-multiplier/check_nested.py": "a976b80dfaf1360586f7d7b54350a6af857a36f580e1b506d0febf4ca85cf3eb", + "research/frequency-weighted-native-multiplier/check_ordinary_floor.py": "9c60d0ff1d88a0981625ae1c998638a8ad28d7ce0d3ffa01eba141cbbb99c3a8", + "research/frequency-weighted-native-multiplier/check_ownership.py": "dd1e4251f87b1b0a1d9a82cb1f47534bf97274db8160f8f2a01cf6f8f2aa960e", + "research/frequency-weighted-native-multiplier/check_placement.py": "96fb5ca7b5472ff02b3d8062673895aae517211080f72d386ec8e4a3892428a2", + "research/frequency-weighted-native-multiplier/check_raw.py": "ce6d00c50fcf816436555b882bc0e428e7cfea8be86a530e1c3d46862690914a", + "research/frequency-weighted-native-multiplier/check_stage_seam.py": "f65ba986ef88b58c2e88fd43fdf40043d9b47f9952a83cb8277881776c914183", + "research/frequency-weighted-native-multiplier/check_w5664.py": "e2c878d9805c79859c134b2a0d545e13650320720197a40efa16a49a4decd4cf", + "research/frequency-weighted-native-multiplier/grades.py": "8f8ec926213345e38e73110c2230e0bf03a2282252e924b5710cf212ca514be7", + "research/frequency-weighted-native-multiplier/independent_price.py": "b250c6169229b33b7a50bb6921a48cda3a47ad4fa1d0e88fe7289d4f469da79b", + "research/frequency-weighted-native-multiplier/measure_setup.py": "cbfe019024fbeee428c415549db10180af69995078825b6341bc9021f3d08723", + "research/frequency-weighted-native-multiplier/portable/EVIDENCE.json": "3bfffdda94bbc6a14282399eca69b8619c96bd587c7957b3bdf854e03ef89427", + "research/frequency-weighted-native-multiplier/portable/NOTICE.md": "57d7e187fb48df97838976a7942e41dc381f00daeff7c2b5c392fb1a6f252517", + "research/frequency-weighted-native-multiplier/portable/README.md": "141d07df12c9e5352a8f83a03a033dd2c41cc5d0d6e0edb3532cab462536a974", + "research/frequency-weighted-native-multiplier/portable/STACK-LOCALITY.md": "0211732aaa6083a305e861f8172b581b0a9c98e10191d8432d546ee224c0bf5f", + "research/frequency-weighted-native-multiplier/portable/TRACE-CLOCK.md": "9f2b0d125cc35f91bb037363505d027331c79153211ea21de838405ae01a1a2a", + "research/frequency-weighted-native-multiplier/portable/bounded_wasi.py": "8232cc247e5910aab7a0fecb03426088c8f851fd93cbf8fb3587a4a5d7ee143d", + "research/frequency-weighted-native-multiplier/portable/compare.py": "7a906b2b871011595f66882897e7ff0fa79f007fc7887ae0c21b555d778a75c8", + "research/frequency-weighted-native-multiplier/portable/compiler_state.py": "11f371903410a53aa138bb9b9c49e9441393a34092fff922716a78b5521e1870", + "research/frequency-weighted-native-multiplier/portable/consumer.py": "411cc1052a70f7084de81f6f1e54636737d5e5155d0756b8271d5d82c268d3b3", + "research/frequency-weighted-native-multiplier/portable/fixed_directory.py": "c99e9945295b954b453f4995474db4ec8da9e7d8d6ba1a564456213d066e5904", + "research/frequency-weighted-native-multiplier/portable/guest_opcodes.py": "9b2a1b128939cc8d2ef379199c09af74c52ed4b696640fce01606c431d931db6", + "research/frequency-weighted-native-multiplier/portable/module_census.py": "f22218fc37012f5c14b17afba3e8b868fd7268f25931836397f00fbdd319f6f7", + "research/frequency-weighted-native-multiplier/portable/producer.py": "5a76b94efb0bb59a686255f212b532a0f44a586649befda07dbfc5fe86c6a8b7", + "research/frequency-weighted-native-multiplier/portable/record_census.py": "8132c345cfcc5e7d89494fa437685673273f878f2dc40e0187bf2b84eee17e08", + "research/frequency-weighted-native-multiplier/portable/run.py": "6a1e17556326107cac9e70f446b2a90c35e9b4b07bfb7c4b31e5fe9b081f7d9b", + "research/frequency-weighted-native-multiplier/portable/signed.py": "7620e713be7a8064c5b9f83e6573cfabab801b627f0133b7998fdb51a6bac449", + "research/frequency-weighted-native-multiplier/portable/source_image.py": "e354c3fb2bb05eb36dc2438d89c30b18b7973638c51af526d8e55b56803c73ba", + "research/frequency-weighted-native-multiplier/portable/tape_directory.py": "70bf289334f724cabf1cfa9e074199e6be93ef0aeba8193f279e5ef1336de97b", + "research/frequency-weighted-native-multiplier/portable/verify_receipt.py": "8b42d3c5f35d6810321eb000e10b4e5593d543296cc670c3c8847e7051c1b30c", + "research/frequency-weighted-native-multiplier/positive_debit.py": "2d79420b6bc76f7a96a0686c37fd53c5beb3383a1e6f8ff7c27e519a1d18b825", + "research/frequency-weighted-native-multiplier/receipt.py": "57bbecc48227e3bf938920221d0ec4b260452031c9afbb18ee28fbccda096c7b", + "research/frequency-weighted-native-multiplier/runtime.patch": "3a7653a0a3a508587870712076737467501b9e69a5ec8b9ffbf4ac50399e5379", + "research/frequency-weighted-native-multiplier/typed_raw.py": "41f7e353bbf1914ed54f2c1c087476561dbcc06d1d5d4c828e20ebdd5bd8f28d", + "research/frequency-weighted-native-multiplier/typed_transport.py": "8968c44fb4349b3e0404c7b47dafad51e373d0ad1d290323674d6ad3cfa04348", + "research/frequency-weighted-native-multiplier/verify.py": "050ce49cc5a9b2c8a75e4d8da65fa4bd621c2be7200dfa5f477c3ec259d0dcaf", + "research/frequency-weighted-native-multiplier/w5664_shortcut10.json.gz": "ce395afbf5c32be64c4e62389acaf9ce8cf8a9aaaa2fb7a278135bcfa0e635aa", + "research/tiered-native-multiplier/CLOCK.md": "cf71e4a3216df23eb7e4fa8a8d9de3735e6257c65ca8a60a5085d9f3c90c4ecb", + "research/tiered-native-multiplier/LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "research/tiered-native-multiplier/MEASUREMENTS.json": "a1083bc55178baf0015ef83ef169f45df61475fcc648f487e03c852c871f1f00", + "research/tiered-native-multiplier/NOTICE.md": "c386dabe3fd1d046bddc782c671219757c7708e9ec874a6ede55b540edc95f2c", + "research/tiered-native-multiplier/NUMERICAL.md": "14b86724db522393981ed54b540a35f27bd952f3d95d6e6d14c5b23896811dc9", + "research/tiered-native-multiplier/README.md": "d2c214591f03313dece24592cde3193deffb2f1057b891604597b5e8c6d020ca", + "research/tiered-native-multiplier/RESULT.json": "661e16fcb533b69b97ad2dc91ab81bed79c44e7fdce01306ce573cb6f0ed7fa7", + "research/tiered-native-multiplier/SERIAL-SETUP.md": "1ca7e23ae113647605a31fa309c3bbdde2baf2d442913247fcda4c8a1eef7e7c", + "research/tiered-native-multiplier/SETUP.md": "6951a98f2f8a0bf73c8d60b16ebbbd66bf87584251df8afbefe4e3a0330bfbf3", + "research/tiered-native-multiplier/SOURCES.json": "7a10012734132909e99b0c6160d68d0b8647e1607d25679efb1f5315cf8e23de", + "research/tiered-native-multiplier/ScaledEntrance.lean": "e404be78622db98e9c3b490a15d0e9f002a2cf1eee9ecbd0a9516efbd0db5329", + "research/tiered-native-multiplier/TASK.json": "2cfe7fe1ea4ee8cd07d24048d45e543fdb8a6fa6585ebdc20b1ede55982a16a7", + "research/tiered-native-multiplier/TierCost.lean": "668a248d1060dd4fe97a0edb6652cb3782b8ba4ccc0d00ec73ee6ae253eb9945", + "research/tiered-native-multiplier/VERIFICATION.md": "343f4b2de9b49c1536d35046eee086898bad48023b7da528c5096ca43a1358d0", + "research/tiered-native-multiplier/VERIFY.json": "c684d5b86039809900c85fb0ce64d531db23c62e06bfcf210d6b2cc349480492", + "research/tiered-native-multiplier/bootstrap.py": "74ac8f1d3af21f86cda48a3d50084d6fa5faf84b44ec2e5929b587f40f5bcfd1", + "research/tiered-native-multiplier/check_gaussian.py": "383a3385bc9763d6eb557163ee62aa9ab999b0d98c719a004db87abfee063d24", + "research/tiered-native-multiplier/check_lean.py": "0d53ee2a814887bb53e78f62f2d2e73544641f2cac470dbecec93cdb0aa17203", + "research/tiered-native-multiplier/check_phase_passes.py": "6afd65da931476680d88cb54336ffedf531c3063af181f75403d511e24e83b94", + "research/tiered-native-multiplier/check_placement.py": "d416329ba75727d8f968abc39caded0c1a1fd3f21ffc9286274c5b834aab7154", + "research/tiered-native-multiplier/check_serial_setup.py": "11d1c3209cb523a360ab9abaefb3122507fdf5cb469169890fe2dac636812c47", + "research/tiered-native-multiplier/grades.py": "340684fdd5ca0e611836b0e7301f1c339282ba532bf9e3ec8055944d8981f3c8", + "research/tiered-native-multiplier/independent_price.py": "0b2ecc4a1845a2807782644b6b2675e2fcb194fcbb3ae80b50af9a775363e952", + "research/tiered-native-multiplier/installations.py": "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df", + "research/tiered-native-multiplier/measure_setup.py": "896349b654c7b8195e9823beaee080d2d30b3f72a562de90c7b6e2554bdd20bb", + "research/tiered-native-multiplier/receipt.py": "3d0219eb2262ea64ccf2dc8da4d2877e32c519c4670d99577703f8bfc236ba61", + "research/tiered-native-multiplier/runtime.patch": "6c93961841be2abc3629928074e2c7917d264e94187276fc88a33f922a3c62e4", + "research/tiered-native-multiplier/serial_setup.py": "61b5058d394ed74e943303e4bdbf21d58ccf5d8bb39fc4b02e97bc135d7bdbbc", + "research/tiered-native-multiplier/source/INSTALLER-NOTICE.md": "c6b1753ad6ebda2a2143b1a9efc80fadad6c1b27552c3ec8bc7bfdb431fb8eeb", + "research/tiered-native-multiplier/source/K7-NOTICE.md": "9c5ae9750012d305d917e625d14a33cc880e810e801e73364725bcdc24bffdb5", + "research/tiered-native-multiplier/source/K7-STACK-LEDGER.json": "a0c0d5b241e6861a5c49a287617e48fba56b09824f5ef4fcb7f03152edf37e8e", + "research/tiered-native-multiplier/source/activation.py": "6e7f89d40a4d10ecd40a50e5b96334dfc64db90841ece7e3ef12eeca5ee5093b", + "research/tiered-native-multiplier/source/check_binary_k7.py": "5eeb8f818725249cbabf215c323c3f8351b1c4ed3c127119341e6ed09f490dd6", + "research/tiered-native-multiplier/source/installer.tar.gz": "6696459e2e3552f802e7caaaf93dc86c9bb6b62ee38631702bff2e3a8a9a481a", + "research/tiered-native-multiplier/source/ordinary_clock.py": "91dcf0ef72dddbde998b80f3d8b30c8036de9ce97e06e2bbd9c4159bf292020d", + "research/tiered-native-multiplier/source/outer_budget.py": "ca4438db28a447ed5c43d87d43f0ac10a0cb2b4e183342ac93139d517b9d4d02", + "research/tiered-native-multiplier/source/outer_clock.py": "63363c3da673365f3ac5e1b7e318c6938005f1e9c9896799504cc598efbf96fa", + "research/tiered-native-multiplier/source/strong-bit-k7.json.gz": "9e7392c52bcf29c0cc58c54c619f95c28f476394c33e8e0a5aa30c9557d31362", + "research/tiered-native-multiplier/verify.py": "d6cf9085e87743db14932a21cf895f8bd4d0f126b6c0bb7220d3255268dba39a" + } +} diff --git a/research/p104-10shortcut-child-tariff/source/transfer/SCREEN.json b/research/p104-10shortcut-child-tariff/source/transfer/SCREEN.json new file mode 100644 index 0000000000..dcf0fc7b27 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/transfer/SCREEN.json @@ -0,0 +1,26 @@ +{ + "scope": "One fixed 28-bit six-stage source and price screen, no native build", + "inputs_sha256": { + "peer/RESULT.json": "f3ff96fb44169735871b27c1a22dd3f499e20a77401896fe53845f546aa1c9f5", + "peer/prepare.py": "5c54f3b1f1156eb4710038b1d0124d83db9241c80cb06c59abe1f0d132f8a55b", + "handoff/r431/check_tariff.py": "f5e258d3fe81b2a220e4458846c733649dd607fa3d0b07d1c1d4ff2a57d3cc8f", + "handoff/r427/check_fringe.py": "63c8b56140e5f42f504ac98bb4824934e90e4a5ff26fa3065fe10c8e199640c4" + }, + "proposed_tariff": "10981863/4703998", + "whole_factor_ratio": "5622713856/5647149599", + "kept_ordinary_reserve": "256/255", + "old_geometric_budget": 2401, + "proved_new_geometric_sum": 2391, + "tested_debit": "1414569/1048576", + "directed_precisions": [ + 112, + 192 + ], + "old_ordinary_cap": "9369558426040195713771823460678675873/2401919792316416000000000000000000000000", + "new_ordinary_cap": "9369558461011608925524934122014027169/2401919792316416000000000000000000000000", + "gaussian_cap": "2138026285702664495874749/548090675200000000000000000", + "binding": "ordinary", + "projected_kappa": "60950974059/15625000000000", + "projected_delta": "14559/1000000000000000", + "complete_log2_C": 171810078109 +} diff --git a/research/p104-10shortcut-child-tariff/source/transfer/assemble.py b/research/p104-10shortcut-child-tariff/source/transfer/assemble.py new file mode 100644 index 0000000000..14957c66e6 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/transfer/assemble.py @@ -0,0 +1,181 @@ +"""Apply the exact child tariff transfer to the frozen #8097 source.""" + +from argparse import ArgumentParser +from hashlib import sha256 +import json +import os +from pathlib import Path +import runpy +import shutil +import signal +from subprocess import run +from tempfile import TemporaryDirectory + + +HERE = Path(__file__).resolve().parent +PEER = Path("research/frequency-weighted-native-multiplier") +INSTALLATIONS = Path("research/tiered-native-multiplier/installations.py") +PINS = { + "receipt.py": "57bbecc48227e3bf938920221d0ec4b260452031c9afbb18ee28fbccda096c7b", + "independent_price.py": "b250c6169229b33b7a50bb6921a48cda3a47ad4fa1d0e88fe7289d4f469da79b", + "check_stage_seam.py": "f65ba986ef88b58c2e88fd43fdf40043d9b47f9952a83cb8277881776c914183", + "runtime.patch": "3a7653a0a3a508587870712076737467501b9e69a5ec8b9ffbf4ac50399e5379", + "SOURCES.json": "f5690dee0461295b8312f0611805dc5c837a4929fd8b6e4df51a9068fcaa2b0d", +} +PEER_HEAD = "e1c251401fe254909ac7e7bf2c773b921a1b6b57" +FULL_PREIMAGE = "48fe570b5c7ad6099cd6e886df880a959a3fe6582cb18dad44509d26e2757291" +SCREEN = "923a6c8fc1e15f6ca087b4de5d93e40bc49a889708f97e2dc7718f66053747ca" +PREIMAGE = "1c6978b8c7d136ef87191512d9ab9eb3dda8a818844244b96cb165d46d97b1df" +OLD_IMAGE = "cbf85060a63dc4433c706d71ec582b0ebe6a09bbe26963ff78acb4c08e5edd92" +OLD_RESULT = "2f4faa6648592f589df22a8a0a07ba6856d20786294a44a7776c7d6e0efa14a5" +OLD_RATE = "0.003900862325217" +NEW_RATE = "0.003900862339776" +SELECTOR = b'TERMINAL = Profile((8192, 63614, 1005821, 15903360, 251454111, 268435455), 52270, Q(".003900862325217"), Q(1, 256))' +NEW_SELECTOR = SELECTOR.replace(b".003900862325217", b".003900862339776") + + +def digest(data): + return sha256(data).hexdigest() + + +def authenticated(path, expected): + raw = path.read_bytes() + if digest(raw) != expected: + raise ValueError(f"Unexpected frozen source at {path.name!r}") + return raw + + +def unique_object(pairs): + result = {} + for key, value in pairs: + if key in result: + raise ValueError(f"Duplicate manifest key {key!r}") + result[key] = value + return result + + +def replace_unique(text, before, after): + if text.count(before) != 1: + raise ValueError(f"Expected one source anchor, found {text.count(before)}: {before[:110]!r}") + return text.replace(before, after, 1) + + +def image(preimage, patch, stage): + with TemporaryDirectory(prefix="selector-", dir=stage) as temporary: + target = Path(temporary) / "installations.py" + target.write_bytes(preimage) + env = dict(os.environ, GIT_CEILING_DIRECTORIES=str(stage)) + run(["git", "apply", "--no-index", "--include=installations.py", "--whitespace=nowarn", "-"], + cwd=temporary, env=env, input=patch, check=True, timeout=10) + return target.read_bytes() + + +def inventory(root): + files = {} + for path in (root / "research").rglob("*"): + if path.is_symlink(): + raise ValueError(f"A source symlink is outside this assembly: {path.relative_to(root)}") + if path.is_file(): + files[path.relative_to(root).as_posix()] = digest(path.read_bytes()) + return files + + +def materialize(frozen, stage): + prior = {name: authenticated(frozen / PEER / name, pin) for name, pin in PINS.items()} + frozen_manifest = json.loads(authenticated(HERE / "PREIMAGE.json", FULL_PREIMAGE), + object_pairs_hook=unique_object) + before = inventory(frozen) + if not frozen_manifest["source_only"] or before != frozen_manifest["files"] or len(before) != 93: + raise ValueError("The complete materialized #8097 source inventory differs") + screen = json.loads(authenticated(HERE / "SCREEN.json", SCREEN), object_pairs_hook=unique_object) + if (screen["binding"], screen["proposed_tariff"], screen["tested_debit"]) != ( + "ordinary", "10981863/4703998", "1414569/1048576" + ): + raise ValueError("The exact tariff screen differs") + preimage = authenticated(frozen / INSTALLATIONS, PREIMAGE) + baseline = image(preimage, prior["runtime.patch"], stage) + if digest(baseline) != OLD_IMAGE: + raise ValueError("The installed #8097 image differs") + patch = replace_unique(prior["runtime.patch"], b"+" + SELECTOR, b"+" + NEW_SELECTOR) + installed = image(preimage, patch, stage) + if installed != replace_unique(baseline, SELECTOR, NEW_SELECTOR): + raise ValueError("The selector patch made another change to installations.py") + compile(installed, "installations.py", "exec") + manifest = json.loads(prior["SOURCES.json"], object_pairs_hook=unique_object) + pins = manifest["runtime_images"]["installations.py"] + if pins != {"before": PREIMAGE, "after": OLD_IMAGE} or manifest["local_sources"]["runtime.patch"] != PINS["runtime.patch"]: + raise ValueError("The old selector pins differ") + pins["after"] = digest(installed) + manifest["local_sources"]["runtime.patch"] = digest(patch) + edits = runpy.run_path(str(HERE / "edits.py"))["EDITS"] + changed = { + "runtime.patch": patch, + "SOURCES.json": (json.dumps(manifest, indent=2) + "\n").encode(), + } + for name, replacements in edits.items(): + text = prior[name].decode() + for anchor, replacement in replacements: + text = replace_unique(text, anchor, replacement) + compile(text, name, "exec") + changed[name] = text.encode() + if set(changed) != set(PINS): + raise ValueError("The changed source inventory differs") + old_result = (PEER / "RESULT.json").as_posix() + if old_result in before: + authenticated(frozen / old_result, OLD_RESULT) + candidate = stage / "candidate" + shutil.copytree(frozen / "research", candidate / "research") + (candidate / old_result).unlink(missing_ok=True) + for name, raw in changed.items(): + (candidate / PEER / name).write_bytes(raw) + after = inventory(candidate) + differences = {p for p in before.keys() | after.keys() if before.get(p) != after.get(p)} + expected = {(PEER / name).as_posix() for name in changed} + if differences - {old_result} != expected or old_result in after: + raise ValueError("An unexpected source changed or a stale receipt survived") + return candidate, { + "scope": "Frozen source assembly and exact selector image only. Installed replay unrun.", + "peer_head": PEER_HEAD, + "complete_preimage_manifest_sha256": FULL_PREIMAGE, + "screen_sha256": SCREEN, + "baseline_terminal_kappa": OLD_RATE, + "projected_terminal_kappa": NEW_RATE, + "projected_delta": "14559/1000000000000000", + "inherited_archive_result_sha256": OLD_RESULT, + "comparator_result_sha256": screen["inputs_sha256"]["peer/RESULT.json"], + "installation_preimage_sha256": PREIMAGE, + "old_installation_sha256": OLD_IMAGE, + "candidate_installation_sha256": digest(installed), + "changed": {p: {"before": before[p], "after": after[p]} for p in sorted(expected)}, + "candidate_RESULT": "not generated", + } + + +def timeout(_signal, _frame): + raise TimeoutError("Source assembly reached the 45-second cap") + + +def main(): + if not __debug__: + raise RuntimeError("Run with assertions enabled") + parser = ArgumentParser(description=__doc__) + parser.add_argument("--frozen", type=Path, required=True) + parser.add_argument("--output", type=Path, required=True) + args = parser.parse_args() + frozen, output = args.frozen.resolve(), args.output.resolve() + if args.output.is_symlink() or output.exists() or output.is_relative_to(frozen): + parser.error("--output must be a fresh path outside the frozen tree") + signal.signal(signal.SIGALRM, timeout) + signal.alarm(45) + try: + with TemporaryDirectory(prefix="exact-tariff-transfer-source-", dir=output.parent) as temporary: + candidate, receipt = materialize(frozen, Path(temporary)) + (candidate / "TRANSFER-ASSEMBLY.json").write_text(json.dumps(receipt, indent=2, sort_keys=True) + "\n") + candidate.rename(output) + print(json.dumps(receipt, indent=2, sort_keys=True)) + finally: + signal.alarm(0) + + +if __name__ == "__main__": + main() diff --git a/research/p104-10shortcut-child-tariff/source/transfer/check_installed.py b/research/p104-10shortcut-child-tariff/source/transfer/check_installed.py new file mode 100644 index 0000000000..4d61a5804b --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/transfer/check_installed.py @@ -0,0 +1,153 @@ +"""Measure the admitted ten-recipe 28-bit native directory without opening calendars.""" + +from argparse import ArgumentParser +from fractions import Fraction +from hashlib import sha256 +import json +from pathlib import Path +from shutil import disk_usage +import sys +from tempfile import TemporaryDirectory + + +HEIGHTS = ((3000, 3080, 1024), (8192, 63614, 1005821, 15903360, 251454111, 268435455, 52270)) +SELECTORS = { + "peer": ("cbf85060a63dc4433c706d71ec582b0ebe6a09bbe26963ff78acb4c08e5edd92", ".003900862325217"), + "tariff": ("d34b860c4c35aeb302767216bf58dd9da627fe2b1b2b646fd70d6a544563648e", ".003900862339776"), + "domain": ("83c9616cadecbb6da76a0c4e0d909abe62490d48f35c47c08c68d879c65e13c7", ".003900862349161"), + "clock": ("2d55f0269164878a6507c6756f2f27ccd6b3a6d2cbd5b3232e89ebc8e1b7a422", ".003900862349168"), +} +RUNTIME = { + "grades.py": "8f8ec926213345e38e73110c2230e0bf03a2282252e924b5710cf212ca514be7", + "transport.py": "9eb8f0d77a4c53fc4fddffdfe198cab930b6d1f49e2b6d43c970397051bb7818", + "retimed_supplier.py": "2a87c2781ca93fa854aee098dcb7c50a65f2a46267ba926e3997b442e5a25f2c", + "raw_binary_stage.py": "934d2ae0b305caa364f155cc407c0e8ca479837ba70b906b8f516f67a5cc17b6", + "strong_complex.py": "2e87911b30d2d6467ceca95c4455f71ac010d7d258af3ff167320763fbccfd84", + "typed_raw.py": "41f7e353bbf1914ed54f2c1c087476561dbcc06d1d5d4c828e20ebdd5bd8f28d", + "typed_transport.py": "8968c44fb4349b3e0404c7b47dafad51e373d0ad1d290323674d6ad3cfa04348", + "w5664_shortcut10.json.gz": "ce395afbf5c32be64c4e62389acaf9ce8cf8a9aaaa2fb7a278135bcfa0e635aa", +} +PORTABLE = { + "compiler_state.py": "11f371903410a53aa138bb9b9c49e9441393a34092fff922716a78b5521e1870", + "record_census.py": "8132c345cfcc5e7d89494fa437685673273f878f2dc40e0187bf2b84eee17e08", + "tape_directory.py": "70bf289334f724cabf1cfa9e074199e6be93ef0aeba8193f279e5ef1336de97b", +} + + +def authenticate(root, prefix, pins): + verified = {} + for name, expected in pins.items(): + actual = sha256((root / name).read_bytes()).hexdigest() + if actual != expected: + raise ValueError(f"Unexpected installed source at {prefix}/{name}") + verified[f"{prefix}/{name}"] = actual + return verified + + +def check_profile(profiles, kappa): + assert tuple((*p.rank_logs, p.complex_log) for p in profiles) == HEIGHTS + assert profiles[-1].kappa == kappa + assert tuple(p.eta for p in profiles) == (Fraction(39, 10000), Fraction(1, 256)) + for p in profiles: + for q in (p.eta, p.kappa): + assert max(abs(q.numerator).bit_length(), q.denominator.bit_length()) <= 128 + assert 0 < p.positive_stop_denominator < 2**128 + + +def expanded_serial_bound(actions): + word = 2**38 + extent = 2 * word + 2 + lookup = 8 * (4 * word * actions) * 512 * 128 + local = 2**16 * (extent + 4) * (7 * extent + 9) + 8 * 2**16 * (extent + 4)**2 + return (actions + 1) * (lookup + local + 2**120) * 2**32 + + +def census(args): + image, rate = SELECTORS[args.profile] + sources = authenticate(args.runtime, "runtime", {**RUNTIME, "installations.py": image}) + sources.update(authenticate(args.portable, "portable", PORTABLE)) + for path in (args.runtime, args.scratch): + assert disk_usage(path).free >= 8 * 1024**3 + sys.path[:0] = [str(args.runtime), str(args.portable)] + from upstream import install + + install() + from band_product import production_supplier + from compiler_state import construct + from grades import WeightedRecipe, WEIGHTS + from installations import PROFILES + from record_census import inspect + from tape_directory import dump + from transport import Recipe + + profiles = tuple(PROFILES.values()) + check_profile(profiles, Fraction(rate)) + + def forbidden(*_args, **_kwargs): + raise AssertionError("Fixed setup tried to open a native calendar or materialize its width") + + saved = Recipe.open, Recipe.width, WeightedRecipe.open, WeightedRecipe.width + Recipe.open = WeightedRecipe.open = forbidden + Recipe.width = WeightedRecipe.width = property(forbidden) + try: + state = construct() + layers, word = state[:2] + assert tuple(tuple(r.rank_log for r in layer) for layer in layers) == HEIGHTS + assert all(r.width_log == 92 * r.rank_log for layer in layers for r in layer) + for layer in layers: + for r in layer[:-1]: + assert r.targets is word.targets and r.paid is word.paid and r.cells is word.cells + entry, terminal = (layer[-1] for layer in layers) + assert entry.cells is terminal.cells + assert entry.targets is terminal.targets and entry.paid is terminal.paid + assert WEIGHTS == (1, 45, 2025) + assert tuple(t.scale for t in entry.targets.variants) == (1, 2, 3) + assert tuple(p.scale for p in entry.paid.variants) == (1, 2, 3) + assert len({*entry.targets.histogram, *entry.paid.histogram}) < 2**8 + carriers = [] + for p, layer in zip(profiles, layers, strict=True): + supplier = production_supplier(p.complex_log, p.positive_stop_denominator) + assert supplier.recipe is layer[-1] and supplier.carrier.bit_count() == 1 + assert supplier.carrier.bit_length() == p.complex_log + 1 + carriers.append(supplier.carrier.bit_length()) + with TemporaryDirectory(prefix="ten-recipe-directory-", dir=args.scratch) as temp: + path = Path(temp) / "directory.dag" + with path.open("wb") as stream: + count = dump(stream, state) + observed = inspect(path) + assert count == observed["records"] > 0 + assert observed["tag_counts"][15] == 8 and observed["tag_counts"][17] == 2 + assert observed["largest_integer_bits"] < 2**38 and observed["bytes"] < 2**38 + with path.open("rb") as stream: + from hashlib import file_digest + directory_sha256 = file_digest(stream, "sha256").hexdigest() + finally: + Recipe.open, Recipe.width, WeightedRecipe.open, WeightedRecipe.width = saved + overhead = 2 * 2048 * (2**25 + 1) + sum(map(len, HEIGHTS)) * 2**24 + assert overhead == 137606729728 < 2**40 + serial = expanded_serial_bound(2**68 + 2**40) + assert expanded_serial_bound(2**68) < serial < 2**228 + return { + "scope": "Observed fixed native constructor and compact directory, with conditional setup accounting.", + "profile": args.profile, + "source_sha256": sources, + "heights": HEIGHTS, + "positive_carrier_bits": carriers, + "directory": observed, + "directory_sha256": directory_sha256, + "structural_added_action_ceiling": overhead, + "serial_transition_upper": serial, + } + + +if __name__ == "__main__": + assert __debug__ + parser = ArgumentParser(description=__doc__) + parser.add_argument("--runtime", type=Path, required=True) + parser.add_argument("--portable", type=Path, required=True) + parser.add_argument("--scratch", type=Path, required=True) + parser.add_argument("--profile", choices=SELECTORS, required=True) + args = parser.parse_args() + for name in ("runtime", "portable", "scratch"): + setattr(args, name, getattr(args, name).resolve()) + print(json.dumps(census(args), indent=2, sort_keys=True)) diff --git a/research/p104-10shortcut-child-tariff/source/transfer/edits.py b/research/p104-10shortcut-child-tariff/source/transfer/edits.py new file mode 100644 index 0000000000..f9e1eb9fa0 --- /dev/null +++ b/research/p104-10shortcut-child-tariff/source/transfer/edits.py @@ -0,0 +1,143 @@ +"""Exact tariff-transfer changes to the materialized #8097 verifiers.""" + +RECEIPT = ( + ("ORDINARY_DEBIT = Q(1418665, 2**20)", "ORDINARY_DEBIT = Q(1414569, 2**20)"), + ("CHILD_TARIFF = Q(2401, 1024)", "CHILD_TARIFF = Q(10981863, 4703998)\nRECURSIVE_CLOCK_BUDGET = 2401"), + (''' ordinary_upper = Q("2.5543284") + assert tape_factor_periodic(134, BINARY_C, ORDINARY_FLOOR, paid, bit_cells) * CHILD_TARIFF < ordinary_upper + assert ordinary_upper**1048576 < 2**1418665 + assert Q(75, 32) / CHILD_TARIFF == Q(2400, 2401)''', + ''' full_factor = tape_factor_periodic(134, BINARY_C, ORDINARY_FLOOR, paid, bit_cells) + old_tariff = Q(2401, 1024) + old_upper = Q("2.5543284") + assert full_factor * old_tariff < old_upper + assert old_upper**1048576 < 2**1418665 + assert Q(75, 32) / old_tariff == Q(2400, 2401) + + x = 3**7 # The conserved quotient mean decreases with N, and N>=9. + exact_mean = Q(21*x + 3, 9*x - 1) + assert exact_mean == Q(22965, 9841) < Q(2390, 1024) + assert all(height >= 4 for profile in (ENTRY, TERMINAL) for height in profile.rank_logs) + contraction = exact_mean / CHILD_TARIFF + geometric_sum = 1 / (1 - contraction) + assert contraction == Q(2390, 2391) and geometric_sum == 2391 < RECURSIVE_CLOCK_BUDGET + assert RECURSIVE_CLOCK_BUDGET < 8*376 and (Q(7, 10)*RECURSIVE_CLOCK_BUDGET)**2 < 2**22 + ratio = CHILD_TARIFF / old_tariff + assert ratio == Q(5622713856, 5647149599) + new_lo, new_hi = (2*Q(p, UNIT) for p in power_interval(2, ORDINARY_DEBIT - 1)) + # Keep the directed full old proof, including the entire 256/255 reserve. + assert full_factor * CHILD_TARIFF < old_upper * ratio < new_lo <= new_hi < old_upper'''), + ("== (268290534, 52270)", "== (268290493, 52270)"), + (''' gain = TERMINAL.kappa - older + assert gain == Q(5057431, 10**15)''', + ''' previous = Q(".003900862325217") + gain = TERMINAL.kappa - previous + assert TERMINAL.kappa == Q(".003900862339776") + assert previous - older == Q(5057431, 10**15) + assert gain == Q(14559, 10**15) + + stop = Q(1, TERMINAL.positive_stop_denominator) + + def guarded_ordinary(debit): + booked = Q(0) + for height in TERMINAL.rank_logs: + upper = min(TERMINAL.eta, (249 * (BINARY_C - debit / height) + booked) / 250) + booked = Q(int(upper * 10**21) - 1, 10**21) + return upper - 5*stop + + old_ceiling = guarded_ordinary(Q(1418665, 2**20)) + new_ceiling = guarded_ordinary(ORDINARY_DEBIT) + gaussian_ceiling = GAUSSIAN_C - DEBIT / TERMINAL.complex_log - 5*stop + assert previous < old_ceiling <= previous + Q(1, 10**15) + assert old_ceiling < TERMINAL.kappa < new_ceiling < gaussian_ceiling + assert new_ceiling <= TERMINAL.kappa + Q(1, 10**15)'''), + (''' assert grade_actions < 2**32 and setup["all_setup"] < 2**228''', + ''' # Recompute both enlarged lookup and serial action count for all ten recipes. + actions = 2**68 + 2**40 + lookup = 8*(4*setup["max_datum_bits"]*actions)*512*128 + expanded_setup = (actions + 1)*(lookup + setup["local_arithmetic"] + 2**120)*2**32 + assert grade_actions < 2**32 and setup["all_setup"] < expanded_setup < 2**228'''), + (" previous_rate=str(older),", " previous_rate=str(previous),\n previous_8094_rate=str(older),"), + (''' ordinary_child_contraction="2400/2401", + ordinary_child_geometric_sum=2401,''', + ''' ordinary_child_contraction=str(contraction), + ordinary_child_geometric_sum=int(geometric_sum), + ordinary_child_geometric_budget=RECURSIVE_CLOCK_BUDGET,'''), + (''' native_setup_transition_upper=setup["all_setup"],''', + ''' native_setup_transition_upper=expanded_setup,'''), +) + +INDEPENDENT = ( + (''' print("PASS_INDEPENDENT_PERIODIC_DEBITS", "ord=1418665/2^20", "pos=32401/262144", "2400/2401", "reserve=256/255", flush=True)''', + ''' print("PASS_INDEPENDENT_PERIODIC_DEBITS", "ord=1418665/2^20", "pos=32401/262144", "2400/2401", "reserve=256/255", flush=True) + + x = 3**7 + child_mean = Q(21*x + 3, 9*x - 1) + contraction = Q(2390, 2391) + tariff = child_mean / contraction + ratio = tariff / child_tariff + assert child_mean == Q(22965, 9841) and tariff == Q(10981863, 4703998) + assert ratio == Q(5622713856, 5647149599) + assert 1 / (1 - contraction) == 2391 < 2401 + # Change only the tariff in the complete existing 192-bit conservative invoice. + new_lo, new_hi = (2 * p for p in powers(2, Q(1414569, 2**20) - 1)) + assert hi * ratio < new_lo <= new_hi < lo + print("PASS_EXACT_TARIFF_TRANSFER", str(tariff), "ord=1414569/2^20", "reserve=256/255", "clock_budget=2401", flush=True)'''), + (''' assert TERMINAL.kappa - peer_8094 == Q(5057431, 10**15) + assert TERMINAL.kappa - peer_8073 == Q(2642571711, 10**15)''', + ''' peer_8097 = Q(".003900862325217") + assert peer_8097 - peer_8094 == Q(5057431, 10**15) + assert peer_8097 - peer_8073 == Q(2642571711, 10**15) + assert TERMINAL.kappa - peer_8097 == Q(14559, 10**15)'''), +) + +SEAM = ( + (''' ORDINARY = Q(1418665, 2**20) # periodic-integral suffix at L=1156, 2401/1024 tariff, FULL 256/255 reserve''', + ''' PEER_ORDINARY = Q(1418665, 2**20) + PEER_KAPPA = Q(".003900862325217") + ORDINARY = Q(1414569, 2**20) # exact tariff, same L=1156 and full 256/255 reserve'''), + ('assert TERMINAL.kappa == Q(".003900862325217")', 'assert TERMINAL.kappa == Q(".003900862339776")'), + (''' assert ordinary_upper(ranks) > paid and gaussian_upper(TERMINAL.complex_log) > paid + assert TERMINAL.kappa <= ordinary_upper(ranks) - 5 * STOP < TERMINAL.kappa + Q(1, 10**15)''', + ''' old_upper = ordinary_upper(ranks, debit=PEER_ORDINARY) + assert PEER_KAPPA < old_upper - 5*STOP <= PEER_KAPPA + Q(1, 10**15) + assert old_upper < paid < ordinary_upper(ranks) < gaussian_upper(TERMINAL.complex_log) + assert TERMINAL.kappa < ordinary_upper(ranks) - 5*STOP <= TERMINAL.kappa + Q(1, 10**15)'''), + (''' def require_funding(proposed, gaussian, eta=TERMINAL.eta): + if ordinary_upper(proposed, eta=eta) <= paid or gaussian_upper(gaussian) <= paid: + raise ArithmeticError("Profile does not fund the terminal price")''', + ''' def require_funding(proposed, gaussian, eta=TERMINAL.eta, *, debit=ORDINARY, kappa=TERMINAL.kappa): + threshold = kappa + 5*STOP + if ordinary_upper(proposed, debit=debit, eta=eta) <= threshold or gaussian_upper(gaussian) <= threshold: + raise ArithmeticError("Profile does not fund the terminal price") + + def require_peer_funding(proposed, gaussian): + require_funding(proposed, gaussian, debit=PEER_ORDINARY, kappa=PEER_KAPPA)'''), + (''' require_funding(at(i, -(d - 1)), TERMINAL.complex_log)''', + ''' require_peer_funding(at(i, -(d - 1)), TERMINAL.complex_log)'''), + (''' rejected(lambda i=i, d=d: require_funding(at(i, -d), TERMINAL.complex_log), f"ordinary-height-{i}-minus-{d}")''', + ''' rejected(lambda i=i, d=d: require_peer_funding(at(i, -d), TERMINAL.complex_log), + f"peer8097-ordinary-height-{i}-minus-{d}")'''), + (''' rejected(lambda: require_funding(ranks, TERMINAL.complex_log - 1), "gaussian-height-minus-one"),''', + ''' rejected(lambda: require_funding(ranks, TERMINAL.complex_log - 1), "gaussian-height-minus-one"), + rejected(lambda: require_funding(ranks, TERMINAL.complex_log, debit=PEER_ORDINARY), + "peer8097-ordinary-debit-at-new-rate"), + rejected(lambda: require_funding(ranks, TERMINAL.complex_log, kappa=TERMINAL.kappa + Q(1, 10**15)), + "next-displayed-kappa-at-fixed-six-stage-profile"),'''), + (''' neighbours.append(ordinary_upper((*t, max_penultimate(t), TOP))) + assert all(n <= ordinary_upper(ranks) for n in neighbours)''', + ''' neighbours.append(ordinary_upper((*t, max_penultimate(t), TOP), debit=PEER_ORDINARY)) + assert all(n <= ordinary_upper(ranks, debit=PEER_ORDINARY) for n in neighbours)'''), + (''' # Verify all five comparator control tiers under our exact debits (retaining FULL 256/255):''', + ''' # Preserve all five comparator controls at the original #8097 debits.'''), + (''' u = ordinary_upper(c_ranks, eta=c_eta)''', + ''' u = ordinary_upper(c_ranks, debit=PEER_ORDINARY, eta=c_eta)'''), + (''' assert ordinary_upper(c_ranks[:-1] + (c_ranks[-1] - 1,), eta=c_eta) <= c_paid''', + ''' assert ordinary_upper(c_ranks[:-1] + (c_ranks[-1] - 1,), debit=PEER_ORDINARY, eta=c_eta) <= c_paid'''), +) + +EDITS = { + "receipt.py": RECEIPT, + "independent_price.py": INDEPENDENT, + "check_stage_seam.py": SEAM, +} diff --git a/research/p104-10shortcut-child-tariff/verify.py b/research/p104-10shortcut-child-tariff/verify.py new file mode 100644 index 0000000000..6741997e9e --- /dev/null +++ b/research/p104-10shortcut-child-tariff/verify.py @@ -0,0 +1,159 @@ +"""Replay the tariff transfer on the ten-shortcut construction from the packaged immutable source.""" + +from argparse import ArgumentParser +from hashlib import sha256 +import json +import os +from pathlib import Path, PurePosixPath +from runpy import run_path +from shutil import copyfile, disk_usage +from subprocess import PIPE, run +import sys +from tempfile import TemporaryDirectory, gettempdir + + +HERE = Path(__file__).resolve().parent +SOURCES = HERE / "source" +ORIGINAL = SOURCES / "peer8097" +OVERLAY = SOURCES / "transfer" +DOMAIN = SOURCES / "domain" +WEIGHTED = Path("research/frequency-weighted-native-multiplier") +SCIENTIFIC = ("price", "calendar", "raw", "exterior", "nested", "product") +INPUTS_SHA256 = "066765506f21bd204408dcf4feaab9bf41c5a9d38ceb32faaf00d1a05bd60f2a" +IMAGE_SHA256 = "2d55f0269164878a6507c6756f2f27ccd6b3a6d2cbd5b3232e89ebc8e1b7a422" +RESERVE = 8 * 1024**3 +THREAD_ENV = dict.fromkeys(("OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS", "MKL_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", "BLIS_NUM_THREADS", "NUMEXPR_NUM_THREADS"), "1") + + +def unique_object(pairs): + result = {} + for key, value in pairs: + if key in result: + raise ValueError(f"Duplicate input key {key!r}") + result[key] = value + return result + + +def read_json(data): + return json.loads(data, object_pairs_hook=unique_object) + + +def authenticate(): + data = (HERE / "INPUTS.json").read_bytes() + if sha256(data).hexdigest() != INPUTS_SHA256: + raise ValueError("Unexpected pinned input manifest") + manifest = read_json(data) + if manifest["schema_version"] != 1: + raise ValueError("Unexpected input manifest schema") + files = manifest["files"] + actual_sources = {p.relative_to(HERE).as_posix() for p in SOURCES.rglob("*") + if p.is_file() or p.is_symlink()} + if actual_sources != set(files) - {"RESULT.json", "LICENSE"}: + raise ValueError("Packaged source inventory differs") + for name, pin in files.items(): + relative = PurePosixPath(name) + if relative.as_posix() != name or relative.is_absolute() or ".." in relative.parts: + raise ValueError(f"Unexpected input path {name!r}") + path = HERE / name + if not path.is_file() or path.resolve(strict=True) != path: + raise ValueError(f"Not a regular source input {name!r}") + content = path.read_bytes() + if len(content) != pin["size"] or sha256(content).hexdigest() != pin["sha256"]: + raise ValueError(f"Unexpected packaged bytes at {name!r}") + return files + + +def reserve(scratch): + if min(disk_usage(HERE).free, disk_usage(scratch).free) < RESERVE: + raise RuntimeError("The 8 GiB native replay reserve is unavailable") + + +def python(path, *args, env, capture=False, timeout=None): + reserve(Path(env["TMPDIR"])) + return run([sys.executable, "-IB", str(path), *map(str, args)], check=True, text=True, + env=env, timeout=timeout, stdout=PIPE if capture else None).stdout + + +def prepare(scratch, env): + frozen = scratch / "peer" + frozen.mkdir() + loader = run_path(str(ORIGINAL / "verify.py")) + old = loader["restore"](frozen) + run_path(str(ORIGINAL / "prepare.py"))["materialize"](old) + for name in ("check_cutoff.py", "check_stage_seam.py", "check_ordinary_floor.py", "check_w5664.py"): + copyfile(ORIGINAL / name, old / name) + destination = scratch / "transfer" + observed = python(OVERLAY / "assemble.py", "--frozen", frozen, "--output", destination, + env=env, capture=True) + expected = read_json((OVERLAY / "ASSEMBLY.json").read_bytes()) + if any(read_json(data) != expected for data in ( + observed, (destination / "TRANSFER-ASSEMBLY.json").read_bytes() + )): + raise ValueError("The independently assembled tariff transfer differs from its pin") + narrowed = scratch / "domain" + observed = python(DOMAIN / "assemble.py", "--frozen", destination, "--output", narrowed, + env=env, capture=True) + expected = read_json((DOMAIN / "ASSEMBLY.json").read_bytes()) + if any(read_json(data) != expected for data in ( + observed, (narrowed / "DOMAIN-ASSEMBLY.json").read_bytes() + )): + raise ValueError("The independently assembled domain tariff differs from its pin") + return narrowed / WEIGHTED + +def install(peer, runtime, env): + python(peer / "bootstrap.py", runtime, env=env) + if sha256((runtime / "installations.py").read_bytes()).hexdigest() != IMAGE_SHA256: + raise ValueError("The installed source image differs from its pin") + + +def setup(peer, runtime, env): + original = peer.parent / "tiered-native-multiplier" + python(original / "check_serial_setup.py", env=env) + install(peer, runtime, env) + python(peer / "check_w5664.py", runtime, env=env) + + +def census(peer, runtime, scratch, env): + install(peer, runtime, env) + stock = scratch / "census" + stock.mkdir() + python(OVERLAY / "check_installed.py", "--profile", "clock", "--runtime", runtime, + "--portable", peer / "portable", "--scratch", stock, env=env, timeout=150) + + +def main(): + if sys.version_info[:2] != (3, 12) or not __debug__: + raise RuntimeError("Use CPython 3.12 with assertions enabled") + parser = ArgumentParser(description=__doc__) + parser.add_argument("mode", choices=("inputs", *SCIENTIFIC, "setup", "census", "regenerate")) + mode = parser.parse_args().mode + inputs = authenticate() + if mode == "inputs": + for name in inputs: + if name.endswith(".py"): + compile((HERE / name).read_bytes(), name, "exec") + print(f"PASS_10SHORTCUT_TARIFF_INPUTS {len(inputs)}") + return + reserve(Path(gettempdir())) + with TemporaryDirectory(prefix="p104-10shortcut-child-tariff-") as temporary: + scratch = Path(temporary).resolve() + env = dict(os.environ, **THREAD_ENV, TMPDIR=str(scratch)) + peer = prepare(scratch, env) + if mode in SCIENTIFIC: + copyfile(HERE / "RESULT.json", peer / "RESULT.json") + python(peer / "verify.py", mode, env=env) + elif mode == "setup": + setup(peer, scratch / "runtime", env) + elif mode == "census": + census(peer, scratch / "runtime", scratch, env) + else: + runtime = scratch / "runtime" + install(peer, runtime, env) + python(peer / "receipt.py", runtime, env=env) + return + print(f"PASS_10SHORTCUT_TARIFF_SCOPE {mode}") + + +if __name__ == "__main__": + main()