"""v777 -- FTRANSFER.CLOCKS.01 EXECUTED + the fibered refinement of CONTRACT.F.01: the preregistered external-clock kill and the projective-groupoid reading, ONE module from two probes (24 + 14 checks, 0 failures each, ~7 s; discovery probes run_clocks_executor.py NO-COMMON-CONNECTION -- the K1 kill EXACTLY as the frozen prior expected -- and ftransfer_projective_groupoid_probe.py FTRANSFER-FIBERED-CARRIES, both 2026-08-05).  THE EXECUTED KILL (byte-frozen preregistration: YAML sha256 880224f7..., frozen 2026-08-04; data tables curated + SHA-frozen BEFORE the first run: Saikawa-Shirai 2018 g_*s 8ae2a4fe..., PDG 2024 alpha_s 2ca6332d...): all four dictionaries are construction-VALID (Koide scheme check: |Q_run - 2/3| = 571 x |Q_pole - 2/3|, the on-shell chart is right; washout entropy-chart drift 1.15e-4; QCD 1-loop overlay max dev 0.83% on [m_t, 1 TeV]; relic onset slope dev 0.0602) -- and the one-class prediction FTC.P1 dies sympy-EXACTLY: the transported Schwarzians are {-Delta^2/2, -Delta^2/2, 0} (Delta = 6 log(3/2); symbolic difference exactly nonzero, no tolerance involved).  K1 duty discharged: the reparametrization a pass WOULD need is exhibited -- h = Moebius(e^{+-Delta sigma}), the NON-affine exponential clock change the freeze forbids (exactly the v578 u = e^{Delta t}).  K2/K3 quiet.  THE FIBERED REFINEMENT (the architectural reading the kill leaves standing, all gates frozen before the first run): F_transfer is NOT one common continuous clock but a FIBERED functor -- a shared DISCRETE PGL2 base (cross-ratio of the four anchor quadruples = 4/3 EXACTLY symbolic and through the frozen g_*s table, dev 6.5e-4; deck unit |Delta sigma| = 1 exact; the deck generator is the unit parabolic translation, tr^2 - 4 det = 0 -- the v632 lattice-explicit discrete half) + channel-specific projective connections whose obstruction is the CONSTANT seam cocycle: antisymmetry and the cocycle identity exact (27 triples), values EXACTLY {0, +-Delta^2/2}, d/dsigma identically zero (symbolic + 50-digit spot checks); the classification matches the predeclared marker -- thermal/proper-time clocks {tau, beta} -> coset -Delta^2/2, RG clock {log mu} -> coset 0, relic degenerate NOT classified; all three controls fire (wrong slope leaves the value set, scrambled anchors give CR = 3/4, the v578 Moebius transplant moves QCD onto -Delta^2/2).  FIRST-RUN DISCLOSURE (carried verbatim in the probe docstring): the groupoid's G2b spot checks were first evaluated with float64 lambdify (dev 3.0e-9), violating the frozen sympy-exact kernel method; the arithmetic was conformed to the frozen method (50-digit evalf), the 1e-12 bar UNTOUCHED.  CONSEQUENCE: the jet route of CONTRACT.F.01 closes at the physical-clock level (the v578 diagnosis finalized) and the contract's surviving form is the fibered functor with the constant obstruction cocycle; the one named proof-grade next step: derive the coset assignment from KMS/modular clock typing.  The four observables stay [C]/[O]; no marker move.  NO RH claim.  Python-only per GATE.WOLFRAM.02.

PROVENANCE: discovery executor run_clocks_executor.py (2026-08-05, 24 checks 0 failures, NO-COMMON-CONNECTION, matches the frozen prior) + ftransfer_projective_groupoid_probe.py (2026-08-05, 14 checks 0 failures, FTRANSFER-FIBERED-CARRIES); both re-run identically at promotion.  Promoted verbatim; transforms: the data/YAML paths point read-only at experiments/ftransfer-clocks/ (freeze guards unchanged, abort-on-mismatch), the results-JSON writes are DROPPED (the experiments-side scripts remain the writers of record), and run() encodes both preregistered patterns (v757 precedent).  Numbers unchanged.

Original executor docstring (verbatim):
FTRANSFER.CLOCKS.01 -- the experiments-side executor of the frozen
external-clock contract (hypotheses/ftransfer_clocks_v1.yaml, byte-frozen
2026-08-04).

WHAT THIS IS.  The preregistered kill test for the jet residual of
CONTRACT.F.01, executed EXACTLY as frozen: four external clocks (proper time
tau / inverse temperature beta / RG time t / e-folds ln a), four affine
dictionaries with frozen slopes (-1, -1, +1, -1) into the common chart
sigma = ln(mu/M_Z), symbolic (sympy-exact) Schwarzian-cocycle transport, the
one-class prediction FTC.P1, the three kill criteria K1/K2/K3 with frozen
bars, the four data-driven dictionary-validity legs FTC.01.K/B/Q/R, and the
three controls FTC.C1/C2/C3.  NO frozen value is altered; the executor
verifies the sha256 of the preregistration YAML and of the two curated data
tables (data/DATA_FREEZE.sha256) at startup and aborts on any mismatch.

WHAT THIS IS NOT.  Not load-bearing: experiments/ only, typed [X]; no ledger
row moves, no marker, no paper/website surface.  The preregistration's
executor clause names a FUTURE verification module (vN_ftransfer_clock_jets
pattern) entered via the promotion workflow; this script is the
experiments-side execution that produces the adjudicated numbers for that
promotion round -- it creates no vN module and upgrades nothing.

HONEST PRIOR (frozen in the YAML before execution): expected verdict
NO-COMMON-CONNECTION (K1) -- affine transport scales a Schwarzian by
slope^2 and cannot move 0 (the QCD value) onto -Delta^2/2 (the seam value).
ONE-CLASS would be the surprise.

Data interfaces (curated + byte-frozen BEFORE this executor first ran):
  data/gstar_saikawa_shirai_2018.csv   (Saikawa & Shirai 2018, arXiv:1803.01038)
  data/alphas_pdg2024_running.csv      (PDG 2024 world average + 4-loop running)

Run:  . experiments/tfpt-discovery/.venv/bin/activate
      python experiments/ftransfer-clocks/run_clocks_executor.py
Output: results/ftransfer_clocks_v1_execution.json + console report.

Original groupoid probe docstring (verbatim):
ftransfer_projective_groupoid_probe -- the fibered-functor probe after the K1 kill.

PLACEMENT.  experiments/ftransfer-clocks/ (this probe reuses the byte-frozen
preregistration YAML and the two SHA-frozen data tables of the executed
contract as its freeze guards; separating it into tfpt-discovery/ would
duplicate the freeze surface).  Exploration only: no verification/ module,
no ledger row, no paper/website surface, typed [X] work product.

THE ARCHITECTURAL READING UNDER TEST (the review's, confirmed by the
executed K1 kill of FTRANSFER.CLOCKS.01, verdict NO-COMMON-CONNECTION):
F_transfer is NOT one common continuous clock.  The correct category is a
FIBERED functor Sheet-Diamond -> {proper time tau, inverse temperature
beta, RG time log mu, e-folds log a}: a shared DISCRETE common PGL2
structure (the base) + channel-specific projective connections (the
fibers), with the Schwarzian differences stored as an OBSTRUCTION COCYCLE
-- not fitted away.

ALL GATES FROZEN HERE, BEFORE THE FIRST RUN (2026-08-05; no bar, set,
convention or marker below may be changed after execution):

  FREEZE GUARDS (abort on mismatch):
    prereg YAML sha256  880224f76380c77dce2c1e3d7651bccc9e1619e74c60b7e15326ee0ee2bbf4d0
    gstar table sha256  8ae2a4fec098fd68d3a469fbf2b7806ee1630f5595498a3e6cf2abca2d79b939
    alphas table sha256 2ca6332dd1ee0caa089f64be58e90a8c916c94bbe612125eca41da50c33a2ac2

  G1 -- THE SHARED DISCRETE LAYER (make-or-break: if this differs, the
  whole F_transfer category dies):
    Anchor quadruples: four consecutive clock e-fold ticks {0,1,2,3} from
    the frozen base point of each channel (pole: x1* = -sigma*,
    sigma* = ln(m_tau/M_Z); Boltzmann: z = 1; QCD: sigma_t = ln(m_t/M_Z);
    relic: four points equally spaced in ln a spanning the frozen validated
    window [onset - 0.5, onset + 0.5], onset = ln a at 3H(T_osc) = m_a).
    G1a cross-ratio (symbolic): CR of the dictionary images of the anchor
        quadruple equals 4/3 EXACTLY for all four affine dictionaries
        (equally-spaced lattice cross-ratio; sympy zero).
    G1b cross-ratio (data): pole/Boltzmann/QCD legs |CR - 4/3| <= 1e-9
        (pure affine, float noise only); relic leg THROUGH THE FROZEN
        g_*s TABLE |CR - 4/3| <= 0.15 (bar mirrors the frozen prereg
        slope tolerance class -- the only frozen tolerance of that leg).
    G1c deck unit: one clock e-fold maps to |Delta sigma| = 1 EXACTLY
        (symbolic) for the three affine channels; relic measured mean
        |d sigma/d ln a| in [0.85, 1.15] on the frozen window.
    G1d deck class + objects: the deck generator (one clock e-fold pushed
        to sigma) is the unit translation -- PGL2 matrix [[1, +-1],[0,1]],
        parabolic: tr^2 - 4 det = 0 EXACTLY; all four dictionaries target
        the SAME object (the sigma-line); orientations recorded
        (-1,-1,+1,-1) and identified under inverse-conjugation (a
        translation is PGL2-conjugate to its inverse; the YAML freezes
        'orientation is irrelevant to the class data').

  G2 -- THE OBSTRUCTION COCYCLE (on the transported Schwarzians S_i):
    Degenerate-leg convention (FROZEN): F_relic carries NO Schwarzian
    (v578/prereg honesty clause) -- it is an object of the groupoid with
    identity morphism only and is EXCLUDED from the cocycle carrier set;
    the cocycle lives on the three non-degenerate channels.
    G2a antisymmetry: omega_ij = -omega_ji EXACT (sympy zero).
    G2b cocycle identity omega_ij + omega_jk = omega_ik EXACT, and the
        STRUCTURAL content: omega is a CONSTANT cocycle, not a running
        function -- d/dsigma of every transported Schwarzian expression
        vanishes IDENTICALLY (symbolic), plus 5-point numeric spot checks
        per channel across the frozen evaluation windows (pole: sigma in
        sigma* + [0, 3]; Boltzmann: z in [1, 10]; QCD: mu in [m_t, 1 TeV]),
        max deviation from the channel constant <= 1e-12.
    G2c values: the cocycle takes values EXACTLY in {0, +-Delta^2/2},
        Delta^2/2 = 18 log^2(3/2) = 2.959235170076978, closed form
        (sympy zero against 18*log(3/2)**2).

  G3 -- THE CLASSIFICATION (marker predeclared HERE, before computing):
    The two-coset split of the cocycle must be
      THERMAL/PROPER-TIME CLOCKS {tau, beta} -> coset S = -Delta^2/2
      (the two channels whose clock is a wall/modular time on which the
      seam contraction acts per e-fold),
      RG CLOCK {log mu} -> coset S = 0
      (the one channel whose clock IS the native flow variable),
      RELIC {log a} -> degenerate object, NOT classified (predeclared:
      honesty forbids assigning the jet-free channel to a coset).
    The torsor difference between the two cosets is the seam constant
    Delta^2/2 exactly.

  G4 -- CONTROLS (all three MUST fire):
    G4a wrong-slope dictionary (slope 2 on the Koide channel): the deck
        unit breaks (|Delta sigma| = 2 != 1) AND the transported
        Schwarzian leaves the frozen value set (slope^2 scaling:
        -4 * Delta^2/2 not in {0, +-Delta^2/2}).
    G4b scrambled anchors (frozen scramble: swap the LAST TWO anchors of
        the F_pole quadruple): cross-ratio mismatch detected
        (CR = 3/4 != 4/3).
    G4c v578 Moebius clock transplanted to QCD: t = h(sigma) =
        e^{Delta sigma} moves the QCD Schwarzian from 0 onto -Delta^2/2
        EXACTLY (symbolic) -- the obstruction is exactly the forbidden
        non-affine freedom (the K1-duty check transplanted).

  VERDICT ENUM (frozen):
    FTRANSFER-FIBERED-CARRIES  -- all G1-G3 pass and all G4 controls fire
    FTRANSFER-FIBERED-PARTIAL  -- G1 holds but some later gate fails (name it)
    FTRANSFER-FIBERED-DEAD     -- G1 fails (the category dies entirely)

FIREWALL: search-surface probe; a CARRIES verdict does NOT upgrade any
marker, does NOT close CONTRACT.F.01, and enters papers only via a future
promotion round.  No new state, no new scale; all constants from the
frozen corpus (Delta = 6 log(3/2), the v184/v185 anchors, the two frozen
data tables).
"""

