diff --git a/research/t16-rank7-provider-composition/BOUNDED-DOMAIN.md b/research/t16-rank7-provider-composition/BOUNDED-DOMAIN.md
new file mode 100644
index 0000000000..db784e2d7d
--- /dev/null
+++ b/research/t16-rank7-provider-composition/BOUNDED-DOMAIN.md
@@ -0,0 +1,17 @@
+# Omitted full-bin patterns after PR3457
+
+PR3457 optimizes a chronological dictionary containing every capacity-8 and capacity-16 pattern, but only the pooled optimum patterns at capacities 32 and 48. Its new feasible construction does not establish a chronological packing optimum.
+
+The changed domain adds precisely `[7,7,9,9]` at capacity 32 and `[7,7,7,9,9,9]` at capacity 48. A floating LP reduced-cost screen nominates eligible groups; those numerical results are discovery aids, not proof inputs. A global 90-second integer attempt produced no incumbent. A local repair keeps every other group's pattern counts and role flow fixed and frees only the nominated group plus groups currently serving the nominated calls' width-7/9 demands. One initial repair and a bounded pass over 29 further capacity-32 nominations yielded the retained literal certificate. No claim of exhaustion outside these named neighborhoods is made.
+
+The independent certificate replay checks every integer flow, actual event window, bin degree, source-derived helper width and both provider bindings. All 144 calls and 58,752 helpers remain complete. The resulting idle delta relative to PR3457 is
+
+`-229 H1 + 110 H2 + H3 - 2 H5 + 2 H8`.
+
+For `H_r = 73^a r^(1-a)`, `0= 0, "overfull pattern")
+ totals, bins, idle, seen = Counter(), Counter(), Counter(), set()
+ for g, p, n in allocation:
+ integer(g, 0, 143)
+ integer(p, 0, len(patterns) - 1)
+ integer(n, 1, 224)
+ need((g, p) not in seen, "duplicate allocation")
+ seen.add((g, p))
+ need(model.groups[g].capacity == patterns[p][0], "allocation capacity")
+ totals[p] += n
+ bins[g] += n
+ if residuals[p]:
+ idle[residuals[p]] += n
+ need(all(bins[g] == 224 for g in range(144)), "all bins allocated")
+ need(
+ [totals[p] for p in range(len(patterns))] == [p[2] for p in patterns],
+ "pattern inventory",
+ )
+ return dict(idle)
+
+
+def check_certificate(cert, model, expected):
+ need(pattern_inventory(cert, model) == expected, "attaining idle profile")
+ patterns, allocation, flow = (cert[k] for k in ("patterns", "allocation", "flow"))
+ need(len(flow) <= 30000, "flow bound")
+ demands, supplies, degrees, seen = Counter(), Counter(), Counter(), set()
+ for a, t, k, n in flow:
+ integer(a, 0, len(allocation) - 1)
+ integer(t, 0, 143)
+ integer(k, 0, 4)
+ integer(n, 1, 240)
+ need((a, t, k) not in seen, "duplicate flow")
+ seen.add((a, t, k))
+ g, _p, count = allocation[a]
+ need(t in model.groups[g].times, "flow outside window")
+ demands[t, k] += n
+ supplies[a, k] += n
+ degrees[a, t] += n
+ need(degrees[a, t] <= count, "one call exceeds pattern bin count")
+ need(
+ all(demands[t, k] == INVENTORY[k] for t in range(144) for k in range(5)),
+ "per-call demand",
+ )
+ need(
+ all(
+ supplies[a, k] == n * patterns[p][1][k]
+ for a, (_, p, n) in enumerate(allocation)
+ for k in range(5)
+ ),
+ "pattern width balance",
+ )
+
+
+def regular_graph(demands, counts, multiplicity):
+ """Make the time-to-slot multigraph regular using dummy slots and times."""
+ times = sorted(demands)
+ slots = [k for k, n in enumerate(counts) for _ in range(n)]
+ size = max(len(times), len(slots))
+ need(size <= 144, "graph vertex bound")
+ matrix = [[0] * size for _ in range(size)]
+ for k in range(5):
+ columns = [j for j, width in enumerate(slots) if width == k]
+ remaining = {j: multiplicity for j in columns}
+ for i, t in enumerate(times):
+ count = demands[t][k]
+ for j in columns:
+ amount = min(count, remaining[j])
+ matrix[i][j] += amount
+ remaining[j] -= amount
+ count -= amount
+ need(count == 0, "slot supply exhausted")
+ need(not any(remaining.values()), "unfilled real slot")
+ row_defect = [multiplicity - sum(row) for row in matrix]
+ col_defect = [multiplicity - sum(row[j] for row in matrix) for j in range(size)]
+ for i in range(size):
+ for j in range(len(slots), size):
+ amount = min(row_defect[i], col_defect[j])
+ matrix[i][j] += amount
+ row_defect[i] -= amount
+ col_defect[j] -= amount
+ need(not any(row_defect) and not any(col_defect), "regularization")
+ return matrix, times, slots
+
+
+def perfect_matching(matrix):
+ """Bounded alternating-path matching on positive support, without recursion."""
+ size = len(matrix)
+ left, right = [-1] * size, [-1] * size
+ for start in range(size):
+ queue, previous, endpoint = deque([start]), {}, None
+ for _ in range(size):
+ if not queue or endpoint is not None:
+ break
+ i = queue.popleft()
+ for j in range(size):
+ if matrix[i][j] <= 0 or j in previous:
+ continue
+ previous[j] = i
+ if right[j] == -1:
+ endpoint = j
+ break
+ queue.append(right[j])
+ need(endpoint is not None, "regular graph has no perfect matching")
+ for _ in range(size):
+ i = previous[endpoint]
+ old = left[i]
+ left[i], right[endpoint] = endpoint, i
+ if old == -1:
+ break
+ endpoint = old
+ else:
+ raise ValueError("alternating path exceeded vertex bound")
+ return left
+
+
+def colour_pattern(demands, counts, multiplicity):
+ if not any(counts):
+ return [[] for _ in range(multiplicity)]
+ matrix, times, slots = regular_graph(demands, counts, multiplicity)
+ bins = []
+ for _ in range(multiplicity):
+ if len(bins) == multiplicity:
+ break
+ match = perfect_matching(matrix)
+ amount = min(matrix[i][j] for i, j in enumerate(match))
+ values = sorted(
+ (times[i], slots[j]) for i, j in enumerate(match) if j < len(slots)
+ )
+ need(len({t for t, _ in values}) == len(values), "repeated time in colour")
+ bins.extend([values] * amount)
+ for i, j in enumerate(match):
+ matrix[i][j] -= amount
+ need(
+ len(bins) == multiplicity and not any(any(row) for row in matrix),
+ "colour exhaustion",
+ )
+ return bins
+
+
+def expand(cert, model):
+ demands = defaultdict(lambda: defaultdict(lambda: [0] * 5))
+ for a, t, k, n in cert["flow"]:
+ demands[a][t][k] = n
+ available = {
+ (t, k): deque(h for h, w in enumerate(values) if w == width)
+ for t, values in enumerate(model.widths)
+ for k, width in enumerate(WIDTHS)
+ }
+ rows, used = [], Counter()
+ for a, (g, p, n) in enumerate(cert["allocation"]):
+ coloured = colour_pattern(demands[a], cert["patterns"][p][1], n)
+ for values in coloured:
+ owner, child = model.groups[g].keys[used[g] // 112]
+ port = used[g] % 112
+ used[g] += 1
+ offset = 0
+ for t, k in values:
+ need(bool(available[t, k]), "literal helper shortage")
+ rows.append(
+ (
+ t,
+ available[t, k].popleft(),
+ owner,
+ child,
+ port,
+ offset,
+ WIDTHS[k],
+ )
+ )
+ offset += WIDTHS[k]
+ need(all(not q for q in available.values()), "unassigned helper")
+ return sorted(rows)
+
+
+def check_rows(rows, model):
+ need(len(rows) == 69120, "literal helper count")
+ seen, families, bins = set(), set(), defaultdict(list)
+ for t, h, owner, child, port, offset, width in rows:
+ integer(t, 0, 143)
+ integer(h, 0, 479)
+ integer(owner, 0, 15)
+ integer(child, 0, 17)
+ integer(port, 0, 111)
+ integer(offset, 0, 48)
+ need((t, h) not in seen, "duplicate literal helper")
+ seen.add((t, h))
+ need(type(width) is int and width == model.widths[t][h], "literal width")
+ need((owner, child) in model.windows, "literal owner")
+ need(t in model.windows[owner, child][1], "literal window")
+ f = family(model, owner, child, port)
+ need((t, f) not in families, "two helpers on one family in one call")
+ families.add((t, f))
+ stage, replica = model.calls[t]
+ need(
+ owner != replica or model.pairs[child] != max(0, (stage - 1) // 2),
+ "literal active data pair",
+ )
+ bins[owner, child, port].append((offset, width))
+ idle = Counter()
+ for (owner, child), (capacity, _) in model.windows.items():
+ for port in range(112):
+ used = 0
+ for offset, width in sorted(bins[owner, child, port]):
+ need(offset == used, "literal overlap or prefix gap")
+ used += width
+ need(used <= capacity, "literal overfull bin")
+ if used < capacity:
+ idle[capacity - used] += 1
+ return dict(sorted(idle.items()))
+
+
+def verify(root=ROOT, certificate=None):
+ model = source_model(*sources(root))
+ check_geometry(model)
+ cert = read_json(HERE / "CERTIFICATE.json") if certificate is None else certificate
+ need(
+ cert["schema_version"] == 1 and set(cert["profiles"]) == set(EXPECTED), "schema"
+ )
+ result = {}
+ for name, expected in EXPECTED.items():
+ profile = cert["profiles"][name]
+ check_certificate(profile, model, expected)
+ rows = expand(profile, model)
+ idle = check_rows(rows, model)
+ need(idle == expected, "literal profile")
+ digest = hashlib.sha256(
+ json.dumps(rows, separators=(",", ":")).encode()
+ ).hexdigest()
+ result[name] = {
+ "idle": {str(r): n for r, n in idle.items()},
+ "helpers": len(rows),
+ "assignment_sha256": digest,
+ "pattern_flow_rows": len(profile["flow"]),
+ }
+ return {
+ "schema_version": 1,
+ "calls": 144,
+ "bins": 32256,
+ "profiles": result,
+ "one_helper_per_family_per_call": True,
+ "active_data_pairs_excluded": True,
+ "scope": "Finite hosting on supplied selected windows; no complete physical admission.",
+ }
+
+
+def export_owners(output, model, certificate):
+ output = output.resolve()
+ need(not output.is_relative_to(ROOT), "owner output must be outside the checkout")
+ output.mkdir(parents=True, exist_ok=False)
+ for name, profile in certificate["profiles"].items():
+ rows = expand(profile, model)
+ need(check_rows(rows, model) == EXPECTED[name], "exported owner profile")
+ owners = []
+ for t, h, owner, child, port, offset, width in rows:
+ stage, replica = model.calls[t]
+ owners.append(
+ {
+ "time": t,
+ "helper": h,
+ "stage": stage,
+ "replica": replica,
+ "owner_replica": owner,
+ "child": child,
+ "port": port,
+ "offset": offset,
+ "width": width,
+ "copy": owner * 112 + port,
+ "family": family(model, owner, child, port),
+ }
+ )
+ data = json.dumps(owners, sort_keys=True, separators=(",", ":")).encode()
+ (output / f"OWNERS-{name}.json.gz").write_bytes(gzip.compress(data, mtime=0))
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--root", type=Path, default=ROOT)
+ parser.add_argument("--certificate", type=Path, default=HERE / "CERTIFICATE.json")
+ parser.add_argument(
+ "--owners-dir", type=Path, help="New external directory for literal owner maps"
+ )
+ parser.add_argument("--write", action="store_true")
+ args = parser.parse_args()
+ certificate = read_json(args.certificate)
+ result = verify(args.root, certificate)
+ if args.write:
+ (HERE / "RESULT.json").write_text(json.dumps(result, indent=2) + "\n")
+ else:
+ need(result == read_json(HERE / "RESULT.json"), "complete receipt equality")
+ if args.owners_dir is not None:
+ export_owners(args.owners_dir, source_model(*sources(args.root)), certificate)
+ print("PASS_T16_DISTINCT_CALL_ATTAINMENT", json.dumps(result, sort_keys=True))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/research/t16-rank7-provider-composition/PROOF.md b/research/t16-rank7-provider-composition/PROOF.md
new file mode 100644
index 0000000000..b84c1bbd8e
--- /dev/null
+++ b/research/t16-rank7-provider-composition/PROOF.md
@@ -0,0 +1,33 @@
+# Literal allocation argument
+
+The source-bound frame replay of each of the two words yields the same ordered 408 helper widths and the same local profile. Retained literal helper registers, sorted after removing the 72 retired registers, define compact helper IDs. This changes the local supplier relative to PR3413's 480-helper word, so its fixed-inventory packing ceiling does not apply.
+
+The actual event-derived T16 windows form 144 groups, each with two owner/child pairs and 224 physical ports. The certificate supplies 189 group/pattern allocations and 1,222 nonzero integer flows. Verification checks every group bin total, pattern capacity, six-width supply, 144-call demand, actual event window, and the requirement that a call uses at most one slot in each physical bin.
+
+For an allocation of n identical bins, make a bipartite multigraph from eligible call times to the pattern's width-labeled slots. Real slot degree is n; every call degree is at most n. Dummy vertices and edges make the graph n-regular. Repeated perfect matchings decompose it into n bins. Thus no bin contains two helpers from one call, and every slot has the prescribed width. The inherited deterministic coloring implementation fixes the literal assignment without any optimizer.
+
+At each call, the authenticated geometry checks that eligible children cannot alias the same physical family. Coloring therefore enforces family uniqueness as well as width capacity. The original independent auditor then checks all 58,752 literal roles, offsets, physical families, active pairs, and actual source-event windows. A second checker consumes both current native provider interfaces and the modern fill format.
+
+The reconstructed idle profile is 4,147 H1 + 110 H2 + 1,091 H3 + 456 H5 + 2 H8 + 6,078 H48. Adding 144 actual local profiles gives the stored complete rank profile, with mass 1,041,408 and deficit 5,120. Two rational engines certify its complex endpoint 0.001727254340596650594393. The profile and owner checks do not by themselves establish changed-provider controller, private-stock, precision, or outer admission; those are separate reproducible obligations.
+
+Dispatch is explicit: call (0,0) uses `extra`, and the remaining 143 calls use `gauge44`. Both have the same authenticated ordered widths and local bill. This exercises both providers in the unchanged upstream reconstruction.
+
+## Strict improvement over PR3457
+
+The local words, ordered helper widths and chronology are unchanged from PR3457. Only the bounded pattern-flow allocation changes. The complete profile delta is
+`110(H2-2H1) + (H3-3H1) + 2(H8-H5-3H1)`.
+For `H_r = 73^a r^(1-a)` and `0 2:
+ x /= 2
+ k += 1
+ lo, hi = log_unit(x)
+ l2, u2 = log_unit(Q(2))
+ lo, hi = lo+k*l2, hi+k*u2
+ # Outward rational rounding keeps later certificates compact.
+ return Q((lo*GRID).__floor__(), GRID), Q((hi*GRID).__ceil__(), GRID)
+
+
+def exp_bounds(x):
+ require(0 <= x < 1, "exponential range")
+ term = total = Q(1)
+ for j in range(1, 13):
+ term *= x/j
+ total += term
+ tail = term*x/13/(1-x/14)
+ return total, total+tail
+
+
+def moment(m, W, entries, saving):
+ lo = hi = Q(0)
+ for t, count in entries:
+ t, count = int(t), int(count)
+ require(0 < t < m and count > 0, "improper child")
+ l, u = log_bounds(Q(m, t))
+ lower = exp_bounds(saving*l)[0]
+ upper = exp_bounds(saving*u)[1]
+ lo += Q(t*count, m*W)*lower
+ hi += Q(t*count, m*W)*upper
+ return Q((lo*GRID).__floor__(), GRID), Q((hi*GRID).__ceil__(), GRID)
+
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/complex-k492-owner-repair/vendor/multicold/engines/moment.py b/research/t16-rank7-provider-composition/source-inputs/research/complex-k492-owner-repair/vendor/multicold/engines/moment.py
new file mode 100644
index 0000000000..7d697cb452
--- /dev/null
+++ b/research/t16-rank7-provider-composition/source-inputs/research/complex-k492-owner-repair/vendor/multicold/engines/moment.py
@@ -0,0 +1,113 @@
+"""Independent prospective ordinary five-stage cost, never supplier admission.
+
+Consumes a raw one-invocation ledger made from the actual source/internal/target
+paths. No packed profile is used as an input. Missing physical/finite/compiler
+obligations must remain explicit in the accompanying report.
+"""
+from collections import Counter
+from decimal import Decimal, localcontext, ROUND_FLOOR
+from fractions import Fraction as F
+from functools import lru_cache
+from math import factorial
+import hashlib, json, sys
+from pathlib import Path
+
+DYAD = 1 << 224
+
+def floor(x): return F(x.numerator*DYAD//x.denominator, DYAD)
+def ceil(x): return -floor(-x)
+
+@lru_cache(None)
+def logarithm(x):
+ """Mercator bounds after binary reduction; ln(2) via two Mercator sums.
+
+ For 1 <= y < 2, log(y) is an alternating series in z=y-1.
+ We instead reduce to 1 <= y < 3/2, and bound log(3/2) and
+ log(2) by the same alternating series at z=1/2 and z=1/3,
+ using log(2)=log(3/2)+log(4/3). All sums are exact rationals.
+ """
+ assert x >= 1
+ k = 0
+ while x >= 2: x /= 2; k += 1
+ j = int(x >= F(3, 2))
+ if j: x /= F(3, 2)
+ def mercator(y):
+ z=y-1
+ assert 0 <= z <= F(1,2)
+ # An even partial sum is below log; the next term bounds its tail.
+ t=z; s=F(0)
+ for n in range(1, 225):
+ s += (t if n & 1 else -t)/n
+ t *= z
+ return s, s+t/225
+ a,b=mercator(x); c,d=mercator(F(3,2)); e,f=mercator(F(4,3))
+ return floor(a+(k+j)*c+k*e), ceil(b+(k+j)*d+k*f)
+
+def exponential(l,u):
+ assert 0 <= l <= u < F(1,10)
+ def poly(x):
+ s=t=F(1)
+ for j in range(1,25): t=t*x/j; s+=t
+ return s,t
+ lo,_=poly(l);hi,last=poly(u)
+ return floor(lo),ceil(hi+last*u/25/(1-u/26))
+
+def moment(H,m,W,a,bad=False):
+ lo=hi=F(0)
+ for r,n in H.items():
+ assert 0 < r < m and n > 0
+ l,u=logarithm(F(m,r)); e,f=exponential(a*l,a*u)
+ p=F(r*n,m*W);lo+=p*e;hi+=p*f
+ if bad:
+ # Existing envelope shape, only conditionally portable to the new cover.
+ l,u=logarithm(F(m));e,f=exponential(a*l,a*u)
+ p=F(32*m*sum(H.values()),10**16*W)
+ lo+=p*e;hi+=p*f
+ return floor(lo),ceil(hi)
+
+def decimal(x):
+ with localcontext() as c:
+ c.prec=70
+ return str(Decimal(x.numerator)/Decimal(x.denominator))
+
+def certify(H,m,W,bad=False):
+ with localcontext() as c:
+ c.prec=70
+ terms=[(Decimal(r*n)/Decimal(m*W),(Decimal(m)/Decimal(r)).ln()) for r,n in H.items()]
+ fallback=Decimal(32*m*sum(H.values()))/Decimal(10**16*W) if bad else Decimal(0)
+ lm=Decimal(m).ln();lo=Decimal(0);hi=Decimal('.003')
+ for _ in range(210):
+ a=(lo+hi)/2
+ if sum(p*(a*l).exp() for p,l in terms)+fallback*(a*lm).exp()<1:lo=a
+ else:hi=a
+ q=int(((lo+hi)/2*10**24).to_integral_value(rounding=ROUND_FLOOR))
+ lo=F(q,10**24);hi=lo+F(1,10**24)
+ lv=moment(H,m,W,lo,bad);hv=moment(H,m,W,hi,bad)
+ assert lv[1]<10 for v in slacks.values()),{k:str(v) for k,v in slacks.items() if v<=0}
+ assert min(margins.values())==minimum
+ assert margins['balanced_prefix']-minimum==eta and 1-eps-r==eta/2
+ assert 1-eps*(1+c)==eta-eps*eta/4
+ return dict(parameters=dict(a_bit=a,a_complex=b,tau=tau,sigma=sigma,
+ eta=eta,beta=beta,q=q,c=c,epsilon=eps,lambda_=lam,
+ lambda_prime=lp,alpha_squared_power=r,delta=delta,
+ C0=bridge['semantic']['C0'],C1=1,kappa=kappa),
+ strict_constraints=slacks,margins=margins,minimum_margin=minimum,
+ absorption_gap=minimum-kappa,
+ recurrence=dict(internal=internal,leaf=leaf,reservations=1-c))
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-global/vendor535/inputs/ROUND20-PARENT-TEMPLATE.json.gz b/research/t16-rank7-provider-composition/source-inputs/research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-global/vendor535/inputs/ROUND20-PARENT-TEMPLATE.json.gz
new file mode 100644
index 0000000000..3e28a9b59f
Binary files /dev/null and b/research/t16-rank7-provider-composition/source-inputs/research/complex-k492-owner-repair/vendor/multicold/vendor/pr558/vendor/pr552/complex-global/vendor535/inputs/ROUND20-PARENT-TEMPLATE.json.gz differ
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/coupled-carrier-cap740/vendor/PR3133-PROVIDERS.json b/research/t16-rank7-provider-composition/source-inputs/research/coupled-carrier-cap740/vendor/PR3133-PROVIDERS.json
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8,
+ 8,
+ 8,
+ 8,
+ 8,
+ 8,
+ 5,
+ 5,
+ 8,
+ 8,
+ 8,
+ 8
+ ]
+ }
+}
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/coupled-carrier-cap740/words/base.json.gz b/research/t16-rank7-provider-composition/source-inputs/research/coupled-carrier-cap740/words/base.json.gz
new file mode 100644
index 0000000000..cb4cc24a45
Binary files /dev/null and b/research/t16-rank7-provider-composition/source-inputs/research/coupled-carrier-cap740/words/base.json.gz differ
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/coupled-carrier-cap740/words/extra.json.gz b/research/t16-rank7-provider-composition/source-inputs/research/coupled-carrier-cap740/words/extra.json.gz
new file mode 100644
index 0000000000..decc8f26d8
Binary files /dev/null and b/research/t16-rank7-provider-composition/source-inputs/research/coupled-carrier-cap740/words/extra.json.gz differ
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/frontier1094-idle-star-ceiling/analyze.py b/research/t16-rank7-provider-composition/source-inputs/research/frontier1094-idle-star-ceiling/analyze.py
new file mode 100644
index 0000000000..c0521d10dd
--- /dev/null
+++ b/research/t16-rank7-provider-composition/source-inputs/research/frontier1094-idle-star-ceiling/analyze.py
@@ -0,0 +1,324 @@
+#!/usr/bin/env python3
+"""Exact ceiling and star-move optimum for idle rank-48 repartitions on #1094.
+
+Reads the frozen #1094 idle remainder from the selected replay and answers,
+for the unhosted idle rank-48 children of each (replica, port) group:
+
+1. relaxation: the best price of *any* within-group repartition with ranks in
+ [1, 51] and an unchanged child count (commuting constraints dropped);
+2. pair class: an independent recount of PR1252's 48+48 -> 45+51 matching;
+3. star class: the exact optimum over disjoint stars, where a centre child
+ moves axes to leaves under PR1252's commuting rule, each leaf capped at 51.
+
+Every profile is priced with the pinned multicold engines (exact rationals).
+"""
+import argparse, random, tarfile, gzip, hashlib, importlib.util, json, sys
+from collections import Counter, defaultdict
+from fractions import Fraction as Q
+from functools import lru_cache
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[2]
+OUT = Path(__file__).resolve().parent
+OWNER_MAP = ROOT / 'research/complex-t16-rare-pattern-exchanges/OWNERS.json.gz'
+BASELINE = ROOT / 'research/community-frontier1094-audit/ASSEMBLY.json'
+ENGINE_ROOT = ROOT / 'research/complex-k492-owner-repair/vendor/multicold/engines'
+ENGINE_SHA256 = {
+ 'moment': '81cbc864e106418fc7854322746f72180cb8110ff39f74450a3b8d55a82c1482',
+ 'base_two_moment': 'aee70c242a2f1d225528fabe2002e1564d1dc884797c07d28a831c7878ee9098',
+ 'outer': 'c1ebb52163a7219504c728a5c2b098bf1e50bf20148a2879c5a74c3cadc7c03c',
+}
+M, W, DEFICIT, CAP = 73, 14336, 5120, 51
+PAIR = 'pair_class_max (PR1252 rule, independent recount)'
+
+
+REPLAY_TAR = ROOT / 'research/community-frontier1094-audit/selected-replay.tar.gz'
+MEMBERS = ('hosted/IDLE-REMAINDER-FRAMES.json.gz', 'base/work/complex-nine-native/DATA-PHASES.json',
+ 'audit/OWNERS-AND-PROFILE.json')
+
+
+def replay_inputs(root):
+ """{member: raw bytes}; read from the committed selected replay unless a
+ pre-extracted candidate/strict/global directory is given."""
+ if root is not None:
+ return {m: (Path(root) / m).read_bytes() for m in MEMBERS}
+ with tarfile.open(REPLAY_TAR) as tar:
+ return {m: tar.extractfile('candidate/strict/global/' + m).read() for m in MEMBERS}
+
+
+def parse(name, raw):
+ return json.loads(gzip.decompress(raw) if name.endswith('.gz') else raw)
+
+
+def sha(p): return hashlib.sha256(Path(p).read_bytes()).hexdigest()
+
+
+def read(p):
+ raw = Path(p).read_bytes()
+ return json.loads(gzip.decompress(raw) if str(p).endswith('.gz') else raw)
+
+
+def decimal(q, places):
+ return '0.' + str(q.numerator * 10**places // q.denominator).zfill(places)
+
+
+def dot(a, b): return (a & b).bit_count() & 1
+
+
+def load_engine(name):
+ path = ENGINE_ROOT / (name + '.py')
+ assert sha(path) == ENGINE_SHA256[name], name
+ spec = importlib.util.spec_from_file_location('idlestar_' + name, path)
+ mod = importlib.util.module_from_spec(spec); spec.loader.exec_module(mod)
+ return mod
+
+
+def price(profile, bad, baseline, eng):
+ """Exact complex endpoint and kappa; the outer recipe is PR1252's
+ math_support.price (retained #1094 recipe), re-stated here."""
+ moment, base_two, outer = eng
+ assert M * W - sum(r * n for r, n in profile.items()) == DEFICIT
+ assert M * M > 2 * max(profile) ** 2
+ endpoint = Q(moment.certify(profile, M, W, bad)['lower'])
+ for z, accept in ((endpoint, True), (endpoint + Q(1, 10**24), False)):
+ lo, hi = moment.moment(profile, M, W, z, bad)
+ blo, bhi = base_two.moment(M, W, list(profile.items()), z)
+ if bad:
+ slo, shi = base_two.moment(M, W, [(1, 32 * M * M * sum(profile.values()))], z)
+ blo += slo / 10**16; bhi += shi / 10**16
+ assert (hi < 1 and bhi < 1) if accept else (lo > 1 and blo > 1)
+ bit = Q(baseline['bit_lower']); eta = beta = Q(1, 10**24)
+ s = min(bit, (1 - beta) * endpoint) - Q(1, 10**27)
+ chain = [Q(384599, 10**10)]
+ for _ in range(7):
+ old = chain[-1]; a = (1 - s) * s + s * old
+ gap = min(s - a, 1 - a - s, 1 - a - s * (1 - old), 1 - s)
+ assert old < a < s < 1 - a and gap > 0
+ chain.append(a)
+ q = chain[-1] * (1 - 2 * eta)
+ ticks = (1 - eta) * q / (1 + q) * 10**18
+ kappa = Q((ticks.numerator - 1) // ticks.denominator, 10**18)
+ bridge = {'semantic': {'C0': {'base': 2, 'exponent': 210000}, 'strict_literal_gap': 1},
+ 'rows': {'degree_gap': Q(10**6) - Q(51 * 20161, 25)}}
+ assembled = outer.assembly(chain[-1], endpoint, bridge, kappa, eta=eta, beta=beta)
+ assert len(assembled['strict_constraints']) == 47
+ assert all(x > 0 for x in assembled['strict_constraints'].values())
+ try:
+ outer.assembly(chain[-1], endpoint, bridge, kappa + Q(1, 10**18), eta=eta, beta=beta)
+ except AssertionError:
+ pass
+ else:
+ raise AssertionError('next kappa grid point accepted')
+ return dict(endpoint=str(endpoint), endpoint_decimal=decimal(endpoint, 24),
+ kappa=str(kappa), kappa_decimal=decimal(kappa, 18))
+
+
+def group_context(rows, recipe):
+ ys = [int(s[k]) for s in recipe['stage_alignment'] for k in ('entry_Y', 'exit_Y')]
+ ys.append(int(recipe['terminal_Y_translation']))
+ xs = [int(s[k]) for s in recipe['stage_alignment'] for k in ('entry_X', 'exit_X')]
+ stage = ys + xs
+ axes = [list(map(int, r['orthogonal_axes'])) for r in rows]
+ trans = [int(recipe['idle_children'][r['child']]['translation_after']) for r in rows]
+ k = len(rows)
+ # movable[d][l]: axes of donor d commuting with every axis of leaf l, all
+ # stage X/Y and terminal Y translations, and both terminal translations.
+ movable = [[None] * k for _ in range(k)]
+ for d in range(k):
+ for l in range(k):
+ if d != l:
+ fixed = axes[l] + stage + [trans[d], trans[l]]
+ movable[d][l] = frozenset(i for i, v in enumerate(axes[d])
+ if all(dot(v, x) == 0 for x in fixed))
+ return movable
+
+
+def pair_edge(movable, i, j):
+ return len(movable[i][j]) >= 3 or len(movable[j][i]) >= 3
+
+
+def max_matching(k, edge):
+ @lru_cache(None)
+ def best(mask):
+ if not mask: return 0
+ i = (mask & -mask).bit_length() - 1
+ rest = mask & ~(1 << i)
+ value = best(rest)
+ for j in range(i + 1, k):
+ if rest >> j & 1 and edge(i, j):
+ value = max(value, 1 + best(rest & ~(1 << j)))
+ return value
+ return best((1 << k) - 1)
+
+
+def star_flow(movable, centre, leaves, need):
+ """Max axes the centre can send: leaf l takes <= need distinct axes from
+ movable[centre][l]; each centre axis moves once (bipartite b-matching).
+ Returns {leaf: sorted centre-axis indices}."""
+ slots = [(l, t) for l in leaves for t in range(need)]
+ match = {}
+ def augment(s, seen):
+ l = slots[s][0]
+ for ax in sorted(movable[centre][l]):
+ if ax in seen: continue
+ seen.add(ax)
+ if ax not in match or augment(match[ax], seen):
+ match[ax] = s; return True
+ return False
+ for s in range(len(slots)):
+ augment(s, set())
+ sent = {l: [] for l in leaves}
+ for ax, s in match.items():
+ sent[slots[s][0]].append(ax)
+ return {l: sorted(v) for l, v in sent.items()}
+
+
+def cost(vec, a):
+ return sum(r ** (1 - a) for r in vec)
+
+
+def partitions(items):
+ if not items: yield []; return
+ first, rest = items[0], items[1:]
+ for p in partitions(rest):
+ yield [[first]] + p
+ for i in range(len(p)):
+ yield p[:i] + [[first] + p[i]] + p[i + 1:]
+
+
+def best_star(k, movable, a):
+ """Exact optimum of the disjoint-star class for one group at test exponent a.
+
+ Enumerate set partitions of the k children; each block is a star with one
+ centre (or a singleton). Leaves receive up to CAP-48 = 3 axes from the centre.
+ Returns (sorted rank vector, [(centre, leaf, centre-axis indices)])."""
+ best = None
+ for part in partitions(list(range(k))):
+ vec, moves = [], []
+ for block in part:
+ if len(block) == 1:
+ vec.append(48); continue
+ options = []
+ for c in block:
+ leaves = [x for x in block if x != c]
+ sent = star_flow(movable, c, leaves, CAP - 48)
+ v = [48 - sum(map(len, sent.values()))] + [48 + len(sent[l]) for l in leaves]
+ options.append((cost(v, a), v, [(c, l, sent[l]) for l in leaves if sent[l]]))
+ _, v, mv = min(options, key=lambda o: o[0])
+ vec.extend(v); moves.extend(mv)
+ if best is None or cost(vec, a) < best[0] - 1e-12:
+ best = (cost(vec, a), sorted(vec), moves)
+ return best[1], best[2]
+
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__)
+ ap.add_argument('--replay-root', type=Path,
+ help='Optional extracted candidate/strict/global of selected-replay.tar.gz')
+ ap.add_argument('--no-price', action='store_true')
+ ap.add_argument('--check', action='store_true',
+ help='Recompute and compare with the committed RESULT.json and STAR-MOVES.json.gz; write nothing')
+ args = ap.parse_args()
+ raw = replay_inputs(args.replay_root)
+ frames, phases, audit = (parse(m, raw[m]) for m in MEMBERS)
+ owners = read(OWNER_MAP); baseline = json.loads(BASELINE.read_text())
+ recipes = {x['port']: x for x in phases['recipes']}
+ roles = {(x['owner_replica'], x['port'], x['child']) for x in owners}
+ base_profile = Counter({int(k): v for k, v in audit['paid_profile'].items()})
+ assert sum(r * n for r, n in base_profile.items()) == M * W - DEFICIT
+
+ eligible, owner48 = defaultdict(list), defaultdict(list)
+ for row in frames:
+ if row['rank'] == 48 and row['hosted'] == 0 and row['pending_offset'] == 0:
+ key = (row['replica'], row['port'], row['child'])
+ (owner48 if key in roles else eligible)[row['replica'], row['port']].append(row)
+ n_elig = sum(map(len, eligible.values())); n_owner = sum(map(len, owner48.values()))
+ assert n_elig + n_owner == base_profile[48] and n_owner == 0 # owner map uses no idle 48
+ sizes = Counter(len(v) for v in eligible.values())
+
+ a_test = 0.0016756 # near the endpoint; star choice is checked below to be a-invariant
+ pairs_total, relax, star = 0, Counter(), Counter()
+ star_alt = Counter(); star_moves = []
+ for key, rows in sorted(eligible.items()):
+ k = len(rows)
+ relax.update([CAP] * (k - 1) + [48 * k - CAP * (k - 1)] if k > 1 else [48])
+ movable = group_context(rows, recipes[key[1]])
+ pairs_total += max_matching(k, lambda i, j: pair_edge(movable, i, j))
+ vec, moves = best_star(k, movable, a_test)
+ star.update(vec); star_alt.update(best_star(k, movable, 0.01)[0])
+ for c, l, idx in moves:
+ ca = list(map(int, rows[c]['orthogonal_axes']))
+ star_moves.append(dict(replica=key[0], port=key[1], centre_child=rows[c]['child'],
+ leaf_child=rows[l]['child'], moved_axes=[str(ca[i]) for i in idx]))
+
+ def with48(counter):
+ p = Counter(base_profile); p[48] -= sum(counter.values()); p.update(counter)
+ return {r: n for r, n in sorted((+p).items())}
+
+ pair_profile = Counter(base_profile); pair_profile[48] -= 2 * pairs_total
+ pair_profile[45] += pairs_total; pair_profile[51] += pairs_total
+ profiles = {
+ 'baseline_1094': {r: n for r, n in sorted(base_profile.items())},
+ PAIR: {r: n for r, n in sorted((+pair_profile).items())},
+ 'star_class_optimum': with48(star),
+ 'relaxation_ceiling': with48(relax),
+ }
+ result = dict(
+ status='PASS_IDLE48_REPARTITION_CEILING',
+ replay_archive={str(REPLAY_TAR.relative_to(ROOT)): sha(REPLAY_TAR)},
+ inputs={m: hashlib.sha256(raw[m]).hexdigest() for m in MEMBERS}
+ | {str(OWNER_MAP.relative_to(ROOT)): sha(OWNER_MAP), str(BASELINE.relative_to(ROOT)): sha(BASELINE)},
+ eligible_children=n_elig, owner_slot_rank48_children=n_owner,
+ groups=len(eligible), group_size_histogram={str(k): v for k, v in sorted(sizes.items())},
+ pair_class_maximum_pairs=pairs_total,
+ star_vector_invariant_between_a=[a_test, 0.01], star_vector_invariant=(star == star_alt),
+ star_rank_histogram={str(k): v for k, v in sorted(star.items())},
+ relaxation_rank_histogram={str(k): v for k, v in sorted(relax.items())},
+ profiles={name: {str(r): n for r, n in p.items()} for name, p in profiles.items()},
+ )
+ assert star == star_alt
+ if not args.no_price:
+ eng = tuple(load_engine(n) for n in ('moment', 'base_two_moment', 'outer'))
+ result['prices'] = {}
+ for name, p in profiles.items():
+ result['prices'][name] = dict(native=price(p, False, baseline, eng),
+ conservative=price(p, True, baseline, eng))
+ print(name, result['prices'][name]['native']['kappa_decimal'], file=sys.stderr)
+ P = {n: Q(v['native']['kappa']) for n, v in result['prices'].items()}
+ assert P['baseline_1094'] == Q(baseline['kappa'])
+ assert P['baseline_1094'] < P[PAIR] < P['star_class_optimum'] < P['relaxation_ceiling']
+ # Control: deterministic random within-group repartitions (ranks in [1, 51],
+ # same child count and group mass) never price above the ceiling.
+ rng = random.Random(1094); controls = []
+ for _ in range(4):
+ alt = Counter()
+ for rows in eligible.values():
+ vec = [48] * len(rows)
+ for _ in range(6):
+ i, j = rng.randrange(len(vec)), rng.randrange(len(vec))
+ t = min(rng.randint(0, 6), vec[i] - 1, CAP - vec[j]) if i != j else 0
+ vec[i] -= t; vec[j] += t
+ alt.update(vec)
+ kap = Q(price(with48(alt), False, baseline, eng)['kappa'])
+ assert kap <= P['relaxation_ceiling']
+ controls.append(dict(max_rank=max(alt), kappa=str(kap), below_ceiling=True))
+ result['random_repartition_controls'] = controls
+ overlay = dict(schema='idle48-star-moves/1', source_frames_sha256=hashlib.sha256(raw[MEMBERS[0]]).hexdigest(),
+ moves=star_moves, profile=result['profiles']['star_class_optimum'])
+ payload = json.dumps(overlay, sort_keys=True, separators=(',', ':')).encode()
+ result['star_moves'] = len(star_moves)
+ result['star_moves_payload_sha256'] = hashlib.sha256(payload).hexdigest()
+ text = json.dumps(result, indent=2) + '\n'
+ if args.check:
+ assert (OUT / 'RESULT.json').read_text() == text, 'RESULT.json differs'
+ assert gzip.decompress((OUT / 'STAR-MOVES.json.gz').read_bytes()) == payload, 'STAR-MOVES differs'
+ print('PASS_IDLE48_REPARTITION_CEILING_RECOMPUTED', 'pairs=%d' % pairs_total)
+ return
+ gz = bytearray(gzip.compress(payload, mtime=0)); gz[9] = 255
+ (OUT / 'STAR-MOVES.json.gz').write_bytes(bytes(gz))
+ (OUT / 'RESULT.json').write_text(text)
+ print(result['status'], 'pairs=%d' % pairs_total)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/allocation/vendor/PLAN.json.gz b/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/allocation/vendor/PLAN.json.gz
new file mode 100644
index 0000000000..7a1db55a4d
Binary files /dev/null and b/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/allocation/vendor/PLAN.json.gz differ
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/allocation/vendor/TEMPLATE.json.gz b/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/allocation/vendor/TEMPLATE.json.gz
new file mode 100644
index 0000000000..114808c32b
Binary files /dev/null and b/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/allocation/vendor/TEMPLATE.json.gz differ
diff --git a/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/allocation/vendor/independent_owners.py b/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/allocation/vendor/independent_owners.py
new file mode 100644
index 0000000000..16013201b1
--- /dev/null
+++ b/research/t16-rank7-provider-composition/source-inputs/research/rank7-joint-endframes/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<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= 0 and offset + width <= rank[child], 'R6', 'slice exceeds child rank')
+ need(not cells[owner, child, port] & new, 'R6', 'overlapping slices')
+ cells[owner, child, port] |= new
+ need(all(hosted[call] == set(range(R)) for call in order), 'R2', 'incomplete helper inventory')
+ idle = Counter()
+ for (owner, child) in span_:
+ for port in range(V):
+ used = cells[owner, child, port]
+ need(used == set(range(len(used))), 'R6', 'gap in occupied prefix')
+ if rank[child] > len(used):
+ idle[rank[child] - len(used)] += 1
+ need(idle == expected_idle, 'R7', f'idle profile {dict(sorted(idle.items()))} != claimed')
+ profile = Counter({r: L * T * n for r, n in local_profile.items()})
+ profile.update(idle)
+ mass = sum(r * n for r, n in profile.items())
+ need(M * live - mass == 320 * T, 'R7', 'rank deficit')
+ need(max(profile) ** 2 * 2 < M * M, 'R7', 'halving guard')
+ return dict(idle=dict(sorted(idle.items())), profile=dict(sorted(profile.items())), rank_mass=mass,
+ deficit=M * live - mass, calls=len(order), roles=len(roles), windows=len(span_),
+ cross_replica_roles=sum(z['owner_replica'] != z['replica'] for z in roles))
+
+
+def as_profile(d):
+ return Counter({int(k): v for k, v in d.items()})
+
+
+# ---------------------------------------------------------------- controls
+
+def controls(geo, widths, local_profile, roles, plan, expected_idle, T):
+ """Each mutant must be rejected by the rule it targets."""
+ rank, place = geo['rank'], geo['place']
+ span_, callpos = windows(geo, [tuple(x) for x in plan['order']])
+ order = [tuple(x) for x in plan['order']]
+ first = roles[0]
+ out = []
+
+ def expect(name, rule, mutant, idle=expected_idle):
+ try:
+ audit(geo, widths, local_profile, mutant, plan, idle, T)
+ except Reject as e:
+ need(str(e).startswith(rule + ':'), 'control', f'{name} rejected by {e} instead of {rule}')
+ out.append(dict(name=name, rejected_by=rule))
+ return
+ raise Reject(f'control: accepted {name}')
+
+ def swap(i, z):
+ return roles[:i] + [z] + roles[i + 1:]
+
+ expect('drop_role', 'R1', roles[1:])
+ expect('narrow_width', 'R2', swap(0, dict(first, width=first['width'] - 1)))
+ j = next(i for i, z in enumerate(roles) if z['time'] == first['time'] and z['helper'] != first['helper'])
+ expect('duplicate_helper', 'R2', swap(j, dict(roles[j], helper=first['helper'])))
+ expect('private_family', 'R3', swap(0, dict(first, family=T * FAMILIES_PER_REPLICA)))
+ # A role whose family/copy are consistent but sits on the active pair.
+ for i, z in enumerate(roles):
+ s, r = z['stage'], z['replica']
+ p = geo['stage_pair'][s]
+ child = next(c for c, (pp, sd) in place.items() if pp == p and c in rank and (r, c) in span_)
+ fam = r * FAMILIES_PER_REPLICA + (2 * p + place[child][1]) * V + z['port']
+ expect('active_pair', 'R3', swap(i, dict(z, owner_replica=r, child=child, family=fam, copy=r * V + z['port'])))
+ break
+ # Two helpers of one invocation on the same family (second gets a fresh slice range).
+ calls = defaultdict(list)
+ for i, z in enumerate(roles):
+ calls[z['time']].append(i)
+ a, b = calls[first['time']][0], calls[first['time']][1]
+ za, zb = roles[a], roles[b]
+ expect('family_collision', 'R4', swap(b, dict(zb, owner_replica=za['owner_replica'], child=za['child'],
+ port=za['port'], family=za['family'], copy=za['copy'],
+ offset=za['offset'] + za['width'])))
+ # Move a whole role to an invocation after its owner's idle sweep, keeping the helper index unique
+ # by swapping times with the same helper there.
+ for i, z in enumerate(roles):
+ lo, hi = span_[z['owner_replica'], z['child']]
+ later = next((key for key in order if callpos[key] > hi), None)
+ if later is None:
+ continue
+ t2 = order.index(later)
+ k = next(k for k in calls[t2] if roles[k]['helper'] == z['helper'])
+ mutant = list(roles)
+ mutant[i] = dict(z, stage=later[0], replica=later[1], time=t2)
+ mutant[k] = dict(roles[k], stage=z['stage'], replica=z['replica'], time=z['time'])
+ expect('past_idle_sweep', 'R5', mutant)
+ break
+ # Two slices of one bin overlapping in cells (different invocations, so R4 is silent).
+ by_bin = defaultdict(list)
+ for i, z in enumerate(roles):
+ by_bin[z['owner_replica'], z['child'], z['port']].append(i)
+ i, k = next(v for v in by_bin.values() if len(v) >= 2)[:2]
+ expect('overlap', 'R6', swap(k, dict(roles[k], offset=roles[i]['offset'])))
+ # Shift the last slice of some bin up by one inside capacity: a gap appears.
+ for v in by_bin.values():
+ top = max(v, key=lambda x: roles[x]['offset'])
+ z = roles[top]
+ if z['offset'] + z['width'] < rank[z['child']]:
+ expect('prefix_gap', 'R6', swap(top, dict(z, offset=z['offset'] + 1)))
+ break
+ tampered = Counter(expected_idle)
+ one = min(tampered)
+ tampered[one] -= 1
+ tampered[one + 1] += 1
+ expect('claimed_idle_tampered', 'R7', roles, idle=+tampered)
+ stale = dict(plan, windows=dict(plan['windows']))
+ key = next(iter(stale['windows']))
+ stale['windows'][key] = [stale['windows'][key][0], stale['windows'][key][1][:-1]]
+ try:
+ audit(geo, widths, local_profile, roles, stale, expected_idle, T)
+ except Reject as e:
+ need(str(e).startswith('X1:'), 'control', 'stale window rejected elsewhere')
+ out.append(dict(name='plan_window_truncated', rejected_by='X1'))
+ else:
+ raise Reject('control: accepted plan_window_truncated')
+ return out
+
+
+# ---------------------------------------------------------------- main
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ ap.add_argument('--repo', type=Path, default=HERE.parent.parent, help='repository holding the pinned blobs')
+ ap.add_argument('--fetch', action='store_true', help='fetch refs/pull/N/head for every claim first')
+ ap.add_argument('--only', type=int, action='append', help='audit only these PR numbers')
+ ap.add_argument('--write', action='store_true', help='rewrite RESULT.json instead of comparing with it')
+ args = ap.parse_args()
+ sources = json.loads((HERE / 'SOURCES.json').read_text())
+ repo = args.repo.resolve()
+
+ pins = sources['inputs']
+ tbytes, pbytes, wbytes = (repo / TEMPLATE).read_bytes(), (repo / PHASES).read_bytes(), WORD.read_bytes()
+ need(sha(tbytes) == pins['template_sha256'], 'input', 'parent template hash')
+ need(sha(pbytes) == pins['data_phases_sha256'], 'input', 'DATA-PHASES hash')
+ need(sha(gzip.decompress(wbytes)) == pins['word_content_sha256'], 'input', 'seven-slot word content hash')
+ template, phases, word = load(tbytes, TEMPLATE), load(pbytes, PHASES), load(wbytes, '.gz')
+ geo = geometry(template, phases)
+ widths = word_widths(word)
+ local_profile = as_profile(word['report']['local_profile'])
+ need(Counter(widths) == as_profile(word['report']['width_inventory']), 'word', 'width inventory')
+
+ if args.fetch:
+ for c in sources['claims']:
+ subprocess.run(['git', '-C', str(repo), 'fetch', '-q', 'https://github.com/CrocSwap/integer-mult-bounds.git',
+ f'refs/pull/{c["pr"]}/head'], check=True)
+
+ rows, receipt_controls, t8_done = [], {}, None
+ for c in sources['claims']:
+ if args.only and c['pr'] not in args.only:
+ continue
+ get = {name: load(blob(repo, oid), name) for name, oid in c['blobs'].items()}
+ spec, plan = get['data/SPEC.json'], get['data/PLAN.json']
+ if 'RESULT.json' in get:
+ result = get['RESULT.json']
+ else: # #1082 ships CANDIDATE.json (kappa) and PROFILE.json instead of RESULT.json
+ result = dict(kappa_decimal=get['CANDIDATE.json']['kappa'], profile=get['PROFILE.json'])
+ need(spec['providers']['gauge44']['expected_profile'] == {str(k): v for k, v in sorted(local_profile.items())},
+ 'spec', f'#{c["pr"]} local profile differs from the word')
+ need(Counter(widths) == as_profile(spec['providers']['gauge44']['inventory']), 'spec', 'width inventory')
+ if t8_done is None and 'data/T8/OWNERS.json.gz' in get:
+ # The shared T8 owner map (#1018) under the same rules, T = 8.
+ t8 = audit(geo, widths, local_profile, get['data/T8/OWNERS.json.gz'], get['data/T8/PLAN.json'],
+ as_profile(get['data/SPEC-T8.json']['expected']['idle_remainder_profile']), 8)
+ need(t8['profile'] == {int(k): v for k, v in get['data/T8/PLAN.json']['profile'].items()}, 'R7', 'T8 PLAN profile')
+ t8_done = dict(owners_blob=c['blobs']['data/T8/OWNERS.json.gz'], **t8)
+ roles = get['data/OWNERS.json.gz']
+ r = audit(geo, widths, local_profile, roles, plan,
+ as_profile(spec['expected']['idle_remainder_profile']), 16)
+ claimed = result.get('complex_profile', result.get('profile')) # rohanarun packages use 'profile'
+ need(r['profile'] == {int(k): v for k, v in claimed.items()}, 'R7', 'RESULT profile')
+ need(r['profile'] == {int(k): v for k, v in plan['profile'].items()}, 'R7', 'PLAN profile')
+ if 'idle_remainder_profile' in result:
+ need(r['idle'] == {int(k): v for k, v in result['idle_remainder_profile'].items()}, 'R7', 'RESULT idle')
+ need(r['cross_replica_roles'] == spec['expected'].get('cross_replica_helper_roles', r['cross_replica_roles']),
+ 'R7', 'cross-replica role count')
+ if c['pr'] == sources['controls_on']:
+ receipt_controls = controls(geo, widths, local_profile, roles, plan,
+ as_profile(spec['expected']['idle_remainder_profile']), 16)
+ rows.append(dict(pr=c['pr'], head=c['head'], kappa=result['kappa_decimal'], **r))
+ print(f"PASS #{c['pr']} kappa={result['kappa_decimal']} idle={r['idle']}", flush=True)
+
+ receipt = dict(
+ status='PASS_INDEPENDENT_T16_OWNER_AUDIT',
+ geometry=dict(source_events_per_replica=30, positive_children=len(geo['rank']),
+ child_ranks={str(c): geo['rank'][c] for c in sorted(geo['rank'])},
+ x2_disjoint_child_port_checks=geo['x2_child_ports']),
+ word=dict(R=len(widths), width_inventory={str(k): v for k, v in sorted(Counter(widths).items())},
+ local_profile={str(k): v for k, v in sorted(local_profile.items())}),
+ t8=t8_done, claims=rows, controls=receipt_controls)
+ text = json.dumps(receipt, indent=1, default=lambda o: {str(k): v for k, v in o.items()}) + '\n'
+ text = json.dumps(json.loads(text), indent=1) + '\n'
+ target = HERE / 'RESULT.json'
+ if args.write:
+ target.write_text(text)
+ elif not args.only:
+ need(target.read_text() == text, 'receipt', 'RESULT.json differs from this run')
+ print(f"PASS_INDEPENDENT_T16_OWNER_AUDIT claims={len(rows)} roles={sum(r['roles'] for r in rows)} "
+ f"t8_roles={t8_done['roles'] if t8_done else 0} controls={len(receipt_controls)}")
+
+
+if __name__ == '__main__':
+ try:
+ main()
+ except Reject as e:
+ sys.exit(f'FAIL {e}')
diff --git a/research/t16-rank7-provider-composition/test_materialize.py b/research/t16-rank7-provider-composition/test_materialize.py
new file mode 100644
index 0000000000..1bcdf589f4
--- /dev/null
+++ b/research/t16-rank7-provider-composition/test_materialize.py
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: Apache-2.0
+"""Distinguishing boundary controls for Git-free materialization."""
+import gzip,hashlib,io,json,tarfile,tempfile
+from pathlib import Path
+import importlib.util
+_spec=importlib.util.spec_from_file_location("scientific_materialize",Path(__file__).resolve().parent/"materialize.py")
+_module=importlib.util.module_from_spec(_spec);_spec.loader.exec_module(_module)
+build=_module.build
+sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
+def test():
+ with tempfile.TemporaryDirectory(prefix='t16-materialize-controls-')as tmp:
+ root=Path(tmp);repo=root/'main';repo.mkdir();(repo/'a').write_bytes(b'alpha')
+ def archive(items):
+ p=root/'overlay.tar.gz'
+ with tarfile.open(p,'w:gz')as tar:
+ for name,b in items:
+ e=tarfile.TarInfo(name);e.size=len(b);tar.addfile(e,io.BytesIO(b))
+ return p
+ def recipe(extra=None):
+ d={'entries':{'source/a':{'source_kind':'canonical_main','source_path':'a','bytes':5,'sha256':hashlib.sha256(b'alpha').hexdigest()},'source/b':{'source_kind':'overlay','source_path':'source/b','bytes':4,'sha256':hashlib.sha256(b'beta').hexdigest()}},'original_bundle_manifest':{'scope':'test only'}}
+ if extra:extra(d)
+ p=root/'recipe.json';p.write_text(json.dumps(d));return p
+ r=recipe();o=archive([('source/b',b'beta')]);build(repo,r,o,root/'positive',sha(r),sha(o));assert(root/'positive/source/a').read_bytes()==b'alpha'
+ count=1
+ def reject(label,fn):
+ nonlocal count
+ try:fn()
+ except (ValueError,AssertionError):count+=1
+ else:raise AssertionError('accepted '+label)
+ reject('archive authentication',lambda:build(repo,r,o,root/'bad-hash',sha(r),'0'*64))
+ (repo/'a').write_bytes(b'ALPHA');reject('changed mainfile',lambda:build(repo,r,o,root/'bad-main',sha(r),sha(o)));(repo/'a').write_bytes(b'alpha')
+ o=archive([('source/b',b'BETA')]);reject('corrupt overlay payload despite updated archivehash',lambda:build(repo,r,o,root/'bad-payload',sha(r),sha(o)))
+ o=archive([('../escape',b'x'),('source/b',b'beta')]);reject('archive traversal',lambda:build(repo,r,o,root/'bad-path',sha(r),sha(o)))
+ o=archive([('source/b',b'beta'),('extra',b'x')]);reject('extra archiveentry',lambda:build(repo,r,o,root/'bad-extra',sha(r),sha(o)))
+ o=archive([('source/b',b'beta'),('source/b',b'beta')]);reject('duplicate entry',lambda:build(repo,r,o,root/'bad-duplicate',sha(r),sha(o)))
+ o=archive([('source/b',b'beta')]);r=recipe(lambda d:d['entries']['source/a'].update(source_path='../escape'));reject('mainfile traversal',lambda:build(repo,r,o,root/'bad-sourcepath',sha(r),sha(o)))
+ o=archive([]);r=recipe();reject('missing archiveentry',lambda:build(repo,r,o,root/'bad-missing',sha(r),sha(o)))
+ if any(p.name.startswith('bad-')for p in root.iterdir()):raise AssertionError('invalid input wrote output')
+ return {'controls_passed':count,'failed_inputs_write_no_output':True}
+if __name__=='__main__':print(json.dumps(test()))
diff --git a/research/t16-rank7-provider-composition/test_reconstruct.py b/research/t16-rank7-provider-composition/test_reconstruct.py
new file mode 100644
index 0000000000..bf8f8b30bd
--- /dev/null
+++ b/research/t16-rank7-provider-composition/test_reconstruct.py
@@ -0,0 +1,111 @@
+"""Behavioral certificate, chronology, source and literal owner controls."""
+import copy
+import json
+import os
+from pathlib import Path
+import shutil
+import tempfile
+import unittest
+import sys
+
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import reconstruct as r # noqa: E402 - isolated-script bootstrap
+
+ROOT = Path(os.environ.get("T16_RESEARCH_ROOT", r.HERE / "source-inputs")).resolve()
+
+
+class CertificateControls(unittest.TestCase):
+ @classmethod
+ def setUpClass(cls):
+ cls.rows, cls.plan, cls.audit = r.reconstruct(ROOT)
+ cls.cert = r.read(r.HERE / "CERTIFICATE.json")
+ cls.auditor, cls.geo, cls.widths, cls.local = r.sources(ROOT)
+
+ def rejected(self, change, message):
+ cert = copy.deepcopy(self.cert)
+ change(cert)
+ with self.assertRaisesRegex(ValueError, message):
+ r.reconstruct(ROOT, certificate=cert)
+
+ def test_positive_literal_and_both_provider_contract(self):
+ self.assertEqual(len(self.rows), 58752)
+ self.assertEqual(self.audit["rank_mass"], 1041408)
+ self.assertEqual(self.audit["idle"], {1: 4147, 2: 110, 3: 1091, 5: 456, 8: 2, 48: 6078})
+
+ def test_duplicate_and_missing_flow(self):
+ self.rejected(lambda c: c["flow"].append(c["flow"][0][:]), "duplicate flow")
+ self.rejected(lambda c: c["flow"].pop(), "demand|supply")
+
+ def test_fractional_and_boolean_counts(self):
+ self.rejected(lambda c: c["flow"][0].__setitem__(3, 1.5), "integer domain")
+ self.rejected(
+ lambda c: c["allocation"][0].__setitem__(2, True), "integer domain"
+ )
+
+ def test_width_and_bin_corruption(self):
+ self.rejected(
+ lambda c: c["patterns"][0][1].__setitem__(5, 12), "overfull pattern"
+ )
+ self.rejected(
+ lambda c: c["allocation"][0].__setitem__(2, c["allocation"][0][2] - 1),
+ "integer domain|group bin",
+ )
+
+ def test_window_corruption(self):
+ def change(c):
+ # Find a known forbidden time from authenticated literal plan windows.
+ grouped = {}
+ for key, (capacity, times) in self.plan["windows"].items():
+ grouped.setdefault((capacity, tuple(times)), []).append(key)
+ groups = sorted(grouped)
+ for row in c["flow"]:
+ group = c["allocation"][row[0]][0]
+ bad = next((t for t in range(144) if t not in groups[group][1]), None)
+ if bad is not None:
+ row[1] = bad
+ return
+ self.fail("missing negative window control")
+
+ self.rejected(change, "flow outside window")
+
+ def test_literal_time_width_and_family_controls(self):
+ for field, value in [("time", 143), ("width", 10), ("family", 16 * 896)]:
+ rows = copy.deepcopy(self.rows)
+ rows[0][field] = value
+ with self.assertRaises(self.auditor.Reject):
+ self.auditor.audit(
+ self.geo,
+ self.widths,
+ self.local,
+ rows,
+ self.plan,
+ self.audit["idle"],
+ 16,
+ )
+
+ def test_local_source_corruption_precedes_reconstruction(self):
+ with tempfile.TemporaryDirectory() as directory:
+ package = Path(directory) / "package"
+ shutil.copytree(r.HERE, package)
+ with (package / "CERTIFICATE.json").open("a") as handle:
+ handle.write("\n")
+ with self.assertRaisesRegex(ValueError, "source hash"):
+ r.reconstruct(ROOT, package=package)
+
+ def test_modern_two_provider_dispatch(self):
+ fill, order, dispatch, audit = r.modern_inputs(ROOT, self.rows, self.plan)
+ self.assertEqual(len(fill["rows"]), 58752)
+ self.assertEqual(dispatch[0], [0, 0, "extra"])
+ self.assertTrue(all(row[2] == "gauge44" for row in dispatch[1:]))
+ bad = copy.deepcopy(self.rows)
+ bad[0]["width"] += 1
+ with self.assertRaisesRegex(ValueError, "actual provider width"):
+ r.modern_inputs(ROOT, bad, self.plan)
+
+ def test_duplicate_json_key(self):
+ with self.assertRaisesRegex(ValueError, "duplicate JSON key"):
+ json.loads('{"schema":1,"schema":2}', object_pairs_hook=r.unique)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/research/t16-rank7-provider-composition/verify.py b/research/t16-rank7-provider-composition/verify.py
new file mode 100644
index 0000000000..2f951f98b8
--- /dev/null
+++ b/research/t16-rank7-provider-composition/verify.py
@@ -0,0 +1,92 @@
+# SPDX-License-Identifier: Apache-2.0
+"""Reconstruct the literal T16 candidate and replay its complete finite admission."""
+import argparse
+from fractions import Fraction
+import hashlib
+import json
+import os
+from pathlib import Path
+import subprocess
+import sys
+import tempfile
+
+HERE = Path(__file__).resolve().parent
+ROOT = HERE.parents[1]
+KAPPA = Fraction('0.001727254340596650594393') - Fraction(1, 10**46) - Fraction(1, 10**70)
+BASELINE = Fraction('0.001727153212938552593775') - Fraction(1, 10**46) - Fraction(1, 10**70)
+
+
+def need(value, message):
+ if not value:
+ raise ValueError(message)
+
+
+def read(path):
+ return json.loads(path.read_text())
+
+
+def run(script, *arguments, timeout):
+ subprocess.run([sys.executable, '-I', '-Werror', '-B', str(HERE / script),
+ *map(str, arguments)], check=True, timeout=timeout)
+
+
+def verify(work, main_files):
+ need(__debug__, 'full ancestral admission requires enabled assertions')
+ need(not work.exists(), 'use a fresh external work directory')
+ need(not work.is_relative_to(ROOT), 'work directory must be outside the checkout')
+ work.mkdir(parents=True)
+ run('reconstruct.py', '--output', work / 'allocation', timeout=120)
+ run('replay.py', '--main-files', main_files, '--allocation', work / 'allocation',
+ '--work', work / 'replay', '--jobs', 2, timeout=570)
+ admission = work / 'replay/admission'
+ result = read(admission / 'RESULT.json')
+ release_path = admission / 'release/RELEASE-RECEIPT.json'
+ release = read(release_path)
+ need(result['status'] == 'PASS_REPLICA_ORDER_FILL_DERIVATIVE_COMPLETE_RELEASE',
+ 'complete admission required')
+ need(release['status'] == 'PASS_RELEASE', 'complete release required')
+ need(Fraction(result['kappa']) == Fraction(release['kappa_decimal']) == KAPPA > BASELINE,
+ 'exact scoped T16 gain')
+ need(hashlib.sha256(release_path.read_bytes()).hexdigest()
+ == result['release_receipt_sha256'], 'release receipt binding')
+ invoice = read(admission / 'discovery/global/audit/PREFIX-AND-INVOICE.json')
+ need(invoice['private_zero_buffers'] == 91 and invoice['physical'] == 14845,
+ 'fully charged private buffers and physical families')
+ need(invoice['physical_stock_identity'] == {
+ 'data_and_owner_families': 14336, 'local_helpers': 408,
+ 'private_centres': 8, 'private_zero_buffers': 91, 'coefficient_work': 2},
+ 'physical stock decomposition')
+ expected = read(HERE / 'EXPECTED.json')
+ profile = read(work / 'allocation/MODERN-OWNER-AUDIT.json')['profile']
+ need(profile == expected['profile'], 'literal paid profile')
+ need(all(stage['exit_code'] == 0 for stage in result['stages']), 'all stages completed')
+ receipt = {'status': 'PASS_T16_RANK7_PROVIDER_COMPOSITION', 'kappa': str(KAPPA),
+ 'kappa_decimal': result['kappa_decimal'], 'baseline_pr': 3457,
+ 'baseline_kappa': str(BASELINE), 'gain': str(KAPPA - BASELINE),
+ 'replicas': 16, 'calls': 144, 'helpers_per_call': 408,
+ 'roles': 58752, 'profile': profile,
+ 'release_receipt_sha256': result['release_receipt_sha256'],
+ 'source_manifest_sha256': result['source_manifest_sha256'],
+ 'native_receipt_sha256': result['native_receipt_sha256'],
+ 'scope': 'Complete conditional finite T16 admission and modern outer arithmetic. '
+ 'Both native providers reused from authenticated prior fresh executions. '
+ 'Below the T740 frontier; inherited all-size assumptions remain.'}
+ (work / 'RESULT.json').write_text(json.dumps(receipt, indent=2) + '\n')
+ print(receipt['status'], receipt['kappa_decimal'], flush=True)
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--work', type=Path)
+ parser.add_argument('--main-files', type=Path, default=ROOT)
+ args = parser.parse_args()
+ if args.work is None:
+ parent = Path(tempfile.mkdtemp(prefix='t16-rank7-', dir=os.environ.get('TMPDIR')))
+ work = parent / 'run'
+ else:
+ work = args.work.resolve()
+ verify(work, args.main_files.resolve())
+
+
+if __name__ == '__main__':
+ main()