"mcb_id": mcb_id, "product_variant_id": pv_lead, "qualification_tier": "BANK_QUALIFICATION", "antiviral_genotype_stratum": "TYK2_WT__IFIH1_WT_OR_A946T", } stub_b4_sha = v38.compute_canonical_lot_sha256(stub_b4) stub_b4["payload_sha256"] = stub_b4_sha _run_r06_b4_both_layouts("r06_b4_both_layouts_metadata_only_stub_archive_held_exit_2", stub_b4, stub_b4_sha) # 44. (ii) Tampered internal payload_sha256 on archived composite bank bundle tamp_b4 = copy.deepcopy(bank_bundle) tamp_b4_sha = compute_composite_payload_sha256(tamp_b4) tamp_b4["payload_sha256"] = hashlib.sha256(b"TAMPERED_COMP_ARCHIVE_SELF_SHA").hexdigest() _run_r06_b4_both_layouts("r06_b4_both_layouts_tampered_internal_payload_sha256_held_exit_2", tamp_b4, tamp_b4_sha) # 45. (iii) Contradictory nested mcb_id inside archived composite bank bundle contra_g0v_b4 = v38.build_passing_reference_payload( lot_id=bank_lot_id, mcb_id="MCB-NESTED-CONFLICT-999", product_variant_id=pv_lead, qualification_tier="BANK_QUALIFICATION", openislet_root=openislet_root, ) contra_b4 = _make_composite_bundle(bank_lot_id, mcb_id, pv_lead, leg_bank, contra_g0v_b4) _run_r06_b4_both_layouts("r06_b4_both_layouts_contradictory_nested_mcb_id_held_exit_2", contra_b4, contra_b4["payload_sha256"]) # 46. (iv) Structurally complete archived bank bundle that FAILS BANK_QUALIFICATION fail_g0v_b4 = copy.deepcopy(g0v_bank) fail_g0v_b4["gate0v_b_infectious_challenge"]["pathogens"]["cvb4_e2"]["day28_persistence_by_lineage"]["pericyte"]["stage2_confirmed_infectious_k"] = 1 fail_g0v_b4["payload_sha256"] = v38.compute_canonical_lot_sha256(fail_g0v_b4) fail_bundle_b4 = _make_composite_bundle(bank_lot_id, mcb_id, pv_lead, leg_bank, fail_g0v_b4) _run_r06_b4_both_layouts("r06_b4_both_layouts_structurally_complete_failing_archive_held_exit_2", fail_bundle_b4, fail_bundle_b4["payload_sha256"]) # 47. R06-M3: Autologous process record carrying allogeneic PASS_WHOLEGRAFT_BANK_QUALIFICATION fails closed! bad_m3_proc = v38.build_authenticated_process_qualification_record( product_variant_id=pv_d1a, process_qual_id="PROCQUAL-M3-WRONG-BANK-VERDICT", underlying_gate0v_verdict="PASS_WHOLEGRAFT_BANK_QUALIFICATION", ) v38.write_record_to_trusted_qualification_store(trusted_store, bad_m3_proc, category="process_qualifications") g0v_m3_bad = v38.build_passing_reference_payload( lot_id=clin_lot_id, mcb_id=mcb_id, product_variant_id=pv_d1a, qualification_tier="AUTOLOGOUS_D1B_PROCESS_QUAL", process_qualification_ref_sha256=bad_m3_proc["sha256"], openislet_root=openislet_root, ) _run_case( "r06_m3_autologous_process_record_with_bank_pass_verdict_held", _make_composite_bundle(clin_lot_id, mcb_id, pv_d1a, leg_d1a_clin, g0v_m3_bad), "HOLD_COMPOSITE_RELEASE", store_path=trusted_store, expected_gate0v_pass=False, expected_token="UNDERLYING_GATE0V_VERDICT_NOT_AUTOLOGOUS_PROCESS_QUAL_PASS", ) # ------------------------------------------------------------------ # Round-07 Final-Closure Differential Matrix (B1, B2, M1) # ------------------------------------------------------------------ # 48. R07-B1a: Plain whole-graft-only bank archive (NO archived legacy observations) in BOTH store # layouts (embedded-dict registry JSON AND file-backed directory store) MUST BE REJECTED by # composite clinical release (exit 2, archived_bank_payload_live_legacy_revalidation_passed=False, # HOLD_MISSING_ARCHIVED_LEGACY_PAYLOAD_FOR_COMPOSITE_RELEASE, NEVER PASS_COMPOSITE_CLINICAL_RELEASE)! plain_bank_rec = copy.deepcopy(auth_bank_rec) plain_bank_rec["bank_payload_sha256"] = g0v_bank["payload_sha256"] plain_bank_rec["sha256"] = compute_qualification_record_sha256(plain_bank_rec) g0v_clin_plain = v38.build_passing_reference_payload( lot_id=clin_lot_id, mcb_id=mcb_id, product_variant_id=pv_lead, qualification_tier="LOT_RELEASE_SURROGATE", bridged_mcb_qualification_sha256=plain_bank_rec["sha256"], openislet_root=openislet_root, ) clin_plain_bundle = _make_composite_bundle(clin_lot_id, mcb_id, pv_lead, leg_clin, g0v_clin_plain) clin_plain_file = Path(td) / "r07_b1_clin_plain_bundle.json" clin_plain_file.write_text(json.dumps(clin_plain_bundle), encoding="utf-8") reg_plain_r07 = Path(td) / "r07_b1_reg_plain.json" dir_plain_r07 = Path(td) / "r07_b1_dir_plain" v38.write_record_to_trusted_qualification_store( reg_plain_r07, plain_bank_rec, category="bank_qualifications", archived_payload=g0v_bank ) v38.write_record_to_trusted_qualification_store( dir_plain_r07, plain_bank_rec, category="bank_qualifications", archived_payload=g0v_bank ) r07_plain_comp_ok = True last_plain_holds: List[str] = [] for st_pl in (reg_plain_r07, dir_plain_r07): r_pl, rc_pl = evaluate_composite_lot_file( clin_plain_file, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, trusted_qualification_store=st_pl, openislet_root=openislet_root, ) last_plain_holds = r_pl["holds"] pqa_pl = r_pl["prior_qualification_authentication"] if not ( rc_pl == 2 and r_pl["composite_verdict"] == "HOLD_COMPOSITE_RELEASE" and pqa_pl.get("archived_bank_payload_verified") is False and pqa_pl.get("archived_bank_payload_live_g0v_revalidation_passed") is True and pqa_pl.get("archived_bank_payload_live_legacy_revalidation_passed") is False and "HOLD_MISSING_ARCHIVED_LEGACY_PAYLOAD_FOR_COMPOSITE_RELEASE" in r_pl["holds"] and "HOLD_MISSING_OR_INVALID_ARCHIVED_BANK_PAYLOAD" in r_pl["holds"] and "HOLD_UNVERIFIED_EXTERNAL_APPROVAL_STORE" in r_pl["holds"] ): r07_plain_comp_ok = False cases.append({ "case": "r07_b1_both_layouts_plain_standalone_wholegraft_bank_archive_rejected_exit_2", "expected_verdict": "HOLD_COMPOSITE_RELEASE", "actual_verdict": "HOLD_COMPOSITE_RELEASE" if r07_plain_comp_ok else "UNEXPECTED_PASS_OR_META", "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": "HOLD_MISSING_ARCHIVED_LEGACY_PAYLOAD_FOR_COMPOSITE_RELEASE", "exit_code": 2 if r07_plain_comp_ok else -1, "archived_bank_payload_verified": False if r07_plain_comp_ok else None, "archived_bank_payload_live_g0v_revalidation_passed": True if r07_plain_comp_ok else None, "archived_bank_payload_live_legacy_revalidation_passed": False if r07_plain_comp_ok else None, "hard_stops": [], "holds": last_plain_holds[:4], "passed": r07_plain_comp_ok, }) # 49. R07-B1b: Composite bank archive with FAILING archived legacy observations (both hard-stop # legacy kill failure AND incomplete legacy observations) in BOTH store layouts -> REJECTED (exit 2)! leg_bank_fail_s9 = copy.deepcopy(leg_bank) leg_bank_fail_s9["obs_icasp9_log10_kill"] = 1.0 leg_bank_incomplete = { "current_lot_id": bank_lot_id, "mcb_id": mcb_id, "product_variant_id": pv_lead, "obs_icasp9_log10_kill": 4.6, "obs_tp53_ppm1d_bcor_vaf": 0.0, "obs_mcb_effective_clonogenic_trials": 299573228.0, "obs_gate0v_day28_persistent_vp1_ie1_cells_scored": 5990.0, } r07_fail_leg_ok = True last_fail_leg_holds: List[str] = [] for sub_tag, bad_leg_obs in (("s9_hard_stop", leg_bank_fail_s9), ("incomplete_panel", leg_bank_incomplete)): bad_leg_bundle = _make_composite_bundle(bank_lot_id, mcb_id, pv_lead, bad_leg_obs, g0v_bank) bad_leg_rec = copy.deepcopy(auth_bank_rec) bad_leg_rec["bank_payload_sha256"] = bad_leg_bundle["payload_sha256"] bad_leg_rec["sha256"] = compute_qualification_record_sha256(bad_leg_rec) g0v_surr_bl = v38.build_passing_reference_payload( lot_id=clin_lot_id, mcb_id=mcb_id, product_variant_id=pv_lead, qualification_tier="LOT_RELEASE_SURROGATE", bridged_mcb_qualification_sha256=bad_leg_rec["sha256"], openislet_root=openislet_root, ) bl_file = Path(td) / f"r07_b1_fail_leg_{sub_tag}_clin.json" bl_file.write_text( json.dumps(_make_composite_bundle(clin_lot_id, mcb_id, pv_lead, leg_clin, g0v_surr_bl)), encoding="utf-8", ) reg_bl = Path(td) / f"r07_b1_fail_leg_{sub_tag}_reg.json" dir_bl = Path(td) / f"r07_b1_fail_leg_{sub_tag}_dir" v38.write_record_to_trusted_qualification_store( reg_bl, bad_leg_rec, category="bank_qualifications", archived_payload=bad_leg_bundle ) v38.write_record_to_trusted_qualification_store( dir_bl, bad_leg_rec, category="bank_qualifications", archived_payload=bad_leg_bundle ) for st_bl in (reg_bl, dir_bl): r_bl, rc_bl = evaluate_composite_lot_file( bl_file, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, trusted_qualification_store=st_bl, openislet_root=openislet_root, ) last_fail_leg_holds = r_bl["holds"] pqa_bl = r_bl["prior_qualification_authentication"] if not ( rc_bl == 2 and r_bl["composite_verdict"] == "HOLD_COMPOSITE_RELEASE" and pqa_bl.get("archived_bank_payload_verified") is False and pqa_bl.get("archived_bank_payload_live_legacy_revalidation_passed") is False and "HOLD_MISSING_OR_INVALID_ARCHIVED_BANK_PAYLOAD" in r_bl["holds"] and any("ARCHIVED_LEGACY_REVALIDATION_FAILED" in h for h in r_bl["holds"]) ): r07_fail_leg_ok = False cases.append({ "case": "r07_b1_both_layouts_composite_bank_archive_failing_legacy_obs_rejected_exit_2", "expected_verdict": "HOLD_COMPOSITE_RELEASE", "actual_verdict": "HOLD_COMPOSITE_RELEASE" if r07_fail_leg_ok else "UNEXPECTED_PASS_OR_META", "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": "ARCHIVED_LEGACY_REVALIDATION_FAILED", "exit_code": 2 if r07_fail_leg_ok else -1, "archived_bank_payload_verified": False if r07_fail_leg_ok else None, "archived_bank_payload_live_legacy_revalidation_passed": False if r07_fail_leg_ok else None, "hard_stops": [], "holds": last_fail_leg_holds[:4], "passed": r07_fail_leg_ok, }) # 50. R07-B1c: Complete passing dual-replay composite bank archive in BOTH store layouts -> ACCEPTED # (PASS_COMPOSITE_CLINICAL_RELEASE, exit 0) with explicit BOTH live replay booleans == True! r07_dual_pass_ok = True for st_ok in (trusted_store, trusted_dir): r_dp, rc_dp = evaluate_composite_lot_file( clin_bundle_file, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, trusted_qualification_store=st_ok, openislet_root=openislet_root, ) pqa_dp = r_dp["prior_qualification_authentication"] if not ( rc_dp == 0 and r_dp["composite_verdict"] == "PASS_COMPOSITE_CLINICAL_RELEASE" and pqa_dp.get("archived_bank_payload_verified") is True and pqa_dp.get("archived_bank_payload_live_g0v_revalidation_passed") is True and pqa_dp.get("archived_bank_payload_live_legacy_revalidation_passed") is True ): r07_dual_pass_ok = False cases.append({ "case": "r07_b1_both_layouts_complete_dual_replay_composite_bank_archive_passes_exit_0", "expected_verdict": "PASS_COMPOSITE_CLINICAL_RELEASE", "actual_verdict": "PASS_COMPOSITE_CLINICAL_RELEASE" if r07_dual_pass_ok else "UNEXPECTED_HOLD_OR_META", "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": None, "exit_code": 0 if r07_dual_pass_ok else -1, "archived_bank_payload_verified": True if r07_dual_pass_ok else None, "archived_bank_payload_live_g0v_revalidation_passed": True if r07_dual_pass_ok else None, "archived_bank_payload_live_legacy_revalidation_passed": True if r07_dual_pass_ok else None, "hard_stops": [], "holds": [], "passed": r07_dual_pass_ok, })