diff --git a/research/paired-extension-cap-fill/.gitattributes b/research/paired-extension-cap-fill/.gitattributes new file mode 100644 index 0000000000..e1d75a2b2d --- /dev/null +++ b/research/paired-extension-cap-fill/.gitattributes @@ -0,0 +1,2 @@ +# Keep vendored, data, allocation and evidence bytes exact (the repository default normalizes text). +* -text diff --git a/research/paired-extension-cap-fill/ALLOCATION-PINS.json b/research/paired-extension-cap-fill/ALLOCATION-PINS.json new file mode 100644 index 0000000000..aca7827264 --- /dev/null +++ b/research/paired-extension-cap-fill/ALLOCATION-PINS.json @@ -0,0 +1,14 @@ +{ + "allocation/DISPATCH.json": "65e435bd68e97243c003677271b88485a29d4d0fae2dff1354100404a145e74c", + "allocation/FILL.json.gz": "e045aa613f8fba06d81313f5e1c2cbec9ee94552163b8d1eb9205bf2fa7f2285", + "allocation/ORDER.json": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "allocation/PROFILE.json": "8b6f825a93cb1fa94047b062f1b1b8d489b2c397ec0c8114d0e53737f56c065e", + "allocation/PROVIDERS.json": "1fbbe45a0b70b909bf764fab7d89ec05b10c6c3dec5340a59a69b871d309c6ab", + "allocation/SEARCH.json": "9ac59657d263ab7181503020aaae2dad4d73412eb62846b4c6992aebd8891987", + "allocation/baseline/CLAIM.json": "e6c836c0178661a53a69cd91f29d83585e876f2511ff40c6b6204cd270fbdeac", + "allocation/baseline/ORDER.json": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "allocation/baseline/PROFILE.json": "07ee0cfe8d88073de9b75cd3262a98f4ac428b1bdd3922b5a077dbf3436be00c", + "allocation/vendor/PLAN.json.gz": "d566cfb87b71639d4138e1f89b543e2dd6a7772070226a2a14c799a6835bf21e", + "allocation/vendor/TEMPLATE.json.gz": "21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e", + "allocation/vendor/independent_owners.py": "77a848729159e271ba64f403dfd59dddb13044b17b2950fa56700f442e2fe461" +} diff --git a/research/paired-extension-cap-fill/CLAIM.json b/research/paired-extension-cap-fill/CLAIM.json new file mode 100644 index 0000000000..4f8ea2dbe4 --- /dev/null +++ b/research/paired-extension-cap-fill/CLAIM.json @@ -0,0 +1,38 @@ +{ + "admitted_package_manifest_sha256": "b690eab49b010091973a4e7d1b8d58306200fd09f4c2281bbeeec57aa1b077d5", + "baseline_head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "baseline_kappa": "17215886471978018806049999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000", + "baseline_pr": 2917, + "calls": 666, + "complex_lower": "1722499906443274564357/1000000000000000000000000", + "coverage_law_ceiling_approx": "0.0017580218062580484", + "fill_sha256": "e045aa613f8fba06d81313f5e1c2cbec9ee94552163b8d1eb9205bf2fa7f2285", + "fixed_inventory_cap": { + "cap_lower": "1722499906443274564357/1000000000000000000000000", + "cap_upper": "17224999064432745643571/10000000000000000000000000", + "realized": "attained (profile equals the fractional optimum)" + }, + "gain": "113907405684085469/125000000000000000000000", + "helpers": 408, + "independent_inputs": 632, + "kappa": "17224999064432745643569999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000", + "kappa_decimal": "0.0017224999064432745643569999999999999999999998999999999999999999999999", + "live_families": 66304, + "native_receipt_sha256": "9a2e23c80436cf257c6f21fa4bd3f796fdb569bf30005ca2c2bb16d8f2094969", + "physical_families": 66804, + "profile": { + "1": 1626372, + "2": 426240, + "3": 192474, + "4": 73260, + "48": 27158, + "5": 24198, + "8": 5328 + }, + "release_receipt_sha256": "efc5eebdc42e976b0500cd032e1b6f4b8755fa33d9a23ac27415e27922e85b75", + "replicas": 74, + "scope": "Conditional finite supplier/outer certificate for PR2917's unchanged words with a new literal T74 allocation. Inherited all-size/compiler/theorem hypotheses remain. No selected-frontier change or independent-human-review claim.", + "source_manifest_sha256": "98d57c82a1c7318be3c330c3b66897844d57232f0aaeaea88fb4bebd0a1bedf1", + "status": "CONDITIONAL_CANDIDATE_COMPLETE_FINITE_RELEASE", + "zero_buffers": 82 +} diff --git a/research/paired-extension-cap-fill/CREDITS.md b/research/paired-extension-cap-fill/CREDITS.md new file mode 100644 index 0000000000..d694ca64b4 --- /dev/null +++ b/research/paired-extension-cap-fill/CREDITS.md @@ -0,0 +1,9 @@ +# Credits + +- **PR #2917, Mason Hale**: the nine additional paired extractions, the final 82-endpoint words used here unchanged, the T74 chronology (ORDER/DISPATCH), the allocation checker, moment auditor, extension stage and adapter derivation that this package reuses. +- **PR #2908, Jeremy Diviney**: the paired input/output extraction, its structural certificate and the closed-adapter admission chain. +- **PR #2894 / #2833, Jeremy Kothe**: the preload re-synthesis supplier, the frame accounting and cleanup (vendor/preload_move.py), the source materializer and the inherited supplier lineage. +- **PR #2857 / #2848, Yiyang Lu (Lyy-iiis)**: the shared-kernel words and the chronological flow model and realization (edge colouring) used to construct this allocation; PR2843 (Marius-Paul Dumitrean) is that flow model's starting point. +- **PR #2863 / #2839, Dugongue**: the precedent of attaining a fixed-inventory packing optimum, and the PR2839 owner engine lineage. +- **Tekalign**: the independent owner/chronology checker (allocation/vendor/independent_owners.py) and admission tooling. +- **New here (Marius-Paul Dumitrean, with substantial AI assistance from Anthropic Claude via Claude Code)**: the exact fixed-capacity relaxation of PR2917's inventory and its Fractions-only certificate, the integral pattern mix, the cap-attaining literal T74 allocation of PR2917's unchanged words, the generalized adapter derivation with the PR2917 comparator, and the complete fresh replay. diff --git a/research/paired-extension-cap-fill/MANIFEST.json b/research/paired-extension-cap-fill/MANIFEST.json new file mode 100644 index 0000000000..e3f3cbb839 --- /dev/null +++ b/research/paired-extension-cap-fill/MANIFEST.json @@ -0,0 +1,72 @@ +{ + ".gitattributes": "056f4f66161e333f3a8d4c20de323ca05599a7deac1aa02d47ba6f6b96335573", + "ALLOCATION-PINS.json": "f07d3079149f056d3948054ed0d3c9af1c7f09582680a05e07a29cfd7c1a5c82", + "CLAIM.json": "9c2c14158780a677b3661623d7476acc4f535ac9e0481addfa1d6c4c7633b74b", + "CREDITS.md": "8d6cdb5abe3b5df137b502e71b49d96c8305ecbf35fd105c10a8324d7aa8745c", + "NOTICE": "efe81e972dedee779c7241d7ae2cead22725658aa3464b454ac2081c5c7293e3", + "PINS.json": "e8572a413719715c6537e20238955d2926d5a5659435baadd5d5eee13526f0c5", + "README.md": "b0c6a1719fa039551dfdd9a1c20213b4bcae3d5181ad6ae882cd4d375bcc0810", + "SOURCES.json": "40decf367d6ff91bdfbac32545f0ff5536f1aa25c1ff5dea90cf0d9f65b2e5c7", + "TASK.json": "1b0c80c3f3255c2ed2336f3cfe5e8061bc08975bb195c100157a0e84a54da12b", + "VERIFY.json": "4fafdf99d05974d08bc20d9e5500f4742d8253ca2da6758d0563e55aa117b22b", + "allocation/DISPATCH.json": "65e435bd68e97243c003677271b88485a29d4d0fae2dff1354100404a145e74c", + "allocation/FILL.json.gz": "e045aa613f8fba06d81313f5e1c2cbec9ee94552163b8d1eb9205bf2fa7f2285", + "allocation/ORDER.json": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "allocation/PROFILE.json": "8b6f825a93cb1fa94047b062f1b1b8d489b2c397ec0c8114d0e53737f56c065e", + "allocation/PROVIDERS.json": "1fbbe45a0b70b909bf764fab7d89ec05b10c6c3dec5340a59a69b871d309c6ab", + "allocation/SEARCH.json": "9ac59657d263ab7181503020aaae2dad4d73412eb62846b4c6992aebd8891987", + "allocation/baseline/CLAIM.json": "e6c836c0178661a53a69cd91f29d83585e876f2511ff40c6b6204cd270fbdeac", + "allocation/baseline/ORDER.json": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "allocation/baseline/PROFILE.json": "07ee0cfe8d88073de9b75cd3262a98f4ac428b1bdd3922b5a077dbf3436be00c", + "allocation/vendor/PLAN.json.gz": "d566cfb87b71639d4138e1f89b543e2dd6a7772070226a2a14c799a6835bf21e", + "allocation/vendor/TEMPLATE.json.gz": "21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e", + "allocation/vendor/independent_owners.py": "77a848729159e271ba64f403dfd59dddb13044b17b2950fa56700f442e2fe461", + "certificates/RELAX-CAP.json": "518ba849ece61bf191d161aa3e61c0f1229c4fda6f8171f8eca5761bc0fc1644", + "check_allocation.py": "0672d17458d837a2064b4fc7d26cfdc4931a93a7a3a39a71f6a2ed7b8b7e90a3", + "check_cap.py": "19e0502c8f7618f0dc88566f4eac425fa9772c9e75d6109375064685ab4f1ae0", + "construction/T37-FLOW.json.gz": "3ff02610ba7bc1e9fc4e141bc9c9233bfa11c0887908529b6fd46d3cf8be956f", + "construction/T37-MODEL.json": "db012cdd24470ce5ce7f9ecde44cb849f55e017b58d93914ab2af2a55c0d7308", + "construction/T37-PATTERNS.json": "d420d228a051974ee79b3e09e9a2294e085fd1b8c6683977f4675c163569d938", + "construction/T37-SOLVER.json": "e02af4643322b4b4e1dde4a0049fd8899a40e77d6c5bb17ea90d74c7086be119", + "construction/controls.py": "4f07c315bc66821695fdb3ea92a245a663f3026a9e2c596b7eccffbaed14ab2a", + "construction/double.py": "426462c181333b3b56ddeab4b21d0523a2d52874033dbb2a3546ba9990fe15cd", + "construction/fill17.py": "ecd49f72a6f42969c4157c5c51370f66cf09db3f82d74b2e852383eeff77b58c", + "data/WORD-base.json.gz": "fec3c120db1a35022944628d34b56a36f2456248c274c2eaba1a325cdc690ce8", + "data/WORD-extra.json.gz": "e4d0c617df85bf8a824ff68310ca3373dc017c1ebf9ea733056a3ee4a784b36f", + "evidence/ADAPTER-DERIVATION.json": "554d6d5f0959f11b122b3700d997d667bd51a467d7c860627e39209d84db75d6", + "evidence/ADMISSION-RESULT.json": "75e941faed996af9656b3bdd69e227964033bf080e8dfe2bee2e9faec4a198d9", + "evidence/ADMISSION-STAGES.json": "7a075cde897e06ebf080c066d771ffb28635fa1cb1148c1e22e81b974424f4e0", + "evidence/ENVIRONMENT.json": "c6faaaa9b538ddbf0ea3c624bbe2f1c7e4074f8cb504d4bee0f3353f1e7f32a1", + "evidence/FULL-NATIVE-RECEIPT.json": "9a2e23c80436cf257c6f21fa4bd3f796fdb569bf30005ca2c2bb16d8f2094969", + "evidence/FULL-NATIVE-RESULT.json": "32ff4570a520e9f395142c3daf33398d2257027dd51b06c11de283b86effd8a7", + "evidence/FULL-REPLAY-RESULT.json": "8712530cf2240ab697af45eb28f91c1775894a6cf5ad16f53162091aba431b84", + "evidence/FULL-REPLAY-STAGES.json": "c5cf6c867a4d3cc90bff634caf1ac4e0175558c0476da05a7061008a1d6a1bac", + "evidence/RELEASE-RECEIPT.json": "efc5eebdc42e976b0500cd032e1b6f4b8755fa33d9a23ac27415e27922e85b75", + "evidence/RETAINED-BOOTSTRAP-RECEIPT.json": "eec93526dafc5d6fb8f6b4318efb57b15209b7a31bbd670d470b1a65de244720", + "evidence/RUNTIME-PATCHES.json": "c342c27f065c4710792d181e17c2bade42373b069113e2484ffc711742fa651a", + "evidence/logs/admission-discovery.log.txt": "19dec04aaef58a5b7e349eef83a702575d0d747c8a4ab665456dabd9455d7e87", + "evidence/logs/admission-outer-check_ledger.py.log.txt": "4d04f73fa3b7dac96c30f5401ab6afe9e0fe83dc5dde59a9007bac53e67e8af5", + "evidence/logs/admission-outer-independent_check.py.log.txt": "91a7ed8a166901a19690f2172ddb1066bd6cf4c692b217bcb620bd4a5a13d990", + "evidence/logs/admission-owners.log.txt": "3cd9ba8872ab07f8f92a91ffbd26832abb91c5e51f14715a95adf318ae5665da", + "evidence/logs/admission-parent-lift.log.txt": "7b6249a123ca39fae7b7a6339dd9e8ae8777b081f4336418f2cc101704b70644", + "evidence/logs/admission-rebind.log.txt": "4503a92b598c31af5d39cfafdc0e4bc97bc8a1194576d632a0690ff17d2479ad", + "evidence/logs/admission-release.log.txt": "e01086be77ae2169e978708e1f7417f1ea2195ed3fc21579102986f1b2115778", + "evidence/logs/complete-admission.log.txt": "9a738eed12d381021f68a5a4221485bbf00e4982d508e5d616631367d9d02672", + "evidence/logs/derive-closed-adapters.log.txt": "d39b2faff6f37fffdd06722fea4b58e065b19b886c0b148d5639ec64dbf18938", + "evidence/logs/export-pr2833.log.txt": "6727020814b72c6d919999190845a46ffb33f2589ed65c501fcf66142d6f30de", + "evidence/logs/export-pr2894.log.txt": "6bd8df30779863897e48441608240db6a7e3fcbd0754511e44f854f3a5c462a6", + "evidence/logs/four-kernel-stage.log.txt": "f2bbb6462b3f5bb8a6415bb33c0c35355353b13343ddb90961660f7473caa5a2", + "evidence/logs/fresh-current-native.log.txt": "d7581123b0f3330f2598e7758ccbca466018d2599124fc6ceb1b678a9ee27dec", + "evidence/logs/fresh-retained-bootstrap.log.txt": "4a1625fdd9a947187583e67492c492f309e28669082f2e6f2aa97b5da345ea29", + "evidence/logs/paired-extension-stage.log.txt": "61cc77beeae833d7473b5c5338b176b150f95f6652a888c0307f080674cfde35", + "evidence/logs/parent-paired-stage.log.txt": "d80d8494c48816e3acf662db00cc0077a888b82392d736826f73beb1c4248299", + "evidence/logs/preload-stage.log.txt": "2eb7601c48840a39c58eb838886aed00a531349b259f0bbc3ea6421376b8ea3c", + "reproduce.py": "290a088c82c4f001151dd8e97853c17ff6da51da5ea3f56d5244af559b365fa7", + "run_registered.py": "ba2cc644fd3cea513b04e72cc30557456a8559898e072f27049a46979e560922", + "tools/audit_allocation_moment.py": "1dd0072f377ed2cea986b0aafcdb4175a4ae397d456b2f0d07d704bff7ace7d4", + "tools/derive_adapters.py": "631895d159ca25fd11d3665b2ebecb43d46381355d596d87111b021c9a606800", + "tools/relax.py": "0fed1c56b50a2e6d44deeeb6db0f1c7e1f71b86d1747130e1a9202216249a728", + "tools/relax_exact.py": "baf1855d6095c951a90d19a0d8094bd33290519940b732e2b758c5647830f044", + "tools/root.py": "55f5aca39b5ee2fe4687ac8863e6c24569010f27a332883c069b8e14b8fe09e3", + "vendor/preload_move.py": "c8fda4674644fcd5cbf39b6645ce148a21daa90a998b678cbe51f970b78b0044" +} diff --git a/research/paired-extension-cap-fill/NOTICE b/research/paired-extension-cap-fill/NOTICE new file mode 100644 index 0000000000..af55b97e91 --- /dev/null +++ b/research/paired-extension-cap-fill/NOTICE @@ -0,0 +1,14 @@ +research/paired-extension-cap-fill +Copyright 2026 Marius-Paul Dumitrean. Licensed under the Apache License, Version 2.0. +Prepared with substantial AI assistance (Anthropic Claude, via Claude Code). + +This package retains, byte-identical, Apache-2.0 files from PR #2917 (Mason Hale, head +224bd5e56041c40078ff6b5fa7393733a215de5c, research/paired-helper-extension): data/WORD-base.json.gz, +data/WORD-extra.json.gz, vendor/preload_move.py (Jeremy Kothe's PR2894 frame accounting and cleanup), +allocation/ORDER.json, allocation/DISPATCH.json, allocation/PROVIDERS.json, allocation/vendor/ +(independent_owners.py: Tekalign's independent owner checker as vendored by PR2839/PR2917; PLAN.json.gz, +TEMPLATE.json.gz) and allocation/baseline/ (PR2917's CLAIM.json, ORDER.json, PROFILE.json). +tools/audit_allocation_moment.py is PR2917's exact moment auditor with only its authenticated baseline +changed; tools/derive_adapters.py generalizes PR2917's adapter derivation (PR2908, Jeremy Diviney) by an +extra comparator. construction/ retains the flow model of PR2857/PR2843 (Yiyang Lu, Marius-Paul Dumitrean) +as adapted for this allocation. All original notices of the exported predecessor packages remain in force. diff --git a/research/paired-extension-cap-fill/PINS.json b/research/paired-extension-cap-fill/PINS.json new file mode 100644 index 0000000000..40287b8224 --- /dev/null +++ b/research/paired-extension-cap-fill/PINS.json @@ -0,0 +1,10 @@ +{ + "data/WORD-base.json.gz": "fec3c120db1a35022944628d34b56a36f2456248c274c2eaba1a325cdc690ce8", + "data/WORD-extra.json.gz": "e4d0c617df85bf8a824ff68310ca3373dc017c1ebf9ea733056a3ee4a784b36f", + "tools/audit_allocation_moment.py": "1dd0072f377ed2cea986b0aafcdb4175a4ae397d456b2f0d07d704bff7ace7d4", + "tools/derive_adapters.py": "631895d159ca25fd11d3665b2ebecb43d46381355d596d87111b021c9a606800", + "tools/relax.py": "0fed1c56b50a2e6d44deeeb6db0f1c7e1f71b86d1747130e1a9202216249a728", + "tools/relax_exact.py": "baf1855d6095c951a90d19a0d8094bd33290519940b732e2b758c5647830f044", + "tools/root.py": "55f5aca39b5ee2fe4687ac8863e6c24569010f27a332883c069b8e14b8fe09e3", + "vendor/preload_move.py": "c8fda4674644fcd5cbf39b6645ce148a21daa90a998b678cbe51f970b78b0044" +} diff --git a/research/paired-extension-cap-fill/README.md b/research/paired-extension-cap-fill/README.md new file mode 100644 index 0000000000..75fece42d9 --- /dev/null +++ b/research/paired-extension-cap-fill/README.md @@ -0,0 +1,128 @@ +# A cap-attaining allocation of PR #2917's words: conditional κ = 0.001722499906443274564357 − 10⁻⁴⁶ − 10⁻⁷⁰ + +```text +Status / UTC update / priority revision: DONE (conditional candidate) · 2026-10-16 · priority revision 5 · base main 8c8bcecb +Concrete question and changed premise: PR #2917 ships a literal T74 fill 9.11e-7 below the exact fixed-capacity packing + optimum of its own inventory. Can PR2917's UNCHANGED words be packed at that optimum and admitted? +Established result and evidence status: yes. A literal allocation whose complete paid profile EQUALS the fractional optimum + passes the owner engine, PR2917's moment auditor, and the complete fresh-native admission and modern outer release: + κ = 0.001722499906443274564357 − 10⁻⁴⁶ − 10⁻⁷⁰, exactly 113907405684085469/125000000000000000000000 ≈ 9.1126e-7 above + PR2917 (head 224bd5e5). Author-checked (AI-assisted); not maintainer-reviewed. +Public artifact URL + exact commit: this package (see the PR). +Next useful task: change the words (further paired extractions on the final 82-endpoint word); the fill layer of these + words is exhausted by this allocation. +Active claim / expiry: released. +``` + +## Result + +| | κ (headline) | complete paid profile | +|---|---|---| +| PR #2917 (Mason Hale) | 0.001721588647197801880605 − 10⁻⁴⁶ − 10⁻⁷⁰ | {1:1625724, 2:426240, 3:191980, 4:73260, 5:24951, 6:167, 7:45, 8:5328, 24:1, 32:207, 48:26958} | +| **this package** | **0.001722499906443274564357 − 10⁻⁴⁶ − 10⁻⁷⁰** | **{1:1626372, 2:426240, 3:192474, 4:73260, 5:24198, 8:5328, 48:27158}** | + +The gain is exactly `113907405684085469/125000000000000000000000` ≈ **9.1126e-7** (about 0.053%). The two provider words, the call +order, the dispatch, the per-helper widths, the owner engine and its plan/template are PR2917's, byte for byte. Only the literal +allocation changes: `allocation/FILL.json.gz`, `allocation/PROFILE.json` and `allocation/SEARCH.json`. Same words, same +82 private buffers, same physical stock 66,304 + 408 + 8 + 82 + 2 = 66,804, same 271,728 helper roles. + +## Why PR2917's fill was below its cap, and why this one is optimal + +The fixed-capacity fractional relaxation (bins 672/448/448/448 per replica of capacity 8/16/32/48, all 1,163 count-vector +patterns, one idle child per bin, the complete local profile paid) of PR2917's inventory {4:26, 5:2, 7:62, 8:96, 9:222} with +local profile {1:2416, 2:640, 3:280, 4:110, 5:26, 8:8} has optimum + +`cap ∈ [0.001722499906443274564357, 0.0017224999064432745643571]`, 11 tight patterns, and an **integral** optimal basis per replica: +[8]×672, [7,9]×352, [8,8]×96, [7,7,9,9]×103, [5,9,9,9]×18, [9,9,9]×93, [4,9,9,9]×234, [9⁵]×81, []×367, i.e. idle children +{1:234, 3:81, 5:93, 48:367} per replica. + +PR2917's literal fill pays 207 empty cap-32 bins, one rank-24 and 212 rank-6/7 idle children, and parks 5,378 width-8 roles in +cap-32/48 bins instead of [8,8] cap-16 bins. Every single whole-role relocation from it is uphill (a single-move fixed point: +the first move of a width-9 role out of a [9⁵] bin costs +0.021 H-units before the drain completes), which is why bounded +exchange/relocation repair stops there. + +Because the optimal basis is integral, an allocation with exactly the optimal pattern mix has **no rounding residue**: its +complete profile is 666 × local + 74 × idle_per_replica, which is the profile above. `check_cap.py` verifies, with exact +rationals only, the basis' primal feasibility, the sign of every one of the 1,163 reduced costs at the upper end of the root +bracket (weak duality), that the literal profile equals the optimum's, and that its exact root bracket is the cap bracket. +So no allocation of these words, under these bin capacities and this relaxation, has a larger complex endpoint. This is a +statement about the packing of fixed words only; changed words, templates or coverage laws are outside it. For reference, the +coverage-law local-word ceiling of `research/complex-local-word-ceiling` for this local profile is about 0.00175802181; the +headline realizes about 97.98% of it. + +## Construction + +1. `tools/relax.py` (exact relaxation, scipy/HiGHS only to locate the basis) gives the integral pattern mix above. +2. `construction/fill17.py`: PR2857's chronological flow model (PR2843 lineage) on PR2833's T37 owner chronology with the + integral mix as global pattern targets and PR2917's exact per-helper widths; CP-SAT (OR-Tools 9.15, one worker; several + workers deadlock on our machine) finds a feasible flow, realized as literal bins by regular-bipartite edge colouring. + The recorded run used seed 7 with PR2857's flow as a hint (`construction/T37-SOLVER.json`); an unhinted run is faster. +3. `construction/double.py`: PR2917's T74 order is exactly two interleaved copies of the PR2833 T37 chronology + (order74[2k] = order37[k], order74[2k+1] = (stage, replica+37), dispatch copied), so each T37 row (t,h,o,c,p,z) maps to + (2t,h,o,c,p,z) and (2t+1,h,o+37,c,p,z): a T74 allocation on PR2917's own chronology. +4. `construction/controls.py`: fresh engine load, claimed-profile check, five rejection controls, 82-buffer stock and + PR2917's exact moment auditor. The flow, model and pattern targets of the recorded run are in `construction/` (scratch + paths replaced by placeholders; provenance, not a portable entry point). + +## Verification + +**Registered, bounded** (`run_registered.py`, standard library, about a minute): +- complete package pins; the vendored owner engine on the new allocation (271,728 roles, compact prefixes, windows, + same-call family distinctness, capacities, complete profile, rank mass, physical 66,804) and five rejection controls + (missing role, duplicate helper, same-call family collision, capacity overflow, changed profile); +- PR2917's exact dyadic moment auditor with its authenticated baseline re-pinned to the PR2917 headline (strict gain); +- the Fractions-only cap certificate and literal-profile equality (`check_cap.py`), with two rejection controls; +- binding of the stored complete native/admission/release receipts in `evidence/` to the exact words, allocation and claim. + +**Complete replay** (`reproduce.py`): exact Git exports of PR2908 (51309592) and PR2917 (224bd5e5), through them PR2894 +(18d03c44) and PR2833 (e9307b48); fresh retained bootstrap by PR2894's `prepare_retained.py`; PR2857's four-kernel stage, +PR2894's preload stage, PR2908's paired stage and PR2917's extension stage, giving PR2917's derived source (manifest +98d57c82, 632 files); closed adapters with the PR2917 headline as comparator; fresh five-stage native chains for both +providers; complete admission (owners, parent lift, rebind, discovery, block-norm, physical/prefix invoice, independent +outer checks, release). + +The recorded run (`evidence/`) is a single invocation of this package's `reproduce.py --jobs 2` on macOS arm64, +CPython 3.12.13 (numpy 2.4.5, scipy 1.16.1, sympy 1.14.0, mpmath 1.3.0, gmpy2 2.3.2, psutil 7.2.1): fresh retained bootstrap +279 s, source stages 2 s, fresh native chains for both providers 25 s, complete admission 256 s (release 201 s), 563 s wall, +ending `PASS_CAP_FILL_COMPLETE_REPLAY`. The native receipt's "reused retained" fields refer to the retained cache that the +same run had just bootstrapped (`evidence/FULL-REPLAY-RESULT.json`: `fresh_retained_bootstrap: true`). Hash-bound receipts +are stored verbatim (they contain the run's absolute paths); logs under `evidence/logs/` have paths replaced by placeholders. + +```sh +# exact predecessor commits must be present locally (no network access during the replay) +git fetch https://github.com/CrocSwap/integer-mult-bounds.git \ + 224bd5e56041c40078ff6b5fa7393733a215de5c 51309592971e3b5be935599eed2a95404dc7781e \ + 18d03c447886895ef9abf888398178e0428533ca e9307b48d7d1b690939935ecef0f8e524e6d92f4 +python3.12 scripts/research_package.py --package research/paired-extension-cap-fill +OPENBLAS_NUM_THREADS=1 OMP_NUM_THREADS=1 \ + python3.12 -B research/paired-extension-cap-fill/reproduce.py --repo . --work /tmp/cap-fill-complete +``` + +The complete replay needs Python 3.12 with numpy, scipy, sympy, mpmath, gmpy2 and psutil (versions of the recorded run in +`evidence/ENVIRONMENT.json`). `--retained DIR` reuses an authenticated retained cache instead of the fresh bootstrap. + +## Scope + +Conditional finite supplier and modern outer certificate, exactly as inherited by PR2917; all inherited all-size, compiler, +hosting, precision and analytic hypotheses remain. No selected-frontier change, no unconditional multiplication theorem and +no independent human review is claimed. The optimality statement is for the fixed words and the stated packing relaxation. + +## Open next questions + +1. **Change the words.** This allocation exhausts the fill layer of PR2917's words, so further gains must lower the paid + local profile or the width inventory, e.g. further paired extractions on the final 82-endpoint word (PR2917 stopped + searching once its nine-step word was frozen). One more 9→8 extraction at PR2917-step-1 cost ({1:+3, 2:−2}) is worth + about +3.6e-7 after a cap-attaining re-pack. First step: recompute the paired nullspaces on the final word and price + each nominee with a relaxation certificate for the changed inventory before synthesis. +2. **A general constructor.** The cap basis was integral per replica here; inventories with fractional optimal + multiplicities additionally need PR2863-style lockstep copies and vacancy relays. + +Details are in `TASK.json`. + +## Credit + +Mason Hale (PR #2917) for the words, chronology and admission tooling reused unchanged; Jeremy Diviney (PR #2908) for the +paired extraction and adapter chain; Jeremy Kothe (PR #2894/#2833) for the supplier, frame accounting and source tools; +Yiyang Lu (PR #2857/#2848) for the flow model and realization; Dugongue (PR #2863/#2839) for the cap-attainment precedent +and engine lineage; Tekalign for the independent owner checker. See `CREDITS.md` and `NOTICE`. New work by Marius-Paul +Dumitrean, prepared with substantial AI assistance (Anthropic Claude, via Claude Code). Apache-2.0. diff --git a/research/paired-extension-cap-fill/SOURCES.json b/research/paired-extension-cap-fill/SOURCES.json new file mode 100644 index 0000000000..3bdc4f8aa2 --- /dev/null +++ b/research/paired-extension-cap-fill/SOURCES.json @@ -0,0 +1,214 @@ +{ + "schema_version": 1, + "base_commit": "8c8bcecb03def61bca701dd3b045932d39c48022", + "upstream_repository": "https://github.com/CrocSwap/integer-mult-bounds", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "889b95d936746df124872133ae1e7cc339adcb92", + "sha256": "7d185cd8c2af35988d638d969748ad7b670f902606444dbfc748e4402c340df6" + } + ], + "retained_sources": [ + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/data/WORD-base.json.gz", + "package_path": "data/WORD-base.json.gz", + "git_blob": "9be0aa5349dbc8c928a46089a7695e224d0e4d16", + "sha256": "fec3c120db1a35022944628d34b56a36f2456248c274c2eaba1a325cdc690ce8", + "bytes": 69818, + "role": "PR2917 final base provider word (82 restored endpoints), unchanged" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/data/WORD-extra.json.gz", + "package_path": "data/WORD-extra.json.gz", + "git_blob": "40b38365ea4b841101405ebd2c4fdcadcb8b9808", + "sha256": "e4d0c617df85bf8a824ff68310ca3373dc017c1ebf9ea733056a3ee4a784b36f", + "bytes": 69814, + "role": "PR2917 final extra provider word, unchanged" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/vendor/preload_move.py", + "package_path": "vendor/preload_move.py", + "git_blob": "55b435035bbc439a9d55e8abd125993208cef8d9", + "sha256": "c8fda4674644fcd5cbf39b6645ce148a21daa90a998b678cbe51f970b78b0044", + "bytes": 7243, + "role": "PR2894 frame accounting (frame_report) as vendored by PR2917" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/allocation/ORDER.json", + "package_path": "allocation/ORDER.json", + "git_blob": "7409c4df1092241729739596c7648bda504e6aad", + "sha256": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "bytes": 4573, + "role": "PR2917 T74 call order (unchanged chronology)" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/allocation/DISPATCH.json", + "package_path": "allocation/DISPATCH.json", + "git_blob": "9544fee4e6ee1f202cee22bfaeaf229ee3b2515e", + "sha256": "65e435bd68e97243c003677271b88485a29d4d0fae2dff1354100404a145e74c", + "bytes": 10401, + "role": "PR2917 provider dispatch (unchanged)" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/allocation/PROVIDERS.json", + "package_path": "allocation/PROVIDERS.json", + "git_blob": "1bd962152fa7f0766fbaaa93569ac21e08a7cb62", + "sha256": "1fbbe45a0b70b909bf764fab7d89ec05b10c6c3dec5340a59a69b871d309c6ab", + "bytes": 7684, + "role": "PR2917 per-helper widths and local profiles (unchanged)" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/allocation/vendor/independent_owners.py", + "package_path": "allocation/vendor/independent_owners.py", + "git_blob": "16013201b19054f7e45398ecf10af74c9c6a9114", + "sha256": "77a848729159e271ba64f403dfd59dddb13044b17b2950fa56700f442e2fe461", + "bytes": 10057, + "role": "independent owner/chronology engine (Tekalign; PR2839 lineage)" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/allocation/vendor/PLAN.json.gz", + "package_path": "allocation/vendor/PLAN.json.gz", + "git_blob": "7a1db55a4d53ee99280be4f3ab7d29f7b2033adf", + "sha256": "d566cfb87b71639d4138e1f89b543e2dd6a7772070226a2a14c799a6835bf21e", + "bytes": 29933, + "role": "parent plan for the owner engine" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/allocation/vendor/TEMPLATE.json.gz", + "package_path": "allocation/vendor/TEMPLATE.json.gz", + "git_blob": "114808c32b1799da53524bdc25cea67efb60009e", + "sha256": "21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e", + "bytes": 1124331, + "role": "owner template for the owner engine" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/CLAIM.json", + "package_path": "allocation/baseline/CLAIM.json", + "git_blob": "50cc0eeeba13e48f64127544fcb17fe16bd99c30", + "sha256": "e6c836c0178661a53a69cd91f29d83585e876f2511ff40c6b6204cd270fbdeac", + "bytes": 1743, + "role": "PR2917 complete headline (comparator)" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/allocation/ORDER.json", + "package_path": "allocation/baseline/ORDER.json", + "git_blob": "7409c4df1092241729739596c7648bda504e6aad", + "sha256": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "bytes": 4573, + "role": "PR2917 order (baseline for the moment auditor)" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "author": "Mason Hale (mason-hale)", + "upstream_path": "research/paired-helper-extension/allocation/PROFILE.json", + "package_path": "allocation/baseline/PROFILE.json", + "git_blob": "a3c711f5c3c8b69b44324c1d3b4ec4454dae3570", + "sha256": "07ee0cfe8d88073de9b75cd3262a98f4ac428b1bdd3922b5a077dbf3436be00c", + "bytes": 151, + "role": "PR2917 complete paid profile (baseline for the moment auditor)" + } + ], + "adapted_sources": [ + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "upstream_path": "research/paired-helper-extension/tools/audit_allocation_moment.py", + "package_path": "tools/audit_allocation_moment.py", + "change": "authenticated baseline re-pinned from the PR2908 headline to the PR2917 headline; nothing else" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "upstream_path": "research/paired-helper-extension/tools/derive_adapters.py", + "package_path": "tools/derive_adapters.py", + "change": "generalized: buffer count, source profile and an additional comparator (PR2917) as parameters; with PR2917 parameters and the PR2908 comparator only, its adapters equal PR2917s byte for byte" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "upstream_path": "research/paired-helper-extension/check_allocation.py", + "package_path": "check_allocation.py", + "change": "paths, new allocation, PR2917 comparator, claimed-profile binding" + }, + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "upstream_path": "research/paired-helper-extension/reproduce.py", + "package_path": "reproduce.py", + "change": "also exports PR2917 from its commit; PR2917 comparator; this package allocation" + } + ], + "upstream_exports": [ + { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "package": "research/paired-helper-extension", + "manifest_sha256": "55c46ddf2e3edc87dfe1ba3320947466d36980d457eb37f6cd6fba341dae0192" + }, + { + "pr": 2908, + "head": "51309592971e3b5be935599eed2a95404dc7781e", + "package": "research/two-sided-helper-extraction", + "manifest_sha256": "9dba3fe371602ec023a54e26c0fd66f69eb7a74be86aab89923529083c14b36f" + }, + { + "pr": 2894, + "head": "18d03c447886895ef9abf888398178e0428533ca", + "package": "research/shared-kernel-packing", + "role": "exported by PR2908 reproduce.py --dry-run" + }, + { + "pr": 2833, + "head": "e9307b48d7d1b690939935ecef0f8e524e6d92f4", + "role": "source materialized and authenticated by PR2894 tools/materialize_source.py" + } + ], + "derived_source": { + "manifest_sha256": "98d57c82a1c7318be3c330c3b66897844d57232f0aaeaea88fb4bebd0a1bedf1", + "files": 632, + "builder": "PR2917 tools/build_extension.py" + }, + "source_boundary": "Only this new package is submitted. The words are PR2917s, byte-identical; exact frozen ancestor exports remain unchanged. Full replay performs no network fetch." +} diff --git a/research/paired-extension-cap-fill/TASK.json b/research/paired-extension-cap-fill/TASK.json new file mode 100644 index 0000000000..afc75f7f70 --- /dev/null +++ b/research/paired-extension-cap-fill/TASK.json @@ -0,0 +1,68 @@ +{ + "schema_version": 1, + "task_id": "selected-packing", + "priority_revision": 5, + "base_commit": "8c8bcecb03def61bca701dd3b045932d39c48022", + "original_card": { + "id": "selected-packing", + "question": "Is there a genuinely unsearched, explicitly bounded improvement to the selected packing?", + "starting_points": [ + "certificates/selected-result.json", + "research/heterogeneous-owner-assembly/README.md", + "research/complex-local-word-ceiling/README.md" + ], + "methods": [ + "Search a named unclaimed canonical candidate domain with a reproducible partition.", + "Prove a stronger scoped relaxation or exact optimum for one named residual subproblem." + ], + "acceptance_gate": "Check live PR overlap first, price both suppliers and distinguish a search best from an optimum. Report the word's packing cap from ceiling.ceiling() and the fraction of it realized; label packing gains as such.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Locate the selected packing source in the review and check live PRs for the same residual problem.", + "scope": "Positive control / source-bound orientation only; this is not a new construction or full cold replay." + }, + "first_experiment": "Define an unclaimed canonical domain and a favorable bound before starting a new search.", + "bottleneck_link": "An actual paid-profile gain can improve the frontier up to the other supplier cap.", + "allowed_variations": [ + "One bounded residual packing instance or exact relaxation.", + "If the coverage law, template or guard changes, derive an applicable fully charged replacement bound instead of applying the incumbent ceiling outside its scope." + ], + "scope_change_triggers": [ + "Rerunning an existing search with only a different seed as a separate mathematical contribution." + ], + "overlap_terms": [ + "T16", + "owner exchange", + "packing" + ] + }, + "scope_status": "refined", + "actual_scope": "Exact fixed-capacity packing relaxation of the top open claim PR #2917 (inventory {4:26,5:2,7:62,8:96,9:222}, local profile {1:2416,2:640,3:280,4:110,5:26,8:8}) and a literal owner-legal T74 allocation of its unchanged words that attains that relaxation optimum; complete fresh-native admission and modern outer release against the PR2917 headline.", + "scope_change_reason": "The card asks for a bounded improvement to the selected packing. The selected record (#1094) is far behind the open frontier; the unsearched, explicitly bounded packing instance with real headroom is the open-PR frontier word itself: PR2917 ships a fill 9.11e-7 below the exact fractional optimum of its own inventory (its own search stopped at a single-move fixed point). This package closes that residual exactly; it does not change the selected frontier.", + "bottleneck_link": "A fixed word set has an exact packing cap. PR2917 realized 9.11e-7 less than its cap; this allocation realizes all of it (the complete profile equals the fractional optimum), so further gains on these words must change the words (inventory or local profile), not the fill.", + "budget_minutes": 240, + "stop_rule": "Stop when a literal allocation of the unchanged words reaches the certified cap with owner-engine PASS and the complete admission passes strictly above the PR2917 headline, or report a scoped finding if any stage rejects it.", + "outcome": "completed", + "evidence": "run_registered.py (stdlib): package pins; owner engine on the new allocation (271,728 roles, physical 66,804) and five rejection controls; PR2917 moment auditor re-pinned to the PR2917 headline; Fractions-only relaxation certificate and literal-profile equality; stored receipts binding. reproduce.py: exact Git exports of PR2908/PR2917 (and through them PR2894/PR2833), fresh retained bootstrap, PR2917 derived source (manifest 98d57c82), adapters, fresh native chains for both providers and complete admission: PASS_REPLICA_ORDER_FILL_DERIVATIVE_COMPLETE_RELEASE and PASS_RELEASE at the claimed kappa.", + "author": "Marius-Paul Dumitrean", + "ai_assistance": "Substantial AI assistance (Anthropic Claude via Claude Code) for search, implementation, exact computation and checks; no independent human review is claimed.", + "open_questions": [ + { + "question": "Can the words of PR2917 be changed so that the fixed-inventory cap itself rises (further paired extractions on the final 82-endpoint word, or narrowings), and can each change be packed at its new cap?", + "why_it_matters": "This allocation exhausts the fill layer for these words: every further gain must lower the paid local profile or the width inventory. One more 9->8 extraction at PR2917-step-1 cost ({1:+3,2:-2}) is worth about +3.6e-7 after a cap-attaining re-pack.", + "first_step": "Recompute PR2908/PR2917 paired nullspaces on the final 82-endpoint word (existing and lowered terminal frames), price each nominee with the certified frame solver and certificates/RELAX-CAP.json-style relaxation for the changed inventory, then pack it with the same flow route.", + "blocked_by": "Search time; PR2917 stopped searching once its nine-step word was frozen." + }, + { + "question": "Is the flow-plus-doubling route a general constructor for every PR2917-lineage inventory?", + "why_it_matters": "The cap basis was integral per replica here, so no integrality residue remained; other inventories may need lockstep copies (PR2863) to reach their caps.", + "first_step": "Run construction/fill17.py with --catalogue tight on a changed inventory; if the integral basis mix has fractional multiplicities, combine with PR2863-style vacancy relays over copies.", + "blocked_by": "None for inventories with an integral optimal basis." + } + ] +} diff --git a/research/paired-extension-cap-fill/VERIFY.json b/research/paired-extension-cap-fill/VERIFY.json new file mode 100644 index 0000000000..6bbc54fff9 --- /dev/null +++ b/research/paired-extension-cap-fill/VERIFY.json @@ -0,0 +1,14 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [], + "commands": [ + { + "argv": ["{python}", "-B", "{package}/run_registered.py"], + "timeout_seconds": 420, + "checks": "Complete package pins; literal T74 owner geometry of the new allocation with PR2917's vendored PR2839 engine (271,728 roles, 82-buffer physical stock 66,804) and five rejection controls; PR2917's exact dyadic moment auditor re-pinned to PR2917's headline (strict gain); Fractions-only verification of the fixed-capacity relaxation basis (1,163 patterns, primal feasibility, dual signs) and equality of the literal complete profile with the fractional optimum; binding of the stored complete native/admission/release receipts to the exact words, allocation and claim. Native and integrated admission are rerun separately by reproduce.py from exact Git sources." + } + ] +} diff --git a/research/paired-extension-cap-fill/allocation/DISPATCH.json b/research/paired-extension-cap-fill/allocation/DISPATCH.json new file mode 100644 index 0000000000..9544fee4e6 --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/DISPATCH.json @@ -0,0 +1 @@ +[[0,0,"extra"],[0,37,"extra"],[0,1,"extra"],[0,38,"extra"],[0,2,"extra"],[0,39,"extra"],[0,3,"extra"],[0,40,"extra"],[0,4,"extra"],[0,41,"extra"],[1,0,"extra"],[1,37,"extra"],[0,5,"extra"],[0,42,"extra"],[1,1,"extra"],[1,38,"extra"],[0,6,"extra"],[0,43,"extra"],[1,2,"extra"],[1,39,"extra"],[0,7,"extra"],[0,44,"extra"],[1,3,"extra"],[1,40,"extra"],[0,8,"extra"],[0,45,"extra"],[1,4,"extra"],[1,41,"extra"],[0,9,"extra"],[0,46,"extra"],[2,0,"extra"],[2,37,"extra"],[1,5,"extra"],[1,42,"extra"],[0,10,"extra"],[0,47,"extra"],[2,1,"extra"],[2,38,"extra"],[1,6,"extra"],[1,43,"extra"],[0,11,"extra"],[0,48,"extra"],[2,2,"extra"],[2,39,"extra"],[1,7,"extra"],[1,44,"extra"],[0,12,"extra"],[0,49,"extra"],[2,3,"extra"],[2,40,"extra"],[1,8,"extra"],[1,45,"extra"],[0,13,"extra"],[0,50,"extra"],[2,4,"extra"],[2,41,"extra"],[1,9,"extra"],[1,46,"extra"],[3,0,"extra"],[3,37,"extra"],[0,14,"extra"],[0,51,"extra"],[2,5,"extra"],[2,42,"extra"],[1,10,"extra"],[1,47,"extra"],[3,1,"extra"],[3,38,"extra"],[0,15,"extra"],[0,52,"extra"],[2,6,"extra"],[2,43,"extra"],[1,11,"extra"],[1,48,"extra"],[3,2,"extra"],[3,39,"extra"],[0,16,"extra"],[0,53,"extra"],[2,7,"extra"],[2,44,"extra"],[1,12,"extra"],[1,49,"extra"],[3,3,"extra"],[3,40,"extra"],[0,17,"extra"],[0,54,"extra"],[2,8,"extra"],[2,45,"extra"],[1,13,"extra"],[1,50,"extra"],[3,4,"extra"],[3,41,"extra"],[0,18,"extra"],[0,55,"extra"],[2,9,"extra"],[2,46,"extra"],[4,0,"extra"],[4,37,"extra"],[1,14,"extra"],[1,51,"extra"],[3,5,"extra"],[3,42,"extra"],[0,19,"extra"],[0,56,"extra"],[2,10,"extra"],[2,47,"extra"],[4,1,"extra"],[4,38,"extra"],[1,15,"extra"],[1,52,"extra"],[3,6,"extra"],[3,43,"extra"],[0,20,"extra"],[0,57,"extra"],[2,11,"extra"],[2,48,"extra"],[4,2,"extra"],[4,39,"extra"],[1,16,"extra"],[1,53,"extra"],[3,7,"extra"],[3,44,"extra"],[0,21,"extra"],[0,58,"extra"],[2,12,"extra"],[2,49,"extra"],[4,3,"extra"],[4,40,"extra"],[1,17,"extra"],[1,54,"extra"],[3,8,"extra"],[3,45,"extra"],[0,22,"extra"],[0,59,"extra"],[2,13,"extra"],[2,50,"extra"],[4,4,"extra"],[4,41,"extra"],[1,18,"extra"],[1,55,"extra"],[3,9,"extra"],[3,46,"extra"],[0,23,"extra"],[0,60,"extra"],[5,0,"extra"],[5,37,"extra"],[2,14,"extra"],[2,51,"extra"],[4,5,"extra"],[4,42,"extra"],[1,19,"extra"],[1,56,"extra"],[3,10,"extra"],[3,47,"extra"],[0,24,"extra"],[0,61,"extra"],[5,1,"extra"],[5,38,"extra"],[2,15,"extra"],[2,52,"extra"],[4,6,"extra"],[4,43,"extra"],[1,20,"extra"],[1,57,"extra"],[3,11,"extra"],[3,48,"extra"],[0,25,"extra"],[0,62,"extra"],[5,2,"extra"],[5,39,"extra"],[2,16,"extra"],[2,53,"extra"],[4,7,"extra"],[4,44,"extra"],[1,21,"extra"],[1,58,"extra"],[3,12,"extra"],[3,49,"extra"],[0,26,"extra"],[0,63,"extra"],[5,3,"extra"],[5,40,"extra"],[2,17,"extra"],[2,54,"extra"],[4,8,"extra"],[4,45,"extra"],[1,22,"extra"],[1,59,"extra"],[3,13,"extra"],[3,50,"extra"],[0,27,"extra"],[0,64,"extra"],[5,4,"extra"],[5,41,"extra"],[2,18,"extra"],[2,55,"extra"],[4,9,"extra"],[4,46,"extra"],[1,23,"extra"],[1,60,"extra"],[6,0,"extra"],[6,37,"extra"],[3,14,"extra"],[3,51,"extra"],[0,28,"extra"],[0,65,"extra"],[5,5,"extra"],[5,42,"extra"],[2,19,"extra"],[2,56,"extra"],[4,10,"extra"],[4,47,"extra"],[1,24,"extra"],[1,61,"extra"],[6,1,"extra"],[6,38,"extra"],[3,15,"extra"],[3,52,"extra"],[0,29,"extra"],[0,66,"extra"],[5,6,"extra"],[5,43,"extra"],[2,20,"extra"],[2,57,"extra"],[4,11,"extra"],[4,48,"extra"],[1,25,"extra"],[1,62,"extra"],[6,2,"extra"],[6,39,"extra"],[3,16,"extra"],[3,53,"extra"],[0,30,"extra"],[0,67,"extra"],[5,7,"extra"],[5,44,"extra"],[2,21,"extra"],[2,58,"extra"],[4,12,"extra"],[4,49,"extra"],[1,26,"extra"],[1,63,"extra"],[6,3,"extra"],[6,40,"extra"],[3,17,"extra"],[3,54,"extra"],[0,31,"extra"],[0,68,"extra"],[5,8,"extra"],[5,45,"extra"],[2,22,"extra"],[2,59,"extra"],[4,13,"extra"],[4,50,"extra"],[1,27,"extra"],[1,64,"extra"],[6,4,"extra"],[6,41,"extra"],[3,18,"extra"],[3,55,"extra"],[0,32,"extra"],[0,69,"extra"],[5,9,"extra"],[5,46,"extra"],[2,23,"extra"],[2,60,"extra"],[7,0,"extra"],[7,37,"extra"],[4,14,"extra"],[4,51,"extra"],[1,28,"extra"],[1,65,"extra"],[6,5,"extra"],[6,42,"extra"],[3,19,"extra"],[3,56,"extra"],[0,33,"extra"],[0,70,"extra"],[5,10,"extra"],[5,47,"extra"],[2,24,"extra"],[2,61,"extra"],[7,1,"extra"],[7,38,"extra"],[4,15,"extra"],[4,52,"extra"],[1,29,"extra"],[1,66,"extra"],[6,6,"extra"],[6,43,"extra"],[3,20,"extra"],[3,57,"extra"],[0,34,"extra"],[0,71,"extra"],[5,11,"extra"],[5,48,"extra"],[2,25,"extra"],[2,62,"extra"],[7,2,"extra"],[7,39,"extra"],[4,16,"extra"],[4,53,"extra"],[1,30,"extra"],[1,67,"extra"],[6,7,"extra"],[6,44,"extra"],[3,21,"extra"],[3,58,"extra"],[0,35,"extra"],[0,72,"extra"],[5,12,"extra"],[5,49,"extra"],[2,26,"extra"],[2,63,"extra"],[7,3,"extra"],[7,40,"extra"],[4,17,"extra"],[4,54,"extra"],[1,31,"extra"],[1,68,"extra"],[6,8,"extra"],[6,45,"extra"],[3,22,"extra"],[3,59,"extra"],[0,36,"extra"],[0,73,"extra"],[5,13,"extra"],[5,50,"extra"],[2,27,"extra"],[2,64,"extra"],[7,4,"extra"],[7,41,"extra"],[4,18,"extra"],[4,55,"extra"],[1,32,"extra"],[1,69,"extra"],[6,9,"extra"],[6,46,"extra"],[3,23,"extra"],[3,60,"extra"],[8,0,"extra"],[8,37,"extra"],[5,14,"extra"],[5,51,"extra"],[2,28,"extra"],[2,65,"extra"],[7,5,"extra"],[7,42,"extra"],[4,19,"extra"],[4,56,"extra"],[1,33,"extra"],[1,70,"extra"],[6,10,"extra"],[6,47,"extra"],[3,24,"extra"],[3,61,"extra"],[8,1,"extra"],[8,38,"extra"],[5,15,"extra"],[5,52,"extra"],[2,29,"extra"],[2,66,"extra"],[7,6,"extra"],[7,43,"extra"],[4,20,"extra"],[4,57,"extra"],[1,34,"extra"],[1,71,"extra"],[6,11,"extra"],[6,48,"extra"],[3,25,"extra"],[3,62,"extra"],[8,2,"extra"],[8,39,"extra"],[5,16,"extra"],[5,53,"extra"],[2,30,"extra"],[2,67,"extra"],[7,7,"extra"],[7,44,"extra"],[4,21,"extra"],[4,58,"extra"],[1,35,"extra"],[1,72,"extra"],[6,12,"extra"],[6,49,"extra"],[3,26,"extra"],[3,63,"extra"],[8,3,"extra"],[8,40,"extra"],[5,17,"extra"],[5,54,"extra"],[2,31,"extra"],[2,68,"extra"],[7,8,"extra"],[7,45,"extra"],[4,22,"extra"],[4,59,"extra"],[1,36,"extra"],[1,73,"extra"],[6,13,"extra"],[6,50,"extra"],[3,27,"extra"],[3,64,"extra"],[8,4,"extra"],[8,41,"extra"],[5,18,"extra"],[5,55,"extra"],[2,32,"extra"],[2,69,"extra"],[7,9,"extra"],[7,46,"extra"],[4,23,"extra"],[4,60,"extra"],[6,14,"extra"],[6,51,"extra"],[3,28,"gauge44"],[3,65,"gauge44"],[8,5,"gauge44"],[8,42,"gauge44"],[5,19,"gauge44"],[5,56,"gauge44"],[2,33,"gauge44"],[2,70,"gauge44"],[7,10,"gauge44"],[7,47,"gauge44"],[4,24,"gauge44"],[4,61,"gauge44"],[6,15,"gauge44"],[6,52,"gauge44"],[3,29,"gauge44"],[3,66,"gauge44"],[8,6,"gauge44"],[8,43,"gauge44"],[5,20,"gauge44"],[5,57,"gauge44"],[2,34,"gauge44"],[2,71,"gauge44"],[7,11,"gauge44"],[7,48,"gauge44"],[4,25,"gauge44"],[4,62,"gauge44"],[6,16,"gauge44"],[6,53,"gauge44"],[3,30,"gauge44"],[3,67,"gauge44"],[8,7,"gauge44"],[8,44,"gauge44"],[5,21,"gauge44"],[5,58,"gauge44"],[2,35,"gauge44"],[2,72,"gauge44"],[7,12,"gauge44"],[7,49,"gauge44"],[4,26,"gauge44"],[4,63,"gauge44"],[6,17,"gauge44"],[6,54,"gauge44"],[3,31,"gauge44"],[3,68,"gauge44"],[8,8,"gauge44"],[8,45,"gauge44"],[5,22,"gauge44"],[5,59,"gauge44"],[2,36,"gauge44"],[2,73,"gauge44"],[7,13,"gauge44"],[7,50,"gauge44"],[4,27,"gauge44"],[4,64,"gauge44"],[6,18,"gauge44"],[6,55,"gauge44"],[3,32,"gauge44"],[3,69,"gauge44"],[8,9,"gauge44"],[8,46,"gauge44"],[5,23,"gauge44"],[5,60,"gauge44"],[7,14,"gauge44"],[7,51,"gauge44"],[4,28,"gauge44"],[4,65,"gauge44"],[6,19,"gauge44"],[6,56,"gauge44"],[3,33,"gauge44"],[3,70,"gauge44"],[8,10,"gauge44"],[8,47,"gauge44"],[5,24,"gauge44"],[5,61,"gauge44"],[7,15,"gauge44"],[7,52,"gauge44"],[4,29,"gauge44"],[4,66,"gauge44"],[6,20,"gauge44"],[6,57,"gauge44"],[3,34,"gauge44"],[3,71,"gauge44"],[8,11,"gauge44"],[8,48,"gauge44"],[5,25,"gauge44"],[5,62,"gauge44"],[7,16,"gauge44"],[7,53,"gauge44"],[4,30,"gauge44"],[4,67,"gauge44"],[6,21,"gauge44"],[6,58,"gauge44"],[3,35,"gauge44"],[3,72,"gauge44"],[8,12,"gauge44"],[8,49,"gauge44"],[5,26,"gauge44"],[5,63,"gauge44"],[7,17,"gauge44"],[7,54,"gauge44"],[4,31,"gauge44"],[4,68,"gauge44"],[6,22,"gauge44"],[6,59,"gauge44"],[3,36,"gauge44"],[3,73,"gauge44"],[8,13,"gauge44"],[8,50,"gauge44"],[5,27,"gauge44"],[5,64,"gauge44"],[7,18,"gauge44"],[7,55,"gauge44"],[4,32,"gauge44"],[4,69,"gauge44"],[6,23,"gauge44"],[6,60,"gauge44"],[8,14,"gauge44"],[8,51,"gauge44"],[5,28,"gauge44"],[5,65,"gauge44"],[7,19,"gauge44"],[7,56,"gauge44"],[4,33,"gauge44"],[4,70,"gauge44"],[6,24,"gauge44"],[6,61,"gauge44"],[8,15,"gauge44"],[8,52,"gauge44"],[5,29,"gauge44"],[5,66,"gauge44"],[7,20,"gauge44"],[7,57,"gauge44"],[4,34,"gauge44"],[4,71,"gauge44"],[6,25,"gauge44"],[6,62,"gauge44"],[8,16,"gauge44"],[8,53,"gauge44"],[5,30,"gauge44"],[5,67,"gauge44"],[7,21,"gauge44"],[7,58,"gauge44"],[4,35,"gauge44"],[4,72,"gauge44"],[6,26,"gauge44"],[6,63,"gauge44"],[8,17,"gauge44"],[8,54,"gauge44"],[5,31,"gauge44"],[5,68,"gauge44"],[7,22,"gauge44"],[7,59,"gauge44"],[4,36,"gauge44"],[4,73,"gauge44"],[6,27,"gauge44"],[6,64,"gauge44"],[8,18,"gauge44"],[8,55,"gauge44"],[5,32,"gauge44"],[5,69,"gauge44"],[7,23,"gauge44"],[7,60,"gauge44"],[6,28,"gauge44"],[6,65,"gauge44"],[8,19,"gauge44"],[8,56,"gauge44"],[5,33,"gauge44"],[5,70,"gauge44"],[7,24,"gauge44"],[7,61,"gauge44"],[6,29,"gauge44"],[6,66,"gauge44"],[8,20,"gauge44"],[8,57,"gauge44"],[5,34,"gauge44"],[5,71,"gauge44"],[7,25,"gauge44"],[7,62,"gauge44"],[6,30,"gauge44"],[6,67,"gauge44"],[8,21,"gauge44"],[8,58,"gauge44"],[5,35,"gauge44"],[5,72,"gauge44"],[7,26,"gauge44"],[7,63,"gauge44"],[6,31,"gauge44"],[6,68,"gauge44"],[8,22,"gauge44"],[8,59,"gauge44"],[5,36,"gauge44"],[5,73,"gauge44"],[7,27,"gauge44"],[7,64,"gauge44"],[6,32,"gauge44"],[6,69,"gauge44"],[8,23,"gauge44"],[8,60,"gauge44"],[7,28,"gauge44"],[7,65,"gauge44"],[6,33,"gauge44"],[6,70,"gauge44"],[8,24,"gauge44"],[8,61,"gauge44"],[7,29,"gauge44"],[7,66,"gauge44"],[6,34,"gauge44"],[6,71,"gauge44"],[8,25,"gauge44"],[8,62,"gauge44"],[7,30,"gauge44"],[7,67,"gauge44"],[6,35,"gauge44"],[6,72,"gauge44"],[8,26,"gauge44"],[8,63,"gauge44"],[7,31,"gauge44"],[7,68,"gauge44"],[6,36,"gauge44"],[6,73,"gauge44"],[8,27,"gauge44"],[8,64,"gauge44"],[7,32,"gauge44"],[7,69,"gauge44"],[8,28,"gauge44"],[8,65,"gauge44"],[7,33,"gauge44"],[7,70,"gauge44"],[8,29,"gauge44"],[8,66,"gauge44"],[7,34,"gauge44"],[7,71,"gauge44"],[8,30,"gauge44"],[8,67,"gauge44"],[7,35,"gauge44"],[7,72,"gauge44"],[8,31,"gauge44"],[8,68,"gauge44"],[7,36,"gauge44"],[7,73,"gauge44"],[8,32,"gauge44"],[8,69,"gauge44"],[8,33,"gauge44"],[8,70,"gauge44"],[8,34,"gauge44"],[8,71,"gauge44"],[8,35,"gauge44"],[8,72,"gauge44"],[8,36,"gauge44"],[8,73,"gauge44"]] \ No newline at end of file diff --git a/research/paired-extension-cap-fill/allocation/FILL.json.gz b/research/paired-extension-cap-fill/allocation/FILL.json.gz new file mode 100644 index 0000000000..7e19c68553 Binary files /dev/null and b/research/paired-extension-cap-fill/allocation/FILL.json.gz differ diff --git a/research/paired-extension-cap-fill/allocation/ORDER.json b/research/paired-extension-cap-fill/allocation/ORDER.json new file mode 100644 index 0000000000..7409c4df10 --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/ORDER.json @@ -0,0 +1 @@ +[[0,0],[0,37],[0,1],[0,38],[0,2],[0,39],[0,3],[0,40],[0,4],[0,41],[1,0],[1,37],[0,5],[0,42],[1,1],[1,38],[0,6],[0,43],[1,2],[1,39],[0,7],[0,44],[1,3],[1,40],[0,8],[0,45],[1,4],[1,41],[0,9],[0,46],[2,0],[2,37],[1,5],[1,42],[0,10],[0,47],[2,1],[2,38],[1,6],[1,43],[0,11],[0,48],[2,2],[2,39],[1,7],[1,44],[0,12],[0,49],[2,3],[2,40],[1,8],[1,45],[0,13],[0,50],[2,4],[2,41],[1,9],[1,46],[3,0],[3,37],[0,14],[0,51],[2,5],[2,42],[1,10],[1,47],[3,1],[3,38],[0,15],[0,52],[2,6],[2,43],[1,11],[1,48],[3,2],[3,39],[0,16],[0,53],[2,7],[2,44],[1,12],[1,49],[3,3],[3,40],[0,17],[0,54],[2,8],[2,45],[1,13],[1,50],[3,4],[3,41],[0,18],[0,55],[2,9],[2,46],[4,0],[4,37],[1,14],[1,51],[3,5],[3,42],[0,19],[0,56],[2,10],[2,47],[4,1],[4,38],[1,15],[1,52],[3,6],[3,43],[0,20],[0,57],[2,11],[2,48],[4,2],[4,39],[1,16],[1,53],[3,7],[3,44],[0,21],[0,58],[2,12],[2,49],[4,3],[4,40],[1,17],[1,54],[3,8],[3,45],[0,22],[0,59],[2,13],[2,50],[4,4],[4,41],[1,18],[1,55],[3,9],[3,46],[0,23],[0,60],[5,0],[5,37],[2,14],[2,51],[4,5],[4,42],[1,19],[1,56],[3,10],[3,47],[0,24],[0,61],[5,1],[5,38],[2,15],[2,52],[4,6],[4,43],[1,20],[1,57],[3,11],[3,48],[0,25],[0,62],[5,2],[5,39],[2,16],[2,53],[4,7],[4,44],[1,21],[1,58],[3,12],[3,49],[0,26],[0,63],[5,3],[5,40],[2,17],[2,54],[4,8],[4,45],[1,22],[1,59],[3,13],[3,50],[0,27],[0,64],[5,4],[5,41],[2,18],[2,55],[4,9],[4,46],[1,23],[1,60],[6,0],[6,37],[3,14],[3,51],[0,28],[0,65],[5,5],[5,42],[2,19],[2,56],[4,10],[4,47],[1,24],[1,61],[6,1],[6,38],[3,15],[3,52],[0,29],[0,66],[5,6],[5,43],[2,20],[2,57],[4,11],[4,48],[1,25],[1,62],[6,2],[6,39],[3,16],[3,53],[0,30],[0,67],[5,7],[5,44],[2,21],[2,58],[4,12],[4,49],[1,26],[1,63],[6,3],[6,40],[3,17],[3,54],[0,31],[0,68],[5,8],[5,45],[2,22],[2,59],[4,13],[4,50],[1,27],[1,64],[6,4],[6,41],[3,18],[3,55],[0,32],[0,69],[5,9],[5,46],[2,23],[2,60],[7,0],[7,37],[4,14],[4,51],[1,28],[1,65],[6,5],[6,42],[3,19],[3,56],[0,33],[0,70],[5,10],[5,47],[2,24],[2,61],[7,1],[7,38],[4,15],[4,52],[1,29],[1,66],[6,6],[6,43],[3,20],[3,57],[0,34],[0,71],[5,11],[5,48],[2,25],[2,62],[7,2],[7,39],[4,16],[4,53],[1,30],[1,67],[6,7],[6,44],[3,21],[3,58],[0,35],[0,72],[5,12],[5,49],[2,26],[2,63],[7,3],[7,40],[4,17],[4,54],[1,31],[1,68],[6,8],[6,45],[3,22],[3,59],[0,36],[0,73],[5,13],[5,50],[2,27],[2,64],[7,4],[7,41],[4,18],[4,55],[1,32],[1,69],[6,9],[6,46],[3,23],[3,60],[8,0],[8,37],[5,14],[5,51],[2,28],[2,65],[7,5],[7,42],[4,19],[4,56],[1,33],[1,70],[6,10],[6,47],[3,24],[3,61],[8,1],[8,38],[5,15],[5,52],[2,29],[2,66],[7,6],[7,43],[4,20],[4,57],[1,34],[1,71],[6,11],[6,48],[3,25],[3,62],[8,2],[8,39],[5,16],[5,53],[2,30],[2,67],[7,7],[7,44],[4,21],[4,58],[1,35],[1,72],[6,12],[6,49],[3,26],[3,63],[8,3],[8,40],[5,17],[5,54],[2,31],[2,68],[7,8],[7,45],[4,22],[4,59],[1,36],[1,73],[6,13],[6,50],[3,27],[3,64],[8,4],[8,41],[5,18],[5,55],[2,32],[2,69],[7,9],[7,46],[4,23],[4,60],[6,14],[6,51],[3,28],[3,65],[8,5],[8,42],[5,19],[5,56],[2,33],[2,70],[7,10],[7,47],[4,24],[4,61],[6,15],[6,52],[3,29],[3,66],[8,6],[8,43],[5,20],[5,57],[2,34],[2,71],[7,11],[7,48],[4,25],[4,62],[6,16],[6,53],[3,30],[3,67],[8,7],[8,44],[5,21],[5,58],[2,35],[2,72],[7,12],[7,49],[4,26],[4,63],[6,17],[6,54],[3,31],[3,68],[8,8],[8,45],[5,22],[5,59],[2,36],[2,73],[7,13],[7,50],[4,27],[4,64],[6,18],[6,55],[3,32],[3,69],[8,9],[8,46],[5,23],[5,60],[7,14],[7,51],[4,28],[4,65],[6,19],[6,56],[3,33],[3,70],[8,10],[8,47],[5,24],[5,61],[7,15],[7,52],[4,29],[4,66],[6,20],[6,57],[3,34],[3,71],[8,11],[8,48],[5,25],[5,62],[7,16],[7,53],[4,30],[4,67],[6,21],[6,58],[3,35],[3,72],[8,12],[8,49],[5,26],[5,63],[7,17],[7,54],[4,31],[4,68],[6,22],[6,59],[3,36],[3,73],[8,13],[8,50],[5,27],[5,64],[7,18],[7,55],[4,32],[4,69],[6,23],[6,60],[8,14],[8,51],[5,28],[5,65],[7,19],[7,56],[4,33],[4,70],[6,24],[6,61],[8,15],[8,52],[5,29],[5,66],[7,20],[7,57],[4,34],[4,71],[6,25],[6,62],[8,16],[8,53],[5,30],[5,67],[7,21],[7,58],[4,35],[4,72],[6,26],[6,63],[8,17],[8,54],[5,31],[5,68],[7,22],[7,59],[4,36],[4,73],[6,27],[6,64],[8,18],[8,55],[5,32],[5,69],[7,23],[7,60],[6,28],[6,65],[8,19],[8,56],[5,33],[5,70],[7,24],[7,61],[6,29],[6,66],[8,20],[8,57],[5,34],[5,71],[7,25],[7,62],[6,30],[6,67],[8,21],[8,58],[5,35],[5,72],[7,26],[7,63],[6,31],[6,68],[8,22],[8,59],[5,36],[5,73],[7,27],[7,64],[6,32],[6,69],[8,23],[8,60],[7,28],[7,65],[6,33],[6,70],[8,24],[8,61],[7,29],[7,66],[6,34],[6,71],[8,25],[8,62],[7,30],[7,67],[6,35],[6,72],[8,26],[8,63],[7,31],[7,68],[6,36],[6,73],[8,27],[8,64],[7,32],[7,69],[8,28],[8,65],[7,33],[7,70],[8,29],[8,66],[7,34],[7,71],[8,30],[8,67],[7,35],[7,72],[8,31],[8,68],[7,36],[7,73],[8,32],[8,69],[8,33],[8,70],[8,34],[8,71],[8,35],[8,72],[8,36],[8,73]] \ No newline at end of file diff --git a/research/paired-extension-cap-fill/allocation/PROFILE.json b/research/paired-extension-cap-fill/allocation/PROFILE.json new file mode 100644 index 0000000000..968ff38ed2 --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/PROFILE.json @@ -0,0 +1,9 @@ +{ + "1": 1626372, + "2": 426240, + "3": 192474, + "4": 73260, + "5": 24198, + "8": 5328, + "48": 27158 +} \ No newline at end of file diff --git a/research/paired-extension-cap-fill/allocation/PROVIDERS.json b/research/paired-extension-cap-fill/allocation/PROVIDERS.json new file mode 100644 index 0000000000..1bd962152f --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/PROVIDERS.json @@ -0,0 +1,842 @@ +{ + "extra": { + "actual_paid_profile": { + "1": 2416, + "2": 640, + "3": 280, + "4": 110, + "5": 26, + "8": 8 + }, + "widths": [ + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 8, + 9, + 9, + 9, + 9, + 8, + 9, + 9, + 4, + 9, + 4, + 9, + 8, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 8, + 9, + 9, + 4, + 9, + 4, + 9, + 8, + 9, + 9, + 4, + 8, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 4, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 4, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 4, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 4, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 8, + 9, + 9, + 9, + 8, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 8, + 9, + 9, + 9, + 8, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 9, + 8, + 8, + 9, + 8, + 9, + 8, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 8, + 8, + 7, + 7, + 7, + 7, + 8, + 9, + 8, + 9, + 7, + 7, + 7, + 7, + 7, + 7, + 9, + 9, + 9, + 9, + 8, + 8, + 8, + 8, + 8, + 8, + 9, + 9, + 9, + 9, + 8, + 7, + 7, + 8, + 8, + 8, + 8, + 9, + 9, + 9, + 9, + 8, + 8, + 8, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 8, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 8, + 7, + 8, + 8, + 9, + 9, + 9, + 9, + 8, + 8, + 8, + 8, + 7, + 7, + 7, + 7, + 9, + 8, + 9, + 8, + 8, + 8, + 8, + 8, + 7, + 7, + 9, + 8, + 9, + 8, + 7, + 7, + 7, + 7, + 8, + 8, + 8, + 8, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 5, + 5, + 8, + 8, + 8, + 8 + ] + }, + "gauge44": { + "actual_paid_profile": { + "1": 2416, + "2": 640, + "3": 280, + "4": 110, + "5": 26, + "8": 8 + }, + "widths": [ + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 8, + 9, + 9, + 9, + 9, + 8, + 9, + 9, + 4, + 9, + 4, + 9, + 8, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 8, + 9, + 9, + 4, + 9, + 4, + 9, + 8, + 9, + 9, + 4, + 8, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 4, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 4, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 4, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 4, + 9, + 4, + 9, + 4, + 9, + 9, + 9, + 9, + 4, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 8, + 9, + 9, + 9, + 8, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 8, + 9, + 9, + 9, + 8, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 9, + 8, + 8, + 9, + 8, + 9, + 8, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 8, + 8, + 7, + 7, + 7, + 7, + 8, + 9, + 8, + 9, + 7, + 7, + 7, + 7, + 7, + 7, + 9, + 9, + 9, + 9, + 8, + 8, + 8, + 8, + 8, + 8, + 9, + 9, + 9, + 9, + 8, + 7, + 7, + 8, + 8, + 8, + 8, + 9, + 9, + 9, + 9, + 8, + 8, + 8, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 8, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 8, + 7, + 8, + 8, + 9, + 9, + 9, + 9, + 8, + 8, + 8, + 8, + 7, + 7, + 7, + 7, + 9, + 8, + 9, + 8, + 8, + 8, + 8, + 8, + 7, + 7, + 9, + 8, + 9, + 8, + 7, + 7, + 7, + 7, + 8, + 8, + 8, + 8, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 5, + 5, + 8, + 8, + 8, + 8 + ] + } +} \ No newline at end of file diff --git a/research/paired-extension-cap-fill/allocation/SEARCH.json b/research/paired-extension-cap-fill/allocation/SEARCH.json new file mode 100644 index 0000000000..1e9e932dd1 --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/SEARCH.json @@ -0,0 +1,51 @@ +{ + "calls": 666, + "gain_vs_PR2917_claim": "113907405684085469/125000000000000000000000", + "gain_vs_PR2917_claim_float": 9.112592454726837e-07, + "headline_floor24_minus_1e-46_minus_1e-70": "0.0017224999064432745643569999999999999999999998999999999999999999999999", + "idle_histogram": { + "1": 17316, + "3": 5994, + "48": 27158, + "5": 6882 + }, + "kappa_root_bracket": [ + "1722499906443274564357/1000000000000000000000000", + "17224999064432745643571/10000000000000000000000000" + ], + "kappa_root_lower_decimal": "0.001722499906443274564357", + "lineage": "PR2917 (mason-hale) words/chronology/engine; PR2857 flow model and realization (discover_original.py / PR2843 build_allocation.py); PR2839 owner engine; lane C r12 relax/root/fill tools; r13 lane C1.", + "method": [ + "relax.py (lane C r12): exact 1163-pattern fixed-capacity relaxation of inventory {4:26,5:2,7:62,8:96,9:222} with local {1:2416,2:640,3:280,4:110,5:26,8:8}: cap bracket [1722499906443274564357/1e24, 17224999064432745643571/1e25]; the optimal basic solution is integral per replica ([8] 672, [7,9] 352, [7,7,9,9] 103, [8,8] 96, [9^5] 81, [5,9,9,9] 18, [9,9,9] 93, [4,9,9,9] 234, [] 367).", + "fill17.py: PR2857-style chronological flow model (X[window-class,pattern] bins, Z[.,.,call,width] roles, one role per bin per call, exact pattern supply, per-call width demand, global pattern targets = the integral LP mix) under PR2833's T37 owners chronology (333 calls); CP-SAT 9.15.6755, num_search_workers=1, random_seed=7, hint = PR2857 FLOW.json.gz (3065 matching variables) + zeros; first feasible flow at 266.7 s; regular-bipartite edge colouring realizes literal bins.", + "double.py: PR2917's T74 ORDER is the exact interleaving of two copies of the T37 chronology (order74[2k]=order37[k], order74[2k+1]=(stage, replica+37)) with the dispatch copied, so row (t,h,o,c,p,z) -> (2t,h,o,c,p,z) and (2t+1,h,o+37,c,p,z) is a T74 fill on PR2917's own chronology.", + "Checks: vendored PR2839 owner engine check() (sha 77a84872...) PASS; the five check_allocation.py rejection controls; PR2917's tools/audit_allocation_moment.py exact dyadic moment (source = PR2917 allocation/baseline); root.py exact bracket." + ], + "order_and_dispatch_unchanged_vs_PR2917": true, + "physical": 66804, + "pr2917_pins_unchanged": { + "allocation/DISPATCH.json": "65e435bd68e97243c003677271b88485a29d4d0fae2dff1354100404a145e74c", + "allocation/ORDER.json": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "allocation/vendor/PLAN.json.gz": "d566cfb87b71639d4138e1f89b543e2dd6a7772070226a2a14c799a6835bf21e", + "allocation/vendor/TEMPLATE.json.gz": "21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e", + "allocation/vendor/independent_owners.py": "77a848729159e271ba64f403dfd59dddb13044b17b2950fa56700f442e2fe461" + }, + "profile": { + "1": 1626372, + "2": 426240, + "3": 192474, + "4": 73260, + "48": 27158, + "5": 24198, + "8": 5328 + }, + "relaxation_cap_bracket": [ + "1722499906443274564357/1000000000000000000000000", + "17224999064432745643571/10000000000000000000000000" + ], + "replicas": 74, + "roles": 271728, + "scope": "Literal owner allocation for PR2917's UNCHANGED words (same PROVIDERS widths/local profile, same ORDER/DISPATCH chronology); attains the exact fractional packing cap of the inventory. Local/native/global/outer admission remains separate.", + "source_words_unchanged_by_allocation": true, + "status": "C1_FLOW_ROUTE_CAP_ATTAINING_LITERAL_FILL" +} \ No newline at end of file diff --git a/research/paired-extension-cap-fill/allocation/baseline/CLAIM.json b/research/paired-extension-cap-fill/allocation/baseline/CLAIM.json new file mode 100644 index 0000000000..50cc0eeeba --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/baseline/CLAIM.json @@ -0,0 +1,35 @@ +{ + "baseline_head": "51309592971e3b5be935599eed2a95404dc7781e", + "baseline_kappa": "17203983373542378859309999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000", + "baseline_pr": 2908, + "calls": 666, + "complete_package_manifest_sha256": "bf852fb4ecfa28dddfb8cc6fe7bf53019b3932114e01cba3e026b63ef2b1babd", + "complex_lower": "344317729439560376121/200000000000000000000000", + "gain": "595154921781997337/500000000000000000000000", + "helpers": 408, + "independent_inputs": 632, + "kappa": "17215886471978018806049999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000", + "kappa_decimal": "0.0017215886471978018806049999999999999999999998999999999999999999999999", + "live_families": 66304, + "native_receipt_sha256": "5c1ea6f03e48673d9b56563494fff2258ee18bc8dacdeb72ba5c07e2044008ca", + "physical_families": 66804, + "profile": { + "1": 1625724, + "2": 426240, + "24": 1, + "3": 191980, + "32": 207, + "4": 73260, + "48": 26958, + "5": 24951, + "6": 167, + "7": 45, + "8": 5328 + }, + "release_receipt_sha256": "f7639e51fd620070767b8e2a855a0a613ae9bfd19f86a1ba023d88316193ae06", + "replicas": 74, + "scope": "Conditional finite supplier/outer certificate. Inherited all-size/compiler/theorem hypotheses remain. No selected frontier change, optimality or independent-human-review claim. Both changed native chains are fresh; unchanged retained parent/native evidence is explicitly authenticated and reused.", + "source_manifest_sha256": "98d57c82a1c7318be3c330c3b66897844d57232f0aaeaea88fb4bebd0a1bedf1", + "status": "CONDITIONAL_CANDIDATE_COMPLETE_FINITE_RELEASE", + "zero_buffers": 82 +} diff --git a/research/paired-extension-cap-fill/allocation/baseline/ORDER.json b/research/paired-extension-cap-fill/allocation/baseline/ORDER.json new file mode 100644 index 0000000000..7409c4df10 --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/baseline/ORDER.json @@ -0,0 +1 @@ +[[0,0],[0,37],[0,1],[0,38],[0,2],[0,39],[0,3],[0,40],[0,4],[0,41],[1,0],[1,37],[0,5],[0,42],[1,1],[1,38],[0,6],[0,43],[1,2],[1,39],[0,7],[0,44],[1,3],[1,40],[0,8],[0,45],[1,4],[1,41],[0,9],[0,46],[2,0],[2,37],[1,5],[1,42],[0,10],[0,47],[2,1],[2,38],[1,6],[1,43],[0,11],[0,48],[2,2],[2,39],[1,7],[1,44],[0,12],[0,49],[2,3],[2,40],[1,8],[1,45],[0,13],[0,50],[2,4],[2,41],[1,9],[1,46],[3,0],[3,37],[0,14],[0,51],[2,5],[2,42],[1,10],[1,47],[3,1],[3,38],[0,15],[0,52],[2,6],[2,43],[1,11],[1,48],[3,2],[3,39],[0,16],[0,53],[2,7],[2,44],[1,12],[1,49],[3,3],[3,40],[0,17],[0,54],[2,8],[2,45],[1,13],[1,50],[3,4],[3,41],[0,18],[0,55],[2,9],[2,46],[4,0],[4,37],[1,14],[1,51],[3,5],[3,42],[0,19],[0,56],[2,10],[2,47],[4,1],[4,38],[1,15],[1,52],[3,6],[3,43],[0,20],[0,57],[2,11],[2,48],[4,2],[4,39],[1,16],[1,53],[3,7],[3,44],[0,21],[0,58],[2,12],[2,49],[4,3],[4,40],[1,17],[1,54],[3,8],[3,45],[0,22],[0,59],[2,13],[2,50],[4,4],[4,41],[1,18],[1,55],[3,9],[3,46],[0,23],[0,60],[5,0],[5,37],[2,14],[2,51],[4,5],[4,42],[1,19],[1,56],[3,10],[3,47],[0,24],[0,61],[5,1],[5,38],[2,15],[2,52],[4,6],[4,43],[1,20],[1,57],[3,11],[3,48],[0,25],[0,62],[5,2],[5,39],[2,16],[2,53],[4,7],[4,44],[1,21],[1,58],[3,12],[3,49],[0,26],[0,63],[5,3],[5,40],[2,17],[2,54],[4,8],[4,45],[1,22],[1,59],[3,13],[3,50],[0,27],[0,64],[5,4],[5,41],[2,18],[2,55],[4,9],[4,46],[1,23],[1,60],[6,0],[6,37],[3,14],[3,51],[0,28],[0,65],[5,5],[5,42],[2,19],[2,56],[4,10],[4,47],[1,24],[1,61],[6,1],[6,38],[3,15],[3,52],[0,29],[0,66],[5,6],[5,43],[2,20],[2,57],[4,11],[4,48],[1,25],[1,62],[6,2],[6,39],[3,16],[3,53],[0,30],[0,67],[5,7],[5,44],[2,21],[2,58],[4,12],[4,49],[1,26],[1,63],[6,3],[6,40],[3,17],[3,54],[0,31],[0,68],[5,8],[5,45],[2,22],[2,59],[4,13],[4,50],[1,27],[1,64],[6,4],[6,41],[3,18],[3,55],[0,32],[0,69],[5,9],[5,46],[2,23],[2,60],[7,0],[7,37],[4,14],[4,51],[1,28],[1,65],[6,5],[6,42],[3,19],[3,56],[0,33],[0,70],[5,10],[5,47],[2,24],[2,61],[7,1],[7,38],[4,15],[4,52],[1,29],[1,66],[6,6],[6,43],[3,20],[3,57],[0,34],[0,71],[5,11],[5,48],[2,25],[2,62],[7,2],[7,39],[4,16],[4,53],[1,30],[1,67],[6,7],[6,44],[3,21],[3,58],[0,35],[0,72],[5,12],[5,49],[2,26],[2,63],[7,3],[7,40],[4,17],[4,54],[1,31],[1,68],[6,8],[6,45],[3,22],[3,59],[0,36],[0,73],[5,13],[5,50],[2,27],[2,64],[7,4],[7,41],[4,18],[4,55],[1,32],[1,69],[6,9],[6,46],[3,23],[3,60],[8,0],[8,37],[5,14],[5,51],[2,28],[2,65],[7,5],[7,42],[4,19],[4,56],[1,33],[1,70],[6,10],[6,47],[3,24],[3,61],[8,1],[8,38],[5,15],[5,52],[2,29],[2,66],[7,6],[7,43],[4,20],[4,57],[1,34],[1,71],[6,11],[6,48],[3,25],[3,62],[8,2],[8,39],[5,16],[5,53],[2,30],[2,67],[7,7],[7,44],[4,21],[4,58],[1,35],[1,72],[6,12],[6,49],[3,26],[3,63],[8,3],[8,40],[5,17],[5,54],[2,31],[2,68],[7,8],[7,45],[4,22],[4,59],[1,36],[1,73],[6,13],[6,50],[3,27],[3,64],[8,4],[8,41],[5,18],[5,55],[2,32],[2,69],[7,9],[7,46],[4,23],[4,60],[6,14],[6,51],[3,28],[3,65],[8,5],[8,42],[5,19],[5,56],[2,33],[2,70],[7,10],[7,47],[4,24],[4,61],[6,15],[6,52],[3,29],[3,66],[8,6],[8,43],[5,20],[5,57],[2,34],[2,71],[7,11],[7,48],[4,25],[4,62],[6,16],[6,53],[3,30],[3,67],[8,7],[8,44],[5,21],[5,58],[2,35],[2,72],[7,12],[7,49],[4,26],[4,63],[6,17],[6,54],[3,31],[3,68],[8,8],[8,45],[5,22],[5,59],[2,36],[2,73],[7,13],[7,50],[4,27],[4,64],[6,18],[6,55],[3,32],[3,69],[8,9],[8,46],[5,23],[5,60],[7,14],[7,51],[4,28],[4,65],[6,19],[6,56],[3,33],[3,70],[8,10],[8,47],[5,24],[5,61],[7,15],[7,52],[4,29],[4,66],[6,20],[6,57],[3,34],[3,71],[8,11],[8,48],[5,25],[5,62],[7,16],[7,53],[4,30],[4,67],[6,21],[6,58],[3,35],[3,72],[8,12],[8,49],[5,26],[5,63],[7,17],[7,54],[4,31],[4,68],[6,22],[6,59],[3,36],[3,73],[8,13],[8,50],[5,27],[5,64],[7,18],[7,55],[4,32],[4,69],[6,23],[6,60],[8,14],[8,51],[5,28],[5,65],[7,19],[7,56],[4,33],[4,70],[6,24],[6,61],[8,15],[8,52],[5,29],[5,66],[7,20],[7,57],[4,34],[4,71],[6,25],[6,62],[8,16],[8,53],[5,30],[5,67],[7,21],[7,58],[4,35],[4,72],[6,26],[6,63],[8,17],[8,54],[5,31],[5,68],[7,22],[7,59],[4,36],[4,73],[6,27],[6,64],[8,18],[8,55],[5,32],[5,69],[7,23],[7,60],[6,28],[6,65],[8,19],[8,56],[5,33],[5,70],[7,24],[7,61],[6,29],[6,66],[8,20],[8,57],[5,34],[5,71],[7,25],[7,62],[6,30],[6,67],[8,21],[8,58],[5,35],[5,72],[7,26],[7,63],[6,31],[6,68],[8,22],[8,59],[5,36],[5,73],[7,27],[7,64],[6,32],[6,69],[8,23],[8,60],[7,28],[7,65],[6,33],[6,70],[8,24],[8,61],[7,29],[7,66],[6,34],[6,71],[8,25],[8,62],[7,30],[7,67],[6,35],[6,72],[8,26],[8,63],[7,31],[7,68],[6,36],[6,73],[8,27],[8,64],[7,32],[7,69],[8,28],[8,65],[7,33],[7,70],[8,29],[8,66],[7,34],[7,71],[8,30],[8,67],[7,35],[7,72],[8,31],[8,68],[7,36],[7,73],[8,32],[8,69],[8,33],[8,70],[8,34],[8,71],[8,35],[8,72],[8,36],[8,73]] \ No newline at end of file diff --git a/research/paired-extension-cap-fill/allocation/baseline/PROFILE.json b/research/paired-extension-cap-fill/allocation/baseline/PROFILE.json new file mode 100644 index 0000000000..a3c711f5c3 --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/baseline/PROFILE.json @@ -0,0 +1,13 @@ +{ + "1": 1625724, + "2": 426240, + "3": 191980, + "4": 73260, + "5": 24951, + "6": 167, + "7": 45, + "8": 5328, + "24": 1, + "32": 207, + "48": 26958 +} \ No newline at end of file diff --git a/research/paired-extension-cap-fill/allocation/vendor/PLAN.json.gz b/research/paired-extension-cap-fill/allocation/vendor/PLAN.json.gz new file mode 100644 index 0000000000..7a1db55a4d Binary files /dev/null and b/research/paired-extension-cap-fill/allocation/vendor/PLAN.json.gz differ diff --git a/research/paired-extension-cap-fill/allocation/vendor/TEMPLATE.json.gz b/research/paired-extension-cap-fill/allocation/vendor/TEMPLATE.json.gz new file mode 100644 index 0000000000..114808c32b Binary files /dev/null and b/research/paired-extension-cap-fill/allocation/vendor/TEMPLATE.json.gz differ diff --git a/research/paired-extension-cap-fill/allocation/vendor/independent_owners.py b/research/paired-extension-cap-fill/allocation/vendor/independent_owners.py new file mode 100644 index 0000000000..16013201b1 --- /dev/null +++ b/research/paired-extension-cap-fill/allocation/vendor/independent_owners.py @@ -0,0 +1,111 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Independent integer-time and mask check of the actual parameterized-replica owner allocation with PR2802 retired7 providers. + +Chronology/mask method derives from Tekalign's PR2751 independent_owners.py; +Marius-Paul Dumitrean's PR2802 retired7 native construction and the retained +provider frame checker keep their +upstream attribution. No solver, producer, emitter or floating arithmetic is +imported. This checks finite geometry, not global native/outer admission. +""" +from pathlib import Path +from collections import Counter,defaultdict +import argparse,hashlib,gzip,json,sys,types +sys.dont_write_bytecode=True +def need(v,msg): + if not v:raise ValueError(msg) +def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest() +def read(p): + b=Path(p).read_bytes();return json.loads(gzip.decompress(b)if str(p).endswith('.gz')else b) +def inputs(PROVIDER): + provider_pins={'inputs/PLAN.json.gz':'afb3c5c8134fc2cfce0b50a21758490c225574994b2c3c5161e53e2355acc6fa','inputs/GLOBAL-TEMPLATE.json.gz':'21297b20f1f2dc76eb9dd8124416068c3cb096bab9df17fa4da19bc68dfe082e','independent_local.py':'ee1faab70095fa312fc61d375ddf015b76104cb1a542ae7876a149e7999faa20','inputs/PROVIDERS.json':'391075b1411a3976850c633f92f58c35ed3f046f09d55bd435d7545124543fd4','inputs/WORD-base.json.gz':'dca8becca633ffc5e998985631bcbcab1123b27ca7f10ac6a96b1ec21ce69a66','inputs/WORD-extra.json.gz':'6bcb3c2c73eaf7558ddc6ef6b484334f8d96b9d2b227e265483b657de00f4bb7'} + hashes={} + for n,pin in provider_pins.items(): + p=PROVIDER/n;need(sha(p)==pin,'pinned PR2802 provider source '+n);hashes[str(p)]=pin + L=types.ModuleType('retained_independent_frames');exec(compile((PROVIDER/'independent_local.py').read_bytes(),'pinned_PR2802_independent_local.py','exec'),L.__dict__);providers=read(PROVIDER/'inputs/PROVIDERS.json') + for tag,pid in [('base','gauge44'),('extra','extra')]: + word=read(PROVIDER/f'inputs/WORD-{tag}.json.gz');report,start,ends=L.check_frames(word);L.check_cleanup(word);L.algebra(word) + widths=[L.dm(ends[k])-L.dm(start[k])for k in sorted(start)if k>=224] + need(widths==providers[pid]['widths']and len(widths)==408,'actual ordered provider frame widths');need(len(word['centers'])==8,'eight centres');providers[pid]['actual_paid_profile']={int(k):v for k,v in report['profile'].items()} + return read(PROVIDER/'inputs/PLAN.json.gz'),read(PROVIDER/'inputs/GLOBAL-TEMPLATE.json.gz'),providers,hashes + +def windows(template,order,T): + ranks={c['child']:c['rank']for c in template['idle_children']};pairs={e['stage']:e['pair']for e in template['recipe']if e['kind']=='local'} + blocks={};stage=None + for event in template['execution_schedule']: + if event['kind']in('bank_padding_cover_sweep','translate_every_live_family'):continue + if event['kind']=='local_cover_sweep':stage=event['stage'];blocks[stage]=[] + need(stage is not None,'source event before local call');blocks[stage].append(event) + need(set(blocks)==set(range(9)),'nine source stages') + progress=[0]*T;last={};result={} + for t,(stage,replica)in enumerate(order): + need(0<=replica0,'idle source position');start=last.get((replica,event['pair']),-1) + for child in event['child_indices']: + if child in ranks:result[replica,child]=(ranks[child],start,t) + elif kind in ('terminal_Y_translations','terminal'):pass # inherited terminal phase; no pending-window endpoints + else:raise ValueError('unknown source event kind') + need(progress==[9]*T,'complete replica source progression');return result + +def check(T,order,fill,dispatch,claimed,plan,template,providers): + need(type(T)is int and T>0,'positive T');N=9*T + need(len(order)==N and set(map(tuple,order))=={(s,r)for s in range(9)for r in range(T)},'complete T call coverage') + win=windows(template,order,T) + need(set(dispatch)==set(map(tuple,order))and all(p in providers for p in dispatch.values()),'provider dispatch coverage') + for s,r,pid in fill.get('dispatch_overrides',[]):need(dispatch.get((s,r))==pid,'final dispatch override binding') + need(fill['columns']==['time','helper','owner_replica','child','port','offset'],'literal role columns') + need(len(fill['rows'])==N*408,'complete role count');helpers=[0]*N;families=[0]*N;occupied={};lastrow={} + for idx,row in enumerate(fill['rows']): + need(len(row)==6 and all(type(x)is int for x in row),'integer role shape');t,h,o,c,p,z=row + need(0<=tlastrow[key][0]:lastrow[key]=(z,idx,w) + need(helpers==[(1<<408)-1]*N,'all helper identities');idle=Counter() + for(o,c),(cap,_,_)in win.items(): + for p in range(112): + key=(o,c,p);mask=occupied.get(key,0);used=mask.bit_count();need(mask==(1<= 704} + assert buffers == {704 + int(h) for h in word['helper_final']}, 'actual cleanup buffer/end-point bijection' + assert len(buffers) == 82, 'all 82 private buffers charged' + private_counts.add(len(buffers)) + providers[provider] = {'widths': widths, 'actual_paid_profile': {int(k): v for k, v in profile.items()}} + word_records[tag] = {'sha256': sha(path), 'local_profile': profile, 'width_inventory': inventory, 'private_buffers': len(buffers)} + assert len(private_counts) == 1 + registry = read(P / 'allocation/PROVIDERS.json') + assert {k: {'widths': v['widths'], 'actual_paid_profile': {int(r): n for r, n in v['actual_paid_profile'].items()}} for k, v in registry.items()} == providers + base = P / 'allocation' + order, fill = read(base / 'ORDER.json'), read(base / 'FILL.json.gz') + raw_dispatch = read(base / 'DISPATCH.json') + dispatch = {(s, r): provider for s, r, provider in raw_dispatch} + assert len(dispatch) == len(raw_dispatch), 'unique actual call/provider binding' + profile = read(base / 'PROFILE.json') + plan, template = read(base / 'vendor/PLAN.json.gz'), read(base / 'vendor/TEMPLATE.json.gz') + T = len(order) // 9 + def check(candidate=fill, claimed=profile): + return owners.check(T, order, candidate, dispatch, claimed, plan, template, providers) + result, _, _ = check() + assert T == 74 and result['roles'] == 271728 + result['physical'] = result['live'] + len(helpers) + len(word['centers']) + next(iter(private_counts)) + 2 + assert result['physical'] == 66804 + result['physical_source'] = 'Actual 82-register private cleanup namespace, 408 live helpers, eight centres and two guards; global stock checked separately.' + controls = {} + def reject(name, candidate=fill, claimed=profile): + try: + check(candidate, claimed) + except ValueError as error: + controls[name] = str(error) + else: + raise AssertionError('owner corruption accepted: ' + name) + reject('missing_role', {**fill, 'rows': fill['rows'][:-1]}) + first = fill['rows'][0] + j = next(i for i, r in enumerate(fill['rows'][1:], 1) if r[0] == first[0]) + def mutate(index, row): + rows = list(fill['rows']); rows[index] = row + return {**fill, 'rows': rows} + duplicate = list(fill['rows'][j]); duplicate[1] = first[1] + reject('duplicate_helper', mutate(j, duplicate)) + collision = list(fill['rows'][j]); collision[2:5] = first[2:5] + reject('same_call_family_collision', mutate(j, collision)) + overflow = list(first); overflow[5] = 49 + reject('capacity_overflow', mutate(0, overflow)) + wrong = dict(profile); wrong['1'] = wrong.get('1', 0) + 1 + reject('changed_paid_profile', claimed=wrong) + exact = moment.run(base, base / 'baseline') + claim = read(P / 'CLAIM.json') + assert {str(k): v for k, v in profile.items()} == {str(k): v for k, v in claim['profile'].items()}, 'claimed complete profile' + assert all(sha(P / name) == digest for name, digest in {**word_pins, **allocation_pins}.items()), 'input drift' + result.update(status='PASS_CAP_FILL_LITERAL_OWNERS_AND_EXACT_MOMENT', providers=word_records, + controls=controls, moment=exact, allocation_sha256=allocation_pins, + scope='Recounted local frames, exact whole-owner geometry and directed moment; algebra/native/global/outer admission remains separately required.') + (out / 'RESULT.json').write_text(json.dumps(result, sort_keys=True, indent=2) + '\n') + print(result['status'], exact['target_decimal'], exact['gain_decimal']) + +if __name__ == '__main__': + main() diff --git a/research/paired-extension-cap-fill/check_cap.py b/research/paired-extension-cap-fill/check_cap.py new file mode 100644 index 0000000000..c1569e8ebc --- /dev/null +++ b/research/paired-extension-cap-fill/check_cap.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Fractions-only certificate that the literal allocation attains the fixed-capacity packing optimum. + +certificates/RELAX-CAP.json stores the 9-pattern optimal basis of the fractional relaxation of PR2917's +unchanged inventory (bins 672/448/448/448 per replica of capacity 8/16/32/48, all 1,163 count-vector +patterns, one idle child per bin, the complete per-call local profile paid). tools/relax_exact.py checks, +with exact rationals only: primal feasibility of the basis (so the cap is at least its root) and the sign of +every pattern's reduced cost at the upper end of the root bracket (weak duality: the cap is at most that +end). This script then checks that the literal complete profile of allocation/PROFILE.json EQUALS the +basic solution's profile summed over the 74 replicas (666 calls x local + 74 x idle), and that its exact +root bracket equals the cap bracket. Hence no allocation of these words, under these capacities and this +relaxation, can have a larger complex endpoint. It is not a bound over changed words or other templates. +Marius-Paul Dumitrean, with substantial AI assistance (Claude Code). The relaxation model and root +arithmetic are ours (research/t37-word-level-census-r12 lineage); the moment model is the shared +complete-profile moment used by PR2857/PR2917. +""" +import gzip, json, sys +from fractions import Fraction as Q +from pathlib import Path +P = Path(__file__).resolve().parent +sys.path.insert(0, str(P / 'tools')) +import relax_exact as RE +import root as R + +def read(path): + raw = path.read_bytes() + return json.loads(gzip.decompress(raw) if raw[:2] == b'\x1f\x8b' else raw) + +def main(): + if not __debug__: + raise SystemExit('refusing python -O') + cert = read(P / 'certificates/RELAX-CAP.json') + words = [read(P / f'data/WORD-{t}.json.gz') for t in ('base', 'extra')] + for w in words: + assert {k: v for k, v in w['report']['local_profile'].items()} == cert['local_per_call'], 'certificate local profile = actual words' + assert {k: v for k, v in w['report']['width_inventory'].items()} == cert['inventory_per_call'], 'certificate inventory = actual words' + r = RE.verify_basis(cert['local_per_call'], cert['inventory_per_call'], cert['basis_patterns']) + assert r['status'] == 'PASS_EXACT_RELAXATION_CAP' and r['patterns'] == 1163 + assert Q(r['cap_lower']) == Q(cert['cap_lower']) and Q(r['cap_upper']) == Q(cert['cap_upper']) + T, calls = 74, 666 + expected = {} + for k, v in cert['local_per_call'].items(): + expected[int(k)] = expected.get(int(k), 0) + calls * v + for k, v in r['idle_per_replica'].items(): + n = T * Q(v) + assert n.denominator == 1, 'integral idle multiplicity at T74' + expected[int(k)] = expected.get(int(k), 0) + int(n) + profile = {int(k): v for k, v in read(P / 'allocation/PROFILE.json').items()} + assert profile == expected, 'literal complete profile equals the fractional optimum profile' + lo, hi = R.kappa_from_profile(profile, T) + assert (lo, hi) == (Q(cert['cap_lower']), Q(cert['cap_upper'])), 'literal root bracket equals the cap bracket' + # rejection controls: a perturbed basis and a perturbed profile must fail + controls = {} + try: + bad = [dict(e) for e in cert['basis_patterns']]; bad[0] = dict(bad[0]); bad[0]['widths'] = list(bad[0]['widths']) + [4] + RE.verify_basis(cert['local_per_call'], cert['inventory_per_call'], bad) + except Exception as error: + controls['perturbed_basis_pattern'] = str(error)[:120] + else: + raise AssertionError('perturbed basis accepted') + # a finer split of one idle rank-3 child into rank 1 + rank 2 (same rank mass) lowers the root strictly + # (concavity) and is not the optimum's profile + finer = dict(profile); finer[3] -= 1; finer[1] += 1; finer[2] += 1 + assert sum(r * n for r, n in finer.items()) == sum(r * n for r, n in profile.items()) + if not R.kappa_from_profile(finer, T)[1] < lo: + raise AssertionError('a finer idle split must fall strictly below the cap') + if finer == expected: + raise AssertionError('profile-equality check must reject a perturbed profile') + controls['finer_split_strictly_below_cap_and_rejected'] = 'PASS' + out = dict(status='PASS_LITERAL_ALLOCATION_ATTAINS_FIXED_INVENTORY_CAP', cap_lower=str(lo), cap_upper=str(hi), + tight_patterns=r['tight_patterns'], strict_patterns=r['strict_patterns'], idle_per_replica=r['idle_per_replica'], + profile={str(k): v for k, v in sorted(profile.items())}, controls=controls) + print(json.dumps(out, sort_keys=True)) + +if __name__ == '__main__': + main() diff --git a/research/paired-extension-cap-fill/construction/T37-FLOW.json.gz b/research/paired-extension-cap-fill/construction/T37-FLOW.json.gz new file mode 100644 index 0000000000..4f61d6da2f Binary files /dev/null and b/research/paired-extension-cap-fill/construction/T37-FLOW.json.gz differ diff --git a/research/paired-extension-cap-fill/construction/T37-MODEL.json b/research/paired-extension-cap-fill/construction/T37-MODEL.json new file mode 100644 index 0000000000..1f5dfa6783 --- /dev/null +++ b/research/paired-extension-cap-fill/construction/T37-MODEL.json @@ -0,0 +1 @@ +{"T":37,"catalogue":"tight","chronology":"pr2833-t37","constraints":78830,"flow_variables":94492,"groups":333,"nonzeros":361705,"pattern_variables":703,"patterns_per_cap":{"16":2,"32":4,"48":2,"8":1},"variables":95195,"workers":1} \ No newline at end of file diff --git a/research/paired-extension-cap-fill/construction/T37-PATTERNS.json b/research/paired-extension-cap-fill/construction/T37-PATTERNS.json new file mode 100644 index 0000000000..cd4b0b3ecf --- /dev/null +++ b/research/paired-extension-cap-fill/construction/T37-PATTERNS.json @@ -0,0 +1 @@ +{"T":37,"catalogue":"tight","chronology":"pr2833-t37","gain_vs_PR2917_claim_exact_lower":"9112592454726837520000000000000000000001000000000000000000000001/10000000000000000000000000000000000000000000000000000000000000000000000","gain_vs_PR2917_claim_float":9.112592454726837e-07,"gain_vs_PR2917_root_lower_float":9.112592454726837e-07,"gap_to_relaxation_cap":1e-25,"headline_floor24_minus":"17224999064432745643569999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000","idle":{"1":8658,"3":2997,"5":3441,"48":13579},"kappa_lower":"1722499906443274564357/1000000000000000000000000","kappa_lower_decimal":"0.001722499906443274564357","kappa_upper":"17224999064432745643571/10000000000000000000000000","kappa_upper_decimal":"0.0017224999064432745643571","mode":"milp","profile":{"1":813186,"2":213120,"3":96237,"4":36630,"5":12099,"8":2664,"48":13579},"relaxation_cap_lower":"1722499906443274564357/1000000000000000000000000","relaxation_cap_upper":"17224999064432745643571/10000000000000000000000000","relaxation_cap_upper_decimal":"0.0017224999064432745643571","target":[[8,[0,0,0,1,0],24864],[16,[0,0,0,2,0],3552],[16,[0,0,1,0,1],13024],[32,[0,0,0,0,3],3441],[32,[0,0,2,0,2],3811],[32,[0,1,0,0,3],666],[32,[1,0,0,0,3],8658],[48,[0,0,0,0,0],13579],[48,[0,0,0,0,5],2997]],"widths":[4,5,7,8,9]} \ No newline at end of file diff --git a/research/paired-extension-cap-fill/construction/T37-SOLVER.json b/research/paired-extension-cap-fill/construction/T37-SOLVER.json new file mode 100644 index 0000000000..38938d4a67 --- /dev/null +++ b/research/paired-extension-cap-fill/construction/T37-SOLVER.json @@ -0,0 +1 @@ +{"T":37,"candidate":true,"catalogue":"tight","chronology":"pr2833-t37","hint_fill":null,"hint_flow":"../../../r12/vendor/pr2857/research/shared-kernel-repacking/allocation/construction/FLOW.json.gz","hint_zeros":true,"max_time_seconds":900,"seconds":267.91080689430237,"seed":7,"status":"OPTIMAL","workers":1} \ No newline at end of file diff --git a/research/paired-extension-cap-fill/construction/controls.py b/research/paired-extension-cap-fill/construction/controls.py new file mode 100644 index 0000000000..08ee9f4653 --- /dev/null +++ b/research/paired-extension-cap-fill/construction/controls.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +"""controls.py -- independent re-verification of a produced allocation directory exactly the way #2917's check_allocation.py does: +fresh load of the vendored PR2839 engine from #2917's package, owner.check(T, ORDER, FILL, DISPATCH, PROFILE(claimed), PLAN, TEMPLATE, PROVIDERS), +the five semantic rejection controls (missing role, duplicate helper, same-call family collision, capacity overflow, changed paid profile), +the 82-buffer physical display (live + 408 + 8 + 82 + 2), and #2917's own exact dyadic moment auditor tools/audit_allocation_moment.run +(candidate = the directory, source = #2917's allocation/baseline = PR2908's pinned claim), plus root.py's bracket. +Usage: python controls.py OUT_DIR [--chronology pr2833-t37|pr2917-t74|pr2833-t74] (writes OUT_DIR/CONTROLS.json)""" +import os, sys +os.environ['PYTHONDONTWRITEBYTECODE'] = '1' +sys.dont_write_bytecode = True +import argparse, gzip, hashlib, json, pathlib, types, collections +from fractions import Fraction as Q +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import root as R +import relax as X +import fill17 as F + +def load(name, path): + m = types.ModuleType(name); m.__file__ = str(path); sys.modules[name] = m + exec(compile(path.read_bytes(), str(path), 'exec'), m.__dict__); return m + +ap = argparse.ArgumentParser(); ap.add_argument('out', type=pathlib.Path); ap.add_argument('--chronology', default=None); a = ap.parse_args() +out = a.out.resolve() +assert hashlib.sha256(F.ENGINE.read_bytes()).hexdigest() == F.ENGINE_SHA +owners = load('c1_owners', F.ENGINE) +moment = load('c1_moment', F.PKG17 / 'tools/audit_allocation_moment.py') +order, fill, raw_dispatch = F.read(out / 'ORDER.json'), F.read(out / 'FILL.json.gz'), F.read(out / 'DISPATCH.json') +profile = F.read(out / 'PROFILE.json'); providers_raw = F.read(out / 'PROVIDERS.json') +providers = {k: {'widths': v['widths'], 'actual_paid_profile': {int(r): n for r, n in v['actual_paid_profile'].items()}} for k, v in providers_raw.items()} +# the provider registry must be exactly #2917's (same widths per id, same local profile) +reg = F.read(F.PKG17 / 'allocation/PROVIDERS.json') +assert {k: (v['widths'], {int(r): n for r, n in v['actual_paid_profile'].items()}) for k, v in reg.items()} == {k: (v['widths'], v['actual_paid_profile']) for k, v in providers.items()}, 'PROVIDERS differ from #2917' +dispatch = {(s, r): p for s, r, p in raw_dispatch}; assert len(dispatch) == len(raw_dispatch) +chron = a.chronology or json.load(open(out / 'OWNER-CHECK.json'))['chronology'] +template, plan, c_order, c_dispatch, T = F.load_chronology(chron) +assert order == c_order and raw_dispatch == c_dispatch, 'ORDER/DISPATCH are not the %s chronology' % chron +assert len(order) // 9 == T +def check(candidate=fill, claimed=profile): + return owners.check(T, order, candidate, dispatch, claimed, plan, template, providers) +result, _, _ = check() +assert result['roles'] == 9 * T * 408 +physical = result['live'] + 408 + 8 + 82 + 2 +controls = {} +def reject(name, candidate=fill, claimed=profile): + try: + check(candidate, claimed) + except ValueError as e: + controls[name] = str(e) + else: + raise AssertionError('owner corruption accepted: ' + name) +reject('missing_role', {**fill, 'rows': fill['rows'][:-1]}) +first = fill['rows'][0] +j = next(i for i, r in enumerate(fill['rows'][1:], 1) if r[0] == first[0]) +def mutate(index, row): + rows = list(fill['rows']); rows[index] = row; return {**fill, 'rows': rows} +duplicate = list(fill['rows'][j]); duplicate[1] = first[1]; reject('duplicate_helper', mutate(j, duplicate)) +collision = list(fill['rows'][j]); collision[2:5] = first[2:5]; reject('same_call_family_collision', mutate(j, collision)) +overflow = list(first); overflow[5] = 49; reject('capacity_overflow', mutate(0, overflow)) +wrong = dict(profile); wrong['1'] = wrong.get('1', 0) + 1; reject('changed_paid_profile', claimed=wrong) +# #2917's own exact dyadic moment auditor (source = its allocation/baseline = PR2908's pinned claim/profile/order) +exact = moment.run(out, F.PKG17 / 'allocation/baseline') +prof = {int(k): v for k, v in profile.items()} +k_lo, k_hi = R.kappa_from_profile(prof, T) +inv = collections.Counter(providers['gauge44']['widths']) +rel = X.relax(providers['gauge44']['actual_paid_profile'], dict(inv)) +res = dict(status='PASS_C1_INDEPENDENT_RECHECK', chronology=chron, T=T, engine=result, physical=physical, controls=controls, moment=exact, + root_bracket=[str(k_lo), str(k_hi)], root_lower_decimal=R.mpmath_str(k_lo, 25), relaxation_cap=[rel['cap_lower'], rel['cap_upper']], + gain_vs_PR2917_claim=str(Q(exact['target']) - F.PR2917_KAPPA), gain_vs_PR2917_claim_float=float(Q(exact['target']) - F.PR2917_KAPPA), + target_vs_PR2917_claim_decimal=str(Q(exact['target']) - F.PR2917_KAPPA), headline_target=exact['target_decimal'], + fill_sha256=hashlib.sha256((out / 'FILL.json.gz').read_bytes()).hexdigest(), files_sha256={p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(out.iterdir()) if p.is_file()}) +(out / 'CONTROLS.json').write_text(json.dumps(res, sort_keys=True, indent=1, default=str) + '\n') +print(json.dumps({k: res[k] for k in ['status', 'chronology', 'T', 'physical', 'root_lower_decimal', 'gain_vs_PR2917_claim_float', 'headline_target']}, indent=1)) +print('engine', result['roles'], result['idle'], 'rank_mass', result['rank_mass']) +print('controls', {k: v for k, v in controls.items()}) +print('moment auditor', exact['status'], 'lower', exact['lower'], 'upper', exact['upper'], 'target', exact['target_decimal'][:40], 'gain vs PR2908', exact['gain_decimal'][:30]) diff --git a/research/paired-extension-cap-fill/construction/double.py b/research/paired-extension-cap-fill/construction/double.py new file mode 100644 index 0000000000..7bb063b346 --- /dev/null +++ b/research/paired-extension-cap-fill/construction/double.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +"""double.py -- if #2917's T74 chronology is the exact interleaving of two copies of PR2833's T37 chronology +(order74[2k] = order37[k], order74[2k+1] = (stage, replica+37), dispatch copied), a T37 fill doubles into a T74 fill +on #2917's OWN chronology: row (t,h,o,c,p,z) -> (2t,h,o,c,p,z) and (2t+1,h,o+37,c,p,z). Verified by the vendored engine. +Usage: python double.py T37_DIR OUT_DIR""" +import os, sys +os.environ['PYTHONDONTWRITEBYTECODE'] = '1' +sys.dont_write_bytecode = True +import collections, hashlib, json, pathlib, types, time +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import root as R, relax as X, fill17 as F +src, out = pathlib.Path(sys.argv[1]).resolve(), pathlib.Path(sys.argv[2]).resolve() +out.mkdir(parents=True, exist_ok=False) +owner = types.ModuleType('frozen_owner'); exec(compile(F.ENGINE.read_bytes(), 'frozen_owner', 'exec'), owner.__dict__) +t37 = F.load_chronology('pr2833-t37'); t74 = F.load_chronology('pr2917-t74') +order37, disp37 = t37[2], {(s, r): p for s, r, p in t37[3]} +template, plan, order74, dispatch74, T = t74 +disp74 = {(s, r): p for s, r, p in dispatch74} +ok_order = all(order74[2 * k] == order37[k] and order74[2 * k + 1] == [order37[k][0], order37[k][1] + 37] for k in range(333)) +ok_disp = all(disp74[(s, r)] == disp37[(s, r)] and disp74[(s, r + 37)] == disp37[(s, r)] for s, r in map(tuple, order37)) +print('order74 == interleave(order37, order37+37):', ok_order, '; dispatch copied:', ok_disp) +assert ok_order and ok_disp +fill37 = F.read(src / 'FILL.json.gz') +providers = F.load_providers(F.PKG17 / 'allocation/PROVIDERS.json') +assert F.read(src / 'PROVIDERS.json')['gauge44']['widths'] == providers['gauge44']['widths'] +rows = [] +for t, h, o, c, p, z in fill37['rows']: + rows.append([2 * t, h, o, c, p, z]); rows.append([2 * t + 1, h, o + 37, c, p, z]) +fill = {'columns': fill37['columns'], 'dispatch_overrides': [], 'method': fill37.get('method', '') + ' | doubled from the T37 fill onto #2917 T74 chronology (order74 = interleave of two T37 copies; double.py)', 'rows': sorted(rows)} +t0 = time.time() +result, _, _ = owner.check(T, order74, fill, disp74, None, plan, template, providers) +print('engine PASS in %.1f s' % (time.time() - t0), result['roles'], result['idle'], 'rank_mass', result['rank_mass'], 'live', result['live']) +profile = {int(k): v for k, v in result['profile'].items()} +prof37 = {int(k): v for k, v in F.read(src / 'PROFILE.json').items()} +assert profile == {r: 2 * n for r, n in prof37.items()}, 'profile is not 2x the T37 profile' +inv = collections.Counter(providers['gauge44']['widths']) +rel = X.relax(providers['gauge44']['actual_paid_profile'], dict(inv)) +k_lo, k_hi, pr = F.price(profile, T, rel) +prov_out = {pid: {'actual_paid_profile': {str(r): n for r, n in providers[pid]['actual_paid_profile'].items()}, 'widths': providers[pid]['widths']} for pid in providers} +payload_sha = {} +for n, obj in [('ORDER.json', order74), ('FILL.json.gz', fill), ('DISPATCH.json', dispatch74), ('PROFILE.json', {str(k): v for k, v in sorted(profile.items())}), ('PROVIDERS.json', prov_out)]: + F.save(out / n, obj); payload_sha[n] = hashlib.sha256(json.dumps(obj, sort_keys=True, separators=(',', ':')).encode()).hexdigest() +check = dict(result, status='PASS_VENDORED_PR2839_OWNER_ENGINE_CHECK', solver='DOUBLED_FROM_T37_FILL ' + str(src), chronology='pr2917-t74', T=T, calls=len(order74), + physical=result['live'] + 408 + 8 + 82 + 2, physical_formula='live + 408 helpers + 8 centres + 82 private buffers + 2 guards', + inventory={pid: dict(sorted(inv.items())) for pid in providers}, local=providers['gauge44']['actual_paid_profile'], engine_sha256=F.ENGINE_SHA, payload_sha256=payload_sha, **pr) +F.save(out / 'OWNER-CHECK.json', check) +print('physical', check['physical'], 'KAPPA', pr['kappa_lower_decimal'], '..', pr['kappa_upper_decimal'], 'cap', rel['cap_upper_decimal'], 'gap %.3e' % pr['gap_to_relaxation_cap'], 'gain vs PR2917 claim %.6e' % pr['gain_vs_PR2917_claim_float']) +print('payload sha', payload_sha) diff --git a/research/paired-extension-cap-fill/construction/fill17.py b/research/paired-extension-cap-fill/construction/fill17.py new file mode 100644 index 0000000000..01775cdaff --- /dev/null +++ b/research/paired-extension-cap-fill/construction/fill17.py @@ -0,0 +1,552 @@ +#!/usr/bin/env python3 +"""fill17.py -- lane C's fill.py (r12) adapted to PR #2917's words: literal owner allocation for #2917's exact +per-provider widths (allocation/PROVIDERS.json) under a chosen chronology, with the integer pattern mix of relax.py, +CP-SAT (single thread), edge-colouring realization, the vendored PR2839 owner engine (sha 77a84872..., the same file +#2917 ships in allocation/vendor/) and root.py's exact bracket. Also replays/prices any literal fill (--check-fill). + +Chronologies: + pr2833-t37 : PR2833 T37 owners chronology (333 calls) as used by PR2857/lane C (template/plan from PR2857 sources) + pr2833-t74 : PR2833 borrow-fill chronology (666 calls) + pr2917-t74 : #2917's own allocation/ORDER.json + DISPATCH.json (666 calls; = PR2908's, 'inherited chronology') +Template and plan payloads are byte-identical across the packages (decompressed sha 514e5931..., 163431bf...). + +Usage (AGI venv = OR-Tools 9.15; num_search_workers MUST be 1 on this machine): + $AGI -B fill17.py --work OUT/x --chronology pr2833-t37 --catalogue tight --hint-flow PR2857/FLOW.json.gz --hint-zeros --seed 7 --seconds 900 + $AGI -B fill17.py --work OUT/x --chronology pr2917-t74 --catalogue tight --hint-fill PR2917/allocation/FILL.json.gz --hint-zeros + $AGI -B fill17.py --work OUT/x --chronology pr2917-t74 --check-fill PR2917/allocation/FILL.json.gz (replay + price) + --mix-only : stop after the pattern mix and its exact kappa (fill-independent) + --mix-file PATTERNS.json : use a given target mix (list of [cap, counts, n]) instead of the milp +Outputs: PATTERNS.json, MODEL.json, SOLVER.json, FLOW.json.gz, ORDER.json, FILL.json.gz, DISPATCH.json, PROFILE.json, + PROVIDERS.json (= #2917's allocation format), OWNER-CHECK.json (engine result, physical stock, exact bracket, cap, gains). +""" +import os, sys +os.environ['PYTHONDONTWRITEBYTECODE'] = '1' +sys.dont_write_bytecode = True +import argparse, collections, gzip, hashlib, json, pathlib, time, types +from fractions import Fraction as Q +import numpy as np +from scipy.sparse import coo_matrix, csr_matrix +from scipy.sparse.csgraph import maximum_bipartite_matching +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import root as R +import relax as X + +SCR = pathlib.Path('S') +PKG17 = SCR / 'r13/vendor/pr2917/research/paired-helper-extension' +PKG57 = SCR / 'r12/vendor/pr2857/research/shared-kernel-repacking' +P33 = SCR / 'r12/vendor/pr2833/research/gmx-t74-borrow43-handoff' +ENGINE = PKG17 / 'allocation/vendor/independent_owners.py' +ENGINE_SHA = '77a848729159e271ba64f403dfd59dddb13044b17b2950fa56700f442e2fe461' +PR2917_KAPPA = Q('17215886471978018806049999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000') +PR2917_ROOT_LOWER = Q('1721588647197801880605/1000000000000000000000000') # floor of its root at 24 digits (CLAIM complex_lower = 344317729439560376121/2e23) +PRIVATE_BUFFERS = 82 +HELPERS = 408 +CENTRES = 8 +GUARDS = 2 + + +def read(p): + b = pathlib.Path(p).read_bytes() + return json.loads(gzip.decompress(b) if b[:2] == b'\x1f\x8b' else b) + + +def save(p, x): + b = json.dumps(x, sort_keys=True, separators=(',', ':')).encode() + if str(p).endswith('.gz'): + b = bytearray(gzip.compress(b, mtime=0)) + b[9] = 255 + b = bytes(b) + pathlib.Path(p).write_bytes(b) + + +def log(*a): + print(*a, flush=True) + + +def load_chronology(name): + if name == 'pr2833-t37': + template = read(PKG57 / 'sources/PR2833-T37-TEMPLATE.json.gz') + plan = read(PKG57 / 'sources/PR2833-PLAN.json.gz') + owners = read(PKG57 / 'sources/PR2833-T37-OWNERS.json.gz') + T = 37 + timecalls = {} + for r in owners: + key, call = r['time'], (r['stage'], r['replica']) + assert key not in timecalls or timecalls[key] == call + timecalls[key] = call + assert set(timecalls) == set(range(9 * T)) + order = [list(timecalls[t]) for t in range(9 * T)] + dispatch = read(PKG57 / 'sources/PR2833-T37-DISPATCH.json') + elif name == 'pr2833-t74': + template = read(PKG57 / 'sources/PR2833-T37-TEMPLATE.json.gz') + plan = read(PKG57 / 'sources/PR2833-PLAN.json.gz') + order = read(P33 / 'new/borrow-fill/ORDER.json') + dispatch = read(P33 / 'new/borrow-fill/DISPATCH.json') + T = 74 + elif name == 'pr2917-t74': + template = read(PKG17 / 'allocation/vendor/TEMPLATE.json.gz') + plan = read(PKG17 / 'allocation/vendor/PLAN.json.gz') + order = read(PKG17 / 'allocation/ORDER.json') + dispatch = read(PKG17 / 'allocation/DISPATCH.json') + T = 74 + else: + raise SystemExit('unknown chronology ' + name) + assert {(s, r) for s, r, p in dispatch} == set(map(tuple, order)) and len(order) == 9 * T and len(dispatch) == 9 * T + return template, plan, order, dispatch, T + + +def load_providers(path, local_override=None): + providers = read(path) + out = {} + for pid, v in providers.items(): + widths = [int(w) for w in v['widths']] + assert len(widths) == HELPERS + local = {int(k): int(n) for k, n in v['actual_paid_profile'].items()} + if local_override is not None: + local = dict(local_override) + local = {k: n for k, n in sorted(local.items()) if n} + assert sum(r * n for r, n in local.items()) - sum(widths) == 1856, 'local mass - width mass != 1856 for ' + pid + out[pid] = {'widths': widths, 'actual_paid_profile': local} + return out + + +def integer_pattern_mix(inv_by_call, T, bins_per_replica, cap_root, catalogue, tight): + widths = sorted({w for inv in inv_by_call for w in inv}) + bins = {c: n * T for c, n in bins_per_replica.items()} + demand = collections.Counter() + for inv in inv_by_call: + for w, n in inv.items(): + demand[w] += n + from scipy.optimize import milp, Bounds, LinearConstraint + pats = X.patterns(bins_per_replica, widths) + if catalogue == 'tight': + keep = {(t['capacity'], tuple(t['widths'].count(w) for w in widths)) for t in tight} + for cap in bins: + for i, w in enumerate(widths): + if w <= cap: + keep.add((cap, tuple(int(j == i) for j in range(len(widths))))) + keep.add((cap, tuple(0 for _ in widths))) + pats = [p for p in pats if (p[0], p[1]) in keep] + elif catalogue == 'tightonly': + keep = {(t['capacity'], tuple(t['widths'].count(w) for w in widths)) for t in tight} + pats = [p for p in pats if (p[0], p[1]) in keep] + caps = sorted(bins) + b = float(cap_root) + c = np.array([X.Hfloat(r, b) for cap, counts, r in pats]) + A = np.zeros((len(caps) + len(widths), len(pats))) + for j, (cap, counts, r) in enumerate(pats): + A[caps.index(cap), j] = 1.0 + for i, n in enumerate(counts): + A[len(caps) + i, j] = n + rhs = np.array([float(bins[cap]) for cap in caps] + [float(demand[w]) for w in widths]) + res = milp(c, integrality=np.ones(len(pats)), bounds=Bounds(0, np.inf), constraints=LinearConstraint(A, rhs, rhs), options={'time_limit': 120, 'mip_rel_gap': 0}) + assert res.x is not None, 'integer pattern mix infeasible: ' + str(res.message) + xi = np.rint(res.x).astype(np.int64) + assert np.max(np.abs(xi - res.x)) < 1e-6 and np.all(A @ xi == rhs) + target = {(pats[j][0], pats[j][1]): int(xi[j]) for j in range(len(pats)) if xi[j]} + return target, widths + + +def color_pattern(n, q, counts, WID): + slots = [w for j, w in enumerate(WID) for _ in range(q[j])] + if not slots: + assert not counts + return [[] for _ in range(n)] + times = sorted({t for t, w in counts}) + K = len(times) + assert K >= len(slots) + ti = {t: j for j, t in enumerate(times)} + A = np.zeros((K, K), dtype=np.int64) + slot_by_w = collections.defaultdict(list) + for j, w in enumerate(slots): + slot_by_w[w].append(j) + for w, js in slot_by_w.items(): + atslot = 0 + remaining = n + for t in times: + needed = counts.get((t, w), 0) + while needed: + take = min(needed, remaining) + A[ti[t], js[atslot]] += take + needed -= take + remaining -= take + if remaining == 0: + atslot += 1 + remaining = n + assert atslot == len(js) + assert all(v <= n for v in A.sum(axis=1)) + j = len(slots) + remaining = n + for r in range(K): + needed = n - int(A[r].sum()) + while needed: + assert j < K + take = min(needed, remaining) + A[r, j] += take + needed -= take + remaining -= take + if remaining == 0: + j += 1 + remaining = n + assert np.all(A.sum(axis=0) == n) and np.all(A.sum(axis=1) == n) + output = [] + for color in range(n): + matching = maximum_bipartite_matching(csr_matrix(A > 0), perm_type='column') + assert len(matching) == K and min(matching) >= 0 and len(set(map(int, matching))) == K + output.append([(times[r], slots[int(c)]) for r, c in enumerate(matching) if c < len(slots)]) + A[np.arange(K), matching] -= 1 + assert not A.any() + return output + + +def pattern_name(WID, counts): + return '+'.join(str(w) for w, k in zip(WID, counts) for _ in range(k)) or 'empty' + + +def fill_to_bins(fill, order, disp, providers): + """literal fill rows -> {bin: [(t, w)]} using the provider widths (helper column = 0-based index, as the engine reads it).""" + bybin = collections.defaultdict(list) + for t, h, o, c, p, z in fill['rows']: + w = providers[disp[tuple(order[t])]]['widths'][h] + bybin[o, c, p].append((t, w)) + return bybin + + +def price(profile, T, rel): + k_lo, k_hi = R.kappa_from_profile(profile, T) + cap_hi = Q(rel['cap_upper']) + return k_lo, k_hi, dict(kappa_lower=str(k_lo), kappa_upper=str(k_hi), kappa_lower_decimal=R.mpmath_str(k_lo, 25), kappa_upper_decimal=R.mpmath_str(k_hi, 25), + headline_floor24_minus=str(Q(int(k_lo * 10 ** 24), 10 ** 24) - Q(1, 10 ** 46) - Q(1, 10 ** 70)), + relaxation_cap_lower=rel['cap_lower'], relaxation_cap_upper=rel['cap_upper'], relaxation_cap_upper_decimal=rel['cap_upper_decimal'], + gap_to_relaxation_cap=float(cap_hi - k_lo), gain_vs_PR2917_claim_float=float(k_lo - PR2917_KAPPA), gain_vs_PR2917_root_lower_float=float(k_lo - PR2917_ROOT_LOWER), + gain_vs_PR2917_claim_exact_lower=str(k_lo - PR2917_KAPPA)) + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument('--work', type=pathlib.Path, required=True) + ap.add_argument('--chronology', choices=['pr2833-t37', 'pr2833-t74', 'pr2917-t74'], default='pr2833-t37') + ap.add_argument('--providers', type=pathlib.Path, default=PKG17 / 'allocation/PROVIDERS.json') + ap.add_argument('--local', help='JSON per-call local profile overriding PROVIDERS (both providers)') + ap.add_argument('--catalogue', choices=['all', 'tight', 'tightonly'], default='tight') + ap.add_argument('--mix-file', type=pathlib.Path, help='PATTERNS.json-style target list [[cap, counts, n], ...] to use instead of the milp') + ap.add_argument('--mix-only', action='store_true') + ap.add_argument('--seconds', type=int, default=600) + ap.add_argument('--workers', type=int, default=1) + ap.add_argument('--seed', type=int, default=124) + ap.add_argument('--hint-flow', type=pathlib.Path, help='FLOW.json.gz of the same chronology/T (e.g. PR2857 allocation/construction/FLOW.json.gz for pr2833-t37)') + ap.add_argument('--hint-fill', type=pathlib.Path, help='literal FILL.json.gz of the same chronology (e.g. #2917 allocation/FILL.json.gz for pr2917-t74); converted to X/Z hints') + ap.add_argument('--hint-zeros', action='store_true') + ap.add_argument('--reuse-flow', type=pathlib.Path) + ap.add_argument('--solver', choices=['cp', 'highs-lp', 'highs-mip'], default='cp', help='cp = CP-SAT; highs-lp = LP relaxation feasibility only (fractional flow); highs-mip = scipy milp') + ap.add_argument('--check-fill', type=pathlib.Path, help='replay: owner-check and price this literal fill under the chronology (no solve)') + ap.add_argument('--method', default='r13 lane C1: relax.py integer pattern mix + CP-SAT chronological flow + edge-colouring realization (fill17.py)') + a = ap.parse_args() + assert a.workers == 1, 'num_search_workers must be 1 on this machine (3 deadlocks)' + out = a.work.resolve() + out.mkdir(parents=True, exist_ok=False) + t0 = time.time() + assert hashlib.sha256(ENGINE.read_bytes()).hexdigest() == ENGINE_SHA, 'owner engine pin' + owner = types.ModuleType('frozen_owner') + exec(compile(ENGINE.read_bytes(), 'frozen_owner', 'exec'), owner.__dict__) + template, plan, order, dispatch, T = load_chronology(a.chronology) + local_override = {int(k): int(v) for k, v in json.loads(a.local).items()} if a.local else None + providers = load_providers(a.providers, local_override) + disp = {(s, r): p for s, r, p in dispatch} + inv_by_call = [collections.Counter(providers[disp[tuple(sr)]]['widths']) for sr in order] + calls_by_pid = collections.Counter(disp[tuple(sr)] for sr in order) + locals_ = {pid: providers[pid]['actual_paid_profile'] for pid in providers} + # relaxation cap (call-weighted average inventory; the local profile is the same for both providers here) + avg_inv = collections.Counter() + for inv in inv_by_call: + for w, n in inv.items(): + avg_inv[w] += Q(n, len(order)) + loc0 = next(iter(locals_.values())) + assert all(l == loc0 for l in locals_.values()), 'providers differ in local profile; relax.py needs one profile' + rel = X.relax(loc0, avg_inv) + cap_lo, cap_hi = Q(rel['cap_lower']), Q(rel['cap_upper']) + log('CHRONOLOGY', a.chronology, 'T', T, 'calls', len(order), 'calls per provider', dict(calls_by_pid)) + log('INVENTORY', {pid: dict(sorted(collections.Counter(providers[pid]['widths']).items())) for pid in providers}, 'LOCAL', loc0) + log('RELAX cap', rel['cap_lower_decimal'], rel['cap_upper_decimal'], 'tight', rel['tight_patterns'], 'idle/replica', rel['idle_per_replica']) + live = 896 * T + physical = live + HELPERS + CENTRES + PRIVATE_BUFFERS + GUARDS + + if a.check_fill: + fill = read(a.check_fill) + result, _, _ = owner.check(T, order, fill, disp, None, plan, template, providers) + profile = {int(k): v for k, v in result['profile'].items()} + k_lo, k_hi, pr = price(profile, T, rel) + bybin = fill_to_bins(fill, order, disp, providers) + pat_hist = collections.Counter() + win = owner.windows(template, order, T) + for (o, c), (cap, lo, hi) in win.items(): + for port in range(112): + rs = bybin.get((o, c, port), []) + pat_hist['%d:%s' % (cap, '+'.join(str(w) for w in sorted(w for t, w in rs)) or 'empty')] += 1 + assert result['live'] == live + check = dict(result, status='PASS_VENDORED_PR2839_OWNER_ENGINE_CHECK', mode='check-fill', fill=str(a.check_fill), chronology=a.chronology, T=T, + physical=result['live'] + HELPERS + CENTRES + PRIVATE_BUFFERS + GUARDS, physical_expected=physical, pattern_histogram=dict(sorted(pat_hist.items())), **pr) + save(out / 'OWNER-CHECK.json', check) + save(out / 'PROFILE.json', dict(sorted(profile.items()))) + log('CHECK-FILL PASS roles', result['roles'], 'idle', result['idle'], 'physical', check['physical']) + log('PATTERNS', dict(sorted(pat_hist.items()))) + log('KAPPA', pr['kappa_lower_decimal'], '..', pr['kappa_upper_decimal'], 'cap', rel['cap_upper_decimal'], 'gap %.3e' % pr['gap_to_relaxation_cap'], 'gain vs PR2917 claim %.4e' % pr['gain_vs_PR2917_claim_float']) + return + + bins_per_replica = X.BINS + if a.mix_file: + mf = read(a.mix_file) + WID = [int(w) for w in mf['widths']] + target = {(int(cap), tuple(int(k) for k in counts)): int(n) for cap, counts, n in mf['target']} + else: + target, WID = integer_pattern_mix(inv_by_call, T, bins_per_replica, (cap_lo + cap_hi) / 2, a.catalogue, rel['tight_pattern_list']) + idle_mix = collections.Counter() + for (cap, counts), n in target.items(): + r = cap - sum(w * k for w, k in zip(WID, counts)) + assert r >= 0 + if r: + idle_mix[r] += n + profile_mix = collections.Counter(idle_mix) + for pid, ncalls in calls_by_pid.items(): + for r, n in locals_[pid].items(): + profile_mix[r] += n * ncalls + mix_lo, mix_hi, mix_pr = price(dict(profile_mix), T, rel) + log('PATTERN MIX', {('%d:%s' % (cap, pattern_name(WID, counts))): n for (cap, counts), n in sorted(target.items())}) + log('MIX kappa bracket', mix_pr['kappa_lower_decimal'], mix_pr['kappa_upper_decimal'], 'idle', dict(sorted(idle_mix.items())), 'gap to cap %.3e' % mix_pr['gap_to_relaxation_cap'], 'gain vs PR2917 %.4e' % mix_pr['gain_vs_PR2917_claim_float']) + save(out / 'PATTERNS.json', dict(mode='milp' if not a.mix_file else 'file', catalogue=a.catalogue, T=T, chronology=a.chronology, widths=WID, + target=[[cap, list(counts), n] for (cap, counts), n in sorted(target.items())], idle=dict(sorted(idle_mix.items())), + profile=dict(sorted(profile_mix.items())), **mix_pr)) + if a.mix_only: + return + + # ---- chronology windows and the flow model (PR2857 discover_original.py, all bins active) + win = owner.windows(template, order, T) + family = lambda b: b[0] * 896 + (2 * plan['pairs'][str(b[1])] + plan['sides'][str(b[1])]) * 112 + b[2] + fw = collections.defaultdict(list) + for (o, c), (cap, lo, hi) in win.items(): + fw[family((o, c, 0))].append((lo, hi, c)) + for ww in fw.values(): + for i, (lo, hi, c) in enumerate(ww): + assert all(max(lo, l) >= min(hi, h) for l, h, d in ww[i + 1:]), 'overlapping same-family windows' + need = {t: collections.Counter(inv_by_call[t]) for t in range(len(order))} + pats = collections.defaultdict(list) + for (cap, counts) in target: + pats[cap].append(counts) + groups = collections.defaultdict(list) + for (o, c), (cap, lo, hi) in win.items(): + for port in range(112): + groups[cap, tuple(range(max(0, lo + 1), min(len(order), hi + 1)))].append((o, c, port)) + G = sorted(groups) + groupof = {b: gi for gi, g in enumerate(G) for b in groups[g]} + edge, lb, ub, rl, ru = [], [], [], [], [] + Xv, Zv = {}, {} + + def cr(l, u=None): + j = len(rl) + rl.append(l) + ru.append(l if u is None else u) + return j + + def cv(u): + j = len(lb) + lb.append(0) + ub.append(u) + return j + + def put(r, v, n): + if n: + edge.append((r, v, n)) + callrow = {(t, w): cr(n) for t, cnt in need.items() for w, n in cnt.items() if n} + globalrow = {key: cr(n) for key, n in target.items()} + for gi, (cap, ts) in enumerate(G): + nb = len(groups[G[gi]]) + br = cr(nb) + for q in pats[cap]: + xv = cv(nb) + Xv[gi, q] = xv + put(br, xv, 1) + put(globalrow[cap, q], xv, 1) + residual = {w: q[j] for j, w in enumerate(WID) if q[j]} + wr = {w: cr(0) for w in residual} + for w, n in residual.items(): + put(wr[w], xv, -n) + for t in ts: + tr = cr(-nb, 0) + put(tr, xv, -1) + for w in residual: + if (t, w) not in callrow: + continue + zv = cv(min(nb, need[t][w])) + Zv[gi, q, t, w] = zv + put(tr, zv, 1) + put(wr[w], zv, 1) + put(callrow[t, w], zv, 1) + modelinfo = dict(T=T, chronology=a.chronology, groups=len(G), variables=len(lb), pattern_variables=len(Xv), flow_variables=len(Zv), constraints=len(rl), nonzeros=len(edge), workers=a.workers, + catalogue=a.catalogue, patterns_per_cap={str(cap): len(ps) for cap, ps in pats.items()}) + save(out / 'MODEL.json', modelinfo) + log('MODEL', modelinfo) + rr = np.fromiter((e[0] for e in edge), np.int32) + cc = np.fromiter((e[1] for e in edge), np.int32) + vv = np.fromiter((e[2] for e in edge), np.float64) + mat = coo_matrix((vv, (rr, cc)), shape=(len(rl), len(lb))).tocsr() + del edge + t1 = time.time() + if a.reuse_flow: + saved = read(a.reuse_flow) + value = np.zeros(len(lb), dtype=np.int64) + for gi, q, n in saved['x']: + value[Xv[gi, tuple(q)]] = n + for gi, q, t, w, n in saved['z']: + value[Zv[gi, tuple(q), t, w]] = n + status = 'EXACT_FLOW_REPLAY' + elif a.solver == 'highs-lp': + from scipy.optimize import milp, Bounds, LinearConstraint + r = milp(np.zeros(len(lb)), integrality=np.zeros(len(lb)), bounds=Bounds(np.array(lb, dtype=float), np.array(ub, dtype=float)), constraints=LinearConstraint(mat, np.array(rl, dtype=float), np.array(ru, dtype=float)), options={'time_limit': a.seconds, 'disp': True}) + status = 'LP_RELAXATION_' + ('FEASIBLE' if r.x is not None else 'INFEASIBLE_OR_FAILED') + ': ' + str(r.message) + log('LP RELAXATION', status, '%.1f s' % (time.time() - t1)) + save(out / 'SOLVER.json', dict(status=status, solver='highs-lp', seconds=time.time() - t1, chronology=a.chronology, T=T, catalogue=a.catalogue, mix_file=str(a.mix_file) if a.mix_file else None)) + return + elif a.solver == 'highs-mip': + from scipy.optimize import milp, Bounds, LinearConstraint + r = milp(np.zeros(len(lb)), integrality=np.ones(len(lb)), bounds=Bounds(np.array(lb, dtype=float), np.array(ub, dtype=float)), constraints=LinearConstraint(mat, np.array(rl, dtype=float), np.array(ru, dtype=float)), options={'time_limit': a.seconds, 'mip_rel_gap': 0, 'disp': True}) + status = str(r.message) + value = None if r.x is None else np.rint(r.x).astype(np.int64) + else: + from ortools.sat.python import cp_model + model = cp_model.CpModel() + vs = [model.NewIntVar(int(l), int(u), '') for l, u in zip(lb, ub)] + for j, (l, u) in enumerate(zip(rl, ru)): + b, e = mat.indptr[j:j + 2] + ind = mat.indices[b:e] + co = mat.data[b:e] + model.AddLinearConstraint(cp_model.LinearExpr.WeightedSum([vs[int(k)] for k in ind], [int(k) for k in co]), int(l), int(u)) + hinted = {} + if a.hint_flow: + saved = read(a.hint_flow) + for gi, q, n in saved['x']: + if (gi, tuple(q)) in Xv: + hinted[Xv[gi, tuple(q)]] = min(int(n), int(ub[Xv[gi, tuple(q)]])) + for gi, q, t, w, n in saved['z']: + if (gi, tuple(q), t, w) in Zv: + hinted[Zv[gi, tuple(q), t, w]] = min(int(n), int(ub[Zv[gi, tuple(q), t, w]])) + log('HINT from flow', a.hint_flow, 'variables', len(hinted), 'of', len(vs)) + if a.hint_fill: + hf = read(a.hint_fill) + bybin = fill_to_bins(hf, order, disp, providers) + hx = collections.Counter() + hz = collections.Counter() + missing = collections.Counter() + for gi_, g_ in enumerate(G): + for b in groups[g_]: + rs = bybin.get(b, []) + q = tuple(sum(1 for t, w in rs if w == ww) for ww in WID) + if (gi_, q) not in Xv: + missing['%d:%s' % (G[gi_][0], pattern_name(WID, q))] += 1 + continue + hx[gi_, q] += 1 + for t, w in rs: + hz[gi_, q, t, w] += 1 + for k, n in hx.items(): + hinted[Xv[k]] = min(n, int(ub[Xv[k]])) + for k, n in hz.items(): + if k in Zv: + hinted[Zv[k]] = min(n, int(ub[Zv[k]])) + log('HINT from fill', a.hint_fill, 'bins hinted', sum(hx.values()), 'bins with non-catalogue patterns (unhinted)', sum(missing.values()), dict(missing.most_common(12)), 'variables', len(hinted)) + if hinted: + for j, v in hinted.items(): + model.AddHint(vs[j], v) + if a.hint_zeros: + for j in range(len(vs)): + if j not in hinted: + model.AddHint(vs[j], 0) + log('HINT total', len(hinted), '(+ zeros for the rest)' if a.hint_zeros else '') + solver = cp_model.CpSolver() + solver.parameters.num_search_workers = a.workers + solver.parameters.max_time_in_seconds = a.seconds + solver.parameters.random_seed = a.seed + solver.parameters.log_search_progress = True + result = solver.Solve(model) + status = solver.StatusName(result) + value = np.array([solver.Value(v) for v in vs], dtype=np.int64) if result in (cp_model.OPTIMAL, cp_model.FEASIBLE) else None + log(solver.ResponseStats()) + solve_seconds = time.time() - t1 + log('SOLVER', status, '%.1f s' % solve_seconds) + save(out / 'SOLVER.json', dict(status=status, seconds=solve_seconds, workers=a.workers, seed=a.seed, max_time_seconds=a.seconds, candidate=value is not None, chronology=a.chronology, T=T, catalogue=a.catalogue, + hint_flow=str(a.hint_flow) if a.hint_flow else None, hint_fill=str(a.hint_fill) if a.hint_fill else None, hint_zeros=a.hint_zeros)) + if value is None: + log('NO FEASIBLE FLOW (status %s)' % status) + raise SystemExit(2) + assert not (np.any(value < lb) or np.any(value > ub) or np.any(mat @ value < rl) or np.any(mat @ value > ru)) + xc = collections.defaultdict(collections.Counter) + zc = collections.defaultdict(collections.Counter) + for (gi, q), v in Xv.items(): + if value[v]: + xc[gi][q] = int(value[v]) + for (gi, q, t, w), v in Zv.items(): + if value[v]: + zc[gi, q][t, w] = int(value[v]) + save(out / 'FLOW.json.gz', {'x': [[gi, list(q), n] for gi, c in xc.items() for q, n in c.items()], 'z': [[gi, list(q), t, w, n] for (gi, q), c in zc.items() for (t, w), n in c.items()]}) + gc = collections.Counter() + for gi, c in xc.items(): + for q, n in c.items(): + gc[G[gi][0], q] += n + assert dict(gc) == target, 'global integer pattern counts differ' + for gi in range(len(G)): + assert sum(xc[gi].values()) == len(groups[G[gi]]), 'window class bin count' + call_count = collections.defaultdict(collections.Counter) + for (gi, q), c in zc.items(): + by_w = collections.Counter() + by_t = collections.Counter() + for (t, w), n in c.items(): + assert t in G[gi][1] and q[WID.index(w)] > 0, 'ineligible time/width flow' + by_w[w] += n + by_t[t] += n + call_count[t][w] += n + assert all(by_w[w] == q[j] * xc[gi][q] for j, w in enumerate(WID)), 'pattern-width supply' + assert all(n <= xc[gi][q] for n in by_t.values()), 'more than one role per bin/time' + assert all(call_count[t] == need[t] for t in range(len(order))), 'flow call width demand' + slots = [] + for gi, (cap, ts) in enumerate(G): + bins = groups[G[gi]] + offset = 0 + for q, n in sorted(xc[gi].items()): + res = color_pattern(n, q, zc[gi, q], WID) + assert len(res) == n + for b, it in zip(bins[offset:offset + n], res): + z = 0 + for t, w in sorted(it): + slots.append((t, w, *b, z)) + z += w + assert z <= cap + offset += n + assert offset == len(bins) + available = {t: collections.defaultdict(list) for t in range(len(order))} + for t in available: + for h, w in enumerate(providers[disp[tuple(order[t])]]['widths']): + available[t][w].append(h) + final = [] + for t, w, o, c, p, z in sorted(slots): + final.append([t, available[t][w].pop(), o, c, p, z]) + assert not any(v for d in available.values() for v in d.values()) + fill = {'columns': ['time', 'helper', 'owner_replica', 'child', 'port', 'offset'], 'dispatch_overrides': [], 'method': a.method, 'rows': sorted(final)} + result, _, _ = owner.check(T, order, fill, disp, None, plan, template, providers) + profile = {int(k): v for k, v in result['profile'].items()} + assert collections.Counter(profile) == profile_mix, 'realized profile differs from the pattern-mix profile' + assert result['live'] == live + k_lo, k_hi, pr = price(profile, T, rel) + payload_sha = {} + prov_out = {pid: {'actual_paid_profile': {str(r): n for r, n in providers[pid]['actual_paid_profile'].items()}, 'widths': providers[pid]['widths']} for pid in providers} + for n, obj in [('ORDER.json', order), ('FILL.json.gz', fill), ('DISPATCH.json', dispatch), ('PROFILE.json', {str(k): v for k, v in sorted(profile.items())}), ('PROVIDERS.json', prov_out)]: + save(out / n, obj) + payload_sha[n] = hashlib.sha256(json.dumps(obj, sort_keys=True, separators=(',', ':')).encode()).hexdigest() + check = dict(result, status='PASS_VENDORED_PR2839_OWNER_ENGINE_CHECK', solver=status, solve_seconds=solve_seconds, total_seconds=time.time() - t0, chronology=a.chronology, T=T, calls=len(order), + physical=result['live'] + HELPERS + CENTRES + PRIVATE_BUFFERS + GUARDS, physical_formula='live + 408 helpers + 8 centres + 82 private buffers + 2 guards', + inventory={pid: dict(sorted(collections.Counter(providers[pid]['widths']).items())) for pid in providers}, local=loc0, engine_sha256=ENGINE_SHA, catalogue=a.catalogue, + pattern_mix={('%d:%s' % (cap, pattern_name(WID, counts))): n for (cap, counts), n in sorted(target.items())}, payload_sha256=payload_sha, seed=a.seed, **pr) + save(out / 'OWNER-CHECK.json', check) + log('OWNER_CHECK_PASS', out, 'roles', result['roles'], 'idle', result['idle'], 'physical', check['physical']) + log('KAPPA', pr['kappa_lower_decimal'], '..', pr['kappa_upper_decimal'], 'cap', rel['cap_upper_decimal'], 'gap %.3e' % pr['gap_to_relaxation_cap'], 'gain vs PR2917 claim %.4e' % pr['gain_vs_PR2917_claim_float']) + + +if __name__ == '__main__': + main() diff --git a/research/paired-extension-cap-fill/data/WORD-base.json.gz b/research/paired-extension-cap-fill/data/WORD-base.json.gz new file mode 100644 index 0000000000..9be0aa5349 Binary files /dev/null and b/research/paired-extension-cap-fill/data/WORD-base.json.gz differ diff --git a/research/paired-extension-cap-fill/data/WORD-extra.json.gz b/research/paired-extension-cap-fill/data/WORD-extra.json.gz new file mode 100644 index 0000000000..40b38365ea Binary files /dev/null and b/research/paired-extension-cap-fill/data/WORD-extra.json.gz differ diff --git a/research/paired-extension-cap-fill/evidence/ADAPTER-DERIVATION.json b/research/paired-extension-cap-fill/evidence/ADAPTER-DERIVATION.json new file mode 100644 index 0000000000..4bcbc9f4f8 --- /dev/null +++ b/research/paired-extension-cap-fill/evidence/ADAPTER-DERIVATION.json @@ -0,0 +1,124 @@ +{ + "status": "PASS_CHECKED_82_BUFFER_ADAPTER_DERIVATION_R13", + "parent_head": "51309592971e3b5be935599eed2a95404dc7781e", + "parent_manifest_sha256": "9dba3fe371602ec023a54e26c0fd66f69eb7a74be86aab89923529083c14b36f", + "source_commit": "paired-helper-extension-pr2908", + "source_profile": "paired-extension", + "upstream_head": "51309592971e3b5be935599eed2a95404dc7781e", + "source_manifest_sha256": "98d57c82a1c7318be3c330c3b66897844d57232f0aaeaea88fb4bebd0a1bedf1", + "source_files": 632, + "comparisons": { + "pr2908": { + "pr": 2908, + "head": "51309592971e3b5be935599eed2a95404dc7781e", + "sha256": "2406680a07b43a69b0f12f8462cc43f3616f3c8cb0a46bc767541b45945cd2bf" + }, + "pr2917": { + "pr": 2917, + "head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "sha256": "e6c836c0178661a53a69cd91f29d83585e876f2511ff40c6b6204cd270fbdeac" + } + }, + "retained_receipt_sha256": "eec93526dafc5d6fb8f6b4318efb57b15209b7a31bbd670d470b1a65de244720", + "buffer_count": 82, + "physical_overhead": 500, + "changes": { + "prepare_extension_native.py": { + "source": "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/r13pub-build/runs/fresh1/pr2908/tools/prepare_channel_native.py", + "before_sha256": "4d207b9bbe3e0b8a86d10ad5d5f329a81da0cf56dce6c03e6fdd5b78e581ce91", + "after_sha256": "a64ff448b62a93108ed6db64dfbed71d86bbbe4dec36f78731d6e995e39772cf", + "replacements": [ + { + "old": "SOURCE_SHA='56cf455752722051d598a7da1e5ee700637fbaef09189f534413dbe6e0525a83'", + "new": "SOURCE_SHA='98d57c82a1c7318be3c330c3b66897844d57232f0aaeaea88fb4bebd0a1bedf1'" + }, + { + "old": "SOURCE_FILES=610", + "new": "SOURCE_FILES=632" + }, + { + "old": "SOURCE_COMMIT='two-sided-helper408-pr2894'", + "new": "SOURCE_COMMIT='paired-helper-extension-pr2908'" + }, + { + "old": "OLD_RECEIPT_SHA='dd36443f2789ffa6deca7210c76ada781e2b9b7e622a546b366f51a475faff3e'", + "new": "OLD_RECEIPT_SHA='eec93526dafc5d6fb8f6b4318efb57b15209b7a31bbd670d470b1a65de244720'" + }, + { + "old": "len(can['zero_buffers'])==73", + "new": "len(can['zero_buffers'])==82" + } + ] + }, + "admit_extension.py": { + "source": "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/r13pub-build/runs/fresh1/pr2908/tools/admit_channel408.py", + "before_sha256": "a62c21eac4e0df502cbfb78c88b19a763fd351cde3c11c0588874f84db6992bf", + "after_sha256": "682a9e90994d86a248f48c76bc05bdef71751414ab6d6c78fc6e1ac64e835308", + "replacements": [ + { + "old": " 'channel408': dict(commit='two-sided-helper408-pr2894',manifest='56cf455752722051d598a7da1e5ee700637fbaef09189f534413dbe6e0525a83',helpers=408,source_file_count=610,upstream_head='18d03c447886895ef9abf888398178e0428533ca'),", + "new": " 'paired-extension': dict(commit='paired-helper-extension-pr2908',manifest='98d57c82a1c7318be3c330c3b66897844d57232f0aaeaea88fb4bebd0a1bedf1',helpers=408,source_file_count=632,upstream_head='51309592971e3b5be935599eed2a95404dc7781e')," + }, + { + "old": "COMPARISONS = {", + "new": "COMPARISONS = {\n 'pr2908': dict(pr=2908,head='51309592971e3b5be935599eed2a95404dc7781e',sha256='2406680a07b43a69b0f12f8462cc43f3616f3c8cb0a46bc767541b45945cd2bf',field='kappa'),\n 'pr2917': dict(pr=2917,head='224bd5e56041c40078ff6b5fa7393733a215de5c',sha256='e6c836c0178661a53a69cd91f29d83585e876f2511ff40c6b6204cd270fbdeac',field='kappa')," + }, + { + "old": "ap.add_argument('--source-profile', choices=['channel408'], default='channel408')", + "new": "ap.add_argument('--source-profile', choices=['paired-extension'], default='paired-extension')" + }, + { + "old": "ap.add_argument('--comparison-profile', choices=['pr2894'], default='pr2894')", + "new": "ap.add_argument('--comparison-profile', choices=['pr2908','pr2917'], default='pr2908')" + }, + { + "old": "zero_buffers_allocated_and_cleared=73", + "new": "zero_buffers_allocated_and_cleared=82" + }, + { + "old": "len(c.get('zero_buffers',[]))==73, 'helper408 physical ABI including all 73 private buffers'", + "new": "len(c.get('zero_buffers',[]))==82, 'paired extension physical ABI including all 82 private buffers'" + }, + { + "old": "896*T+expected_helpers+8+73+2, 'complete physical cost including all actual helpers and 73 buffers'", + "new": "896*T+expected_helpers+8+82+2, 'complete physical cost including all actual helpers and 82 buffers'" + } + ] + }, + "extension_blocknorm.py": { + "source": "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/r13pub-build/runs/fresh1/pr2908/tools/channel_blocknorm.py", + "before_sha256": "b53ebd53e3948f658c6da4f487a9ea10c9cb0a6acf2435750a32d6efeb9869c0", + "after_sha256": "d3893ef2265b1027f90b33832a3631b7a664bfdcac47962b83149d904bb7578f", + "replacements": [ + { + "old": "len(allocated)==73, 'all73 private zero buffers released'", + "new": "len(allocated)==82, 'all82 private zero buffers released'" + }, + { + "old": "'zero_buffers_allocated_and_cleared':73", + "new": "'zero_buffers_allocated_and_cleared':82" + }, + { + "old": "r['zero_buffers_returned_to_zero']==73", + "new": "r['zero_buffers_returned_to_zero']==82" + }, + { + "old": "physical==live+8+408+73+2", + "new": "physical==live+8+408+82+2" + }, + { + "old": "'zero_buffers':[live+416,live+489], 'coefficient':[live+489,live+491]", + "new": "'zero_buffers':[live+416,live+498], 'coefficient':[live+498,live+500]" + }, + { + "old": "len(mp)==73 and set(mp.values())==set(range(*ns['zero_buffers'])), '73distinct private Z slots'", + "new": "len(mp)==82 and set(mp.values())==set(range(*ns['zero_buffers'])), '82distinct private Z slots'" + }, + { + "old": "T=len(order)//9; live=896*T; physical=live+490", + "new": "T=len(order)//9; live=896*T; physical=live+500" + } + ] + } + } +} diff --git a/research/paired-extension-cap-fill/evidence/ADMISSION-RESULT.json b/research/paired-extension-cap-fill/evidence/ADMISSION-RESULT.json new file mode 100644 index 0000000000..7ac29da97c --- /dev/null +++ b/research/paired-extension-cap-fill/evidence/ADMISSION-RESULT.json @@ -0,0 +1,382 @@ +{ + "actual_expected_helpers": 408, + "comparison_claim_sha256": "e6c836c0178661a53a69cd91f29d83585e876f2511ff40c6b6204cd270fbdeac", + "comparison_head": "224bd5e56041c40078ff6b5fa7393733a215de5c", + "comparison_kappa": "17215886471978018806049999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000", + "comparison_pr": 2917, + "complex_lower": "1722499906443274564357/1000000000000000000000000", + "dispatch_sha256": "65e435bd68e97243c003677271b88485a29d4d0fae2dff1354100404a145e74c", + "external_input_sha256": { + "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/r13pub-build/runs/fresh1/adapters/extension_blocknorm.py": "d3893ef2265b1027f90b33832a3631b7a664bfdcac47962b83149d904bb7578f", + "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/r13pub-build/runs/fresh1/parent-export/pr2894/vendor/pr2857/vendor/pr2839/lift_parent.py": "9a1edd7d4ab4a2f2ac8d15b42b7e40f93653d65026bac59e4c1ce80b486bd60e", + "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/r13pub-build/runs/fresh1/parent-export/pr2894/vendor/pr2857/vendor/pr2839/reconstruct_replica.py": "5472811c24aef3852dc7e189dff5060076a6c0b25bfde928da50dcfe9b5bdc15", + "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/r13pub-build/runs/fresh1/parent-export/pr2894/vendor/pr2857/vendor/pr2839/replica_parent.py": "48bdbf28f59d80edb266803ec61bf5e22e8fb5e5a0e2b88004b6039147589bd4", + "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/r13pub-build/runs/fresh1/pr2917/CLAIM.json": "e6c836c0178661a53a69cd91f29d83585e876f2511ff40c6b6204cd270fbdeac", + "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/wt-r13pub/research/paired-extension-cap-fill/allocation/DISPATCH.json": "65e435bd68e97243c003677271b88485a29d4d0fae2dff1354100404a145e74c", + "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/wt-r13pub/research/paired-extension-cap-fill/allocation/FILL.json.gz": "e045aa613f8fba06d81313f5e1c2cbec9ee94552163b8d1eb9205bf2fa7f2285", + "/private/tmp/claude-501/-Users-mdumitrean-Desktop-dev-aigent-math-prime/c80ebb8e-fc28-4d1d-b7ef-b214d4660f98/scratchpad/wt-r13pub/research/paired-extension-cap-fill/allocation/ORDER.json": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1" + }, + "fill_sha256": "e045aa613f8fba06d81313f5e1c2cbec9ee94552163b8d1eb9205bf2fa7f2285", + "gain": "113907405684085469/125000000000000000000000", + "kappa": "17224999064432745643569999999999999999999998999999999999999999999999/10000000000000000000000000000000000000000000000000000000000000000000000", + "kappa_decimal": "0.0017224999064432745643569999999999999999999998999999999999999999999999", + "native_receipt_sha256": "9a2e23c80436cf257c6f21fa4bd3f796fdb569bf30005ca2c2bb16d8f2094969", + "order_sha256": "519d1d5dbb997a219fcfcad34c0b03e7838bef24199784d7e964fa10090f66e1", + "package_manifest_sha256": "b690eab49b010091973a4e7d1b8d58306200fd09f4c2281bbeeec57aa1b077d5", + "patches": [ + { + "after_sha256": "52f8b4cec2dab69cbe590e1fd0f7a68e1b35de5a540bd22fd2adfce07a92b46b", + "before_sha256": "faf283eb4edd2e6a1ccb40b3cb3ba30ae54338eaf5ea0a10d84d11d7939502af", + "path": "new/rebind.py", + "replacements": [ + [ + "physical=spec['expected']['live'] + 8 + R + 2)", + "physical=spec['expected']['live'] + 8 + R + 2 + max(len(rd(d / 'CANONICAL-WORD.json.gz').get('zero_buffers', [])) for d in locs.values()))" + ] + ] + }, + { + "after_sha256": "99bef04f24a99088e5c0c9b8f6bbc8386669d8315b8f572d6bbfb932c5d51145", + "before_sha256": "7edb4732b34e5814b27650a55c938626cb50d68f06397744dd4fe451437e90e0", + "path": "geometry_controls.py", + "replacements": [ + [ + " i['complete_invocation_sweeps']=i['bridge_sweeps']=333", + " i['complete_invocation_sweeps']-=1;i['bridge_sweeps']-=1" + ], + [ + " o,i=copy.deepcopy(owner),copy.deepcopy(invoice);fn(o,i);oh=digest(o);i['owner_audit_sha256']=oh", + " o,i=copy.deepcopy(owner),copy.deepcopy(invoice);fn(o,i);assert (o,i)!=(owner,invoice), 'geometry mutant must change actual receipts';oh=digest(o);i['owner_audit_sha256']=oh" + ] + ] + }, + { + "after_sha256": "6cfefe80c02a6c0f243f50ca9e146e1ab1440b84a033d8a71d42be5a5fa27f6b", + "before_sha256": "c43680a2da390f79925547a5ee1919d8a76637cccf98e2c8164b6f667fbc3183", + "path": "verify_release.py", + "replacements": [ + [ + "Fraction(1, 10 ** 3046) - Fraction(1, 10 ** 3022)", + "Fraction(1, 10 ** (spec['outer_refinement']['endpoint_digits'] + 46)) - Fraction(1, 10 ** (spec['outer_refinement']['endpoint_digits'] + 22))" + ], + [ + "epsilon=1-(1025/1024)e-3080", + "epsilon=1-(1025/1024)e-{spec['outer_refinement']['endpoint_digits']+80}" + ], + [ + "at the one 3000-digit rejection call", + "at the one {spec['outer_refinement']['endpoint_digits']}-digit rejection call" + ] + ] + }, + { + "after_sha256": "1dd56009986eb14dd6603c9193c7ad71dd45c7d005bf71c9cd3f916e66f54d98", + "before_sha256": "9e12909c73d3b3a31a45d801ae76c034510d6306400412e474df79bc4f1dc67e", + "path": "outer/check_ledger.py", + "replacements": [ + [ + "assert (m,W)==(73,66304)", + "T=spec['geometry']['replicas']\nassert type(T) is int and T>0\nassert m==73 and W==896*T and W==BJ['live']" + ] + ] + }, + { + "after_sha256": "ebaf637f1f818dac9c0fce0ee3f18df300873105818cea29a8ae9e8b737b5c7d", + "before_sha256": "08ca58abff11bdfba721dc56ab8acf06ec1b7c48a8699a0955cf35324680aca7", + "path": "code/witness.py", + "replacements": [ + [ + " with open(os.environ['WITNESS_RECORD'],'a')as f:f.write(json.dumps([key,got],default=str)+chr(10))", + " import time as _wr_time\n _wr_path=Path(os.environ['WITNESS_RECORD'])\n _wr_lock=_wr_path.with_name(_wr_path.name+'.append.lock')\n _wr_deadline=_wr_time.monotonic()+60\n _wr_fd=None\n while _wr_fd is None:\n try:_wr_fd=os.open(_wr_lock,os.O_CREAT|os.O_EXCL|os.O_WRONLY)\n except FileExistsError:\n if _wr_time.monotonic()>=_wr_deadline:raise TimeoutError('discovery record lock timeout; existing lock preserved')\n _wr_time.sleep(.005)\n try:\n with _wr_path.open('a',encoding='utf-8',newline='\\n')as _wr_out:\n _wr_out.write(json.dumps([key,got],default=str)+chr(10))\n _wr_out.flush()\n finally:\n os.close(_wr_fd)\n _wr_lock.unlink()" + ] + ] + }, + { + "after_sha256": "680b6de474a8226777c5a17191470b21cd5cc524cc22921d12dff6cef25c43ee", + "before_sha256": "b0d5f4217b4699c37609dc7c3633d570acbccd205840777d38f891846b4b918c", + "path": "verify.py", + "replacements": [ + [ + "run('lift-parent',P/'lift_parent.py','--owners',work/'rebuilt-owners','--out',work/'rebuilt-parent')", + "run('lift-parent',P/'lift_parent.py','--package',P,'--owners',work/'rebuilt-owners','--out',work/'rebuilt-parent')" + ] + ] + }, + { + "after_sha256": "0d8cc021d2401d047aaec79060ec2ea28ba06f12eca8dbf4c60c78bb31975c4e", + "before_sha256": "ebaf637f1f818dac9c0fce0ee3f18df300873105818cea29a8ae9e8b737b5c7d", + "path": "code/witness.py", + "replacements": [ + [ + "PAYLOAD==1<<(192+(GEO['dimension']+1)//2+2*CALLS+4).bit_length()", + "PAYLOAD==1<<(128+(GEO['dimension']+1)//2+18+1330+1+4).bit_length()" + ] + ] + }, + { + "after_sha256": "c5106e0d7a97382677fa228fbade989262347968a0e54acfcf6712aa37e02f47", + "before_sha256": "bb213d0af12218ff7c9c572717e522d8bbeeb2856b87a253f4a7f44e0fd71f15", + "path": "code/invoice_allcold.py", + "replacements": [ + [ + " required_prefix=localbits+input_l2_bits+call_count+bridge_sweeps+4", + " from blocknorm_certificate import certify\n blocknorm=certify(template, {pid:base/'providers'/pid for pid in template['local_providers']})\n assert blocknorm['status'] == 'PASS_TENSOR_BLOCK_NORM_CERTIFICATE'\n assert localbits <= 128, 'actual native scalar/Horner prefix exceeds charged local reserve'\n required_prefix=localbits+input_l2_bits+blocknorm['max_active_depth']+blocknorm['stock_l2_bits']+1+4" + ] + ] + }, + { + "after_sha256": "0d522b09c7fe6a5e62fe80c28f3eefe733557a82d77c6212e5d4b91ffb7e3421", + "before_sha256": "02502a217fe8c9e10229075b50745518beac512c48db20e64c3e06514a4da5b5", + "path": "independent_core.py", + "replacements": [ + [ + " payload = 1 << (192 + (M+1)//2 + 2*len(c['order']) + 4).bit_length()", + " require(localbits <= 128, 'measured native prefix exceeds local reserve')\n payload = 1 << (128 + (M+1)//2 + 18 + 1330 + 1 + 4).bit_length()" + ] + ] + }, + { + "after_sha256": "d598a2ac1e2e8eaee14a8c285e0277a7ae44ca6a15bd2b5cfc67fb40844fb387", + "before_sha256": "c5106e0d7a97382677fa228fbade989262347968a0e54acfcf6712aa37e02f47", + "path": "code/invoice_allcold.py", + "replacements": [ + [ + " complete_invocation_sweeps=call_count,bridge_sweeps=bridge_sweeps,row_prefix_extra=2*payload,", + " complete_invocation_sweeps=call_count,bridge_sweeps=bridge_sweeps,row_prefix_extra=2*payload,blocknorm=blocknorm," + ], + [ + " primitive_arithmetic_margin_bits=4,controller_audit_sha256=", + " tensor_block_norm=blocknorm,partial_cover_margin_bits=1,physical_stock_l2_bits=blocknorm['stock_l2_bits'],primitive_arithmetic_margin_bits=4,controller_audit_sha256=" + ], + [ + "Sum every actual invocation and bridge sweep and take the maximum local scalar/Horner prefix over both orientations of the fixed provider.", + "All invocations and bridge sweeps remain charged. Bound completed-boundary energy by at most eighteen active steps per owner replica, using exact tensor-isomorphic whole-family helper unitaries. Add the full group-indexed physical-stock sup-to-l2 factor and one partial-cover margin, then the maximum local scalar/Horner prefix." + ] + ] + }, + { + "after_sha256": "e051aaa166e01263780d5ae03699690670b597fed6593af4c37a7e978825eb85", + "before_sha256": "0d522b09c7fe6a5e62fe80c28f3eefe733557a82d77c6212e5d4b91ffb7e3421", + "path": "independent_core.py", + "replacements": [ + [ + " prefix = localbits + (M + 1) // 2 + len(c['order']) + c['bridges'] + 4", + " bn=c['blocknorm']\n require(bn['status']=='PASS_TENSOR_BLOCK_NORM_CERTIFICATE' and bn['max_active_depth']==18 and bn['stock_l2_bits']<=1330, 'independent tensor block certificate')\n prefix = localbits + (M + 1) // 2 + bn['max_active_depth'] + bn['stock_l2_bits'] + 1 + 4" + ], + [ + "prefix_formula=dict(local_scalar=localbits, input_l2=(M + 1) // 2, invocations=len(c['order']), bridges=c['bridges'], margin=4)", + "prefix_formula=dict(local_scalar=localbits, input_l2=(M + 1) // 2, invocations=len(c['order']), bridges=c['bridges'], active_block_depth=18,stock_l2=bn['stock_l2_bits'],partial_cover=1,margin=4),blocknorm=bn" + ] + ] + }, + { + "after_sha256": "393323f150d0bb686419804d51cf43d0f58450d2a1e7929725acdd26fdbb3640", + "before_sha256": "2286f00e462ff28abbb3f396095463482a1e063213b9526a7225275980c77eaf", + "path": "audit_mixed.py", + "replacements": [ + [ + "pending=A.check_pending_axes(ctx);receipt=A.check_roles(ctx,roles)", + "import blocknorm_certificate as BN;ctx['blocknorm']=BN.certify_context(ctx,roles,dirs,source_parent=parent);pending=A.check_pending_axes(ctx);receipt=A.check_roles(ctx,roles)" + ] + ] + }, + { + "after_sha256": "3ef9b2a2fa0dcf2d53884e205b7ac20ae6ef47d173b0d8a5bc97fb2a445fc143", + "before_sha256": "f25e1e870df5d5a16a1e367b3df8843cb01644ab4b75895d7939af81e4fcb833", + "path": "code/assemble.py", + "replacements": [ + [ + " assert invoice['global_prefix_bits']==max(z['prefix_bits']for p in invoice['providers'].values()for z in p['local'].values())+37+CALLS+CALLS+4", + " bn=invoice['blocknorm']\n assert bn['status']=='PASS_TENSOR_BLOCK_NORM_CERTIFICATE' and bn['replicas']==REPLICAS\n assert bn['max_active_depth']==bn['boundary_depth_bits']==18 and bn['active_calls_per_block']==bn['bridges_per_block']==9\n assert bn['block_width_families']==896 and bn['physical_families']==invoice['physical'] and bn['live_families']==invoice['live']\n assert bn['partial_cover_bits']==1 and bn['input_l2_bits']==37 and bn['local_reserve_bits']==128 and bn['retained_payload_bits']==PAYLOAD\n localbits=max(z['prefix_bits']for p in invoice['providers'].values()for z in p['local'].values())\n assert bn['local_actual_prefix_bits']==localbits and localbits<=128\n assert invoice['global_prefix_bits']==bn['actual_prefix_bits']==localbits+37+18+bn['stock_l2_bits']+1+4\n assert bn['required_reserve_bits']==128+37+18+bn['stock_l2_bits']+1+40\nassert m==73 and W==896*T and W==BJ['live']" + ] + ] + }, + { + "after_sha256": "ebaf637f1f818dac9c0fce0ee3f18df300873105818cea29a8ae9e8b737b5c7d", + "before_sha256": "08ca58abff11bdfba721dc56ab8acf06ec1b7c48a8699a0955cf35324680aca7", + "path": "code/witness.py", + "replacements": [ + [ + " with open(os.environ['WITNESS_RECORD'],'a')as f:f.write(json.dumps([key,got],default=str)+chr(10))", + " import time as _wr_time\n _wr_path=Path(os.environ['WITNESS_RECORD'])\n _wr_lock=_wr_path.with_name(_wr_path.name+'.append.lock')\n _wr_deadline=_wr_time.monotonic()+60\n _wr_fd=None\n while _wr_fd is None:\n try:_wr_fd=os.open(_wr_lock,os.O_CREAT|os.O_EXCL|os.O_WRONLY)\n except FileExistsError:\n if _wr_time.monotonic()>=_wr_deadline:raise TimeoutError('discovery record lock timeout; existing lock preserved')\n _wr_time.sleep(.005)\n try:\n with _wr_path.open('a',encoding='utf-8',newline='\\n')as _wr_out:\n _wr_out.write(json.dumps([key,got],default=str)+chr(10))\n _wr_out.flush()\n finally:\n os.close(_wr_fd)\n _wr_lock.unlink()" + ] + ] + }, + { + "after_sha256": "680b6de474a8226777c5a17191470b21cd5cc524cc22921d12dff6cef25c43ee", + "before_sha256": "b0d5f4217b4699c37609dc7c3633d570acbccd205840777d38f891846b4b918c", + "path": "verify.py", + "replacements": [ + [ + "run('lift-parent',P/'lift_parent.py','--owners',work/'rebuilt-owners','--out',work/'rebuilt-parent')", + "run('lift-parent',P/'lift_parent.py','--package',P,'--owners',work/'rebuilt-owners','--out',work/'rebuilt-parent')" + ] + ] + }, + { + "after_sha256": "0d8cc021d2401d047aaec79060ec2ea28ba06f12eca8dbf4c60c78bb31975c4e", + "before_sha256": "ebaf637f1f818dac9c0fce0ee3f18df300873105818cea29a8ae9e8b737b5c7d", + "path": "code/witness.py", + "replacements": [ + [ + "PAYLOAD==1<<(192+(GEO['dimension']+1)//2+2*CALLS+4).bit_length()", + "PAYLOAD==1<<(128+(GEO['dimension']+1)//2+18+1330+1+4).bit_length()" + ] + ] + }, + { + "after_sha256": "c5106e0d7a97382677fa228fbade989262347968a0e54acfcf6712aa37e02f47", + "before_sha256": "bb213d0af12218ff7c9c572717e522d8bbeeb2856b87a253f4a7f44e0fd71f15", + "path": "code/invoice_allcold.py", + "replacements": [ + [ + " required_prefix=localbits+input_l2_bits+call_count+bridge_sweeps+4", + " from blocknorm_certificate import certify\n blocknorm=certify(template, {pid:base/'providers'/pid for pid in template['local_providers']})\n assert blocknorm['status'] == 'PASS_TENSOR_BLOCK_NORM_CERTIFICATE'\n assert localbits <= 128, 'actual native scalar/Horner prefix exceeds charged local reserve'\n required_prefix=localbits+input_l2_bits+blocknorm['max_active_depth']+blocknorm['stock_l2_bits']+1+4" + ] + ] + }, + { + "after_sha256": "0d522b09c7fe6a5e62fe80c28f3eefe733557a82d77c6212e5d4b91ffb7e3421", + "before_sha256": "02502a217fe8c9e10229075b50745518beac512c48db20e64c3e06514a4da5b5", + "path": "independent_core.py", + "replacements": [ + [ + " payload = 1 << (192 + (M+1)//2 + 2*len(c['order']) + 4).bit_length()", + " require(localbits <= 128, 'measured native prefix exceeds local reserve')\n payload = 1 << (128 + (M+1)//2 + 18 + 1330 + 1 + 4).bit_length()" + ] + ] + }, + { + "after_sha256": "d598a2ac1e2e8eaee14a8c285e0277a7ae44ca6a15bd2b5cfc67fb40844fb387", + "before_sha256": "c5106e0d7a97382677fa228fbade989262347968a0e54acfcf6712aa37e02f47", + "path": "code/invoice_allcold.py", + "replacements": [ + [ + " complete_invocation_sweeps=call_count,bridge_sweeps=bridge_sweeps,row_prefix_extra=2*payload,", + " complete_invocation_sweeps=call_count,bridge_sweeps=bridge_sweeps,row_prefix_extra=2*payload,blocknorm=blocknorm," + ], + [ + " primitive_arithmetic_margin_bits=4,controller_audit_sha256=", + " tensor_block_norm=blocknorm,partial_cover_margin_bits=1,physical_stock_l2_bits=blocknorm['stock_l2_bits'],primitive_arithmetic_margin_bits=4,controller_audit_sha256=" + ], + [ + "Sum every actual invocation and bridge sweep and take the maximum local scalar/Horner prefix over both orientations of the fixed provider.", + "All invocations and bridge sweeps remain charged. Bound completed-boundary energy by at most eighteen active steps per owner replica, using exact tensor-isomorphic whole-family helper unitaries. Add the full group-indexed physical-stock sup-to-l2 factor and one partial-cover margin, then the maximum local scalar/Horner prefix." + ] + ] + }, + { + "after_sha256": "e051aaa166e01263780d5ae03699690670b597fed6593af4c37a7e978825eb85", + "before_sha256": "0d522b09c7fe6a5e62fe80c28f3eefe733557a82d77c6212e5d4b91ffb7e3421", + "path": "independent_core.py", + "replacements": [ + [ + " prefix = localbits + (M + 1) // 2 + len(c['order']) + c['bridges'] + 4", + " bn=c['blocknorm']\n require(bn['status']=='PASS_TENSOR_BLOCK_NORM_CERTIFICATE' and bn['max_active_depth']==18 and bn['stock_l2_bits']<=1330, 'independent tensor block certificate')\n prefix = localbits + (M + 1) // 2 + bn['max_active_depth'] + bn['stock_l2_bits'] + 1 + 4" + ], + [ + "prefix_formula=dict(local_scalar=localbits, input_l2=(M + 1) // 2, invocations=len(c['order']), bridges=c['bridges'], margin=4)", + "prefix_formula=dict(local_scalar=localbits, input_l2=(M + 1) // 2, invocations=len(c['order']), bridges=c['bridges'], active_block_depth=18,stock_l2=bn['stock_l2_bits'],partial_cover=1,margin=4),blocknorm=bn" + ] + ] + }, + { + "after_sha256": "393323f150d0bb686419804d51cf43d0f58450d2a1e7929725acdd26fdbb3640", + "before_sha256": "2286f00e462ff28abbb3f396095463482a1e063213b9526a7225275980c77eaf", + "path": "audit_mixed.py", + "replacements": [ + [ + "pending=A.check_pending_axes(ctx);receipt=A.check_roles(ctx,roles)", + "import blocknorm_certificate as BN;ctx['blocknorm']=BN.certify_context(ctx,roles,dirs,source_parent=parent);pending=A.check_pending_axes(ctx);receipt=A.check_roles(ctx,roles)" + ] + ] + }, + { + "after_sha256": "3ef9b2a2fa0dcf2d53884e205b7ac20ae6ef47d173b0d8a5bc97fb2a445fc143", + "before_sha256": "f25e1e870df5d5a16a1e367b3df8843cb01644ab4b75895d7939af81e4fcb833", + "path": "code/assemble.py", + "replacements": [ + [ + " assert invoice['global_prefix_bits']==max(z['prefix_bits']for p in invoice['providers'].values()for z in p['local'].values())+37+CALLS+CALLS+4", + " bn=invoice['blocknorm']\n assert bn['status']=='PASS_TENSOR_BLOCK_NORM_CERTIFICATE' and bn['replicas']==REPLICAS\n assert bn['max_active_depth']==bn['boundary_depth_bits']==18 and bn['active_calls_per_block']==bn['bridges_per_block']==9\n assert bn['block_width_families']==896 and bn['physical_families']==invoice['physical'] and bn['live_families']==invoice['live']\n assert bn['partial_cover_bits']==1 and bn['input_l2_bits']==37 and bn['local_reserve_bits']==128 and bn['retained_payload_bits']==PAYLOAD\n localbits=max(z['prefix_bits']for p in invoice['providers'].values()for z in p['local'].values())\n assert bn['local_actual_prefix_bits']==localbits and localbits<=128\n assert invoice['global_prefix_bits']==bn['actual_prefix_bits']==localbits+37+18+bn['stock_l2_bits']+1+4\n assert bn['required_reserve_bits']==128+37+18+bn['stock_l2_bits']+1+4 0 + for tag in ('base', 'extra'): + assert native['providers'][tag]['word_sha256'] == sha(P / f'data/WORD-{tag}.json.gz') + assert admit['fill_sha256'] == sha(P / 'allocation/FILL.json.gz') + assert admit['order_sha256'] == sha(P / 'allocation/ORDER.json') + assert admit['dispatch_sha256'] == sha(P / 'allocation/DISPATCH.json') + assert tree() == pins + print('PASS_CAP_FILL_LOCAL_OWNER_MOMENT_CAP_AND_STORED_RELEASE', claim['kappa_decimal'][:40], 'gain', float(Q(claim['gain']))) + +if __name__ == '__main__': + main() diff --git a/research/paired-extension-cap-fill/tools/audit_allocation_moment.py b/research/paired-extension-cap-fill/tools/audit_allocation_moment.py new file mode 100644 index 0000000000..e6a01a5e31 --- /dev/null +++ b/research/paired-extension-cap-fill/tools/audit_allocation_moment.py @@ -0,0 +1,82 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Independent dyadic interval moment auditor, atlas D020. +Retained PR2908 arithmetic by Jeremy Diviney and its credited upstream authors; +Mason Hale with OpenAI Codex assistance changes only the authenticated baseline. +Marius-Paul Dumitrean (Claude Code assisted) again changes only the authenticated baseline: the PR2917 headline. +Uses only Python integers/Fraction; imports no inherited numerical implementation. +This authenticates a paid histogram and its root, not a physical realization. +""" +from fractions import Fraction as F +from pathlib import Path +from functools import lru_cache +from collections import Counter +import argparse,json,hashlib + +BITS=192 +SCALE=1<=1,'log domain');k=0 + while q>2:q/=2;k+=1 + def unit(y): + z=(y-1)/(y+1);z2=z*z;term=z;value=F(0) + for j in range(128): + value+=term/(2*j+1);term*=z2 + remainder=2*term/(257*(1-z2)) + return 2*value,2*value+remainder + l,u=unit(q);l2,u2=unit(F(2));return down(l+k*l2),up(u+k*u2) +def exp_bounds(y): + need(0<=y0,'profile domain');l,u=log_bounds(F(73,rank));a=exp_bounds(b*l)[0];z=exp_bounds(b*u)[1];weight=F(rank*count,73*W);lo+=weight*a;hi+=weight*z + return down(lo),up(hi) +def run(candidate,source): + import sys + if hasattr(sys,'set_int_max_str_digits'):sys.set_int_max_str_digits(0) + need(hashlib.sha256((source/'CLAIM.json').read_bytes()).hexdigest()=='e6c836c0178661a53a69cd91f29d83585e876f2511ff40c6b6204cd270fbdeac','exact pinned PR2917 full headline') + prof={int(k):v for k,v in json.loads((candidate/'PROFILE.json').read_bytes()).items()} + old={int(k):v for k,v in json.loads((source/'PROFILE.json').read_bytes()).items()} + W=896*(1+max(r for s,r in json.loads((candidate/'ORDER.json').read_bytes()))) + oldW=896*(1+max(r for s,r in json.loads((source/'ORDER.json').read_bytes()))) + need(sum(r*n for r,n in prof.items())==W*73-W*320//896,'new rank mass') + need(sum(r*n for r,n in old.items())==oldW*73-oldW*320//896,'old rank mass') + # No floating endpoint or inherited numerical implementation is used. + q=10**26;lo=0;hi=q//200 + need(moment(prof,F(lo,q),W)[1]<1 and moment(prof,F(hi,q),W)[0]>1,'global root bracket') + while hi-lo>1: + mid=(lo+hi)//2;l,u=moment(prof,F(mid,q),W) + if u<1:lo=mid + elif l>1:hi=mid + else:raise ValueError('interval precision insufficient') + endpoint=F((lo//100),10**24) + target=endpoint-F(1,10**46)-F(1,10**70) + prior=F(json.loads((source/'CLAIM.json').read_bytes())['kappa']) + need(target>prior and target1,'overstated endpoint rejected') + wrong=dict(prof);wrong[32]=wrong.get(32,0)+1 + need(moment(wrong,F(lo,q),W)[0]>1,'omitted rank charge rejected') + import decimal + with decimal.localcontext() as c: + c.prec=80 + todec=lambda x:str(decimal.Decimal(x.numerator)/decimal.Decimal(x.denominator)) + texttarget=todec(target);textgain=todec(target-prior) + return dict(status='PASS_SEPARATE_EXACT_RATIONAL_FRONTIER_MOMENT',lower=str(F(lo,q)),upper=str(F(hi,q)),outer_endpoint=str(endpoint),target=str(target),target_decimal=texttarget,previous=str(prior),gain=str(target-prior),gain_decimal=textgain,W=W,oldW=oldW,normalized_profile_delta=normalized_delta,new_moment_at_full_prior=[str(x)for x in at_old],profile_sha256=hashlib.sha256((candidate/'PROFILE.json').read_bytes()).hexdigest(),baseline_profile_sha256=hashlib.sha256((source/'PROFILE.json').read_bytes()).hexdigest(),baseline_claim_sha256=hashlib.sha256((source/'CLAIM.json').read_bytes()).hexdigest(),method='Independent 128-term atanh / degree24 exponential with explicit positive tails and outward 192-bit dyadic rounding',controls=['zero log/exp identities','overstated endpoint','added rank32 charge'],scope='Complete paid histogram and exact moment only; full native/physical/outer release is separate.') +if __name__=='__main__': + p=argparse.ArgumentParser();p.add_argument('--candidate',type=Path,required=True);p.add_argument('--source',type=Path,required=True);p.add_argument('--out',type=Path,required=True);a=p.parse_args() + need(not a.out.exists(),'fresh output required');d=run(a.candidate,a.source);a.out.write_text(json.dumps(d,sort_keys=True,indent=2)+'\n',encoding='utf-8',newline='\n');print(json.dumps({k:d[k]for k in ['status','target_decimal','gain_decimal','lower','upper']})) diff --git a/research/paired-extension-cap-fill/tools/derive_adapters.py b/research/paired-extension-cap-fill/tools/derive_adapters.py new file mode 100644 index 0000000000..9e66ab8172 --- /dev/null +++ b/research/paired-extension-cap-fill/tools/derive_adapters.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""Generalized PR2917 adapter derivation (Marius-Paul Dumitrean, Claude Code assisted; PR2917/PR2908 derivations by Mason Hale and Jeremy Diviney): PR2908's exact tools -> closed-profile adapters for an +arbitrary derived overlay, buffer count B, source profile and comparator set. With B=82, commit +'paired-helper-extension-pr2908', profile 'paired-extension' and comparisons=pr2908 the output is byte-identical to +PR2917's tools/derive_adapters.py output (checked against its evidence/ADAPTER-DERIVATION.json), except the retained +receipt binding, which is always sha256(--retained-receipt). +usage: derive_adapters_r13.py --parent-package PR2908_PKG --source OVERLAY --retained-receipt FILE --out DIR + --buffers B --source-commit NAME --source-profile NAME --upstream-head HEX + [--comparison pr2917=/path/CLAIM.json ...] (pr2908 is always derived from the parent package's CLAIM.json) +""" +from pathlib import Path +import argparse, gzip, hashlib, json, sys +PARENT_HEAD = '51309592971e3b5be935599eed2a95404dc7781e' +PARENT_MANIFEST = '9dba3fe371602ec023a54e26c0fd66f69eb7a74be86aab89923529083c14b36f' +OLD_SOURCE = '56cf455752722051d598a7da1e5ee700637fbaef09189f534413dbe6e0525a83' +OLD_RETAINED = 'dd36443f2789ffa6deca7210c76ada781e2b9b7e622a546b366f51a475faff3e' +HEADS = {'pr2908': PARENT_HEAD, 'pr2917': '224bd5e56041c40078ff6b5fa7393733a215de5c'} +sha = lambda b: hashlib.sha256(b).hexdigest() + +def need(p, msg): + if not p: raise ValueError(msg) + +def tree(p): + need(not any(f.is_symlink() for f in p.rglob('*')), 'no symlinks') + return {f.relative_to(p).as_posix(): sha(f.read_bytes()) for f in p.rglob('*') if f.is_file() and f != p / 'MANIFEST.json'} + +def derive(parent, source, out, retained_sha, B, commit, profile, upstream_head, claims): + manifest = json.loads((parent / 'MANIFEST.json').read_bytes()); need(tree(parent) == manifest, 'complete exact parent manifest inventory') + need(sha((parent / 'MANIFEST.json').read_bytes()) == PARENT_MANIFEST, 'exact PR2908 package manifest') + newsha = sha((source / 'MANIFEST.json').read_bytes()) + files = json.loads((source / 'MANIFEST.json').read_bytes()); need(tree(source) == files, 'complete derived source inventory') + nfiles = len(files) + for tag in ('base', 'extra'): + w = json.loads(gzip.decompress((source / f'new/borrow/words/BORROW-WORD-43{tag}.json.gz').read_bytes())) + need(len(w['helper_final']) == B, f'declared {B}-buffer word ({tag}: {len(w["helper_final"])})') + need(len(set(range(224, 704)) - set(w['removed'])) == 408, '408 live helpers') + need(type(B) is int and 73 <= B <= 200, 'buffer count range') + need(len(retained_sha) == 64 and all(c in '0123456789abcdef' for c in retained_sha), 'retained receipt SHA256') + comps = [('pr2908', parent / 'CLAIM.json')] + [(k, Path(v)) for k, v in claims] + comp_entries = [] + for name, path in comps: + claim = json.loads(path.read_bytes()); need('headline_kappa_source' not in claim and 'kappa' in claim, 'headline outer comparison ' + name) + need(name in HEADS, 'known comparator head ' + name) + comp_entries.append((name, int(name[2:]), HEADS[name], sha(path.read_bytes()))) + out.mkdir(parents=True, exist_ok=False); changes = {} + def adapt(oldname, newname, pairs): + p = parent / 'tools' / oldname; body = p.read_text(); oldhash = sha(p.read_bytes()); applied = [] + for old, new in pairs: + need(body.count(old) == 1, f'exact preimage occurrence {oldname}: {old[:120]}') + body = body.replace(old, new); applied.append({'old': old, 'new': new}) + q = out / newname; q.write_text(body); compile(body, str(q), 'exec') + changes[newname] = {'source': str(p), 'before_sha256': oldhash, 'after_sha256': sha(q.read_bytes()), 'replacements': applied} + adapt('prepare_channel_native.py', 'prepare_extension_native.py', [ + ("SOURCE_SHA='" + OLD_SOURCE + "'", "SOURCE_SHA='" + newsha + "'"), + ('SOURCE_FILES=610', 'SOURCE_FILES=' + str(nfiles)), + ("SOURCE_COMMIT='two-sided-helper408-pr2894'", "SOURCE_COMMIT='" + commit + "'"), + ("OLD_RECEIPT_SHA='" + OLD_RETAINED + "'", "OLD_RECEIPT_SHA='" + retained_sha + "'"), + ("len(can['zero_buffers'])==73", f"len(can['zero_buffers'])=={B}"), + ]) + oldprofile = " 'channel408': dict(commit='two-sided-helper408-pr2894',manifest='" + OLD_SOURCE + "',helpers=408,source_file_count=610,upstream_head='18d03c447886895ef9abf888398178e0428533ca')," + newprofile = " '" + profile + "': dict(commit='" + commit + "',manifest='" + newsha + "',helpers=408,source_file_count=" + str(nfiles) + ",upstream_head='" + upstream_head + "')," + comp_text = "COMPARISONS = {" + ''.join("\n '" + n + "': dict(pr=" + str(pr) + ",head='" + h + "',sha256='" + s + "',field='kappa')," for n, pr, h, s in comp_entries) + choices = "['" + "','".join(n for n, *_ in comp_entries) + "']" + adapt('admit_channel408.py', 'admit_extension.py', [ + (oldprofile, newprofile), + ("COMPARISONS = {", comp_text), + ("ap.add_argument('--source-profile', choices=['channel408'], default='channel408')", "ap.add_argument('--source-profile', choices=['" + profile + "'], default='" + profile + "')"), + ("ap.add_argument('--comparison-profile', choices=['pr2894'], default='pr2894')", "ap.add_argument('--comparison-profile', choices=" + choices + ", default='pr2908')"), + ('zero_buffers_allocated_and_cleared=73', f'zero_buffers_allocated_and_cleared={B}'), + ("len(c.get('zero_buffers',[]))==73, 'helper408 physical ABI including all 73 private buffers'", f"len(c.get('zero_buffers',[]))=={B}, 'paired extension physical ABI including all {B} private buffers'"), + ("896*T+expected_helpers+8+73+2, 'complete physical cost including all actual helpers and 73 buffers'", f"896*T+expected_helpers+8+{B}+2, 'complete physical cost including all actual helpers and {B} buffers'"), + ]) + adapt('channel_blocknorm.py', 'extension_blocknorm.py', [ + ("len(allocated)==73, 'all73 private zero buffers released'", f"len(allocated)=={B}, 'all{B} private zero buffers released'"), + ("'zero_buffers_allocated_and_cleared':73", f"'zero_buffers_allocated_and_cleared':{B}"), + ("r['zero_buffers_returned_to_zero']==73", f"r['zero_buffers_returned_to_zero']=={B}"), + ('physical==live+8+408+73+2', f'physical==live+8+408+{B}+2'), + ("'zero_buffers':[live+416,live+489], 'coefficient':[live+489,live+491]", f"'zero_buffers':[live+416,live+{416 + B}], 'coefficient':[live+{416 + B},live+{418 + B}]"), + ("len(mp)==73 and set(mp.values())==set(range(*ns['zero_buffers'])), '73distinct private Z slots'", f"len(mp)=={B} and set(mp.values())==set(range(*ns['zero_buffers'])), '{B}distinct private Z slots'"), + ('T=len(order)//9; live=896*T; physical=live+490', f'T=len(order)//9; live=896*T; physical=live+{418 + B}'), + ]) + # The native address dimension and symplectic stock factor are deliberately retained (as in PR2917). + b = (out / 'extension_blocknorm.py').read_text(); a = (out / 'admit_extension.py').read_text() + need("require(d['m']==73" in b and 'Sp(72,2)' in b and 'range(1,37)' in b, 'retained native dimension and symplectic group') + need('assert m==73' in a, 'retained outer dimension') + receipt = {'status': f'PASS_CHECKED_{B}_BUFFER_ADAPTER_DERIVATION_R13', 'parent_head': PARENT_HEAD, 'parent_manifest_sha256': PARENT_MANIFEST, + 'source_commit': commit, 'source_profile': profile, 'upstream_head': upstream_head, 'source_manifest_sha256': newsha, 'source_files': nfiles, + 'comparisons': {n: dict(pr=pr, head=h, sha256=s) for n, pr, h, s in comp_entries}, 'retained_receipt_sha256': retained_sha, + 'buffer_count': B, 'physical_overhead': 418 + B, 'changes': changes} + (out / 'ADAPTER-DERIVATION.json').write_text(json.dumps(receipt, indent=2) + '\n'); return receipt + +if __name__ == '__main__': + ap = argparse.ArgumentParser(); ap.add_argument('--parent-package', type=Path, required=True); ap.add_argument('--source', type=Path, required=True) + ap.add_argument('--retained-receipt', type=Path, required=True); ap.add_argument('--out', type=Path, required=True); ap.add_argument('--buffers', type=int, required=True) + ap.add_argument('--source-commit', required=True); ap.add_argument('--source-profile', required=True); ap.add_argument('--upstream-head', required=True) + ap.add_argument('--comparison', action='append', default=[], help='name=path/to/CLAIM.json (pr2917=...)'); a = ap.parse_args() + claims = [tuple(c.split('=', 1)) for c in a.comparison] + r = derive(a.parent_package.resolve(), a.source.resolve(), a.out.resolve(), sha(a.retained_receipt.read_bytes()), a.buffers, a.source_commit, a.source_profile, a.upstream_head, claims) + print(r['status'], r['source_manifest_sha256'], r['source_files'], {k: v['after_sha256'][:16] for k, v in r['changes'].items()}) diff --git a/research/paired-extension-cap-fill/tools/relax.py b/research/paired-extension-cap-fill/tools/relax.py new file mode 100644 index 0000000000..97dfe35c43 --- /dev/null +++ b/research/paired-extension-cap-fill/tools/relax.py @@ -0,0 +1,329 @@ +#!/usr/bin/env python3 +"""relax.py -- changed-inventory, fixed-capacity fractional relaxation (upper bound on the complex endpoint) +for an ARBITRARY per-call local profile and per-call helper-width inventory, with exact rational verification. + +Model (everything per replica; the fractional cap is independent of T): + * bins: every replica has 112 ports x 18 idle children; the child capacities (ranks) come from the + T37 template: 6 children of capacity 8, 4 of 16, 4 of 32, 4 of 48 -> bins {8:672, 16:448, 32:448, 48:448}. + * roles: every call hosts all its helpers; a helper of width w occupies w consecutive units of ONE bin; + the 9 calls of a replica supply 9*inventory[w] roles of width w per replica (the inventory is per call; + with two providers of different widths pass the call-weighted average, a Fraction is fine). + * pattern catalogue: every multiset of widths with sum <= capacity ("bounded count-vector enumeration"); + the bin then pays ONE idle child of rank cap - used (rank 0 = nothing). + * CHRONOLOGY IS IGNORED: no source windows, no per-call family collisions, no "one role per bin per call", + no integrality. A bin pattern count may be fractional. Hence this is an UPPER bound on what any + actual fill of the same inventory can reach, and the bound is NOT a chronological witness. + * local profile is fixed and fully paid: 9 * local[r] children of rank r per replica. + Moment: M_x(b) = (9*sum_r local_r H_r(b) + sum_p x_p H_{r_p}(b)) / (73*896), H_r(b) = r*(73/r)^b, + LP(b): min_x sum_p x_p H_{r_p}(b) s.t. sum_{p in cap c} x_p = bins[c], sum_p n_w(p) x_p = 9*inv[w], x>=0. + cap = the root b of min_x M_x(b) = 1 (g(b) = min_x M_x(b) is increasing). + +Exact verification (same technique as PR2857's audit_relaxation.py, re-implemented): + 1. float bisection with scipy/HiGHS locates b*; the optimal basis B (9 columns) is read off; + 2. x_B = B^-1 rhs exactly (Fractions) -> the primal profile; root bracketed at 10^-25 with the package's + rational interval arithmetic (root.py): M(lo) < 1 < M(hi) -> cap >= lo (x_B is feasible); + 3. dual y(b) = B^-T c_B(b) is an exact rational combination of the H_k(b): the Y matrix of the receipt; + every pattern's reduced cost at b = hi is bracketed with the H enclosures and must be > 0 (or identically 0 + for the tight patterns) -> by weak duality every feasible x has M_x(hi) >= M_{x_B}(hi) > 1 -> cap <= hi. + Reproduces PR2857: cap in [0.001720100805416885927944, 0.001720100805416885927945], 1163 patterns, 11 tight. + +Usage: + python -B relax.py --calibrate + python -B relax.py --inventory '{"4":26,"5":2,"7":62,"8":85,"9":233}' --local '{"1":2397,"2":640,"3":266,"4":128,"5":26,"8":8}' + python -B relax.py --delta-inventory '{"8":1,"9":-1}' --delta-local '{"1":3,"2":-2}' # relative to PR2857 + python -B relax.py --scenarios # the hypothetical table of ROUND.md (one/two 9->8, 8->7, removal) +API: relax(local, inventory, bins=BINS) -> dict (cap_lower, cap_upper, active patterns, idle histogram, dual check, ...) +""" +from fractions import Fraction as Q +from itertools import product +import argparse, json, sys, os +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import root as R + +BINS = {8: 672, 16: 448, 32: 448, 48: 448} # bins per replica (112 ports x children per capacity) +LIVE = R.LIVE_PER_REPLICA # 896 +CALLS = R.CALLS_PER_REPLICA # 9 +PR2857_LOCAL = {1: 2394, 2: 642, 3: 266, 4: 128, 5: 26, 8: 8} +PR2857_INV = {4: 26, 5: 2, 7: 62, 8: 84, 9: 234} +PR2857_REALIZED_LOWER = Q('17200966286848326009728/10000000000000000000000000') +PR2857_REALIZED_UPPER = Q('17200966286848326009729/10000000000000000000000000') +PR2857_CAP_UPPER = Q('344020161083377185589/200000000000000000000000') # 0.001720100805416885927945 +PR2848_KAPPA = Q('17186585083049300/10000000000000000000') # 0.0017186585083049300 (incumbent of PR2857's gain) + + +def need(c, m): + if not c: + raise ValueError(m) + + +def patterns(bins, widths): + out = [] + for cap in sorted(bins): + for counts in product(*(range(cap // w + 1) for w in widths)): + used = sum(w * n for w, n in zip(widths, counts)) + if used <= cap: + out.append((cap, counts, cap - used)) + return out + + +def Hfloat(r, b): + import math + return 0.0 if r == 0 else r * (73.0 / r) ** b + + +def lp_min(pats, caps, widths, rhs, b): + """float LP at saving b: returns (optimal value, x, duals y).""" + import numpy as np + from scipy.optimize import linprog + c = np.array([Hfloat(r, b) for cap, counts, r in pats]) + A = np.zeros((len(caps) + len(widths), len(pats))) + for j, (cap, counts, r) in enumerate(pats): + A[caps.index(cap), j] = 1.0 + for i, n in enumerate(counts): + if n: + A[len(caps) + i, j] = n + res = linprog(c, A_eq=A, b_eq=np.array([float(v) for v in rhs]), bounds=(0, None), method='highs') + need(res.status == 0, 'LP infeasible or failed: ' + res.message) + return res.fun, res.x, res.eqlin.marginals, A + + +def rat_inverse(Bm): + n = len(Bm) + M = [row[:] + [Q(int(i == j)) for j in range(n)] for i, row in enumerate(Bm)] + for col in range(n): + piv = next((r for r in range(col, n) if M[r][col] != 0), None) + need(piv is not None, 'singular basis') + M[col], M[piv] = M[piv], M[col] + f = M[col][col] + M[col] = [v / f for v in M[col]] + for r in range(n): + if r != col and M[r][col] != 0: + g = M[r][col] + M[r] = [a - g * bb for a, bb in zip(M[r], M[col])] + return [row[n:] for row in M] + + +def rat_rank(cols): + """rank of a list of rational column vectors""" + rows = [list(c) for c in cols] + rank = 0 + ncol = len(rows[0]) if rows else 0 + for col in range(ncol): + piv = next((r for r in range(rank, len(rows)) if rows[r][col] != 0), None) + if piv is None: + continue + rows[rank], rows[piv] = rows[piv], rows[rank] + for r in range(len(rows)): + if r != rank and rows[r][col] != 0: + g = rows[r][col] / rows[rank][col] + rows[r] = [a - g * bb for a, bb in zip(rows[r], rows[rank])] + rank += 1 + return rank + + +def column(pat, caps, widths): + cap, counts, r = pat + return [Q(int(cap == c)) for c in caps] + [Q(n) for n in counts] + + +def relax(local, inventory, bins=BINS, digits=25, verbose=False): + local = {int(r): Q(n) for r, n in local.items() if Q(n) != 0} + inventory = {int(w): Q(n) for w, n in inventory.items() if Q(n) != 0} + need(all(n > 0 for n in local.values()) and all(n > 0 for n in inventory.values()), 'positive local/inventory') + widths = sorted(inventory) + caps = sorted(bins) + pats = patterns(bins, widths) + rhs = [Q(bins[c]) for c in caps] + [CALLS * inventory[w] for w in widths] + local_rep = {r: CALLS * n for r, n in local.items()} + total_cap = sum(c * bins[c] for c in caps) + inv_mass = sum(w * inventory[w] for w in widths) * CALLS + local_mass = sum(r * n for r, n in local_rep.items()) + idle_mass = total_cap - inv_mass + need(idle_mass >= 0, 'inventory exceeds bin capacity') + mass_ok = (local_mass + idle_mass == R.MASS_PER_REPLICA) + + # --- 1. float bisection on b + import numpy as np + def gfloat(b): + val, x, y, A = lp_min(pats, caps, widths, rhs, b) + loc = sum(float(n) * Hfloat(r, b) for r, n in local_rep.items()) + return (loc + val) / (73 * LIVE) - 1.0, x, y + lo, hi = 0.0, 0.01 + g_lo, _, _ = gfloat(lo) + g_hi, _, _ = gfloat(hi) + need(g_lo < 0 < g_hi, 'root window [0, 0.01] does not bracket the cap') + for _ in range(64): + mid = (lo + hi) / 2 + g, x, y = gfloat(mid) + if g < 0: + lo = mid + else: + hi = mid + b_star = (lo + hi) / 2 + g, x, y, = gfloat(b_star) + val, x, y, A = lp_min(pats, caps, widths, rhs, b_star) + + # --- 2. basis: support of x, completed by tight (zero reduced cost) columns to full rank + c = np.array([Hfloat(r, b_star) for cap, counts, r in pats]) + rc = c - A.T @ y + order = sorted(range(len(pats)), key=lambda j: (0 if x[j] > 1e-9 else 1, abs(float(rc[j])), -float(x[j]))) + basis = [] + cols = [] + for j in order: + if len(basis) == len(rhs): + break + if x[j] <= 1e-9 and abs(rc[j]) > 1e-7: + continue + col = column(pats[j], caps, widths) + if rat_rank(cols + [col]) > len(cols): + basis.append(j) + cols.append(col) + need(len(basis) == len(rhs), 'could not complete an optimal basis (degenerate LP); %d of %d' % (len(basis), len(rhs))) + Bm = [[cols[k][i] for k in range(len(basis))] for i in range(len(rhs))] # rows = constraints + Binv = rat_inverse(Bm) + xB = [sum(Binv[k][i] * rhs[i] for i in range(len(rhs))) for k in range(len(basis))] + need(all(v >= 0 for v in xB), 'basis not primal feasible') + active = [(pats[j], xB[k]) for k, j in enumerate(basis) if xB[k] > 0] + idle = {} + for (cap, counts, r), n in active: + if r: + idle[r] = idle.get(r, 0) + n + full = dict(local_rep) + for r, n in idle.items(): + full[r] = full.get(r, 0) + n + cap_lo, cap_hi = R.root_bracket(full, LIVE, digits, check_mass_T=1 if mass_ok else None) + + # --- 3. exact dual in the H basis: y_j(b) = sum_k (B^-T)_{j,k} H_{r_k}(b) + ranks = sorted({r for cap, counts, r in pats if r}) + # (B^-T)_{j,k} = Binv[k][j] + Y = {j: {} for j in range(len(rhs))} + for j in range(len(rhs)): + for k, pj in enumerate(basis): + r = pats[pj][2] + if r == 0 or Binv[k][j] == 0: + continue + Y[j][r] = Y[j].get(r, 0) + Binv[k][j] + Hhi = {r: R.H(r, cap_hi) for r in ranks} + tight = [] + strict = 0 + min_slack = None + for p in pats: + cap, counts, r = p + a = column(p, caps, widths) + coeff = {} + if r: + coeff[r] = Q(1) + for j in range(len(rhs)): + if a[j] == 0: + continue + for k, v in Y[j].items(): + coeff[k] = coeff.get(k, 0) - a[j] * v + coeff = {k: v for k, v in coeff.items() if v != 0} + if not coeff: + tight.append(p) + continue + lower = sum(v * (Hhi[k][0] if v > 0 else Hhi[k][1]) for k, v in coeff.items()) + need(lower > 0, 'dual sign failure for pattern %s (reduced-cost lower bound %s)' % (str(p), str(lower))) + strict += 1 + min_slack = lower if min_slack is None else min(min_slack, lower) + dual_obj = sum(rhs[j] * sum(v * Hhi[k][0] for k, v in Y[j].items()) for j in range(len(rhs))) # not needed for the proof, informational + dual_rows = ['cap%d' % c for c in caps] + ['w%d' % w for w in widths] + return dict( + status='PASS_EXACT_RELAXATION_CAP' if mass_ok else 'PASS_EXACT_RELAXATION_CAP_MASS_NOT_65088', + cap_lower=str(cap_lo), cap_upper=str(cap_hi), cap_lower_decimal=R.mpmath_str(cap_lo, digits), cap_upper_decimal=R.mpmath_str(cap_hi, digits), + patterns=len(pats), tight_patterns=len(tight), strict_patterns=strict, minimum_slack_lower=str(min_slack), + basis_patterns=[dict(capacity=pats[j][0], widths=[w for w, n in zip(widths, pats[j][1]) for _ in range(n)], count_per_replica=str(xB[k])) for k, j in enumerate(basis)], + tight_pattern_list=[dict(capacity=p[0], widths=[w for w, n in zip(widths, p[1]) for _ in range(n)]) for p in tight], + idle_per_replica={str(r): str(n) for r, n in sorted(idle.items())}, + idle_mass_per_replica=str(idle_mass), local_mass_per_replica=str(local_mass), rank_mass_per_replica=str(local_mass + idle_mass), rank_mass_identity=mass_ok, + dual_Y={dual_rows[j]: {str(k): str(v) for k, v in sorted(Y[j].items())} for j in range(len(rhs))}, + inventory_per_call={str(w): str(inventory[w]) for w in widths}, local_per_call={str(r): str(n) for r, n in sorted(local.items())}, bins_per_replica=bins, + delta_vs_PR2857_realized=dict(lower=str(cap_lo - PR2857_REALIZED_UPPER), upper=str(cap_hi - PR2857_REALIZED_LOWER), float=float(cap_lo - PR2857_REALIZED_LOWER)), + delta_vs_PR2857_cap=dict(float=float(cap_lo - PR2857_CAP_UPPER)), + assumptions='fixed capacities 8/16/32/48 (112 ports x 6/4/4/4 children per replica), all count-vector patterns with sum<=cap, one idle child of rank cap-used per bin, chronology/windows/collisions/integrality ignored, local profile fully paid; upper bound on any actual fill of this inventory, not a witness', + ) + + +def scenarios(): + base_local, base_inv = PR2857_LOCAL, PR2857_INV + def mod(dl, di): + l = {r: base_local.get(r, 0) + dl.get(r, 0) for r in set(base_local) | set(dl)} + i = {w: base_inv.get(w, 0) + di.get(w, 0) for w in set(base_inv) | set(di)} + return {r: n for r, n in l.items() if n}, {w: n for w, n in i.items() if n} + table = [ + ('PR2857 actual (calibration)', {}, {}), + ('one more 9->8 at PR2857 cost {1:+3,2:-2}', {1: 3, 2: -2}, {8: 1, 9: -1}), + ('one more 9->8 at PR2853 cost {1:+5,2:-3}', {1: 5, 2: -3}, {8: 1, 9: -1}), + ('one more 9->8 at minimal cost {1:+1,2:-1}', {1: 1, 2: -1}, {8: 1, 9: -1}), + ('two more 9->8 at PR2857 cost {1:+6,2:-4}', {1: 6, 2: -4}, {8: 2, 9: -2}), + ('four more 9->8 at PR2857 cost {1:+12,2:-8}', {1: 12, 2: -8}, {8: 4, 9: -4}), + ('one 8->7 at PR2857-like cost {1:+3,2:-2}', {1: 3, 2: -2}, {7: 1, 8: -1}), + ('one 8->7 at minimal cost {1:+1,2:-1}', {1: 1, 2: -1}, {7: 1, 8: -1}), + ('one 9->7 (two units) at cost {1:+6,2:-4}', {1: 6, 2: -4}, {7: 1, 9: -1}), + ('remove one width-9 helper, its 9 one-dim climbs vanish {1:-9}', {1: -9}, {9: -1}), + ('remove one width-9 helper paying {1:-7,2:-1}', {1: -7, 2: -1}, {9: -1}), + ('remove one width-8 helper {1:-8}', {1: -8}, {8: -1}), + ('remove one width-4 helper {1:-4}', {1: -4}, {4: -1}), + ('local only: +1 H1 -1 H2 per call (mass -1, inventory unchanged: NOT a legal word, derivative probe)', {1: 1, 2: -1}, {}), + ('local only: -1 H1 per call (mass -1, derivative probe)', {1: -1}, {}), + ('local only: 2 H1 -> 1 H2 per call (mass neutral)', {1: -2, 2: 1}, {}), + ('local only: 1 H3 -> 1 H1 + 1 H2 per call (mass neutral)', {3: -1, 1: 1, 2: 1}, {}), + ] + out = [] + for name, dl, di in table: + l, i = mod(dl, di) + try: + r = relax(l, i) + row = dict(scenario=name, delta_local=dl, delta_inventory=di, cap_lower=r['cap_lower_decimal'], cap_upper=r['cap_upper_decimal'], + gain_vs_PR2857_realized_float=r['delta_vs_PR2857_realized']['float'], gain_vs_PR2857_cap_float=r['delta_vs_PR2857_cap']['float'], + tight=r['tight_patterns'], patterns=r['patterns'], idle_per_replica=r['idle_per_replica'], basis=r['basis_patterns'], rank_mass_identity=r['rank_mass_identity'], status=r['status']) + except Exception as e: # noqa + row = dict(scenario=name, delta_local=dl, delta_inventory=di, error=str(e)) + out.append(row) + print('%-95s cap<= %s gain vs realized %+.4e vs cap %+.4e %s' % (name, row.get('cap_upper', '?'), row.get('gain_vs_PR2857_realized_float', float('nan')), row.get('gain_vs_PR2857_cap_float', float('nan')), row.get('error', '')), file=sys.stderr, flush=True) + return out + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument('--calibrate', action='store_true') + ap.add_argument('--scenarios', action='store_true') + ap.add_argument('--inventory', help='JSON per-call {width: count}') + ap.add_argument('--local', help='JSON per-call {rank: count}') + ap.add_argument('--delta-inventory', help='JSON {width: +-count} relative to PR2857') + ap.add_argument('--delta-local', help='JSON {rank: +-count} relative to PR2857') + ap.add_argument('--digits', type=int, default=25) + ap.add_argument('--out') + a = ap.parse_args() + if a.calibrate: + r = relax(PR2857_LOCAL, PR2857_INV, digits=a.digits) + r['reproduces_PR2857_cap_lower'] = (Q(r['cap_lower']) == Q('215012600677110740993/125000000000000000000000')) + r['bracket_inside_PR2857_bracket'] = (Q(r['cap_lower']) >= Q('215012600677110740993/125000000000000000000000') and Q(r['cap_upper']) <= PR2857_CAP_UPPER) + r['reproduces_PR2857_cap_upper_at_24_digits'] = (relax(PR2857_LOCAL, PR2857_INV, digits=24)['cap_upper'] == str(PR2857_CAP_UPPER)) + r['reproduces_PR2857_pattern_count_1163'] = (r['patterns'] == 1163) + r['reproduces_PR2857_11_tight_1152_strict'] = (r['tight_patterns'] == 11 and r['strict_patterns'] == 1152) + res = r + elif a.scenarios: + res = scenarios() + else: + local = dict(PR2857_LOCAL) + inv = dict(PR2857_INV) + if a.local: + local = {int(k): Q(v) for k, v in json.loads(a.local).items()} + if a.inventory: + inv = {int(k): Q(v) for k, v in json.loads(a.inventory).items()} + if a.delta_local: + for k, v in json.loads(a.delta_local).items(): + local[int(k)] = local.get(int(k), 0) + Q(v) + if a.delta_inventory: + for k, v in json.loads(a.delta_inventory).items(): + inv[int(k)] = inv.get(int(k), 0) + Q(v) + res = relax({k: v for k, v in local.items() if v}, {k: v for k, v in inv.items() if v}, digits=a.digits) + s = json.dumps(res, indent=1, sort_keys=True, default=str) + if a.out: + open(a.out, 'w').write(s) + print(s) + + +if __name__ == '__main__': + main() diff --git a/research/paired-extension-cap-fill/tools/relax_exact.py b/research/paired-extension-cap-fill/tools/relax_exact.py new file mode 100644 index 0000000000..0be97756bb --- /dev/null +++ b/research/paired-extension-cap-fill/tools/relax_exact.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +"""relax_exact.py -- Fractions-only verification of a stored optimal basis of the changed-inventory +fixed-capacity fractional relaxation (relax.py), without scipy. + +relax.py locates the optimal basis with a float LP (scipy/HiGHS) and then certifies it exactly. This module +performs only the exact part, from a stored list of basis patterns: + 1. x_B = B^-1 rhs (exact rationals), x_B >= 0: the basic solution is feasible, so the cap is at least the + root of its complete profile (root.py bracket at 10^-digits); + 2. the dual y(b) = B^-T c_B(b) is an exact rational combination of the H_k(b); every one of the capacity- + feasible patterns has reduced cost > 0 (or identically 0) at b = hi, so by weak duality every feasible x + has moment >= 1 at hi: the cap is at most hi. +The bins, pattern catalogue, moment model and interval arithmetic are relax.py's / root.py's (imported). + +Marius-Paul Dumitrean, prepared with substantial AI assistance (Anthropic Claude, via Claude Code). Apache-2.0. +""" +from fractions import Fraction as Q +import os, sys +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import root as R +import relax as X + + +def need(c, m): + if not c: + raise ValueError(m) + + +def pattern_of(entry, widths, bins): + cap = int(entry['capacity']) + need(cap in bins, 'basis pattern capacity %r is not a bin capacity' % cap) + counts = tuple(list(entry['widths']).count(w) for w in widths) + need(sum(counts) == len(entry['widths']), 'basis pattern uses a width outside the inventory: %r' % (entry,)) + used = sum(w * n for w, n in zip(widths, counts)) + need(used <= cap, 'basis pattern exceeds its capacity') + return (cap, counts, cap - used) + + +def verify_basis(local, inventory, basis_patterns, bins=X.BINS, digits=25): + local = {int(r): Q(n) for r, n in local.items() if Q(n) != 0} + inventory = {int(w): Q(n) for w, n in inventory.items() if Q(n) != 0} + need(all(n > 0 for n in local.values()) and all(n > 0 for n in inventory.values()), 'positive local/inventory') + widths = sorted(inventory) + caps = sorted(bins) + pats = X.patterns(bins, widths) + patset = set(pats) + rhs = [Q(bins[c]) for c in caps] + [X.CALLS * inventory[w] for w in widths] + local_rep = {r: X.CALLS * n for r, n in local.items()} + total_cap = sum(c * bins[c] for c in caps) + inv_mass = sum(w * inventory[w] for w in widths) * X.CALLS + local_mass = sum(r * n for r, n in local_rep.items()) + idle_mass = total_cap - inv_mass + need(idle_mass >= 0, 'inventory exceeds bin capacity') + mass_ok = (local_mass + idle_mass == R.MASS_PER_REPLICA) + basis = [pattern_of(e, widths, bins) for e in basis_patterns] + need(len(basis) == len(rhs), 'basis must have exactly %d patterns' % len(rhs)) + need(all(p in patset for p in basis), 'basis pattern outside the catalogue') + need(len(set(basis)) == len(basis), 'repeated basis pattern') + cols = [X.column(p, caps, widths) for p in basis] + need(X.rat_rank(cols) == len(rhs), 'basis columns are linearly dependent') + Bm = [[cols[k][i] for k in range(len(basis))] for i in range(len(rhs))] + Binv = X.rat_inverse(Bm) + xB = [sum(Binv[k][i] * rhs[i] for i in range(len(rhs))) for k in range(len(basis))] + need(all(v >= 0 for v in xB), 'basis not primal feasible (negative basic variable)') + for e, v in zip(basis_patterns, xB): + if 'count_per_replica' in e: + need(Q(e['count_per_replica']) == v, 'stored basic count differs from B^-1 rhs: %r' % (e,)) + idle = {} + for p, n in zip(basis, xB): + if p[2] and n: + idle[p[2]] = idle.get(p[2], 0) + n + full = dict(local_rep) + for r, n in idle.items(): + full[r] = full.get(r, 0) + n + cap_lo, cap_hi = R.root_bracket(full, X.LIVE, digits, check_mass_T=1 if mass_ok else None) + ranks = sorted({r for cap, counts, r in pats if r}) + Y = {j: {} for j in range(len(rhs))} + for j in range(len(rhs)): + for k, p in enumerate(basis): + r = p[2] + if r == 0 or Binv[k][j] == 0: + continue + Y[j][r] = Y[j].get(r, 0) + Binv[k][j] + Hhi = {r: R.H(r, cap_hi) for r in ranks} + tight = strict = 0 + min_slack = None + for p in pats: + a = X.column(p, caps, widths) + coeff = {} + if p[2]: + coeff[p[2]] = Q(1) + for j in range(len(rhs)): + if a[j] == 0: + continue + for k, v in Y[j].items(): + coeff[k] = coeff.get(k, 0) - a[j] * v + coeff = {k: v for k, v in coeff.items() if v != 0} + if not coeff: + tight += 1 + continue + lower = sum(v * (Hhi[k][0] if v > 0 else Hhi[k][1]) for k, v in coeff.items()) + need(lower > 0, 'dual sign failure for pattern %s (reduced-cost lower bound %s)' % (str(p), str(lower))) + strict += 1 + min_slack = lower if min_slack is None else min(min_slack, lower) + return dict(status='PASS_EXACT_RELAXATION_CAP' if mass_ok else 'PASS_EXACT_RELAXATION_CAP_MASS_NOT_65088', + cap_lower=str(cap_lo), cap_upper=str(cap_hi), patterns=len(pats), tight_patterns=tight, + strict_patterns=strict, minimum_slack_lower=str(min_slack), rank_mass_identity=mass_ok, + idle_per_replica={str(r): str(n) for r, n in sorted(idle.items())}, + basic_counts=[str(v) for v in xB]) diff --git a/research/paired-extension-cap-fill/tools/root.py b/research/paired-extension-cap-fill/tools/root.py new file mode 100644 index 0000000000..bd6dc2eb4e --- /dev/null +++ b/research/paired-extension-cap-fill/tools/root.py @@ -0,0 +1,254 @@ +#!/usr/bin/env python3 +"""root.py -- exact (rational-bracketed) complex endpoint kappa from a complete global profile. + +The T-replica network has 9*T calls, live width W = 896*T, base m = 73. A complete paid profile +{rank: count} (local jumps of all calls + idle/remainder children of all bins) has the moment + + M(b) = sum_r count_r * r * (73/r)^b / (73 * W) (= audit_owners.moment(profile, b, W)) + +which is increasing in b; the complex endpoint is the root M(b) = 1. PR2857's headline is +floor(root_lower, 24 digits) - 1e-46 - 1e-70; PR2853/PR2833's headlines are their roots - O(1e-3022). +The rational interval arithmetic (log via atanh series, exp via Taylor, outward rounding at 10^-45) +is the package's own, so the brackets coincide exactly with the independent audits. + +Rank-mass identity for a complete profile: sum_r r*count_r = 65088*T (= (73-1)*896*T + 64*9*T). + +Usage: + python -B root.py --calibrate # PR2857 / PR2853 / PR2833 reproduction + python -B root.py --profile '{"1":805860,...}' --T 37 [--delta '{"1":9,"2":-9}'] [--digits 25] + python -B root.py --profile-file PROFILE.json --T 37 --table # per-rank derivative table +API: + kappa_from_profile(profile, T, digits=25) -> (lo, hi) exact Fractions, M(lo)<1 dict with new bracket and exact gain interval + derivatives(profile, T) -> {rank: dkappa/dcount_r} (mpmath, 40 digits) +""" +from fractions import Fraction as Q +from functools import lru_cache +import argparse, json, sys + +M_BASE = 73 +LIVE_PER_REPLICA = 896 +CALLS_PER_REPLICA = 9 +MASS_PER_REPLICA = (M_BASE - 1) * LIVE_PER_REPLICA + 64 * CALLS_PER_REPLICA # 65088 +SCALE = 10 ** 45 + + +def need(c, m): + if not c: + raise ValueError(m) + + +@lru_cache(None) +def logarithm(x): + """Rational enclosure of log(x), x >= 1 (package arithmetic, outward rounding 10^-45).""" + need(x >= 1, 'log argument') + k = 0 + while x >= 2: + x /= 2 + k += 1 + + def unit(y): + z = (y - 1) / (y + 1) + power = z + total = Q(0) + for j in range(100): + total += power / (2 * j + 1) + power *= z * z + total *= 2 + tail = 2 * power / (201 * (1 - z * z)) + return total, total + tail + + lo, hi = unit(x) + l2, h2 = unit(Q(2)) + lo += k * l2 + hi += k * h2 + return Q((lo * SCALE).__floor__(), SCALE), Q((hi * SCALE).__ceil__(), SCALE) + + +def exponential(x): + need(0 <= x < 1, 'exp argument') + term = total = Q(1) + for j in range(1, 19): + term *= x / j + total += term + tail = term * x / 19 / (1 - x / 20) + return total, total + tail + + +def H(rank, b): + """Enclosure of H_r(b) = r*(73/r)^b (the moment of one rank-r child times 73).""" + l, h = logarithm(Q(M_BASE, rank)) + return rank * exponential(b * l)[0], rank * exponential(b * h)[1] + + +def moment(profile, b, W): + """Enclosure of sum_r count_r * r * (73/r)^b / (73*W); counts may be Fractions (>=0).""" + lo = hi = Q(0) + for rank, count in profile.items(): + if count == 0: + continue + need(0 < rank < M_BASE and count > 0, 'child profile') + e0, e1 = H(rank, b) + lo += Q(count) * e0 / (M_BASE * W) + hi += Q(count) * e1 / (M_BASE * W) + return Q((lo * SCALE).__floor__(), SCALE), Q((hi * SCALE).__ceil__(), SCALE) + + +def normalize(profile): + out = {} + for r, n in profile.items(): + r = int(r) + n = Q(n) if not isinstance(n, int) else n + if n: + out[r] = out.get(r, 0) + n + return out + + +def rank_mass(profile): + return sum(r * Q(n) for r, n in normalize(profile).items()) + + +def root_bracket(profile, W, digits=25, check_mass_T=None): + """Bisection on the grid 10^-digits: returns (lo, hi) with M(lo) < 1 < M(hi) certified.""" + profile = normalize(profile) + if check_mass_T is not None: + need(rank_mass(profile) == MASS_PER_REPLICA * check_mass_T, 'rank-mass identity (incomplete profile?)') + G = 10 ** digits + low, high = 0, G // 100 + need(moment(profile, Q(low, G), W)[1] < 1 < moment(profile, Q(high, G), W)[0], 'root initial interval') + while high - low > 1: + mid = (low + high) // 2 + a, b = moment(profile, Q(mid, G), W) + if b < 1: + low = mid + elif a > 1: + high = mid + else: + raise ValueError('root interval precision exhausted at %d digits' % digits) + return Q(low, G), Q(high, G) + + +def kappa_from_profile(profile, T, digits=25, strict_mass=True): + """Exact bracket of the complex endpoint for a complete global profile of a T-replica network.""" + return root_bracket(profile, LIVE_PER_REPLICA * T, digits, T if strict_mass else None) + + +def add_profiles(a, b, scale_b=1): + out = dict(normalize(a)) + for r, n in normalize(b).items(): + out[r] = out.get(r, 0) + scale_b * n + need(out[r] >= 0, 'negative count at rank %d' % r) + if out[r] == 0: + del out[r] + return out + + +def delta_value(profile, T, delta, digits=25, strict_mass=True): + """Value (exact root brackets) of changing the complete profile by delta = {rank: +-count}.""" + base = kappa_from_profile(profile, T, digits, strict_mass) + newp = add_profiles(profile, delta) + mass_ok = rank_mass(newp) == MASS_PER_REPLICA * T + new = kappa_from_profile(newp, T, digits, strict_mass and mass_ok) + return dict(base_lower=str(base[0]), base_upper=str(base[1]), new_lower=str(new[0]), new_upper=str(new[1]), + gain_lower=str(new[0] - base[1]), gain_upper=str(new[1] - base[0]), + gain_float=float((new[0] + new[1] - base[0] - base[1]) / 2), new_profile={str(r): str(n) for r, n in sorted(newp.items())}, + new_rank_mass_identity=mass_ok, note=None if mass_ok else 'delta breaks the rank-mass identity: a derivative probe, not a complete legal profile (a legal word change moves local mass and inventory/idle mass together)') + + +def derivatives(profile, T, b=None): + """dkappa/dcount_r (per single child of rank r) by the implicit function theorem, mpmath 40 digits.""" + import mpmath + mpmath.mp.dps = 40 + profile = normalize(profile) + W = LIVE_PER_REPLICA * T + if b is None: + lo, hi = kappa_from_profile(profile, T, strict_mass=False) + b = (lo + hi) / 2 + b = mpmath.mpf(b.numerator) / b.denominator + dMdb = mpmath.mpf(0) + for r, n in profile.items(): + dMdb += mpmath.mpf(n) * r * mpmath.power(mpmath.mpf(M_BASE) / r, b) * mpmath.log(mpmath.mpf(M_BASE) / r) / (M_BASE * W) + out = {} + for r in range(1, M_BASE): + dMdn = r * mpmath.power(mpmath.mpf(M_BASE) / r, b) / (M_BASE * W) + out[r] = -dMdn / dMdb + return out, b + + +def fmt(x, nd=28): + return mpmath_str(x, nd) + + +def mpmath_str(x, nd): + import mpmath + mpmath.mp.dps = nd + 5 + return mpmath.nstr(mpmath.mpf(x.numerator) / x.denominator if isinstance(x, Q) else x, nd) + + +CALIBRATION = { + 'PR2857': dict(T=37, profile={1: 805860, 2: 213786, 3: 91775, 4: 42624, 5: 13098, 8: 2664, 9: 1, 48: 13379}, + expected_lower='17200966286848326009728/10000000000000000000000000', + expected_upper='17200966286848326009729/10000000000000000000000000', + headline='0.001720096628684832600972 - 1e-46 - 1e-70 (CLAIM.json)'), + 'PR2853': dict(T=74, profile={1: 1616713, 2: 424908, 3: 183207, 4: 85249, 5: 26625, 6: 58, 7: 3, 8: 5328, 32: 47, 48: 26703}, + headline='0.00171937765869758665904733841726077218140089564514 (outer/OUTER-CLAIM.json, = C - 1e-3046 - 1e-3022)'), + 'PR2833': dict(T=74, profile={1: 1603728, 2: 432900, 3: 183683, 4: 85248, 5: 26862, 8: 5328, 9: 1, 48: 26625}, + headline='0.00171865743716685595569345761432428040996497469293 (outer/OUTER-CLAIM.json)'), +} + + +def calibrate(digits=25): + results = {} + for name, c in CALIBRATION.items(): + lo, hi = kappa_from_profile(c['profile'], c['T'], digits) + row = dict(T=c['T'], profile=c['profile'], lower=str(lo), upper=str(hi), lower_decimal=mpmath_str(lo, digits), + upper_decimal=mpmath_str(hi, digits), headline=c['headline'], rank_mass=str(rank_mass(c['profile']))) + if 'expected_lower' in c: + row['reproduces_package_bracket'] = (lo == Q(c['expected_lower']) and hi == Q(c['expected_upper'])) + else: + head = c['headline'].split(' ')[0] + row['headline_inside_bracket'] = (Q(head) >= lo - Q(1, 10 ** 22)) and (Q(head) <= hi) + dec = mpmath_str(lo, digits) + k = 0 + while k < min(len(dec), len(head)) and dec[k] == head[k]: + k += 1 + row['matches_headline_to_digits'] = k - 2 # decimals in common ('0.' excluded) + results[name] = row + return results + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument('--calibrate', action='store_true') + ap.add_argument('--profile', help='JSON {rank: count}') + ap.add_argument('--profile-file') + ap.add_argument('--T', type=int, default=37) + ap.add_argument('--delta', help='JSON {rank: +-count} (complete-profile change, e.g. 9*T per-call units)') + ap.add_argument('--per-call-delta', help='JSON {rank: +-count per call}; multiplied by 9*T') + ap.add_argument('--digits', type=int, default=25) + ap.add_argument('--table', action='store_true', help='print per-rank derivative table') + ap.add_argument('--no-mass-check', action='store_true') + a = ap.parse_args() + if a.calibrate: + print(json.dumps(calibrate(a.digits), indent=1, sort_keys=True)) + return + profile = json.loads(a.profile) if a.profile else json.load(open(a.profile_file)) + profile = {int(k): (int(v) if str(v).lstrip('-').isdigit() else Q(v)) for k, v in profile.items()} + strict = not a.no_mass_check + lo, hi = kappa_from_profile(profile, a.T, a.digits, strict) + out = dict(T=a.T, W=LIVE_PER_REPLICA * a.T, lower=str(lo), upper=str(hi), lower_decimal=mpmath_str(lo, a.digits), + rank_mass=str(rank_mass(profile))) + if a.delta or a.per_call_delta: + d = {int(k): int(v) for k, v in json.loads(a.delta or a.per_call_delta).items()} + if a.per_call_delta: + d = {k: v * CALLS_PER_REPLICA * a.T for k, v in d.items()} + out['delta'] = delta_value(profile, a.T, d, a.digits, strict) + if a.table: + der, b = derivatives(profile, a.T) + out['derivative_per_child'] = {str(r): mpmath_str(v, 12) for r, v in der.items() if r in profile or r <= 9 or r == 48} + out['derivative_per_call_unit'] = {str(r): mpmath_str(v * CALLS_PER_REPLICA * a.T, 12) for r, v in der.items() if r in profile or r <= 9 or r == 48} + print(json.dumps(out, indent=1, sort_keys=True)) + + +if __name__ == '__main__': + main() diff --git a/research/paired-extension-cap-fill/vendor/preload_move.py b/research/paired-extension-cap-fill/vendor/preload_move.py new file mode 100644 index 0000000000..55b435035b --- /dev/null +++ b/research/paired-extension-cap-fill/vendor/preload_move.py @@ -0,0 +1,133 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Declared preload-move stage: two more staged quartets on the PR2857 shared-kernel words. + +Preload re-synthesis (quartets (456,457,466,467) and (458,459,464,465)) by Jeremy Kothe +(jeremykothe2), with AI assistance; the staged-kernel gate shapes, frame/inverse-cleanup +conventions and the dirt-entry supplier are credited in CREDITS.md (PR2857 Lyy-iiis, PR2863 +Dugongue, PR2833 Jeremy Kothe, PR2853 philippeVV). + +apply(word, patch) takes the decoded PR2857 shared-kernel word and a DECLARED patch input +that lists every changed gate. Every listed old gate must be present at its index, no +other gate may change, the changed sections are limited to +{A, B, compensation, start_extra, report, cleanup}, the frame/paid profile and width +inventory are re-derived exactly from the changed word and must equal the declaration, and +the inverse-reverse cleanup is re-derived. The inherited exact auditor (forward and dual +free-operator replay over every input column) is the separate semantic check. +No file, import, process or output is touched by apply(). +""" +import copy, hashlib, json +from collections import Counter + +SOURCE_CANONICAL = { + 'base': 'c0af0ef7ee6282e91f046d027983b35eaed7ebcb46489134d47e07724cf664bc', + 'extra': '61b20fbe78fdcbca0cde0597befcc254017ee206dad0724c576672aca690c66f', +} +ALLOWED_SECTIONS = {'A', 'B', 'compensation', 'start_extra', 'report', 'cleanup'} + +def require(ok, reason): + if not ok:raise ValueError(str(reason)) + +def canon(w):return hashlib.sha256(json.dumps(w,sort_keys=True,separators=(',',':')).encode()).hexdigest() + +def basis(vs): + piv={} + for a in vs: + while a: + bit=a.bit_length()-1 + if bit in piv:a^=piv[bit] + else:piv[bit]=a;break + for k in sorted(piv): + for j in piv: + if j>k and piv[j]>>k&1:piv[j]^=piv[k] + return tuple(piv[k] for k in sorted(piv,reverse=True)) + +def contained(a,b):return basis(a+b)==b + +def restored_of(w): + n=2*w['report']['v']+w['report']['R'] + return {g[1]-n for g in w['cleanup'] if g[1]>=n}|{g[2]-n for g in w['cleanup'] if g[0]=='add' and g[2]>=n} + +def derive_cleanup(w,restored): + v=w['report']['v'];n=2*v+w['report']['R'];full=list(basis([1<=224) + return {str(k):v for k,v in sorted(paid.items())},{str(k):v for k,v in sorted(inv.items())} + +def apply(word, patch): + """Return (changed word, ledger). Authenticates the decoded source first.""" + require(patch.get('stage')=='preload-move','stage tag') + digest=canon(word);require(digest==patch['source_canonical_sha256'],'source canonical hash differs from the declared source') + require(patch['variant'] in SOURCE_CANONICAL and SOURCE_CANONICAL[patch['variant']]==digest,'unauthorized decoded source SHA256') + x=copy.deepcopy(word) + # A: replacements and insertions, both addressed by index in the SOURCE A (before any edit). + ops=patch['A_edits'];seen=set();byp={};repl={} + for e in ops: + if e['op']=='replace': + i=e['index'];require(i not in seen and i not in repl,('duplicate A replace',i));require(word['A'][i]==e['old'],('A old gate mismatch',i,word['A'][i]));repl[i]=e['new'] + else: + require(e['op']=='insert' and 0<=e['before']<=len(word['A']),'A edit op');byp.setdefault(e['before'],[]).append(e['gate']) + A=[] + for p in range(len(word['A'])+1): + A.extend(copy.deepcopy(g) for g in byp.get(p,[])) + if p