from __future__ import annotations

import hashlib
import json
import math
import os
import time

import sympy as sp
import yaml

T_START = time.time()
HERE = os.path.abspath(os.path.join(os.path.dirname(
    os.path.abspath(__file__)), "..", "experiments", "ftransfer-clocks"))

# ---------------------------------------------------------------------------
# Frozen freeze-guard hashes.  The YAML hash is the byte-freeze of record
# (committed 2026-08-04, commit 368df86f); the data hashes were frozen by
# scripts/curate_data_tables.py BEFORE the executor first ran (2026-08-05).
# ---------------------------------------------------------------------------
YAML_PATH = os.path.join(HERE, "hypotheses", "ftransfer_clocks_v1.yaml")
YAML_SHA256 = "880224f76380c77dce2c1e3d7651bccc9e1619e74c60b7e15326ee0ee2bbf4d0"
DATA_FREEZE = os.path.join(HERE, "data", "DATA_FREEZE.sha256")
GSTAR_CSV = os.path.join(HERE, "data", "gstar_saikawa_shirai_2018.csv")
ALPHAS_CSV = os.path.join(HERE, "data", "alphas_pdg2024_running.csv")

# Corpus anchors entering ONLY through base points / window edges (v184, v185,
# tfpt_constants); affine offsets by construction, outside the class data.
PHI0 = 0.053171952176845526      # tfpt_constants phi0 (retained seed)
V_EW = 174.0                     # GeV (v184)
M3_EV = 0.05                     # eV, m_3 ~ sqrt(dm^2_atm) (v184)
MBAR = 2.435323e18               # GeV, reduced Planck mass (v184/v185)
DIM_SPLUS = 16                   # v185: f_a = M_scal/(2 * dim S+ * |mu4|) = M_scal/128
N_EFF_SM = 3.044                 # SM value the Planck N_eff certificate is tested against

CHECKS = []


def check(name: str, ok: bool, detail: str = "") -> bool:
    CHECKS.append({"name": name, "ok": bool(ok), "detail": detail})
    print("[%s] %s%s" % ("PASS" if ok else "FAIL", name, (": " + detail) if detail else ""))
    return bool(ok)


def sha256_file(path: str) -> str:
    h = hashlib.sha256()
    with open(path, "rb") as f:
        for chunk in iter(lambda: f.read(65536), b""):
            h.update(chunk)
    return h.hexdigest()


def schwarzian(y, x):
    y1, y2, y3 = sp.diff(y, x), sp.diff(y, x, 2), sp.diff(y, x, 3)
    return sp.simplify(y3 / y1 - sp.Rational(3, 2) * (y2 / y1) ** 2)


def read_csv(path: str):
    rows = []
    with open(path) as f:
        for line in f:
            line = line.strip()
            if not line or line.startswith("#"):
                continue
            rows.append([float(v) for v in line.split(",")])
    return rows


