scripts/verify_iip0042_master_multilayer_portfolio_crosswalk.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0042_master_multilayer_portfolio_crosswalk.py · SHA-256: 16964a158458b5cf…
"phi_0p25": _honest_stage0_unconditional_ev(by25_s, "0.25"),
"phi_0p50": _honest_stage0_unconditional_ev(by50_s, "0.50"),
}
h3_channel_budget = {
"epistemic_warning": (
"UNCITED MODELING JUDGMENT SCENARIO — NOT EMPIRICALLY IDENTIFIED. The 6.5 / 2.5 / 2.0 pp "
"Channel (a)/(b)/(c) partition and overlap parameter omega in [0, 1] are bookkeeping scenarios, "
"not measured human transplant-graft quantities. Quote the full omega in [0, 1] band rather than "
"treating any single omega point as an empirical finding."
),
"live_c3_baseline": 0.89,
"total_systemic_h3_failure_pp": 11.0,
"channel_decomposition_scenario_pp": {
"channel_a_memory_tcell_recurrence_acute_and_reconstitution": 6.5,
"channel_b_humoral_autoab_igm_igg_complement_escape": 2.5,
"channel_c_innate_neutrophil_myeloid_cytokine_bystander": 2.0,
},
"omega_min_for_c3_lt_0p94": sc_25["omega_sweep_strict"]["min_omega_for_c3_lt_0p94"],
"meld_atg_primary_clinical_anchor": (
"MELD-ATG low-dose arm (PMID:40976248, NCT04509791): single active Day-1 0.5 mg/kg IV rabbit ATG "
"+ Day-2 IV placebo (only higher-dose arms received active drug on Day 2); n=35 assigned, n=34 safety "
"denominator, 8/34 (24%) CRS, 11/34 (32%) serum sickness, ages 5-25 recent-onset native T1D (no graft). "
"Native-T1D trial rates do not empirically identify graft H3 response or H4 AE drag."
),
}
# Run executable Gate 30-ATG-XREACT, mirrored Gate 30-SHIELD-SPR, and NCT cohort mapping self-tests!
xreact_self_tests = run_gate30_atg_xreact_decision_table_self_tests()
shield_spr_self_tests = run_gate30_shield_spr_decision_table_self_tests()
nct_mapping_self_tests = run_iip0042_nct_mapping_self_tests()
nct_mapping_audit: dict[str, Any] = {
"nct_cohort_mapping_verified": False,
"self_tests": nct_mapping_self_tests,
}
md_candidate = openislet_root / "docs" / "GATE-30-PORTFOLIO-AND-TRACKB-CONTINGENCY-PROTOCOL.md"
md_text_loaded: str | None = None
if md_candidate.is_file():
md_text_loaded = md_candidate.read_text(encoding="utf-8")
verify_gate30_protocol_markdown_alignment(md_text_loaded, md_candidate.name)
# Verify verbatim alignment with side-contract owner re-authorization condition & NCT trial mapping whenever present!
sc_candidates = [
openislet_root / "data" / "protocols" / "iip0042_portfolio_and_trackb_side_contract_v0.8.0.json",
]
if ART_DIR.name == "artifacts-carbon":
sc_candidates.insert(0, ART_DIR / "exp030_iip0043_side_contract.json")
for sc_candidate in sc_candidates:
if sc_candidate.is_file():
sc_raw = sc_candidate.read_text(encoding="utf-8")
sc_obj = load_strict_json_text(sc_raw, sc_candidate.name)
sc_rule = sc_obj.get("locked_owner_policy", {}).get("trackb_eligibility_rule")
if sc_rule != CANONICAL_TRACKB_ELIGIBILITY_RULE:
raise RuntimeError(
f"Eligibility rule mismatch vs side contract {sc_candidate.name}: "
f"receipt={CANONICAL_TRACKB_ELIGIBILITY_RULE!r} vs side_contract={sc_rule!r}"
)
sc_1jk8 = _v37_find_unnegated_1jk8_conflation(sc_raw) or _v37_find_unnegated_1jk8_conflation(
json.dumps(sc_obj, ensure_ascii=False)
)
if sc_1jk8 is not None:
raise RuntimeError(
f"Side contract {sc_candidate.name} contains prohibited PDB 1JK8 <-> WT InsB:9-23 conflation: {sc_1jk8!r}"
)
nct_res = verify_iip0042_published_trial_cohort_nct_mapping(
sc_obj,
md_text_loaded,
openislet_root=openislet_root,
)
nct_mapping_audit = {
**nct_res,
"self_tests": nct_mapping_self_tests,
}
receipt = {
"schema_version": "exp030_master_2pow20_portfolio_receipt_v3.4_r04",
"investigation_id": "EXP-030",
"candidate_id": "CAND-033",
"target_iip": "IIP-0042",
"decision_id": "DEC-121",
"generated_date": GENERATED_DATE,
"locked_owner_policy": "POLICY_OPTION_1_SPLIT_SHIP_DESIGN_A_EXCLUDES_ATG_INDUCTION_SHIELD_FIRST_GATED_OPTIONAL_TRACKB_AFTER_ATG_XREACT",
"live_headline_delta_pp_today": 0.0,
"current_active_trackb_ev_pp": 0.0,
"runtime_environment": {
"python_version": sys.version,
"python_version_info": list(sys.version_info[:3]),
"byte_exact_scope": "pinned_cpython_3_12_12_build_both_-B_and_-O_-B",
"parity_tolerance_policy": "24/24_displayed_scalar_parity_and_numeric_tolerance_le_1e-12_across_cpython_builds",
"portable_comparison_ignored_fields": ["runtime_environment.python_version", "portable_payload_sha256"],
"portable_check_cli_flag": "--check-portable",
},
"epistemic_notice": (
"SPLIT-SHIP & COMPUTATIONAL #ODDS CONVENTION (BPR-13 DATED SUPERSESSION, 2026-12-02): "
"Historical IIP-0042 split-ship provenance is preserved intact — the frozen Core 3x2 OQ-016 baseline "
"(50.7782% locked / 54.1163% modular / 57.9176% ceiling) and shipped IIP-0035 5-arm W_U3 baseline "
"(60.6439% locked / 61.5921% modular / 66.4117% ceiling; informally ~62% shorthand) remain unchanged "
"(live_headline_delta_pp_today = +0.00 pp in this IIP-0042 split-ship receipt). "
"Superseding the obsolete earlier Gate 30 §4 publication prohibition, maintainer public-display policy "
"(AGENTS.md and TNFA-IFNG-INTRINSIC-APOPTOSIS-QUALIFICATION-NOTE.md §4) explicitly "
"permits publishing audited staged computational scenarios (e.g. 66.57% zero-drug / 67.21% optional-reset "
"computational modular scenarios) on openislet.org/blueprint#odds alongside the invariant underlying baselines "
"and explicit unmeasured-assumption caveats. Public display of a computational scenario does NOT activate "
"Track-B or alter gate eligibility: Track-B reset rows remain strictly inactive today (all 12 Track-B rows "
"per sensitivity carry option1_eligible=false, live_activated_today=false, and current_active_ev_pp=0.0 while "
"Gate 30-ATG-XREACT, Gate 30-SHIELD-SPR, and owner re-authorization remain pending: the 3 reset-alone "
"sensitivity rows carry scenario_activation_status=PENDING_SHIELD_DISPOSITION_AND_OWNER_REAUTH, while the "
"other 9 conditional Track-B rows carry scenario_activation_status=CONDITIONAL_SCENARIO_PENDING_XREACT_PASS_AND_OWNER_REAUTH); "
"the 4 ineligible full-cocktail-plus-reset diagnostic rows (option1_eligible=false, 0.0000 pp EV weight) "
"are segregated into ineligible_full_cocktail_diagnostics_zero_ev_weight; parked EXP-029 R3B scenarios "
"are strictly segregated into parked_counterfactual_r3b_sensitivity_exp029_gy027_block with R3B masked "
"in strict live-eligible totals (W_U3=57.5945%, W_U4=56.8730%). Zero hosted Tier-2 structure-prediction "
"numeric outputs are copied into this receipt (Gate 30-TOS-QUARANTINE)."
),
"h3_channel_abc_ceiling_budget": h3_channel_budget,
"parity_verification": parity,
"gate30_atg_xreact_decision_table_self_tests": xreact_self_tests,
"gate30_shield_spr_decision_table_self_tests": shield_spr_self_tests,
"published_trial_cohort_nct_mapping_audit": nct_mapping_audit,
"layer_0_core_3arm": l0,
"headline_live_eligible_scenarios_strict_no_r3b": {
"phi_0p25_central": sc_25["strict_rows"],
"phi_0p50_harsh_stress": sc_50["strict_rows"],
},
"ineligible_full_cocktail_diagnostics_zero_ev_weight": {
"scope_warning": (
"DIAGNOSTIC ONLY — INELIGIBLE UNDER LOCKED POLICY OPTION 1 (0.0000 pp EV WEIGHT): "
"When a full SHIELD cocktail succeeds, Track-B finite host reset is ineligible (option1_eligible=false) "
"and carries strictly 0.0000 pp Policy Option 1 EV weight. These 4 strict-route (zero-R3B) diagnostic "
"rows per phi_c are segregated out of headline_live_eligible_scenarios_strict_no_r3b and retained "
"solely for overlap-damping sensitivity and the legal 0.003 checkerboard fragility proof."
),
"phi_0p25_central": sc_25["ineligible_full_cocktail_diag_rows"],
"phi_0p50_harsh_stress": sc_50["ineligible_full_cocktail_diag_rows"],
},
"parked_counterfactual_r3b_sensitivity_exp029_gy027_block": {
"scope_warning": (
"PARKED COUNTERFACTUAL ONLY: EXP-029 (ROUTE_3B_ACTIVE_IEOG) is parked under active GY-027 BLOCK "
"with unregistered route status. Strict live-eligible totals mask R3B (W_U3=57.5945%, W_U4=56.8730%)."
),
"phi_0p25_central": sc_25["parked_r3b_rows"],
"phi_0p50_harsh_stress": sc_50["parked_r3b_rows"],
},
"omega_sweep_full_band": {
"strict_live_eligible_no_r3b": {"phi_0p25": sc_25["omega_sweep_strict"], "phi_0p50": sc_50["omega_sweep_strict"]},
"parked_counterfactual_r3b": {"phi_0p25": sc_25["omega_sweep_parked_r3b"], "phi_0p50": sc_50["omega_sweep_parked_r3b"]},
},
"checkerboard_mass_transfer_stress_test": {
"disclosure": (
"Scenario-specific adverse stress test on the ineligible full-cocktail comparison: a legal 0.003 "
"checkerboard mass transfer across 4 joint (m_cell, m_h4) cells involving only the 5th arm preserves "
"all hurdle marginals and the full 4,096-state incumbent projection while shifting locked success by "
"-0.3000 pp — flipping L4-AE slightly negative (-0.0569 pp vs L3B)."
),
"parked_r3b_L4_AE_phi25": sc_25["checkerboard_parked_l4_ae"],
"parked_r3b_L4_AE_phi50": sc_50["checkerboard_parked_l4_ae"],
"strict_L3B_ZeroDrug_AE_phi25": sc_25["checkerboard_strict_l3b_ae"],
"strict_L3B_ZeroDrug_AE_phi50": sc_50["checkerboard_strict_l3b_ae"],
},
"strategic_finite_reset_overlap_analysis": {
"computation_precision": "computed_from_unrounded_exact_probabilities_before_4dp_display_rounding",
"phi_0p25": d25_all["rounded_4dp"],
"phi_0p50": d50_all["rounded_4dp"],
},
"policy_option1_trackb_eligibility_corrected_ev": {
"eligibility_rule": CANONICAL_TRACKB_ELIGIBILITY_RULE,
"current_gate_state": {
"gate30_atg_xreact": "PENDING",
"gate30_shield_spr": "PENDING",
"owner_reauthorization": "PENDING_NOT_GRANTED",
},
"current_p_owner_reauth": 0.0,
"current_p_hold_or_pending": 1.0,
"current_active_ev_pp": 0.0,
"scenario_ev_classification": "CONDITIONAL_SCENARIO_GIVEN_OWNER_REAUTH_AND_NO_HOLD",
"joint_hold_and_owner_reauth_sensitivity": joint_hold_and_owner_reauth_sensitivity,
"strict_live_eligible_zero_sort_guard_primary": ev_strict_zero_sort_guard,
"strict_live_eligible_with_sort_guard_sensitivity": ev_strict_with_sort_guard_sens,
"legacy_parked_r3b_comparator_eligibility_audit": ev_legacy_r3b_eligibility_audit,
},
"honest_stage0_foundry_unconditional_ev": honest_stage0_foundry,
"bpr05_cross_stage_dependence_sensitivity": {
"audit_id": "BPR-05",
"method": (
"Exact LP bounds over permissible joint couplings of earlier survivors (M_cell = H1&H2&H3) and "
"final-route successes (M_h4 = H4) conditioned on stage-level shared ceilings passing, holding "
"published stage distributions, shared ceilings, and all individual full-path arm successes fixed "
"(plus full 4-stage 3-incumbent joint history in 5-arm scenarios)."
),
"L0_CORE_3ARM": bpr05_l0_core,
"L3B_STACK_STRICT_100PCT_ZERO_DRUG_phi_0p25": sc_25["bpr05_5arm_sensitivities"]["L3B_STACK_STRICT_100PCT_ZERO_DRUG"],
"L3A_STRICT_ZERODRUG_PLUS_RESET_OMEGA_0P60_phi_0p25": sc_25["bpr05_5arm_sensitivities"]["L3A_STRICT_ZERODRUG_PLUS_RESET_OMEGA_0P60"],
},
}
receipt["portable_payload_sha256"] = compute_portable_payload_sha256(receipt)
return receipt
def build_portable_receipt_payload(receipt: dict[str, Any]) -> dict[str, Any]:
"""Return a cross-build semantic projection of the IIP-0042 receipt omitting ONLY
runtime_environment.python_version (the CPython build banner/date string) and
portable_payload_sha256 itself, while retaining python_version_info and every numeric,
parity, self-test, and quarantine field verbatim.
"""
proj = dict(receipt)
proj.pop("portable_payload_sha256", None)
if isinstance(proj.get("runtime_environment"), dict):
rt = dict(proj["runtime_environment"])
rt.pop("python_version", None)
proj["runtime_environment"] = rt
return proj
def compute_portable_payload_sha256(receipt: dict[str, Any]) -> str:
proj = build_portable_receipt_payload(receipt)
raw = json.dumps(proj, sort_keys=True, ensure_ascii=False, separators=(",", ":"), allow_nan=False).encode("utf-8")
return hashlib.sha256(raw).hexdigest()
def verify_portable_receipt_file(existing_path: Path, fresh_receipt: dict[str, Any]) -> str:
"""Fail-closed cross-build receipt check ignoring ONLY runtime_environment.python_version."""
if not existing_path.is_file():
raise FileNotFoundError(
f"--check-portable failed (fail-closed): expected receipt missing: {existing_path.name}"
)
existing_receipt = load_strict_json_text(existing_path.read_text(encoding="utf-8"), existing_path.name)
if not isinstance(existing_receipt, dict) or not isinstance(existing_receipt.get("runtime_environment"), dict):
raise RuntimeError(
f"--check-portable failed (fail-closed): malformed receipt structure in {existing_path.name}"
)
existing_pyver = existing_receipt["runtime_environment"].get("python_version")
if not isinstance(existing_pyver, str) or not existing_pyver.strip():
raise RuntimeError(
f"--check-portable failed (fail-closed): missing/non-string runtime_environment.python_version in {existing_path.name}"
)
existing_portable_sha = compute_portable_payload_sha256(existing_receipt)
fresh_portable_sha = compute_portable_payload_sha256(fresh_receipt)
if (
build_portable_receipt_payload(existing_receipt) != build_portable_receipt_payload(fresh_receipt)
or existing_portable_sha != fresh_portable_sha
):
raise RuntimeError(
f"--check-portable failed (fail-closed): semantic receipt mismatch outside "
f"runtime_environment.python_version for {existing_path.name} "
f"(existing_portable_sha={existing_portable_sha}, fresh_portable_sha={fresh_portable_sha})"
)
if "portable_payload_sha256" in existing_receipt and existing_receipt["portable_payload_sha256"] != fresh_portable_sha:
raise RuntimeError(
f"--check-portable failed (fail-closed): embedded portable_payload_sha256 mismatch in {existing_path.name} "