scripts/verify_wave7_cellgemma_2p24_rebase.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_wave7_cellgemma_2p24_rebase.py · SHA-256: 5f31a6369f25031d…
chk("FAIL_R1_GATE31C_RECOMPUTED_PAIRED_L95_FAILED" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "gate31_evidence": _sign_receipt({**g31_a_42, "gate31c_paired_blocks": [{"block_id": f"B{i}", "open_sink_t_half_h": 28.0+0.2*i, "limited_exchange_t_half_h": 65.0+0.5*i} for i in range(6)]})})["failures"], "G43_ADV_g31c_raw_blocks_fail")
chk("FAIL_CHECK_D2_NOT_APPLICABLE_FORBIDS_EVAL_FIELDS:check_d2_challenger_gene" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d2_challenger_gene": None})["failures"], "G43_ADV_forbid_d2_none")
chk("FAIL_CHECK_D3A_NOT_ATTEMPTED_FORBIDS_EVAL_FIELDS:check_d3a_per_lot_records" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d3a_per_lot_records": None})["failures"], "G43_ADV_forbid_d3a_none")
chk("FAIL_CHECK_D3B_NOT_ATTEMPTED_FORBIDS_EVAL_FIELDS:d3b_pilot_receipt" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "d3b_pilot_receipt": None})["failures"], "G43_ADV_forbid_d3b_none")
chk("FAIL_CHECK_D2_UNREFERRED_PROLIFERATION_ELEVATION:D2-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_per_lot_records": [_mk_d2_lot(1, ki67=1.05, ref=False), _mk_d2_lot(2), _mk_d2_lot(3)]})["failures"], "G43_ADV_d2_prolif_unref")
chk("HOLD_CHECK_D2_PROLIFERATION_REFERRED:D2-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_per_lot_records": [_mk_d2_lot(1, edu=1.04, ref=True), _mk_d2_lot(2), _mk_d2_lot(3)]})["holds"], "G43_ADV_d2_prolif_ref_hold")
chk("HOLD_CANONICAL_BANK_MATERIALIZATION_MISSING" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "materialization_evidence": None})["holds"], "G43_ADV_A_requires_mat")
chk("HOLD_MISSING_R1_GATE31_EVIDENCE" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "gate31_evidence": None})["holds"], "G43_ADV_A_assembled_req_g31")
chk("FAIL_CHECK_D1_BLOQ_MUST_USE_NULL_CONCENTRATION_NOT_NUMERIC" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_residual_t3_arm_b_nM": 0.10, "check_d1_arm_b_below_lloq": True})["failures"], "G43_ADV_bloq_numeric")
chk("FAIL_CHECK_D1_NON_BLOQ_CONCENTRATION_MISSING_OR_BELOW_LLOQ" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_residual_t3_arm_b_nM": 0.10, "check_d1_arm_b_below_lloq": False})["failures"], "G43_ADV_nonbloq_lt_lloq")
g43_quant_t3b = {**g43_base, "check_d1_residual_t3_arm_b_nM": 0.45, "check_d1_arm_b_below_lloq": False}
g43_quant_t3b["check_d1_paired_assay_receipt"] = _mk_d1_unified(g43_quant_t3b)
chk(evaluate_gate43_cellgemma_guardrails_and_pilots(g43_quant_t3b)["verdict"] == "PASS_DESCRIPTIVE_PILOT_ZERO_ODDS_GY037_WARN_RETAINED", "G43_ADV_quant_t3b_pass")
chk("FAIL_CHECK_D3A_REQUIRES_AT_LEAST_3_INDEPENDENT_LOT_RECORDS" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": d3a_ok_lots[:2]})["failures"], "G43_ADV_d3a_lt3")
chk("FAIL_CHECK_D3A_NON_ZERO_PTPRC_CONTAMINATION:IEC-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [_mk_d3a_lot(1, iec_ptprc_pct=0.5), d3a_ok_lots[1], d3a_ok_lots[2]]})["failures"], "G43_ADV_d3a_ptprc")
chk("FAIL_CHECK_D3A_NO_FUNCTIONAL_TAT_REDUCTION:IEC-LOT-2" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [d3a_ok_lots[0], _mk_d3a_lot(2, chandler_tat_f3_sirna_ng_ml=95.0), d3a_ok_lots[2]]})["failures"], "G43_ADV_d3a_tat")
chk("FAIL_EPISTEMIC_TIER_MUST_BE_CELLGEMMA_IN_SILICO_PRIOR" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "evidence_tier": "clinical"})["failures"], "G43_tier")
chk("FAIL_DRAFT_D_NONZERO_LIVE_ODDS" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "live_odds_delta_pp": 0.1})["failures"], "G43_live_odds")
chk("FAIL_DRAFT_D_NONZERO_PROSPECTIVE_ODDS" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "prospective_odds_delta_pp": 0.1})["failures"], "G43_prosp_odds")
chk("FAIL_GY037_MUST_USE_REVOCABLE_WARN_SEVERITY" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "graveyard_severity": "HARD_EXCLUDE"})["failures"], "G43_warn")
chk("FAIL_CHECK_D1_ZERO_ADOPTION_AUTHORITY_VIOLATED_OR_MISSING" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_claims_adoption_authority": True})["failures"], "G43_adopt")
chk("FAIL_CHECK_D1_ARM_WASHES_MUST_BE_IDENTICAL_INT_GE_3" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_arm_a_washes": 3, "check_d1_arm_b_washes": 4})["failures"], "G43_wash")
chk("FAIL_CHECK_D1_UNDECLARED_ZM447439_REGIMEN" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_starting_zm_regimen": "CUSTOM"})["failures"], "G43_zm_reg")
chk("FAIL_CHECK_D1_ZM447439_LLOQ_EXCEEDS_0P005UM" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_zm447439_lloq_uM": 0.01})["failures"], "G43_zm_lloq")
chk("FAIL_CHECK_D1_ZM447439_ABOVE_LLOQ_OR_0P005UM" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_arm_a_zm447439_lcms_uM": 0.008})["failures"], "G43_zm_hi")
chk("FAIL_CHECK_D1_SPIKE_RECOVERY_OUT_OF_80_120" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_arm_a_spike_recovery_pct": 70.0})["failures"], "G43_spike")
chk("FAIL_CHECK_D1_UNMATCHED_HANDLING_ARMS" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_both_arms_matched_24h_nac": False})["failures"], "G43_nac")
chk("FAIL_CHECK_D1_RETAINED_ARM_T3_OUTSIDE_7_13NM_WINDOW" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_residual_t3_arm_a_nM": 5.0})["failures"], "G43_t3_a")
chk("FAIL_CHECK_D1_T3_LLOQ_INSUFFICIENT_TO_RESOLVE_RESIDUAL_LIMIT" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_t3_lloq_nM": 0.80})["failures"], "G43_t3_lloq")
chk("HOLD_CHECK_D1_T3_EXPOSURE_NOT_SEPARATED" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_residual_t3_arm_b_nM": 1.8, "check_d1_arm_b_below_lloq": False})["holds"], "G43_t3_sep")
chk("FAIL_CHECK_D1_PRE_COASSEMBLY_VASCULAR_FUNCTION_FAILED" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_pre_coassembly_vascular_function_pass": False})["failures"], "G43_vasc")
chk("HOLD_CHECK_D1_PAIRED_GSIS_NOT_RECORDED" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_paired_gsis_40_100mmhg_recorded": False})["holds"], "G43_gsis_rec")
chk("HOLD_CHECK_D1_PAIRED_ICAM1_VCAM1_FACS_NOT_RECORDED" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_paired_icam1_vcam1_facs_recorded": False})["holds"], "G43_facs_rec")
chk("FAIL_CHECK_D3_C3_MUST_REMAIN_UNTESTED" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d3_c3_explicitly_untested": False})["failures"], "G43_c3")
chk("FAIL_CHECK_D3B_UNMATCHED_TREATED_VS_NT_LOT_ID" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "d3b_pilot_receipt": _sign_receipt({**d3b_rcpt_a, "nt_control_lot_id": "OTHER"})})["failures"], "G43_d3b_lot")
chk("FAIL_CHECK_D3B_MISSING_SAME_PRODUCT_NT_SIRNA" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "d3b_pilot_receipt": _sign_receipt({**d3b_rcpt_a, "same_product_nt_sirna": False})})["failures"], "G43_d3b_nt")
chk("FAIL_CHECK_D3B_MISSING_PARENTAL_ATTRIBUTION_ARM" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "d3b_pilot_receipt": _sign_receipt({**d3b_rcpt_a, "parental_attribution_included": False})})["failures"], "G43_d3b_par")
chk("FAIL_CHECK_D3B_SHIELD_PRESERVATION_BELOW_85PCT:PDL1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "d3b_pilot_receipt": _sign_receipt({**d3b_rcpt_a, "f3_sirna_shield_by_component": {**_mk_r8_shields(pa, 91.0), "PDL1": 70.0}})})["failures"], "G43_d3b_sh")
chk("FAIL_CHECK_D3B_UNDECLARED_ASSAY_SCOPE" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "d3b_assay_scope": "MYSTERY"})["failures"], "G43_d3b_scope")
chk("FAIL_CHECK_D2_UNRECOGNIZED_CHALLENGER_GENE" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_challenger_gene": "TP53"})["failures"], "G43_d2_gene")
chk("FAIL_GATE43_UNKNOWN_OR_UNRECONCILED_FIELDS:rogue_k" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "rogue_k": 1})["failures"], "G43_unknown_key")
chk("FAIL_CHECK_D3A_F3_KD_BELOW_60PCT:IEC-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [_mk_d3a_lot(1, f3_kd_pct=45.0), d3a_ok_lots[1], d3a_ok_lots[2]]})["failures"], "G43_d3a_kd")
chk("FAIL_CHECK_D3A_CXCL10_RETENTION_BELOW_85PCT:IEC-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [_mk_d3a_lot(1, cxcl10_retention_pct=70.0), d3a_ok_lots[1], d3a_ok_lots[2]]})["failures"], "G43_d3a_cxcl10")
chk("FAIL_CHECK_D3A_CD274_RETENTION_BELOW_85PCT:IEC-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [_mk_d3a_lot(1, cd274_retention_pct=70.0), d3a_ok_lots[1], d3a_ok_lots[2]]})["failures"], "G43_d3a_cd274")
chk("FAIL_CHECK_D3A_APOPTOSIS_INCREASE:IEC-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [_mk_d3a_lot(1, cleaved_casp3_fold=1.5), d3a_ok_lots[1], d3a_ok_lots[2]]})["failures"], "G43_d3a_casp3")
chk("FAIL_CHECK_D3A_CHANDLER_CONTROLS_INVALID:IEC-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [_mk_d3a_lot(1, pos_ctrl_tat_fold=1.5), d3a_ok_lots[1], d3a_ok_lots[2]]})["failures"], "G43_d3a_ctrl")
chk("FAIL_CHECK_D3A_LOT_CONTENT_HASH_INVALID:IEC-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [{**d3a_ok_lots[0], "f3_kd_pct": 88.0}, d3a_ok_lots[1], d3a_ok_lots[2]]})["failures"], "G43_d3a_hash")
chk("FAIL_CHECK_D2_REQUIRES_AT_LEAST_3_ISOGENIC_LOT_RECORDS" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_per_lot_records": [_mk_d2_lot(1), _mk_d2_lot(2)]})["failures"], "G43_d2_lt3")
chk("FAIL_CHECK_D2_NON_CANONICAL_PRODUCT_ID" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_product_id": "LEGACY_PROD"})["failures"], "G43_d2_prod")
chk("FAIL_CHECK_D2_MISSING_BANK_ID" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_bank_id": ""})["failures"], "G43_d2_bank")
chk("FAIL_CHECK_D2_INVALID_MATCHED_CONTROL_LOT_ID:D2-LOT-1" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_per_lot_records": [_mk_d2_lot(1, mctrl_override="D2-LOT-1"), _mk_d2_lot(2), _mk_d2_lot(3)]})["failures"], "G43_d2_same_ctrl")
chk("HOLD_CHECK_D3B_TIMED_PILOT_RECEIPT_MISSING" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "d3b_pilot_receipt": None})["holds"], "G43_d3b_rcpt_miss")
chk("FAIL_CHECK_D3B_INCOMPLETE_INTERVENTION_SHIELD_RECORDS" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "d3b_pilot_receipt": _sign_receipt({**d3b_rcpt_a, "parental_shield_by_component": None})})["failures"], "G43_d3b_par_sh_miss")
chk("FAIL_CHECK_D3B_INVALID_STATUS" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d3b_status": "EVAL"})["failures"], "G43_d3b_bad_stat")
chk("HOLD_GATE0V_LOT_SURROGATE_REQUIRES_VERIFIED_PRIOR_BANK_ARCHIVE" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "gate0v_evidence": _mk_r8_gate0v(pa, ba, la, ra, mat_a_42, "2026-10-12T09:30:00Z", tier_override="PASS_WHOLEGRAFT_LOT_RELEASE_SURROGATE")})["holds"], "G43_ADV_g0v_surrogate_needs_bank")
# IEC_ONLY_NON_ASSEMBLED on Design A does NOT require GATE-31 (only PLVAP_iEC Hour-0!)
d3b_rcpt_iec = _sign_receipt({
"stage": "CHECK_D3B_PILOT", "verdict": "PASS",
"product_id": pa, "bank_id": ba, "lot_id": la, "route_id": ra,
"evidence_scope": "exact_product", "recorded_at_utc": "2026-10-15T10:00:00Z",
"parent_receipt_sha256": mat_a_42["receipt_sha256"],
"prerequisite_receipt_sha256s": {
"BANK_MATERIALIZATION": mat_a_42["receipt_sha256"],
"NATIVE_SAFETY_SWITCH": sw_a_42["receipt_sha256"],
"GATE-0V-KILL": g0v_a_42["receipt_sha256"],
},
"d3b_assay_scope": "IEC_ONLY_NON_ASSEMBLED",
"assay_acquired_at_utc": "2026-10-14T10:00:00Z",
"f3_kd_pct_in_pilot": 74.0,
"treated_lot_id": la, "nt_control_lot_id": la,
"same_product_nt_sirna": True, "parental_attribution_included": True,
"f3_sirna_shield_by_component": _mk_r8_shields(pa, 91.0),
"nt_sirna_shield_by_component": _mk_r8_shields(pa, 96.0),
"parental_shield_by_component": _mk_r8_shields(pa, 98.0),
"hour0_density_by_lineage": _mk_r8_hour0(pa, REQUIRED_HOUR0_LINEAGES_IEC),
})
g43_iec_a = {k: v for k, v in g43_full_a.items() if k != "gate31_evidence"}
g43_iec_a.update({"d3b_assay_scope": "IEC_ONLY_NON_ASSEMBLED", "d3b_pilot_receipt": d3b_rcpt_iec})
chk(evaluate_gate43_cellgemma_guardrails_and_pilots(g43_iec_a)["verdict"] == "PASS_DESCRIPTIVE_PILOT_ZERO_ODDS_GY037_WARN_RETAINED", "G43_iec_only_A_pass")
# Exact outward-rounded Decimal Gate 0V upper bound parity check (0/120000, 180/200, 36/36 <= 1e-4)
u_dec_120k = clopper_pearson_upper_decimal(0, 120000, "0.005") / (clopper_pearson_lower_decimal(180, 200, "0.025") * clopper_pearson_lower_decimal(36, 36, "0.005"))
chk(Decimal("6.01e-5") < u_dec_120k < Decimal("6.03e-5"), "G43_ADV_decimal_g0v_est1_exact")
chk("FAIL_CHECK_D2_READOUT2_SCOPE_MISMATCH_LOT" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_per_lot_records": [{**_mk_d2_lot(1), "readout2_receipt": _sign_receipt({**_mk_d2_lot(1)["readout2_receipt"], "lot_id": "WRONG-LOT"})}, _mk_d2_lot(2), _mk_d2_lot(3)]})["failures"], "G43_d2_lot_mm")
chk("FAIL_CHECK_D1_MISSING_T3_QUANTIFICATION_OR_CENSORING_FLAG" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_arm_b_below_lloq": "yes"})["failures"], "G43_d1_bloq_type")
chk("HOLD_CHECK_D1_PRE_COASSEMBLY_VASCULAR_FUNCTION_UNVERIFIED" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_base, "check_d1_pre_coassembly_vascular_function_pass": None})["holds"], "G43_d1_vasc_hold")
chk("FAIL_CHECK_D2_DUPLICATE_OR_EMPTY_LOT_ID" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_per_lot_records": [_mk_d2_lot(1), _mk_d2_lot(1), _mk_d2_lot(3)]})["failures"], "G43_d2_dup_lot")
chk("FAIL_CHECK_D3B_CD47_HOUR0_GY009_BELOW_200K_180K:PLVAP_iEC" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_iec_a, "d3b_pilot_receipt": _sign_receipt({**d3b_rcpt_iec, "hour0_density_by_lineage": {"PLVAP_iEC": {**_mk_r8_hour0(pa, REQUIRED_HOUR0_LINEAGES_IEC)["PLVAP_iEC"], "cd47_median_molecules_per_cell": 150000.0}}})})["failures"], "G43_d3b_cd47")
chk("FAIL_CHECK_D3B_HLAE_HOUR0_BELOW_15000:PLVAP_iEC" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_iec_a, "d3b_pilot_receipt": _sign_receipt({**d3b_rcpt_iec, "hour0_density_by_lineage": {"PLVAP_iEC": {**_mk_r8_hour0(pa, REQUIRED_HOUR0_LINEAGES_IEC)["PLVAP_iEC"], "hlae_molecules_per_cell": 8000.0}}})})["failures"], "G43_d3b_hlae")
chk("FAIL_CHECK_D3A_DUPLICATE_OR_EMPTY_LOT_ID" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d3a_per_lot_records": [_mk_d3a_lot(1), _mk_d3a_lot(1), _mk_d3a_lot(3)]})["failures"], "G43_d3a_dup_lot")
chk("FAIL_CHECK_D2_D2-LOT-1_READOUT2_MATCHED_COMPARATOR_ID_MISMATCH" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_per_lot_records": [_mk_d2_lot(1, readout2_evidence=_mk_r8_readout2(matched_comparator_id="WRONG-CTRL", block_prefix="D2L1", meas_id="MEAS-D2-LOT-1")), _mk_d2_lot(2), _mk_d2_lot(3)]})["failures"], "G43_d2_comp_mm")
chk("FAIL_CHECK_D2_READOUT2_SCOPE_MISMATCH_PRODUCT" in evaluate_gate43_cellgemma_guardrails_and_pilots({**g43_full_a, "check_d2_per_lot_records": [{**_mk_d2_lot(1), "readout2_receipt": _sign_receipt({**_mk_d2_lot(1)["readout2_receipt"], "product_id": pb})}, _mk_d2_lot(2), _mk_d2_lot(3)]})["failures"], "G43_d2_prod_mm")
# ========================================================================
# ADVERSARIAL REGRESSION SUITE (39 NEW TESTS -> 400/400 TOTAL!)
# Adversarial fail-closed invariant regression tests.
# ========================================================================
# --- Shared Statistics & Exactness (4 tests) ---
# 1. Exact fractional Satterthwaite df in two_sample_welch_summary (df=4.4669 -> p ~ 0.30622, NOT floored 0.31250!)
p_frac = student_t_two_sided_p(1.1538, 4.4669)
chk(0.305 < p_frac < 0.308, "ADV_shared_welch_exact_fractional_df")
# 2. Exact rational/scaled-integer paired sign-flip eliminates binary float subtraction tie drift on 10-block stress case!
# Example: 10 blocks where 9 blocks have exact diff +44.5 and 1 block has exact diff -0.0001? Better: exact tie sum!
# Construct exact tie: d = [1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 0.0]? Even better: tr - ctrl with exact decimal 0.1+0.2 == 0.3!
# tr=[50.1, 50.2, 50.3, 51.0, 52.0, 54.0, 58.0, 66.0, 82.0, 98.0], ctrl=[50.0]*10 -> diffs [0.1, 0.2, 0.3, ...]
# And exact tie: [50.3, 50.1, 50.2, 50.0+0.6, ...] -> compare exact_two_sided_sign_flip_paired_p on [50.1, 50.2, 50.3] vs [50.0, 50.0, 50.0]:
# diffs = [0.1, 0.2, 0.3], obs=0.6; flips with |sum|>=0.6: only +0.1+0.2+0.3 & -0.1-0.2-0.3 -> 2/8=0.25!
# Exact tie with opposite sign: tr=[50.1, 50.2, 50.0], ctrl=[50.0, 50.0, 50.3] -> diffs=[0.1, 0.2, -0.3], sum=0 EXACT -> p=1.0 (float64 gives 0.1+0.2-0.3=5.55e-17 != 0 -> would give 0.75 or wrong!)
chk(exact_two_sided_sign_flip_paired_p([50.1, 50.2, 50.0], [50.0, 50.0, 50.3]) == 1.0, "ADV_shared_exact_rational_signflip_0p1_0p2_0p3_zero")
# Exact 10-block Holm boundary tie stress case: diffs = [0.1, 0.2, 0.3, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 160.0] with last=-0.3+0.3 tie ->
# Specifically [0.1, 0.2, -0.3] + 7 blocks of +40.0 -> obs = 280.0; BOTH (+0.1,+0.2,-0.3) AND (-0.1,-0.2,+0.3) give exact 280.0!
# Plus flipping (+0.1,+0.2,+0.3) gives 280.6 > 280, etc. Exact rational count = 6/1024; in binary float64 (50.1-50.0)+(50.2-50.0)-(50.3-50.0) != 0 breaks symmetry!