def loglog_interp(table, x, xi=0, yi=1):
    """log-log linear interpolation in column yi against column xi."""
    lx = math.log(x)
    lo, hi = 0, len(table) - 1
    if not (table[lo][xi] <= x <= table[hi][xi]):
        raise ValueError("interpolation out of range: %g" % x)
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if table[mid][xi] <= x:
            lo = mid
        else:
            hi = mid
    x0, x1 = math.log(table[lo][xi]), math.log(table[hi][xi])
    y0, y1 = math.log(table[lo][yi]), math.log(table[hi][yi])
    return math.exp(y0 + (y1 - y0) * (lx - x0) / (x1 - x0))


def main() -> int:
    print("=" * 78)
    print("FTRANSFER.CLOCKS.01 -- frozen external-clock contract: EXECUTION")
    print("=" * 78)

    # -----------------------------------------------------------------------
    # 0. FREEZE GUARD (K2 machine form): byte-frozen YAML + frozen data tables.
    # -----------------------------------------------------------------------
    yaml_hash = sha256_file(YAML_PATH)
    check("G0.1 preregistration YAML byte-freeze verified (sha256 == frozen record)",
          yaml_hash == YAML_SHA256, yaml_hash)
    frozen_data_hashes = {}
    with open(DATA_FREEZE) as f:
        for line in f:
            line = line.strip()
            if not line or line.startswith("#"):
                continue
            h, name = line.split()
            frozen_data_hashes[name] = h
    for path in (GSTAR_CSV, ALPHAS_CSV):
        name = os.path.basename(path)
        check("G0.2 frozen data table %s hash verified" % name,
              sha256_file(path) == frozen_data_hashes[name], frozen_data_hashes[name])
    if not all(c["ok"] for c in CHECKS):
        print("\nVERDICT: ABORT -- freeze guard failed; nothing executed")
        return 1

    with open(YAML_PATH) as f:
        prereg = yaml.safe_load(f)
    D = prereg["data"]

    # -----------------------------------------------------------------------
    # Frozen symbolic kernel.
    # -----------------------------------------------------------------------
    Delta = 6 * sp.log(sp.Rational(3, 2))
    Dsq2 = Delta**2 / 2                     # = 18 log(3/2)^2 = 2.959235170076978
    sigma = sp.symbols("sigma", real=True)
    x1, x2, t, la = sp.symbols("x1 x2 t la", real=True)
    C1, cg, k1, k2, k4 = sp.symbols("C1 c_g k1 k2 k4", positive=True)
    B1, a0, th_i = sp.symbols("B1 alpha0 theta_i", positive=True)

    # Native trajectories, each in its OWN frozen clock (v99/v425/v159/v632):
    u_pole = C1 * sp.exp(Delta * (x1 + cg))          # frozen gauge t_v99 = x1 + const
    q_pole = (5 - 2 * u_pole) / (1 - u_pole)         # v99 Moebius flow, fixed pts {2,5}
    y_boltz = B1 * sp.exp(-Delta * x2)               # v425 contraction (2/3)^6 / beta e-fold
    y_qcd = a0 / (1 + 7 * a0 * t / (2 * sp.pi))      # 1-loop b0 = 7 Riccati flow
    y_relic = th_i + 0 * la                          # frozen constant (identity element)

    exports = {"F_pole": (q_pole, x1), "F_Boltzmann": (y_boltz, x2),
               "F_QCD": (y_qcd, t), "F_relic": (y_relic, la)}

    # Frozen affine dictionaries into sigma (slopes -1, -1, +1, -1):
    dicts = {"F_pole": -sigma + k1, "F_Boltzmann": -sigma + k2,
             "F_QCD": sigma, "F_relic": -sigma + k4}

    # -----------------------------------------------------------------------
    # FTC.01 -- dictionary validity (data-driven, floats; frozen tolerances).
    # -----------------------------------------------------------------------
    print("-" * 78)
    print("FTC.01 dictionary validity (data legs; floats enter HERE only)")
    print("-" * 78)

    # FTC.01.K -- Koide base point + scheme check (PDG 2024 pole masses frozen in YAML).
    k = D["koide"]
    me, mmu, mtau = k["m_e_MeV"], k["m_mu_MeV"], k["m_tau_MeV"]
    Q_exp = (me + mmu + mtau) / (math.sqrt(me) + math.sqrt(mmu) + math.sqrt(mtau)) ** 2
    dm = 1e-4  # numerical derivative step for the m_tau error propagation [MeV]
    Qp = (me + mmu + mtau + dm) / (math.sqrt(me) + math.sqrt(mmu) + math.sqrt(mtau + dm)) ** 2
    sigma_Q = abs(Qp - Q_exp) / dm * 0.09
    pull = (Q_exp - 2.0 / 3.0) / sigma_Q
    q_exp = 3 * Q_exp
    sigma_q = 3 * sigma_Q
    ftc01k_base = abs(q_exp - 2) <= 3 * sigma_q
    check("FTC.01.K base point: q_exp = %.10f, |q_exp - 2| = %.3e <= 3*sigma_q = %.3e "
          "(frozen tolerance); Q_exp = %.10f (frozen record %.10f), pull = %+.3f sigma "
          "(frozen record %+.3f)"
          % (q_exp, abs(q_exp - 2), 3 * sigma_q, Q_exp, k["frozen_check_values"]["Q_exp"],
             pull, k["frozen_check_values"]["pull_vs_two_thirds"]),
          ftc01k_base and abs(Q_exp - k["frozen_check_values"]["Q_exp"]) < 1e-9
          and abs(pull - k["frozen_check_values"]["pull_vs_two_thirds"]) < 0.01)
    r = k["scheme_check"]
    Q_run = (r["m_e_run_MeV"] + r["m_mu_run_MeV"] + r["m_tau_run_MeV"]) / (
        math.sqrt(r["m_e_run_MeV"]) + math.sqrt(r["m_mu_run_MeV"])
        + math.sqrt(r["m_tau_run_MeV"])) ** 2
    ratio = abs(Q_run - 2.0 / 3.0) / abs(Q_exp - 2.0 / 3.0)
    ftc01k_scheme = abs(Q_run - 2.0 / 3.0) > 10 * abs(Q_exp - 2.0 / 3.0)
    check("FTC.01.K scheme check: Q_run(M_Z) = %.7f, |Q_run - 2/3| = %.3e = %.0f x "
          "|Q_pole - 2/3| > 10x (frozen bar) -- the on-shell/proper-time clock "
          "assignment is the right chart, the running chart fails it"
          % (Q_run, abs(Q_run - 2.0 / 3.0), ratio), ftc01k_scheme)
    ftc01k = ftc01k_base and ftc01k_scheme

    # FTC.01.B -- radiation certificate + g_*s chart consistency on the washout window.
    gstar = read_csv(GSTAR_CSV)          # T, g_rho, g_rho_err, g_s, g_s_err
    M_R = V_EW**2 / (M3_EV * 1e-9)
    M1 = M_R * PHI0**4
    T_win = [M1 / 10.0, M1]              # washout window z = M_1*beta in [1, 10]
    gs_lo = loglog_interp(gstar, T_win[0], yi=3)
    gs_hi = loglog_interp(gstar, T_win[1], yi=3)
    slope_B = abs(math.log(gs_hi / gs_lo) / math.log(T_win[1] / T_win[0]))
    drift_B = slope_B / 3.0              # entropy-chart slope contamination
    neff = D["boltzmann"]["radiation_certificate"]
    neff_pull = abs(N_EFF_SM - 2.99) / 0.17
    ftc01b = (drift_B <= 0.15) and (neff_pull <= 2.0)
    check("FTC.01.B: washout window T in [%.3e, %.3e] GeV (M_1 = %.3e GeV, affine "
          "offset only); g_*s = %.4f..%.4f, |dln g_*s/dln T| = %.2e, entropy-chart "
          "drift %.2e <= 0.15 (frozen slope-tolerance class); radiation certificate "
          "N_eff = 2.99 +- 0.17 vs SM 3.044: %.2f sigma"
          % (T_win[0], T_win[1], M1, gs_lo, gs_hi, slope_B, drift_B, neff_pull),
          ftc01b, "certificate frozen in YAML: %s" % neff)

    # FTC.01.Q -- 1-loop overlay within 10% on [m_t, 1 TeV].
    qd = D["qcd"]
    a_mz, mz, mt = qd["alpha_s_MZ"], qd["M_Z_GeV"], qd["m_t_GeV"]
    a_mt_1l = 1.0 / (1.0 / a_mz + (23.0 / 3.0) / (2 * math.pi) * math.log(mt / mz))
    chain_ok = abs(a_mt_1l - float(qd["frozen_chain"].split(":")[-1])) < 1e-9
    check("FTC.01.Q frozen chain reproduced: alpha_s^(1l)(m_t) = %.10f (frozen "
          "0.1080741169; b0 = 23/3 leg M_Z -> m_t)" % a_mt_1l, chain_ok)
    alphas = read_csv(ALPHAS_CSV)        # Q, alpha, lo, hi
    lo_w, hi_w = qd["overlay_window_GeV"]
    devs = []
    for row in alphas:
        Q = row[0]
        if lo_w - 1e-9 <= Q <= hi_w + 1e-9:
            a1l = a_mt_1l / (1.0 + 7.0 * a_mt_1l * math.log(Q / mt) / (2 * math.pi))
            devs.append((abs(a1l - row[1]) / row[1], Q, a1l, row[1]))
    max_dev, Qm, a1m, adm = max(devs)
    ftc01q = chain_ok and max_dev <= 0.10
    check("FTC.01.Q overlay: max |alpha_1loop - alpha_data|/alpha_data = %.4f at "
          "Q = %.1f GeV (1-loop %.6f vs 4-loop PDG %.6f; %d grid points on "
          "[%.2f, %.0f]) <= 0.10 (frozen tolerance, honestly covering the >= 2-loop "
          "truncation)" % (max_dev, Qm, a1m, adm, len(devs), lo_w, hi_w), ftc01q)

    # FTC.01.R -- relic entropy-chart slope at the frozen onset 3H(T_osc) = m_a.
    M_scal = (1.0 / (8 * math.pi)) ** 3.5 * MBAR
    f_a = M_scal / (2 * DIM_SPLUS * 4)   # = M_scal/128 (v185)
    m_a_GeV = 5.70 * (1e12 / f_a) * 1e-15  # 5.70 ueV * (1e12/f_a), in GeV
    lo_T, hi_T = 1.0, 1e4

    def hubble3(T):
        g_rho = loglog_interp(gstar, T, yi=1)
        return 3.0 * math.sqrt(math.pi**2 * g_rho / 90.0) * T * T / MBAR

    for _ in range(200):
        mid = math.sqrt(lo_T * hi_T)
        if hubble3(mid) < m_a_GeV:
            lo_T = mid
        else:
            hi_T = mid
    T_osc = math.sqrt(lo_T * hi_T)
    gs0 = gstar[0][3]                    # low-T plateau g_*s(T0) = 3.9309363 (const offset)

    def ln_a_of_T(T):                    # adiabatic chart g_*s T^3 a^3 = const (offset free)
        return -math.log(T) - (1.0 / 3.0) * math.log(loglog_interp(gstar, T, yi=3) / gs0)

    lna_osc = ln_a_of_T(T_osc)
    n_pts, half = 201, 0.5               # onset window: ln a in [lna_osc - 0.5, lna_osc + 0.5]
    Ts = [T_osc * math.exp(1.2 * (i / (n_pts - 1) - 0.5)) for i in range(n_pts)]
    pts = sorted((ln_a_of_T(T), math.log(T / mz)) for T in Ts)
    worst = 0.0
    for i in range(1, len(pts) - 1):
        if abs(pts[i][0] - lna_osc) <= half:
            dslope = (pts[i + 1][1] - pts[i - 1][1]) / (pts[i + 1][0] - pts[i - 1][0])
            worst = max(worst, abs(dslope + 1.0))
    ftc01r = worst <= 0.15
    check("FTC.01.R: onset 3H(T_osc) = m_a (m_a = %.3f ueV from f_a = M_scal/128 = "
          "%.4e GeV, v185) gives T_osc = %.2f GeV; entropy-chart slope max "
          "|dsigma/dln a + 1| = %.4f over ln a in [onset - 0.5, onset + 0.5] <= 0.15 "
          "(frozen tolerance)" % (m_a_GeV * 1e15, f_a, T_osc, worst), ftc01r)
    # informational only (no adjudication): worst entropy-chart drift anywhere on the table
    worst_any, at_T = 0.0, 0.0
    for i in range(1, len(gstar) - 1):
        dlg = math.log(gstar[i + 1][3] / gstar[i - 1][3])
        dlT = math.log(gstar[i + 1][0] / gstar[i - 1][0])
        s = (dlg / dlT) / 3.0
        d = abs(s / (1.0 + s))           # |dsigma/dln a + 1| via the chain rule
        if d > worst_any:
            worst_any, at_T = d, gstar[i][0]
    print("       [info] worst entropy-chart drift anywhere on the table: "
          "|dsigma/dln a + 1| = %.3f at T = %.3f GeV (QCD crossover) -- the frozen "
          "onset at %.1f GeV sits far above it" % (worst_any, at_T, T_osc))

    construction_ok = ftc01k and ftc01b and ftc01q and ftc01r

    # -----------------------------------------------------------------------
    # FTC.02 -- THE one-class test (symbolic; the contract itself).
    # -----------------------------------------------------------------------
    print("-" * 78)
    print("FTC.02 the one-class test (sympy-exact transport; frozen dictionaries)")
    print("-" * 78)
    S_sigma = {}
    for name in ("F_pole", "F_Boltzmann", "F_QCD"):
        y, x = exports[name]
        S_sigma[name] = sp.simplify(schwarzian(y.subs(x, dicts[name]), sigma))
    check("FTC.02 seam transport exact: {q,sigma} = {y_B,sigma} = -Delta^2/2 = "
          "-18 log(3/2)^2 = %.15f (slope^2 = 1, cocycle term 0 for affine h)"
          % float(-Dsq2),
          sp.simplify(S_sigma["F_pole"] + Dsq2) == 0
          and sp.simplify(S_sigma["F_Boltzmann"] + Dsq2) == 0)
    check("FTC.02 QCD transport exact: {alpha_s,sigma} = 0 (identity dictionary; "
          "Moebius flow stays Moebius)", sp.simplify(S_sigma["F_QCD"]) == 0)
    diff_pair = sp.simplify(S_sigma["F_QCD"] - S_sigma["F_pole"])
    one_class = (sp.simplify(S_sigma["F_pole"] - S_sigma["F_Boltzmann"]) == 0
                 and diff_pair == 0)
    check("FTC.02 FTC.P1 one-class prediction: transported Schwarzians all equal "
          "-- %s (symbolic difference QCD - seam = %s = %.15f, EXACTLY nonzero)"
          % ("YES" if one_class else "NO", diff_pair, float(diff_pair)),
          not one_class if diff_pair != 0 else one_class,
          "the prediction FTC.P1 %s" % ("holds" if one_class else "FAILS -- contract dies"))

    # -----------------------------------------------------------------------
    # FTC.03 -- degeneracy honesty + K3 single-clock structural assertion.
    # -----------------------------------------------------------------------
    print("-" * 78)
    print("FTC.03 degeneracy honesty + K3 single-clock assertion (structural)")
    print("-" * 78)
    check("FTC.03 relic degeneracy: theta(ln a) = theta_i constant, y' = 0 "
          "identically -- jets degenerate, NO Schwarzian, channel scored on "
          "kills/dictionary only (frozen honesty clause)",
          sp.diff(y_relic, la) == 0)
    clock_syms = {x1, x2, t, la, sigma}
    k3_fired = False
    for name, (y, x) in exports.items():
        used = y.free_symbols & clock_syms
        ok = used <= {x}
        k3_fired = k3_fired or not ok
        check("FTC.03 K3 watch %s: export references exactly one clock (%s)"
              % (name, sorted(str(s) for s in used) or "constant"), ok)

    # -----------------------------------------------------------------------
    # Controls FTC.C1 / C2 / C3.
    # -----------------------------------------------------------------------
    print("-" * 78)
    print("controls (C1 calibration must pass, C2 swap must fail, C3 frame must pass)")
    print("-" * 78)
    S_nat = {n: (None if n == "F_relic" else sp.simplify(schwarzian(*exports[n])))
             for n in exports}
    check("FTC.C1 calibration: identity dictionaries reproduce the v578 native "
          "quadruple {-Delta^2/2, -Delta^2/2, 0, degenerate} EXACTLY",
          sp.simplify(S_nat["F_pole"] + Dsq2) == 0
          and sp.simplify(S_nat["F_Boltzmann"] + Dsq2) == 0
          and S_nat["F_QCD"] == 0 and S_nat["F_relic"] is None)
    S_swap = sp.simplify(schwarzian(q_pole.subs(x1, dicts["F_QCD"]), sigma))
    check("FTC.C2 swap control: QCD dictionary (identity, slope +1) on the Koide "
          "channel still leaves {q,sigma} = -Delta^2/2 != 0 = {alpha_s,sigma} -- "
          "the class split IS detected (the statistic cannot trivially pass)",
          sp.simplify(S_swap + Dsq2) == 0 and sp.simplify(S_swap - S_sigma["F_QCD"]) != 0)
    frame_ok = True
    for name in ("F_pole", "F_Boltzmann", "F_QCD"):
        y, x = exports[name]
        y_framed = (2 * y - 1) / (y + 3)             # frozen nontrivial Moebius frame
        S_f = sp.simplify(schwarzian(y_framed.subs(x, dicts[name]), sigma))
        frame_ok = frame_ok and sp.simplify(S_f - S_sigma[name]) == 0
    check("FTC.C3 frame independence: post-composing every y with the frozen "
          "Moebius map (2y-1)/(y+3) changes NO transported Schwarzian (cocycle "
          "correctness)", frame_ok)

    # -----------------------------------------------------------------------
    # Kill adjudication (frozen order: construction gate, then K3, K1; K2 guard).
    # -----------------------------------------------------------------------
    print("-" * 78)
    print("kill adjudication")
    print("-" * 78)
    k1_duty = {}
    if not one_class:
        # K1 duty: exhibit, per failing pair, the reparametrization h that WOULD
        # be needed (solving {h,sigma} = S_target - S_source * (h')^2 for the
        # QCD source S = 0: {h,sigma} = -Delta^2/2 => h = Moebius(e^{+-Delta*sigma})).
        h_req = sp.exp(Delta * sigma)
        S_h = sp.simplify(schwarzian(h_req, sigma))
        needed_ok = sp.simplify(S_h + Dsq2) == 0
        nonaffine = sp.simplify(sp.diff(h_req, sigma, 2)) != 0
        for pair in (("F_QCD", "F_pole"), ("F_QCD", "F_Boltzmann")):
            k1_duty["%s->%s" % pair] = (
                "h(sigma) = Moebius(e^{+-Delta*sigma}), Delta = 6 log(3/2): "
                "{h,sigma} = -Delta^2/2 exactly; NON-affine (h'' != 0) -- the "
                "forbidden exponential clock change, exactly the v578 u = e^{Delta t}")
        check("K1 duty: the reparametrization that WOULD be needed per failing pair "
              "is exhibited -- h = Moebius(e^{+-Delta*sigma}) with {h,sigma} = "
              "-Delta^2/2 (verified symbolically), and it is NON-AFFINE: the pass "
              "would require exactly the freedom the freeze forbids",
              needed_ok and nonaffine)
        check("K1 fired: NO-COMMON-CONNECTION -- with clocks and dictionaries "
              "exactly as frozen, the transported Schwarzians differ symbolically "
              "({-Delta^2/2, -Delta^2/2, 0}); no tolerance involved, the kernel is "
              "exact", True)
    check("K2 guard: executed against the byte-frozen YAML (sha256 %s...); NO "
          "post-freeze deviation of any gauge, dictionary, slope, xi, mu_0, scheme, "
          "window or frame was applied -- K2 does not fire (the exhibited h above "
          "is the deviation a pass WOULD need, i.e. any pass is K2-forbidden)"
          % YAML_SHA256[:12], True)
    check("K3 guard: every channel export is a function of exactly one clock "
          "(structural assertion above) -- K3 does not fire", not k3_fired)

    # -----------------------------------------------------------------------
    # Verdict (frozen enum).
    # -----------------------------------------------------------------------
    if not construction_ok:
        verdict = "CONSTRUCTION-FAIL"
    elif k3_fired:
        verdict = "SECOND-CLOCK-NEEDED"
    elif one_class:
        verdict = "ONE-CLASS"
    else:
        verdict = "NO-COMMON-CONNECTION"
    matches_prior = (verdict == "NO-COMMON-CONNECTION")

    n_fail = sum(1 for c in CHECKS if not c["ok"])
    print("\nVERDICT: %s -- %s the frozen prior (prereg_expected: K1 kill)"
          % (verdict, "MATCHES" if matches_prior else "*** DOES NOT MATCH ***"))
    print("transported Schwarzians on sigma: F_pole = F_Boltzmann = -Delta^2/2 = "
          "%.15f, F_QCD = 0, F_relic degenerate" % float(-Dsq2))
    print("checks: %d, failures: %d" % (len(CHECKS), n_fail))
    print("elapsed: %.1f s" % (time.time() - T_START))

    out = {
        "contract": "FTRANSFER.CLOCKS.01",
        "executed": time.strftime("%Y-%m-%d %H:%M:%S"),
        "execution_surface": "experiments-only (typed [X]; no vN module, no marker move)",
        "prereg_yaml_sha256": yaml_hash,
        "data_tables": frozen_data_hashes,
        "transported_schwarzians_sigma": {
            "F_pole": str(S_sigma["F_pole"]),
            "F_Boltzmann": str(S_sigma["F_Boltzmann"]),
            "F_QCD": str(S_sigma["F_QCD"]),
            "F_relic": "degenerate",
            "numeric_seam": -float(Dsq2), "numeric_qcd": 0.0,
        },
        "ftc01": {
            "K": {"pass": ftc01k, "q_exp": q_exp, "abs_dev": abs(q_exp - 2),
                  "bar_3sigma_q": 3 * sigma_q, "Q_run": Q_run, "scheme_ratio": ratio},
            "B": {"pass": ftc01b, "M1_GeV": M1, "window_GeV": T_win,
                  "gstar_s": [gs_lo, gs_hi], "chart_drift": drift_B,
                  "neff_pull_sigma": neff_pull},
            "Q": {"pass": ftc01q, "alpha_mt_1loop": a_mt_1l, "max_rel_dev": max_dev,
                  "at_Q_GeV": Qm, "bar": 0.10},
            "R": {"pass": ftc01r, "T_osc_GeV": T_osc, "m_a_ueV": m_a_GeV * 1e15,
                  "max_slope_dev": worst, "bar": 0.15,
                  "info_worst_anywhere": {"dev": worst_any, "T_GeV": at_T}},
        },
        "one_class": one_class,
        "kills": {"K1_fired": (not one_class) and construction_ok and not k3_fired,
                  "K2_fired": False, "K3_fired": k3_fired,
                  "K1_duty_reparametrizations": k1_duty},
        "verdict": verdict,
        "matches_frozen_prior": matches_prior,
        "checks_total": len(CHECKS), "checks_failed": n_fail,
        "checks": CHECKS,
    }
    _ = out   # promoted module: adjudication only -- the experiments-
    # side executor remains the writer of record for the results JSON
    print("(promoted module: results JSON not rewritten; writer of "
          "record = experiments/ftransfer-clocks/run_clocks_executor.py)")
    return 1 if n_fail else 0


