scripts/wetlab_contract.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/wetlab_contract.py · SHA-256: 6bb3955530f8f05d…
and not ap1903_insulin_dump_unmitigated
and not mandatory_hypoxic_or_p10_retention_cliff_failed
and not unmitigated_cd47_or_hypoxic_retention_cliff_failed
and not zero_event_proportion_missing_denominator_or_explicit_se
)
has_explicit_dec048_muse_r5_obs = bool(
'obs_ap1903_pulsed_pk_log10_kill' in validated_stage0
and 'obs_ap1903_monotherapy_pulsed_pk_log10_kill' in validated_stage0
and ap1903_mono_pk_lower95 >= 4.0
and 'obs_ap1903_step1_sublethal_survivor_count_k' in validated_stage0
and ap1903_step1_trials_supplied
and ap1903_step1_trials >= 29957322.8
and 'obs_hypoxic_15mmhg_f_isr_translation_ratio' in validated_stage0
and _lower95('obs_hypoxic_15mmhg_f_isr_translation_ratio') >= 0.50
and 'obs_iec_cd47_p10_molecules' in validated_stage0
and se_provenance_by_mean.get('obs_iec_cd47_p10_molecules') == 'EXPLICIT_SE_SUPPLIED'
and _lower95('obs_iec_cd47_p10_molecules') >= 180000.0
and 'obs_iec_abo_ab_antigen_mfi_ratio' in validated_stage0
and _upper95('obs_iec_abo_ab_antigen_mfi_ratio') <= 1.05
and 'obs_post_stress_nkg2d_dnam1_attributed_lysis_pct' in validated_stage0
and _upper95('obs_post_stress_nkg2d_dnam1_attributed_lysis_pct') <= 5.0
and 'obs_senescent_p16_sasp_positive_cell_pct' in validated_stage0
and senescent_p16_upper95 <= 1.0
and not ap1903_pulsed_pk_kill_failed
and not ap1903_step1_sublethal_survivor_detected
and not iec_vascular_support_failed
and not post_stress_nkg2d_dnam1_lysis_failed
and not senescent_p16_sasp_failed
and not zero_event_proportion_missing_denominator_or_explicit_se
)
# Single authoritative policy table for all 13 canonical DEC-053/055/057 endpoints required directly (no supplementary alias substitution; R7S2-F01; DEC-057):
has_explicit_dec053_muse_r6_obs = bool(
'obs_gate0v_cvb_day14_log10_viral_reduction' in validated_stage0
and validated_stage0['obs_gate0v_cvb_day14_log10_viral_reduction'] >= 3.0
and _lower95('obs_gate0v_cvb_day14_log10_viral_reduction') >= 3.0
and 'obs_gate0v_day28_persistent_vp1_ie1_positive_cell_pct' in validated_stage0
and validated_stage0['obs_gate0v_day28_persistent_vp1_ie1_positive_cell_pct'] <= 0.0
and vp1_ie1_upper95 <= 0.05
and 'obs_post_stress_20q11_bcl2l1_outgrowth_fold' in validated_stage0
and validated_stage0['obs_post_stress_20q11_bcl2l1_outgrowth_fold'] <= 1.0
and _upper95('obs_post_stress_20q11_bcl2l1_outgrowth_fold') <= 1.20
and 'obs_assembled_cassette_chandler_loop_sc5b9_fold' in validated_stage0
and validated_stage0['obs_assembled_cassette_chandler_loop_sc5b9_fold'] <= 2.0
and _upper95('obs_assembled_cassette_chandler_loop_sc5b9_fold') <= 2.0
and 'obs_assembled_cassette_chandler_loop_platelet_retention_pct' in validated_stage0
and validated_stage0['obs_assembled_cassette_chandler_loop_platelet_retention_pct'] >= 70.0
and _lower95('obs_assembled_cassette_chandler_loop_platelet_retention_pct') >= 70.0
and 'obs_hypoxic_72h_five_transgene_joint_above_threshold_fraction' in validated_stage0
and validated_stage0['obs_hypoxic_72h_five_transgene_joint_above_threshold_fraction'] >= 0.90
and _lower95('obs_hypoxic_72h_five_transgene_joint_above_threshold_fraction') >= 0.90
and 'obs_apoptotic_effero_clearance_retention_pct_of_wt' in validated_stage0
and validated_stage0['obs_apoptotic_effero_clearance_retention_pct_of_wt'] >= 70.0
and _lower95('obs_apoptotic_effero_clearance_retention_pct_of_wt') >= 70.0
and 'obs_nutlin3a_p21_mdm2_fold_induction' in validated_stage0
and validated_stage0['obs_nutlin3a_p21_mdm2_fold_induction'] >= 5.0
and _lower95('obs_nutlin3a_p21_mdm2_fold_induction') >= 5.0
and 'obs_vascular_pericyte_ng2_pdgfrb_coverage_pct' in validated_stage0
and validated_stage0['obs_vascular_pericyte_ng2_pdgfrb_coverage_pct'] >= 70.0
and _lower95('obs_vascular_pericyte_ng2_pdgfrb_coverage_pct') >= 70.0
and 'obs_assembled_cluster_slc18a1_enterochromaffin_pct' in validated_stage0
and validated_stage0['obs_assembled_cluster_slc18a1_enterochromaffin_pct'] <= 1.0
and slc18a1_ec_upper95 <= 1.0
and 'obs_assembled_cluster_ins_gcg_polyhormonal_pct' in validated_stage0
and validated_stage0['obs_assembled_cluster_ins_gcg_polyhormonal_pct'] <= 2.0
and _upper95('obs_assembled_cluster_ins_gcg_polyhormonal_pct') <= 2.0
and 'obs_assembled_cluster_ki67_progenitor_pct' in validated_stage0
and validated_stage0['obs_assembled_cluster_ki67_progenitor_pct'] <= 0.5
and ki67_prog_upper95 <= 0.5
and 'obs_post_stress_mafa_nkx61_beta_identity_retention_pct' in validated_stage0
and validated_stage0['obs_post_stress_mafa_nkx61_beta_identity_retention_pct'] >= 85.0
and _lower95('obs_post_stress_mafa_nkx61_beta_identity_retention_pct') >= 85.0
and not post_stress_20q11_outgrowth_failed
and not nutlin3a_p53_functional_failed
and not gate0v_viral_sanctuary_failed
and not assembled_cassette_chandler_ibmir_failed
and not effero_clearance_failed
and not assembled_cluster_lineage_or_identity_failed
and not zero_event_proportion_missing_denominator_or_explicit_se
)
# Mandatory original exact-product primary biological & pouch endpoints required for READY_FOR_ENCAPSULATION_COMPLETE_STAGE0_EVIDENCE (R7S3-F01; DEC-058; Design Z Zero-CaO2 H2O2 exemption IIP-0024; DEC-103):
# Prevents composite COMP-R4 combined-stress secondary coupons or omitted/UNAVAILABLE primary pouch oxygen/peroxide/pH/HLA-II/yield/CD47/SERPINB9/iCasp9 observations from awarding COMPLETE Stage-0 readiness.
_orig_primary_keys_for_product = tuple(
mk for mk in STAGE0_ORIGINAL_PRIMARY_MANDATORY_MEAN_KEYS
if not (_is_design_z_product and mk in ('obs_pouch_min_po2_mmhg', 'obs_pouch_max_h2o2_uM', 'obs_pouch_max_ph'))
)
missing_original_primary_endpoints = [
mk for mk in _orig_primary_keys_for_product if mk not in validated_stage0
]
has_explicit_original_primary_obs = bool(
not missing_original_primary_endpoints
and all(
se_provenance_by_mean.get(mk) == 'EXPLICIT_SE_SUPPLIED'
for mk in _orig_primary_keys_for_product
)
and validated_stage0['obs_stage7_yield_ratio'] >= 0.70
and _lower95('obs_stage7_yield_ratio') >= 0.70
and validated_stage0['obs_cd47_fold'] >= 3.0
and _lower95('obs_cd47_fold') >= 3.0
and validated_stage0['obs_serpinb9_log10_kass'] >= 6.0
and _lower95('obs_serpinb9_log10_kass') >= 6.0
and validated_stage0['obs_icasp9_log10_kill'] >= 4.0
and icasp9_lower95 >= 4.0
and (_is_design_z_product or (validated_stage0['obs_pouch_min_po2_mmhg'] >= 15.0 and _lower95('obs_pouch_min_po2_mmhg') >= 15.0))
and (_is_design_z_product or (validated_stage0['obs_pouch_max_h2o2_uM'] <= 5.0 and _upper95('obs_pouch_max_h2o2_uM') <= 5.0))
and (_is_design_z_product or (validated_stage0['obs_pouch_max_ph'] <= 7.45 and _upper95('obs_pouch_max_ph') <= 7.45))
and validated_stage0['obs_ifng_hla_dr_dq_negative_pct'] >= 99.0
and _lower95('obs_ifng_hla_dr_dq_negative_pct') >= 99.0
and not primary_biological_or_pouch_gate_failed
)
has_explicit_release_critical_molecule_and_rate_se = bool(
'obs_cd47_hour0_molecules' in validated_stage0
and se_provenance_by_mean.get('obs_cd47_hour0_molecules') == 'EXPLICIT_SE_SUPPLIED'
and 'obs_hlae_hour0_molecules' in validated_stage0
and se_provenance_by_mean.get('obs_hlae_hour0_molecules') == 'EXPLICIT_SE_SUPPLIED'
and all(
se_provenance_by_mean.get(mk) == 'EXPLICIT_SE_SUPPLIED'
for mk in STAGE0_RELEASE_CRITICAL_MOLECULE_AND_RATE_MEAN_KEYS
if mk in validated_stage0
)
)
has_explicit_extended_stage0_obs = bool(
has_explicit_original_primary_obs
and has_explicit_release_critical_molecule_and_rate_se
and 'obs_nkg2c_adaptive_nk_lysis_pct' in validated_stage0
and 'obs_kir_nkg2a_neg_nk_lysis_pct' in validated_stage0
and 'obs_phagocytosis_index_pct' in validated_stage0
and tp53_duplex_depth_explicitly_supplied
and vaf_duplex_depth >= 62958.0
and cast_duplex_depth_explicitly_supplied
and cast_duplex_depth >= 62958.0
and mcb_clonogenic_trials_explicitly_supplied
and mcb_clonogenic_trials >= 299573228.0
and mcb_survivors_k_explicitly_supplied
and mcb_survivors_k == 0.0
and not mcb_clonogenic_survivor_detected
and has_chronic_capsule_obs
and has_explicit_indirect_apc_gate0d_obs
and has_explicit_exogenous_b2m_obs
and has_explicit_glucagon_and_perfusion_obs
and has_explicit_dec046_astra_r5_obs
and has_explicit_dec047_tumour_and_retention_obs
and has_explicit_dec048_muse_r5_obs
and has_explicit_dec053_muse_r6_obs
and combined_stress_spec.get('full_7metric_panel_complete') is True
and combined_stress_coupon_status == 'RETAIN_EMBODIMENT_A_STAR_4143BP'
and not is_comp_r4_product
and (not _req_iip0020_full or (iip0020_hold_status is None and (_dz_arm_val is not None or iip0020_p05_species_status == 'CLEARED_P05_HUMAN_P04040_SPECIES_ENDOTOXIN_AND_SHED_MASS_GATE') and iip0020_cuff_status == 'CLEARED_CUFF_HUMORAL_HYDROLYSIS_AND_HEPATOCYTE_SAFETY_GATE'))
and (not _req_iip0021_full or (iip0021_hold_status is None and iip0021_rest_status is not None and iip0021_cond_status == 'CLEARED_CONDITIONING_4ARM_PELLET_LOQ_NQO1_AND_LINEAGE_GSIS_GATE'))
and (not _req_iip0022_full or iip0022_hold_status is None)
and (not _req_iip0024_full or iip0024_hold_status is None)
and not non_integer_scored_cell_or_trial_denominator
and not mosaic_explicit_se_missing_scored_cell_denominator
)
any_fallback_switch_triggered = bool(
s1_promoted
or s2_promoted
or s3_promoted
or s4_promoted
or s5_promoted
or s6_promoted
or s7_allo_triggered
or s8_promoted
or s8_tyk2_epistasis_triggered
or s9_promoted
or (s10_nkg2c_triggered and not s10_v3_release_qualified)
or (_s10_v3_active and not s10_v3_release_qualified)
or combined_stress_promoted
or track2_kir_or_hlag1_fallback_promoted
)
any_resolved_component_on_hold = any(
str(resolved_arch.get(k, '')).startswith('HOLD_')
for k in ('locus1_construct', 'locus2_construct', 'locus3_construct', 'locus4_construct', 'track2_kir_subbank_construct')
)
_prod_non_executable = bool(product_def is not None and product_def.get('execution_supported') is False)
_pvid_for_tier = str(product_def.get('product_variant_id', '')) if product_def is not None else ''
if safety_kill_s9_triggered:
lot_release_readiness_tier = 'HARD_SAFETY_STOP_REJECTED'
elif iip0031_tier6b_eval is not None and iip0031_tier6b_eval.get('hard_stop') is True:
lot_release_readiness_tier = 'HARD_SAFETY_STOP_REJECTED'
resolved_arch['lot_maturation_status'] = 'FAIL_TIER6B_OUTGROWTH_DETECTED'
elif str(resolved_arch.get('lot_maturation_status', '')).startswith('NO_GO_'):
lot_release_readiness_tier = 'NO_GO_TERMINAL_BIOTRANSPORT_OR_IMMUNE_CEILING_EXCEEDED'
elif resolved_arch.get('lot_maturation_status') not in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY') or any_resolved_component_on_hold:
lot_release_readiness_tier = 'HOLD_FAILED_OR_INCOMPLETE_GATE'
elif is_comp_r4_product and combined_stress_coupon_status == 'RETAIN_EMBODIMENT_A_STAR_4143BP':
lot_release_readiness_tier = 'CANDIDATE_NOT_INDICATED_RETAIN_EMBODIMENT_A_STAR_4143BP'
elif _prod_non_executable and (_pvid_for_tier == 'ISLET1_B2_5LOCUS_BASE' or _pvid_for_tier in _staged_l2_v3_ids):
lot_release_readiness_tier = 'STAGE0_RESEARCH_COMPARATOR_PENDING_ALLELE_QC'
resolved_arch['lot_maturation_status'] = 'STAGE0_RESEARCH_COMPARATOR_PENDING_ALLELE_QC'
elif _prod_non_executable and _pvid_for_tier == 'ISLET1_Z_X_MOL_140UM_ZERO_CAO2':
if any_fallback_switch_triggered:
lot_release_readiness_tier = 'CANDIDATE_FALLBACK_PROMOTED_PENDING_REPLACEMENT_QUALIFICATION'
elif full_5endpoint_s9_panel_complete and has_explicit_maturity_obs and has_explicit_immune_and_ocr_core_obs and has_explicit_extended_stage0_obs:
lot_release_readiness_tier = 'WILDCARD_COUPON_QUALIFIED_NON_EXECUTABLE'
resolved_arch['lot_maturation_status'] = 'WILDCARD_COUPON_QUALIFIED_NON_EXECUTABLE'
else:
lot_release_readiness_tier = 'HOLD_FAILED_OR_INCOMPLETE_GATE'
resolved_arch['lot_maturation_status'] = 'HOLD_INCOMPLETE_WILDCARD_STAGE0_EVIDENCE'
elif _prod_non_executable:
lot_release_readiness_tier = 'RESEARCH_COMPARATOR_UNSUPPORTED_VARIANT_HOLD'
resolved_arch['lot_maturation_status'] = 'RESEARCH_COMPARATOR_UNSUPPORTED_VARIANT_HOLD'
elif any_fallback_switch_triggered:
lot_release_readiness_tier = 'CANDIDATE_FALLBACK_PROMOTED_PENDING_REPLACEMENT_QUALIFICATION'
elif full_5endpoint_s9_panel_complete and has_explicit_maturity_obs and has_explicit_immune_and_ocr_core_obs and has_explicit_extended_stage0_obs:
lot_release_readiness_tier = (
'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'
if prior_s9_reset_history_retained
else 'READY_FOR_ENCAPSULATION_COMPLETE_STAGE0_EVIDENCE'
)
elif full_5endpoint_s9_panel_complete and has_explicit_maturity_obs and has_explicit_immune_and_ocr_core_obs:
lot_release_readiness_tier = (
'PROVISIONAL_CORE_14_PANEL_CLEARED_WITH_RETAINED_PRIOR_S9_HISTORY'
if prior_s9_reset_history_retained
else 'PROVISIONAL_CORE_14_PANEL_CLEARED_EXTENDED_NK_PHAGO_DEPTH_CHRONIC_UNMEASURED'
)
elif full_5endpoint_s9_panel_complete and has_explicit_maturity_obs:
lot_release_readiness_tier = (
'PROVISIONAL_S9_AND_MATURITY_CLEARED_WITH_RETAINED_PRIOR_S9_HISTORY'
if prior_s9_reset_history_retained
else 'PROVISIONAL_S9_AND_MATURITY_CLEARED_IMMUNE_AND_OCR_GATES_UNMEASURED'
)
else:
lot_release_readiness_tier = (
'PROVISIONAL_CORE_S9_CLEARED_WITH_RETAINED_PRIOR_S9_HISTORY'
if prior_s9_reset_history_retained
else 'PROVISIONAL_CORE_S9_CLEARED_UNMEASURED_GATES_PENDING'
)
resolved_arch['lot_release_readiness_tier'] = lot_release_readiness_tier
decisions = {
'S1_Locus3_Kinetic_and_Topology_Gate_0C': (
'NO_GO_ACUTE_REGIME_II_LYSIS_GT_25PCT_TERMINAL'
if lysis_2h_upper95 > 25.0
else ('PROMOTE_ISLET1_A4_L3_BFB_BASALFLOOR' if s1_promoted else 'RETAIN_CHAMPION_LOCUS3_OR_L3_SCARFREE_3799')
),
'S2_Locus1_Arm1B_vs_Arm1X_Gate_0A': (
'HOLD_S2_CATASTROPHIC_NKG2A_LYSIS_GT_15PCT_REQUIRES_MULTI_RECEPTOR_RESCUE'
if catastrophic_nkg2a_lysis_exceeds_arm1x
else (
'PROMOTE_ISLET1_A4_X_MOL_RNLS_WT'
if s2_promoted
else 'RETAIN_EMBODIMENT_A_STAR_ARM1B'
)
),
'S3_Locus1_Constitutive_Split_Fallback_DX_S': (
'PROMOTE_ISLET1_A4_DXS_ARM1C_L4CD47'
if s3_promoted
else (
'HOLD_DXS_RARE_EVENT_REQUIRES_EXPLICIT_SE_OR_CELL_COUNT'
if dxs_hold_missing_explicit_se_or_counts