From 9f33bee7ee94cbfb316107492a9a2887aa04c3ee Mon Sep 17 00:00:00 2001 From: Cinna Davis Date: Sun, 18 Oct 2026 21:30:22 -0500 Subject: [PATCH] Research: bound PR1154 packing headroom --- research/pr1154-packing-relaxation/README.md | 99 +++++++++ .../pr1154-packing-relaxation/RESULT.json | 94 ++++++++ .../pr1154-packing-relaxation/SOURCES.json | 66 ++++++ research/pr1154-packing-relaxation/TASK.json | 72 ++++++ .../pr1154-packing-relaxation/VERIFY.json | 28 +++ research/pr1154-packing-relaxation/verify.py | 209 ++++++++++++++++++ 6 files changed, 568 insertions(+) create mode 100644 research/pr1154-packing-relaxation/README.md create mode 100644 research/pr1154-packing-relaxation/RESULT.json create mode 100644 research/pr1154-packing-relaxation/SOURCES.json create mode 100644 research/pr1154-packing-relaxation/TASK.json create mode 100644 research/pr1154-packing-relaxation/VERIFY.json create mode 100644 research/pr1154-packing-relaxation/verify.py diff --git a/research/pr1154-packing-relaxation/README.md b/research/pr1154-packing-relaxation/README.md new file mode 100644 index 0000000000..39ccfd94f0 --- /dev/null +++ b/research/pr1154-packing-relaxation/README.md @@ -0,0 +1,99 @@ +# PR1154 adaptive T16 word: packing relaxation + +## Question and result + +Does the fixed aggregate paid profile in the merged PR1154 adaptive rank-seven +T16 construction still have room under the standard nine-stage complex packing +relaxation? The profile is named and source-pinned; this is a different word +from the selected PR1094 word and from the staged544 supplier in PR3815. + +The answer is yes, but the remaining headroom is small. From PR1154's frozen +owner-audit receipt, subtracting its idle histogram from the complete profile +gives the following average local paid profile over 144 calls: + +```text +H1=42949/18, H2=8135/18, H3=15623/36, +H4=4753/36, H5=82, H8=8 +``` + +Applying `research/complex-local-word-ceiling/ceiling.py::ceiling()` with +`m=73`, `families=896`, `stages=9`, `centre=64`, and grid `10^-15` brackets +the relaxed complex saving root by + +```text +421850048701/250000000000000 <= a* <= 337480038961/200000000000000. +``` + +Thus the retained transfer gives the PR1154 word a packing cap +`kappa <= a*/(1+a*) <= 0.001684557671861340916...`. Its source-reported +`kappa=0.001673260706543984` realizes 99.3293809% of the cap. This is an +upper bound from a fractional idle relaxation, not an attained packing optimum +or a supplier-admission result. + +## Derivation and scope + +The source receipt gives the complete rank profile +`{1:344363,2:65097,3:62855,4:19012,5:11808,7:8,8:1152,11:2,48:4873}` and +idle profile `{1:771,2:17,3:363,7:8,11:2,48:4873}`. Their difference is the +aggregate local profile. Rank mass is 1,041,408, exactly `72*14336 + 64*144`; +the idle mass is 58,969/36 per call and the local mass is 201,383/36 per call. +The outer halving guard permits idle rank at most 51. + +The ceiling proof uses only aggregate local counts. Even though PR1154 selects +different local prefixes on different calls, their moment contributions add. +For each `a >= 0`, the cost per unit of idle rank, +`(r/73)^(1-a)/r`, is non-increasing in `r`; therefore every idle histogram +with rank at most 51 costs at least the fractional placement of all remaining +mass at rank 51. The exact interval engine certifies the two sides of the root +bracket. This covers every repacking of PR1154's fixed aggregate local profile +under this coverage law and guard. It does not cover changes to the local word, +port count, coverage law, template, centre charge, or outer recipe. + +The candidate's exact complex saving in `expected/EXACT-PRICE.json` is +`1676065200585730447963/10^24`, below the ceiling. Its required saving for the +reported kappa is `104578794158999/62395421205841001`. The selected bit +supplier's source-bound saving remains +`1733427039589844234749/10^24`, above that requirement, so the complex side +still binds for this comparison. The selected-record baseline is a bindings +and arithmetic check only. + +PR1154 remains a partially reviewed archive. Its whole-head native/provider, +physical-owner, and complete-admission obligations were not rerun here. The +source `OWNER-AUDIT.json` and exact-price receipt are hash-checked and their +profile arithmetic is reconstructed; their underlying owner/native replay is +not independently reproduced by this package. No kappa is selected or +promoted. + +## Reproduce + +From the repository root: + +```sh +python3 -B research/pr1154-packing-relaxation/verify.py --write +python3 scripts/research_package.py --package research/pr1154-packing-relaxation --check-only +python3 scripts/research_package.py --package research/pr1154-packing-relaxation +``` + +The first command regenerates `RESULT.json`; the default verifier checks it. +The calculation uses Python's standard library and the pinned ceiling module. +The registered hook checks input hashes, the coverage identity, rank split, +exact interval endpoints, the candidate and bit-side comparison, and three +failure controls. It does not run PR1154's full replay. + +## Open next questions + +Can an independent source-level reconstruction of PR1154's adaptive local +profiles and idle histogram reproduce the hash-pinned owner-audit receipt? +This matters because the present cap trusts that receipt as its input. The +first step is to run `research/adaptive-kernel-demotion/audit_owner_table.py` +against its frozen inputs in a separately budgeted audit. Its remaining blocker +is the inherited native/provider and complete supplier-admission chain. + +## Credit + +PR1154 was contributed by Dugongue, building on PR1117, PR1111, and the +retained T16 supplier lineage. The packing-ceiling lemma and exact interval +engine come from `research/complex-local-word-ceiling/`, credited there to +Douglas Colkitt with Claude assistance. This scoped application was prepared +with OpenAI Codex assistance. The source construction retains its Apache-2.0 +license and notices; this new result is Apache-2.0. diff --git a/research/pr1154-packing-relaxation/RESULT.json b/research/pr1154-packing-relaxation/RESULT.json new file mode 100644 index 0000000000..0a9d59fc9b --- /dev/null +++ b/research/pr1154-packing-relaxation/RESULT.json @@ -0,0 +1,94 @@ +{ + "controls": { + "idle_rank_52": "rejected", + "local_profile_mass_over_coverage": "rejected", + "one_rank_unit_added_to_complete_profile": "rejected" + }, + "limits": [ + "The hash-pinned PR1154 owner-audit and exact-price receipts are inputs; their underlying owner/native replay was not independently reproduced.", + "PR1154 remains partially reviewed and is not a selected supplier.", + "The selected bit value is source-bound by the selected certificate; the full bit circuit was not replayed in this session." + ], + "model": { + "calls": 144, + "centre": 64, + "coverage_identity": "rank_mass = 72*live_stock + 64*calls", + "deficit": 5120, + "families": 896, + "idle_rank_cap": 51, + "live_stock": 14336, + "m": 73, + "rank_mass": "1041408", + "stages": 9 + }, + "packing_cap": { + "a_lower": "421850048701/250000000000000", + "a_root_lower_relaxation": [ + "115792089237316018834055606565245307022430145434682530476350785458923278827839/115792089237316195423570985008687907853269984665640564039457584007913129639936", + "28948022309329004708513901641311326755607536358670632619087696364730819706969/28948022309329048855892746252171976963317496166410141009864396001978282409984" + ], + "a_root_upper_relaxation": [ + "57896044618658177796543724602433634590596981195715896928494734661634808457269/57896044618658097711785492504343953926634992332820282019728792003956564819968", + "115792089237316355593087449204867269181193962391431793856989469323269616914575/115792089237316195423570985008687907853269984665640564039457584007913129639936" + ], + "a_upper": "337480038961/200000000000000", + "a_upper_decimal": "0.001687400194805000", + "candidate_a_fraction_realized": "1676065200585730447963/1687400194805000000000", + "candidate_a_fraction_realized_decimal": "0.993282569094061618", + "candidate_kappa_fraction_of_cap": "20951052087327073381748760039/21092502435062500000000000000", + "candidate_kappa_fraction_of_cap_decimal": "0.993293809107245103", + "kappa_upper": "337480038961/200337480038961", + "kappa_upper_decimal": "0.001684557671861340" + }, + "profiles": { + "complete": { + "1": 344363, + "11": 2, + "2": 65097, + "3": 62855, + "4": 19012, + "48": 4873, + "5": 11808, + "7": 8, + "8": 1152 + }, + "idle": { + "1": 771, + "11": 2, + "2": 17, + "3": 363, + "48": 4873, + "7": 8 + }, + "idle_mass_per_call": "58969/36", + "local_mass_per_call": "201383/36", + "local_per_call": { + "1": "42949/18", + "2": "8135/18", + "3": "15623/36", + "4": "4753/36", + "5": "82", + "8": "8" + } + }, + "scope": "Upper bound for all repackings of PR1154's fixed aggregate local profile under the 73-rank, 896-family, nine-stage, centre-64 coverage model and rank-51 halving guard. Fractional idle placement is allowed. Not an attained optimum, supplier admission, or bound for changed words or models.", + "source": { + "merge_commit": "998a33b0df8af40aa672c72585c61ad7e1bbe701", + "pr": 1154, + "pr_head": "390de2866a03758e7f4ddbb2846e5b2ee4e72154", + "selected_kappa": "836330098538459/500000000000000000", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129", + "supplier_source_head": "342b67f23dfa8f41a520a0d58978b2875e9eb0dd", + "task_base": "20ecf2891d80b5acf18d980b2164fb44ea7faa90" + }, + "status": "PASS_PR1154_AGGREGATE_PACKING_RELAXATION", + "supplier_comparison": { + "candidate_complex_a_lower": "1676065200585730447963/1000000000000000000000000", + "candidate_kappa": "104578794158999/62500000000000000", + "candidate_kappa_decimal": "0.001673260706543984", + "candidate_required_a": "104578794158999/62395421205841001", + "complex_side_binds_for_this_comparison": true, + "selected_bit_a_lower": "1733427039589844234749/1000000000000000000000000", + "selected_bit_margin_over_candidate_required_a": "3579116105803355341226851043813143749/62395421205841001000000000000000000000000" + } +} diff --git a/research/pr1154-packing-relaxation/SOURCES.json b/research/pr1154-packing-relaxation/SOURCES.json new file mode 100644 index 0000000000..ea5131fdeb --- /dev/null +++ b/research/pr1154-packing-relaxation/SOURCES.json @@ -0,0 +1,66 @@ +{ + "schema_version": 1, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "input", + "git_blob": "b1fea0c94436b236cc2b7d41a7be032811b94c81", + "sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "path": "research/community-frontier1094-audit/ASSEMBLY.json", + "usage": "input", + "git_blob": "5fd676df060f3b450782fdf5ff5f6beb63a5eeb0", + "sha256": "1122cb3a575f8c788345fc1bf4c108ac7c3250fb81a5988671f5eb04b3ab3045" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "67f085acd86acd7d4e03922d9cf4b26bca66fed5", + "sha256": "47b42433f5a85809a3aadd29c2c339da2c6ed728e4f7762df6b88bccb7874cf0" + }, + { + "path": "research/adaptive-kernel-demotion/MANIFEST.json", + "usage": "input", + "git_blob": "902eca929548ad2b56e86e9cd07e17ee14de4035", + "sha256": "500ad2de1456f788783d10fb5570db80891451d36c081a0934cfad86a853e25b" + }, + { + "path": "research/adaptive-kernel-demotion/README.md", + "usage": "input", + "git_blob": "d6180f40044ce63577618e21c227d2e8c16de1f2", + "sha256": "7731ec24896362dc45709279946c47b39a4b4e7207c826c220d85f270e0f769b" + }, + { + "path": "research/adaptive-kernel-demotion/data/SOURCE-BINDING.json", + "usage": "input", + "git_blob": "87a2d5ae89f2c5fd3cd060cf8eedc9acea02047f", + "sha256": "818b400c402ad376dcf5ddde7e97b3727c3778e66b7bc765c3f5b290dc225853" + }, + { + "path": "research/adaptive-kernel-demotion/expected/EXACT-PRICE.json", + "usage": "input", + "git_blob": "93ff6101ae1d7cfe21c8496fc74a87af23c10381", + "sha256": "3883ea5f2a3802bc13ba6b2c33ac749ad738b45bed13ae0f0fd6399d30b48a1a" + }, + { + "path": "research/adaptive-kernel-demotion/expected/OWNER-AUDIT.json", + "usage": "input", + "git_blob": "0a5bb027b42c5280cca336acf8b253f9ed5343c8", + "sha256": "e7dc4874fa7d671765caab0f747519e2fd9f3f821a5daf58bba9b3a34f276ed9" + }, + { + "path": "research/complex-local-word-ceiling/README.md", + "usage": "input", + "git_blob": "f5f742f8196da29d2c3f4dffb3c27685ca9401f6", + "sha256": "b60be039cb0e03e064a27407d0bce9e58908d793da5ee405c876de5aebfa5f81" + }, + { + "path": "research/complex-local-word-ceiling/ceiling.py", + "usage": "input", + "git_blob": "6c0f54527d879396f689523bfde19928a9b6157c", + "sha256": "86a1432870b3b21d8454106ec9162fddc0471472d9214c590a1420f2426cedfc" + } + ] +} diff --git a/research/pr1154-packing-relaxation/TASK.json b/research/pr1154-packing-relaxation/TASK.json new file mode 100644 index 0000000000..b323921396 --- /dev/null +++ b/research/pr1154-packing-relaxation/TASK.json @@ -0,0 +1,72 @@ +{ + "schema_version": 1, + "task_id": "selected-packing", + "priority_revision": 6, + "base_commit": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "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" + ], + "existing_checks": [ + { + "scope": "Packing-independent ceiling for the selected paid profile under the one-unpaid-coordinate coverage and halving guard.", + "evidence": "docs/research/community-efficient1000-review.md", + "remaining": "A changed word or model requires new pricing; a local packing search must name uncovered scope.", + "status": "reviewed", + "source_commit": "836b19bfa309ceafbc8ee32a15e8c4b10dde7e11", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + } + ] + }, + "scope_status": "changed", + "actual_scope": "For PR1154's fixed adaptive rank-seven T16 word, derive the aggregate local paid profile from its frozen complete and idle histograms and certify the remaining nine-stage packing cap under the one-unpaid-coordinate law and rank-51 halving guard.", + "scope_change_reason": "The selected PR1094 word and recent staged544/T488 packing scopes already have direct current coverage. PR1154 is a named alternate local word; the live queue ceiling census explicitly left it unscreened, and no current #1166 claim matched this aggregate-profile bound.", + "bottleneck_link": "This prices the complex-side headroom of a named candidate against the unchanged selected bit-side saving. It can reject further packing-only effort for this word if its ceiling is exhausted; it does not admit the candidate.", + "budget_minutes": 60, + "stop_rule": "Stop if the source profile split fails its mass identity, if the source call count does not match 896/9 live families per call, or if the rank-51 halving guard is not valid. Do not extend to another word in this session.", + "outcome": "partial", + "evidence": "research/pr1154-packing-relaxation/RESULT.json certifies the aggregate PR1154 relaxation bracket and compares its cap with the source-reported candidate kappa and the selected bit-side lower saving. Exact inputs and the ceiling engine are pinned in SOURCES.json.", + "author": "macbook-16 Codex agent", + "ai_assistance": "OpenAI Codex assistance for source inspection, exact derivation, verifier and report.", + "open_questions": [ + { + "question": "Can an independent source-level reconstruction of PR1154's adaptive local profiles and idle histogram reproduce its hash-pinned owner-audit receipt?", + "why_it_matters": "The packing ceiling uses that receipt as its fixed aggregate input; an independent reconstruction would check the receipt boundary without expanding the word search.", + "first_step": "Run research/adaptive-kernel-demotion/audit_owner_table.py against its frozen inputs and compare the complete and idle histograms with expected/OWNER-AUDIT.json.", + "blocked_by": "A full supplier-admission review still needs the inherited native/provider and complete physical-owner chain; this session did not rerun that chain." + } + ] +} diff --git a/research/pr1154-packing-relaxation/VERIFY.json b/research/pr1154-packing-relaxation/VERIFY.json new file mode 100644 index 0000000000..a8498d4781 --- /dev/null +++ b/research/pr1154-packing-relaxation/VERIFY.json @@ -0,0 +1,28 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "certificates/selected-result.json", + "research/adaptive-kernel-demotion/MANIFEST.json", + "research/adaptive-kernel-demotion/README.md", + "research/adaptive-kernel-demotion/data/SOURCE-BINDING.json", + "research/adaptive-kernel-demotion/expected/EXACT-PRICE.json", + "research/adaptive-kernel-demotion/expected/OWNER-AUDIT.json", + "research/complex-local-word-ceiling/README.md", + "research/complex-local-word-ceiling/ceiling.py", + "research/community-frontier1094-audit/ASSEMBLY.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Source pins; profile split, mass identity, halving guard; exact ceiling bracket; both-supplier comparison; three rejected mutations." + } + ] +} diff --git a/research/pr1154-packing-relaxation/verify.py b/research/pr1154-packing-relaxation/verify.py new file mode 100644 index 0000000000..09a45e9338 --- /dev/null +++ b/research/pr1154-packing-relaxation/verify.py @@ -0,0 +1,209 @@ +#!/usr/bin/env python3 +"""Verify the PR1154 aggregate-profile packing relaxation. Apache-2.0.""" +from fractions import Fraction as Q +from hashlib import sha256 +import json +from pathlib import Path +import sys + +ROOT = Path(__file__).resolve().parents[2] +HERE = Path(__file__).resolve().parent +SOURCE = ROOT / "research/adaptive-kernel-demotion" +sys.path.insert(0, str(ROOT / "research/complex-local-word-ceiling")) +import ceiling as C # noqa: E402 + +M, FAMILIES, STAGES, CENTRE = 73, 896, 9, 64 +GRID = Q(1, 10**15) +SELECTED_RECORD_SHA256 = "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" +CEILING_SHA256 = "86a1432870b3b21d8454106ec9162fddc0471472d9214c590a1420f2426cedfc" +SOURCE_HEAD = "342b67f23dfa8f41a520a0d58978b2875e9eb0dd" +MANIFEST_INPUTS = ( + "expected/OWNER-AUDIT.json", + "expected/EXACT-PRICE.json", + "data/SOURCE-BINDING.json", +) + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def json_file(path): + return json.loads(path.read_text()) + + +def digest(path): + return sha256(path.read_bytes()).hexdigest() + + +def derive_local(full, idle, calls, live): + R = C.max_idle_rank(M) + require(calls > 0 and live > 0, "positive calls and live stock") + require(all(r > 0 and n >= 0 for r, n in full.items()), "complete profile domain") + require(all(r > 0 and n >= 0 for r, n in idle.items()), "idle profile domain") + require(all(r <= R for r in idle), "idle rank exceeds halving guard") + require(all(idle.get(r, 0) <= n for r, n in full.items()), "idle profile not contained in complete profile") + require(all(r in full for r in idle), "idle rank absent from complete profile") + expected_mass = (M - 1) * live + CENTRE * calls + observed_mass = sum(r * n for r, n in full.items()) + require(observed_mass == expected_mass, "complete profile violates coverage identity") + local_counts = {r: n - idle.get(r, 0) for r, n in full.items()} + require(sum(r * n for r, n in local_counts.items()) + sum(r * n for r, n in idle.items()) == expected_mass, + "local and idle rank mass do not reconstruct complete profile") + return {r: Q(n, calls) for r, n in local_counts.items() if n} + + +def expect_reject(fn, label): + try: + fn() + except ValueError: + return "rejected" + raise ValueError("failure control accepted: " + label) + + +def decimal(q, digits=18): + q = Q(q) + scale = 10**digits + n = (abs(q.numerator) * scale) // q.denominator + sign = "-" if q < 0 else "" + return f"{sign}{n // scale}.{n % scale:0{digits}d}" + + +def main(): + selected_raw = (ROOT / "certificates/selected-result.json").read_bytes() + record = json.loads(selected_raw) + require(sha256(selected_raw).hexdigest() == SELECTED_RECORD_SHA256, "selected record pin changed") + certificate_path = ROOT / record["certificate"] + require(digest(certificate_path) == record["certificate_sha256"], "selected certificate hash changed") + selected_certificate = json_file(certificate_path) + bit_saving = Q(selected_certificate["bit_lower"]) + + require(digest(ROOT / "research/complex-local-word-ceiling/ceiling.py") == CEILING_SHA256, + "ceiling module pin changed") + manifest = json_file(SOURCE / "MANIFEST.json") + for rel in MANIFEST_INPUTS: + require(rel in manifest and digest(SOURCE / rel) == manifest[rel], + "PR1154 manifest mismatch: " + rel) + binding = json_file(SOURCE / "data/SOURCE-BINDING.json") + require(binding["source_head"] == SOURCE_HEAD, "PR1154 source head changed") + for rel, expected in binding["files"].items(): + require(digest(SOURCE / "data" / rel) == expected, "PR1154 source binding mismatch: " + rel) + + owner = json_file(SOURCE / "expected/OWNER-AUDIT.json") + price = json_file(SOURCE / "expected/EXACT-PRICE.json") + full = {int(r): int(n) for r, n in owner["profile"].items()} + priced_full = {int(r): int(n) for r, n in price["profile"].items()} + idle = {int(r): int(n) for r, n in owner["idle_profile"].items()} + require(full == priced_full, "owner audit and exact-price profiles differ") + calls = int(owner["calls"]) + live_fraction = Q(FAMILIES * calls, STAGES) + require(live_fraction.denominator == 1, "source call count gives nonintegral live stock") + live = live_fraction.numerator + require(live == 14336, "unexpected PR1154 live stock") + require(int(owner["idle_remainders"]) == sum(idle.values()) == 6034, + "idle remainder count mismatch") + require(sum(r * n for r, n in full.items()) == int(owner["rank_mass"]), + "owner-audit rank mass mismatch") + require(int(owner["deficit"]) == M * live - sum(r * n for r, n in full.items()), + "recorded deficit mismatch") + + local = derive_local(full, idle, calls, live) + q = C.model(local, M, FAMILIES, STAGES, CENTRE) + require(q["R"] == 51, "unexpected halving-guard rank cap") + lo, hi = C.ceiling(local, M, FAMILIES, STAGES, CENTRE, grid=GRID) + lower_value = C.relax(local, M, FAMILIES, STAGES, CENTRE, lo)[1] + upper_value = C.relax(local, M, FAMILIES, STAGES, CENTRE, hi)[0] + require(lower_value < 1 < upper_value, "exact root bracket does not straddle one") + + candidate_a = Q(price["complex_lower"]) + candidate_kappa = Q(price["kappa"]) + kappa_cap = hi / (1 + hi) + required_a = candidate_kappa / (1 - candidate_kappa) + require(candidate_a < lo, "candidate complex saving not below relaxation root") + require(candidate_kappa <= candidate_a / (1 + candidate_a), + "candidate kappa is not covered by its complex saving") + require(bit_saving > required_a, "bit-side saving does not clear candidate kappa") + require(candidate_kappa < kappa_cap, "candidate kappa exceeds packing cap") + + bad_full = dict(full) + bad_full[1] += 1 + controls = { + "one_rank_unit_added_to_complete_profile": expect_reject( + lambda: derive_local(bad_full, idle, calls, live), "coverage mass"), + "idle_rank_52": expect_reject( + lambda: derive_local(full, {**idle, 52: 1}, calls, live), "halving guard"), + "local_profile_mass_over_coverage": expect_reject( + lambda: C.model({1: Q(10000)}, M, FAMILIES, STAGES, CENTRE), "local mass"), + } + + result = { + "status": "PASS_PR1154_AGGREGATE_PACKING_RELAXATION", + "source": { + "task_base": "20ecf2891d80b5acf18d980b2164fb44ea7faa90", + "pr": 1154, + "pr_head": "390de2866a03758e7f4ddbb2846e5b2ee4e72154", + "merge_commit": "998a33b0df8af40aa672c72585c61ad7e1bbe701", + "supplier_source_head": SOURCE_HEAD, + "selected_record_sha256": SELECTED_RECORD_SHA256, + "selected_kappa": record["kappa"], + }, + "model": { + "m": M, "families": FAMILIES, "stages": STAGES, "centre": CENTRE, + "calls": calls, "live_stock": live, "idle_rank_cap": q["R"], + "coverage_identity": "rank_mass = 72*live_stock + 64*calls", + "rank_mass": str(sum(r * n for r, n in full.items())), + "deficit": int(owner["deficit"]), + }, + "profiles": { + "complete": {str(r): full[r] for r in sorted(full)}, + "idle": {str(r): idle[r] for r in sorted(idle)}, + "local_per_call": {str(r): str(local[r]) for r in sorted(local)}, + "local_mass_per_call": str(q["local_mass"]), + "idle_mass_per_call": str(q["idle_mass"]), + }, + "packing_cap": { + "a_lower": str(lo), "a_upper": str(hi), + "a_upper_decimal": decimal(hi), + "kappa_upper": str(kappa_cap), + "kappa_upper_decimal": decimal(kappa_cap), + "a_root_lower_relaxation": [str(x) for x in C.relax(local, M, FAMILIES, STAGES, CENTRE, lo)], + "a_root_upper_relaxation": [str(x) for x in C.relax(local, M, FAMILIES, STAGES, CENTRE, hi)], + "candidate_a_fraction_realized": str(candidate_a / hi), + "candidate_a_fraction_realized_decimal": decimal(candidate_a / hi), + "candidate_kappa_fraction_of_cap": str(candidate_kappa / kappa_cap), + "candidate_kappa_fraction_of_cap_decimal": decimal(candidate_kappa / kappa_cap), + }, + "supplier_comparison": { + "candidate_complex_a_lower": str(candidate_a), + "candidate_kappa": str(candidate_kappa), + "candidate_kappa_decimal": price["kappa_decimal"], + "candidate_required_a": str(required_a), + "selected_bit_a_lower": str(bit_saving), + "selected_bit_margin_over_candidate_required_a": str(bit_saving - required_a), + "complex_side_binds_for_this_comparison": True, + }, + "controls": controls, + "scope": "Upper bound for all repackings of PR1154's fixed aggregate local profile under the 73-rank, 896-family, nine-stage, centre-64 coverage model and rank-51 halving guard. Fractional idle placement is allowed. Not an attained optimum, supplier admission, or bound for changed words or models.", + "limits": [ + "The hash-pinned PR1154 owner-audit and exact-price receipts are inputs; their underlying owner/native replay was not independently reproduced.", + "PR1154 remains partially reviewed and is not a selected supplier.", + "The selected bit value is source-bound by the selected certificate; the full bit circuit was not replayed in this session.", + ], + } + encoded = json.dumps(result, indent=2, sort_keys=True) + "\n" + out = HERE / "RESULT.json" + if sys.argv[1:] == ["--write"]: + out.write_text(encoded) + else: + require(out.is_file() and out.read_text() == encoded, "RESULT.json differs; run with --write") + print(result["status"], "kappa_cap", result["packing_cap"]["kappa_upper_decimal"], + "fraction_realized", result["packing_cap"]["candidate_kappa_fraction_of_cap_decimal"]) + + +if __name__ == "__main__": + try: + main() + except (KeyError, OSError, TypeError, ValueError) as exc: + print("FAIL:", exc) + sys.exit(1)