scripts/evaluate_gate0v_composite_release.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/evaluate_gate0v_composite_release.py · SHA-256: 2be0252340222fe4…
and "HOLD_NW08_AMBIGUOUS_OR_NONCANONICAL_OCR_JSON:JSON_DEPTH_OR_RECURSION_LIMIT_EXCEEDED" in r_d_ocr["holds"]
and rc_d_store == 2
and r_d_store["composite_verdict"] == "HOLD_COMPOSITE_RELEASE"
and r_d_store["release_authorizing"] is False
and "HOLD_UNVERIFIED_EXTERNAL_APPROVAL_STORE" in r_d_store["holds"]
and any("JSON_DEPTH_OR_RECURSION_LIMIT_EXCEEDED" in h for h in r_d_store["holds"])
and rc_r_lot == 2
and r_r_lot["composite_verdict"] == "HOLD_COMPOSITE_RELEASE"
and r_r_lot["release_authorizing"] is False
and "HOLD_COMPOSITE_AMBIGUOUS_OR_NONCANONICAL_LOT_JSON:JSON_DEPTH_OR_RECURSION_LIMIT_EXCEEDED" in r_r_lot["holds"]
)
cases.append({
"case": "r11_b4_depth_gt_64_and_injected_recursion_error_composite_lot_ocr_and_store_hold_exit_2",
"expected_verdict": "HOLD_COMPOSITE_RELEASE",
"actual_verdict": "HOLD_COMPOSITE_RELEASE" if ok_72 else "UNHANDLED_RECURSION_OR_WRONG_RC",
"operational_tier": "LOT_RELEASE_SURROGATE",
"legacy_passed": True,
"legacy_tier": LEGACY_PASS_TIER,
"legacy_resolved_pvid": pv_lead,
"gate0v_passed": True,
"gate0v_verdict": "PASS_WHOLEGRAFT_LOT_RELEASE_SURROGATE",
"expected_token": "JSON_DEPTH_OR_RECURSION_LIMIT_EXCEEDED",
"exit_code": 2 if ok_72 else -1,
"hard_stops": [],
"holds": r_r_lot["holds"][:3],
"passed": ok_72,
})
# ------------------------------------------------------------------
# Round-12 Final-Closure Composite Regressions (R12-B1 & R12-B2)
# ------------------------------------------------------------------
# 73. R12-B1: Composite `--lot-json` with missing clustering_and_independence_spec,
# invalid deff, independent_biological_units_n: 6 -> 3, or mutated per_unit_counts
# MUST fail closed (exit 2 HOLD, exact_directional_confidence_certified=False,
# release_authorizing=False), while deterministic biological FAIL_HARD_STOP
# (cxadr_ko_present=True with missing spec) preserves exit 3 FAIL_HARD_STOP!
g0v_r12_miss = copy.deepcopy(g0v_bank)
g0v_r12_miss.pop("clustering_and_independence_spec", None)
g0v_r12_miss["payload_sha256"] = v38.compute_canonical_lot_sha256(g0v_r12_miss)
f_r12_miss = Path(td) / "r12_b1_missing_spec.json"
f_r12_miss.write_text(json.dumps(_make_composite_bundle(bank_lot_id, mcb_id, pv_lead, leg_bank, g0v_r12_miss), sort_keys=True), encoding="utf-8")
r_73_miss, rc_73_miss = evaluate_composite_lot_file(
f_r12_miss, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, openislet_root=openislet_root
)
g0v_r12_u3 = copy.deepcopy(g0v_bank)
g0v_r12_u3["clustering_and_independence_spec"]["independent_biological_units_n"] = 3
g0v_r12_u3["payload_sha256"] = v38.compute_canonical_lot_sha256(g0v_r12_u3)
f_r12_u3 = Path(td) / "r12_b1_units_3.json"
f_r12_u3.write_text(json.dumps(_make_composite_bundle(bank_lot_id, mcb_id, pv_lead, leg_bank, g0v_r12_u3), sort_keys=True), encoding="utf-8")
r_73_u3, rc_73_u3 = evaluate_composite_lot_file(
f_r12_u3, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, openislet_root=openislet_root
)
g0v_r12_mut = copy.deepcopy(g0v_bank)
g0v_r12_mut["gate0v_kill_stress_ap1903"]["normoxia_baseline"]["beta"]["per_unit_counts"]["ap1903_24h"][0]["n"] += 1
g0v_r12_mut["payload_sha256"] = v38.compute_canonical_lot_sha256(g0v_r12_mut)
f_r12_mut = Path(td) / "r12_b1_mutated_partition.json"
f_r12_mut.write_text(json.dumps(_make_composite_bundle(bank_lot_id, mcb_id, pv_lead, leg_bank, g0v_r12_mut), sort_keys=True), encoding="utf-8")
r_73_mut, rc_73_mut = evaluate_composite_lot_file(
f_r12_mut, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, openislet_root=openislet_root
)
g0v_r12_cx = copy.deepcopy(g0v_r12_miss)
g0v_r12_cx["cxadr_ko_present"] = True
g0v_r12_cx["payload_sha256"] = v38.compute_canonical_lot_sha256(g0v_r12_cx)
f_r12_cx = Path(td) / "r12_b1_missing_spec_bio_fail.json"
f_r12_cx.write_text(json.dumps(_make_composite_bundle(bank_lot_id, mcb_id, pv_lead, leg_bank, g0v_r12_cx), sort_keys=True), encoding="utf-8")
r_73_cx, rc_73_cx = evaluate_composite_lot_file(
f_r12_cx, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, openislet_root=openislet_root
)
ok_73 = bool(
rc_73_miss == 2
and r_73_miss["composite_verdict"] == "HOLD_COMPOSITE_RELEASE"
and r_73_miss["release_authorizing"] is False
and (r_73_miss.get("gate0v_result_summary") or {}).get("exact_directional_confidence_certified") is False
and (r_73_miss.get("gate0v_result_summary") or {}).get("confidence_scope") == "UNCERTIFIED_MISSING_OR_INVALID_SAMPLING_SPEC"
and rc_73_u3 == 2
and r_73_u3["composite_verdict"] == "HOLD_COMPOSITE_RELEASE"
and r_73_u3["release_authorizing"] is False
and "HOLD_INSUFFICIENT_INDEPENDENT_BIOLOGICAL_UNITS" in r_73_u3["holds"]
and (r_73_u3.get("gate0v_result_summary") or {}).get("exact_directional_confidence_certified") is False
and rc_73_mut == 2
and r_73_mut["composite_verdict"] == "HOLD_COMPOSITE_RELEASE"
and r_73_mut["release_authorizing"] is False
and "HOLD_SAMPLING_UNIT_PARTITION_MISMATCH_OR_INSUFFICIENT_UNITS" in r_73_mut["holds"]
and (r_73_mut.get("gate0v_result_summary") or {}).get("exact_directional_confidence_certified") is False
and rc_73_cx == 3
and r_73_cx["composite_verdict"] == "FAIL_HARD_STOP_COMPOSITE_RELEASE"
and r_73_cx["release_authorizing"] is False
and (r_73_cx.get("gate0v_result_summary") or {}).get("exact_directional_confidence_certified") is False
)
cases.append({
"case": "r12_b1_sampling_spec_missing_invalid_6_to_3_partition_mismatch_hold_bio_fail_preserved",
"expected_verdict": "HOLD_COMPOSITE_RELEASE",
"actual_verdict": r_73_u3["composite_verdict"],
"operational_tier": r_73_u3["operational_tier"],
"legacy_passed": (r_73_u3.get("legacy_result_summary") or {}).get("legacy_evaluator_passed"),
"legacy_tier": (r_73_u3.get("legacy_result_summary") or {}).get("lot_release_readiness_tier"),
"legacy_resolved_pvid": (r_73_u3.get("legacy_result_summary") or {}).get("resolved_product_variant_id"),
"gate0v_passed": (r_73_u3.get("gate0v_result_summary") or {}).get("gate0v_evaluator_passed"),
"gate0v_verdict": (r_73_u3.get("gate0v_result_summary") or {}).get("verdict"),
"expected_token": "HOLD_INSUFFICIENT_INDEPENDENT_BIOLOGICAL_UNITS",
"exit_code": rc_73_u3,
"hard_stops": r_73_cx["hard_stops"][:2],
"holds": r_73_u3["holds"][:3],
"passed": ok_73,
})
# 74. R12-B2 (a): Coupled composite `--nw08-ocr-json` (even when FULLY lot-bound!) with
# `"uncertainty_se": -1e-400`, `-0.0`, and `"-0.0"` MUST fail closed (exit 2
# HOLD_COMPOSITE_RELEASE, release_authorizing=False, solver_executed=False)!
ocr_bound_base = v38.build_bound_nw08_ocr_record(
lot_id=clin_lot_id,
mcb_id=mcb_id,
product_variant_id=pv_lead,
route_id="R2_DZ40",
lot_payload_sha256=clin_r2_bundle["payload_sha256"],
measured_ocr=1.097,
uncertainty_se=0.0,
measurement_record_id="OCR-R12B2-BOUND-1",
measurement_evidence_sha256=clin_ev_sha,
measurement_timestamp_utc="2026-11-29T01:00:00Z",
)
f_ocr_uf = Path(td) / "r12_b2_ocr_underflow.json"
f_ocr_uf.write_text(
json.dumps(ocr_bound_base, sort_keys=True).replace('"uncertainty_se": 0.0', '"uncertainty_se": -1e-400'),
encoding="utf-8",
)
ocr_bound_sz = copy.deepcopy(ocr_bound_base)
ocr_bound_sz["uncertainty_se"] = v38.Decimal("-0.0")
ocr_bound_sz["ocr_record_sha256"] = v38.compute_nw08_ocr_record_sha256(ocr_bound_sz)
f_ocr_sz = Path(td) / "r12_b2_ocr_signed_zero.json"
f_ocr_sz.write_text(v38._canonical_json_dumps(ocr_bound_sz), encoding="utf-8")
ocr_bound_sz_s = copy.deepcopy(ocr_bound_base)
ocr_bound_sz_s["uncertainty_se"] = "-0.0"
ocr_bound_sz_s["ocr_record_sha256"] = v38.compute_nw08_ocr_record_sha256(ocr_bound_sz_s)
f_ocr_sz_s = Path(td) / "r12_b2_ocr_signed_zero_str.json"
f_ocr_sz_s.write_text(json.dumps(ocr_bound_sz_s, sort_keys=True), encoding="utf-8")
r_74_uf, rc_74_uf = evaluate_composite_lot_file(
clin_r2_f,
legacy_evaluator=leg_fn,
gate0v_evaluator=g0v_fn,
trusted_qualification_store=trusted_store,
openislet_root=openislet_root,
nw08_ocr_json_path=f_ocr_uf,
)
r_74_sz, rc_74_sz = evaluate_composite_lot_file(
clin_r2_f,
legacy_evaluator=leg_fn,
gate0v_evaluator=g0v_fn,
trusted_qualification_store=trusted_store,
openislet_root=openislet_root,
nw08_ocr_json_path=f_ocr_sz,
)
r_74_szs, rc_74_szs = evaluate_composite_lot_file(
clin_r2_f,
legacy_evaluator=leg_fn,
gate0v_evaluator=g0v_fn,
trusted_qualification_store=trusted_store,
openislet_root=openislet_root,
nw08_ocr_json_path=f_ocr_sz_s,
)
ok_74 = bool(
rc_74_uf == 2
and r_74_uf["composite_verdict"] == "HOLD_COMPOSITE_RELEASE"
and r_74_uf["release_authorizing"] is False
and "HOLD_NW08_AMBIGUOUS_OR_NONCANONICAL_OCR_JSON:NONZERO_FLOAT_UNDERFLOW_REJECTED" in r_74_uf["holds"]
and (r_74_uf.get("nw08_measured_ocr_dispatch_result") or {}).get("solver_executed") is False
and rc_74_sz == 2
and r_74_sz["composite_verdict"] == "HOLD_COMPOSITE_RELEASE"
and r_74_sz["release_authorizing"] is False
and "INVALID_NEGATIVE_OR_SIGNED_ZERO_BOUNDARY_VALUE" in r_74_sz["holds"]
and (r_74_sz.get("nw08_measured_ocr_dispatch_result") or {}).get("solver_executed") is False
and rc_74_szs == 2
and r_74_szs["composite_verdict"] == "HOLD_COMPOSITE_RELEASE"
and r_74_szs["release_authorizing"] is False
and "INVALID_NEGATIVE_OR_SIGNED_ZERO_BOUNDARY_VALUE" in r_74_szs["holds"]
and (r_74_szs.get("nw08_measured_ocr_dispatch_result") or {}).get("solver_executed") is False
)
cases.append({
"case": "r12_b2_coupled_nw08_ocr_underflow_neg_1e_minus_400_and_signed_zero_hold_exit_2",
"expected_verdict": "HOLD_COMPOSITE_RELEASE",
"actual_verdict": r_74_uf["composite_verdict"],
"operational_tier": r_74_uf["operational_tier"],
"legacy_passed": (r_74_uf.get("legacy_result_summary") or {}).get("legacy_evaluator_passed"),
"legacy_tier": (r_74_uf.get("legacy_result_summary") or {}).get("lot_release_readiness_tier"),
"legacy_resolved_pvid": (r_74_uf.get("legacy_result_summary") or {}).get("resolved_product_variant_id"),
"gate0v_passed": (r_74_uf.get("gate0v_result_summary") or {}).get("gate0v_evaluator_passed"),
"gate0v_verdict": (r_74_uf.get("gate0v_result_summary") or {}).get("verdict"),
"expected_token": "HOLD_NW08_AMBIGUOUS_OR_NONCANONICAL_OCR_JSON:NONZERO_FLOAT_UNDERFLOW_REJECTED",
"exit_code": rc_74_uf,
"hard_stops": [],
"holds": r_74_uf["holds"][:3],
"passed": ok_74,
})
# 75. R12-B2 (b): Composite `--lot-json` with `clustering_design_effect_deff: 1.00000000000000001`
# (raw JSON number) AND `"1.00000000000000001"` (JSON string) MUST BOTH fail closed identically
# with exit 2, HOLD_CLUSTERED_DEFF_GT_1_REQUIRES_CLUSTER_LEVEL_INFERENCE,
# exact_directional_confidence_certified=False, release_authorizing=False!
g0v_deff_str = copy.deepcopy(g0v_clin)
g0v_deff_str["clustering_and_independence_spec"]["clustering_design_effect_deff"] = "1.00000000000000001"
g0v_deff_str["payload_sha256"] = v38.compute_canonical_lot_sha256(g0v_deff_str)
f_deff_str = Path(td) / "r12_b2_comp_deff_str.json"
f_deff_str.write_text(
json.dumps(_make_composite_bundle(clin_lot_id, mcb_id, pv_lead, leg_clin, g0v_deff_str), sort_keys=True),
encoding="utf-8",
)
g0v_deff_num = copy.deepcopy(g0v_clin)
g0v_deff_num["clustering_and_independence_spec"]["clustering_design_effect_deff"] = v38.Decimal("1.00000000000000001")
g0v_deff_num["payload_sha256"] = v38.compute_canonical_lot_sha256(g0v_deff_num)
comp_num_txt = v38._canonical_json_dumps(
_make_composite_bundle(clin_lot_id, mcb_id, pv_lead, leg_clin, g0v_deff_num)
)
f_deff_num = Path(td) / "r12_b2_comp_deff_num.json"
f_deff_num.write_text(comp_num_txt, encoding="utf-8")
r_75_str, rc_75_str = evaluate_composite_lot_file(
f_deff_str,
legacy_evaluator=leg_fn,
gate0v_evaluator=g0v_fn,
trusted_qualification_store=trusted_store,
openislet_root=openislet_root,
)
r_75_num, rc_75_num = evaluate_composite_lot_file(
f_deff_num,
legacy_evaluator=leg_fn,
gate0v_evaluator=g0v_fn,
trusted_qualification_store=trusted_store,
openislet_root=openislet_root,
)
ok_75 = bool(
'"clustering_design_effect_deff":1.00000000000000001' in comp_num_txt
and rc_75_str == 2
and rc_75_num == 2
and r_75_str["composite_verdict"] == "HOLD_CLUSTERED_DEFF_GT_1_REQUIRES_CLUSTER_LEVEL_INFERENCE"
and r_75_num["composite_verdict"] == "HOLD_CLUSTERED_DEFF_GT_1_REQUIRES_CLUSTER_LEVEL_INFERENCE"
and r_75_str["release_authorizing"] is False
and r_75_num["release_authorizing"] is False
and (r_75_str.get("gate0v_result_summary") or {}).get("exact_directional_confidence_certified") is False
and (r_75_num.get("gate0v_result_summary") or {}).get("exact_directional_confidence_certified") is False
and "HOLD_CLUSTERED_DEFF_GT_1_REQUIRES_CLUSTER_LEVEL_INFERENCE" in r_75_str["holds"]
and "HOLD_CLUSTERED_DEFF_GT_1_REQUIRES_CLUSTER_LEVEL_INFERENCE" in r_75_num["holds"]
)
cases.append({
"case": "r12_b2_composite_lot_deff_json_number_vs_string_1p00000000000000001_identical_clustered_hold",