"intervention_cohort_id": c1_cohort_y, "five_arm_family_matrix_sha256": c1_fam_sha_6, "c1_common_family_acquisition_record": c1_common_acq_6, "biological_blocks_n": 6, "statistical_test_method": "PAIRED_T_TEST_NORMALITY_VERIFIED", "multiplicity_method": "HOLM_BONFERRONI_5_ARM", "c1_normoxia": c1_norm_6, "c1_hypoxia_2pct_o2": c1_hyp_6, }) def _mk_c2_prolif_lot( i: int, *, active_lot: str = ly, prod_v: str = py, gene_v: str = tg_dual, active_nt: str = nt_y, **ov: Any, ) -> dict[str, Any]: lid_v = active_lot if i == 1 else f"C2-LOT-{i}" nt_v = active_nt if i == 1 else f"C2-NT-LOT-{i}" body: dict[str, Any] = { "lot_id": lid_v, "product_id": prod_v, "candidate_gene": gene_v, "comparator_nt_lot_id": nt_v, "treated_sample_id": f"C2-TR-SMP-{lid_v}", "matched_control_sample_id": f"C2-CTRL-SMP-{nt_v}", "resting_assay_record_id": f"REST-ASSAY-{i}", "post_recovery_assay_record_id": f"POSTREC-ASSAY-{i}", "resting_ki67_fold_vs_ctrl": 0.98, "resting_edu_fold_vs_ctrl": 0.99, "post_recovery_ki67_fold_vs_ctrl": 0.97, "post_recovery_edu_fold_vs_ctrl": 0.98, "ki67_edu_referred": False, } body.update(ov) body["lot_record_sha256"] = sha256_bytes(canonical_json_bytes(body)) return body def _mk_c1_with_kd_lot(blk_in: Mapping[str, Any], lot_v: str, prod_v: str) -> dict[str, Any]: kpb = {k: v for k, v in blk_in["molecular_kd_provenance"].items() if k != "producer_record_sha256"} new_sp = f"SPEC-C1-KD-{blk_in['assay_record_id']}-{lot_v}" kpb["product_id"] = prod_v kpb["specimen_lot_id"] = lot_v kpb["specimen_id"] = new_sp new_obs = [] for orow in kpb["target_observations"]: ob = {k: v for k, v in orow.items() if k != "producer_observation_sha256"} ob["product_id"] = prod_v ob["specimen_lot_id"] = lot_v ob["specimen_id"] = new_sp new_obs.append({**ob, "producer_observation_sha256": sha256_bytes(canonical_json_bytes(ob))}) kpb["target_observations"] = new_obs return {**blk_in, "molecular_kd_provenance": {**kpb, "producer_record_sha256": sha256_bytes(canonical_json_bytes(kpb))}} def _mk_c2_sol_iapp( *, spec_v: str, lot_v: str, nt_v: str = nt_y, aid_v: Optional[str] = None, treated_pg: float = 14.5, ctrl_pg: float = 13.8, ratio_override: Optional[float] = None, ) -> dict[str, Any]: sib = { "assay_species": "SOLUBLE_OLIGOMERIC_IAPP_ELISA_MATCHED_CTRL", "assay_record_id": aid_v or f"C2-SOL-IAPP-{lot_v}", "specimen_id": spec_v, "specimen_lot_id": lot_v, "comparator_nt_lot_id": nt_v, "treated_soluble_iapp_pg_per_ieq": treated_pg, "matched_ctrl_soluble_iapp_pg_per_ieq": ctrl_pg, "soluble_iapp_ratio_vs_ctrl": round(treated_pg / ctrl_pg, 6) if ratio_override is None else ratio_override, } return {**sib, "assay_receipt_sha256": sha256_bytes(canonical_json_bytes(sib))} def _mk_c2_surv_panel( *, spec_v: str, lot_v: str, nt_v: str = nt_y, aid_v: Optional[str] = None, bcl2l1: float = 94.0, mcl1: float = 92.0, cd59: float = 95.0, ) -> dict[str, Any]: spb = { "specimen_id": spec_v, "specimen_lot_id": lot_v, "comparator_nt_lot_id": nt_v, "assay_record_id": aid_v or f"C2-SURV-PROT-{lot_v}", "bcl2l1_pct_ctrl": bcl2l1, "mcl1_pct_ctrl": mcl1, "cd59_pct_ctrl": cd59, } return {**spb, "panel_receipt_sha256": sha256_bytes(canonical_json_bytes(spb))} c2_prolif_ok = [_mk_c2_prolif_lot(1), _mk_c2_prolif_lot(2), _mk_c2_prolif_lot(3)] c2_y = _sign_receipt({ "stage": "C-2", "verdict": "PASS", "product_id": py, "bank_id": by, "lot_id": ly, "route_id": ry, "evidence_scope": "exact_product", "recorded_at_utc": "2026-09-25T11:00:00Z", "assay_started_at_utc": "2026-09-22T09:00:00Z", "assay_completed_at_utc": "2026-09-25T08:00:00Z", "specimen_id": f"SPEC-C-2-{ly}", "parent_receipt_sha256": c1_y["receipt_sha256"], "prerequisite_receipt_sha256s": pr_c1_yc, "candidate_gene": tg_dual, "comparator_nt_lot_id": nt_y, "basal_shield_retention_pct": 93.0, "basal_shield_retention_by_component": _mk_r8_shields(py, 93.0), "hour0_density_by_lineage": _mk_r8_hour0(py), "granule_processing_preserved": True, "proinsulin_to_insulin_fold_vs_ctrl": 1.05, "pcsk1_pct_ctrl": 94.0, "pcsk2_pct_ctrl": 93.0, "cpe_pct_ctrl": 95.0, "chgb_pct_ctrl": 94.0, "scg2_pct_ctrl": 93.0, "soluble_iapp_pg_per_ieq": 14.5, "soluble_iapp_matched_ctrl_assay": _mk_c2_sol_iapp(spec_v=f"SPEC-C-2-{ly}", lot_v=ly, nt_v=nt_y), "iapp_amyloid_ratio_vs_ctrl": 1.04, "resting_survival_protein_panel": _mk_c2_surv_panel(spec_v=f"SPEC-C-2-{ly}", lot_v=ly, nt_v=nt_y), "c2_per_lot_proliferation_records": c2_prolif_ok, "transient_target_engagement_record": _mk_c_eng(c1_cohort_y, "2026-09-25T08:00:00Z", stage_name="C-2", lot_s_id=ly, win_start="2026-09-22T08:00:00Z", win_end="2026-09-25T09:00:00Z"), }) sw_y_c = _mk_r8_switch(py, by, ly, ry, mat_yc, "2026-09-28T14:00:00Z", candidate_gene=tg_dual, comparator_nt_lot_id=nt_y, prereq_receipts={"C-2": c2_y["receipt_sha256"]}, transient_engagement=_mk_c_eng(c1_cohort_y, "2026-09-28T13:00:00Z", stage_name="NATIVE_SAFETY_SWITCH", lot_s_id=ly, win_start="2026-09-25T12:00:00Z", win_end="2026-09-28T13:15:00Z", mode="VALIDATED_LONGITUDINAL_KINETICS")) g0v_y_c = _mk_r8_gate0v(py, by, ly, ry, mat_yc, "2026-09-28T14:30:00Z", candidate_gene=tg_dual, comparator_nt_lot_id=nt_y, prereq_receipts={"C-2": c2_y["receipt_sha256"]}, transient_engagement=_mk_c_eng(c1_cohort_y, "2026-09-28T13:15:00Z", stage_name="GATE-0V-KILL", lot_s_id=ly, win_start="2026-09-25T12:00:00Z", win_end="2026-09-28T13:30:00Z", mode="VALIDATED_LONGITUDINAL_KINETICS")) pr_c3_yc = { "BANK_MATERIALIZATION": mat_yc["receipt_sha256"], "DRUG_FREE_EXPOSURE": df_y["receipt_sha256"], "NATIVE_SAFETY_SWITCH": sw_y_c["receipt_sha256"], "GATE-0V-KILL": g0v_y_c["receipt_sha256"], } c3_nk_y = _sign_receipt({ "stage": "C-3-NK", "verdict": "PASS", "product_id": py, "bank_id": by, "lot_id": ly, "route_id": ry, "evidence_scope": "exact_product", "recorded_at_utc": "2026-09-30T12:00:00Z", "assay_started_at_utc": "2026-09-28T15:30:00Z", "assay_completed_at_utc": "2026-09-30T10:00:00Z", "specimen_id": f"SPEC-C-3-NK-{ly}", "parent_receipt_sha256": c2_y["receipt_sha256"], "prerequisite_receipt_sha256s": pr_c3_yc, "candidate_gene": tg_dual, "comparator_nt_lot_id": nt_y, "transient_target_engagement_record": _mk_c_eng(c1_cohort_y, "2026-09-30T09:00:00Z", stage_name="C-3-NK", lot_s_id=ly, win_start="2026-09-28T15:00:00Z", win_end="2026-09-30T11:00:00Z"), "readout3b_evidence": _mk_r8_readout3b(include_sirpa_low=True, specimen_id=f"SPEC-C-3-NK-{ly}", specimen_lot_id=ly, intervention_cohort_id=c1_cohort_y), }) c3_gsis_y = _sign_receipt({ "stage": "C-3-GSIS", "verdict": "PASS", "product_id": py, "bank_id": by, "lot_id": ly, "route_id": ry, "evidence_scope": "exact_product", "recorded_at_utc": "2026-10-02T13:00:00Z", "assay_started_at_utc": "2026-09-30T14:00:00Z", "assay_completed_at_utc": "2026-10-01T16:00:00Z", "specimen_id": f"SPEC-C-3-GSIS-{ly}", "parent_receipt_sha256": c3_nk_y["receipt_sha256"], "prerequisite_receipt_sha256s": pr_c3_yc, "candidate_gene": tg_dual, "comparator_nt_lot_id": nt_y, "transient_target_engagement_record": _mk_c_eng(c1_cohort_y, "2026-10-01T16:00:00Z", stage_name="C-3-GSIS", lot_s_id=ly, win_start="2026-09-30T13:00:00Z", win_end="2026-10-01T18:00:00Z"), "readout2_evidence": _mk_r8_readout2( matched_comparator_id=nt_y, block_prefix="C3G", lot_id=ly, stage7_start_utc="2026-09-12T00:00:00Z", sort_reaggregation_utc="2026-09-22T00:00:00Z", assay_harvest_utc="2026-10-01T00:00:00Z", specimen_id=f"SPEC-C-3-GSIS-{ly}", intervention_cohort_id=c1_cohort_y, candidate_gene=tg_dual, ), }) g42_ok = { "target_arm": "Y", "product_id": py, "bank_id": by, "lot_id": ly, "route_id": ry, "drug_free_exposure_evidence": df_y, "materialization_evidence": mat_yc, "foundry_v2_gate36_evidence": g36_y, "native_switch_evidence": sw_y_c, "gate0v_evidence": g0v_y_c, "zero_fasta_minted": True, "iip0049_foundry_attribution_evidence": att_y, "target_gene": tg_dual, "c1_preregistered_plan_receipt": c1_prereg_y, "c1_evidence": c1_y, "c2_evidence": c2_y, "c3_nk_evidence": c3_nk_y, "c3_gsis_evidence": c3_gsis_y, } r42 = evaluate_gate42_gy032_channel_c_screen(g42_ok) chk(r42["verdict"] == OFFLINE_VERDICT_PRIMARY and r42["release_authorizing"] is False and r42["live_ledger_authenticated"] is False, "G42_pass_dual") # GATE-42 closures (10 brand-new tests!) # 1. IIP-0049 Stage-2 IL-1b+IFNg control NOT protected (confounded drop = 20 pp) FAILS! att_il1_bad = _sign_receipt({**att_y, "stage2_normoxia_mechanism_panel": {**att_panel_norm, "cond4_il1b_ifng_beta_t0_pct_by_block": [70.0, 71.0, 72.0]}}) chk("FAIL_IIP0049_IL1_CONTROL_NOT_PROTECTED_OR_CONFOUNDED:NORMOXIA" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "iip0049_foundry_attribution_evidence": att_il1_bad})["failures"], "G42_ADV_iip0049_il1_confounded") # 2. IIP-0049 Stage-2 extrinsic caspase-8 >= caspase-9 FAILS intrinsic attribution! att_c8_bad = _sign_receipt({**att_y, "stage2_normoxia_mechanism_panel": {**att_panel_norm, "cleaved_caspase8_fold_by_block": [4.5, 4.8, 4.6]}}) chk("FAIL_IIP0049_INTRINSIC_CASP9_BH3_MECHANISM_UNPROVEN:NORMOXIA" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "iip0049_foundry_attribution_evidence": att_c8_bad})["failures"], "G42_ADV_iip0049_casp8_dom") # 3. IIP-0049 Stage-2 compromised shield kinetics (< 85%) on attribution background FAILS! att_sh_bad = _sign_receipt({**att_y, "stage2_normoxia_mechanism_panel": {**att_panel_norm, "cxcl10_0h_vs_24h_shield_retention_pct_by_block": [70.0, 72.0, 74.0]}}) chk("FAIL_IIP0049_SHIELD_KINETICS_COMPROMISED_ON_BACKGROUND:NORMOXIA" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "iip0049_foundry_attribution_evidence": att_sh_bad})["failures"], "G42_ADV_iip0049_shield_kinetics") # 4. IIP-0049 Stage-2 failed post-washout GSIS (< 3.0) on attribution background FAILS! att_gs_bad = _sign_receipt({**att_y, "stage2_hypoxia_15mmhg_mechanism_panel": {**att_panel_hyp, "post_washout_gsis_si_by_block": [2.2, 2.5, 2.4]}}) chk("FAIL_IIP0049_POST_WASHOUT_GSIS_FAILED_ON_BACKGROUND:HYPOXIA15" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "iip0049_foundry_attribution_evidence": att_gs_bad})["failures"], "G42_ADV_iip0049_postwash_gsis") # 5. IIP-0049 reported residual drop mismatched vs 5-condition raw vectors FAILS! chk("FAIL_IIP0049_REPORTED_RESIDUAL_DROP_MISMATCH_VS_5COND_RAW" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "iip0049_foundry_attribution_evidence": _sign_receipt({**att_y, "residual_viable_beta_drop_pp": 30.0})})["failures"], "G42_ADV_iip0049_raw_mismatch") # 6. Native safety switch missing data-backed matched-control parity receipt triggers HOLD! sw_no_par = _sign_receipt({**sw_y_c, "matched_control_switch_parity_evidence": None}) chk("HOLD_NATIVE_SWITCH_MATCHED_CONTROL_SWITCH_PARITY_MISSING" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "native_switch_evidence": sw_no_par})["holds"], "G42_ADV_sw_parity_missing_hold") # 7. Native safety switch parity bound to wrong NT comparator lot FAILS! sw_wrong_par = _sign_receipt({**sw_y_c, "matched_control_switch_parity_evidence": _mk_r8_switch_parity("OTHER-NT-LOT")}) chk("FAIL_NATIVE_SWITCH_SW_PARITY_COMPARATOR_LOT_MISMATCH" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "native_switch_evidence": sw_wrong_par})["failures"], "G42_ADV_sw_parity_wrong_nt") # 8. C-2 cross-lot reuse of resting_assay_record_id across LOT-1 & LOT-2 FAILS! chk("FAIL_GATE_C2_PROLIF_ASSAY_RECORDS_MISSING_OR_IDENTICAL:C2-LOT-2" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "c2_evidence": _sign_receipt({**c2_y, "c2_per_lot_proliferation_records": [_mk_c2_prolif_lot(1), _mk_c2_prolif_lot(2, resting_assay_record_id="REST-ASSAY-1"), _mk_c2_prolif_lot(3)]})})["failures"], "G42_ADV_c2_cross_lot_assay_reuse") # 9. Exact scale-invariant Decimal sign-flip returns exact 0.5 on [1e-13, 2e-13] and 0.25 on [1e-13, 2e-13, 4e-13] (NOT 1.0 under 1e-12 epsilon!) chk(exact_two_sided_sign_flip_p([1e-13, 2e-13]) == 0.5 and exact_two_sided_sign_flip_p([1e-13, 2e-13, 4e-13]) == 0.25, "G42_ADV_exact_decimal_signflip_tiny_scale") # 10. JAK2 hypomorph requires quantitative gy001_cxcl10_inducible_shield_pct_ctrl >= 85% (below 85% FAILS)! c1_jk_bad = _mk_r8_c1_block(assay_record_id="C1-JK-N", bids=["B1","B2","B3","B4","B5","B6"], c9_vec=[51.0,55.0,49.0,54.0,52.0,56.0], ctrl_vec=[54.0,52.0,56.0,55.0,53.0,54.0], tr_vec=[76.0,75.0,79.0,77.0,74.0,78.0], veh_vec=[90.0]*6, comp_vec=[71.0]*6, target="JAK2", target_kd=58.0, jak2_shield_pct=72.0) chk("FAIL_GATE_C1_NORMOXIA_JAK2_GY001_SHIELD_BELOW_85PCT" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "target_gene": "JAK2", "c1_evidence": _sign_receipt({**c1_y, "candidate_gene": "JAK2", "c1_normoxia": c1_jk_bad})})["failures"], "G42_ADV_jak2_quant_gy001") # & Core 67 GATE-42 invariants ctrl17 = [50.0] * 16 + [99.0] tr17 = [67.0] * 16 + [1.0] c1_sf17_bad = _mk_r8_c1_block(assay_record_id="C1-NORM-SF17", bids=[f"S{i}" for i in range(17)], c9_vec=[50.0+(i%4) for i in range(17)], ctrl_vec=ctrl17, tr_vec=tr17, veh_vec=[99.5]*17, comp_vec=[62.0]*16+[1.0], stat_method="EXACT_TWO_SIDED_SIGN_FLIP") c1_sf17_hyp = _mk_r8_c1_block(assay_record_id="C1-HYP-SF17", bids=[f"H{i}" for i in range(17)], c9_vec=[48.0+(i%4) for i in range(17)], ctrl_vec=[48.0]*16+[97.0], tr_vec=[65.0]*16+[1.0], veh_vec=[98.0]*17, comp_vec=[60.0]*16+[1.0], stat_method="EXACT_TWO_SIDED_SIGN_FLIP") r_sf17 = evaluate_gate42_gy032_channel_c_screen({**g42_ok, "c1_evidence": _sign_receipt({**c1_y, "biological_blocks_n": 17, "statistical_test_method": "EXACT_TWO_SIDED_SIGN_FLIP", "c1_normoxia": c1_sf17_bad, "c1_hypoxia_2pct_o2": c1_sf17_hyp})}) chk(exact_two_sided_sign_flip_p([6.0]*16 + [-90.0]) == 1.0 and "FAIL_GATE_C1_NORMOXIA_HOLM_BETA_PVALUE_GE_0P01" in r_sf17["failures"], "G42_ADV_sf17_counterexample_fails") bad_sib_p = {**c1_norm_6, "family_raw_p_values_beta": {**c1_norm_6["family_raw_p_values_beta"], "BBC3": 0.0001}} chk("FAIL_GATE_C1_NORMOXIA_SIBLING_RAW_PVALUE_MISMATCH_BETA:BBC3" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "c1_evidence": _sign_receipt({**c1_y, "c1_normoxia": bad_sib_p})})["failures"], "G42_ADV_sibling_rawp_tamper") c1_beta_cp = _mk_r8_c1_block(assay_record_id="C1-HYP-CP", bids=["H1","H2","H3","H4","H5","H6"], c9_vec=[48.0,52.0,47.0,51.0,50.0,53.0], ctrl_vec=[54.0,52.0,56.0,55.0,53.0,54.0], tr_vec=[76.0,75.0,79.0,77.0,74.0,78.0], veh_vec=[90.0,89.0,91.0,90.0,88.0,91.0], comp_vec=[71.0,70.0,73.0,72.0,70.0,72.0]) chk("FAIL_GATE_C1_IDENTICAL_COPY_PASTE_BETA_ACROSS_OXYGEN_REGIMES" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "c1_evidence": _sign_receipt({**c1_y, "c1_hypoxia_2pct_o2": c1_beta_cp})})["failures"], "G42_ADV_beta_only_cp") c1_neg_c9 = _mk_r8_c1_block(assay_record_id="C1-NORM-NEGC9", bids=["B1","B2","B3","B4","B5","B6"], c9_vec=[-15.0,50.0,48.0,45.0,42.0,40.0], ctrl_vec=[54.0,52.0,56.0,55.0,53.0,54.0], tr_vec=[76.0,75.0,79.0,77.0,74.0,78.0], veh_vec=[90.0,89.0,91.0,90.0,88.0,91.0], comp_vec=[71.0,70.0,73.0,72.0,70.0,72.0]) r_negc9 = evaluate_gate42_gy032_channel_c_screen({**g42_ok, "c1_evidence": _sign_receipt({**c1_y, "c1_normoxia": c1_neg_c9})}) chk("FAIL_GATE_C1_NORMOXIA_MEAN_CASP9_REDUCTION_BELOW_40PCT" in r_negc9["failures"] and "FAIL_GATE_C1_NORMOXIA_CASP9_OUT_OF_DOMAIN_NEG100_100" not in r_negc9["failures"], "G42_ADV_casp9_sign_preserving") sw_late = _mk_r8_switch(py, by, ly, ry, mat_yc, "2026-10-01T09:00:00Z", candidate_gene=tg_dual, comparator_nt_lot_id=nt_y) pr_c3_late = {**pr_c3_yc, "NATIVE_SAFETY_SWITCH": sw_late["receipt_sha256"]} c3nk_late = _sign_receipt({**c3_nk_y, "prerequisite_receipt_sha256s": pr_c3_late}) c3gs_late = _sign_receipt({**c3_gsis_y, "parent_receipt_sha256": c3nk_late["receipt_sha256"], "prerequisite_receipt_sha256s": pr_c3_late}) chk("FAIL_CHRONOLOGICAL_PREREQ_POSTDATES_STAGE:NATIVE_SAFETY_SWITCH_AFTER_C-3-NK" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "native_switch_evidence": sw_late, "c3_nk_evidence": c3nk_late, "c3_gsis_evidence": c3gs_late})["failures"], "G42_ADV_sw_postdates_c3nk") df_late = _sign_receipt({**df_y, "recorded_at_utc": "2026-10-10T08:00:00Z"}) chk("FAIL_CHRONOLOGICAL_PREREQ_POSTDATES_STAGE:DRUG_FREE_EXPOSURE_AFTER_C-1" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "drug_free_exposure_evidence": df_late, "foundry_v2_gate36_evidence": _sign_receipt({**g36_y, "prerequisite_receipt_sha256s": {"DRUG_FREE_EXPOSURE": df_late["receipt_sha256"]}}), "c1_evidence": _sign_receipt({**c1_y, "prerequisite_receipt_sha256s": {**pr_c1_yc, "DRUG_FREE_EXPOSURE": df_late["receipt_sha256"]}})})["failures"], "G42_ADV_df_postdates_c1") chk("FAIL_IIP0049_MISSING_SEPARATED_MECHANISM_PANEL:HYPOXIA15" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "iip0049_foundry_attribution_evidence": _sign_receipt({**att_y, "stage2_hypoxia_15mmhg_mechanism_panel": None})})["failures"], "G42_ADV_iip0049_panel_req") chk(f"FAIL_GATE_C2_PROLIF_ASSAY_RECORDS_MISSING_OR_IDENTICAL:{ly}" in evaluate_gate42_gy032_channel_c_screen({**g42_ok, "c2_evidence": _sign_receipt({**c2_y, "c2_per_lot_proliferation_records": [_mk_c2_prolif_lot(1, post_recovery_assay_record_id="REST-ASSAY-1"), c2_prolif_ok[1], c2_prolif_ok[2]]})})["failures"], "G42_ADV_c2_distinct_ids")