pass_spec_ok and pass_prose_and_ok and "> 0%" in blk_hold and "u95 > 5.0%" in blk_hold and "hold_cytotoxicity_u95_exceeds_5pct" in blk_hold and "u95 <= 5.0%" in blk_hold and "hold_observed_nonzero_cytotoxicity" in blk_hold ) pre_adj_str = str(prec_tbl.get("pre_adjudication_nonfinite_rejection", "")).lower() checks["sc_fail_first_precedence_and_cytotoxicity_unit"] = ( isinstance(prec_tbl, dict) and prec_tbl.get("precedence_order") == _EXPECTED_SHIELD_SPR_PRECEDENCE_LIST and "valueerror" in pre_adj_str and isinstance(cyto_unit, dict) and cyto_unit.get("min_n_eff_per_donor") == 60 and "clopper" in json.dumps(cyto_unit).lower() and "n_eff" in json.dumps(cyto_unit).lower() and "donor" in json.dumps(cyto_unit).lower() ) else: for k in ( "sc_typed_gate_present", "sc_stale_v13_hold_note_retired", "sc_post_spr_v14_maturation_present", "sc_comp1_qf09_pi2_lead", "sc_comp2_t006_lead", "sc_two_component_cocktail", "sc_all_4_mandatory_on_target_analytes_and_qc", "sc_dq22_in_target_analytes_and_qc", "sc_ctrl1_all_3_offtarget_analytes", "sc_comp1_all_4_offtarget_analytes", "sc_r05_quant_secmals_batch_hla_gy018_optional_1jk8", "sc_ctrl2_secmals_dls_homodimer_06691", "sc_ctrl3_all_6_parallel_comparators", "sc_register_1jk8_wt15_6dfx_separated", "sc_unified_cytotoxicity_pass_and_hold_tiebreak", "sc_fail_first_precedence_and_cytotoxicity_unit", ): checks[k] = False # --- PART B: Independent full-clause Markdown validation on GATE-30 protocol section ### 2.2 ONLY --- md_masked = mask_canonical_layer2_disclaimer_only(protocol_md_text) md_low = md_masked.lower() sec22 = _extract_gate30_shield_spr_md_section(md_masked) sec22_low = sec22.lower() checks["md_stale_v13_hold_note_retired"] = ("hold for v1.3 affinity maturation" not in md_low) checks["md_post_spr_v14_maturation_present"] = ("v1.4" in sec22_low) checks["md_comp1_qf09_pi2_lead"] = ("isletshield_qf09_pi2" in sec22_low) checks["md_comp2_t006_lead"] = ("isletshield_comp2_t006" in sec22_low) checks["md_two_component_cocktail"] = ("2-component" in sec22_low or "two-component" in sec22_low) md_mandatory_all4_clause = bool( re.search(r"all\s+(?:four|4)\s+mandatory\s+on-target\s+(?:complexes|analytes)", sec22_low) ) checks["md_all_4_mandatory_on_target_analytes_and_qc"] = ( md_mandatory_all4_clause and _RE_MD_WEAKENED_COVERAGE.search(sec22_low) is None and "hla-dq2.5 + hip11" in sec22_low and "hla-dq8-trans + hip11" in sec22_low and "hla-dq2.2 + hip11" in sec22_low and bool(re.search(r"hla-dq8\s*\+\s*(?:15-aa\s+)?native\s+wt\s+insb:9-23", sec22_low)) and "shlvealylvcgerg" in sec22_low ) checks["md_dq22_in_target_analytes_and_qc"] = ( md_mandatory_all4_clause and _RE_MD_WEAKENED_COVERAGE.search(sec22_low) is None and "hla-dq2.2 + hip11" in sec22_low ) checks["md_ctrl1_all_3_offtarget_analytes"] = ( "hla-dq8 + clip1" in sec22_low and ("hla-dq8 + dq8-glia-gamma1a" in sec22_low or "dq8_glia_gamma1a" in sec22_low) and "hla-dq8-trans + wt insb:9-23" in sec22_low ) checks["md_comp1_all_4_offtarget_analytes"] = ( "hla-dq2.5 + clip1" in sec22_low and "hla-dq2.5 + self_igkv2_eaed" in sec22_low and "hla-dq2.5 + cel_glutenin_l1" in sec22_low and "hla-dq8-trans + cpep_nterm_eaed" in sec22_low ) checks["md_r05_quant_secmals_batch_hla_gy018_optional_1jk8"] = ( "95.0%" in sec22_low and "dls_pdi <= 0.15" in sec22_low and "expression_batch_ids" in sec22_low and "hla_genotype" in sec22_low and "t1d_diagnosis_confirmed" in sec22_low and "donor_clinical_cohort" in sec22_low and "t1d_prequalification_ref" in sec22_low and "gy-018" in sec22_low and "gy018_independence_justification" in sec22_low and "design_effect_deff == 1.0" in sec22_low and "zero tolerance" in sec22_low and "decimal" in sec22_low and "bonferroni" in sec22_low and "0.05 / n_roster" in sec22_low and "preregistered_donor_family_roster" in sec22_low and "roster_sha256" in sec22_low and "h0_all" in sec22_low and "non-authorizing" in sec22_low and "optional" in sec22_low and "null" in sec22_low and "crystal_ref_1jk8_14aa" in sec22_low ) # R06 B4: Strict clause-level Markdown batch-requirement validation (rejects contradictory single-batch wording!) sec22_nobt = sec22_low.replace("`", "") md_has_three_linked_batches_clause = ( bool(re.search(r"(?:n\s*>=\s*3|>=\s*3)\s+independent[^\n]{0,40}expression\s+batches", sec22_nobt)) and bool( re.search( r">=\s*3\s+distinct\s+(?:declared\s+)?(?:linked\s+)?(?:passing\s+)?(?:comp1|component\s*1)[^.\n]{0,60}batches", sec22_nobt, ) ) and bool( re.search( r">=\s*3\s+distinct\s+(?:declared\s+)?(?:linked\s+)?(?:passing\s+)?(?:comp2|component\s*2)[^.\n]{0,60}batches", sec22_nobt, ) ) and "construct_ids" in sec22_nobt and _RE_MD_CONTRADICTORY_BATCH_RULE.search(sec22_nobt) is None ) checks["md_construct_bound_three_batch_clause_no_contradiction"] = md_has_three_linked_batches_clause checks["md_ctrl2_secmals_dls_homodimer_06691"] = ( "sec-mals" in sec22_low and "dls" in sec22_low and "homodimer" in sec22_low and "0.6691" in sec22_low ) checks["md_ctrl3_all_6_parallel_comparators"] = all( tok in sec22_low for tok in ("isletshield_comp2_t006", "shield2_qq", "r3_shv2_stk1", "sh2_mp01", "sh2_mp06", "sh2_mp08") ) checks["md_register_1jk8_wt15_6dfx_separated"] = ( _find_unnegated_1jk8_conflation(md_masked) is None and "LVEALYLVCGERGG" in sec22 and "SHLVEALYLVCGERG" in sec22 and "VEELYLVAGEEG" in sec22 and "1jk8" in sec22_low and "6dfx" in sec22_low ) # Strict full-clause PASS, FAIL, HOLD_CYTOTOXICITY_U95_EXCEEDS_5PCT, HOLD_OBSERVED_NONZERO_CYTOTOXICITY checks on sec22 md_aff_pass_ok = ( bool(re.search(r"`?u95\(ic50\)\s*<=\s*100\.0\s*nm`?", sec22_low)) and bool(re.search(r"`?l95\((?:off-target\s+)?selectivity\)\s*>=\s*50\.0(?:x|\u00d7)`?", sec22_low)) ) md_fail_clause_ok = ( bool(re.search(r"`?l95\(ic50\)\s*>\s*500\.0\s*nm`?", sec22_low)) and bool(re.search(r"`?u95\((?:off-target\s+)?selectivity\)\s*<\s*10\.0(?:x|\u00d7)`?", sec22_low)) and bool(re.search(r"`?l95_cp\(k_lt_40,\s*n_roster\)\s*>\s*60\.0%`?", sec22_low)) and "u95_t < 40.0%" not in sec22_low and bool( re.search( r"off-target\s+apc\s+cytotoxicity[^.\n]{0,110}`?simultaneous_worst_donor_bonferroni_lower_pct\s*>\s*5\.0%`?", sec22_low, ) ) and "cohort_mean_cytotoxicity_l975_pct" not in sec22_low and _RE_MD_CONTRADICTORY_CYTO_FAIL.search(sec22_low) is None ) md_pass_and_ok = bool( re.search( r"`?l95_cp\(k_ge_70,\s*n_roster\)\s*>=\s*70\.0%`?[^\n]{0,120}`?min_donor_suppression\s*>=\s*0\.0%`?[^\n]{0,120}" r"(?:\*\*)?and(?:\*\*)?\s+(?:\*\*)?`?0%`?\s+observed\s+off-target\s+apc\s+cytotoxicity(?:\*\*)?\s+" r"(?:\*\*)?and(?:\*\*)?\s+(?:off-target\s+apc\s+cytotoxicity\s+)?`?u95\s*<=\s*5\.0%`?", sec22_low, ) ) and ("l95_t >= 70.0%" not in sec22_low) md_hold_u95_gt5_ok = bool( re.search( r"observed\s+off-target\s+apc\s+cytotoxicity\s+`?>\s*0%`?\s+with\s+[^.\n]{0,65}<=\s*5\.0%`?\s+(?:\*\*)?and(?:\*\*)?\s+(?:conservative\s+)?`?u95\s*>\s*5\.0%`?", sec22_low, ) and "hold_cytotoxicity_u95_exceeds_5pct" in sec22_low ) md_hold_nonzero_ok = bool( re.search( r"(?:observed\s+off-target\s+apc\s+cytotoxicity\s+(?:is\s+)?`?>\s*0%`?|hold\s+if\s+`?>\s*0%`?)\s+(?:\*\*)?while\s+`?u95\s*<=\s*5\.0%`?(?:\*\*)?", sec22_low, ) and "hold_observed_nonzero_cytotoxicity" in sec22_low ) checks["md_unified_cytotoxicity_pass_and_hold_tiebreak"] = ( md_aff_pass_ok and md_fail_clause_ok and md_pass_and_ok and md_hold_u95_gt5_ok and md_hold_nonzero_ok ) # Ordered 6-level numbered precedence + N_eff >= 60 + pre-adjudication ValueError in sec22 md_prec_ordered = bool( re.search( r"1\.\s+(?:\*\*)?`?fail`?(?:\*\*)?.*?" r"2\.\s+(?:\*\*)?`?hold_invalid_or_missing_input`?(?:\*\*)?.*?" r"3\.\s+(?:\*\*)?`?hold_cytotoxicity_u95_exceeds_5pct`?(?:\*\*)?.*?" r"4\.\s+(?:\*\*)?`?hold_observed_nonzero_cytotoxicity`?(?:\*\*)?.*?" r"5\.\s+(?:\*\*)?`?hold`?(?:\*\*)?.*?" r"6\.\s+(?:\*\*)?`?pass`?(?:\*\*)?", sec22_low, flags=re.DOTALL, ) ) checks["md_fail_first_precedence_and_cytotoxicity_unit"] = ( md_prec_ordered and "valueerror" in sec22_low and "clopper" in sec22_low and bool(re.search(r"n_eff[^.\n]{0,35}>=\s*60", sec22_low)) ) # --- PART C: Legacy IIP-0042 vendor-token hygiene compatibility on BOTH surfaces --- legacy_vendor_hits_sc = sum( len(re.findall(r"(? tuple[dict[str, Any], str]: sc = { "executable_stage0_and_conditional_gates": { "Gate_30_SHIELD_SPR": { "registered_cocktail_identity": { "architecture": "2-component Islet-SHIELD cocktail", "component_1_lead_id": "IsletSHIELD_QF09_pI2", "component_1_target": "HLA-DQ2.5 / HLA-DQ8-trans / HLA-DQ2.2 + HIP11", "component_2_lead_id": "IsletSHIELD_Comp2_T006", "component_2_target": "HLA-DQ8 + 15-aa native WT InsB:9-23 (SHLVEALYLVCGERG)", }, "mandatory_on_target_spr_analytes": list(_EXPECTED_MANDATORY_ANALYTE_STRINGS), "mandatory_on_target_spr_analyte_specs": [ { "analyte_id": "HLA-DQ2.5 + HIP11", "required": True, "min_replicates_n": 3, "ic50_pass_u95_max_nm": 100.0, "ic50_fail_l95_gt_nm": 500.0, "selectivity_pass_l95_min_fold": 50.0, "selectivity_fail_u95_lt_fold": 10.0, }, { "analyte_id": "HLA-DQ8-trans + HIP11", "required": True,