_run_part1 = main


def _run_part2():
    # PART 2 -- ftransfer_projective_groupoid_probe.py (verbatim; module-
    # level names local to this function scope; HERE re-pointed, JSON
    # write dropped as declared)
    # (the probe's `from __future__ import annotations` is subsumed by the
    # module-level import above -- a __future__ import is illegal inside a
    # function body)
    import hashlib
    import json
    import math
    import os
    import time

    import sympy as sp

    T_START = time.time()
    HERE = os.path.abspath(os.path.join(os.path.dirname(
        os.path.abspath(__file__)), "..", "experiments", "ftransfer-clocks"))

    YAML_PATH = os.path.join(HERE, "hypotheses", "ftransfer_clocks_v1.yaml")
    YAML_SHA256 = "880224f76380c77dce2c1e3d7651bccc9e1619e74c60b7e15326ee0ee2bbf4d0"
    GSTAR_CSV = os.path.join(HERE, "data", "gstar_saikawa_shirai_2018.csv")
    GSTAR_SHA256 = "8ae2a4fec098fd68d3a469fbf2b7806ee1630f5595498a3e6cf2abca2d79b939"
    ALPHAS_CSV = os.path.join(HERE, "data", "alphas_pdg2024_running.csv")
    ALPHAS_SHA256 = "2ca6332dd1ee0caa089f64be58e90a8c916c94bbe612125eca41da50c33a2ac2"

    # Corpus anchors (identical to the executed contract; affine offsets only).
    PHI0 = 0.053171952176845526
    V_EW, M3_EV, MBAR = 174.0, 0.05, 2.435323e18
    M_Z, M_T, M_TAU = 91.1880, 172.57, 1.77693      # GeV
    DIM_SPLUS = 16

    CHECKS = []


    def check(name, ok, detail=""):
        CHECKS.append({"name": name, "ok": bool(ok), "detail": detail})
        print("[%s] %s%s" % ("PASS" if ok else "FAIL", name, (": " + detail) if detail else ""))
        return bool(ok)


    def sha256_file(path):
        h = hashlib.sha256()
        with open(path, "rb") as f:
            for chunk in iter(lambda: f.read(65536), b""):
                h.update(chunk)
        return h.hexdigest()


    def schwarzian(y, x):
        y1, y2, y3 = sp.diff(y, x), sp.diff(y, x, 2), sp.diff(y, x, 3)
        return y3 / y1 - sp.Rational(3, 2) * (y2 / y1) ** 2


    def cross_ratio(a, b, c, d):
        return ((a - c) * (b - d)) / ((b - c) * (a - d))


    def read_csv(path):
        rows = []
        with open(path) as f:
            for line in f:
                line = line.strip()
                if line and not line.startswith("#"):
                    rows.append([float(v) for v in line.split(",")])
        return rows


    def loglog_interp(table, x, yi):
        lx = math.log(x)
        lo, hi = 0, len(table) - 1
        while hi - lo > 1:
            mid = (lo + hi) // 2
            if table[mid][0] <= x:
                lo = mid
            else:
                hi = mid
        x0, x1 = math.log(table[lo][0]), math.log(table[hi][0])
        y0, y1 = math.log(table[lo][yi]), math.log(table[hi][yi])
        return math.exp(y0 + (y1 - y0) * (lx - x0) / (x1 - x0))


    def main() -> int:
        print("=" * 78)
        print("F_TRANSFER PROJECTIVE GROUPOID -- the fibered-functor probe (post-K1)")
        print("=" * 78)

        # -- freeze guards ------------------------------------------------------
        ok_y = check("G0 prereg YAML byte-freeze reused", sha256_file(YAML_PATH) == YAML_SHA256)
        ok_g = check("G0 frozen g_*s table hash matches executed contract",
                     sha256_file(GSTAR_CSV) == GSTAR_SHA256)
        ok_a = check("G0 frozen alpha_s table hash matches executed contract",
                     sha256_file(ALPHAS_CSV) == ALPHAS_SHA256)
        if not (ok_y and ok_g and ok_a):
            print("\nVERDICT: ABORT -- freeze guard failed")
            return 1

        # -- frozen kernel ------------------------------------------------------
        Delta = 6 * sp.log(sp.Rational(3, 2))
        Dsq2 = Delta**2 / 2
        sigma = sp.symbols("sigma", real=True)
        x1, x2, t, la, n = sp.symbols("x1 x2 t la n", real=True)
        C1, cg, k1, k2, k4, B1, a0, th_i = sp.symbols(
            "C1 c_g k1 k2 k4 B1 alpha0 theta_i", positive=True)

        q_pole = (5 - 2 * C1 * sp.exp(Delta * (x1 + cg))) / (1 - C1 * sp.exp(Delta * (x1 + cg)))
        y_boltz = B1 * sp.exp(-Delta * x2)
        y_qcd = a0 / (1 + 7 * a0 * t / (2 * sp.pi))
        exports = {"F_pole": (q_pole, x1), "F_Boltzmann": (y_boltz, x2), "F_QCD": (y_qcd, t)}
        dicts = {"F_pole": (x1, -sigma + k1, -1), "F_Boltzmann": (x2, -sigma + k2, -1),
                 "F_QCD": (t, sigma, +1), "F_relic": (la, -sigma + k4, -1)}
        # inverse dictionaries sigma(clock) for pushing anchor ticks forward:
        inv_dicts = {"F_pole": (k1 - x1).subs(x1, n), "F_Boltzmann": (k2 - x2).subs(x2, n),
                     "F_QCD": n, "F_relic": (k4 - la).subs(la, n)}

        # =======================================================================
        # G1 -- the shared discrete layer.
        # =======================================================================
        print("-" * 78)
        print("G1 the shared discrete layer (make-or-break)")
        print("-" * 78)
        base_sym = {"F_pole": sp.symbols("b1", real=True), "F_Boltzmann": sp.symbols("b2", real=True),
                    "F_QCD": sp.symbols("b3", real=True), "F_relic": sp.symbols("b4", real=True)}
        cr_sym, deck_sym = {}, {}
        for name in ("F_pole", "F_Boltzmann", "F_QCD", "F_relic"):
            b = base_sym[name]
            imgs = [inv_dicts[name].subs(n, b + j) for j in range(4)]     # ticks {0,1,2,3}
            cr = sp.simplify(cross_ratio(*imgs))
            cr_sym[name] = cr
            deck_sym[name] = sp.simplify(imgs[1] - imgs[0])               # one e-fold in sigma
        g1a = all(sp.simplify(cr_sym[nm] - sp.Rational(4, 3)) == 0 for nm in cr_sym)
        check("G1a cross-ratio (symbolic): CR(dictionary images of ticks {0,1,2,3}) "
              "= 4/3 EXACTLY for ALL FOUR channels (offsets k_i and base points drop "
              "out symbolically)", g1a,
              "CR = %s" % {nm: str(cr_sym[nm]) for nm in cr_sym})

        # data legs
        gstar = read_csv(GSTAR_CSV)
        sig_star = math.log(M_TAU / M_Z)
        M1 = (V_EW**2 / (M3_EV * 1e-9)) * PHI0**4
        cr_data = {}
        cr_data["F_pole"] = cross_ratio(*[-(-sig_star + j) for j in range(4)])
        cr_data["F_Boltzmann"] = cross_ratio(*[-(math.log(M_Z / M1) + j) for j in range(4)])
        cr_data["F_QCD"] = cross_ratio(*[math.log(M_T / M_Z) + j * math.log(1000.0 / M_T) / 3.0
                                         for j in range(4)])
        # relic through the frozen table: invert ln a(T), 4 points across the window
        m_a_GeV = 5.70 * (1e12 / ((1.0 / (8 * math.pi)) ** 3.5 * MBAR / 128.0)) * 1e-15
        lo_T, hi_T = 1.0, 1e4
        for _ in range(200):
            mid = math.sqrt(lo_T * hi_T)
            g_rho = loglog_interp(gstar, mid, 1)
            if 3.0 * math.sqrt(math.pi**2 * g_rho / 90.0) * mid * mid / MBAR < m_a_GeV:
                lo_T = mid
            else:
                hi_T = mid
        T_osc = math.sqrt(lo_T * hi_T)
        gs0 = gstar[0][3]

        def ln_a_of_T(T):
            return -math.log(T) - (1.0 / 3.0) * math.log(loglog_interp(gstar, T, 3) / gs0)

        def T_of_ln_a(lna):
            tl, th = 1e-2, 1e6
            for _ in range(200):
                tm = math.sqrt(tl * th)
                if ln_a_of_T(tm) > lna:      # ln a decreases with T
                    tl = tm
                else:
                    th = tm
            return math.sqrt(tl * th)

        lna_osc = ln_a_of_T(T_osc)
        lnas = [lna_osc - 0.5 + j / 3.0 for j in range(4)]
        sig_relic = [math.log(T_of_ln_a(v) / M_Z) for v in lnas]
        cr_data["F_relic"] = cross_ratio(*sig_relic)
        relic_slope = abs((sig_relic[-1] - sig_relic[0]) / (lnas[-1] - lnas[0]))
        g1b = (all(abs(cr_data[nm] - 4.0 / 3.0) <= 1e-9
                   for nm in ("F_pole", "F_Boltzmann", "F_QCD"))
               and abs(cr_data["F_relic"] - 4.0 / 3.0) <= 0.15)
        check("G1b cross-ratio (data): pole %.12f / Boltzmann %.12f / QCD %.12f "
              "(bar 1e-9) and relic THROUGH the frozen g_*s table %.6f, |dev| = %.2e "
              "<= 0.15 (frozen bar; window ln a in [onset-0.5, onset+0.5], "
              "T_osc = %.2f GeV)"
              % (cr_data["F_pole"], cr_data["F_Boltzmann"], cr_data["F_QCD"],
                 cr_data["F_relic"], abs(cr_data["F_relic"] - 4.0 / 3.0), T_osc), g1b)

        g1c = (all(sp.simplify(sp.Abs(deck_sym[nm]) - 1) == 0
                   for nm in ("F_pole", "F_Boltzmann", "F_QCD", "F_relic"))
               and 0.85 <= relic_slope <= 1.15)
        check("G1c deck unit: one clock e-fold -> |Delta sigma| = 1 EXACTLY for all "
              "four affine dictionaries (symbolic: %s); relic measured mean slope "
              "%.4f in [0.85, 1.15] (frozen window)"
              % ({nm: str(deck_sym[nm]) for nm in deck_sym}, relic_slope), g1c)

        orientations = {nm: dicts[nm][2] for nm in dicts}
        deck_cls, target_ok = {}, True
        for nm, s in orientations.items():
            M = sp.Matrix([[1, s], [0, 1]])                # unit translation in sigma
            deck_cls[nm] = sp.simplify(sp.trace(M) ** 2 - 4 * M.det())
        g1d = (all(v == 0 for v in deck_cls.values())
               and sp.simplify(sp.Matrix([[1, 1], [0, 1]]).inv()
                               - sp.Matrix([[1, -1], [0, 1]])) == sp.zeros(2)
               and target_ok)
        check("G1d deck class + objects: the pushed deck generator is the unit "
              "translation [[1,+-1],[0,1]], tr^2 - 4 det = 0 EXACTLY (parabolic -- "
              "the v632 'one common parabolic action on the discrete half'); all four "
              "dictionaries target the ONE sigma-line; orientations (%+d,%+d,%+d,%+d) "
              "identified under inverse-conjugation (translation ~ its inverse in PGL2)"
              % (orientations["F_pole"], orientations["F_Boltzmann"],
                 orientations["F_QCD"], orientations["F_relic"]), g1d)
        g1 = g1a and g1b and g1c and g1d

        # =======================================================================
        # G2 -- the obstruction cocycle.
        # =======================================================================
        print("-" * 78)
        print("G2 the obstruction cocycle (relic EXCLUDED by frozen convention)")
        print("-" * 78)
        S = {}
        S_expr = {}
        for name, (y, x) in exports.items():
            expr = schwarzian(y.subs(x, dicts[name][1]), sigma)
            S_expr[name] = expr
            S[name] = sp.simplify(expr)
        names3 = ["F_pole", "F_Boltzmann", "F_QCD"]
        omega = {(i, j): sp.simplify(S[i] - S[j]) for i in names3 for j in names3}
        g2a = all(sp.simplify(omega[(i, j)] + omega[(j, i)]) == 0
                  for i in names3 for j in names3)
        check("G2a antisymmetry: omega_ij = -omega_ji EXACT on all 9 pairs", g2a)

        coc = all(sp.simplify(omega[(i, j)] + omega[(j, k)] - omega[(i, k)]) == 0
                  for i in names3 for j in names3 for k in names3)
        dconst = all(sp.simplify(sp.diff(S_expr[nm], sigma)) == 0 for nm in names3)
        # numeric spot checks: 5 sigma points per frozen channel window
        spots = {"F_pole": [sig_star + 3.0 * j / 4 for j in range(5)],
                 "F_Boltzmann": [math.log(M_Z / M1) + math.log(10.0) * j / 4 for j in range(5)],
                 "F_QCD": [math.log(M_T / M_Z)
                           + math.log(1000.0 / M_T) * j / 4 for j in range(5)]}
        subs_num = {C1: sp.Rational(37, 100), cg: sp.Rational(21, 100),
                    k1: sp.Rational(13, 10), k2: sp.Rational(-7, 10),
                    B1: sp.Rational(21, 10), a0: sp.Rational(118, 1000)}
        # Spot evaluation at 50 digits (sympy evalf) -- the frozen kernel method
        # ('all kernel steps symbolic/sympy exact; floats only at the data
        # interfaces'; this is a kernel-side check).  FIRST-RUN RECORD (2026-08-05,
        # radical honesty): the initial implementation evaluated these spots with
        # float64 lambdify, VIOLATING the frozen method, and showed max dev 3.0e-9
        # (double-precision cancellation in the Moebius-of-exponential expressions
        # at sigma ~ -18); the frozen bar 1e-12 is UNCHANGED, only the arithmetic
        # was conformed to the frozen method.
        max_spot = 0.0
        for nm in names3:
            diff_expr = (S_expr[nm] - S[nm]).subs(subs_num)
            for sv in spots[nm]:
                dev = abs(sp.N(diff_expr.subs(sigma, sp.Float(sv, 50)), 50))
                max_spot = max(max_spot, float(dev))
        g2b = coc and dconst and max_spot <= 1e-12
        check("G2b cocycle identity EXACT (27 triples) + CONSTANT cocycle: "
              "d/dsigma of every transported Schwarzian vanishes IDENTICALLY "
              "(symbolic) and 15 numeric spot checks (sympy evalf, 50 digits, the "
              "frozen kernel method) across the frozen windows deviate <= %.1e "
              "from the channel constants (bar 1e-12) -- the obstruction is a "
              "constant cocycle, not a running function" % max_spot, g2b)

        vals = {"omega(pole,B)": omega[("F_pole", "F_Boltzmann")],
                "omega(pole,QCD)": omega[("F_pole", "F_QCD")],
                "omega(B,QCD)": omega[("F_Boltzmann", "F_QCD")]}
        g2c = (sp.simplify(vals["omega(pole,B)"]) == 0
               and sp.simplify(vals["omega(pole,QCD)"] + Dsq2) == 0
               and sp.simplify(vals["omega(B,QCD)"] + Dsq2) == 0)
        check("G2c values: omega(pole,B) = 0, omega(pole,QCD) = omega(B,QCD) = "
              "-Delta^2/2 = -18 log^2(3/2) = %.15f -- the cocycle takes values "
              "EXACTLY in {0, +-Delta^2/2}, closed form" % float(-Dsq2), g2c)
        g2 = g2a and g2b and g2c

        # =======================================================================
        # G3 -- the classification against the predeclared marker.
        # =======================================================================
        print("-" * 78)
        print("G3 classification (marker predeclared in the docstring)")
        print("-" * 78)
        coset = {nm: ("seam" if sp.simplify(S[nm] + Dsq2) == 0
                      else ("rg" if sp.simplify(S[nm]) == 0 else "OTHER")) for nm in names3}
        g3 = (coset["F_pole"] == "seam" and coset["F_Boltzmann"] == "seam"
              and coset["F_QCD"] == "rg")
        check("G3 the two-coset split matches the predeclared marker: thermal/"
              "proper-time clocks {tau, beta} -> coset -Delta^2/2 (%s, %s), RG clock "
              "{log mu} -> coset 0 (%s); relic {log a} degenerate, NOT classified "
              "(predeclared honesty); torsor difference between cosets = Delta^2/2 "
              "= %.15f exactly"
              % (coset["F_pole"], coset["F_Boltzmann"], coset["F_QCD"], float(Dsq2)), g3)

        # =======================================================================
        # G4 -- controls (must fire).
        # =======================================================================
        print("-" * 78)
        print("G4 controls (all three must fire)")
        print("-" * 78)
        # G4a wrong slope 2 on the Koide channel
        S_wrong = sp.simplify(schwarzian(q_pole.subs(x1, -2 * sigma + k1), sigma))
        deck_wrong = sp.simplify((k1 - (-2 * sigma + k1)).subs(sigma, 1))   # image of 1 e-fold
        in_set = any(sp.simplify(S_wrong - v) == 0 for v in (sp.S.Zero, Dsq2, -Dsq2))
        g4a = (sp.simplify(S_wrong + 4 * Dsq2) == 0) and (deck_wrong != 1) and not in_set
        check("G4a wrong-slope control FIRES: slope 2 breaks the deck unit "
              "(|Delta sigma| = 2 != 1) AND scales the Schwarzian by slope^2 = 4 "
              "onto -2 Delta^2 = %.6f -- OUTSIDE the frozen value set {0, +-Delta^2/2}"
              % float(-4 * Dsq2), g4a)
        # G4b scrambled anchors (frozen scramble: swap last two pole anchors)
        b = base_sym["F_pole"]
        imgs = [inv_dicts["F_pole"].subs(n, b + j) for j in (0, 1, 3, 2)]
        cr_scr = sp.simplify(cross_ratio(*imgs))
        g4b = sp.simplify(cr_scr - sp.Rational(3, 4)) == 0 and cr_scr != sp.Rational(4, 3)
        check("G4b scrambled-anchor control FIRES: swapping the last two F_pole "
              "anchors gives CR = %s != 4/3 -- the cross-ratio gate detects anchor "
              "misalignment" % cr_scr, g4b)
        # G4c v578 Moebius clock transplanted to QCD
        S_moeb = sp.simplify(schwarzian(y_qcd.subs(t, sp.exp(Delta * sigma)), sigma))
        g4c = sp.simplify(S_moeb + Dsq2) == 0
        check("G4c Moebius-transplant control FIRES: t = e^{Delta sigma} moves the "
              "QCD Schwarzian from 0 onto -Delta^2/2 EXACTLY -- the obstruction "
              "cocycle is exactly the forbidden non-affine freedom (K1 duty "
              "transplanted)", g4c)
        g4 = g4a and g4b and g4c

        # =======================================================================
        # Verdict (frozen enum).
        # =======================================================================
        if not g1:
            verdict = "FTRANSFER-FIBERED-DEAD"
        elif g2 and g3 and g4:
            verdict = "FTRANSFER-FIBERED-CARRIES"
        else:
            verdict = "FTRANSFER-FIBERED-PARTIAL"
        failed_gates = [g for g, ok in
                        (("G1", g1), ("G2", g2), ("G3", g3), ("G4", g4)) if not ok]

        n_fail = sum(1 for c in CHECKS if not c["ok"])
        print("\nVERDICT: %s%s" % (verdict,
              "" if not failed_gates else " -- failed gates: %s" % failed_gates))
        print("base: ONE discrete parabolic deck action (unit sigma-translation, "
              "CR = 4/3); fibers: projective connections with the constant seam "
              "cocycle omega in {0, +-Delta^2/2}; classes: {tau, beta} | {log mu} | "
              "relic degenerate")
        print("checks: %d, failures: %d" % (len(CHECKS), n_fail))
        print("elapsed: %.1f s" % (time.time() - T_START))

        out = {
            "probe": "ftransfer_projective_groupoid",
            "executed": time.strftime("%Y-%m-%d %H:%M:%S"),
            "freeze": {"yaml": YAML_SHA256, "gstar": GSTAR_SHA256, "alphas": ALPHAS_SHA256},
            "discrete_layer": {
                "cross_ratio_symbolic": {nm: str(cr_sym[nm]) for nm in cr_sym},
                "cross_ratio_data": cr_data,
                "relic_mean_slope": relic_slope,
                "deck_unit": {nm: str(deck_sym[nm]) for nm in deck_sym},
                "deck_class": "parabolic unit translation (tr^2 = 4 det exact)",
                "orientations": orientations,
                "T_osc_GeV": T_osc,
            },
            "cocycle": {
                "convention": "relic excluded (degenerate; identity morphism only)",
                "values": {kk: str(sp.simplify(vv)) for kk, vv in vals.items()},
                "numeric": {"omega(pole,B)": 0.0,
                            "omega(pole,QCD)": float(-Dsq2), "omega(B,QCD)": float(-Dsq2)},
                "constant_cocycle_max_spot_dev": max_spot,
            },
            "classification": {"cosets": coset, "relic": "degenerate, not classified",
                               "torsor_difference": float(Dsq2)},
            "controls": {"G4a": g4a, "G4b": g4b, "G4c": g4c},
            "verdict": verdict,
            "checks_total": len(CHECKS), "checks_failed": n_fail,
            "checks": CHECKS,
        }
        _ = out   # promoted module: adjudication only -- the experiments-
        # side probe remains the writer of record for the results JSON
        print("(promoted module: results JSON not rewritten; writer of "
              "record = ftransfer_projective_groupoid_probe.py)")
        return 1 if n_fail else 0
    return main(), list(CHECKS)


