"The 97.6508% figure is strictly the modeled two-stage screening/control clean-lot pass probability at " "fixed sample sizes (n_panel = 15,990, n_ctrl = 20,000) across 15 independent panels at nominal FPR = 5e-4 " "with perfect Stage-2 confirmation (not a full-protocol empirical pass rate)." ), "pre_ind_silent_reservoir_tail_risk_reduction": tail_risk_rows, "twostage_fpr_clean_lot_pass_probability_audit": fpr_comparison, } # --------------------------------------------------------------------------- # Reference Passing Measured-Lot Payload & Adversarial Test Suite (Zero `assert`) # --------------------------------------------------------------------------- def _valid_digest(tag: str) -> str: return hashlib.sha256(f"OPENISLET_EXP031_REFERENCE_EVIDENCE::{tag}".encode("utf-8")).hexdigest() def build_passing_reference_payload( *, lot_id: str = "LOT-2026-MCB01-R01", mcb_id: str = "MCB-ISLET1-A-001", product_variant_id: str | None = None, product_variant: str | None = None, qualification_tier: str = "BANK_QUALIFICATION", ectopic_receptors: List[str] | None = None, include_cd46_addendum: bool = False, include_cd55_addendum: bool = False, bridged_mcb_qualification_sha256: str | None = None, bridged_mcb_qualification_record: Dict[str, Any] | None = None, process_qualification_ref_sha256: str | None = None, process_qualification_record: Dict[str, Any] | None = None, use_direct_infected_veh_survivor_mode: bool = True, antiviral_genotype_stratum: str = "TYK2_WT__IFIH1_WT_OR_A946T", independent_biological_units_n: int = MIN_INDEPENDENT_BIOLOGICAL_UNITS_N, independent_sampling_unit_class: str = "RECONCILED_MULTI_WELL_CELL_ASSAY_WITH_UNIT_PARTITION", openislet_root: Path | None = None, ) -> Dict[str, Any]: """ Construct a fully passing, auditable, raw-count measured-lot payload for Gate 0V & Gate 0V-Kill (Round-02 compliant across B1-B6): - Canonical registered `product_variant_id` (default: `ISLET1_A4_ARM1B`). - Exact lineage ledger reconciliation (`total_viable_cells_acquired_n == 5*16000 + 2400 == 82400`) plus mandatory `unassigned_fraction_viral_readout` (`2400` screened, `0` hits). - Dual-target ddPCR validation (`UL138`+`UL55` for HCMV; `POS`+`NEG` 5'-del RNA for CVB). - Powered exact-Decimal Clopper-Pearson CD55 echovirus addendum (`n = 16,000` / lineage). - External trusted store reference digests ONLY (no self-attested inline approval unless caller explicitly passes an inline record to test rejection/conflict!). """ pvid = ( product_variant_id if product_variant_id is not None else (product_variant if product_variant is not None else "ISLET1_A4_ARM1B") ) def _make_pathogen_block(pid: str) -> Dict[str, Any]: if pid == "hcmv": dd_targets = { "UL138": {"k": 0, "n": 16000, "primers_verified": True}, "UL55": {"k": 0, "n": 16000, "primers_verified": True}, } else: dd_targets = { "CVB_5PRIME_DELETION_POS_RNA": {"k": 0, "n": 16000, "primers_verified": True}, "CVB_5PRIME_DELETION_NEG_RNA": {"k": 0, "n": 16000, "primers_verified": True}, } lat_block: Dict[str, Any] = { "ddpcr_target_panel": "HCMV_UL138_UL55_LATENT_LYTIC" if pid == "hcmv" else "CVB_5PRIME_DELETION_AWARE_POS_NEG_RNA", "ddpcr_targets": dd_targets, "ddpcr_positive_events_k": 0, "ddpcr_cell_equivalents_screened_n": 16000, "evidence_sha256": _valid_digest(f"latent_{pid}"), } if pid == "hcmv": lat_block.update({ "reactivation_challenge_applied": True, "reactivation_protocol_evidence_sha256": _valid_digest("hcmv_reactivation"), "reactivation_7d_outgrowth_pfu_ml": "0", "reactivation_assay_volume_ml": "2.0", "reactivation_lod_pfu_ml": "0.5", }) else: lat_block["cvb_5prime_deletion_primers_verified"] = True return { "endocrine_72h_log10_pfu_u95": "1.65", "vascular_72h_log10_pfu_u95": "1.50", "coculture_72h_log10_pfu_u95": "1.72", "endocrine_day14_log10_reduction_l95": "3.60", "vascular_day14_log10_reduction_l95": "3.85", "day14_negative_strand_or_ie1_rna_positive_wells_k": 0, "day14_negative_strand_or_ie1_rna_wells_tested_n": 12, "day28_supernatant_infectious_pfu_ml": "0", "day28_supernatant_assay_volume_ml": "2.0", "day28_supernatant_lod_pfu_ml": "0.5", "dual_marker_lineage_panel_attested": True, "lineage_panel_spec_sha256": _valid_digest(f"dual_marker_panel_{pid}"), # Exact arithmetic reconciliation: 5 * 16,000 + 2,400 = 82,400 (2.9126% unassigned <= 5.0%) "total_viable_cells_acquired_n": 82400, "lineage_unassigned_cells_n": 2400, "unassigned_fraction_viral_readout": { "unassigned_cells_screened_n": 2400, "stage1_screen_positive_k": 0, "stage2_sorted_for_confirmation_n": 0, "stage2_confirmed_infectious_k": 0, }, "day28_latent_and_defective_genome_arm": lat_block, "day28_persistence_by_lineage": { lin: { "cells_assigned_n": 16000, "cells_scored_n": 16000, "stage1_screen_positive_k": 2, "stage2_sorted_for_confirmation_n": 2, "stage2_confirmed_infectious_k": 0, "uninfected_ctrl_fp_k": 1, "uninfected_ctrl_scored_n": 20000, "spike_calibrant_detected_k": 29, "spike_calibrant_total_n": 29, "fragile_infected_spike_detected_k": 29, "fragile_infected_spike_total_n": 29, "pre_dissociation_spike_in_attested": True, "pre_dissociation_spike_sop_evidence_sha256": _valid_digest(f"spike_{pid}_{lin}"), } for lin in GRAFT_LINEAGES }, } # Realistic 1.0e7 assembled organoid cells/arm -> pericyte = 357,530 input cells input_cells_1e7_arm = { "beta": 5_141_940, "alpha": 2_570_970, "delta": 856_990, "plvap_iec": 1_072_580, "pericyte": 357_530, } receptors = ( list(ectopic_receptors) if ectopic_receptors is not None else sorted(_implied_ectopic_receptors_for_product(pvid, openislet_root=openislet_root)) ) kill_regimes_to_build = ( STRESS_AP1903_REGIMES if qualification_tier == "BANK_QUALIFICATION" else ("normoxia_baseline", "hypoxia_1pct_plus_cytokines") ) pathogens_to_build = ( GATE0V_PATHOGENS if qualification_tier == "BANK_QUALIFICATION" else (("cvb4_e2",) if qualification_tier == "LOT_RELEASE_SURROGATE" else ()) ) payload: Dict[str, Any] = { "lot_id": lot_id, "mcb_id": mcb_id, "product_variant_id": pvid, "qualification_tier": qualification_tier, "ectopic_viral_receptors_expressed": receptors, "clustering_and_independence_spec": { "independent_biological_units_n": independent_biological_units_n, "independent_sampling_unit_class": independent_sampling_unit_class, "clustering_design_effect_deff": "1.0", "unit_definition": ( "independent_single_cell_limiting_dilution_units" if independent_sampling_unit_class == "INDEPENDENT_SINGLE_CELL_OR_LIMITING_DILUTION_UNIT" else "independent_stage7_differentiation_organoid_wells" ), }, "cxadr_ko_present": False, "cxadr_locus_genotyping_evidence_sha256": _valid_digest("cxadr_wt_pcr_sanger"), "antiviral_genotype_stratum": antiviral_genotype_stratum, "gate0v_a_poly_ic_sensing": { "poly_ic_dose_ng_ml": "500", "assay_duration_h": "24", "vehicle_control_isg_baseline_verified": True, "vehicle_control_evidence_sha256": _valid_digest("polyic_vehicle_ctrl"), "positive_control_ifna_isg_fold": {lin: "12.5" for lin in GRAFT_LINEAGES}, "lineage_isg_fold_induction": { lin: { "IFNB1_or_IFNL1_fold": "18.5", "ISG15_fold": "42.0", "MX1_fold": "31.2", "OAS1_fold": "24.8", } for lin in GRAFT_LINEAGES }, }, "gate0v_b_infectious_challenge": { "pathogens": {pid: _make_pathogen_block(pid) for pid in pathogens_to_build}, }, "gate0v_kill_stress_ap1903": { reg: { lin: { "veh_24h_viable_n": 950 if reg == "normoxia_baseline" else 560, "veh_24h_input_n": 1000, "ap1903_24h_input_n": 10000, "ap1903_24h_viable_survivors_k": 0, "veh_72h_viable_n": 940 if reg == "normoxia_baseline" else 540, "veh_72h_input_n": 1000, "ap1903_72h_input_n": input_cells_1e7_arm[lin] if reg in INFECTED_AP1903_REGIMES else 100000, "ap1903_72h_viable_survivors_k": 0, **( { "aliquot_linkage_id": f"ALQ-{lot_id}-{reg[:8].upper()}-{lin.upper()}", "infected_surveillance_aliquot_linkage_mode": "SAME_72H_ALIQUOT", "caspase9_3_activity_fold_over_vehicle": "14.2", "viral_caspase_stratification_evidence_sha256": _valid_digest(f"casp_{reg}_{lin}"), "pre_ap1903_lineage_input_cells_n": input_cells_1e7_arm[lin], "post_ap1903_viable_survivors_total_n": 0, "survivors_scored_n": 0, "post_ap1903_viable_viral_pos_k": 0, "pretreat_viral_pos_k": 250, "pretreat_scored_n": 1000, **( { "infected_cell_escape_mode": "DIRECT_INFECTED_VEHICLE_DENOMINATOR", "pretreat_infected_veh_survivor_n": 125, } if use_direct_infected_veh_survivor_mode else {} ), "spike_calibrant_detected_k": 24, "spike_calibrant_total_n": 24, "fragile_infected_spike_detected_k": 24, "fragile_infected_spike_total_n": 24, "pre_dissociation_spike_in_attested": True, "pre_dissociation_spike_sop_evidence_sha256": _valid_digest(f"kill_spike_{reg}_{lin}"), } if reg in INFECTED_AP1903_REGIMES else {} ), } for lin in GRAFT_LINEAGES } for reg in kill_regimes_to_build }, } if antiviral_genotype_stratum in EDITED_ANTIVIRAL_GENOTYPES: if antiviral_genotype_stratum == "TYK2_P1104A_HOM__IFIH1_WT": payload["mycobacterial_tb_igra_screening_attested"] = True payload["tb_igra_evidence_sha256"] = _valid_digest("tb_igra_clear") for pid in pathogens_to_build: payload["gate0v_b_infectious_challenge"]["pathogens"][pid]["edited_minus_wt_day14_log10_reduction_l95"] = "-0.12" payload["gate0v_b_infectious_challenge"]["pathogens"][pid]["paired_noninferiority_replicates_n"] = 6 if qualification_tier == "AUTOLOGOUS_D1B_PROCESS_QUAL": payload["genotype_noninferiority_by_pathogen"] = { pid: { "edited_minus_wt_day14_log10_reduction_l95": "-0.12", "paired_noninferiority_replicates_n": 6, }