OpenIslet

scripts/verify_iip0058_armz_ensc_isletsort_v2_and_2p24_portfolio.py

Provisional IIP-0058 / DEC-139 / GATE-37 / GY-036 (Round-14 Blueprint Alignment; staged in iip0058/):

script Release v0.8.0 gen-eb955f8266035aba 837 KB · 62 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_iip0058_armz_ensc_isletsort_v2_and_2p24_portfolio.py · SHA-256: 33439d619c00fcc3…

            and res_en_f["promotion_authorized"] is False
            and res_en_f["teratoma_onesided_95pct_u95_pct"] is None
            and res_en_f["provisional_unverified_aggregate_u95_pct"] is None
            and res_en_f["u95_derivation_source"] == "WITHHELD_INTERNAL_ARCHIVE_CONFLICT"
            and "FAIL_ENSC_ARCHIVE_ROSTER_ALIAS_CONFLICT" in res_en_f["failures"],
            f"{nm_en_f} failed: {res_en_f}",
        )

    # Audit R12-05 Round-13 EnSC self-tests: common study-level follow-up alias validator (archive + caller)
    en_r13_arch_4wk_conflict = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_cur_override({"teratoma_followup_weeks": 26.0, "followup_weeks": 30.0}),
        canonical_manifest=ext_manifest,
    )
    en_r13_arch_none_alias_hold = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_cur_override({"teratoma_followup_weeks": 26.0, "followup_weeks": None}),
        canonical_manifest=ext_manifest,
    )
    en_r13_caller_4wk_conflict = evaluate_gate35_ensc_p19_singlepass(
        {**_sample_valid_ensc_fixture(), "teratoma_followup_weeks": 26.0, "followup_weeks": 30.0},
        canonical_manifest=ext_manifest,
    )
    en_r13_caller_none_alias_reject = evaluate_gate35_ensc_p19_singlepass(
        {**_sample_valid_ensc_fixture(), "teratoma_followup_weeks": 26.0, "followup_weeks": None},
        canonical_manifest=ext_manifest,
    )
    en_r13_both_match_alias_pass = evaluate_gate35_ensc_p19_singlepass(
        {**_ensc_with_cur_override({"teratoma_followup_weeks": 26.0, "followup_weeks": 26.0}), "teratoma_followup_weeks": 26.0, "followup_weeks": 26.0},
        canonical_manifest=ext_manifest,
    )
    _require(
        en_r13_arch_4wk_conflict["decision"] == "FAIL"
        and en_r13_arch_4wk_conflict["bank_qualified"] is False
        and en_r13_arch_4wk_conflict["promotion_authorized"] is False
        and en_r13_arch_4wk_conflict["teratoma_onesided_95pct_u95_pct"] is None
        and en_r13_arch_4wk_conflict["provisional_unverified_aggregate_u95_pct"] is None
        and en_r13_arch_4wk_conflict["u95_derivation_source"] == "WITHHELD_INTERNAL_ARCHIVE_CONFLICT",
        f"en_r13_arch_4wk_conflict failed: {en_r13_arch_4wk_conflict}",
    )
    _require(
        en_r13_arch_none_alias_hold["decision"] == "HOLD"
        and en_r13_arch_none_alias_hold["bank_qualified"] is False
        and en_r13_arch_none_alias_hold["promotion_authorized"] is False
        and en_r13_arch_none_alias_hold["failures"] == []
        and en_r13_arch_none_alias_hold["teratoma_onesided_95pct_u95_pct"] is None
        and en_r13_arch_none_alias_hold["provisional_unverified_aggregate_u95_pct"] == 13.9108
        and en_r13_arch_none_alias_hold["u95_derivation_source"] == "UNVERIFIED_AGGREGATE_HOLD_ONLY"
        and "HOLD_INCOMPLETE_ARCHIVED_STUDY_FOLLOWUP_ALIAS" in en_r13_arch_none_alias_hold["holds"],
        f"en_r13_arch_none_alias_hold failed: {en_r13_arch_none_alias_hold}",
    )
    _require(
        en_r13_caller_4wk_conflict["decision"] == "FAIL"
        and en_r13_caller_4wk_conflict["bank_qualified"] is False
        and en_r13_caller_4wk_conflict["promotion_authorized"] is False
        and en_r13_caller_4wk_conflict["teratoma_onesided_95pct_u95_pct"] == 13.9108
        and en_r13_caller_4wk_conflict["u95_derivation_source"] == "AUTHENTICATED_ARCHIVE_ONLY_CALLER_CONFLICT"
        and en_r13_caller_4wk_conflict["caller_roster_reconciliation_status"] == "CONFLICT_CALLER_MISMATCH",
        f"en_r13_caller_4wk_conflict failed: {en_r13_caller_4wk_conflict}",
    )
    _require(
        en_r13_caller_none_alias_reject["decision"] == "FAIL"
        and en_r13_caller_none_alias_reject["bank_qualified"] is False
        and en_r13_caller_none_alias_reject["promotion_authorized"] is False
        and en_r13_caller_none_alias_reject["teratoma_onesided_95pct_u95_pct"] == 13.9108
        and en_r13_caller_none_alias_reject["u95_derivation_source"] == "AUTHENTICATED_ARCHIVE_ONLY_CALLER_CONFLICT"
        and en_r13_caller_none_alias_reject["caller_roster_reconciliation_status"] == "CONFLICT_CALLER_MISMATCH"
        and "CALLER_STUDY_FOLLOWUP_ALIAS_NULL_OR_MISMATCH" in en_r13_caller_none_alias_reject["failures"],
        f"en_r13_caller_none_alias_reject failed: {en_r13_caller_none_alias_reject}",
    )
    _require(
        en_r13_both_match_alias_pass["decision"] == "SYNTHETIC_SELF_TEST_PASS"
        and en_r13_both_match_alias_pass["promotion_authorized"] is False
        and en_r13_both_match_alias_pass["teratoma_onesided_95pct_u95_pct"] == 13.9108
        and en_r13_both_match_alias_pass["u95_derivation_source"] == "ARCHIVED_PER_ANIMAL_ROSTER_VERIFIED"
        and en_r13_both_match_alias_pass["caller_roster_reconciliation_status"] == "MATCHED",
        f"en_r13_both_match_alias_pass failed: {en_r13_both_match_alias_pass}",
    )

    # Round-14 Review Closure EnSC self-tests:
    # (a) Live Blueprint Section 7 OQ-012 Gate 5 (299,573,228 PASS vs 299,573,227 HOLD vs 0/100k HOLD vs 1/100k FAIL vs
    #     missing recovery HOLD vs eta=0.29 FAIL vs n_eff>floor FAIL)
    # (b) Upstream Dual-FailSafe rejects live GATE-32 role collision (requires GATE-34)!
    def _ensc_with_g5_override(overrides: Mapping[str, Any], *, drop_keys: Sequence[str] = ()) -> dict[str, Any]:
        base = _sample_valid_ensc_fixture()
        g5_b = {k: v for k, v in base["gate5_oq012_record"].items() if k != "archive_sha256" and k not in drop_keys}
        g5_b.update(overrides)
        g5_new = make_signed_evidence_record(g5_b)
        base["gate5_oq012_record"] = g5_new
        dfs_b = {k: v for k, v in base["dual_failsafe_record"].items() if k != "archive_sha256"}
        dfs_b["prerequisite_archive_sha256s"] = {
            "GATE-0V": base["gate0v_5lineage_record"]["archive_sha256"],
            "GATE-5": g5_new["archive_sha256"],
        }
        base["dual_failsafe_record"] = make_signed_evidence_record(dfs_b)
        return base

    en_r14_g5_299573228_pass = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_g5_override({
            "survivor_count_k": 0,
            "tested_cells_n": 299_573_228,
            "clonogenic_fraction_f": 1.0,
            "spike_in_detection_efficiency_eta": 1.0,
            "effective_clonogenic_trials_n_eff": 299_573_228,
            "u95_exact": clopper_pearson_u95(0, 299_573_228),
        }),
        canonical_manifest=ext_manifest,
    )
    en_r14_g5_299573227_hold = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_g5_override({
            "survivor_count_k": 0,
            "tested_cells_n": 299_573_227,
            "clonogenic_fraction_f": 1.0,
            "spike_in_detection_efficiency_eta": 1.0,
            "effective_clonogenic_trials_n_eff": 299_573_227,
            "u95_exact": clopper_pearson_u95(0, 299_573_227),
        }),
        canonical_manifest=ext_manifest,
    )
    en_r14_g5_0of100k_hold = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_g5_override({
            "survivor_count_k": 0,
            "tested_cells_n": 100_000,
            "clonogenic_fraction_f": 1.0,
            "spike_in_detection_efficiency_eta": 1.0,
            "effective_clonogenic_trials_n_eff": 100_000,
            "u95_exact": clopper_pearson_u95(0, 100_000),
        }),
        canonical_manifest=ext_manifest,
    )
    en_r14_g5_1of100k_fail = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_g5_override({
            "survivor_count_k": 1,
            "tested_cells_n": 100_000,
            "clonogenic_fraction_f": 1.0,
            "spike_in_detection_efficiency_eta": 1.0,
            "effective_clonogenic_trials_n_eff": 100_000,
            "u95_exact": clopper_pearson_u95(1, 100_000),
        }),
        canonical_manifest=ext_manifest,
    )
    en_r14_g5_miss_rec_hold = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_g5_override({}, drop_keys=("clonogenic_fraction_f", "spike_in_detection_efficiency_eta", "effective_clonogenic_trials_n_eff")),
        canonical_manifest=ext_manifest,
    )
    en_r14_g5_low_eta_fail = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_g5_override({
            "tested_cells_n": 3_000_000_000,
            "clonogenic_fraction_f": 0.50,
            "spike_in_detection_efficiency_eta": 0.29,
            "effective_clonogenic_trials_n_eff": 400_000_000,
            "u95_exact": clopper_pearson_u95(0, 400_000_000),
        }),
        canonical_manifest=ext_manifest,
    )
    en_r14_g5_neff_exceeds_fail = evaluate_gate35_ensc_p19_singlepass(
        _ensc_with_g5_override({
            "tested_cells_n": 1_000_000_000,
            "clonogenic_fraction_f": 0.50,
            "spike_in_detection_efficiency_eta": 0.80,
            "effective_clonogenic_trials_n_eff": 400_000_001,
            "u95_exact": clopper_pearson_u95(0, 400_000_001),
        }),
        canonical_manifest=ext_manifest,
    )
    en_r14_g32_base = _sample_valid_ensc_fixture()
    g32_col_body = {k: v for k, v in en_r14_g32_base["dual_failsafe_record"].items() if k != "archive_sha256"}
    g32_col_body["gate_source"] = "GATE-32"
    en_r14_g32_base["dual_failsafe_record"] = make_signed_evidence_record(g32_col_body)
    en_r14_live_gate32_collision_reject = evaluate_gate35_ensc_p19_singlepass(en_r14_g32_base, canonical_manifest=ext_manifest)
    _require(
        en_r14_g5_299573228_pass["decision"] == "SYNTHETIC_SELF_TEST_PASS" and en_r14_g5_299573228_pass["promotion_authorized"] is False,
        f"en_r14_g5_299573228_pass failed: {en_r14_g5_299573228_pass}",
    )
    _require(
        en_r14_g5_299573227_hold["decision"] == "HOLD"
        and en_r14_g5_299573227_hold["promotion_authorized"] is False
        and "HOLD_GATE5_OQ012_UNDERPOWERED_BELOW_299573228_EFFECTIVE_TRIALS" in en_r14_g5_299573227_hold["holds"],
        f"en_r14_g5_299573227_hold failed: {en_r14_g5_299573227_hold}",
    )
    _require(
        en_r14_g5_0of100k_hold["decision"] == "HOLD"
        and en_r14_g5_0of100k_hold["promotion_authorized"] is False
        and "HOLD_GATE5_OQ012_UNDERPOWERED_BELOW_299573228_EFFECTIVE_TRIALS" in en_r14_g5_0of100k_hold["holds"],
        f"en_r14_g5_0of100k_hold failed: {en_r14_g5_0of100k_hold}",
    )
    _require(
        en_r14_g5_1of100k_fail["decision"] == "FAIL"
        and en_r14_g5_1of100k_fail["promotion_authorized"] is False
        and "FAIL_GATE5_OQ012_NONZERO_SURVIVOR_OR_U95_GT_1E8" in en_r14_g5_1of100k_fail["failures"],
        f"en_r14_g5_1of100k_fail failed: {en_r14_g5_1of100k_fail}",
    )
    _require(
        en_r14_g5_miss_rec_hold["decision"] == "HOLD"
        and en_r14_g5_miss_rec_hold["promotion_authorized"] is False
        and "HOLD_GATE5_OQ012_INCOMPLETE_RECOVERY_DENOMINATOR" in en_r14_g5_miss_rec_hold["holds"],
        f"en_r14_g5_miss_rec_hold failed: {en_r14_g5_miss_rec_hold}",
    )
    _require(
        en_r14_g5_low_eta_fail["decision"] == "FAIL"
        and en_r14_g5_low_eta_fail["promotion_authorized"] is False
        and "FAIL_GATE5_OQ012_SPIKE_IN_ETA_LT_0P30" in en_r14_g5_low_eta_fail["failures"],
        f"en_r14_g5_low_eta_fail failed: {en_r14_g5_low_eta_fail}",
    )
    _require(
        en_r14_g5_neff_exceeds_fail["decision"] == "FAIL"
        and en_r14_g5_neff_exceeds_fail["promotion_authorized"] is False
        and "FAIL_GATE5_OQ012_EFFECTIVE_TRIALS_EXCEEDS_FLOOR_N_F_ETA" in en_r14_g5_neff_exceeds_fail["failures"],
        f"en_r14_g5_neff_exceeds_fail failed: {en_r14_g5_neff_exceeds_fail}",
    )
    _require(
        en_r14_live_gate32_collision_reject["decision"] == "FAIL"
        and en_r14_live_gate32_collision_reject["promotion_authorized"] is False
        and "FAIL_DUAL_FAILSAFE_LIVE_GATE32_SHIELD_DEBRIS_ROLE_COLLISION" in en_r14_live_gate32_collision_reject["failures"],
        f"en_r14_live_gate32_collision_reject failed: {en_r14_live_gate32_collision_reject}",
    )

    # GINS synthetic isolation + archived study_id binding + affirmative non-integrating + 20% reject + R6-03 archive binding
    def _gins_with_arch_override(overrides: Mapping[str, Any], *, drop_keys: Sequence[str] = ()) -> dict[str, Any]:
        base = _sample_valid_gins_fixture()
        rec_body = {k: v for k, v in base["study_evidence_record"].items() if k != "archive_sha256" and k not in drop_keys}
        rec_body.update(overrides)
        base["study_evidence_record"] = make_signed_evidence_record(rec_body)
        return base

    gi_syn = evaluate_gate35_gins_oq018_reserve(_sample_valid_gins_fixture(), canonical_manifest=ext_manifest)
    gi_vcn = evaluate_gate35_gins_oq018_reserve({**_sample_valid_gins_fixture(), "vector_copy_number_per_cell": 1.2}, canonical_manifest=ext_manifest)
    gi_bad_sid = evaluate_gate35_gins_oq018_reserve({**_sample_valid_gins_fixture(), "study_record_ref": "OTHER_STUDY_999"}, canonical_manifest=ext_manifest)
    gi_20pct = evaluate_gate35_gins_oq018_reserve({**_sample_valid_gins_fixture(), "alpha_coagg_monohormonal_gcg_pct": 20.0}, canonical_manifest=ext_manifest)
    gi_missing = evaluate_gate35_gins_oq018_reserve({k: v for k, v in _sample_valid_gins_fixture().items() if k != "polyclonal_t1d_pbmc_survival_pct"}, canonical_manifest=ext_manifest)
    gi_arch_lenti = evaluate_gate35_gins_oq018_reserve(_gins_with_arch_override({"integrating_lentivirus_used": True}), canonical_manifest=ext_manifest)
    gi_arch_miss_diam = evaluate_gate35_gins_oq018_reserve(_gins_with_arch_override({}, drop_keys=("reaggregation_cluster_diameter_um",)), canonical_manifest=ext_manifest)
    # Audit R7-09 self-test: contradictory valid-sized archived donor aliases MUST FAIL with wave7_promotion_eligible=False!
    gi_arch_alias_conflict = evaluate_gate35_gins_oq018_reserve(
        _gins_with_arch_override({
            "polyclonal_donor_ids": [f"DONOR-{i:02d}" for i in range(1, 9)],
            "donor_ids": [f"OTHER-{i:02d}" for i in range(1, 9)],
        }),
        canonical_manifest=ext_manifest,
    )
    # Audit R8-07 self-tests: matched GINS vcn_assay_id (\u200b) & study_id (\u00ad) with invisible Unicode format chars MUST FAIL!
    gi_inv_vcn_base = _gins_with_arch_override({"vcn_assay_id": "DDPCR_VCN\u200b_001"})
    gi_inv_vcn_base["vcn_assay_id"] = "DDPCR_VCN\u200b_001"
    gi_inv_vcn = evaluate_gate35_gins_oq018_reserve(gi_inv_vcn_base, canonical_manifest=ext_manifest)
    gi_inv_sid_base = _gins_with_arch_override({"study_id": "SYN_GINS\u00ad_STUDY_001"})
    gi_inv_sid_base["study_record_ref"] = "SYN_GINS\u00ad_STUDY_001"
    gi_inv_sid = evaluate_gate35_gins_oq018_reserve(gi_inv_sid_base, canonical_manifest=ext_manifest)
    _require(
        gi_syn["decision"] == "SYNTHETIC_SELF_TEST_PASS"
        and gi_syn["promotion_authorized"] is False
        and gi_syn["active_wave6_credit_pp"] == 0.0,
        f"gi_syn failed: {gi_syn}",