scripts/verify_iip0058_armz_ensc_isletsort_v2_and_2p24_portfolio.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0058_armz_ensc_isletsort_v2_and_2p24_portfolio.py · SHA-256: 33439d619c00fcc3…
"GP2 teratoma_n (all phrasings)",
False,
0,
),
(
r"(?:teratoma_followup_weeks|(?<![A-Za-z0-9_])followup_weeks)" + opt_qual + cmp_cap + num_cap,
float(sc_gp2["min_teratoma_followup_weeks"]),
"GE",
"GP2 followup_weeks (all phrasings)",
False,
0,
),
(
r"(?<![A-Za-z0-9_])(?:challenge_dose_cells|dose_cells)" + opt_qual + cmp_cap + comma_num_cap,
float(sc_gp2["min_teratoma_challenge_dose_cells"]),
"GE",
"GP2 challenge dose (all phrasings)",
True,
0,
),
):
_parse_proto_num_all(conflict_pat, prose_text, expected_v, label_c, expected_dir=exp_dir_c, min_matches=0, allow_commas=commas_c, flags=flg_c)
# ITGA1 protocol thresholds — ALL occurrences checked for BOTH direction AND value!
_parse_proto_num_all(
r"selectivity_ratio\s*=\s*live_cell_ec50_itga2_offtarget_nm\s*/\s*live_cell_ec50_itga1_target_nm" + cmp_cap + num_cap,
prose_text,
float(sc_it["min_live_cell_offtarget_over_target_ec50_ratio"]),
"ITGA1 live-cell EC50 selectivity ratio",
expected_dir="GE",
)
_parse_proto_num_all(
ineq_cmp_cap + num_cap + r"[×x]`?\s+SPR\s+selectivity(?:\s+vs\s+`?ITGA(?:2|10|11)`?)?",
prose_text,
float(sc_it["min_spr_selectivity_vs_itga2_10_11_each"]),
"ITGA1 SPR selectivity",
expected_dir="GE",
flags=re.IGNORECASE,
)
_parse_proto_num_all(
ineq_cmp_cap + num_cap + r"%`?\s+collagen(?:\s+MIDAS)?\s+inhibition",
prose_text,
float(sc_it["max_collagen_midas_inhibition_pct"]),
"ITGA1 collagen inhibition",
expected_dir="LE",
flags=re.IGNORECASE,
)
_parse_proto_num_all(
r"η_sort" + cmp_cap + num_cap + r"%",
prose_text,
float(sc_it["min_common_denominator_eta_sort_pct"]),
"ITGA1 eta_sort pct",
expected_dir="GE",
)
_parse_proto_num_all(
r"entpd3_mature_beta_pct" + cmp_cap + num_cap + r"%",
prose_text,
float(sc_it["min_entpd3_mature_beta_pct_for_release"]),
"ENTPD3 mature beta pct",
expected_dir="GE",
min_matches=2,
)
for conflict_pat, expected_v, exp_dir_c, label_c, flg_c in (
(
r"(?:min_live_cell_offtarget_over_target_ec50_ratio|live_cell_ec50_itga2_offtarget_nm\s*/\s*live_cell_ec50_itga1_target_nm|selectivity_ratio|itga1\s+(?:live[-_\s]?cell\s+)?(?:ec50\s+)?selectivity)"
+ opt_qual + cmp_cap + num_cap + r"(?:[×x])?",
float(sc_it["min_live_cell_offtarget_over_target_ec50_ratio"]),
"GE",
"ITGA1 EC50 selectivity ratio (all phrasings)",
re.IGNORECASE,
),
(
r"(?:min_spr_selectivity_vs_itga2_10_11_each|spr_selectivity_vs_itga(?:2|10|11)_fold|(?:itga1\s+)?spr\s+selectivity)"
+ opt_qual + cmp_cap + num_cap + r"(?:[×x])?",
float(sc_it["min_spr_selectivity_vs_itga2_10_11_each"]),
"GE",
"ITGA1 SPR selectivity (all phrasings)",
re.IGNORECASE,
),
(
r"(?:kd_itga1_nM|max_kd_itga1_nM)" + opt_qual + cmp_cap + num_cap,
float(sc_it["max_kd_itga1_nM"]),
"LE",
"ITGA1 Kd (all phrasings)",
re.IGNORECASE,
),
(
r"(?:residual_ligand_ng_per_1e6|max_residual_ligand_ng_per_1e6_cells)" + opt_qual + cmp_cap + num_cap,
float(sc_it["max_residual_ligand_ng_per_1e6_cells"]),
"LE",
"ITGA1 residual ligand (all phrasings)",
re.IGNORECASE,
),
(
r"(?:max_collagen_midas_inhibition_pct|collagen_midas_inhibition_pct|collagen\s+(?:midas\s+)?inhibition)"
+ opt_qual + cmp_cap + num_cap + r"\s*%",
float(sc_it["max_collagen_midas_inhibition_pct"]),
"LE",
"ITGA1 collagen inhibition (all phrasings)",
re.IGNORECASE,
),
(
r"(?:isx9_nkx61_retention_pct|pcamkii_retention_pct)" + opt_qual + cmp_cap + num_cap + r"\s*%",
float(sc_it["min_isx9_collagen_nkx61_retention_pct"]),
"GE",
"ITGA1 NKX6.1/pCaMKII retention (all phrasings)",
re.IGNORECASE,
),
(
r"(?:pfak_y397_fold_vs_vehicle|psrc_fold_vs_vehicle)" + opt_qual + cmp_cap + num_cap,
float(sc_it["max_live_cell_pfak_y397_fold_vs_vehicle"]),
"LE",
"ITGA1 pFAK/pSrc fold (all phrasings)",
re.IGNORECASE,
),
(
r"(?:integrin_internalization_pct|max_live_cell_integrin_internalization_pct)" + opt_qual + cmp_cap + num_cap + r"\s*%",
float(sc_it["max_live_cell_integrin_internalization_pct"]),
"LE",
"ITGA1 integrin internalization (all phrasings)",
re.IGNORECASE,
),
(
r"(?:post_sort_tph1_sc_ec_pct|max_post_sort_tph1_sc_ec_pct|tph1\+\s+sc-ec)" + opt_qual + cmp_cap + num_cap + r"\s*%",
float(sc_it["max_post_sort_tph1_sc_ec_pct"]),
"LE",
"ITGA1 TPH1+ SC-EC (all phrasings)",
re.IGNORECASE,
),
(
r"(?:min_common_denominator_eta_sort_pct|(?:η|eta)_sort)" + opt_qual + cmp_cap + num_cap + r"\s*%",
float(sc_it["min_common_denominator_eta_sort_pct"]),
"GE",
"ITGA1 eta_sort (all phrasings)",
re.IGNORECASE,
),
(
r"(?:entpd3_mature_beta_pct|min_entpd3_mature_beta_pct(?:_for_release)?|min_mature_beta_entpd3_pct_qc|`?entpd3`?(?:\s+mature\s+beta)?(?:\s+qc)?)"
+ opt_qual + cmp_cap + num_cap + r"\s*%",
float(sc_it["min_entpd3_mature_beta_pct_for_release"]),
"GE",
"ENTPD3 threshold (all phrasings)",
re.IGNORECASE,
),
(
r"(?:oq018_low_glucose_1mM_glucagon_fold)" + opt_qual + cmp_cap + num_cap,
float(sc_it["oq018_min_low_glucose_1mM_glucagon_fold"]),
"GE",
"OQ-018 glucagon fold (all phrasings)",
re.IGNORECASE,
),
(
r"(?:oq018_glucagon_auc_l95)" + opt_qual + cmp_cap + num_cap,
float(sc_it["oq018_min_glucagon_auc_l95_vs_60_30_10"]),
"GE",
"OQ-018 glucagon AUC L95 (all phrasings)",
re.IGNORECASE,
),
):
_parse_proto_num_all(conflict_pat, prose_text, expected_v, label_c, expected_dir=exp_dir_c, min_matches=0, flags=flg_c)
# EnSC protocol thresholds — ALL occurrences checked for BOTH direction AND value!
_parse_proto_num_all(r"mcb_plus_wcb_passage" + cmp_cap + num_cap, prose_text, float(sc_ensc_g["unrounded_max_mcb_plus_wcb_passage"]), "EnSC max passage", expected_dir="LE")
_parse_proto_num_all(r"mcb_plus_wcb_pds" + cmp_cap + num_cap, prose_text, float(sc_ensc_g["unrounded_max_mcb_plus_wcb_pds"]), "EnSC max PDs", expected_dir="LE")
_parse_proto_num_all(ineq_cmp_cap + r"P" + num_cap, prose_text, float(sc_ensc_g["unrounded_max_mcb_plus_wcb_passage"]), "EnSC <= P20 shorthand", expected_dir="LE", min_matches=1)
_parse_proto_num_all(ineq_cmp_cap + num_cap + r"\s*PD\b", prose_text, float(sc_ensc_g["unrounded_max_mcb_plus_wcb_pds"]), "EnSC <= 55.0 PD shorthand", expected_dir="LE", min_matches=1)
_parse_proto_num_all(
r"tumor_challenge_dose_cells" + cmp_cap + comma_num_cap,
prose_text,
float(sc_ensc_g["min_tumor_challenge_dose_cells"]),
"EnSC challenge dose cells",
expected_dir="GE",
allow_commas=True,
)
_parse_proto_num_all(r"(?:U_esc|estimand1_u_esc)" + cmp_cap + num_cap, prose_text, 1e-4, "EnSC Gate 0V escape U_esc", expected_dir="LE", min_matches=1)
_parse_proto_num_all(r"u95_exact" + cmp_cap + num_cap, prose_text, 1e-8, "EnSC Gate 5 live OQ-012 u95_exact", expected_dir="LE", min_matches=1)
_parse_proto_num_all(r"effective_clonogenic_trials_n_eff" + cmp_cap + comma_num_cap, prose_text, float(MIN_GATE5_OQ012_EFFECTIVE_TRIALS), "EnSC Gate 5 live OQ-012 n_eff", expected_dir="GE", min_matches=1, allow_commas=True)
_parse_proto_num_all(r"spike_in_detection_efficiency_eta" + cmp_cap + num_cap, prose_text, 0.30, "EnSC Gate 5 live OQ-012 spike-in eta", expected_dir="GE", min_matches=1)
_parse_proto_num_all(r"(?:U_cond|estimand2_u_cond)" + cmp_cap + num_cap, prose_text, 1e-3, "EnSC conditional escape U_cond", expected_dir="LE", min_matches=1)
_parse_proto_num_all(r"pulse1_si" + cmp_cap + num_cap, prose_text, 2.0, "EnSC pulse1_si", expected_dir="GE")
_parse_proto_num_all(r"pulse2_si" + cmp_cap + num_cap, prose_text, 2.0, "EnSC pulse2_si", expected_dir="GE")
_parse_proto_num_all(r"dynamic_gsis_si" + cmp_cap + num_cap, prose_text, 3.0, "EnSC dynamic_gsis_si", expected_dir="GE")
_parse_proto_num_all(r"stepdown_shutoff_t90_min" + cmp_cap + num_cap, prose_text, float(sc_ensc_g["stepdown_shutoff_t90_max_min"]), "EnSC stepdown shutoff t90", expected_dir="LE")
_parse_proto_num_all(r"stage7_ins_nkx61_beta_pct" + cmp_cap + num_cap + r"\s*%", prose_text, float(sc_ensc_g["min_stage7_ins_nkx61_beta_pct"]), "EnSC beta pct", expected_dir="GE")
_parse_proto_num_all(r"stage7_monohormonal_gcg_cpep_neg_alpha_pct" + cmp_cap + num_cap + r"\s*%", prose_text, float(sc_ensc_g["min_stage7_monohormonal_alpha_pct"]), "EnSC alpha pct", expected_dir="GE")
_parse_proto_num_all(r"stage7_tph1_sc_ec_pct" + cmp_cap + num_cap + r"\s*%", prose_text, float(sc_ensc_g["max_stage7_tph1_sc_ec_pct"]), "EnSC SC-EC pct", expected_dir="LE")
# GINS protocol thresholds — ALL occurrences checked for BOTH direction AND value!
_parse_proto_num_all(r"vector_copy_number_per_cell" + cmp_cap + num_cap, prose_text, 0.0, "GINS VCN", expected_dir="EQ")
_parse_proto_num_all(r"mouse_durability_days" + cmp_cap + num_cap, prose_text, float(sc_gins["min_mouse_durability_days"]), "GINS mouse_durability_days", expected_dir="GE")
_parse_proto_num_all(r"nhp_durability_days" + cmp_cap + num_cap, prose_text, float(sc_gins["min_nhp_durability_days"]), "GINS nhp_durability_days", expected_dir="GE")
_parse_proto_num_all(r"nhp_durability_pass_count" + cmp_cap + num_cap, prose_text, float(sc_gins["min_nhp_cohort_n"]), "GINS NHP durability pass count", expected_dir="GE")
_parse_proto_num_all(r"polyclonal_donor_count" + cmp_cap + num_cap, prose_text, float(sc_gins["min_polyclonal_t1d_pbmc_donors_n"]), "GINS polyclonal donor count", expected_dir="GE")
_parse_proto_num_all(r"polyclonal_donor_survival_pct" + cmp_cap + num_cap, prose_text, float(sc_gins["min_polyclonal_t1d_pbmc_survival_pct"]), "GINS polyclonal_donor_survival_pct", expected_dir="GE")
_parse_proto_num_all(ineq_cmp_cap + num_cap + r"\s*d`?\s+mouse", prose_text, float(sc_gins["min_mouse_durability_days"]), "GINS mouse durability days", expected_dir="GE")
_parse_proto_num_all(ineq_cmp_cap + num_cap + r"\s*d`?\s+NHP", prose_text, float(sc_gins["min_nhp_durability_days"]), "GINS NHP durability days", expected_dir="GE")
_parse_proto_num_all(
ineq_cmp_cap + num_cap + r"%`?\s+polyclonal\s+T1D\s+PBMC\s+survival",
prose_text,
float(sc_gins["min_polyclonal_t1d_pbmc_survival_pct"]),
"GINS polyclonal donor survival pct",
expected_dir="GE",
)
_parse_proto_num_all(
r"(?:alpha_coagg_monohormonal_gcg_pct|min_alpha_coagg_monohormonal_gcg_pct)" + opt_qual + cmp_cap + num_cap,
prose_text,
float(sc_gins["min_alpha_coagg_monohormonal_gcg_pct"]),
"GINS alpha co-aggregation floor",
expected_dir="GE",
min_matches=0,
)
_parse_proto_num_all(
r"(?:gastric_mucin_reversion_pct|mucin)" + opt_qual + cmp_cap + num_cap + r"\s*%",
prose_text,
5.0,
"GINS gastric mucin reversion",
expected_dir="LE",
min_matches=1,
flags=re.IGNORECASE,
)
# Best-effort sentence/clause-level heuristic conflict screen over prose outside the anchored JSON block
# (Audit R7-11 / R8-11). Structured-only opt-out mode explicitly marks unpinned_prose_verified=False and
# deep_companion_thresholds_verified=False; full prose verification requires enforce_companion_byte_pins=True.
sem_lower_cmp_pat = (
r"(?:<=|≤|(?<!-)<(?!-)"
r"|\bat\s+most\b|\bno\s+more\s+than\b|\bno\s+higher\s+than\b|\bno\s+greater\s+than\b"
r"|\bnot\s+exceed(?:s|ed|ing)?\b|\bcannot\s+exceed\b|\bnever\s+exceed(?:s|ed|ing)?\b"
r"|\bbelow\b|\bunder\b|\bless\s+than\b|\bceiling\b|\bmaximum\b|\bcapped\s+at\b|\bupper\s+(?:limit|bound)\b)"
)
sem_upper_cmp_pat = (
r"(?:>=|≥|(?<!-)>(?!-)"
r"|\bat\s+least\b|\bno\s+less\s+than\b|\bno\s+lower\s+than\b|\bnot\s+less\s+than\b|\bnot\s+below\b"
r"|\babove\b|\bover\b|\bgreater\s+than\b|\bmore\s+than\b|\bminimum\b"
r"|(?<!not )(?<!cannot )(?<!never )\bexceed(?:s|ed|ing)?\b|\blower\s+(?:limit|bound)\b)"
)
sem_num_tok = r"(?:[0-9][0-9,]*(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?|P[0-9]+(?:\.[0-9]+)?)"
sem_filler = (
r"(?:\s+(?:of|to|than|the|a|an|at|about|roughly|approximately|threshold|limit|"
r"value|level|rate|cap|floor|cutoff|count|score|fraction|ratio|percentage|ceiling|minimum|maximum|is|be)){0,5}"
)
sem_governed_subjects: tuple[tuple[str, str, str], ...] = (
("purity", "GE", r"(?:post[-_\s]?sort\s+(?:pdx1\+/nkx6\.1\+\s+)?purity|pdx1\+/nkx6\.1\+|post_sort_pdx1_nkx61_pct|\bpurity\b)"),
("recovery", "GE", r"(?:macs_recovery_eta_pct|conditional\s+(?:macs\s+)?(?:recovery|capture)|(?:macs\s+)?recovery|η_sort|\beta_sort\b)"),
("gpi", "GE", r"(?:gpi_post_dissociation_mfi_retention_pct|\bgpi\b(?:\s+mfi)?(?:\s+retention)?)"),
("selectivity", "GE", r"(?:selectivity_ratio|selectivity_vs_umod_fold|spr_selectivity(?:_vs_itga(?:2|10|11)_fold)?|\bselectivity\b)"),
("entpd3", "GE", r"(?:entpd3_mature_beta_pct|\bentpd3\b)"),
("teratoma_cohort_or_followup", "GE", r"(?:teratoma_n\b|teratoma_followup_weeks\b|(?<![a-z0-9_])followup_weeks\b|teratoma\s+(?:cohort|follow[- ]?up)|(?:tumor_)?challenge_dose_cells\b)"),
("durability", "GE", r"(?:mouse_durability_days|nhp_durability_days|nhp_durability_pass_count|polyclonal_donor_survival_pct|polyclonal_donor_count|\bdurability\b)"),
("glucagon", "GE", r"(?:oq018_low_glucose_1mM_glucagon_fold|oq018_glucagon_auc_l95|\bglucagon\b)"),