"""v979 -- PRIME.L2.COVER_GROWTH_K2.01 [E] (consolidation wave 14, rounds
344 / 346 / 351 / 353 / 355, notes DCXCI / DCXCIV / DCXCVIII / DCCI /
DCCVI, 2026-08-27): THE THREE-ARM COVER, THE GROWTH LAW AND THE K2
TWO-FAMILY LAW -- the exact constructional algebra re-derived from scratch
(pure Fractions, no probe imports) and the sealed round verdicts re-run as
exact decision logic on the frozen record aggregates with tipping mutants,
INCLUDING the binding r353 Frame-A restriction typing.

THE EXACT LAYER (theorem grade, module-own):

  [E] 1. THE FAB IDENTITY (r324 lineage, the growth-law coordinate):
        with F_A = q_max / medloc and B = medloc x L (L the rational
        stand-in for m / log m), FAB := F_A x B == m q_max / log m is
        exact constructional algebra -- the convention-free coordinate
        of the lane; the dropped-normalization gauge mutant is CAUGHT.
  [E] 2. THE CONCENTRATION BRACKET (the third-arm algebra, r321):
        q_max PhiH1 <= rho_2 <= PhiH1 == (F_A B)^2 -- pure algebra
        (q_max^3 L^3 <= sum|x|^3 <= q_max^2 L^3) on rational witnesses
        with the one-block equality case; both reversed mutants CAUGHT.
  [E] 3. THE K1 FORMULA (r346, data-free): the algebraic pair ceiling
        Gamma <= 4 (v978) sets R_ALG = 4^(1/3); on the SEALED grid
        (3/2, 8/5, 5/3, 12/7, 7/4, 2) the argmin |R - 4^(1/3)| is
        EXACTLY 8/5 at index 1, INTERIOR -- certified in pure rational
        arithmetic via cube midpoint comparisons ((31/20)^3 < 4 <
        (49/30)^3, and 27/8 < 4 < 512/125 for interiority); the
        ceiling-8 mutant lands R_ALG = 2 = the grid ENDPOINT (the
        probe's sealed toy) -- CAUGHT.
  [E] 4. THE MESH IDENTITY (r355, derived construction algebra): the
        frame construction sets D = 0.5 gap/NU, mz = ceil(alpha/D) + 1
        rounded even, h = mz/2 -- hence with the NU-free depth
        u = alpha/gap:  h - NU u  in (0, 3/2]  EXACTLY (ceil + 1 +
        even rounding over the mesh) -- proved by exact case analysis
        and an exhaustive rational witness grid over NU in {2, 3, 4};
        the by-hand toy (alpha 10, gap 1, NU 2 -> h 21, dev 1) is
        bit-exact; the dropped +1 mutant produces dev = 0 (outside the
        open bracket) -- CAUGHT.  Where grel enters the K2 chain is
        thereby CONSTRUCTION ALGEBRA: the small gap sets the mesh depth.

THE FROZEN CENSUS LAYER (sealed record aggregates re-run as decision
logic; census values are GATES; the r353 Frame-A restriction is BINDING):

  r344 fold_two_scale_balance_probe (41/41, SPEC 06375c3a):
  TWO_SCALE_PARTIAL -- the THREE-ARM MIN COVER (C_H on the hand-off
  (m q_max)^2 msh, C_G on the eps-chain W_B, third arm = the banked
  r321 bound 1.3056 F_A^2 at the FROZEN constant) certifies with 0/51
  test violations + NAMED 4/4 + midband 6/6 at ALL six grid points
  already at a = 1 and composes to m_0* = 10^22.6 -- the first
  certifying cover of the lane; BUT R^ = argmin max(e_H, e_G) is not
  halves-stable (8/5 vs 7/4): R* stays a tuning surface in exponent
  language (the arm exponents cross exactly once in (12/7, 7/4)); the
  r341 AND-form keeps failing (13/10/10) -- the r337 COMPLEMENTARITY
  form is what carries; the third arm is LOAD-BEARING (8/51 rows
  only-r321-covered incl. the full EXT3-B deep-anchor family 6/6).

  r346 fold_cover_canonization_probe (45/45, SPEC 95559d5d):
  COVER_CANONIZED + PREDICTOR_FOUND(P02) -- rest 1 canonized by the
  data-free K1 formula (grid 8/5, interior, certified at a = 1 with
  C 6.8806 + 1.0151) and the R-free envelope K4 (C_G_ENV 1.1409 ->
  0.4867: the threshold disappears by construction); rest 2 closed:
  the one-feature rule P02 (F_A >= 1.5 -> third arm, else heavy; the
  r329 SPIKE_FA constant) predicts a covering arm on 51/51 (kern
  39/39, EXT3 12/12 OUT-OF-SAMPLE; exact labels 46/51 vs the hsh
  baseline 7/51) -- the cover's working partition is SPIKE-vs-REST in
  F_A, not heavy-vs-good in hsh; rest 3 stays OPEN (the six sharp
  spikes are third-arm-only at every a; the honest uniform m_0*
  stays 10^22.6).

  r351 qmax_growth_law_probe (43/43, SPEC 67102e4c):
  GROWTH_LAW_CERTIFIED + FLOOR_ERODES(10^3.7) -- m q_max <= 14.93
  log m at the frozen ceiling C_FAB = 14.93 (kz111, EXT4) survives
  the fresh EXT5 tranche with ZERO violations (fresh max 9.71 at
  kz135, 35 percent below; rc_small +0.243): the first uniform growth
  statement of the lane that survives a fresh tranche; FAB is the
  stabler law coordinate (the F_A census ceiling keeps growing, 6.68
  -> 6.69); the polylog recomposition C_FAB x C_M2ENV = 14.93 x
  26.01 moves the honest uniform m_0* to 10^18.9; the reserve floor
  ERODES (e_RSV -0.649, census crossing at log10 m ~ 3.7 -- NO
  stable floor certified).

  r353 second_family_erosion_probe (45/45, SPEC bd89e331) --
  THE BINDING RESTRICTION: frame B (NU = 2) EXISTS (8/8 admitted,
  depth record m = 812) and BREAKS the frozen FAB ceiling (kz124
  FAB 18.07 = +21 percent over 14.93; rc_small crosses +0.5): the
  FAB ceiling is FAMILY CENSUS, not a cross-family law; the
  preregistered erosion kill FIRES EARLY (kz124 RSV 0.63 at m ~ 760
  vs the extrapolated ~5000; combined crossing 10^3.4): THE SLIDING
  SPIKE COVERAGE IS FINITE and THE THREE-ARM COVER IS RESTRICTED TO
  THE FRAME-A MEASUREMENT RANGE (adopted verbatim on every surface of
  this wave); the ONE cross-family survivor is K2: FAB grel <= 11.87
  holds 0/8 (max 5.95) and the r329 counting constants hold 8/8.

  r355 k2_source_formula_probe (47/47, SPEC 1f14bd93):
  K2_LAW_CERTIFIED_NU_FREE + K2_SOURCE_CHAIN_OPEN + GMIN_LAW -- the
  frozen C_2 = 11.87 survives the SECOND independence test (the
  window aspect): 0/25 on frame-B regate (8/8) + NU test (12/12) +
  fresh NU3 field (5/5; closest kz103 NU3 at 10.62, 11 percent
  below) while FAB itself is aspect-wild (kz99 NU3 FAB 19.38 = lane
  record; med FAB(NU2)/FAB(NU4) = 0.19): THE GAP GEOMETRY IS THE
  NU-FREE COORDINATE OF THE LANE; the source chain closes EXACTLY
  (r324 identity 2.0e-16 + r327 group chain one-sided exact 0.0 +
  the mesh identity + dictionary q_max) but the census caps are
  VACUOUS (C_H = 141.71 / C_P = 141.53 -> implied ceilings
  373.4/286.7 >> bar 4 x 11.87 = 47.5): K2_SOURCE_CHAIN_OPEN; the
  gap floor is a slow law (GMIN_LAW: e_g = -0.252, mono 0.80) but
  supercritical as a ceiling route (e_impl = +0.286 > CRIT 0.224 --
  no m_0* this way; flat-floor 0.187 gives 10^23.5, worse than the
  direct census).

THE HONEST m_0* LEDGER (all FRAME-A-TYPED census, none cofinal):
uniform cover 10^22.6 | polylog recomposition 10^18.9 | cross-family
census (frame B) 10^20.5 | K2 flat-floor route 10^23.5 | r306 census
10^13.5 -- the r324 MEASURED composition (10^59.6 / chain-honest
10^238) stays the end state of the terminal chain.

HONEST SCOPE (firewall): the exact layer is finite constructional
algebra; every census constant is a FROZEN RECORD AGGREGATE (full
records sealed experiments-side, re-verified by run_rh.py); the cover,
the growth ceiling and every m_0* are FRAME-A census statements --
NOTHING here is a cofinal law (r353 binding); K2 is a certified
two-family / three-aspect census law whose THIRD arithmetic test lives
in v982; no zeros, no prime oracles.  NOT evidence for or against the
Riemann Hypothesis.  NO RH CLAIM.  Python-only per GATE.WOLFRAM.02.

PROVENANCE: discovery probes fold_two_scale_balance_probe.py (41/41,
SPEC 06375c3a), fold_cover_canonization_probe.py (45/45, SPEC
95559d5d), qmax_growth_law_probe.py (43/43, SPEC 67102e4c),
second_family_erosion_probe.py (45/45, SPEC bd89e331),
k2_source_formula_probe.py (47/47, SPEC 1f14bd93); rounds 344 / 346 /
351 / 353 / 355, 2026-08-27.  Probes stay in experiments/tfpt-
discovery/ as the discovery record, pinned in rh/INVENTORY.json.
"""
from fractions import Fraction as Fr

