ocr_r17_sub_ulp_t6 = 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=1e-20, ocr_uncertainty_model="STUDENT_T_ESTIMATED_SE", ocr_replicates_n=6, measurement_record_id="OCR-R17-B2-SUBULP-T6", measurement_evidence_sha256=clin_ev_sha, measurement_timestamp_utc="2026-11-29T01:00:00Z", ) ocr_r17_old_z = 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=1e-20, z_one_sided_95=1.6448536269514722, ocr_uncertainty_model="KNOWN_SIGMA_NORMAL", ocr_uncertainty_provenance="calibrated_respirometer_known_sigma_cert_v1", measurement_record_id="OCR-R17-B2-OLDZ-REJECT", measurement_evidence_sha256=clin_ev_sha, measurement_timestamp_utc="2026-11-29T01:00:00Z", ) ocr_r17_new_z = 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=1e-20, z_one_sided_95=v38.MIN_NW08_CONSERVATIVE_Z_ONE_SIDED_95, ocr_uncertainty_model="KNOWN_SIGMA_NORMAL", ocr_uncertainty_provenance="calibrated_respirometer_known_sigma_cert_v1", measurement_record_id="OCR-R17-B2-NEWZ-PASS", measurement_evidence_sha256=clin_ev_sha, measurement_timestamp_utc="2026-11-29T01:00:00Z", ) f_r17_t6 = Path(td) / "r17_b2_ocr_sub_ulp_t6.json" f_r17_t6.write_text(json.dumps(ocr_r17_sub_ulp_t6, sort_keys=True), encoding="utf-8") f_r17_oldz = Path(td) / "r17_b2_ocr_old_z.json" f_r17_oldz.write_text(json.dumps(ocr_r17_old_z, sort_keys=True), encoding="utf-8") f_r17_newz = Path(td) / "r17_b2_ocr_new_z.json" f_r17_newz.write_text(json.dumps(ocr_r17_new_z, sort_keys=True), encoding="utf-8") r_87_t6, rc_87_t6 = 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_r17_t6, ) r_87_oldz, rc_87_oldz = 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_r17_oldz, ) r_87_newz, rc_87_newz = 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_r17_newz, ) direct_disp_r17_fast = v38.dispatch_and_solve_nw08_measured_ocr( "R2_DZ40", 1.097, 0.0, openislet_root=openislet_root, ocr_uncertainty_model="ZERO_UNCERTAINTY_DETERMINISTIC_POINT", ) direct_disp_r17_sub = v38.dispatch_and_solve_nw08_measured_ocr( "R2_DZ40", 1.097, 1e-20, openislet_root=openislet_root, ocr_uncertainty_model="STUDENT_T_ESTIMATED_SE", ocr_degrees_of_freedom=5, ) nw_87_t6 = r_87_t6.get("nw08_measured_ocr_dispatch_result") or {} nw_87_newz = r_87_newz.get("nw08_measured_ocr_dispatch_result") or {} u95_87_t6 = _Decimal(str(nw_87_t6.get("solved_at_vascular_ocr_u95_exact_dec"))) u95_87_newz = _Decimal(str(nw_87_newz.get("solved_at_vascular_ocr_u95_exact_dec"))) ok_87 = bool( rc_87_t6 == 0 and r_87_t6["composite_verdict"] == "PASS_COMPOSITE_CLINICAL_RELEASE" and r_87_t6["release_authorizing"] is True and nw_87_t6.get("solver_executed") is True and float(nw_87_t6.get("native_solver_vasc_scale_float64")) > 1.0 and _Fraction(float(nw_87_t6.get("native_solver_vasc_scale_float64"))) >= _Fraction(u95_87_t6) / _Fraction(_Decimal("1.097")) and _Fraction(float(nw_87_t6.get("native_solver_effective_vascular_ocr_float64"))) >= _Fraction(u95_87_t6) and rc_87_oldz == 2 and r_87_oldz["composite_verdict"] == "HOLD_COMPOSITE_RELEASE" and r_87_oldz["release_authorizing"] is False and (r_87_oldz.get("nw08_measured_ocr_dispatch_result") or {}).get("solver_executed") is False and rc_87_newz == 0 and r_87_newz["composite_verdict"] == "PASS_COMPOSITE_CLINICAL_RELEASE" and float(nw_87_newz.get("native_solver_vasc_scale_float64")) > 1.0 and _Fraction(float(nw_87_newz.get("native_solver_effective_vascular_ocr_float64"))) >= _Fraction(u95_87_newz) and direct_disp_r17_fast.get("qualification_scope") == v38.QUALIFICATION_SCOPE_MODELED_PENDING_PHYSICAL and direct_disp_r17_fast.get("physical_qualification_complete") is False and direct_disp_r17_sub.get("qualification_scope") == v38.QUALIFICATION_SCOPE_MODELED_PENDING_PHYSICAL and direct_disp_r17_sub.get("physical_qualification_complete") is False and float(direct_disp_r17_sub.get("native_solver_vasc_scale_float64")) > 1.0 ) cases.append({ "case": "r17_b2_m1_coupled_sub_ulp_upward_solver_scale_old_z_held_and_direct_dispatch_scope", "expected_verdict": "PASS_0_OLDZ_HOLD_2_NEWZ_PASS_0", "actual_verdict": ( f"{r_87_t6['composite_verdict']}_{rc_87_t6}__" f"{r_87_oldz['composite_verdict']}_{rc_87_oldz}__" f"{r_87_newz['composite_verdict']}_{rc_87_newz}" ), "operational_tier": r_87_t6["operational_tier"], "legacy_passed": (r_87_t6.get("legacy_result_summary") or {}).get("legacy_evaluator_passed"), "legacy_tier": (r_87_t6.get("legacy_result_summary") or {}).get("lot_release_readiness_tier"), "legacy_resolved_pvid": (r_87_t6.get("legacy_result_summary") or {}).get("resolved_product_variant_id"), "gate0v_passed": (r_87_t6.get("gate0v_result_summary") or {}).get("gate0v_evaluator_passed"), "gate0v_verdict": (r_87_t6.get("gate0v_result_summary") or {}).get("verdict"), "sub_ulp_t6_native_scale_f64": nw_87_t6.get("native_solver_vasc_scale_float64"), "sub_ulp_t6_effective_ocr_f64": nw_87_t6.get("native_solver_effective_vascular_ocr_float64"), "expected_token": "HOLD_NW08_OCR_INVALID_PARAMETERS", "exit_code": 0 if ok_87 else -1, "hard_stops": [], "holds": r_87_oldz["holds"][:3], "passed": ok_87, }) wc_sha_after = hashlib.sha256(wc_path.read_bytes()).hexdigest() passed_n = sum(1 for c in cases if c["passed"]) return { "schema_version": "0.8.0-exp031-composite-release-v16-r17", "legacy_wetlab_contract_sha256_before": wc_sha_before, "legacy_wetlab_contract_sha256_after": wc_sha_after, "legacy_wetlab_contract_zero_byte_untouched": wc_sha_before == wc_sha_after, "total_cases": len(cases), "passed_cases": passed_n, "all_passed": bool(passed_n == len(cases) and wc_sha_before == wc_sha_after), "cases": cases, } # --------------------------------------------------------------------------- # Wave-6 Governed Gate 0V Producer Receipt Adapters (v2_round8_governed; Audit R7-06 / R7-07 / R7-12) # --------------------------------------------------------------------------- from collections.abc import Mapping as _AbcMapping, Sequence as _AbcSequence import math as _math_g0v import os as _os_g0v import re as _re_g0v _GY030_REQUIRED_5_LINEAGES = frozenset({"alpha", "beta", "delta", "pericyte", "plvap_iec"}) _FORBIDDEN_CALLER_PHYSICAL_ASSAY_KEYS = frozenset({ "dossier_type", "evidence_tier", "physical_qualification_complete", "whole_graft_stressed_tested", "lineages_verified", "estimand1_u_esc", "estimand2_u_cond", "caspase_fold_activity", "five_virus_max_fold_vs_wt", "nhs20_cdc_c5b9_u95_pct", "qa_decision", "gate0v_assay_payload", }) _PHYSICAL_ASSAY_NUMERIC_FIELDS = ( "estimand1_u_esc", "estimand2_u_cond", "caspase_fold_activity", "five_virus_max_fold_vs_wt", "nhs20_cdc_c5b9_u95_pct", ) _MAX_SAFE_INT_ABS_V2_ROUND8 = 10**300 _SAFE_STORE_ID_RE_V2_ROUND8 = _re_g0v.compile(r"^[A-Za-z0-9._:-]{1,128}$") _QA_ISSUER_REGISTRY_SCHEMA_V2_ROUND8 = "openislet_gate0v_qa_issuer_registry_v1" _GATE0V_TRUST_CONFIG_SCHEMA_V2_ROUND9 = "openislet_gate0v_governed_trust_config_v1" _GATE0V_TRUST_CONFIG_AUTHORITY_ID_V2_ROUND9 = "OPENISLET_GATE0V_OWNER_TRUST_ANCHOR_V1" _GATE0V_TRUST_CONFIG_REL_PATH_V2_ROUND9 = Path("data") / "protocols" / "gate0v_governed_trust_config.json" _PINNED_GATE0V_TRUST_CONFIG_SHA256 = "72efc0c671bd505b98f562c97e20f8048ddf749f674959b12f8745893d5b1a2d" _GATE0V_INSTALLATION_IDENTITY_SCHEMA_V2_ROUND10 = "openislet_gate0v_installation_identity_v1" _GATE0V_INSTALLATION_IDENTITY_AUTHORITY_ID_V2_ROUND10 = "OPENISLET_GOVERNED_GATE0V_OWNER_V1" _GATE0V_INSTALLATION_IDENTITY_REL_PATH_V2_ROUND10 = Path("data") / "protocols" / "gate0v_installation_identity.json" _PINNED_GATE0V_INSTALLATION_IDENTITY_SHA256 = "bccd641aaa535470fea13fb04e9dba40f4ca09c3be8594112bd6fe16eff89751" _SYNTHETIC_ISSUER_FORBIDDEN_MARKERS_V2_ROUND10 = ("SYNTHETIC", "FIXTURE", "MOCK", "PLUMBING") _FORBIDDEN_MODELED_SCOPES_V2_ROUND8 = frozenset({ "MODELED_COMPUTATIONAL_ONLY", QUALIFICATION_SCOPE_MODELED_PENDING_PHYSICAL, }) def _safe_str_v2_round8(val: Any) -> str: return val if isinstance(val, str) else "" def _is_safe_store_id_v2_round8(val: Any) -> bool: return ( isinstance(val, str) and val == val.strip() and bool(_SAFE_STORE_ID_RE_V2_ROUND8.match(val)) and ".." not in val ) def _is_safe_sha256_v2_round8(val: Any) -> bool: return isinstance(val, str) and len(val) == 64 and all(ch in "0123456789abcdef" for ch in val) def _safe_finite_number_v2_round8(val: Any) -> Tuple[bool, float | None, str | None]: """Audit R7-12: Typed value check + guarded finite float conversion (never raises TypeError or OverflowError).""" if isinstance(val, bool) or not isinstance(val, (int, float)): return False, None, f"NON_NUMERIC_VALUE:{type(val).__name__}" if isinstance(val, int) and abs(val) > _MAX_SAFE_INT_ABS_V2_ROUND8: return False, None, "INTEGER_OVERFLOW" try: fv = float(val) except (OverflowError, ValueError, TypeError): return False, None, "INTEGER_OVERFLOW" if not _math_g0v.isfinite(fv): return False, None, "NON_FINITE_NUMBER" return True, fv, None def _check_json_structure_v2_round8(obj: Any, depth: int = 0) -> Tuple[bool, str | None]: if depth > MAX_JSON_NESTING_DEPTH: return False, "JSON_MAX_DEPTH_EXCEEDED" if obj is None or isinstance(obj, (bool, str, int)): return True, None if isinstance(obj, float): return (_math_g0v.isfinite(obj), None if _math_g0v.isfinite(obj) else "NON_FINITE_FLOAT") if isinstance(obj, _AbcMapping): for k, v in obj.items(): if not isinstance(k, str): return False, f"NON_STRING_DICT_KEY:{type(k).__name__}" ok, err = _check_json_structure_v2_round8(v, depth + 1) if not ok: return False, err return True, None