def run():
    """run_all entry point (combined adjudication, frozen): part 1 must
    reproduce the preregistered K1-kill pattern (24 checks green incl.
    'K1 fired', verdict NO-COMMON-CONNECTION == the frozen prior); part 2
    must reproduce FTRANSFER-FIBERED-CARRIES (14 checks green)."""
    rc1 = _run_part1()
    fails1 = [c["name"] for c in CHECKS if not c["ok"]]
    k1 = any(c["name"].startswith("K1 fired") for c in CHECKS)
    part1_ok = (rc1 == 0 and not fails1 and len(CHECKS) == 24 and k1)
    print("\n[%s] PART-1 PATTERN GATE: expected 24 green checks with the "
          "K1 kill fired (NO-COMMON-CONNECTION, matches the frozen prior) "
          "-- fails: %s" % ("PASS" if part1_ok else "FAIL",
                            fails1 or "none"))
    rc2, chks2 = _run_part2()
    fails2 = [c["name"] for c in chks2 if not c["ok"]]
    part2_ok = (rc2 == 0 and not fails2 and len(chks2) == 14)
    print("\n[%s] PART-2 PATTERN GATE: expected 14 green checks "
          "(FTRANSFER-FIBERED-CARRIES) -- fails: %s"
          % ("PASS" if part2_ok else "FAIL", fails2 or "none"))
    ok = part1_ok and part2_ok
    print("\nCOMBINED ADJUDICATION: %s -- NO-COMMON-CONNECTION + "
          "FTRANSFER-FIBERED-CARRIES: the frozen external-clock contract "
          "dies on the exact K1 kill ({-Delta^2/2, -Delta^2/2, 0}, no "
          "tolerance), and the surviving architecture is the fibered "
          "functor -- ONE discrete parabolic deck action (CR = 4/3, unit "
          "sigma-translation) with the constant seam obstruction cocycle "
          "omega in {0, +-Delta^2/2}; classes {tau, beta} | {log mu} | "
          "relic degenerate.  The jet route of CONTRACT.F.01 is closed at "
          "the physical-clock level; next named step: derive the coset "
          "assignment from KMS/modular clock typing.  NO RH claim."
          % ("PASS" if ok else "FAIL"))
    return 0 if ok else 1


if __name__ == "__main__":
    raise SystemExit(run())
