scripts/verify_iip0057_foundry_v2_shield_invvax_insl82i_cuffv2.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0057_foundry_v2_shield_invvax_insl82i_cuffv2.py · SHA-256: 1c63dcf649c42be4…
r_r10_arch_one_omit = _both_mode_ins_roster_probe(
distinct12_r10,
primary_issuer="BIOREPO_T1D_V1",
alias_issuer="BIOREPO_T1D_V1",
cur_primary_issuer="BIOREPO_T1D_V1",
cur_alias_issuer=None,
)
require_cond(
r_r10_arch_one_omit["decision"] == "HOLD"
and r_r10_arch_one_omit["promotion_authorized"] is False
and r_r10_arch_one_omit["unique_hla_donors_verified"] is None
and r_r10_arch_one_omit["exact_one_sided_95pct_u95_pct"] is None
and r_r10_arch_one_omit["ins_statistics_derivation_source"] == "UNVERIFIED_HOLD_MISSING_ARCHIVED_ISSUER"
and any("HOLD_MISSING_ARCHIVED_HLA_REGISTRY_ISSUER:per_allele_panels" in r for r in r_r10_arch_one_omit["reasons"]),
f"R10/R11 archive one-form omitted issuer must HOLD with null official stats, got {r_r10_arch_one_omit}",
)
_rec("r10_ins_archive_one_form_omitted_issuer_hold", r_r10_arch_one_omit)
r_r10_cur_omit_fail = _both_mode_ins_roster_probe(
distinct12_r10,
primary_issuer="BIOREPO_T1D_V1",
alias_issuer=None,
cur_primary_issuer="BIOREPO_T1D_V1",
cur_alias_issuer="BIOREPO_T1D_V1",
)
require_cond(
r_r10_cur_omit_fail["decision"] == "FAIL"
and r_r10_cur_omit_fail["promotion_authorized"] is False
and r_r10_cur_omit_fail["unique_hla_donors_verified"] == 12
and abs(r_r10_cur_omit_fail["exact_one_sided_95pct_u95_pct"] - 22.0922) < 1e-3
and r_r10_cur_omit_fail["ins_statistics_derivation_source"] == "AUTHENTICATED_ARCHIVE_ONLY_CALLER_CONFLICT"
and any("INS_MISSING_CURRENT_HLA_REGISTRY_ISSUER:per_allele_panels" in r for r in r_r10_cur_omit_fail["reasons"]),
f"R10/R11 current omitted issuer vs archive-established issuer must FAIL with archive-only stats, got {r_r10_cur_omit_fail}",
)
_rec("r10_ins_current_omitted_issuer_vs_archived_fail", r_r10_cur_omit_fail)
r_r10_pos_hla_iss = _both_mode_ins_roster_probe(
distinct12_r10,
primary_issuer="BIOREPO_T1D_V1",
alias_issuer="BIOREPO_T1D_V1",
issuer_field="hla_registry_issuer",
)
require_cond(
r_r10_pos_hla_iss["decision"] == "PASS"
and r_r10_pos_hla_iss["promotion_authorized"] is True
and r_r10_pos_hla_iss["unique_hla_donors_verified"] == 12
and r_r10_pos_hla_iss["total_reactive_donors"] == 0
and abs(r_r10_pos_hla_iss["exact_one_sided_95pct_u95_pct"] - 22.0922) < 1e-3
and r_r10_pos_hla_iss["ins_statistics_derivation_source"] == "AUTHENTICATED_ARCHIVE_ROSTER_VERIFIED"
and r_r10_pos_hla_iss["caller_roster_reconciliation_status"] == "MATCHED"
and r_r10_pos_hla_iss["caller_reported_unverified_u95_pct"] is None,
f"R10/R11 positive hla_registry_issuer across both rosters must PASS with AUTHENTICATED_ARCHIVE_ROSTER_VERIFIED, got {r_r10_pos_hla_iss}",
)
_rec("r10_ins_both_rosters_positive_hla_registry_issuer_pass", r_r10_pos_hla_iss)
# Round-11 Audit R10-03: Strict 4-state archive-only official statistics (zero caller contamination; null on HOLD/unverified/internal-archive-conflict)
for lk_mode in ("record_id", "archive_sha256"):
ins_c11, st_c11 = make_authenticated_gate34_fixture_and_store("ins", arm_manifest=arm_manifest, store_key_mode=lk_mode)
ins_c11["hla_allele_panel_records"]["HLA-DRB1*04:01"]["reactive_donor_ids"] = ["T1D_DON_001"]
ins_c11["hla_allele_panel_records"]["HLA-DRB1*04:01"]["reactive_donors"] = 1
r_r11_caller_react = evaluate_gate34_ins_l82i_elisa_pe2max(ins_c11, arm_manifest, trusted_evidence_store=st_c11)
require_cond(
r_r11_caller_react["decision"] == "FAIL"
and r_r11_caller_react["promotion_authorized"] is False
and r_r11_caller_react["unique_hla_donors_verified"] == 12
and r_r11_caller_react["total_reactive_donors"] == 0
and abs(r_r11_caller_react["exact_one_sided_95pct_u95_pct"] - 22.0922) < 1e-3
and r_r11_caller_react["ins_statistics_derivation_source"] == "AUTHENTICATED_ARCHIVE_ONLY_CALLER_CONFLICT"
and r_r11_caller_react["caller_roster_reconciliation_status"] == "CONFLICT_CALLER_MISMATCH"
and r_r11_caller_react["caller_reported_unverified_unique_donors"] == 12
and r_r11_caller_react["caller_reported_unverified_reactive_donors"] == 1
and abs(r_r11_caller_react["caller_reported_unverified_u95_pct"] - 33.8681) < 1e-3,
f"R11 caller-only reactive donor ({lk_mode}) contaminated official archive U95: {r_r11_caller_react}",
)
_rec("r11_ins_caller_only_reactive_preserves_archive_u95_fail", r_r11_caller_react)
ins_no_arch, st_no_arch = make_authenticated_gate34_fixture_and_store("ins", arm_manifest=arm_manifest)
ins_no_arch.pop("current_assay_evidence_record")
r_r11_no_arch = evaluate_gate34_ins_l82i_elisa_pe2max(ins_no_arch, arm_manifest, trusted_evidence_store=st_no_arch)
require_cond(
r_r11_no_arch["decision"] == "HOLD"
and r_r11_no_arch["promotion_authorized"] is False
and r_r11_no_arch["unique_hla_donors_verified"] is None
and r_r11_no_arch["total_reactive_donors"] is None
and r_r11_no_arch["exact_one_sided_95pct_u95_pct"] is None
and r_r11_no_arch["ins_statistics_derivation_source"] == "UNVERIFIED_HOLD_NO_AUTHENTICATED_ARCHIVE"
and r_r11_no_arch["caller_reported_unverified_unique_donors"] == 12,
f"R11 missing archive must HOLD with null official stats, got {r_r11_no_arch}",
)
_rec("r11_ins_missing_archive_null_verified_stats_hold", r_r11_no_arch)
r_r11_no_store = evaluate_gate34_ins_l82i_elisa_pe2max(auth_ins_ok, arm_manifest, trusted_evidence_store=None)
require_cond(
r_r11_no_store["decision"] == "HOLD_UNRESOLVED_TRUSTED_EVIDENCE_STORE"
and r_r11_no_store["promotion_authorized"] is False
and r_r11_no_store["unique_hla_donors_verified"] is None
and r_r11_no_store["total_reactive_donors"] is None
and r_r11_no_store["exact_one_sided_95pct_u95_pct"] is None
and r_r11_no_store["ins_statistics_derivation_source"] == "UNVERIFIED_HOLD_NO_AUTHENTICATED_ARCHIVE"
and r_r11_no_store["caller_reported_unverified_unique_donors"] == 12,
f"R11 missing trusted store must HOLD with null official stats, got {r_r11_no_store}",
)
_rec("r11_ins_missing_trusted_store_null_verified_stats_hold", r_r11_no_store)
ins_conf_alias = copy.deepcopy(auth_ins_ok["current_assay_evidence_record"]["hla_allele_panel_records"])
ins_conf_alias["HLA-DRB1*04:01"]["reactive_donor_ids"] = ["T1D_DON_001"]
ins_conf_alias["HLA-DRB1*04:01"]["reactive_donors"] = 1
ins_conf, ins_conf_st = _reseal_cur(auth_ins_ok, {"per_allele_panels": ins_conf_alias})
r_r11_int_conf = evaluate_gate34_ins_l82i_elisa_pe2max(ins_conf, arm_manifest, trusted_evidence_store=ins_conf_st)
require_cond(
r_r11_int_conf["decision"] == "FAIL"
and r_r11_int_conf["promotion_authorized"] is False
and r_r11_int_conf["unique_hla_donors_verified"] is None
and r_r11_int_conf["total_reactive_donors"] is None
and r_r11_int_conf["exact_one_sided_95pct_u95_pct"] is None
and r_r11_int_conf["ins_statistics_derivation_source"] == "WITHHELD_INTERNAL_ARCHIVE_CONFLICT",
f"R11 internally conflicting archive must FAIL with null official stats, got {r_r11_int_conf}",
)
_rec("r11_ins_internal_archive_conflict_null_verified_stats_fail", r_r11_int_conf)
ins_1of12_panels = copy.deepcopy(auth_ins_ok["hla_allele_panel_records"])
ins_1of12_panels["HLA-DRB1*04:01"]["reactive_donor_ids"] = ["T1D_DON_001"]
ins_1of12_panels["HLA-DRB1*04:01"]["reactive_donors"] = 1
ins_1of12_panels["HLA-DRB1*04:01"]["max_elispot_sfu"] = 65.0
ins_1of12_base = copy.deepcopy(auth_ins_ok)
ins_1of12_base["hla_allele_panel_records"] = copy.deepcopy(ins_1of12_panels)
ins_1of12, ins_1of12_st = _reseal_cur(ins_1of12_base, {"hla_allele_panel_records": copy.deepcopy(ins_1of12_panels)})
r_r11_arch_1of12 = evaluate_gate34_ins_l82i_elisa_pe2max(ins_1of12, arm_manifest, trusted_evidence_store=ins_1of12_st)
require_cond(
r_r11_arch_1of12["decision"] == "FAIL"
and r_r11_arch_1of12["promotion_authorized"] is False
and r_r11_arch_1of12["unique_hla_donors_verified"] == 12
and r_r11_arch_1of12["total_reactive_donors"] == 1
and abs(r_r11_arch_1of12["exact_one_sided_95pct_u95_pct"] - 33.8681) < 1e-3
and r_r11_arch_1of12["ins_statistics_derivation_source"] == "AUTHENTICATED_ARCHIVE_ROSTER_VERIFIED"
and r_r11_arch_1of12["caller_roster_reconciliation_status"] == "MATCHED"
and r_r11_arch_1of12["caller_reported_unverified_u95_pct"] is None,
f"R11 archive-driven 1/12 reactive FAIL must report archive 33.8681%, got {r_r11_arch_1of12}",
)
_rec("r11_ins_archive_1of12_reactive_matched_fail", r_r11_arch_1of12)
sh_caller_adv = copy.deepcopy(auth_sh)
sh_caller_adv["off_target_kd_l95_um"] = 7.5
r_r11_sh_caller = evaluate_gate34_shield_sel(sh_caller_adv, arm_manifest, trusted_evidence_store=auth_store)
require_cond(
r_r11_sh_caller["decision"] == "FAIL"
and r_r11_sh_caller["promotion_authorized"] is False
and abs(r_r11_sh_caller["pan_dq_peak_ro_pct"] - 3.9159) < 1e-3
and r_r11_sh_caller["shield_statistics_derivation_source"] == "AUTHENTICATED_ARCHIVE_ONLY_CALLER_CONFLICT"
and abs(r_r11_sh_caller["caller_reported_unverified_pan_dq_peak_ro_pct"] - 7.5366) < 1e-3,
f"R11 SHIELD caller-only adverse probe contaminated official RO: {r_r11_sh_caller}",
)
_rec("r11_shield_caller_only_adverse_preserves_archive_ro_fail", r_r11_sh_caller)
r_r11_sh_nostore = evaluate_gate34_shield_sel(auth_sh, arm_manifest, trusted_evidence_store=None)
require_cond(
r_r11_sh_nostore["decision"] == "HOLD_UNRESOLVED_TRUSTED_EVIDENCE_STORE"
and r_r11_sh_nostore["promotion_authorized"] is False
and r_r11_sh_nostore["pan_dq_peak_ro_pct"] is None
and r_r11_sh_nostore["recomputed_selectivity_ratio"] is None
and r_r11_sh_nostore["shield_statistics_derivation_source"] == "UNVERIFIED_HOLD_NO_AUTHENTICATED_ARCHIVE",
f"R11 SHIELD missing store must HOLD with null official RO/selectivity, got {r_r11_sh_nostore}",
)
_rec("r11_shield_missing_store_null_verified_stats_hold", r_r11_sh_nostore)
# Round-12 Audit R11-04: Gate ALL official SHIELD (& INS) statistics on complete authenticated archive + every internal consistency check; separate caller reconciliation!
shield_official_stat_keys = (
"pan_dq_peak_ro_pct",
"pan_dq_plasma_trough_ro_pct",
"pan_dq_dln_trough_ro_pct",
"dln_trough_on_target_ro_pct",
"recomputed_selectivity_ratio",
)
def _reseal_module_mode(
mod_name: str,
cur_mutator: Callable[[dict[str, Any]], None],
*,
store_key_mode: str,
parent_mutator: Callable[[dict[str, Any]], None] | None = None,
) -> tuple[dict[str, Any], dict[str, dict[str, Any]]]:
o, _ = make_authenticated_gate34_fixture_and_store(mod_name, arm_manifest=arm_manifest, store_key_mode=store_key_mode)
if parent_mutator is not None:
parent_mutator(o)
c = copy.deepcopy(o["current_assay_evidence_record"])
cur_mutator(c)
o["current_assay_evidence_record"] = seal_evidence_record(c)
st = build_trusted_store_for_obs(o, store_key_mode=store_key_mode)
return o, st
for lk_mode in ("record_id", "archive_sha256", "both"):
sh_no_sid, st_no_sid = _reseal_module_mode(
"shield",
lambda c: c.pop("study_id", None),
store_key_mode=lk_mode,
)
r_r12_no_sid = evaluate_gate34_shield_sel(sh_no_sid, arm_manifest, trusted_evidence_store=st_no_sid)
require_cond(
r_r12_no_sid["decision"] == "HOLD"
and r_r12_no_sid["promotion_authorized"] is False
and all(r_r12_no_sid[k] is None for k in shield_official_stat_keys)
and r_r12_no_sid["shield_statistics_derivation_source"] == "UNVERIFIED_HOLD_INCOMPLETE_ARCHIVE",
f"R12 SHIELD omitted archived study_id ({lk_mode}) must HOLD with null official stats, got {r_r12_no_sid}",
)
sh_no_sid_fail, st_no_sid_fail = _reseal_module_mode(
"shield",
lambda c: c.pop("study_id", None),
store_key_mode=lk_mode,
parent_mutator=lambda p: p.__setitem__("off_target_kd_l95_um", 7.5),
)
r_r12_no_sid_fail = evaluate_gate34_shield_sel(sh_no_sid_fail, arm_manifest, trusted_evidence_store=st_no_sid_fail)
require_cond(
r_r12_no_sid_fail["decision"] == "FAIL"
and r_r12_no_sid_fail["promotion_authorized"] is False
and all(r_r12_no_sid_fail[k] is None for k in shield_official_stat_keys)
and r_r12_no_sid_fail["shield_statistics_derivation_source"] == "WITHHELD_INCOMPLETE_ARCHIVE_WITH_INDEPENDENT_FAIL"
and "_HOLD_" not in r_r12_no_sid_fail["shield_statistics_derivation_source"],
f"R12 SHIELD omitted archived study_id + independent FAIL ({lk_mode}) must never pair FAIL with HOLD label: {r_r12_no_sid_fail}",
)
sh_trough_gt_pk, st_tgp = _reseal_module_mode(
"shield",
lambda c: c.update({"peak_free_nm": 1.0, "plasma_trough_free_nm": 2000.0}),
store_key_mode=lk_mode,
parent_mutator=lambda p: p.update({"peak_free_nm": 1.0, "plasma_trough_free_nm": 2000.0}),
)
r_r12_tgp = evaluate_gate34_shield_sel(sh_trough_gt_pk, arm_manifest, trusted_evidence_store=st_tgp)
require_cond(
r_r12_tgp["decision"] == "FAIL"
and r_r12_tgp["promotion_authorized"] is False
and all(r_r12_tgp[k] is None for k in shield_official_stat_keys)
and r_r12_tgp["shield_statistics_derivation_source"] == "WITHHELD_INTERNAL_ARCHIVE_CONFLICT",
f"R12 SHIELD archived trough > peak ({lk_mode}) must withhold ALL official stats, got {r_r12_tgp}",
)
sh_reg_conf, st_rc = _reseal_module_mode(
"shield",
lambda c: c.update({"dosing_regimen": "Q28D", "timed_pk_day": 84}),
store_key_mode=lk_mode,
parent_mutator=lambda p: p.update({"regimen_id": "Q28D", "timed_pk_day": 84}),
)
r_r12_reg = evaluate_gate34_shield_sel(sh_reg_conf, arm_manifest, trusted_evidence_store=st_rc)
require_cond(
r_r12_reg["decision"] == "FAIL"
and r_r12_reg["promotion_authorized"] is False
and all(r_r12_reg[k] is None for k in shield_official_stat_keys)
and r_r12_reg["shield_statistics_derivation_source"] == "WITHHELD_INTERNAL_ARCHIVE_CONFLICT",
f"R12 SHIELD contradictory archived regimen/interval ({lk_mode}) must withhold ALL official stats, got {r_r12_reg}",