f"Master contract self-hash tamper detected: embedded={embedded_contract_sha} != recomputed={recomputed_contract_sha}", ) if manifest_path is None: rel = mc.get("canonical_arm_manifest_relpath") _require( isinstance(rel, str) and bool(rel.strip()) and not Path(rel).is_absolute(), f"Master contract missing valid relative canonical_arm_manifest_relpath: {rel!r}", ) rel_p = Path(rel) _require(".." not in rel_p.parts, f"Disallowed parent traversal in canonical_arm_manifest_relpath: {rel!r}") manifest_path = (contract_path.parent / rel_p).resolve() if not manifest_path.is_file(): raise FileNotFoundError( f"Fail-closed: release-relative canonical arm manifest missing beside {contract_path.name}: {manifest_path.name}" ) manifest_bytes = manifest_path.read_bytes() actual_manifest_sha = sha256_bytes(manifest_bytes) _require( actual_manifest_sha == mc.get("canonical_arm_manifest_sha256"), f"Manifest SHA-256 mismatch vs contract: file={actual_manifest_sha} != contract={mc.get('canonical_arm_manifest_sha256')}", ) _require( actual_manifest_sha == EXPECTED_CANONICAL_MANIFEST_SHA256, f"Manifest SHA-256 mismatch vs pinned digest: {actual_manifest_sha} != {EXPECTED_CANONICAL_MANIFEST_SHA256}", ) manifest = load_strict_json_text(manifest_bytes.decode("utf-8"), manifest_path.name) _require(isinstance(manifest, dict) and isinstance(manifest.get("arms"), dict), "Malformed canonical arm manifest") actual_manifest_canon_sha = compute_canonical_manifest_sha256(manifest) _require( actual_manifest_canon_sha == EXPECTED_CANONICAL_MANIFEST_CANON_SHA256, f"Manifest canonical-JSON SHA-256 mismatch: {actual_manifest_canon_sha} != {EXPECTED_CANONICAL_MANIFEST_CANON_SHA256}", ) return mc, manifest, recomputed_contract_sha, actual_manifest_sha, contract_file_sha def run_master_wave6_crosswalk( ext_contract: Mapping[str, Any], ext_manifest: Mapping[str, Any], ext_contract_sha: str, ext_manifest_sha: str, ext_contract_file_sha: str, ) -> dict[str, Any]: l0 = eval_core_3arm_l0() l1_arms = [(0.88, 0.78, 0.57, 0.69), (0.88, 0.79, 0.64, 0.70), (0.88, 0.82, 0.73, 0.69), (0.88, 0.84, 0.80, 0.72), (0.62, 0.92, 0.70, 0.70)] w5_arms = [(0.90, 0.78, 0.68, 0.745), (0.90, 0.79, 0.73, 0.775), (0.90, 0.82, 0.83, 0.745), (0.90, 0.84, 0.84, 0.735), (0.66, 0.92, 0.755, 0.715)] base_r = ("R1", "R2", "R1", "R3P", "R3P") base_c = ("INC", "INC", "INC", "STAGED_BASE", "STAGED_BASE") base_m = {"INC": frozenset({"R1", "R2"}), "STAGED_BASE": frozenset({"R3P"})} b_l1_shipped = eval_post_rt_scenario("L1_shipped_IIP0035_phi0", l1_arms, routes=base_r, cell_classes=base_c, compat_map=base_m, phi_inc=0.0) b_w5 = eval_post_rt_scenario("Wave5_L3B_audited_caveated", w5_arms, c1_allo=0.90, c3_base=0.925, routes=base_r, cell_classes=base_c, compat_map=base_m, phi_inc=0.0) b_honest = eval_wave6_unified_state("L1_honest_monoculture_phi_inc_0.50", c1_pass=False, c2_pass=False, c3_level="none", c4_pass=False, compute_strassen=True) # Reachable prerequisite-enforced scenarios r_c1 = eval_wave6_unified_state("W6_C1_standalone_over_honest_L1", c1_pass=True, c2_pass=False, c3_level="none", c4_pass=False, compute_strassen=True) r_c2_c1 = eval_wave6_unified_state("W6_C2_plus_C1_R4Omentum_zeroRest", c1_pass=True, c2_pass=True, c3_level="none", c4_pass=False, compute_strassen=True) r_c3_noinv = eval_wave6_unified_state("W6_C3_noinv_standalone_A_frozen", c1_pass=False, c2_pass=False, c3_level="partial", c4_pass=False, compute_strassen=True) r_c3_full = eval_wave6_unified_state("W6_C3_full_standalone_A_frozen", c1_pass=False, c2_pass=False, c3_level="full", c4_pass=False, compute_strassen=True) r_c4_c1 = eval_wave6_unified_state("W6_C4_plus_C1_ArmZ_EnSC_R3P", c1_pass=True, c2_pass=False, c3_level="none", c4_pass=True, compute_strassen=True) p_5_cons = eval_wave6_unified_state("Wave6_5Arm_Conservative_NoInvVax", c1_pass=True, c2_pass=True, c3_level="partial", c4_pass=False, c4_univ_on_r4=0.945, c4_r4_cap=0.860, phi_r4=0.35, compute_strassen=True, compute_h23_lp=True) p_5_cent = eval_wave6_unified_state("Wave6_5Arm_Central_H1_88_LOCKED", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=False, c4_univ_on_r4=0.950, c4_r4_cap=0.870, phi_r4=0.30, compute_strassen=True, compute_h23_lp=True) p_6_cons = eval_wave6_unified_state("Wave6_6Arm_Conservative_NoInvVax", c1_pass=True, c2_pass=True, c3_level="partial", c4_pass=True, c4_univ_on_r4=0.945, c4_r4_cap=0.860, phi_r4=0.35, compute_strassen=True, compute_h23_lp=True) p_6_cent = eval_wave6_unified_state("Wave6_6Arm_Central_EnSC_H1_88_LOCKED", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=True, c4_univ_on_r4=0.950, c4_r4_cap=0.870, phi_r4=0.30, compute_strassen=True, compute_h23_lp=True) p_6_stress = eval_wave6_unified_state("Wave6_6Arm_Selected_Harsh_Stress_phi050_NoInvVax", c1_pass=True, c2_pass=True, c3_level="partial", c4_pass=True, c1_univ_z=0.920, c1_z=0.82, phi_z_h1=0.65, phi_z_h2=0.85, phi_z_h3=0.85, c4_univ_on_r4=0.940, c4_r4_cap=0.850, phi_r4=0.50, phi_c=0.50, phi_inc_override=0.50, compute_strassen=True) # Segregated prerequisite-waived diagnostic counterfactuals (0% released-state weight!) d_c2_isol = eval_wave6_unified_state("Diag_PrereqWaived_C2_isolated_zeroRest", c1_pass=False, c2_pass=True, c3_level="none", c4_pass=False, enforce_prerequisites=False, compute_strassen=True) d_c2_c4univ92 = eval_wave6_unified_state("Diag_PrereqWaived_C2_c4univ_held_0.92_site_only", c1_pass=False, c2_pass=True, c3_level="none", c4_pass=False, enforce_prerequisites=False, c4_univ_on_r4=0.920, compute_strassen=True) d_c2_rest_5arm = eval_wave6_unified_state("Diag_PrereqWaived_C2_prospective_rest_1p5pp_all_eligible_BXYD", c1_pass=False, c2_pass=True, c3_level="none", c4_pass=False, enforce_prerequisites=False, dh4_exvivo=0.015, compute_strassen=True) d_c4_isol = eval_wave6_unified_state("Diag_PrereqWaived_C4_isolated_EnSC_R3P", c1_pass=False, c2_pass=False, c3_level="none", c4_pass=True, enforce_prerequisites=False, compute_strassen=True) # Mandatory audit sensitivities (exact changed parameters disclosed!) sens_phi50_c1 = eval_wave6_unified_state("Sens_C1_marginals_only_at_phi_inc_0.50", c1_pass=True, c2_pass=False, c3_level="none", c4_pass=False, phi_inc_override=0.50) sens_phi75_c1 = eval_wave6_unified_state("Sens_C1_marginals_only_at_phi_inc_0.75", c1_pass=True, c2_pass=False, c3_level="none", c4_pass=False, phi_inc_override=0.75) sens_c3_const_cap = eval_wave6_unified_state("Sens_C3_full_c3cap_held_0.89", c1_pass=False, c2_pass=False, c3_level="full", c4_pass=False, c3_cap_override=0.890) sens_phi50_6arm = eval_wave6_unified_state("Sens_6Arm_Central_at_phi_inc_0.50", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=True, phi_inc_override=0.50) sens_c4univ92_6arm = eval_wave6_unified_state("Sens_6Arm_Central_c4univ_held_0.92", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=True, c4_univ_on_r4=0.920) sens_c3_89_6arm = eval_wave6_unified_state("Sens_6Arm_Central_c3_held_0.89", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=True, c3_cap_override=0.890) sens_z_nested_h1 = eval_wave6_unified_state("Sens_6Arm_Central_Z_fully_nested_H1", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=True, c1_univ_z=0.88, phi_z_h1=1.0) sens_fwd90_1param = eval_wave6_unified_state("Sens_6Arm_TrueSingleParam_c1_allo_90_c1univ_925_incl_A_H1", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=True, c1_allo=0.90, c1_univ_z=0.925) sens_fwd90_2param = eval_wave6_unified_state("Sens_6Arm_TwoParam_c1_allo_90_and_c1univ_940_incl_A_H1", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=True, c1_allo=0.90, c1_univ_z=0.940) sens_6arm_rest_all5 = eval_wave6_unified_state("Sens_6Arm_Central_Prospective_Rest_1p5pp_AllEligible_BXYDZ", c1_pass=True, c2_pass=True, c3_level="full", c4_pass=True, dh4_exvivo=0.015) # Wave-7 Horizon Benchmark (Design A strictly frozen, 0.000 ex-vivo rest; 0.00 pp Wave-6 credit) w7_arms = [ (0.88, 0.78, 0.57, 0.69), (0.88, 0.80, 0.73, 0.70), (0.88, 0.83, 0.80, 0.69), (0.88, 0.85, 0.85, 0.72), (0.78, 0.92, 0.78, 0.80), (0.86, 0.84, 0.84, 0.81), ] w7_horizon = eval_post_rt_scenario( "Wave7_Horizon_TrueNonPSC_XenoOrGINS_H1_88", w7_arms, c1_allo=0.88, c1_univ=0.955, c1_z=0.86, phi_z_h1=0.30, phi_z_h2=0.45, c3_base=0.942, c3_univ=0.955, c3_z=0.88, phi_z_h3=0.40, c4_univ=0.955, c4_r4=0.88, phi_r4=0.25, phi_inc=0.25, routes=("R1", "R2", "R1", "R3P", "R4", "R4"), cell_classes=("INC", "INC", "INC", "STAGED_HARDENED", "STAGED_HARDENED", "Z_HARDENED"), compat_map={"INC": frozenset({"R1", "R2"}), "STAGED_HARDENED": frozenset({"R3P", "R4"}), "Z_HARDENED": frozenset({"R3P", "R4"})}, compute_strassen=True, compute_h23_lp=True, ) # 24-State Prerequisite-Enforced Released-Product Scenario Average + Exact Marginal-Weight LP Bounds! ev_regimes = { "Conservative": {"p_c1": 0.35, "p_c2": 0.35, "p_c3": (0.60, 0.30, 0.10), "p_c4": 0.25}, "Central": {"p_c1": 0.50, "p_c2": 0.50, "p_c3": (0.45, 0.415, 0.135), "p_c4": 0.40}, "Upper": {"p_c1": 0.65, "p_c2": 0.65, "p_c3": (0.35, 0.48, 0.17), "p_c4": 0.55}, } states_24: dict[str, dict[str, Any]] = {} state_keys: list[tuple[int, int, str, int]] = [] state_objs: dict[tuple[int, int, str, int], dict[str, Any]] = {} for f_c1 in (0, 1): for f_c2 in (0, 1): for f_c3 in ("none", "partial", "full"): for f_c4 in (0, 1): key_t = (f_c1, f_c2, f_c3, f_c4) key_s = f"c1={f_c1}|c2={f_c2}|c3={f_c3}|c4={f_c4}" res = eval_wave6_unified_state( key_s, c1_pass=bool(f_c1), c2_pass=bool(f_c2), c3_level=f_c3, c4_pass=bool(f_c4), enforce_prerequisites=True, compute_strassen=False, ) state_keys.append(key_t) state_objs[key_t] = res states_24[key_s] = { "r4_active": bool(f_c1 and f_c2), "z_active": bool(f_c1 and f_c4), "locked_exact": res["locked_exact"], "modular_exact": res["modular_exact"], "ceiling_exact": res["ceiling_exact"], "locked_pct": res["locked_pct"], "modular_pct": res["modular_pct"], "ceiling_pct": res["ceiling_pct"], } # Exact <1e-12 unrounded parity between standalone rows & matching single-package EV states! _require(abs(state_objs[(0, 0, "none", 0)]["modular_exact"] - b_honest["modular_exact"]) < 1e-12, "EV baseline drift") _require(abs(state_objs[(1, 0, "none", 0)]["modular_exact"] - r_c1["modular_exact"]) < 1e-12, "EV C1 drift") _require(abs(state_objs[(0, 0, "partial", 0)]["modular_exact"] - r_c3_noinv["modular_exact"]) < 1e-12, "EV C3 partial drift") _require(abs(state_objs[(0, 0, "full", 0)]["modular_exact"] - r_c3_full["modular_exact"]) < 1e-12, "EV C3 full drift") _require(abs(state_objs[(1, 1, "none", 0)]["modular_exact"] - r_c2_c1["modular_exact"]) < 1e-12, "EV C1+C2 drift") _require(abs(state_objs[(1, 0, "none", 1)]["modular_exact"] - r_c4_c1["modular_exact"]) < 1e-12, "EV C1+C4 drift") _require(abs(state_objs[(1, 1, "full", 0)]["modular_exact"] - p_5_cent["modular_exact"]) < 1e-12, "EV 5-arm central drift") _require(abs(state_objs[(1, 1, "full", 1)]["modular_exact"] - p_6_cent["modular_exact"]) < 1e-12, "EV 6-arm central drift") mod_payoffs = [state_objs[k]["modular_exact"] for k in state_keys] ev_summary: dict[str, Any] = {} for rname, cfg in ev_regimes.items(): p_c1, p_c2, p_c3, p_c4 = cfg["p_c1"], cfg["p_c2"], cfg["p_c3"], cfg["p_c4"] p30, p31, p32 = p_c3 _require(abs((p30 + p31 + p32) - 1.0) < 1e-12, f"Bad p_c3 sum for {rname}") _require(0.10 <= p32 <= 0.17, f"InvVax prior {p32} outside C3 10%-17% window") p3_map = {"none": p30, "partial": p31, "full": p32} ev_l = ev_m = ev_c = w_tot = 0.0 for (f_c1, f_c2, f_c3, f_c4), res in state_objs.items(): w = (p_c1 if f_c1 else 1.0 - p_c1) * (p_c2 if f_c2 else 1.0 - p_c2) * p3_map[f_c3] * (p_c4 if f_c4 else 1.0 - p_c4) w_tot += w ev_l += w * res["locked_exact"] ev_m += w * res["modular_exact"] ev_c += w * res["ceiling_exact"] _require(abs(w_tot - 1.0) < 1e-12, f"EV weights sum={w_tot}") lp_lo, lp_hi = solve_24state_weight_lp_bounds(state_keys, mod_payoffs, p_c1, p_c2, p_c3, p_c4) _require(lp_lo <= ev_m + 1e-9 and ev_m <= lp_hi + 1e-9, f"24-state LP sanity fail: [{lp_lo}, {lp_hi}] vs {ev_m}") ev_summary[rname] = { "priors": {"p_c1": p_c1, "p_c2": p_c2, "p_c3_none_partial_full": [p30, p31, p32], "p_c4": p_c4}, "all_pass_weight_exact_pct": p_c1 * p_c2 * p32 * p_c4 * 100.0, "all_pass_weight_pct": round(p_c1 * p_c2 * p32 * p_c4 * 100.0, 4), "locked_exact": ev_l, "modular_exact": ev_m, "ceiling_exact": ev_c, "locked_pct": round(ev_l, 4), "modular_pct": round(ev_m, 4), "ceiling_pct": round(ev_c, 4), "delta_vs_honest_l1_exact_pp": ev_m - b_honest["modular_exact"], "delta_vs_shipped_l1_exact_pp": ev_m - b_l1_shipped["modular_exact"], "delta_vs_honest_l1_pct_pp": round(ev_m - b_honest["modular_exact"], 4), "delta_vs_shipped_l1_pct_pp": round(ev_m - b_l1_shipped["modular_exact"], 4), "fixed_marginal_arbitrary_package_dependence_lp_exact_pct": [lp_lo, lp_hi], "fixed_marginal_arbitrary_package_dependence_lp_pct": [round(lp_lo, 4), round(lp_hi, 4)], } h_ref = b_honest["modular_exact"] computed_reachable = { "L0_core_3arm": _pack_scenario(l0), "L1_shipped_IIP0035_phi0": _pack_scenario(b_l1_shipped), "Wave5_L3B_audited_caveated": _pack_scenario(b_w5), "L1_honest_monoculture_phi_inc_0.50": _pack_scenario(b_honest), "W6_C1_standalone_over_honest_L1": _pack_scenario(r_c1, ref_honest=h_ref), "W6_C2_plus_C1_R4Omentum_zeroRest": _pack_scenario(r_c2_c1, ref_honest=h_ref), "W6_C3_noinv_standalone_A_frozen": _pack_scenario(r_c3_noinv, ref_honest=h_ref), "W6_C3_full_standalone_A_frozen": _pack_scenario(r_c3_full, ref_honest=h_ref), "W6_C4_plus_C1_ArmZ_EnSC_R3P": _pack_scenario(r_c4_c1, ref_honest=h_ref), "Wave6_5Arm_Conservative_NoInvVax": _pack_scenario(p_5_cons, ref_honest=h_ref), "Wave6_5Arm_Central_H1_88_LOCKED": _pack_scenario(p_5_cent, ref_honest=h_ref), "Wave6_6Arm_Conservative_NoInvVax": _pack_scenario(p_6_cons, ref_honest=h_ref), "Wave6_6Arm_Central_EnSC_H1_88_LOCKED": _pack_scenario(p_6_cent, ref_honest=h_ref), "Wave6_6Arm_Selected_Harsh_Stress_phi050_NoInvVax": _pack_scenario(p_6_stress, ref_honest=h_ref), } computed_diag_waived: dict[str, Any] = { "scope_warning": "Explicitly disables C1 prerequisites for marginal isolation; carries 0.0% released-state weight.", "Diag_PrereqWaived_C2_isolated_zeroRest": _pack_scenario(d_c2_isol, ref_honest=h_ref), "Diag_PrereqWaived_C2_c4univ_held_0.92_site_only": _pack_scenario(d_c2_c4univ92, ref_honest=h_ref), "Diag_PrereqWaived_C2_prospective_rest_1p5pp_all_eligible_BXYD": _pack_scenario(d_c2_rest_5arm, ref_honest=h_ref), "Diag_PrereqWaived_C4_isolated_EnSC_R3P": _pack_scenario(d_c4_isol, ref_honest=h_ref), } computed_sensitivities = { "Sens_C1_marginals_only_at_phi_inc_0.50": _pack_scenario(sens_phi50_c1, ref_honest=h_ref), "Sens_C1_marginals_only_at_phi_inc_0.75": _pack_scenario(sens_phi75_c1, ref_honest=h_ref), "Sens_C3_full_c3cap_held_0.89": _pack_scenario(sens_c3_const_cap, ref_honest=h_ref), "Sens_6Arm_Central_at_phi_inc_0.50": _pack_scenario(sens_phi50_6arm, ref_honest=h_ref), "Sens_6Arm_Central_c4univ_held_0.92": _pack_scenario(sens_c4univ92_6arm, ref_honest=h_ref), "Sens_6Arm_Central_c3_held_0.89": _pack_scenario(sens_c3_89_6arm, ref_honest=h_ref), "Sens_6Arm_Central_Z_fully_nested_H1": _pack_scenario(sens_z_nested_h1, ref_honest=h_ref), "Sens_6Arm_TrueSingleParam_c1_allo_90_c1univ_925_incl_A_H1": _pack_scenario(sens_fwd90_1param, ref_honest=h_ref), "Sens_6Arm_TwoParam_c1_allo_90_and_c1univ_940_incl_A_H1": _pack_scenario(sens_fwd90_2param, ref_honest=h_ref), "Sens_6Arm_Central_Prospective_Rest_1p5pp_AllEligible_BXYDZ": _pack_scenario(sens_6arm_rest_all5, ref_honest=h_ref), } # STRICT FAIL-CLOSED EXTERNAL CONTRACT VERIFICATION (all 21 invariants + unrounded <1e-12 & 4-dec display parity!) expected_invariants = { "h1_allo_locked_pct": 88.0, "design_a_zero_post_transplant_drugs_and_exvivo_rest": True, "design_a_zero_additional_biologics_beyond_v080_catalase_hydrogel": True, "design_a_contains_preexisting_p04040_catalase_hydrogel": True, "design_a_strictly_zero_protein_biologics": False, "design_a_preexisting_catalase_hydrogel_exception_disclosed": True, "design_a_invariant_tuple": [0.88, 0.78, 0.57, 0.69], "zero_chronic_systemic_immunosuppression": True, "zero_fabricated_or_rng_dna": True, "zero_live_repo_edits_during_draft_build": True, "gy_027_1_enforced_unhardened_abx_not_on_r4": True, "gy_027_1_home_route_locked_and_modular_enforced": True, "gy_014_enforced_no_invivo_72h_diazoxide_credit": True, "exvivo_rest_primary_h4_credit_pp": 0.0, "gy_021_enforced_pe2max_only_no_pe4max_mlh1dn": True, "gy_024_enforced_ensc_terminal_pan_alk5i_free": True, "gy_026_txnip_ko_removal_status": "PENDING_ATOMIC_FOLDIN_MIGRATION", "gy_030_5_lineage_whole_graft_required_all_arms": True, "c1_prerequisite_enforced_for_r4_and_z_in_24state_ev": True, "invvax_stage0_prior_bounded_10_to_17_pct": True,