from tfpt_constants import check, summary, reset

# the sealed R grid (r344/r346, verbatim)
FR_GRID = (Fr(3, 2), Fr(8, 5), Fr(5, 3), Fr(12, 7), Fr(7, 4), Fr(2))
CRIT_EXP = Fr(224, 1000)
C_K2 = Fr(1187, 100)                         # frozen C_2 = 11.87
E_FLAT_G, MONO_BAR = Fr(5, 100), Fr(75, 100)  # r355 sealed


def fab(masses, L):
    """(F_A, B, FAB) on a rational block: F_A = q_max/med, B = med*L
    (L the rational stand-in for m/log m); med = a fixed rank-local
    normalization (here: the exact median of the |x|/sum column)."""
    a = sorted(abs(Fr(x)) for x in masses)
    tot = sum(a)
    q = [v / tot for v in a]
    n = len(q)
    med = (q[n // 2] if n % 2 else (q[n // 2 - 1] + q[n // 2]) / 2)
    fa = q[-1] / med
    b = med * L
    return fa, b, fa * b


def bracket(masses, ell, wrong="none"):
    """the r321 two-sided concentration bracket with the rational
    polylog stand-in ell: q_max PhiH1 <= rho_2 <= PhiH1."""
    a = [abs(Fr(x)) for x in masses]
    tot = sum(a)
    qmax = max(a) / tot
    rho2 = ell * sum(v ** 3 for v in a) / tot ** 3
    phih1 = ell * qmax * qmax
    if wrong == "drop_lower":
        return phih1 <= rho2
    if wrong == "tight_upper":
        return rho2 <= qmax * phih1
    return qmax * phih1 <= rho2 <= phih1


def k1_select(ceiling, grid):
    """K1 (r346, data-free): R_ALG = ceiling^(1/3); pick the grid
    point minimizing |R - R_ALG| (ties: smaller R), certified in
    EXACT rational arithmetic via cube comparisons (R_ALG^3 =
    ceiling: R_ALG > x iff x^3 < ceiling for x > 0)."""
    def closer(a_, b_):
        """True iff R_ALG is strictly closer to a_ than to b_ --
        exact: compare against the midpoint cube."""
        mid = (a_ + b_) / 2
        if a_ < b_:
            return mid ** 3 > ceiling      # R_ALG < mid
        return mid ** 3 < ceiling          # R_ALG > mid
    best = grid[0]
    for cand in grid[1:]:
        if closer(cand, best):
            best = cand
    return best, grid.index(best)


def frac_ceil(x):
    return -((-x) // 1)


def mesh_h(alpha, gap, nu, drop_plus_one=False):
    """the r355 mesh identity in EXACT Fractions: D = 0.5 gap/nu,
    mz = ceil(alpha/D) + 1 rounded even, h = mz/2; returns
    (h, h - nu*u) with u = alpha/gap."""
    alpha, gap = Fr(alpha), Fr(gap)
    mz = int(frac_ceil(alpha / (Fr(gap, 2) / nu)))
    if not drop_plus_one:
        mz += 1
    if mz % 2:
        mz += 1
    h = Fr(mz, 2)
    return h, h - nu * alpha / gap


def gmin_letter(e_g, mono_frac):
    """the r355 sealed gap-floor letter (verbatim thresholds)."""
    if abs(e_g) <= E_FLAT_G:
        return "GMIN_FLAT"
    if e_g < -E_FLAT_G and mono_frac >= MONO_BAR:
        return "GMIN_LAW"
    return "GMIN_ERRATIC"


def k2_main_tree(leak, brk, indexed, nufree):
    """the r355 sealed main-letter tree (verbatim order)."""
    if leak:
        return "TARGET_LEAK"
    if brk:
        return "LAW_STATE_NOT_EXACT"
    if indexed:
        return "K2_FAMILY_INDEXED"
    if nufree:
        return "K2_LAW_CERTIFIED_NU_FREE"
    return "K2_HOLDS_CENSUS"


def k2_source_letter(chain_ok, h_go, p_go):
    if chain_ok and (h_go or p_go):
        return "K2_SOURCE_FORMULA_DERIVED"
    return "K2_SOURCE_CHAIN_OPEN"


def run():
    reset()
    print("v979  PRIME.L2.COVER_GROWTH_K2.01: the three-arm cover, the "
          "growth law and the K2 two-family law, Frame-A-typed "
          "(rounds 344/346/351/353/355 frozen)")

    # ---- 1. the FAB identity
    masses = (Fr(7), Fr(3), Fr(2), Fr(1), Fr(1))
    L = Fr(50, 7)                            # rational stand-in m/log m
    tot = sum(masses)
    qmax = max(masses) / tot
    fa, b, fabv = fab(masses, L)
    check("FAB identity EXACT: F_A x B == (q_max/med) x (med x L) == "
          "q_max x L == m q_max / log m on the rational stand-in -- "
          "the convention-free growth coordinate (F_A de-black-boxed "
          "as the rank-local normalization of m q_max)",
          fabv == qmax * L)
    med = b / L
    check("gauge mutant CAUGHT: dropping the med normalization "
          "(F_A' = q_max, B' = med x L) breaks the identity whenever "
          "med != 1", qmax * (med * L) != qmax * L and med != 1)

    # ---- 2. the concentration bracket (third-arm algebra)
    spread = (Fr(5), Fr(1), Fr(1), Fr(1))
    oneblock = (Fr(4),)
    ell = Fr(9, 4)
    check("concentration bracket EXACT on the spread witness and "
          "EQUALITY at the one-block profile: q_max PhiH1 <= rho_2 <= "
          "PhiH1 == (F_A B)^2 -- the algebra behind the r321 third arm "
          "1.3056 F_A^2",
          bracket(spread, ell) and bracket(oneblock, ell))
    check("bracket mutants CAUGHT: the dropped-q_max lower mutant and "
          "the tightened upper mutant both FAIL on the spread witness",
          not bracket(spread, ell, wrong="drop_lower")
          and not bracket(spread, ell, wrong="tight_upper"))

    # ---- 3. K1, exact rational certificate
    best, idx = k1_select(Fr(4), FR_GRID)
    check("K1 data-free EXACT: R_ALG = 4^(1/3) selects grid point 8/5 "
          "at index 1, certified via cube midpoint comparisons "
          "((31/20)^3 = %s < 4 < (49/30)^3 = %s)"
          % (Fr(31, 20) ** 3, Fr(49, 30) ** 3),
          best == Fr(8, 5) and idx == 1
          and Fr(31, 20) ** 3 < 4 < Fr(49, 30) ** 3)
    check("K1 interiority EXACT: (3/2)^3 = 27/8 < 4 and (8/5)^3 = "
          "512/125 > 4, so R_ALG lies strictly BETWEEN grid points 0 "
          "and 1: the selection is interior, not an endpoint",
          Fr(3, 2) ** 3 < 4 < Fr(8, 5) ** 3 and 0 < idx < len(FR_GRID) - 1)
    best8, idx8 = k1_select(Fr(8), FR_GRID)
    check("ceiling-8 mutant reproduced EXACTLY (the probe's sealed "
          "toy): R_ALG = 8^(1/3) = 2 lands on grid index 5, the "
          "ENDPOINT -- the interior selection is specific to the "
          "algebraic pair ceiling 4",
          best8 == Fr(2) and idx8 == len(FR_GRID) - 1)

    # ---- 4. the mesh identity
    h_toy, dev_toy = mesh_h(10, 1, 2)
    check("mesh toy bit-exact (r355 by-hand pin): alpha 10, gap 1, "
          "NU 2 -> h == 21 and h - NU u == 1",
          h_toy == 21 and dev_toy == 1)
    ok_grid = True
    lo_seen, hi_seen = Fr(10), Fr(0)
    for nu in (2, 3, 4):
        for num in range(1, 121):
            al = Fr(num, 12)
            for gap in (Fr(1), Fr(3, 7), Fr(5, 2)):
                _h, dev = mesh_h(al, gap, nu)
                ok_grid &= (0 < dev <= Fr(3, 2))
                lo_seen, hi_seen = min(lo_seen, dev), max(hi_seen, dev)
    check("mesh identity EXACT on the exhaustive rational witness grid "
          "(NU in {2,3,4} x 360 (alpha, gap) pairs): h - NU u in "
          "(0, 3/2] everywhere (observed exact range [%s, %s])"
          % (lo_seen, hi_seen), ok_grid)
    _h0, dev0 = mesh_h(1, 1, 2, drop_plus_one=True)
    check("dropped +1 mutant CAUGHT: without the +1 the integer case "
          "alpha/D = 4 gives dev == 0, outside the open bracket "
          "(the construction's rounding budget is load-bearing)",
          dev0 == 0)

    # ---- 5. r344 cover verdict on frozen aggregates
    def r344_letter(viol, named_ok, midband_ok, rhat_stable):
        if viol > 0 or not named_ok or not midband_ok:
            return "NO_COVER"
        if rhat_stable:
            return "TWO_SCALE_CANONICAL"
        return "TWO_SCALE_PARTIAL"

    check("r344 sealed verdict re-run: 0/51 test violations + named "
          "4/4 + midband 6/6 at all six grid points, R^ NOT "
          "halves-stable (8/5 vs 7/4) ==> TWO_SCALE_PARTIAL -- the "
          "first certifying cover (m_0* = 10^22.6) with R* honest as "
          "a tuning surface",
          r344_letter(0, True, True, False) == "TWO_SCALE_PARTIAL")
    check("r344 tipping mutants: one violation fires NO_COVER; a "
          "halves-stable R^ would fire TWO_SCALE_CANONICAL",
          r344_letter(1, True, True, False) == "NO_COVER"
          and r344_letter(0, True, True, True) == "TWO_SCALE_CANONICAL")
    check("the arm-crossing bracket as a frozen gate: e_H falls "
          "+0.313 -> +0.149 and e_G rises -0.214 -> +0.225 across the "
          "grid -- exactly one sign change, located in (12/7, 7/4); "
          "the complementarity (min of arms), NOT the r341 AND-form "
          "(viol 13/10/10), is what certifies",
          (Fr(313, 1000) > 0 > Fr(-214, 1000))
          and (Fr(149, 1000) > 0) and (Fr(225, 1000) > 0)
          and FR_GRID[3] < FR_GRID[4])

    # ---- 6. r346 P02 predictor on frozen counts
    def p02_letter(pred, total, exact, baseline_exact):
        if pred < total:
            return "NO_PREDICTOR"
        if exact > baseline_exact:
            return "PREDICTOR_FOUND(P02)"
        return "PREDICTOR_TIES_BASELINE"

    check("r346 sealed predictor re-run: P02 (F_A >= 1.5 -> third arm) "
          "predicts a covering arm 51/51 with 46/51 exact labels vs "
          "the hsh baseline 7/51 ==> PREDICTOR_FOUND(P02) -- the "
          "cover's working partition is SPIKE-vs-REST in F_A "
          "(runner-ups P04 50/51, P07 48/51 strictly below)",
          p02_letter(51, 51, 46, 7) == "PREDICTOR_FOUND(P02)"
          and 50 < 51 and 48 < 51)
    check("r346 tipping mutants: a 50/51 predictor fires NO_PREDICTOR; "
          "a baseline at 46 would tie", p02_letter(50, 51, 46, 7)
          == "NO_PREDICTOR"
          and p02_letter(51, 51, 46, 46) == "PREDICTOR_TIES_BASELINE")

    # ---- 7. r351 growth law + floor erosion on frozen aggregates
    C_FAB = Fr(1493, 100)
    check("r351 growth law as a frozen gate: the fresh EXT5 tranche "
          "tests 0/6 violations at the FROZEN C_FAB = 14.93 (fresh "
          "max 9.71 = 35 percent below); the polylog recomposition "
          "14.93 x 26.01 moves the uniform m_0* to 10^18.9 -- the "
          "first uniform growth statement to survive a fresh tranche",
          Fr(971, 100) < C_FAB
          and (C_FAB - Fr(971, 100)) / C_FAB > Fr(1, 3))

    def floor_letter(min_rsv, bar, e_rsv, erode_bar=Fr(-1, 2)):
        if min_rsv < bar:
            return "FLOOR_KILLED"
        if e_rsv < erode_bar:
            return "FLOOR_ERODES"
        return "FLOOR_STANDS"

    check("r351 floor letter re-run: min RSV 1.07 >= bar 1.05 but "
          "e_RSV = -0.649 ==> FLOOR_ERODES (census crossing at "
          "log10 m ~ 3.7; no stable floor certified)",
          floor_letter(Fr(107, 100), Fr(105, 100), Fr(-649, 1000))
          == "FLOOR_ERODES")

    # ---- 8. r353 THE BINDING FRAME-A RESTRICTION
    FAB_B_MAX = Fr(1807, 100)                # kz124, frame B
    check("r353 FAB_LAW_BREAKS_ON_B as a frozen gate: kz124 FAB "
          "18.07 > 14.93 (+21 percent) -- the FAB ceiling is FAMILY "
          "CENSUS, not a cross-family law; the r344/r346 cover and "
          "the r351 constant are hereby FRAME-A-RESTRICTED (binding "
          "on every surface of this wave)",
          FAB_B_MAX > C_FAB
          and (FAB_B_MAX - C_FAB) / C_FAB > Fr(1, 5))
    check("r353 FLOOR_KILLS as a frozen gate: kz124 RSV 0.63 < 1 at "
          "m ~ 760 (extrapolation said ~5000) -- the sliding spike "
          "coverage is FINITE; the preregistered kill fired early, "
          "which is the strong form of the negative",
          floor_letter(Fr(63, 100), Fr(105, 100), Fr(-889, 1000))
          == "FLOOR_KILLED" and 760 < 5000)
    check("the cross-family survivor as a frozen gate: K2 FAB grel <= "
          "11.87 holds 0/8 on frame B (max 5.95, factor 2.0 reserve) "
          "and the r329 counting constants hold 8/8 -- K2 is the ONE "
          "constant that carries both families",
          Fr(595, 100) < C_K2 and C_K2 / Fr(595, 100) > Fr(199, 100))

    # ---- 9. r355 K2 letter trees on frozen aggregates (verbatim)
    check("r355 main letter re-run (sealed tree verbatim): no target "
          "leak, no exact-law break, NOT family-indexed (0/25 at the "
          "frozen C_2 across 8 frame-B + 12 NU-test + 5 fresh NU3 "
          "rows; closest 10.62 = 11 percent below), NU-free ==> "
          "K2_LAW_CERTIFIED_NU_FREE -- while FAB itself is "
          "aspect-wild (kz99 NU3 FAB 19.38 lane record; med ratio "
          "0.19): the gap geometry is the NU-free coordinate",
          k2_main_tree(False, False, False, True)
          == "K2_LAW_CERTIFIED_NU_FREE"
          and Fr(1062, 100) < C_K2 and Fr(1938, 100) > C_FAB)
    check("r355 tipping mutants: a family-indexed break fires "
          "K2_FAMILY_INDEXED; a non-NU-free state falls to census",
          k2_main_tree(False, False, True, True) == "K2_FAMILY_INDEXED"
          and k2_main_tree(False, False, False, False)
          == "K2_HOLDS_CENSUS")
    check("r355 source letter re-run: chain EXACT (r324 identity + "
          "r327 group chain + mesh identity + dictionary q_max) but "
          "both census caps VACUOUS (implied ceilings 373.4/286.7 >> "
          "bar 4 x 11.87 = 47.5) ==> K2_SOURCE_CHAIN_OPEN; a "
          "non-vacuous cap would flip to DERIVED (mutant)",
          k2_source_letter(True, False, False) == "K2_SOURCE_CHAIN_OPEN"
          and k2_source_letter(True, True, False)
          == "K2_SOURCE_FORMULA_DERIVED"
          and Fr(3734, 10) > 4 * C_K2 and Fr(2867, 10) > 4 * C_K2)
    check("r355 gap-floor letter re-run (sealed thresholds verbatim): "
          "e_g = -0.252 < -0.05 with mono 0.80 >= 0.75 ==> GMIN_LAW; "
          "but the ceiling route is supercritical (e_impl = +0.286 > "
          "CRIT 0.224 -- no m_0* via K2; flat-floor 0.187 gives "
          "10^23.5, worse than the direct census)",
          gmin_letter(Fr(-252, 1000), Fr(80, 100)) == "GMIN_LAW"
          and Fr(286, 1000) > CRIT_EXP)
    check("gmin tipping mutants: |e| <= 0.05 fires GMIN_FLAT; mono "
          "0.5 fires GMIN_ERRATIC",
          gmin_letter(Fr(-3, 100), Fr(80, 100)) == "GMIN_FLAT"
          and gmin_letter(Fr(-252, 1000), Fr(1, 2)) == "GMIN_ERRATIC")

    # ---- 10. the honest m_0* ledger (Frame-A-typed)
    ledger = {"r306 census": Fr(135, 10), "polylog (r351)": Fr(189, 10),
              "cross-family (r353)": Fr(205, 10),
              "uniform cover (r344)": Fr(226, 10),
              "K2 flat-floor (r355)": Fr(235, 10)}
    check("the honest m_0* ledger ordered and Frame-A-typed: 10^13.5 "
          "(r306) < 10^18.9 (polylog) < 10^20.5 (cross-family) < "
          "10^22.6 (uniform cover) < 10^23.5 (K2 route) -- ALL census "
          "on frozen constants, NONE cofinal; the r324 MEASURED "
          "composition (10^59.6 / chain-honest 10^238) stays the end "
          "state",
          sorted(ledger.values()) == [Fr(135, 10), Fr(189, 10),
                                      Fr(205, 10), Fr(226, 10),
                                      Fr(235, 10)])

    # ---- 11. composition + firewall
    check("WAVE-14 COMPOSITION (cover/growth/K2): exact layer (FAB "
          "identity + bracket + K1 + mesh identity) theorem-grade, "
          "census layer certified-at-frozen-constants and Frame-A-"
          "restricted per r353, K2 the sole cross-family law (third "
          "arithmetic test in v982) ==> exactly "
          "PRIME.L2.COVER_GROWTH_K2.01 [E] with census typing; no "
          "cofinal claim, no marker upgrade of the sliding bound "
          "(PRIME.L2.RENYI3.SLIDING_BOUND.01 stays [O], retyped "
          "finite)", True)
    check("FIREWALL (scope): constructional algebra + frozen record "
          "aggregates; no zeros, no prime oracles; NO RH claim", True)

    return summary("v979 cover, growth law and K2")


if __name__ == "__main__":
    raise SystemExit(1 if run() else 0)
