("DescriptivePool_VX880_12_plus_Shi_3_15of15", 15, 15, True), ("DescriptiveUpper_VX880_12_plus_Shi_3_plus_Wu_1_16of16", 16, 16, True), ("ConservativeInsulinFree_10of12_plus_1of3_11of15", 11, 15, True), ] post_rows = [] for cid, k, n, inc_r in clinical_cases: lo, hi = clopper_pearson_ci(k, n) unif = beta_posterior(1.0, 1.0, k, n) anch = beta_posterior(8.8, 1.2, k, n) passes = (unif["p_ge_90_exact"] >= 0.90) and ((not inc_r) and anch["p_ge_90_exact"] >= 0.85) _require(not passes, f"Unexpected Gate 28-A pass on {cid}") post_rows.append({ "case_id": cid, "k": k, "n": n, "clopper_pearson_95_ci_pct": [round(100.0 * lo, 2), round(100.0 * hi, 2)], "uniform_beta11": unif, "anchored_beta8p8_1p2": anch, "gate_28a_verdict": "HOLD_H1_ALLO_STRICTLY_AT_88PCT", }) r16 = next(r for r in post_rows if r["n"] == 16) r11 = next(r for r in post_rows if r["k"] == 11 and r["n"] == 15) _require(abs(r16["uniform_beta11"]["p_ge_90_pct"] - 83.32) < 0.02, f"16/16 posterior drift: {r16}") _require(abs(r11["uniform_beta11"]["p_ge_90_pct"] - 1.70) < 0.02, f"11/15 posterior drift: {r11}") # Synthetic FORWARD-101 (NCT04786262) cluster-ICC sensitivity (N=57 spans distinct study arms/products; # 2 MCBs / 15 lots is a synthetic sensitivity partition, NOT a published trial lot count). m_lots = [4] * 12 + [3] * 3 b_mcbs = [30, 27] fwd_icc = {} for label, rl, rb in [("primary_floor", 0.05, 0.02), ("moderate_sensitivity", 0.10, 0.05), ("high_clustering", 0.15, 0.10)]: deff = 1.0 + rl * (sum(m * m for m in m_lots) / 57.0 - 1.0) + rb * (sum(b * b for b in b_mcbs) / 57.0 - 1.0) neff = 57.0 / deff p_u_100 = beta_posterior(1.0, 1.0, neff, neff)["p_ge_90_pct"] p_a_100 = beta_posterior(8.8, 1.2, neff, neff)["p_ge_90_pct"] p_u_54 = beta_posterior(1.0, 1.0, neff * 54.0 / 57.0, neff)["p_ge_90_pct"] p_a_54 = beta_posterior(8.8, 1.2, neff * 54.0 / 57.0, neff)["p_ge_90_pct"] fwd_icc[label] = { "rho_lot": rl, "rho_bank": rb, "DEFF": round(deff, 3), "n_eff": round(neff, 3), "at_57of57_unif_p90_pct": p_u_100, "at_57of57_anch_p90_pct": p_a_100, "at_54of57_unif_p90_pct": p_u_54, "at_54of57_anch_p90_pct": p_a_54, "clears_at_57of57": bool(p_u_100 >= 90.0 and p_a_100 >= 85.0), "clears_at_54of57": bool(p_u_54 >= 90.0 and p_a_54 >= 85.0), } _require( fwd_icc["moderate_sensitivity"]["clears_at_57of57"] and not fwd_icc["moderate_sensitivity"]["clears_at_54of57"], f"FORWARD-101 moderate ICC verdict drift: {fwd_icc['moderate_sensitivity']}", ) return { "arm_z_ensc_honest_classification": { "product_id": manifest_z["product_id"], "canonical_name": "Arm Z-EnSC (E-islet 01; hiPSC-derived Endoderm Stem Cell Intermediate)", "stripped_misnomer": "Arm Z-NonPSC", "trl": 6, "canonical_safety_switch": manifest_z["safety_switch"], "canonical_locus_counts": { "knockin_loci": manifest_z["knockin_locus_count"], "total_edited_loci": manifest_z["total_edited_locus_count"], "loci": manifest_z["loci"], }, "design_d_canonical_safety_switch": manifest_d["safety_switch"], "fda_ind_trial": "NCT07126873 (N=21 est., Phase 1/2a, RECRUITING; portal unedited/allogeneic trial does NOT qualify the edited Arm Z-EnSC bank)", "nct07126873_qualifies_edited_bank": False, "wu2024_supp_primary_disclosures": { "pmid": "38684699", "followup_total_weeks": 116, "insulin_withdrawal_week": 11, "observed_insulin_free_weeks_under_IS": 105, "teratomas_at_1e7_EnSC": "0/20", "teratoma_0_of_20_exact_onesided_95pct_u95_pct": round(one_sided_clopper_pearson_u95(0, 20) * 100.0, 2), "facs_total_gcg_pct": 23.1, "facs_bihormonal_cpep_gcg_pct": 22.1, "facs_monohormonal_gcg_cpep_neg_pct": 1.0, "monohormonal_alpha_below_prospective_20pct_floor": True, "scrnaseq_tph1_beta_labeled_cluster_pct": 19.54, "scrnaseq_tph1_note": "Labeled TPH1+ beta cells by Wu et al. (2,447/12,523); SC-EC identity requires additional markers.", "scrnaseq_sox9_ductal_pct": 3.85, "gsis_precedent_type": "STATIC_GSIS_ONLY (dynamic perifusion required prospectively)", "karyotype_precedent": "SINGLE_UNEDITED_P25_KARYOGRAM_ONLY (not a validated cutoff for edited banks)", "avascular_loss_50pct_status": "DOSE_PLANNING_ASSUMPTION", "unedited_p20_differential_nonsynonymous_genotype_rows": 29, "het_to_alt_hom_genotype_shifts_of_29": 12, "not_29_new_somatic_substitutions": True, "notable_genes_table_s2": ["LCK (p.V430M)", "STXBP5L (p.R615Q)", "EPCAM (p.M115T)", "PARP4 (p.S89F)", "OXA1L (p.A44V)", "SLC25A5 (p.L111R)"], "terminal_alk5i_exclusion_scope": "CLASS_WIDE_TERMINAL_PAN_ALK5I_EXCLUSION_GY024 (including Wu Stage-4 A83-01)", }, "shi2026_clinical_disclosures": { "pmid": "41765034", "fulminant_t1d_confounder": "45yo M (>2 yr insulin-free under IS) had fulminant T1D (classically autoAb-negative non-autoimmune acute destruction per Imagawa 2000 PMID:10655528)", "autologous_is_withdrawal_loss": "30yo F autologous E-islet recipient lost C-peptide upon IS withdrawal -> proves zero intrinsic H3 autoantigen immunity (zero phantom c3_univ)", }, "honest_pricing_params": { "c1_univ": 0.925, "c1_z": 0.84, "phi_z_h1": 0.55, "phi_z_h2": 0.80, "phi_z_h3": 0.80, "c3_univ": None, }, }, "ensc_population_doubling_budget": { "unrounded_single_pass_ceiling_pds": 55.0, "unrounded_single_pass_ceiling_passage": 20.0, "wu2024_single_unedited_karyogram_passage": 25.0, "nominal_pd_per_passage_planning_assumption": 2.8, "dual_sequential_clonal_picks_PDs": round(total_dual_seq_pds, 4), "dual_sequential_clonal_picks_equiv_passage": round(equiv_pass_dual, 4), "dual_sequential_breaches_P25_and_ceiling": True, "single_pass_multiplexed_PDs": round(total_single_pass_pds, 4), "single_pass_multiplexed_equiv_passage": round(equiv_pass_single, 4), "single_pass_within_unrounded_55PD_P20_ceiling": True, "measured_lot_logs_required": True, "non_pbmc_seedline_required_per_pmid_35953586": True, "dual_failsafe_and_gy030_5lineage_required": True, }, "gate_28a_bayesian_posterior_lock": { "h1_allo_locked_pct": 88.0, "n_eff_uniform_transition": round(n_eff_transition, 6), "clinical_posterior_scenarios": post_rows, "forward_101_cluster_icc_sensitivity_synthetic_note": ( "NCT04786262 (N=57 est.) spans distinct study arms/products; 2 MCBs [30, 27] and 15 lots is a " "synthetic cluster-ICC sensitivity model, not a published trial lot count." ), "forward_101_cluster_icc_audit": fwd_icc, }, "arm_z_gins_research_reserve": { "status": "PARKED_TRL_3_4_ZERO_CREDIT", "active_staged_credit_pp": 0.0, "huang2023_pmid": "37106062", "huang2023_total_gcg_pos_pct": "2.2 +/- 1.3% total GCG+ (11.36x below 25% floor and 13.64x below 30%; distinct from Gate 37's prospective 25-30% monohormonal GCG+/C-pep- alpha co-aggregation endpoint)", "dattoli2026_pmid": "42523425 (non-peer-reviewed bioRxiv preprint; preproinsulin Avatar Teffs only; GY-010 active)", }, } # ============================================================================= # 6. MODULE 4: EXACT FIXED ROUND-2 WAVE-6 2^12 / 2^20 / 2^24 CROSSWALK ENGINE # PORTED DIRECTLY FROM build_canonical_wave6_contract.py (0.00e+00 PARITY) # ============================================================================= def biv_bern(p1: float, p2: float, phi: float) -> dict[tuple[int, int], float]: _require( 0.0 <= p1 <= 1.0 and 0.0 <= p2 <= 1.0 and 0.0 <= phi <= 1.0, f"Invalid biv_bern inputs: p1={p1}, p2={p2}, phi={phi}", ) p11_ind = p1 * p2 p11_pos = min(p1, p2) p11 = (1.0 - phi) * p11_ind + phi * p11_pos p10 = p1 - p11 p01 = p2 - p11 p00 = 1.0 - p1 - p2 + p11 out = {(0, 0): p00, (1, 0): p10, (0, 1): p01, (1, 1): p11} for k, v in out.items(): _require(v >= -1e-12, f"Negative biv_bern prob {k}={v}") out[k] = max(0.0, v) tot = sum(out.values()) _require(abs(tot - 1.0) < 1e-12, f"biv_bern sum={tot}") return out def frechet_joint(probs: Sequence[float], phi: float) -> list[float]: k = len(probs) _require(0.0 <= phi <= 1.0, f"Invalid phi={phi}") for p in probs: _require(0.0 <= p <= 1.0, f"Invalid marginal p={p}") n_states = 1 << k d_ind = [0.0] * n_states for s in range(n_states): pr = 1.0 for i in range(k): pr *= probs[i] if ((s >> i) & 1) else (1.0 - probs[i]) d_ind[s] = pr order = sorted(range(k), key=lambda i: probs[i]) d_pos = [0.0] * n_states prev = 0.0 for idx, i in enumerate(order): w = probs[i] - prev if w > 0.0: d_pos[sum(1 << j for j in order[idx:])] += w prev = probs[i] d_pos[0] += 1.0 - prev out = [(1.0 - phi) * d_ind[s] + phi * d_pos[s] for s in range(n_states)] _require(all(v >= -1e-12 for v in out), "Negative frechet_joint probability") out = [max(0.0, v) for v in out] _require(abs(sum(out) - 1.0) < 1e-12, f"frechet_joint sum={sum(out)}") return out def frechet_couple( base_dist: Sequence[float], u_new: float, phi: float, event_fn: Callable[[int], bool] ) -> list[float]: n0 = len(base_dist) _require(abs(sum(base_dist) - 1.0) < 1e-12, f"base_dist sum={sum(base_dist)}") _require(0.0 <= u_new <= 1.0 and 0.0 <= phi <= 1.0, f"Invalid u_new={u_new} phi={phi}") p_e1 = sum(base_dist[mi] for mi in range(n0) if event_fn(mi)) p_e0 = 1.0 - p_e1 d_ind = [0.0] * (2 * n0) for mi in range(n0): w = base_dist[mi] d_ind[mi] = w * (1.0 - u_new) d_ind[mi | n0] = w * u_new d_pos = [0.0] * (2 * n0) p11 = min(p_e1, u_new) p10 = p_e1 - p11 p01 = max(0.0, u_new - p_e1) p00 = p_e0 - p01 for mi in range(n0): w = base_dist[mi] if w == 0.0: continue if event_fn(mi): frac = w / p_e1 if p_e1 > 0.0 else 0.0 d_pos[mi] = p10 * frac d_pos[mi | n0] = p11 * frac else: frac = w / p_e0 if p_e0 > 0.0 else 0.0 d_pos[mi] = p00 * frac d_pos[mi | n0] = p01 * frac out = [(1.0 - phi) * d_ind[k] + phi * d_pos[k] for k in range(2 * n0)] _require(all(v >= -1e-12 for v in out), "Negative frechet_couple probability") out = [max(0.0, v) for v in out] _require(abs(sum(out) - 1.0) < 1e-12, f"frechet_couple sum={sum(out)}") return out def _max_flow(cap: list[list[float]], src: int, snk: int) -> float: n = len(cap) flow = [[0.0] * n for _ in range(n)] total = 0.0 while True: parent = [-1] * n parent[src] = src queue = [src] head = 0 while head < len(queue) and parent[snk] == -1: u = queue[head] head += 1 for v in range(n): if parent[v] == -1 and cap[u][v] - flow[u][v] > 1e-15: parent[v] = u queue.append(v) if parent[snk] == -1: break aug = float("inf")