scripts/rank_islet1_stacks.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/rank_islet1_stacks.py · SHA-256: c05d5fe606219e88…
for k in range(16):
d[k] += c_arm_y * r * d_both[k]
d[0] += c_arm_y * (1.0 - r) * (1.0 - u_y)
d[8] += c_arm_y * (1.0 - r) * u_y
return d
d2 = _nested_h([pa[1], pb[1], px[1]], 0.87, p_y[1], c2_y)
d3 = _nested_h([pa[2], pb[2], px[2]], 0.89, p_y[2], c3_y)
v_h123 = [0.0] * 16
v_h123[15] = 1.0
for dist in (d1, d2, d3):
vn = [0.0] * 16
for s, vs in enumerate(v_h123):
if vs == 0.0:
continue
for m, w in enumerate(dist):
if w == 0.0:
continue
vn[s & m] += vs * w
v_h123 = vn
d4_inc = _live_incumbent_h4_cond_iip0034()
biv4 = _bivariate_bernoulli_iip0034(0.85 / c4_univ, c4_r3 / c4_univ, phi_h4)
u_y4 = p_y[3] / c4_r3
d4 = [0.0] * 16
d4[0] += 1.0 - c4_univ
for (s0, s1), wp in biv4.items():
w = c4_univ * wp
if s0 == 0 and s1 == 0:
d4[0] += w
elif s0 == 1 and s1 == 0:
for mi in range(8):
d4[mi] += w * d4_inc[mi]
elif s0 == 0 and s1 == 1:
d4[0] += w * (1.0 - u_y4)
d4[8] += w * u_y4
else:
for mi in range(8):
d4[mi] += w * d4_inc[mi] * (1.0 - u_y4)
d4[mi | 8] += w * d4_inc[mi] * u_y4
locked_ind = 0.0
locked_adv = 0.0
for mi in range(8):
p_mi = d4[mi] + d4[mi | 8]
if p_mi == 0.0:
continue
q_y4 = d4[mi | 8] / p_mi
p_inc_win = sum(v_h123[s] for s in range(16) if (s & mi) != 0)
p_y_rescue = sum(v_h123[s] for s in range(16) if (s & mi) == 0 and (s & 8) != 0)
locked_ind += p_mi * (p_inc_win + p_y_rescue * q_y4)
locked_adv += p_mi * (p_inc_win + max(0.0, p_y_rescue + q_y4 - 1.0))
locked_mix = (1.0 - adverse_mix_weight) * locked_ind + adverse_mix_weight * locked_adv
w_break = (locked_ind - c0) / (locked_ind - locked_adv) if (locked_ind > c0 and locked_ind > locked_adv) else 0.0
return {
"scenario": label,
"adverse_cross_hurdle_mix_weight": adverse_mix_weight,
"independent_hurdles_locked_pct": round(100.0 * locked_ind, 4),
"maximally_adverse_overlap_locked_pct": round(100.0 * locked_adv, 4),
"negative_cross_hurdle_locked_pct": round(100.0 * locked_mix, 4),
"adverse_mix_weight_erasing_gain_pct": round(100.0 * w_break, 3),
"clears_57p92_locked": bool(locked_mix > c0),
}
cross_hurdle_negative_coupling_sensitivity = [
_eval_4arm_negative_cross_hurdle_sensitivity(
"W_B3_10PCT_ADVERSE_CROSS_HURDLE_COUPLING_BELOW_57p92",
(0.88, 0.84, 0.80, 0.75),
c2_y=0.87, c3_y=0.89, phi_yx=0.75, c4_univ=0.92, c4_r3=0.87, phi_h4=0.25, adverse_mix_weight=0.10,
),
_eval_4arm_negative_cross_hurdle_sensitivity(
"W_B9_10PCT_ADVERSE_CROSS_HURDLE_COUPLING_BELOW_57p92",
(0.88, 0.84, 0.80, 0.68),
c2_y=0.90, c3_y=0.92, phi_yx=1.00, c4_univ=0.90, c4_r3=0.85, phi_h4=0.50, adverse_mix_weight=0.10,
),
]
bridge_5arm = [
_eval_5arm(lbl, py, pd1, c2_y=c2y, c3_y=c3y, phi_c=phi_c, d1_on_r3=d1_r3, c4_univ=c4u, c4_r3=c4r3, stage0_status="STAGE0_GATED_FORWARD_COMPATIBILITY_BRIDGE_5ARM")
for lbl, py, pd1, c2y, c3y, phi_c, d1_r3, c4u, c4r3 in [
("W_BC1_5Arm_ZeroH3Lift_Y@3P_D1(p1=0.70)@3P_c4u0.92_phi=0.25", (0.88, 0.84, 0.80, 0.72), (0.70, 0.92, 0.70, 0.70), 0.87, 0.89, 0.25, True, 0.92, 0.85),
("W_BC2_5Arm_ZeroH3Lift_Y@3P_D1(p1=0.70)@3P_c4u0.92_phi=0.50", (0.88, 0.84, 0.80, 0.72), (0.70, 0.92, 0.70, 0.70), 0.87, 0.89, 0.50, True, 0.92, 0.85),
("W_BC3_5Arm_EXTREME_HOSTILE_ZeroH3Lift_Y@3P(0.68)_D1(0.55,0.60)@R2", (0.88, 0.84, 0.80, 0.68), (0.55, 0.90, 0.60, 0.70), 0.87, 0.89, 0.50, False, 0.90, 0.85),
("W_BC4_5Arm_NestedY(90/92)_Y@Hyb3P_D1(p1=0.70)@3P_c4u0.92_phi=0.25", (0.88, 0.84, 0.80, 0.75), (0.70, 0.92, 0.70, 0.70), 0.90, 0.92, 0.25, True, 0.92, 0.87),
("W_BC5_5Arm_NestedY(90/92)_Y@Hyb3P_D1(p1=0.70)@3P_c4u0.92_phi=0.50", (0.88, 0.84, 0.80, 0.75), (0.70, 0.92, 0.70, 0.70), 0.90, 0.92, 0.50, True, 0.92, 0.87),
]
]
return {
"schema_version": "openislet_multiparadigm_portfolio_v0.8.0",
"proposal_id": "IIP-0034",
"decision_id": "DEC-113",
"license": "CC-BY-4.0",
"epistemic_status": "COMPUTATIONAL_SCENARIO_EVALUATOR_STAGE0_PROMOTION_PENDING",
"live_headline_delta_pp_today": 0.0,
"modular_compatibility_matrix": {
k: sorted(v) for k, v in sorted(ALLOWED_CELL_ROUTE_PAIRS_IIP0034.items())
},
"w_b0_modular_permissions_note": (
"In hypothetical counterfactual W_B0, the 4th cell is assigned R2 on the locked diagonal and permitted "
"{'R1', 'R2'} in the modular branch (giving 55.1161% K=100 modular; restricting W_B0 strictly to {'R2'} "
"lowers modular K=100 to 54.9679%). W_B0 is an unregistered hypothetical counterfactual outside Design Y v2."
),
"five_arm_bridge_registration_status": {
"DESIGN_Y_FULLSTACK_V2": "REGISTERED_AND_FASTA_VERIFIED_IN_IIP0034_MODE_B_NON_EXECUTABLE_ROUTE_3P_ONLY",
"D1B_AUTO_C_V2": "UNREGISTERED_STAGE0_FORWARD_BRIDGE_PLACEHOLDER_NO_IIP0034_PRODUCT_OR_FASTA",
"note": (
"Registry and FASTA verification in IIP-0034 covers the six staged Design Y-FullStack v2 records; "
"D1B_AUTO_C_V2 in stage0_gated_5arm_unified_bridge is an unregistered Stage-0-gated forward "
"compatibility placeholder with no exact product definition or FASTA staged in IIP-0034."
),
},
"caveat": (
"Live OQ-016 3x2 headline odds (50.778198% locked / 54.116275% modular K=100 / 57.917640% conditional shared-hurdle "
"model ceiling — NOT an established biological ceiling) and all 2,160 Layer-1 combinatorial stacks remain strictly "
"unchanged (+0.00 pp today). All 20 ordinary scenarios + 2 phi_H4/marginal counterexamples + 2 adverse-coupling "
"outputs enforce 4,096-state incumbent joint probability parity (max |delta| <= 1e-12), bind registered "
"DESIGN_Y_FULLSTACK_V2 strictly to {'R3P'} matching product_contract.py, exclude prohibited A/B/X + Route 3P mass "
"on both locked and modular paths, and note that Fréchet mixture weights phi are unmeasured modeling parameters "
"unidentified by short Stage-0 assays: W_B9 crosses exact 57.917640% near phi_H4 = 0.5136 (57.7545% at 0.60), "
"equalizing Y's H2/H3 marginals to X drops W_B3 to 56.8286%, and ~2.72%/0.365% adverse cross-hurdle mixture weight "
"erases W_B3/W_B9 gain (10% drops them to 57.4151%/57.2375%)."
),
"live_3x2_baseline_invariant": {
"arms": {"A": list(pa), "B": list(pb), "X": list(px)},
"shared_ceilings": list(c_base),
"locked_pct": round(100.0 * p0_l, 6),
"modular_k100_pct": round(100.0 * p0_m, 6),
"modular_k90_pct": round(100.0 * (0.90 * p0_m + 0.10 * p0_l), 6),
"shared_ceiling_pct": round(100.0 * c0, 6),
"residual_risk_reduction_locked_bar_pct": round(ql_bar, 4),
"residual_risk_reduction_mod_bar_pct": round(qm_bar, 4),
},
"conservative_zero_h2_h3_lift_4x3_architectural": zero_lift_4arm,
"stage0_gated_conditional_4x3_off_the_shelf": conditional_4arm,
"phi_h4_sensitivity_counterexamples": phi_h4_sensitivity_counterexamples,
"cross_hurdle_negative_coupling_sensitivity": cross_hurdle_negative_coupling_sensitivity,
"stage0_gated_5arm_unified_bridge": bridge_5arm,
}
# =============================================================================
# IIP-0035 (DEC-114): Compatibility-Constrained Wave C 4-Arm Autologous
# D1b-Auto-C v2 & Unified 5-Arm Portfolio Artifact
# (Emits data/extracted/islet1_5arm_autologous_portfolio_v0.8.0.json while
# keeping islet1_multiparadigm_portfolio_v0.8.0.json 100% byte-for-bit UNCHANGED!)
# =============================================================================
_ACTIVE_LAW_COLLECTOR_IIP0035: contextvars.ContextVar[dict[str, dict] | None] = contextvars.ContextVar(
"_ACTIVE_LAW_COLLECTOR_IIP0035",
default=None,
)
def _eval_4arm_d1auto_iip0035(
label: str,
p_d1: tuple[float, float, float, float],
*,
pa: tuple[float, float, float, float],
pb: tuple[float, float, float, float],
px: tuple[float, float, float, float],
c2_univ: float,
c2_auto: float,
c3_shared: float,
h4_mode: str,
c4_univ: float,
c4_r3: float,
phi_cross: float,
p0_l: float,
p0_m: float,
c0: float,
stage0_status: str,
fourth_arm_cell_class: str = "D1B_AUTO_C_V2",
) -> dict:
u_d1 = p_d1[0] / 0.88
d1 = [0.0] * 16
d1[0] = 0.12
d1[7] = 0.88 * (1.0 - u_d1)
d1[15] = 0.88 * u_d1
d2_inc = _frechet_bernoulli_joint_iip0034([pa[1] / 0.87, pb[1] / 0.87, px[1] / 0.87], 0.0)
biv2 = _bivariate_bernoulli_iip0034(0.87 / c2_univ, c2_auto / c2_univ, phi_cross)
if p_d1[1] > c2_auto + 1e-12:
raise ValueError(f"Autologous H2 probability {p_d1[1]} exceeds ceiling c2_auto={c2_auto} in {label}")
u_d2 = p_d1[1] / c2_auto
d2 = [0.0] * 16
d2[0] += 1.0 - c2_univ
for (s0, s1), wp in biv2.items():
w = c2_univ * wp
if s0 == 0 and s1 == 0:
d2[0] += w
elif s0 == 1 and s1 == 0:
for mi in range(8):
d2[mi] += w * d2_inc[mi]
elif s0 == 0 and s1 == 1:
d2[0] += w * (1.0 - u_d2)
d2[8] += w * u_d2
else:
for mi in range(8):
d2[mi] += w * d2_inc[mi] * (1.0 - u_d2)
d2[mi | 8] += w * d2_inc[mi] * u_d2
c2_e = c2_univ * (1.0 - biv2[(0, 0)])
d3_inc = _frechet_bernoulli_joint_iip0034([pa[2] / c3_shared, pb[2] / c3_shared, px[2] / c3_shared], 0.0)
d3_cond = _frechet_couple_new_arm_iip0034(d3_inc, p_d1[2] / c3_shared, phi_cross, lambda mi: mi != 0)
d3 = [0.0] * 16
d3[0] += 1.0 - c3_shared
for k in range(16):
d3[k] += c3_shared * d3_cond[k]
c3_e = c3_shared
d4_inc = _live_incumbent_h4_cond_iip0034()
if h4_mode == "SHARED_R2":
d4_cond = _frechet_couple_new_arm_iip0034(d4_inc, p_d1[3] / 0.85, 1.0, lambda mi: bool(mi & 2))
d4 = [0.0] * 16
d4[0] += 0.15
for k in range(16):
d4[k] += 0.85 * d4_cond[k]
c4_e = 0.85
routes = ("R1", "R2", "R1", "R2")
elif h4_mode == "ORTHOG_R3P":
biv4 = _bivariate_bernoulli_iip0034(0.85 / c4_univ, c4_r3 / c4_univ, phi_cross)
u_d4 = p_d1[3] / c4_r3
d4 = [0.0] * 16
d4[0] += 1.0 - c4_univ
for (s0, s1), wp in biv4.items():
w = c4_univ * wp
if s0 == 0 and s1 == 0:
d4[0] += w
elif s0 == 1 and s1 == 0:
for mi in range(8):
d4[mi] += w * d4_inc[mi]
elif s0 == 0 and s1 == 1:
d4[0] += w * (1.0 - u_d4)
d4[8] += w * u_d4
else:
for mi in range(8):
d4[mi] += w * d4_inc[mi] * (1.0 - u_d4)
d4[mi | 8] += w * d4_inc[mi] * u_d4
c4_e = c4_univ * (1.0 - biv4[(0, 0)])
routes = ("R1", "R2", "R1", "R3P")
else:
raise ValueError(h4_mode)
return _run_dp_and_verify_parity_iip0034(
label,
[pa, pb, px, p_d1],
[d1, d2, d3, d4],
[0.88, c2_e, c3_e, c4_e],
p0_l,
p0_m,