OpenIslet

scripts/verify_iip0041_clinical_h1_cd64t_siglec.py

EXP-028 (CAND-031 / Target IIP-0041 — Bucket 2A) Remediated Verification Suite

script Release v0.8.0 gen-eb955f8266035aba 984 KB · 69 sections

Use this file in any AI chat (paste-only or attachment-capable):

Download as text (.txt) Download section (.txt)

Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0041_clinical_h1_cd64t_siglec.py · SHA-256: f004cf6d8259b8b4…

                "P(H1 >= 0.90) >= 0.85 on cluster-adjusted (k_eff, n_eff), AND "
                "(3) Primary peer-reviewed PDFs verify >= 6-month sustained C2b durability, quantitative stimulated C-peptide, complete "
                "per-recipient adjudication, and transparent parallel disclosure of the separate CMC Readiness Ledger "
                "(P_release_CMC and H1_CMC_ATTEMPTED_LOT_READINESS). Clopper-Pearson 95% CIs MUST be published alongside any future headline change."
            ),
            "shi_2026_outcome_decision_table": shi_decision_table,
            "wang2024_autologous_vs_d1b_p1_asymmetry": (
                "Wang et al. 2024 (PMID:39326417) used unedited autologous CiPSC-islets in the abdominal anterior rectus sheath under "
                "continued 3-drug prior liver-tx IS plus peri-infusion induction; in Part D S2a, D1b-Auto-C v2 p1 is conservatively "
                "held at 0.62 (reflecting sequential 6-locus GMP editing friction rather than unedited CiPSC differentiation), "
                "while S2b reports the proportionally scaled 0.6341 sensitivity."
            ),
            "primary_cmc_and_registry_sources": [
                "ClinicalTrials.gov NCT04786262 (updated 2026-09-01; Phase 1/2/3 master protocol evaluating VX-880/zimislecel and VX-017, target enrollment n=57, primary completion 2027-12-31)",
                "Vertex Pharmaceuticals Q1 2026 Corporate/Earnings Update (May 2026: Jan 2026 voluntary zimislecel dosing pause for internal manufacturing analysis completed and dosing resumed; original 2026 BLA delayed)",
                "Vertex Pharmaceuticals Q3 2026 Corporate/Earnings Release (Nov 2, 2026: strategic prioritization of universal-donor Type-O VX-017 with FDA Fast Track designation over blood-type A/AB-restricted zimislecel; pivotal initiation expected 2027)",
            ],
        },
        "key_forensic_findings": [
            "Reichman et al. 2025 (NEJM; PMID:40544428): n = 14 analyzed population comprises 14 dosed participants in Parts A-C with >= 12 months follow-up (2 half-dose Part A + 12 full-dose Parts B/C; excludes any dosed participants with < 12 months follow-up), with 14/14 C-peptide+ engraftment; in the 12 full-dose Parts B/C 12-month analysis, 12/12 met the original NEJM glycemic endpoint, 11/12 had Day-365 CGM records in Figure 3, 10/12 (83.33%) were insulin-independent at Day 365, and 2/12 received protocol-prohibited peri-infusion glucocorticoids (both remained on insulin); 2 deaths occurred in the 14-participant analyzed population: 1 fatal cryptococcal meningitis (~19.5 months post-infusion) following surgery complicated by skull-base injury, prolonged protocol-prohibited systemic glucocorticoids, and concurrent chronic immunosuppression (assessed by investigators as unrelated to zimislecel [cell product] BUT related to the chronic immunosuppressive medication regimen), and 1 progression of pre-existing neurocognitive disease (~30 months post-infusion, unrelated to zimislecel or immunosuppression).",
            "Vertex 2026 CMC & strategic update (ClinicalTrials.gov NCT04786262 [2026-09-01]; Vertex Q1 2026 [May 2026] & Q3 2026 [Nov 2, 2026] earnings releases): tracked in the separate CMC Readiness Ledger (P_release_CMC and H1_CMC_ATTEMPTED_LOT_READINESS = P_release_CMC * P_infuse_given_released * H1_Blueprint) without overloading Blueprint H1's post-release clinical estimand.",
            "Wang et al. 2024 (Cell; PMID:39326417): 1/1 sustained insulin independence from Day 75 through 1 year in the abdominal anterior rectus sheath (ChiCTR2300072200), BUT recipient continued a 3-drug IS regimen from prior liver transplantation plus peri-infusion induction -> distinct product, site, and IS regimen from Reichman; mixed 13/13 intervals/posteriors are descriptive sensitivities only (primary_verified=False); autologous D1b-Auto-C v2 p1 stays held at 0.62.",
            "Shi et al. Lancet Diabetes Endocrinol Apr 2026;14(4):285-288 (PMID:41765034, DOI:10.1016/S2213-8587(25)00423-1): Live PubMed efetch confirms PublicationType=Letter with 0 abstract chars (paywalled). Investigators describe a repeat infusion in the first recipient; secondary claim of '3/3 insulin-independent' is unauthenticated and conflicts with the 2026-02-26 CAS institutional report logged in OpenIslet CEG M0144 (1/3 insulin-independent; autologous recipient lost detectable C-peptide upon stopping IS). Even under hypothetical assumed counts, all four n=3 scenarios hold live H1 at 88%.",
            "Strict H1 vs H2/H3 separation: Every human SC-islet insulin-independence durability outcome to date (Reichman, Wang, Wu, Shi) occurred under systemic immunosuppression. Live Blueprint H1 stays locked at 0.88 (+0.00 pp today); H1 = 0.90 remains strictly a conditional sensitivity with ZERO spillover onto IS-free H2/H3.",
        ],
        "cohorts": results,
    }


