c1_by_gate["Protenix iPTM (>=0.60)"]["result"] == c1_ptx_derived, f"Comp1 Protenix iPTM verdict contradiction: derived {c1_ptx_derived} vs labeled {c1_by_gate['Protenix iPTM (>=0.60)']['result']}", ) c1_pep_dq25 = Decimal(str(c1_dq25["max_pep_share_pct"])) c1_pep_dq8t = Decimal(str(c1_dq8t["max_pep_share_pct"])) c1_pep_derived = ( "PASS" if (c1_pep_dq25 >= Decimal("35.0") and c1_pep_dq8t >= Decimal("35.0")) else ("FAIL" if (c1_pep_dq25 < Decimal("35.0") and c1_pep_dq8t < Decimal("35.0")) else "PARTIAL") ) require_cond( c1_by_gate["Peptide-Contact Share (>=35%)"]["result"] == c1_pep_derived, f"Comp1 Peptide-Contact Share verdict contradiction: derived {c1_pep_derived} vs labeled {c1_by_gate['Peptide-Contact Share (>=35%)']['result']}", ) c1_cl_dq25 = Decimal(str(c1_dq25["best_3seed_complete_link_A"])) c1_cl_dq8t = Decimal(str(c1_dq8t["best_3seed_complete_link_A"])) c1_cl_derived = "PASS" if (c1_cl_dq25 <= Decimal("2.5") and c1_cl_dq8t <= Decimal("2.5")) else "FAIL" require_cond( c1_by_gate["Seed Convergence (<=2.5 A CL)"]["result"] == c1_cl_derived, f"Comp1 Seed Convergence verdict contradiction: derived {c1_cl_derived} from (DQ2.5={c1_cl_dq25} A, DQ8t={c1_cl_dq8t} A <= 2.5 A) vs labeled {c1_by_gate['Seed Convergence (<=2.5 A CL)']['result']}", ) c1_flagged = c1["flagged_off_targets_gt_025"] require_cond(isinstance(c1_flagged, dict) and len(c1_flagged) > 0, "Comp1 flagged_off_targets_gt_025 missing") c1_ot_derived = "FAIL" if any(Decimal(str(v)) > Decimal("0.25") for v in c1_flagged.values()) else "PASS" require_cond( c1_by_gate["Off-Target Ceiling (<=0.25)"]["result"] == c1_ot_derived, f"Comp1 Off-Target Ceiling verdict contradiction: derived {c1_ot_derived} vs labeled {c1_by_gate['Off-Target Ceiling (<=0.25)']['result']}", ) c1_cel_derived = "FAIL" if any(Decimal(str(v)) > Decimal("0.25") for k, v in c1_flagged.items() if str(k).startswith("cel_")) else "PASS" require_cond( c1_by_gate["Celiac 6/6 Rejected (<=0.25)"]["result"] == c1_cel_derived, f"Comp1 Celiac 6/6 verdict contradiction: derived {c1_cel_derived} vs labeled {c1_by_gate['Celiac 6/6 Rejected (<=0.25)']['result']}", ) c1_md_on = c1["openmm_10ns_md"]["on_target_DQ25_HIP11"] c1_md_neg = c1["openmm_10ns_md"]["matched_neg_DQ25_CLIP1"] c1_md_on_derived = (Decimal(str(c1_md_on["binder_rmsd_A"])) <= Decimal("3.5") and Decimal(str(c1_md_on["pep_retention"])) >= Decimal("0.70")) c1_md_neg_derived = (Decimal(str(c1_md_neg["binder_rmsd_A"])) <= Decimal("3.5") and Decimal(str(c1_md_neg["pep_retention"])) >= Decimal("0.70")) require_cond(c1_md_on["pass_md_gate"] is c1_md_on_derived, "Comp1 on-target MD pass_md_gate contradicts structured RMSD/pep_retention") require_cond(c1_md_neg["pass_md_gate"] is c1_md_neg_derived, "Comp1 matched CLIP1 NEG MD pass_md_gate contradicts structured RMSD/pep_retention") c1_md_row_derived = "PASS (n=1)" if c1_md_on_derived else "FAIL" require_cond( c1_by_gate["Explicit 10 ns MD (HIP11, n=1)"]["result"] == c1_md_row_derived, f"Comp1 Explicit 10 ns MD verdict contradiction: derived {c1_md_row_derived} vs labeled {c1_by_gate['Explicit 10 ns MD (HIP11, n=1)']['result']}", ) c1_fail_gates = {g["gate"] for g in c1["registered_gates"] if str(g["result"]).upper() == "FAIL"} expected_c1_fails = { "Cross-Engine Dock RMSD (<=3.5 A)", "Peptide-Contact Share (>=35%)", "Seed Convergence (<=2.5 A CL)", "Off-Target Ceiling (<=0.25)", "Celiac 6/6 Rejected (<=0.25)", } require_cond(c1_fail_gates == expected_c1_fails, f"Comp1 required FAIL rows mismatch: {c1_fail_gates}") require_cond(c1_dq25["n_ge_060"] == 9 and abs(float(c1_cl_dq8t) - 3.395) <= 1e-6, "Comp1 DQ2.5/DQ8-trans structured metrics mismatch") c2 = shield["component_2"] require_cond(c2["lead_id"] == "IsletSHIELD_Comp2_T006", "Comp2 lead_id mismatch") c2_recomp = recompute_gate_counts(c2["registered_gates"], "Comp2") require_cond(c2_recomp == {"PASS": 4, "PARTIAL": 3, "FAIL": 4, "total": 11}, f"Comp2 recomputed gates mismatch: {c2_recomp}") require_cond(c2["registered_gates_summary"] == c2_recomp, "Comp2 reported summary disagrees with recomputed rows") require_cond( side_contract["programs_registered"]["Islet_SHIELD"]["component_2"]["pre_registered_gates"] == c2_recomp, "Side-contract Comp2 pre_registered_gates disagrees with recomputed rows", ) c2_by_gate = {g["gate"]: g for g in c2["registered_gates"]} for row in c2["registered_gates"]: require_cond( row.get("verdict_verification_basis") == "LOCALLY_RECOMPUTED_FROM_STRUCTURED_METRICS", f"Comp2 gate {row['gate']!r} must declare verdict_verification_basis=LOCALLY_RECOMPUTED_FROM_STRUCTURED_METRICS", ) require_cond( c2.get("verdict_verification_summary") == {"LOCALLY_RECOMPUTED_FROM_STRUCTURED_METRICS": 11, "UPSTREAM_REPORTED_PROVENANCE_ONLY": 0, "total": 11}, f"Comp2 verdict_verification_summary mismatch: {c2.get('verdict_verification_summary')}", ) expected_c2_fails = { "Peptide-Contact Share (>=35%)", "HLA-DQ8 14-Peptide Off-Target Ceiling (<=0.25)", "Cross-Engine Pose Consensus (<=3.5 A)", "Explicit-Solvent 10 ns OpenMM 8.6.1 MD (n=1)", } c2_fail_gates = {g["gate"] for g in c2["registered_gates"] if str(g["result"]).upper() == "FAIL"} require_cond(c2_fail_gates == expected_c2_fails, f"Comp2 required FAIL rows mismatch: {c2_fail_gates}") # Precision consistency check: Comp2 cross-engine row must use exact 2.32 A and 10.87-20.43 A (never 2.28 A or 20.5 A) ce_obs = c2_by_gate["Cross-Engine Pose Consensus (<=3.5 A)"]["observed"] require_cond("2.32 A" in ce_obs and "10.87-20.43 A" in ce_obs, "Comp2 Cross-Engine row missing reconciled 2.32 A / 10.87-20.43 A") require_cond("2.28 A" not in ce_obs and "20.5 A" not in ce_obs, "Comp2 Cross-Engine row retains stale 2.28 A / 20.5 A rounding") ptx = c2["protenix_4seed_WT15"] # Derive Comp2 gates 1-6 directly from structured ptx measurements (B5!) require_cond( c2_by_gate["Protenix-v1 4-Seed Native WT15 (>=0.60)"]["result"] == ("PASS" if (ptx["n_bpep_ge_060"] == ptx["n_samples"] and Decimal(str(ptx["min_b_pep"])) >= Decimal("0.60")) else "FAIL"), "Comp2 Protenix-v1 4-Seed Native WT15 verdict contradicts structured metrics", ) require_cond( c2_by_gate["4-Seed Pose Convergence (<=2.5 A CL)"]["result"] == ("PASS" if Decimal(str(ptx["best3_seed_cl_A"])) <= Decimal("2.5") else "FAIL"), "Comp2 4-Seed Pose Convergence verdict contradicts best3_seed_cl_A", ) require_cond( c2_by_gate["6DFX T1D3 TCR Steric Overlap (>=70%)"]["result"] == ("PASS" if Decimal(str(ptx["t1d3_overlap_range_pct"][0])) >= Decimal("70.0") else "FAIL"), "Comp2 6DFX T1D3 TCR Steric Overlap verdict contradicts t1d3_overlap_range_pct", ) require_cond( c2_by_gate["DQ-Beta Wall Share (<=90%)"]["result"] == ("PASS" if Decimal(str(ptx["dqb_share_range_pct"][1])) <= Decimal("90.0") else "FAIL"), "Comp2 DQ-Beta Wall Share verdict contradicts dqb_share_range_pct", ) c2_r2_ok = Decimal(str(ptx["max_b_pep"])) >= Decimal("0.60") c2_r3_ok = Decimal(str(ptx["mimotope_6dfx_p8E9E_max_b_pep"])) >= Decimal("0.60") c2_reg_derived = "PASS" if (c2_r2_ok and c2_r3_ok) else ("FAIL" if (not c2_r2_ok and not c2_r3_ok) else "PARTIAL") require_cond( c2_by_gate["Register-3 vs Equilibrium Register-2 Frame"]["result"] == c2_reg_derived, f"Comp2 Register-3 vs Register-2 verdict contradiction: derived {c2_reg_derived}", ) c2_pep_lo = Decimal(str(ptx["pep_share_range_pct"][0])) c2_pep_hi = Decimal(str(ptx["pep_share_range_pct"][1])) c2_pep_derived = "PASS" if c2_pep_lo >= Decimal("35.0") else ("FAIL" if c2_pep_hi < Decimal("35.0") else "PARTIAL") require_cond( c2_by_gate["Peptide-Contact Share (>=35%)"]["result"] == c2_pep_derived, f"Comp2 Peptide-Contact Share verdict contradiction: derived {c2_pep_derived}", ) require_cond(ptx["n_samples"] == 12 and ptx["n_bpep_ge_060"] == 12, "Comp2 Protenix 4-seed must be 12/12") require_cond(abs(ptx["min_b_pep"] - 0.8713) <= 1e-6 and abs(ptx["max_b_pep"] - 0.8865) <= 1e-6, "Comp2 4-seed b_pep range mismatch") require_cond(ptx["n_clash_free_of_12"] == 9, "Comp2 clash-free count must be 9/12") require_cond(ptx["t1d3_overlap_range_pct"] == [82.7, 85.5], "Comp2 6DFX T1D3 overlap range mismatch") require_cond(ptx["dqb_share_range_pct"][1] <= 90.0, "Comp2 DQ-beta share must be <= 90%") require_cond(ptx["pep_share_range_pct"] == [21.2, 32.0] and ptx["pep_share_range_pct"][1] < 35.0, "Comp2 peptide share FAIL (<35%) mismatch") # Recompute 14-peptide off-target pass/fail counts AND enforce 14 UNIQUE canonical peptide IDs + gate 7 verdict! ot = c2["dq8_14_peptide_off_target_sweep"] ot_peps = ot.get("peptides", []) require_cond(len(ot_peps) == 14, f"Expected 14 peptides in DQ8 off-target table, got {len(ot_peps)}") ot_ids = [str(p.get("peptide_id") or "") for p in ot_peps] require_cond( len(set(ot_ids)) == 14, f"Duplicate peptide_id detected in DQ8 14-peptide off-target table: {len(set(ot_ids))} unique of {len(ot_ids)}", ) require_cond( set(ot_ids) == EXPECTED_DQ8_14_OFFTARGET_PEPTIDE_IDS, f"DQ8 14-peptide off-target panel ID mismatch: missing={sorted(EXPECTED_DQ8_14_OFFTARGET_PEPTIDE_IDS - set(ot_ids))}, extra={sorted(set(ot_ids) - EXPECTED_DQ8_14_OFFTARGET_PEPTIDE_IDS)}", ) for p in ot_peps: dec_val = Decimal(str(p["max_b_pep"])) expected_pass = dec_val <= Decimal("0.25") require_cond( p.get("pass_le_025") is expected_pass, f"Off-target pass_le_025 boolean disagrees with exact decimal threshold for {p['peptide_id']}: {dec_val}", ) ot_pass_recomp = sum(1 for p in ot_peps if Decimal(str(p["max_b_pep"])) <= Decimal("0.25")) ot_fails_recomp = [p for p in ot_peps if Decimal(str(p["max_b_pep"])) > Decimal("0.25")] require_cond( c2_by_gate["HLA-DQ8 14-Peptide Off-Target Ceiling (<=0.25)"]["result"] == ("PASS" if ot_pass_recomp == 14 else "FAIL"), "Comp2 14-peptide off-target gate verdict contradicts recomputed pass count", ) require_cond(ot_pass_recomp == 13 and ot["pass_count"] == 13 and ot["total"] == 14, "Comp2 DQ8 off-target sweep recomputation must be 13/14") require_cond( len(ot_fails_recomp) == 1 and ot_fails_recomp[0]["peptide_id"] == "DQ8_glia_gamma1a" and abs(float(ot_fails_recomp[0]["max_b_pep"]) - 0.5289) <= 1e-6, f"Comp2 DQ8 off-target recomputed failure must be DQ8_glia_gamma1a=0.5289, got {ot_fails_recomp}", ) failing_ot = ot["failing_peptides"] require_cond( len(failing_ot) == 1 and failing_ot[0]["peptide_id"] == "DQ8_glia_gamma1a" and abs(failing_ot[0]["max_b_pep"] - 0.5289) <= 1e-6, f"Comp2 DQ8 off-target failure must be DQ8_glia_gamma1a=0.5289, got {failing_ot}", ) # Derive Comp2 gate 8 (Negative Binder Controls NULL & AAA8 <= 0.25) neg_ctrl = c2["negative_and_cross_allele_controls"] aaa8_vals = [Decimal(str(x)) for x in neg_ctrl["AAA8_sample_b_peps"]] aaa8_le_025_recomp = sum(1 for x in aaa8_vals if x <= Decimal("0.25")) require_cond( neg_ctrl["AAA8_n_le_025_of_3"] == aaa8_le_025_recomp, f"Comp2 AAA8_n_le_025_of_3={neg_ctrl['AAA8_n_le_025_of_3']} contradicts derived {aaa8_le_025_recomp}", ) null_ok = Decimal(str(neg_ctrl["NULL_scramble_max_b_pep"])) <= Decimal("0.25") aaa8_all_ok = (aaa8_le_025_recomp == len(aaa8_vals)) neg_derived = "PASS" if (null_ok and aaa8_all_ok) else ("FAIL" if (not null_ok and aaa8_le_025_recomp == 0) else "PARTIAL") require_cond( c2_by_gate["Negative Binder Controls (NULL & AAA8 <=0.25)"]["result"] == neg_derived, f"Comp2 Negative Binder Controls verdict contradiction: derived {neg_derived}", ) # Derive BOTH min AND max OpenFold3 ranges & Comp2 gate 9 (Cross-Engine Pose Consensus <= 3.5 A) ce = c2["cross_engine_consensus_fail_audit"] boltz_rmsd = Decimal(str(ce["boltz2_mit_v2_2_1_parent"]["WT15_ptx_whole_binder_rmsd_A"])) of3_blk = ce["openfold3_0_5_1_apache2"] for sub_k in ("T006_DQ8_WT15", "T006_DQ8_CLIP1_inverted_higher", "T006_DQ8_glia_gamma1a_inverted_s3_match", "SHIELD2_QQ_DQ8_WT15"): sub = of3_blk[sub_k] iptms = [float(x) for x in sub["iptm_values"]] cds = [float(x) for x in sub["chain_pair_CD_values"]] require_cond( sub["iptm_range"] == [min(iptms), max(iptms)], f"OpenFold3 {sub_k} iptm_range {sub['iptm_range']} disagrees with derived [{min(iptms)}, {max(iptms)}]", ) require_cond( sub["chain_pair_CD_range"] == [min(cds), max(cds)], f"OpenFold3 {sub_k} chain_pair_CD_range {sub['chain_pair_CD_range']} disagrees with derived [{min(cds)}, {max(cds)}]", ) of3_wt = of3_blk["T006_DQ8_WT15"] of3_clip = of3_blk["T006_DQ8_CLIP1_inverted_higher"] of3_glia = of3_blk["T006_DQ8_glia_gamma1a_inverted_s3_match"] wt_shifts = [float(x) for x in of3_wt["pep_com_shift_vs_WT15_groove_A"]] derived_min_shift = min(wt_shifts) derived_max_shift = max(wt_shifts) ce_derived = "PASS" if (boltz_rmsd <= Decimal("3.5") and Decimal(str(derived_max_shift)) <= Decimal("3.5")) else "FAIL" require_cond( c2_by_gate["Cross-Engine Pose Consensus (<=3.5 A)"]["result"] == ce_derived, f"Comp2 Cross-Engine Pose Consensus verdict contradiction: derived {ce_derived}", ) require_cond(abs(float(boltz_rmsd) - 23.4) <= 1e-6, "Boltz-2 MIT 23.4 A flip mismatch") require_cond( abs(derived_min_shift - 10.87) <= 1e-6 and abs(derived_max_shift - 20.43) <= 1e-6, f"Derived OpenFold3 WT15 COM shift range [{derived_min_shift}, {derived_max_shift}] != [10.87, 20.43]", ) require_cond( of3_wt.get("pep_com_shift_range_A") == [derived_min_shift, derived_max_shift], f"OpenFold3 T006_DQ8_WT15 pep_com_shift_range_A {of3_wt.get('pep_com_shift_range_A')} disagrees with derived [{derived_min_shift}, {derived_max_shift}]", ) derived_shift_str_ascii = f"{derived_min_shift:.2f}-{derived_max_shift:.2f} A" derived_shift_str_dash = f"{derived_min_shift:.2f}\u2013{derived_max_shift:.2f} A" require_cond( derived_shift_str_ascii in ce_obs, f"Comp2 Cross-Engine gate observed text missing derived OpenFold3 shift range {derived_shift_str_ascii!r}", ) require_cond( derived_shift_str_ascii in protocol_text or derived_shift_str_dash in protocol_text, f"Protocol doc missing derived OpenFold3 shift range {derived_shift_str_ascii!r}", ) require_cond(max(of3_wt["chain_pair_CD_values"]) < min(of3_clip["chain_pair_CD_values"]), "OpenFold3 CLIP1 chain-pair (C,D) inversion not preserved") require_cond(abs(min(of3_glia["binder_rmsd_vs_T006_ptx_s303_A"]) - 2.32) <= 1e-6, "OpenFold3 glia-g1a sample 3 pose match must be 2.32 A") # Derive Comp2 gate 11 (Explicit-Solvent 10 ns OpenMM 8.6.1 MD) from structured RMSD & pep_retention (B5!) md = c2["openmm_10ns_md_n1"] md_wt_derived = ( Decimal(str(md["on_target_WT15"]["binder_rmsd_A"])) <= Decimal("3.5") and Decimal(str(md["on_target_WT15"]["pep_retention"])) >= Decimal("0.70") ) md_clip_derived = ( Decimal(str(md["matched_neg_CLIP1"]["binder_rmsd_A"])) <= Decimal("3.5") and Decimal(str(md["matched_neg_CLIP1"]["pep_retention"])) >= Decimal("0.70") ) require_cond( md["on_target_WT15"]["pass_md_gate"] is md_wt_derived, "Comp2 WT15 MD pass_md_gate contradicts structured RMSD/pep_retention",