and stale_base_rejected is True ) tests.append({ "test": "r03_b2_r2_dz40_lowered_p_bed_30mmhg_override_fails_and_rejects_stale_baseline", "nominal_40mmhg_face_min_unrounded": d_r2["face_min_mmhg_unrounded"], "override_30mmhg_face_min_unrounded": d_r2_ov30["face_min_mmhg_unrounded"], "solver_p_bed_mmhg_verified": d_r2_ov30["solver_p_bed_mmhg_verified"], "stale_baseline_rejected": stale_base_rejected, "adjudicated_verdict": d_r2_ov30["adjudicated_verdict"], "passed": ok_6, }) # 7. R03-B2: Concurrent multi-threaded dispatch isolation (zero global callback corruption/state leak) with ThreadPoolExecutor(max_workers=2) as pool: f_hi = pool.submit( dispatch_and_solve_nw08_measured_ocr, "R3P_35", 1.25, 0.04, openislet_root=openislet_root, p_bed_mmhg=35.0, always_solve_3d=True, **_known_sig ) f_lo = pool.submit( dispatch_and_solve_nw08_measured_ocr, "R3P_35", 1.25, 0.04, openislet_root=openislet_root, p_bed_mmhg=30.0, always_solve_3d=True, **_known_sig ) c_hi = f_hi.result() c_lo = f_lo.result() ok_7 = bool( c_hi["solver_p_bed_mmhg_verified"] == 35.0 and c_lo["solver_p_bed_mmhg_verified"] == 30.0 and abs(c_hi["face_min_mmhg_unrounded"] - d_r3p35_nom["face_min_mmhg_unrounded"]) < 1e-12 and abs(c_lo["face_min_mmhg_unrounded"] - d_r3p35_ov30["face_min_mmhg_unrounded"]) < 1e-12 ) tests.append({ "test": "r03_b2_concurrent_in_process_fvm_dispatch_state_isolation", "thread_35mmhg_face_min_unrounded": c_hi["face_min_mmhg_unrounded"], "thread_30mmhg_face_min_unrounded": c_lo["face_min_mmhg_unrounded"], "passed": ok_7, }) # 8. R04-B5: At DEFAULT bed pressure on R1_390_stress, a stale 25.0 mmHg caller baseline # MUST raise ValueError immediately (never passing without solving!), while the native # unrounded baseline (~15.261956 mmHg) dispatches live 3D FVM and FAILS < 15.0 mmHg! stale_default_rejected = False try: dispatch_and_solve_nw08_measured_ocr( "R1_390_stress", 1.44804, 0.0, openislet_root=openislet_root, baseline_min_face_mmhg=25.0, ) except ValueError: stale_default_rejected = True d_r1_390_stress_fail = dispatch_and_solve_nw08_measured_ocr( "R1_390_stress", 1.44804, 0.0, openislet_root=openislet_root, ) ok_8 = bool( stale_default_rejected is True and d_r1_390_stress_fail["p_bed_override_applied"] is False and d_r1_390_stress_fail["trigger_dispatched"] is True and d_r1_390_stress_fail["solver_executed"] is True and abs(d_r1_390_stress_fail["baseline_min_face_unrounded_mmhg"] - 15.261956) < 0.001 and d_r1_390_stress_fail["face_min_mmhg_unrounded"] < 15.0 and d_r1_390_stress_fail["adjudicated_verdict"] == "FAIL" ) tests.append({ "test": "r04_b5_default_bed_pressure_rejects_stale_25mmhg_baseline_and_fails_live_r1_390_stress", "stale_25mmhg_default_pressure_rejected": stale_default_rejected, "native_baseline_unrounded_mmhg": d_r1_390_stress_fail["baseline_min_face_unrounded_mmhg"], "solved_face_min_unrounded_mmhg": d_r1_390_stress_fail["face_min_mmhg_unrounded"], "adjudicated_verdict": d_r1_390_stress_fail["adjudicated_verdict"], "passed": ok_8, }) # 9. R04-B5: Negative or sub-95% caller-supplied one-sided quantile MUST raise ValueError # immediately so it can NEVER flip a live FAIL into PASS! neg_z_rejected = False sub95_z_rejected = False try: dispatch_and_solve_nw08_measured_ocr( "R1_390_stress", 1.44804, 0.15, openislet_root=openislet_root, z_one_sided_95=-1.6448536269514722, ) except ValueError: neg_z_rejected = True try: dispatch_and_solve_nw08_measured_ocr( "R1_390_stress", 1.44804, 0.15, openislet_root=openislet_root, z_one_sided_95=1.6448, ) except ValueError: sub95_z_rejected = True ok_9 = bool(neg_z_rejected is True and sub95_z_rejected is True) tests.append({ "test": "r04_b5_live_dispatch_rejects_negative_and_sub95_confidence_quantiles", "negative_z_rejected": neg_z_rejected, "sub95_z_rejected": sub95_z_rejected, "passed": ok_9, }) # 10. R05-B2: Forced & triggered live 3D FVM solve on R3P_30 (1.3164, 0.0 -> 14.906233... mmHg) # at BOTH floor_mmhg=15.0 AND floor_mmhg=14.0 MUST BOTH return FAIL and # passes_15mmhg_floor_unrounded=False, while diagnostic_passes_custom_floor reports # False at 15.0 and True at 14.0! d_r3p30_f15 = dispatch_and_solve_nw08_measured_ocr( "R3P_30", 1.3164, 0.0, openislet_root=openislet_root, floor_mmhg=15.0, always_solve_3d=True ) d_r3p30_f14 = dispatch_and_solve_nw08_measured_ocr( "R3P_30", 1.3164, 0.0, openislet_root=openislet_root, floor_mmhg=14.0, always_solve_3d=True ) d_r3p30_f14_unforced = dispatch_and_solve_nw08_measured_ocr( "R3P_30", 1.3164, 0.0, openislet_root=openislet_root, floor_mmhg=14.0, always_solve_3d=False ) ok_10 = bool( d_r3p30_f15["solver_executed"] is True and d_r3p30_f14["solver_executed"] is True and d_r3p30_f14_unforced["trigger_dispatched"] is True and d_r3p30_f14_unforced["solver_executed"] is True and abs(d_r3p30_f15["face_min_mmhg_unrounded"] - 14.906233358064961) < 1e-9 and abs(d_r3p30_f14["face_min_mmhg_unrounded"] - d_r3p30_f15["face_min_mmhg_unrounded"]) < 1e-12 and abs(d_r3p30_f14_unforced["face_min_mmhg_unrounded"] - d_r3p30_f15["face_min_mmhg_unrounded"]) < 1e-12 and d_r3p30_f15["canonical_floor_mmhg"] == 15.0 and d_r3p30_f14["canonical_floor_mmhg"] == 15.0 and d_r3p30_f15["passes_15mmhg_floor_unrounded"] is False and d_r3p30_f14["passes_15mmhg_floor_unrounded"] is False and d_r3p30_f14_unforced["passes_15mmhg_floor_unrounded"] is False and d_r3p30_f15["adjudicated_verdict"] == "FAIL" and d_r3p30_f14["adjudicated_verdict"] == "FAIL" and d_r3p30_f14_unforced["adjudicated_verdict"] == "FAIL" and d_r3p30_f15["diagnostic_custom_floor_mmhg"] == 15.0 and d_r3p30_f15["diagnostic_passes_custom_floor"] is False and d_r3p30_f14["diagnostic_custom_floor_mmhg"] == 14.0 and d_r3p30_f14["diagnostic_passes_custom_floor"] is True and d_r3p30_f14_unforced["diagnostic_passes_custom_floor"] is True ) tests.append({ "test": "r05_b2_r3p_bed30_sub15mmhg_immutable_canonical_fail_at_floor_15_and_14", "face_min_mmhg_unrounded": d_r3p30_f15["face_min_mmhg_unrounded"], "at_floor_15_verdict": d_r3p30_f15["adjudicated_verdict"], "at_floor_15_passes_15mmhg": d_r3p30_f15["passes_15mmhg_floor_unrounded"], "at_floor_15_diagnostic_passes_custom": d_r3p30_f15["diagnostic_passes_custom_floor"], "at_floor_14_verdict": d_r3p30_f14["adjudicated_verdict"], "at_floor_14_passes_15mmhg": d_r3p30_f14["passes_15mmhg_floor_unrounded"], "at_floor_14_diagnostic_passes_custom": d_r3p30_f14["diagnostic_passes_custom_floor"], "at_floor_14_unforced_solver_executed": d_r3p30_f14_unforced["solver_executed"], "passed": ok_10, }) # 11. R05-B2: Second canonical route below 15.0 mmHg (R1_350_stress at 1.3164, 0.0 -> ~14.8446 mmHg) # at BOTH floor_mmhg=15.0 AND floor_mmhg=14.0 MUST BOTH return FAIL and # passes_15mmhg_floor_unrounded=False, while diagnostic_passes_custom_floor is False at 15.0 and True at 14.0! d_r1_350_f15 = dispatch_and_solve_nw08_measured_ocr( "R1_350_stress", 1.3164, 0.0, openislet_root=openislet_root, floor_mmhg=15.0, always_solve_3d=True ) d_r1_350_f14 = dispatch_and_solve_nw08_measured_ocr( "R1_350_stress", 1.3164, 0.0, openislet_root=openislet_root, floor_mmhg=14.0, always_solve_3d=True ) d_r1_350_f14_unforced = dispatch_and_solve_nw08_measured_ocr( "R1_350_stress", 1.3164, 0.0, openislet_root=openislet_root, floor_mmhg=14.0, always_solve_3d=False ) ok_11 = bool( d_r1_350_f15["solver_executed"] is True and d_r1_350_f14["solver_executed"] is True and d_r1_350_f14_unforced["trigger_dispatched"] is True and d_r1_350_f14_unforced["solver_executed"] is True and 14.0 < d_r1_350_f15["face_min_mmhg_unrounded"] < 15.0 and abs(d_r1_350_f14["face_min_mmhg_unrounded"] - d_r1_350_f15["face_min_mmhg_unrounded"]) < 1e-12 and abs(d_r1_350_f14_unforced["face_min_mmhg_unrounded"] - d_r1_350_f15["face_min_mmhg_unrounded"]) < 1e-12 and d_r1_350_f15["canonical_floor_mmhg"] == 15.0 and d_r1_350_f14["canonical_floor_mmhg"] == 15.0 and d_r1_350_f15["passes_15mmhg_floor_unrounded"] is False and d_r1_350_f14["passes_15mmhg_floor_unrounded"] is False and d_r1_350_f14_unforced["passes_15mmhg_floor_unrounded"] is False and d_r1_350_f15["adjudicated_verdict"] == "FAIL" and d_r1_350_f14["adjudicated_verdict"] == "FAIL" and d_r1_350_f14_unforced["adjudicated_verdict"] == "FAIL" and d_r1_350_f15["diagnostic_custom_floor_mmhg"] == 15.0 and d_r1_350_f15["diagnostic_passes_custom_floor"] is False and d_r1_350_f14["diagnostic_custom_floor_mmhg"] == 14.0 and d_r1_350_f14["diagnostic_passes_custom_floor"] is True and d_r1_350_f14_unforced["diagnostic_passes_custom_floor"] is True ) tests.append({ "test": "r05_b2_r1_350_stress_sub15mmhg_immutable_canonical_fail_at_floor_15_and_14", "face_min_mmhg_unrounded": d_r1_350_f15["face_min_mmhg_unrounded"], "at_floor_15_verdict": d_r1_350_f15["adjudicated_verdict"], "at_floor_15_passes_15mmhg": d_r1_350_f15["passes_15mmhg_floor_unrounded"], "at_floor_15_diagnostic_passes_custom": d_r1_350_f15["diagnostic_passes_custom_floor"], "at_floor_14_verdict": d_r1_350_f14["adjudicated_verdict"], "at_floor_14_passes_15mmhg": d_r1_350_f14["passes_15mmhg_floor_unrounded"], "at_floor_14_diagnostic_passes_custom": d_r1_350_f14["diagnostic_passes_custom_floor"], "at_floor_14_unforced_solver_executed": d_r1_350_f14_unforced["solver_executed"], "passed": ok_11, }) # 12. R08-B2 (a) + R14-B1: Near-floor Route-2 override counterexample verbatim: # R2_DZ40 at p_bed=32.0, baseline_vasc_ocr_mult=2.0, measured_ocr=2.099752752324571, SE=0.0 # gives 14.98975358 on 48x48x28, 15.02371692 on 72x72x42, and 15.13803340 on 96x96x56 # (straddling 15.0 mmHg across predeclared grids!), so under R14-B1 it MUST dispatch live # 3D FVM + 3-grid convergence verification and route to unresolved HOLD (never PASS and # never decisive fixed-grid FAIL) in BOTH default and forced modes! d_r08_near_def = dispatch_and_solve_nw08_measured_ocr( "R2_DZ40", 2.099752752324571, 0.0, openislet_root=openislet_root, baseline_vasc_ocr_mult=2.0, p_bed_mmhg=32.0, ) d_r08_near_forced = dispatch_and_solve_nw08_measured_ocr( "R2_DZ40", 2.099752752324571, 0.0, openislet_root=openislet_root, baseline_vasc_ocr_mult=2.0, p_bed_mmhg=32.0, always_solve_3d=True, ) r2_mc = d_r08_near_def.get("mesh_convergence_verification") or {} ok_12 = bool( d_r08_near_def["solver_executed"] is True and d_r08_near_def["trigger_dispatched"] is True and d_r08_near_def["adjudicated_verdict"] == "HOLD" and d_r08_near_forced["adjudicated_verdict"] == "HOLD" and "HOLD_NW08_MESH_CONVERGENCE_STRADDLES_15MMHG_FLOOR" in (d_r08_near_def.get("holds") or []) and d_r08_near_def["passes_15mmhg_floor_unrounded"] is False and d_r08_near_def["face_min_mmhg_unrounded"] < 15.0 and r2_mc.get("executed") is True and r2_mc.get("straddles_canonical_15mmhg_floor") is True and r2_mc.get("grid_max_mmhg", 0.0) > 15.0 and abs(d_r08_near_def["face_min_mmhg_unrounded"] - d_r08_near_forced["face_min_mmhg_unrounded"]) < 1e-12 ) tests.append({ "test": "r08_b2_r14_b1_r2_dz40_near_floor_pbed32_base2p0_meas2p09975_mesh_reversal_routes_to_hold", "baseline_min_face_unrounded_mmhg": d_r08_near_def["baseline_min_face_unrounded_mmhg"], "default_face_min_unrounded_mmhg": d_r08_near_def["face_min_mmhg_unrounded"], "refined_max_face_min_unrounded_mmhg": r2_mc.get("grid_max_mmhg"), "default_verdict": d_r08_near_def["adjudicated_verdict"], "forced_verdict": d_r08_near_forced["adjudicated_verdict"], "solver_executed": d_r08_near_def["solver_executed"], "passed": ok_12, }) # 13. R08-B2 (b): Default 40.0 mmHg bed pressure with elevated baseline override (5.0 -> 10.0) # MUST dispatch live candidate 3D FVM and return FAIL (~13.1032141 < 15.0 mmHg) matching