scripts/verify_iip0055_hygiene_safecell_minifh_orthogonality.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0055_hygiene_safecell_minifh_orthogonality.py · SHA-256: d5b98e2ba1310333…
if "delta_vs_honest_l1_exact_pp" in ref:
exact_diffs.append(abs(actual["delta_vs_honest_l1_exact_pp"] - ref["delta_vs_honest_l1_exact_pp"]))
e_err = max(exact_diffs)
exact_parity_errs[key] = e_err
require_cond(e_err < 1.0e-12, f"FAIL_CLOSED: unrounded external contract parity drift >= 1e-12 on {key}: max_abs_err={e_err}")
disp_diffs = [
abs(actual["locked_pct"] - ref["locked_pct"]),
abs(actual["modular_pct"] - ref["modular_pct"]),
abs(actual["ceiling_pct"] - ref["ceiling_pct"]),
max(abs(a - b) for a, b in zip(actual["hurdle_caps_pct"], ref["hurdle_caps_pct"])),
max(abs(a - b) for a, b in zip(actual["hurdle_any_success_pct"], ref["hurdle_any_success_pct"])),
]
if "strassen_h123_h4_pct" in ref:
disp_diffs.append(max(abs(a - b) for a, b in zip(actual["strassen_h123_h4_pct"], ref["strassen_h123_h4_pct"])))
if "delta_vs_honest_l1_pct_pp" in ref:
disp_diffs.append(abs(actual["delta_vs_honest_l1_pct_pp"] - ref["delta_vs_honest_l1_pct_pp"]))
d_err = max(disp_diffs)
display_parity_errs[key] = d_err
require_cond(d_err == 0.0, f"FAIL_CLOSED: 4-dp display external contract parity mismatch on {key}: max_abs_err={d_err}")
repo_iip0042_parity_err: float | None = None
if repo_root is not None:
p42 = repo_root / "data" / "extracted" / "iip0042_master_multilayer_portfolio_crosswalk_v0.8.0.json"
require_cond(p42.is_file(), f"FAIL_CLOSED: missing IIP-0042 crosswalk under --repo-root: {p42}")
d42 = load_strict_json_text(p42.read_text(encoding="utf-8"), p42.name)
by25 = {r["layer_id"]: r for r in d42["headline_live_eligible_scenarios_strict_no_r3b"]["phi_0p25_central"]}
repo_iip0042_parity_err = max(
abs(l0["modular_pct"] - d42["layer_0_core_3arm"]["modular_k100_pct"]),
abs(l1_ship["modular_pct"] - round(by25["L1_LIVE_5ARM_WU3"]["modular_k100_exact"] * 100.0, 4)),
abs(w5_l3b["modular_pct"] - round(by25["L3B_STACK_STRICT_100PCT_ZERO_DRUG"]["modular_k100_exact"] * 100.0, 4)),
)
require_cond(repo_iip0042_parity_err < 1e-4, f"IIP-0042 live repo parity error: {repo_iip0042_parity_err}")
return {
"h1_allo_locked_pct": 88.0,
"external_master_contract_verified": True,
"exact_unrounded_parity_tolerance": 1.0e-12,
"exact_unrounded_parity_max_abs_err": max(exact_parity_errs.values()),
"display_4dp_parity_max_abs_err": max(display_parity_errs.values()),
"exact_unrounded_parity_errors_by_scenario": exact_parity_errs,
"display_4dp_parity_errors_by_scenario": display_parity_errs,
"repo_iip0042_cross_check_max_abs_err": repo_iip0042_parity_err,
"attribution_decomposition_note": "Of the +1.9990 pp W6-C1 standalone shift over Honest L1 (59.2944% -> 61.2934%), +1.0056 pp (59.2944% -> 60.3000%) comes from C1 arm marginals alone at fixed phi_inc=0.50 (D H1 0.62->0.78, B/X/Y H2 +0.01, D H3 0.70->0.68), and +0.9934 pp comes from the modeled phi_inc=0.50->0.25 dependence sensitivity shift.",
"scenarios": {
"L0_core_3arm": l0,
"L1_shipped_IIP0035_phi0": l1_ship,
"Wave5_L3B_audited_caveated": w5_l3b,
"L1_honest_monoculture_phi_inc_0.50": l1_honest,
"W6_C1_standalone_over_honest_L1": {**c1_phi25, "phi_inc": 0.25, "h1_allo_locked_pct": 88.0},
"Sens_C1_marginals_only_at_phi_inc_0.50": {**c1_phi50, "phi_inc": 0.50},
"Sens_C1_marginals_only_at_phi_inc_0.75": {**c1_phi75, "phi_inc": 0.75},
"Wave6_6Arm_Central_EnSC_H1_88_LOCKED": {**six_phi25, "phi_inc": 0.25},
"Sens_6Arm_Central_at_phi_inc_0.50": {**six_phi50, "phi_inc": 0.50},
"DIAGNOSTIC_KILLED_D1b_K1_TwinRecurrence_H3_0p15": {
**k1_twin_fail,
"delta_vs_d1b_k2_exact_pp": k1_twin_fail["modular_exact"] - c1_phi25["modular_exact"],
"delta_vs_d1b_k2_pp": round(k1_twin_fail["modular_exact"] - c1_phi25["modular_exact"], 4),
"promotion_permitted": False,
},
},
"phi_inc_sensitivity_sweep": {
"L1_baseline_arms": {
"phi_inc_0.25": l1_phi25,
"phi_inc_0.50": l1_honest,
"phi_inc_0.75": l1_phi75,
},
"W6_C1_arms": {
"phi_inc_0.25": c1_phi25,
"phi_inc_0.50": c1_phi50,
"phi_inc_0.75": c1_phi75,
},
"SixArm_Central": {
"phi_inc_0.25": six_phi25,
"phi_inc_0.50": six_phi50,
"phi_inc_0.75": six_phi75,
},
},
}
# =============================================================================
# PART G — FAIL-CLOSED EXECUTABLE GATE-34 ADJUDICATOR (ROUND 14)
# =============================================================================
ALLOWED_PAN_LINEAGE_LOCI_BY_ARM: Dict[str, FrozenSet[str]] = {
"A": frozenset({"TBP_CHR6_3UTR_IRES"}),
"B": frozenset({"TBP_CHR6_3UTR_IRES"}),
"X": frozenset({"TBP_CHR6_3UTR_IRES"}),
"Y": frozenset({"TBP_CHR6_3UTR_IRES"}),
"D": frozenset({"ACTB_CHR7_3UTR_IRES"}),
"Z": frozenset({"TBP_CHR6_3UTR_IRES"}),
}
CANONICAL_PRIMARY_SWITCH_SPEC_BY_PRODUCT: Dict[str, Dict[str, Any]] = {
"ISLET1_DESIGN_A_V080_REF": {
"allowed_switch_ids": frozenset({"AAVS1::iCasp9"}),
"allowed_loci": frozenset({"chr19:AAVS1", "chr19:AAVS1_iCasp9"}),
"allows_d315a": False,
"is_icasp8": False,
"requires_secondary": False,
},
"ISLET1_DESIGN_A_V090_TBP_CANDIDATE": {
"allowed_switch_ids": frozenset({
"TBP::iCasp9", "TBP::iCasp9_WT", "TBP_iCasp9_WT",
"TBP::iCasp9_D315A", "TBP_iCasp9_D315A", "TBP::iCasp9(D315A)",
}),
"allowed_loci": frozenset({"chr6:TBP", "chr6:TBP_iCasp9"}),
"allows_d315a": True,
"is_icasp8": False,
"requires_secondary": False,
},
"ISLET1_DESIGN_B_V090": {
"allowed_switch_ids": frozenset({
"TBP::iCasp9", "TBP::iCasp9_WT", "TBP_iCasp9_WT",
"TBP::iCasp9_D315A", "TBP_iCasp9_D315A", "TBP::iCasp9(D315A)",
}),
"allowed_loci": frozenset({"chr6:TBP", "chr6:TBP_iCasp9"}),
"allows_d315a": True,
"is_icasp8": False,
"requires_secondary": False,
},
"ISLET1_DESIGN_X_V090": {
"allowed_switch_ids": frozenset({"TBP::iCasp9", "TBP::iCasp9_WT", "TBP_iCasp9_WT"}),
"allowed_loci": frozenset({"chr6:TBP", "chr6:TBP_iCasp9"}),
"allows_d315a": False,
"is_icasp8": False,
"requires_secondary": False,
},
"ISLET1_DESIGN_Y_V3": {
"allowed_switch_ids": frozenset({
"TBP::iCasp9", "TBP::iCasp9_WT", "TBP_iCasp9_WT",
"TBP::iCasp9_D315A", "TBP_iCasp9_D315A", "TBP::iCasp9(D315A)",
}),
"allowed_loci": frozenset({"chr6:TBP", "chr6:TBP_iCasp9"}),
"allows_d315a": True,
"is_icasp8": False,
"requires_secondary": True,
},
"ISLET1_DESIGN_D1B_LEAN_K2": {
"allowed_switch_ids": frozenset({"ACTB::iCasp8", "ACTB_iCasp8"}),
"allowed_loci": frozenset({"chr7:ACTB", "chr7:ACTB_iCasp8"}),
"allows_d315a": False,
"is_icasp8": True,
"requires_secondary": False,
},
"ISLET1_ARM_Z_ENSC_V090": {
"allowed_switch_ids": frozenset({
"TBP::iCasp9", "TBP::iCasp9_WT", "TBP_iCasp9_WT",
"TBP::iCasp9_D315A", "TBP_iCasp9_D315A", "TBP::iCasp9(D315A)",
}),
"allowed_loci": frozenset({"chr6:TBP", "chr6:TBP_iCasp9"}),
"allows_d315a": True,
"is_icasp8": False,
"requires_secondary": True,
},
}
CANONICAL_SECONDARY_SWITCH_IDS: FrozenSet[str] = frozenset({"B2M-/-_CDK1::HSV-TK"})
CANONICAL_SECONDARY_SWITCH_LOCI: FrozenSet[str] = frozenset({"chr10:CDK1", "chr10:CDK1_HSV-TK"})
ALLOWED_SECONDARY_PRODRUGS: FrozenSet[str] = frozenset({"ganciclovir", "GCV"})
PROHIBITED_SUPPORTING_AUTHORITY_SCOPES: FrozenSet[str] = frozenset({
"REJECTED_OR_HELD",
"BANK_QUALIFICATION_ONLY",
"STAGE_LIMITED_SORT_ONLY",
"COMPONENT_SORT_QUALIFICATION_ONLY",
"WAVE7_RESERVE_ONLY",
})
ALLOWED_COMPLEMENT_MODES_BY_ARM: Dict[str, FrozenSet[str]] = {
"A": frozenset({"CELL_INTRINSIC_CD55_CD59_LEGACY_A_BASELINE"}),
"B": frozenset({"ENCAPSULATION_NO_CAO2_WITH_OPTIONAL_CUFF_V2"}),
"X": frozenset({"CELL_INTRINSIC_CD55_CD59_WITH_OPTIONAL_CUFF_V2"}),
"Y": frozenset({"TM_MINIFH_MONO_V2_PDGFRB_PLUS_CD59", "TM_MINIFH_MONO_V2_CD8A_C164S_C181S_PLUS_CD59"}),
"D": frozenset({"NATIVE_AUTOLOGOUS"}),
"Z": frozenset({"TM_MINIFH_MONO_V2_PDGFRB_PLUS_CD59", "TM_MINIFH_MONO_V2_CD8A_C164S_C181S_PLUS_CD59"}),
}
ALLOWED_BANK_ORIGINS_BY_ARM: Dict[str, FrozenSet[str]] = {
"A": frozenset({"allogeneic_hiPSC"}),
"B": frozenset({"allogeneic_hiPSC"}),
"X": frozenset({"allogeneic_hiPSC"}),
"Y": frozenset({"allogeneic_hiPSC"}),
"D": frozenset({"autologous_hiPSC"}),
"Z": frozenset({"allogeneic_EnSC"}),
}
DEFAULT_BANK_ORIGIN_BY_ARM: Dict[str, str] = {
"A": "allogeneic_hiPSC",
"B": "allogeneic_hiPSC",
"X": "allogeneic_hiPSC",
"Y": "allogeneic_hiPSC",
"D": "autologous_hiPSC",
"Z": "allogeneic_EnSC",
}
ARM_RETAINS_MHC_I_CANONICAL: Dict[str, bool] = {
"A": False,
"B": False,
"X": True,
"Y": False,
"D": True,
"Z": False,
}
GATE0V_BANK_ONLY_DECISIONS: FrozenSet[str] = frozenset({
"PASS_WHOLEGRAFT_BANK_QUALIFICATION",
"PASS_COMPOSITE_BANK_QUALIFICATION",
})
GATE0V_ALLO_CLINICAL_DECISIONS: FrozenSet[str] = frozenset({
"PASS_WHOLEGRAFT_LOT_RELEASE_SURROGATE",
"PASS_COMPOSITE_CLINICAL_RELEASE",
})
GATE0V_AUTO_CLINICAL_DECISIONS: FrozenSet[str] = frozenset({
"PASS_WHOLEGRAFT_AUTOLOGOUS_PROCESS_QUAL",
"PASS_COMPOSITE_AUTOLOGOUS_CLINICAL_RELEASE",
})
VALID_GATE0V_PASS_VERDICTS: FrozenSet[str] = (
GATE0V_BANK_ONLY_DECISIONS
| GATE0V_ALLO_CLINICAL_DECISIONS
| GATE0V_AUTO_CLINICAL_DECISIONS
| frozenset({"SYNTHETIC_SELF_TEST_PASS"})
)
GATE5_WETLAB_PASS_DECISIONS: FrozenSet[str] = frozenset({
"PASS_GATE5_OQ012_CLONOGENIC_ERADICATION",
})
GATE5_ALLOWED_DECISIONS: FrozenSet[str] = frozenset({
"PASS_GATE5_OQ012_CLONOGENIC_ERADICATION",
"SYNTHETIC_SELF_TEST_PASS",
})
REQUIRED_H2H_COMPARATOR_ARMS: FrozenSet[str] = frozenset({
"TBP_iCasp9_WT",
"TBP_iCasp9_D315A",
"ACTB_iCasp8",
})
VALID_SUBMISSION_TYPES: FrozenSet[str] = frozenset({
"SYNTHETIC_SELF_TEST_FIXTURE",
"EXTERNAL_LOT_SUBMISSION",
})
VALID_EVALUATION_SCOPES: FrozenSet[str] = frozenset({
"FULL_CLINICAL_PROMOTION",
"BANK_QUALIFICATION_ONLY",
"STAGE0_ONLY_NO_CLINICAL_PROMOTION",
})
def _load_default_arm_manifest_checked() -> Dict[str, Any]:
manifest_path = discover_default_arm_manifest_path()
require_cond(manifest_path.is_file(), f"Missing canonical arm manifest: {manifest_path}")
raw = manifest_path.read_bytes()
require_cond(sha256_bytes(raw) == EXPECTED_ARM_MANIFEST_SHA256, "Canonical arm manifest SHA-256 mismatch")
obj = load_strict_json_text(raw.decode("utf-8"), manifest_path.name)
ok, _ = verify_arm_manifest_dict_integrity(obj)
require_cond(ok, "Canonical arm manifest canonical SHA-256 mismatch")
return obj
def seal_upstream_evidence_record_v1(record: Mapping[str, Any]) -> Dict[str, Any]: