"exposure_duration_days": float(days), "intracellular_azt_mp_tp_lcms_verified": lcms_ok, } if float(peak_uM) > MAX_CERTIFYING_CLINICAL_AZT_PEAK_UM: reasons.append( f"Certifying AZT peak {float(peak_uM):.2f} uM exceeds clinical rescue ceiling " f"<= {MAX_CERTIFYING_CLINICAL_AZT_PEAK_UM:.1f} uM (human 300 mg oral Cmax ~4.49-5.61 uM; " "static 50-200 uM AZT may serve only as a non-certifying mechanistic positive control)." ) return _res("HOLD_SUPRAPHYSIOLOGIC_AZT_ONLY_NOT_CLINICAL_PK", 2, False, derived) if float(days) < MIN_CLINICAL_AZT_DAYS or not lcms_ok: reasons.append( f"Clinical AZT rescue arm requires >= {MIN_CLINICAL_AZT_DAYS:.0f}-day exposure " "(avoiding false-failing 1-2 h single-pulse shortcuts) AND verified intracellular AZT-MP/AZT-TP LC-MS." ) return _res("HOLD_INVALID_OR_MISSING_INPUT", 2, False, derived) # 4. Validate clonogenic assay dynamic range & matched 10 nM AP1903 iCasp9 comparator clono = observation.get("clonogenic_kill_assay") if not isinstance(clono, Mapping): reasons.append("Missing clonogenic_kill_assay object.") return _res("HOLD_INVALID_OR_MISSING_INPUT", 2, False, derived) assay_type = clono.get("assay_modality") n_plated = clono.get("n_clonogenic_cells_plated_per_arm") l95_log10 = clono.get("l95_log10_dividing_kill") zero_rebound = clono.get("zero_post_washout_colony_rebound") ap1903_comp = clono.get("matched_10nM_ap1903_icasp9_comparator_included") if assay_type != "CLONOGENIC_LIMITING_DILUTION_OUTGROWTH": reasons.append( f"assay_modality={assay_type!r} rejected: flow-cytometry-only readouts cannot resolve >= 4.0-log10 kill; " "CLONOGENIC_LIMITING_DILUTION_OUTGROWTH is required." ) return _res("HOLD_INSUFFICIENT_CLONOGENIC_DYNAMIC_RANGE", 2, False, derived) if not _is_strict_int(n_plated) or n_plated < MIN_CLONOGENIC_PLATED: reasons.append( f"n_clonogenic_cells_plated_per_arm={n_plated!r} < {MIN_CLONOGENIC_PLATED:,} required for >= 4.0-log10 dynamic range." ) return _res("HOLD_INSUFFICIENT_CLONOGENIC_DYNAMIC_RANGE", 2, False, derived) if not _is_real_number(l95_log10) or not isinstance(zero_rebound, bool) or not isinstance(ap1903_comp, bool): reasons.append("Missing or invalid l95_log10_dividing_kill, zero_post_washout_colony_rebound, or matched_10nM_ap1903_icasp9_comparator_included.") return _res("HOLD_INVALID_OR_MISSING_INPUT", 2, False, derived) if not ap1903_comp: reasons.append("Matched 10 nM AP1903 iCasp9 comparator arm (GY-026 non-inferiority precedent) is mandatory.") return _res("HOLD_INVALID_OR_MISSING_INPUT", 2, False, derived) # 5. Validate 1:100 spike-in mature Stage-7 beta-cell bystander & mitochondrial safety byst = observation.get("mature_beta_bystander_and_mito_safety") if not isinstance(byst, Mapping): reasons.append("Missing mature_beta_bystander_and_mito_safety object.") return _res("HOLD_INVALID_OR_MISSING_INPUT", 2, False, derived) viab_l95 = byst.get("mature_beta_viability_l95_pct") gsis_l95 = byst.get("mature_beta_gsis_retention_l95_pct") mito_ok = byst.get("mitochondrial_dttp_safety_check_passed") if not _is_real_number(viab_l95) or not _is_real_number(gsis_l95) or not isinstance(mito_ok, bool): reasons.append("Invalid mature_beta_bystander_and_mito_safety fields.") return _res("HOLD_INVALID_OR_MISSING_INPUT", 2, False, derived) derived.update({ "n_clonogenic_cells_plated_per_arm": n_plated, "l95_log10_dividing_kill": float(l95_log10), "zero_post_washout_colony_rebound": zero_rebound, "mature_beta_viability_l95_pct": float(viab_l95), "mature_beta_gsis_retention_l95_pct": float(gsis_l95), "mitochondrial_dttp_safety_check_passed": mito_ok, }) if float(viab_l95) < MIN_BYSTANDER_BETA_VIAB_L95_PCT or float(gsis_l95) < MIN_BYSTANDER_BETA_GSIS_L95_PCT or not mito_ok: reasons.append( f"Mature Stage-7 beta-cell sparing / mitochondrial safety failed " f"(viab L95={float(viab_l95):.1f}% [>=85%], GSIS L95={float(gsis_l95):.1f}% [>=85%], mito_ok={mito_ok}; " "Sato 2013 bystander / McKee 2004 mitochondrial IC50 ~7 uM risk)." ) return _res("HOLD_BYSTANDER_OR_MITOCHONDRIAL_BETA_TOXICITY", 2, False, derived) if float(l95_log10) < MIN_CLONOGENIC_L95_LOG10 or not zero_rebound: reasons.append( f"Clinical-exposure AZT dividing-cell clonogenic kill L95={float(l95_log10):.2f} log10 (< 4.0) " f"or post-washout colony rebound observed (zero_rebound={zero_rebound}). " "Holding chr13 hTMPK-F105Y switch credit while leaving primary AAVS1 iCasp9 gate unaffected." ) return _res("HOLD_HTMPK_SWITCH_UNQUALIFIED", 2, False, derived) reasons.append( f"Qualified {construct_id} dividing-cell containment switch under clinical AZT PK " f"({float(peak_uM):.2f} uM x {float(days):.0f} d, L95={float(l95_log10):.2f} log10 across {n_plated:,} cells/arm, " "mature beta spared). Remains dividing-escape containment only (never a post-mitotic whole-graft substitute)." ) return _res("PASS_GATE33_HTMPK_DIVIDING_SWITCH_QUALIFIED", 0, True, derived) def _build_valid_obs(construct_id: str = "DESIGN_Y_CLYBL_CDK1P_HTMPK_F105Y") -> Dict[str, Any]: return { "promoter_construct_id": construct_id, "claimed_as_postmitotic_whole_graft_substitute": False, "clinical_azt_pk_arm": { "certifying_azt_peak_uM": 5.0, "exposure_duration_days": 7.0, "intracellular_azt_mp_tp_lcms_verified": True, }, "clonogenic_kill_assay": { "assay_modality": "CLONOGENIC_LIMITING_DILUTION_OUTGROWTH", "n_clonogenic_cells_plated_per_arm": 1_000_000, "l95_log10_dividing_kill": 4.35, "zero_post_washout_colony_rebound": True, "matched_10nM_ap1903_icasp9_comparator_included": True, }, "mature_beta_bystander_and_mito_safety": { "mature_beta_viability_l95_pct": 93.5, "mature_beta_gsis_retention_l95_pct": 91.2, "mitochondrial_dttp_safety_check_passed": True, }, } def run_gate33_decision_table_self_tests() -> Dict[str, Any]: """Run 10 deterministic fail-closed self-tests on evaluate_gate33_htmpk_azt_switch.""" r_pass_y = evaluate_gate33_htmpk_azt_switch(_build_valid_obs("DESIGN_Y_CLYBL_CDK1P_HTMPK_F105Y")) r_pass_d = evaluate_gate33_htmpk_azt_switch(_build_valid_obs("DESIGN_D_CLYBL_404BP_CDK1_300_HTMPK_F105Y")) # 3. Claiming post-mitotic whole-graft substitution -> FAIL_GY002 (exit 3) o_pm = _build_valid_obs() o_pm["claimed_as_postmitotic_whole_graft_substitute"] = True r_pm = evaluate_gate33_htmpk_azt_switch(o_pm) # 4. Supraphysiologic 100 uM static AZT only -> HOLD_SUPRAPHYSIOLOGIC o_hi = _build_valid_obs() o_hi["clinical_azt_pk_arm"]["certifying_azt_peak_uM"] = 100.0 r_hi = evaluate_gate33_htmpk_azt_switch(o_hi) # 5. Flow cytometry only -> HOLD_INSUFFICIENT_CLONOGENIC_DYNAMIC_RANGE o_flow = _build_valid_obs() o_flow["clonogenic_kill_assay"]["assay_modality"] = "ANNEXIN_V_FLOW_CYTOMETRY" r_flow = evaluate_gate33_htmpk_azt_switch(o_flow) # 6. Underpowered clonogenic count (< 10^6) -> HOLD_INSUFFICIENT_CLONOGENIC_DYNAMIC_RANGE o_small = _build_valid_obs() o_small["clonogenic_kill_assay"]["n_clonogenic_cells_plated_per_arm"] = 50_000 r_small = evaluate_gate33_htmpk_azt_switch(o_small) # 7. Sub-4-log10 kill (reproducing Marin-like incomplete clearance) -> HOLD_HTMPK_SWITCH_UNQUALIFIED, primary iCasp9 unaffected! o_low = _build_valid_obs() o_low["clonogenic_kill_assay"]["l95_log10_dividing_kill"] = 1.8 r_low = evaluate_gate33_htmpk_azt_switch(o_low) # 8. Mature beta-cell bystander / mitochondrial toxicity -> HOLD_BYSTANDER_OR_MITOCHONDRIAL_BETA_TOXICITY o_byst = _build_valid_obs() o_byst["mature_beta_bystander_and_mito_safety"]["mature_beta_gsis_retention_l95_pct"] = 72.0 r_byst = evaluate_gate33_htmpk_azt_switch(o_byst) # 9. Unrecognized / conflated promoter construct ID -> HOLD_INVALID_OR_MISSING_INPUT o_bad_p = _build_valid_obs("GENERIC_HTMPK_POOLED") r_bad_p = evaluate_gate33_htmpk_azt_switch(o_bad_p) # 10. Strict JSON NaN & duplicate-key rejection + universal invariants nan_rej = False try: load_strict_json_text('{"x": NaN}', "nan_probe") except StrictJsonError: nan_rej = True dup_rej = False try: load_strict_json_text('{"a": 1, "a": 2}', "dup_probe") except StrictJsonError: dup_rej = True all_res = [r_pass_y, r_pass_d, r_pm, r_hi, r_flow, r_small, r_low, r_byst, r_bad_p] cases = { "01_design_y_cdk1p_clinical_pk_clonogenic_pass": ( r_pass_y["verdict"] == "PASS_GATE33_HTMPK_DIVIDING_SWITCH_QUALIFIED" and r_pass_y["exit_code"] == 0 and r_pass_y["chr13_backup_switch_qualified"] is True and r_pass_y["postmitotic_whole_graft_substitute_authorized"] is False ), "02_design_d_cdk1_300_separate_promoter_pass": ( r_pass_d["verdict"] == "PASS_GATE33_HTMPK_DIVIDING_SWITCH_QUALIFIED" and r_pass_d["exit_code"] == 0 and r_pass_d["chr13_backup_switch_qualified"] is True ), "03_postmitotic_substitute_claim_hard_blocks_gy002": ( r_pm["verdict"] == "FAIL_GY002_POSTMITOTIC_SCOPE_VIOLATION" and r_pm["exit_code"] == 3 and r_pm["chr13_backup_switch_qualified"] is False ), "04_supraphysiologic_100uM_azt_only_emits_hold": ( r_hi["verdict"] == "HOLD_SUPRAPHYSIOLOGIC_AZT_ONLY_NOT_CLINICAL_PK" and r_hi["exit_code"] == 2 ), "05_flow_cytometry_only_rejected_insufficient_dynamic_range": ( r_flow["verdict"] == "HOLD_INSUFFICIENT_CLONOGENIC_DYNAMIC_RANGE" and r_flow["exit_code"] == 2 ), "06_underpowered_50k_clonogenic_arm_rejected": ( r_small["verdict"] == "HOLD_INSUFFICIENT_CLONOGENIC_DYNAMIC_RANGE" and r_small["exit_code"] == 2 ), "07_sub_4log_kill_holds_chr13_preserving_primary_aavs1_icasp9": ( r_low["verdict"] == "HOLD_HTMPK_SWITCH_UNQUALIFIED" and r_low["exit_code"] == 2 and r_low["chr13_backup_switch_qualified"] is False and r_low["primary_aavs1_icasp9_gate_unaffected"] is True ), "08_mature_beta_bystander_or_mito_toxicity_emits_hold": ( r_byst["verdict"] == "HOLD_BYSTANDER_OR_MITOCHONDRIAL_BETA_TOXICITY" and r_byst["exit_code"] == 2 ), "09_conflated_generic_promoter_id_rejected": ( r_bad_p["verdict"] == "HOLD_INVALID_OR_MISSING_INPUT" and r_bad_p["exit_code"] == 2 ), "10_strict_json_and_universal_scope_and_primary_switch_invariants": ( nan_rej and dup_rej and all(r["postmitotic_whole_graft_substitute_authorized"] is False for r in all_res) and all(r["primary_aavs1_icasp9_gate_unaffected"] is True for r in all_res) ), } if not all(cases.values()): failed = [k for k, v in cases.items() if not v] raise RuntimeError(f"Gate 33 self-tests failed: {failed}") return { "total_cases": len(cases), "all_passed": True, "universal_never_postmitotic_substitute_invariant": True, "universal_primary_icasp9_unaffected_invariant": True, "cases": cases, } def audit_playbook_gy002_and_blueprint_sync(repo_root: Path) -> Dict[str, Any]: pb = (repo_root / PLAYBOOK_REL).read_text(encoding="utf-8") bp = (repo_root / BLUEPRINT_REL).read_text(encoding="utf-8") g0v = (repo_root / GATE0V_REL).read_text(encoding="utf-8") gy = load_strict_json_file(repo_root / GRAVEYARD_REL) dt = load_strict_json_file(repo_root / DECISION_TREE_REL) gy2 = next( (e for e in gy.get("graveyard_entries", []) if e.get("graveyard_id") == "GRAVEYARD_002_LINEAGE_RESTRICTED_G6PC2_OR_INS_ICASP9_SUICIDE_SWITCH"), None, ) if gy2 is None: raise RuntimeError("GRAVEYARD_002 entry missing") gy2_blob = json.dumps(gy2, ensure_ascii=False)