eff_n_eff = int(n_test * f_clon * eta_det) if n_eff == "AUTO" else n_eff g5_body = { **{k: v for k, v in base["upstream_gate5_oq012_record"].items() if k != "archive_sha256"}, "survivor_count_k": k_surv, "tested_cells_n": n_test, "clonogenic_fraction_f": f_clon, "spike_in_detection_efficiency_eta": eta_det, "effective_clonogenic_trials_n_eff": eff_n_eff, "u95_exact": u95_reported, } for dk in drop_keys: g5_body.pop(dk, None) g5_new = seal_upstream_evidence_record(g5_body) g34_body = { **{k: v for k, v in base["upstream_gate32_record"].items() if k != "archive_sha256"}, "prerequisite_archive_sha256s": { "GATE-0V": base["upstream_gate0v_record"]["archive_sha256"], "GATE-5": g5_new["archive_sha256"], }, } g34_new = seal_upstream_evidence_record(g34_body) return {**base, "upstream_gate5_oq012_record": g5_new, "upstream_gate32_record": g34_new} # Review #6 / Audit R4-03 actual max-leaf packing overlap fixtures (within 2% reported-vs-measured tolerance!) audit_r403_pack = _resync({ **om_y_t2, "cluster_min_diam_um": 40.0, "cluster_d_rms3_um": 47.2981, "cluster_d_p95_um": 60.0, "cluster_max_diam_um": 65.0, "areal_loading_ieq_cm2": 1475.0, "total_implanted_ieq": 500_000.0, "total_loaded_area_cm2": 500_000.0 / 1500.0, "per_leaf_records": [ {**om_y_t2["per_leaf_records"][0], "loaded_ieq": 250_000.0, "measured_area_cm2": 250_000.0 / 1500.0}, {**om_y_t2["per_leaf_records"][1], "loaded_ieq": 250_000.0, "measured_area_cm2": 250_000.0 / 1500.0}, ], }) review_6_pack = _resync({ **om_d, "cluster_min_diam_um": 40.0, "cluster_d_rms3_um": 43.9551, "cluster_d_p95_um": 60.0, "cluster_max_diam_um": 65.0, "areal_loading_ieq_cm2": 1180.0, "total_implanted_ieq": 500_000.0, "total_loaded_area_cm2": 500_000.0 / 1199.9999, "per_leaf_records": [ {**om_d["per_leaf_records"][0], "loaded_ieq": 250_000.0, "measured_area_cm2": 250_000.0 / 1199.9999}, {**om_d["per_leaf_records"][1], "loaded_ieq": 250_000.0, "measured_area_cm2": 250_000.0 / 1199.9999}, ], }) single_leaf_500k_animal = _resync({ **om_d, "scale_mode": "ANIMAL_PRECLINICAL_SCALE", "total_implanted_ieq": 500_000.0, "total_loaded_area_cm2": 500_000.0 / 1200.0, "per_leaf_records": [{**om_d["per_leaf_records"][0], "loaded_ieq": 500_000.0, "measured_area_cm2": 500_000.0 / 1200.0}], }) # Review #4: archived endotoxin 3.0 vs parent endotoxin 0.12 om_d_adv_arch_endo = _resync({**om_d, "endotoxin_eu_per_ml": 3.0}) om_d_adv_arch_parent_favorable = {**om_d_adv_arch_endo, "endotoxin_eu_per_ml": 0.12} # Round-10 Audit R9-06, Round-11 Audit R10-05 & Round-13 Audit R12-04: raw JSON lexical decimal helpers (parse_float=Decimal) def _patch_nhp_one_raw_json(base: Dict[str, Any], idx: int, json_fields: Dict[str, str]) -> Dict[str, Any]: patched = _patch_nhp_one(base, idx, {k: 999999 + i for i, k in enumerate(json_fields.keys())}) raw = canonical_json_dumps(patched) for i, (k, tok) in enumerate(json_fields.items()): sentinel = f'"{k}":{999999 + i}' require_cond(sentinel in raw, f"Missing raw-JSON sentinel {sentinel}") raw = raw.replace(sentinel, f'"{k}":{tok}') parsed = load_strict_json_text(raw, "r10_raw_json_self_test") return _resync(parsed) def _patch_porcine_one_raw_json(base: Dict[str, Any], idx: int, json_fields: Dict[str, str]) -> Dict[str, Any]: patched = _patch_porcine_one(base, idx, {k: 999899 + i for i, k in enumerate(json_fields.keys())}) raw = canonical_json_dumps(patched) for i, (k, tok) in enumerate(json_fields.items()): sentinel = f'"{k}":{999899 + i}' require_cond(sentinel in raw, f"Missing raw-JSON sentinel {sentinel}") raw = raw.replace(sentinel, f'"{k}":{tok}') parsed = load_strict_json_text(raw, "r13_porcine_raw_json_self_test") return _resync(parsed) def _patch_leaf_one_raw_json(base: Dict[str, Any], idx: int, json_fields: Dict[str, str]) -> Dict[str, Any]: leaves = [dict(lf) for lf in base["per_leaf_records"]] leaves[idx] = {**leaves[idx], **{k: 999799 + i for i, k in enumerate(json_fields.keys())}} patched = _resync({**base, "per_leaf_records": leaves}) raw = canonical_json_dumps(patched) for i, (k, tok) in enumerate(json_fields.items()): sentinel = f'"{k}":{999799 + i}' require_cond(sentinel in raw, f"Missing raw-JSON sentinel {sentinel}") raw = raw.replace(sentinel, f'"{k}":{tok}') parsed = load_strict_json_text(raw, "r13_leaf_raw_json_self_test") return _resync(parsed) def _patch_top_raw_json(base: Dict[str, Any], json_fields: Dict[str, str]) -> Dict[str, Any]: patched = _patch_sync(base, {k: 999699 + i for i, k in enumerate(json_fields.keys())}) raw = canonical_json_dumps(patched) for i, (k, tok) in enumerate(json_fields.items()): sentinel = f'"{k}":{999699 + i}' require_cond(sentinel in raw, f"Missing raw-JSON sentinel {sentinel}") raw = raw.replace(sentinel, f'"{k}":{tok}') parsed = load_strict_json_text(raw, "r13_top_raw_json_self_test") return _resync(parsed) def _with_g5_raw_u95(base: Dict[str, Any], k_surv: int, n_test: int, raw_u95_tok: str) -> Dict[str, Any]: u95_dec = load_strict_json_text(f'{{"u95_exact":{raw_u95_tok}}}', "r11_g5_raw_json")["u95_exact"] return _with_g5(base, k_surv, n_test, u95_dec) om_d_exact_face15_core5 = _resync( load_strict_json_text( canonical_json_dumps( _patch_leaves( _patch_sync(om_d, {"measured_worst_face_o2_mmhg": 15.0, "measured_worst_core_o2_mmhg": 5.0}), {"measured_face_o2_mmhg": 15.0, "measured_core_o2_mmhg": 5.0}, ) ), "r13_exact_15_5", ) ) # Round-14 collision-free GATE-34 / GATE-35 & partial-responder C-peptide extinction fixtures om_d_g34_key = {k: v for k, v in om_d.items() if k != "upstream_gate32_record"} om_d_g34_key["upstream_gate34_record"] = dict(om_d["upstream_gate32_record"]) om_d_live_g32_collision = { **om_d, "upstream_gate32_record": seal_upstream_evidence_record({ **{k: v for k, v in om_d["upstream_gate32_record"].items() if k != "archive_sha256"}, "gate_source": "GATE-32", }), } om_d_live_g33_collision = { **om_d, "current_assay_evidence_record": seal_upstream_evidence_record({ **{k: v for k, v in om_d["current_assay_evidence_record"].items() if k != "archive_sha256"}, "gate_source": "GATE-33", }), } om_d_partial_responder_ext = _patch_nhp_one( om_d, 3, { "achieved_insulin_independence": False, "residual_exogenous_insulin_u_kg_d": 0.25, "followup_duration_days": 91.0, "omentectomy_performed": True, "omentectomy_procedure_id": "OMENT-NHP-04", "omentectomy_day": 90.0, "cpeptide_extinction_subject_id": "NHP-04", "cpeptide_extinction_procedure_id": "OMENT-NHP-04", "cpeptide_extinction_assessment_day": 91.0, "post_omentectomy_cpeptide_extinguished": True, "lloq_c_peptide_ng_ml": 0.05, "pre_explant_stimulated_c_peptide_ng_ml": 0.45, "post_explant_stimulated_c_peptide_ng_ml": 0.02, }, ) # ALL SYNTHETIC_FIXTURE cases MUST yield promotion_authorized=False! cases: List[Tuple[str, Dict[str, Any], str, bool, Optional[str]]] = [ ("pos_synth_tier1_omentum_d1b_k2_isolated", om_d, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_r14_dec009_0nhp_primate_free_primary_passes", om_d_dec009_pf, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_r14_upstream_gate34_record_key_passes", om_d_g34_key, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_r14_partial_responder_cpeptide_extinction_passes", om_d_partial_responder_ext, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_r14_gy028_exact_7p5um_wall_clearance_passes", _patch_sync(om_d, {"cluster_max_diam_um": 65.0, "staggered_bilayer_plane_offset_um": 20.0}), "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_tier2_omentum_design_y_v3_isolated", om_y_t2, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_union_boundary_1200_at_40mmHg_12um", om_union_1200, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_union_boundary_1201_at_40mmHg_12um", om_union_1201, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_tier1_omentum_arm_z_zero_rest", om_z_no_rest, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_sars_backup_design_y_v3", sars_y, "SYNTHETIC_SELF_TEST_PASS", False, None), ("pos_synth_stage0_booking_isolated", booking_y, "SYNTHETIC_SELF_TEST_BOOKING_PASS", False, None), ("pos_synth_porcine_surgical_only_day60_0p1_insulin_passes", om_d_pigs_day60_ok, "SYNTHETIC_SELF_TEST_PASS", False, None), # Round-14 Live Blueprint section 7 OQ-012 Gate 5 exact checks (k=0, n_eff >= 299,573,228, eta >= 0.30, U95 <= 1e-8) ("pos_synth_r14_gate5_live_oq012_exact_299573228_passes", _with_g5(om_d, 0, 1_000_000_000, clopper_pearson_u95(0, 299_573_228), f_clon=0.50, eta_det=0.60, n_eff=299_573_228), "SYNTHETIC_SELF_TEST_PASS", False, None), ("neg_hold_r14_gate5_live_oq012_299573227_underpowered_hold", _with_g5(om_d, 0, 1_000_000_000, clopper_pearson_u95(0, 299_573_227), f_clon=0.50, eta_det=0.60, n_eff=299_573_227), "HOLD", False, "HOLD_GATE5_OQ012_UNDERPOWERED_BELOW_299573228_EFFECTIVE_TRIALS"), ("neg_hold_r14_gate5_live_oq012_0_of_100k_underpowered_hold", _with_g5(om_d, 0, 100_000, clopper_pearson_u95(0, 40_000), f_clon=0.50, eta_det=0.80, n_eff=40_000), "HOLD", False, "HOLD_GATE5_OQ012_UNDERPOWERED_BELOW_299573228_EFFECTIVE_TRIALS"), ("neg_fail_r14_gate5_live_oq012_1_of_100k_survivor_fail", _with_g5(om_d, 1, 100_000, clopper_pearson_u95(1, 40_000), f_clon=0.50, eta_det=0.80, n_eff=40_000), "FAIL", False, "FAIL_GATE5_OQ012_NONZERO_SURVIVOR_OR_U95_GT_1E8"), ("neg_fail_r14_gate5_live_oq012_1_of_1e9_survivor_fail", _with_g5(om_d, 1, 1_000_000_000, clopper_pearson_u95(1, 400_000_000), f_clon=0.50, eta_det=0.80, n_eff=400_000_000), "FAIL", False, "FAIL_GATE5_OQ012_NONZERO_SURVIVOR_OR_U95_GT_1E8"), ("neg_fail_r14_gate5_live_oq012_eta_0p29_below_0p30_fail", _with_g5(om_d, 0, 2_000_000_000, clopper_pearson_u95(0, 290_000_000), f_clon=0.50, eta_det=0.29, n_eff=290_000_000), "FAIL", False, "FAIL_GATE5_OQ012_DETECTION_EFFICIENCY_ETA_LT_0P30"), ("neg_fail_r14_gate5_live_oq012_neff_exceeds_floor_n_f_eta_fail", _with_g5(om_d, 0, 1_000_000_000, clopper_pearson_u95(0, 400_000_001), f_clon=0.50, eta_det=0.80, n_eff=400_000_001), "FAIL", False, "FAIL_GATE5_OQ012_EFFECTIVE_TRIALS_EXCEEDS_FLOOR_N_F_ETA"), ("neg_hold_r14_gate5_live_oq012_omitted_recovery_denominator_hold", _with_g5(om_d, 0, 1_000_000_000, clopper_pearson_u95(0, 400_000_000), drop_keys=("clonogenic_fraction_f",)), "HOLD", False, "HOLD_GATE5_OQ012_INCOMPLETE_RECOVERY_DENOMINATOR"), ("neg_fail_r14_gate5_live_oq012_forged_u95_mismatch_fail", _with_g5(om_d, 0, 1_000_000_000, 1.0e-9, f_clon=0.50, eta_det=0.80, n_eff=400_000_000), "FAIL", False, "GATE5_UNDERSTATED_OR_FORGED_U95_EXACT"), # Round-14 live GATE-32 / GATE-33 role collisions, GY-028 >= 7.5 um wall clearance, DEC-009 pathway & decoupled C-peptide extinction ("neg_fail_r14_live_gate32_role_collision_rejected", om_d_live_g32_collision, "FAIL", False, "UPSTREAM_GATE34_LIVE_GATE32_ROLE_COLLISION_REJECTED"), ("neg_fail_r14_live_gate33_role_collision_rejected", om_d_live_g33_collision, "FAIL", False, "CURRENT_ASSAY_GATE35_LIVE_GATE33_ROLE_COLLISION_REJECTED"), ("neg_fail_r14_gy028_wall_clearance_5p25um_lt_7p5um_fail", _patch_sync(om_d, {"staggered_bilayer_plane_offset_um": 22.5, "cluster_max_diam_um": 64.5}), "FAIL", False, "GY028_WALL_CLEARANCE_LT_7P5UM_FAIL"), ("neg_fail_r14_gy028_sub_ulp_7p499999999999999um_fail", _patch_top_raw_json(om_d, {"staggered_bilayer_plane_offset_um": "20.000000000000001", "cluster_max_diam_um": "65.0"}), "FAIL", False, "GY028_WALL_CLEARANCE_LT_7P5UM_FAIL"), ("neg_hold_r14_partial_responder_missing_paired_cpeptide_lloq", _patch_nhp_one(om_d_partial_responder_ext, 3, {}, drop_keys=("lloq_c_peptide_ng_ml",)), "HOLD", False, "MISSING_NHP_PAIRED_STIMULATED_CPEPTIDE_OR_LLOQ"), ("neg_fail_r14_partial_responder_pre_cpeptide_le_lloq_fail", _patch_nhp_one(om_d_partial_responder_ext, 3, {"pre_explant_stimulated_c_peptide_ng_ml": 0.05}), "FAIL", False, "R4O_05_NHP_PRE_EXPLANT_CPEPTIDE_NOT_ABOVE_LLOQ_FAIL"), ("neg_fail_r14_partial_responder_post_cpeptide_gt_lloq_fail", _patch_nhp_one(om_d_partial_responder_ext, 3, {"post_explant_stimulated_c_peptide_ng_ml": 0.08}), "FAIL", False, "R4O_05_NHP_POST_EXPLANT_CPEPTIDE_EXCEEDS_LLOQ_FAIL"), ("neg_hold_r14_dec009_missing_pillar1_hold", _drop_both(om_d_dec009_pf, "dec009_pillar1_humanized_mouse_efficacy_pass"), "HOLD", False, "MISSING_DEC009_PILLAR1_HUMANIZED_MOUSE_EVIDENCE"), ("neg_fail_r14_dec009_unauthorized_nhp_exception_false_fail", _patch_sync(om_d, {"dec009_fda_cber_nhp_exception_authorized": False}), "FAIL", False, "DEC009_UNAUTHORIZED_NHP_COHORT_REJECTED"), ("neg_hold_r14_dec009_missing_nhp_exception_auth_hold", _drop_both(om_d, "dec009_fda_cber_nhp_exception_authorized"), "HOLD", False, "MISSING_DEC009_FDA_CBER_NHP_EXCEPTION_AUTHORIZATION"), ("neg_fail_r14_dec009_primate_free_with_unapproved_nhp_cohort_fail", _patch_sync(om_d_dec009_pf, {"nhp_subjects": om_d["nhp_subjects"]}), "FAIL", False, "DEC009_PRIMATE_FREE_PATHWAY_CONTRADICTS_NHP_COHORT_WITHOUT_FDA_EXCEPTION"), # Canonical arm manifest & switch rules ("neg_fail_gy027_1_design_a_on_r4", make_synthetic_valid_gate33_payload(arm_manifest, arm_key="A"), "FAIL", False, "GY027_1_BLOCK_UNHARDENED_ABX_PROHIBITED_ON_R4"), ("neg_fail_gy027_1_design_x_on_r4", make_synthetic_valid_gate33_payload(arm_manifest, arm_key="X"), "FAIL", False, "GY027_1_BLOCK_UNHARDENED_ABX_PROHIBITED_ON_R4"), ("neg_fail_d1b_single_switch_barred_from_sars_backup", make_synthetic_valid_gate33_payload(arm_manifest, arm_key="D", site="R4_SARS_FREE_BACKUP"), "FAIL", False, "D1B_LEAN_K2_SINGLE_SWITCH_BARRED_FROM_R4_SARS_BACKUP"), ("neg_fail_retired_cdk1_htmpk_switch", {**om_y_t2, "safety_switch_id": "Dual-FailSafe (iCasp9 + CDK1p::hTMPK)"}, "FAIL", False, "RETIRED_MISMATCHED_CDK1_HTMPK_SWITCH_PROHIBITED"), ("neg_fail_product_id_manifest_mismatch", {**om_d, "product_id": "ISLET1_DESIGN_Y_V3"}, "FAIL", False, "PRODUCT_ID_CANONICAL_MANIFEST_MISMATCH"), # Physical placement, geometry, steric packing, OCR, asymmetric bed, face O2, layout ("neg_fail_midplane_shift_zc_10um", _patch_sync(om_d, {"staggered_bilayer_plane_offset_um": 10.0}), "FAIL", False, "STAGGERED_BILAYER_PLANE_OFFSET_LT_20UM_FAIL"), ("neg_fail_impossible_10um_slab_sol_probe", _patch_sync(om_d, {"construct_thickness_um": 10.0}), "FAIL", False, "CONSTRUCT_THICKNESS_OUTSIDE_100_TO_120UM_FAIL"), ("neg_fail_20um_clusters_below_40um_domain", _patch_sync(om_d, {"cluster_min_diam_um": 20.0, "cluster_d_rms3_um": 20.0, "cluster_d_p95_um": 20.0, "cluster_max_diam_um": 20.0}), "FAIL", False, "CLUSTER_D_RMS3_OUTSIDE_40_TO_65UM_FAIL"), ("neg_fail_42_65um_1500_steric_overlap", _patch_sync(om_y_t2, {"cluster_min_diam_um": 40.0, "cluster_d_rms3_um": 42.0, "cluster_d_p95_um": 60.0, "cluster_max_diam_um": 65.0}), "FAIL", False, "STERIC_SAME_PLANE_PITCH_OVERLAP_FAIL"), ("neg_fail_monolayer_layout_rejected", _patch_sync(om_d, {"construct_layout": "MONOLAYER"}), "FAIL", False, "CONSTRUCT_LAYOUT_MUST_BE_STAGGERED_BILAYER"), ("neg_fail_lot_ocr_plus10pct", _patch_sync(om_d, {"measured_lot_ocr_mult": 1.2067}), "FAIL", False, "MEASURED_LOT_OCR_MULT_EXCEEDS_1P097_FAIL"), ("neg_fail_asymmetric_bed_25_45_mean35", _patch_sync(om_d, {"bed_face_bot_po2_mmhg": 25.0, "bed_face_top_po2_mmhg": 45.0}), "FAIL", False, "MIN_BILATERAL_BED_PO2_BELOW_35MMHG_ENVELOPE_FLOOR"), ("neg_fail_adverse_face_o2_14p6_mmhg", _patch_sync(om_d, {"measured_worst_face_o2_mmhg": 14.6028}), "FAIL", False, "MEASURED_WORST_FACE_O2_LT_15MMHG_FAIL"), ("neg_fail_adverse_core_o2_4p5_mmhg", _patch_sync(om_d, {"measured_worst_core_o2_mmhg": 4.5}), "FAIL", False, "MEASURED_WORST_CORE_O2_LT_5MMHG_FAIL"), ("neg_fail_tier2_1500_at_35mmHg_bed", _patch_sync(om_y_t2, {"bed_face_bot_po2_mmhg": 35.0, "bed_face_top_po2_mmhg": 35.0}), "FAIL", False, "TIER2_LOADING_GT_1200_REQUIRES_MIN_BILATERAL_BED_PO2_GE_40MMHG"), ("neg_fail_retired_1800_loading_cap", _patch_sync(om_y_t2, {"areal_loading_ieq_cm2": 1800.0}), "FAIL", False, "AREAL_LOADING_EXCEEDS_OMENTUM_ENVELOPE_CAP_1500_IEQ_CM2"), ("neg_fail_tier1_fibrin_gt_10um_at_36mmHg", _patch_sync(om_d, {"measured_fibrin_capsule_um": 11.0}), "FAIL", False, "TIER1_FIBRIN_CAPSULE_EXCEEDS_10UM_CEILING_AT_BED_LT_40MMHG"), ("neg_fail_retired_19um_fibrin", _patch_sync(om_y_t2, {"measured_fibrin_capsule_um": 19.0}), "FAIL", False, "FIBRIN_CAPSULE_EXCEEDS_12UM_MAX_ENVELOPE_CEILING"), ("neg_fail_unilateral_perfusion", _patch_sync(om_d, {"bilateral_vascular_perfusion_verified": False}), "FAIL", False, "UNILATERAL_PERFUSION_ANOXIA_FAIL"), ("neg_fail_back_to_back_folded_stacking", _patch_sync(om_d, {"back_to_back_unperfused_stacking": True}), "FAIL", False, "BACK_TO_BACK_UNPERFUSED_FOLDED_STACKING_PROHIBITED"), ("neg_fail_cluster_max_diam_200um", _patch_sync(om_d, {"cluster_max_diam_um": 200.0}), "FAIL", False, "CLUSTER_MAX_DIAM_EXCEEDS_65UM_SIEVING_LAW"),