# =============================================================================
# EXECUTABLE CMC ATTEMPTED-LOT READINESS & BANK/LOT-AWARE GATE 28-A EVALUATORS
# =============================================================================
GATE_28A_COMPATIBILITY_TARGET: dict[str, str] = {
    "product_class": "ALLOGENEIC_GMP_SC_ISLET",
    "transplant_site": "INTRAPORTAL_HEPATIC",
    "disease_population": "TYPE_1_DIABETES",
    "immunosuppression_protocol_class": "DE_NOVO_CHRONIC_GLUCOCORTICOID_FREE_SYSTEMIC_IS",
    "dose_regimen": "FULL_DOSE_SINGLE_INFUSION",
}

GATE_28A_INTERCURRENT_EVENT_ADJUDICATION: dict[str, Any] = {
    "NONE": "PRIMARY_RESPONDER_1_IF_ALL_C2B_CRITERIA_MET_ELSE_0",
    "RESCUE_REPEAT_INFUSION": 0,
    "PROHIBITED_PERI_INFUSION_GLUCOCORTICOIDS": 0,
    "MISSING_PRIMARY_ENDPOINT_OR_LTFU": 0,
    "PRE_LANDMARK_DEATH": 0,
    "PRIMARY_GRAFT_NON_FUNCTION": 0,
}

GATE_28A_DISTINCT_LOTS_MIN = 3
GATE_28A_DISTINCT_MCB_MIN = 2
GATE_28A_MAX_SINGLE_LOT_SHARE = Decimal("0.40")
GATE_28A_RHO_LOT_MIN = 0.05
GATE_28A_RHO_BANK_MIN = 0.02
GATE_28A_ICC_SENSITIVITY_SCENARIOS: tuple[tuple[str, float, float], ...] = (
    ("primary_floor", 0.05, 0.02),
    ("moderate_sensitivity", 0.10, 0.05),
    ("high_clustering_sensitivity", 0.15, 0.10),
)
GATE_28A_ALLOWED_ATTESTATION_AUTHORITIES = frozenset({
    "OPENISLET_QA_RELEASE_BOARD_V1",
    "OPENISLET_INDEPENDENT_ASSAY_REGISTRY_V1",
    "OPENISLET_CLINICAL_ADJUDICATION_BOARD_V1",
})


def _compute_gate28a_icc_sensitivity_report(
    k: int,
    n: int,
    m_eff_lot: float,
    m_eff_bank: float,
) -> tuple[dict[str, Any], bool, str]:
    """Compute prespecified 3-scenario same-cohort ICC sensitivity report and 4-state review status."""
    report: dict[str, Any] = {}
    meets_by_scenario: dict[str, bool] = {}
    for scen_name, s_rho_lot, s_rho_mcb in GATE_28A_ICC_SENSITIVITY_SCENARIOS:
        s_deff = 1.0 + s_rho_lot * (m_eff_lot - 1.0) + s_rho_mcb * (m_eff_bank - 1.0)
        s_n_eff = float(n) / s_deff
        s_k_eff = s_n_eff * (float(k) / float(n))
        s_p_unif = 1.0 - beta_cdf(0.90, 1.0 + s_k_eff, 1.0 + (s_n_eff - s_k_eff))
        s_p_anch = 1.0 - beta_cdf(0.90, 8.8 + s_k_eff, 1.2 + (s_n_eff - s_k_eff))
        s_mean_unif = (1.0 + s_k_eff) / (2.0 + s_n_eff)
        s_mean_anch = (8.8 + s_k_eff) / (10.0 + s_n_eff)
        s_meets = (s_p_unif >= 0.90) and (s_p_anch >= 0.85)
        meets_by_scenario[scen_name] = s_meets
        report[scen_name] = {
            "rho_lot": s_rho_lot,
            "rho_mcb": s_rho_mcb,
            "rho_bank": s_rho_mcb,
            "deff_cluster": round(s_deff, 6),
            "n_eff": round(s_n_eff, 6),
            "k_eff": round(s_k_eff, 6),
            "posterior_mean": round(s_mean_unif, 6),
            "posterior_p_ge_090": round(s_p_unif, 6),
            "anchored_posterior_mean": round(s_mean_anch, 6),
            "anchored_posterior_p_ge_090": round(s_p_anch, 6),
            "meets_reanchor_bar": s_meets,
        }

    p_ok = meets_by_scenario["primary_floor"]
    m_ok = meets_by_scenario["moderate_sensitivity"]
    h_ok = meets_by_scenario["high_clustering_sensitivity"]
    boundary_sensitive = bool(p_ok and m_ok and (not h_ok))

    if not p_ok:
        review_status = "HOLD_FAILS_PRIMARY_ICC_FLOOR"
    elif not m_ok:
        review_status = "HOLD_FAILS_MODERATE_ICC_SENSITIVITY"
    elif not h_ok:
        review_status = "BOUNDARY_SENSITIVE_DISCLOSED_CLEARS_PRIMARY_AND_MODERATE"
    else:
        review_status = "ROBUST_ACROSS_ALL_THREE_PRESPECIFIED_ICC_SCENARIOS"

    report["boundary_sensitive_under_high_icc"] = boundary_sensitive
    report["icc_sensitivity_review_status"] = review_status
    report["probability_interpretation"] = (
        "PRESPECIFIED_DECISION_MODEL_QUANTITIES_CONDITIONAL_ON_ASSUMED_ICC_VARIANCE_COMPONENTS_NOT_INDEPENDENT_CALIBRATION"
    )
    report["calibration_scope_note"] = (
        "Cluster-adjusted Beta-Binomial probabilities (Uniform Beta(1,1) and anchored Beta(8.8,1.2) on "
        "fractional (k_eff, n_eff)) are prespecified decision-model quantities conditional on assumed lot/bank "
        "variance-component ICCs (rho_lot, rho_bank) and cohort exchangeability rather than independently "
        "calibrated empirical probabilities; attaching this 3-scenario icc_sensitivity_report documents "
        "sensitivity across prespecified variance-component pairs rather than independent ICC calibration."
    )
    return report, boundary_sensitive, review_status


def _parse_raw_clinical_rescue_declaration(
    rec: dict[str, Any],
    rid_label: str,
) -> dict[str, Any]:
    """Parse ALL clinical rescue declarations from a raw recipient row (executed in Pass 0 before duplicate skipping)."""
    parse_errors: list[str] = []
    ie = _strict_literal_id(rec.get("intercurrent_event"))
    ie_valid = ie in GATE_28A_INTERCURRENT_EVENT_ADJUDICATION

    rescue_declared = (ie == "RESCUE_REPEAT_INFUSION")
    rescue_parse_error = False
    if "rescue_infusion_occurred" in rec and rec["rescue_infusion_occurred"] is not None:
        resc_occ = rec["rescue_infusion_occurred"]
        if type(resc_occ) is not bool:
            parse_errors.append(f"Recipient {rid_label} rescue_infusion_occurred must be strict bool.")
            rescue_parse_error = True
        elif resc_occ is True:
            rescue_declared = True
            if ie_valid and ie != "RESCUE_REPEAT_INFUSION":
                parse_errors.append(
                    f"Recipient {rid_label} sets rescue_infusion_occurred=True contradicting intercurrent_event={ie!r}."
                )
                rescue_parse_error = True
        elif ie == "RESCUE_REPEAT_INFUSION":
            parse_errors.append(
                f"Recipient {rid_label} sets rescue_infusion_occurred=False contradicting intercurrent_event='RESCUE_REPEAT_INFUSION'."
            )
            rescue_parse_error = True

    # Reject ANY undocumented *rescue*lot* alias key BY KEY PRESENCE (even when value is None/null/""/[]
    # or intercurrent_event == "NONE"); only canonical rescue_lot_id and rescue_lot_ids are accepted.
    for rk, rv in sorted(rec.items(), key=lambda kv: str(kv[0])):
        if not isinstance(rk, str):
            continue
        if rk in ("rescue_lot_id", "rescue_lot_ids", "rescue_infusion_occurred"):
            continue
        rk_lo = rk.lower()
        if "rescue" in rk_lo and "lot" in rk_lo:
            parse_errors.append(
                f"UNRECOGNIZED_CLINICAL_RESCUE_LOT_ALIAS: recipient {rid_label} uses unsupported rescue key {rk!r} "
                f"(value={rv!r}; rejected by key presence — only canonical rescue_lot_id and rescue_lot_ids are accepted)."
            )
            rescue_parse_error = True

    rlid_a = rec.get("rescue_lot_id")
    declared_rescue_lot_id: str | None = None
    if rlid_a is not None:
        parsed_a = _strict_literal_id(rlid_a)
        if parsed_a is None:
            parse_errors.append(f"Recipient {rid_label} has invalid literal rescue_lot_id={rlid_a!r}.")
            rescue_parse_error = True
        else:
            declared_rescue_lot_id = parsed_a
            rescue_declared = True

    declared_list_rescue_lot_ids: list[str] | None = None
    if "rescue_lot_ids" in rec and rec["rescue_lot_ids"] is not None:
        raw_rlist = rec["rescue_lot_ids"]
        if not isinstance(raw_rlist, list):
            parse_errors.append(
                f"Recipient {rid_label} rescue_lot_ids must be a list of unique strict literal lot IDs."
            )
            rescue_parse_error = True
        else:
            parsed_rlist: list[str] = []
            bad_elem = False
            for r_elem in raw_rlist:
                lp = _strict_literal_id(r_elem)
                if lp is None:
                    parse_errors.append(
                        f"Recipient {rid_label} rescue_lot_ids contains invalid literal lot ID={r_elem!r}."
                    )
                    bad_elem = True
                    rescue_parse_error = True
                else:
                    parsed_rlist.append(lp)
            if not bad_elem:
                if len(set(parsed_rlist)) != len(parsed_rlist):
                    parse_errors.append(
                        f"CLINICAL_DUPLICATE_RESCUE_LOT_ID: recipient {rid_label} rescue_lot_ids={parsed_rlist!r} "
                        "contains duplicate rescue lot IDs."
                    )
                    rescue_parse_error = True
                sorted_rlist = sorted(parsed_rlist)
                if len(sorted_rlist) == 0:
                    if ie == "RESCUE_REPEAT_INFUSION" or rec.get("rescue_infusion_occurred") is True:
                        parse_errors.append(
                            f"CONFLICTING_CLINICAL_RESCUE_LOT_FIELDS: recipient {rid_label} declares empty "
                            "rescue_lot_ids=[] contradicting rescue infusion."
                        )
                        rescue_parse_error = True
                else:
                    rescue_declared = True
                declared_list_rescue_lot_ids = sorted_rlist

    if declared_rescue_lot_id is not None and declared_list_rescue_lot_ids is not None:
        if declared_list_rescue_lot_ids != [declared_rescue_lot_id]:
            parse_errors.append(
                f"CONFLICTING_CLINICAL_RESCUE_LOT_FIELDS: recipient {rid_label} scalar "
                f"rescue_lot_id={declared_rescue_lot_id!r} contradicts rescue_lot_ids={declared_list_rescue_lot_ids!r}."
            )
            rescue_parse_error = True

    if declared_list_rescue_lot_ids is not None and len(declared_list_rescue_lot_ids) > 0:
        explicit_rescue_ids_provided = True
        declared_rescue_lot_ids_sorted = list(declared_list_rescue_lot_ids)
    elif declared_rescue_lot_id is not None:
        explicit_rescue_ids_provided = True
        declared_rescue_lot_ids_sorted = [declared_rescue_lot_id]
    else:
        explicit_rescue_ids_provided = False
        declared_rescue_lot_ids_sorted = []

    if declared_rescue_lot_ids_sorted and ie_valid and ie != "RESCUE_REPEAT_INFUSION":
        parse_errors.append(
            f"Recipient {rid_label} declares rescue lot(s) {declared_rescue_lot_ids_sorted!r} contradicting intercurrent_event={ie!r}."
        )
        rescue_parse_error = True

    missing_explicit_rescue_lot_id = bool(rescue_declared and not explicit_rescue_ids_provided)
    if missing_explicit_rescue_lot_id:
        parse_errors.append(