# 51. R07-B1d: Standalone verify_iip0043 (legacy_evaluator=None) STILL accepts plain whole-graft-only # bank archives across BOTH store layouts (standalone evidence boundary strictly preserved)! r07_standalone_ok = True for st_pl in (reg_plain_r07, dir_plain_r07): r_sa = g0v_fn(g0v_clin_plain, trusted_qualification_store=st_pl, openislet_root=openislet_root) pqa_sa = r_sa["lot_binding"]["prior_qualification_authentication"] if not ( r_sa["verdict"] == "PASS_WHOLEGRAFT_LOT_RELEASE_SURROGATE" and pqa_sa.get("archived_bank_payload_verified") is True and pqa_sa.get("archived_bank_payload_live_g0v_revalidation_passed") is True and pqa_sa.get("archived_bank_payload_live_legacy_revalidation_passed") is None ): r07_standalone_ok = False cases.append({ "case": "r07_b1_both_layouts_standalone_verify_iip0043_accepts_plain_wholegraft_bank_archive", "expected_verdict": "PASS_WHOLEGRAFT_LOT_RELEASE_SURROGATE", "actual_verdict": "PASS_WHOLEGRAFT_LOT_RELEASE_SURROGATE" if r07_standalone_ok else "UNEXPECTED_HOLD", "operational_tier": "LOT_RELEASE_SURROGATE", "legacy_passed": None, "legacy_tier": None, "legacy_resolved_pvid": None, "gate0v_passed": True if r07_standalone_ok else False, "gate0v_verdict": "PASS_WHOLEGRAFT_LOT_RELEASE_SURROGATE" if r07_standalone_ok else "HOLD", "expected_token": None, "exit_code": 0 if r07_standalone_ok else -1, "archived_bank_payload_verified": True if r07_standalone_ok else None, "archived_bank_payload_live_g0v_revalidation_passed": True if r07_standalone_ok else None, "archived_bank_payload_live_legacy_revalidation_passed": None, "hard_stops": [], "holds": [], "passed": r07_standalone_ok, }) # 52. R07-B2: PAIRED_HIGH_INPUT_ALIQUOT with mismatched counts & well-formed 64-hex digest -> HOLD (exit 2), NEVER PASS! g0v_phi_c = copy.deepcopy(g0v_bank) arm_phi_c = g0v_phi_c["gate0v_kill_stress_ap1903"]["active_or_persistent_cvb4_infection"]["beta"] arm_phi_c["infected_surveillance_aliquot_linkage_mode"] = "PAIRED_HIGH_INPUT_ALIQUOT" arm_phi_c["paired_aliquot_linkage_evidence_sha256"] = v38._valid_digest("r07_b2_comp_paired_digest") arm_phi_c["ap1903_72h_input_n"] = 100000 arm_phi_c["ap1903_72h_viable_survivors_k"] = 0 arm_phi_c["pre_ap1903_lineage_input_cells_n"] = 5_141_940 arm_phi_c["post_ap1903_viable_survivors_total_n"] = 2 arm_phi_c["survivors_scored_n"] = 2 v38.reconcile_fixture_per_unit_counts(g0v_phi_c) g0v_phi_c["payload_sha256"] = v38.compute_canonical_lot_sha256(g0v_phi_c) _run_case( "r07_b2_paired_high_input_mismatched_counts_valid_digest_composite_hold", _make_composite_bundle(bank_lot_id, mcb_id, pv_lead, leg_bank, g0v_phi_c), "HOLD_COMPOSITE_RELEASE", expected_legacy_pass=True, expected_gate0v_pass=False, expected_token="HOLD_NON_SAME_ALIQUOT_UNVERIFIED_COUNT_RECONCILIATION", ) # 53. R07-M1: Zero-event 0/1,000 straddling interval under low vehicle control -> HOLD with straddling token! g0v_zstrad_c = copy.deepcopy(g0v_bank) arm_zsc = g0v_zstrad_c["gate0v_kill_stress_ap1903"]["er_stress_tg_or_tm"]["alpha"] arm_zsc["veh_24h_viable_n"] = 50 arm_zsc["veh_24h_input_n"] = 1000 arm_zsc["ap1903_24h_input_n"] = 1000 arm_zsc["ap1903_24h_viable_survivors_k"] = 0 v38.reconcile_fixture_per_unit_counts(g0v_zstrad_c) g0v_zstrad_c["payload_sha256"] = v38.compute_canonical_lot_sha256(g0v_zstrad_c) _run_case( "r07_m1_zero_event_0of1000_straddling_under_low_veh_composite_hold", _make_composite_bundle(bank_lot_id, mcb_id, pv_lead, leg_bank, g0v_zstrad_c), "HOLD_COMPOSITE_RELEASE", expected_legacy_pass=True, expected_gate0v_pass=False, expected_token="HOLD_INDETERMINATE_INTERVAL_STRADDLING_CAP_UNDER_CONTROL_HOLD", ) # ------------------------------------------------------------------ # Round-08 Final-Closure Parity Matrix (B1 Direct vs Archived Envelope Parity) # ------------------------------------------------------------------ def _run_r08_b1_parity_case( case_name: str, mutate_archive_fn: Callable[[Dict[str, Any]], None], expected_direct_hold: str, ) -> None: arch_r08 = copy.deepcopy(bank_bundle) mutate_archive_fn(arch_r08) arch_r08["payload_sha256"] = compute_composite_payload_sha256(arch_r08) direct_r08 = evaluate_composite_clinical_release( arch_r08, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, openislet_root=openislet_root, ) brec_r08 = copy.deepcopy(auth_bank_rec) brec_r08["bank_payload_sha256"] = arch_r08["payload_sha256"] brec_r08["sha256"] = compute_qualification_record_sha256(brec_r08) g0v_surr_r08 = 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=brec_r08["sha256"], openislet_root=openislet_root, ) clin_r08_file = Path(td) / f"r08_b1_{case_name}_clin.json" clin_r08_file.write_text( json.dumps(_make_composite_bundle(clin_lot_id, mcb_id, pv_lead, leg_clin, g0v_surr_r08)), encoding="utf-8", ) reg_r08 = Path(td) / f"r08_b1_{case_name}_reg.json" dir_r08 = Path(td) / f"r08_b1_{case_name}_dir" v38.write_record_to_trusted_qualification_store( reg_r08, brec_r08, category="bank_qualifications", archived_payload=arch_r08 ) v38.write_record_to_trusted_qualification_store( dir_r08, brec_r08, category="bank_qualifications", archived_payload=arch_r08 ) parity_ok = bool( direct_r08["composite_verdict"] == "HOLD_COMPOSITE_RELEASE" and expected_direct_hold in direct_r08["holds"] ) last_holds_r08: List[str] = [] for st_r08 in (reg_r08, dir_r08): r_arch, rc_arch = evaluate_composite_lot_file( clin_r08_file, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, trusted_qualification_store=st_r08, openislet_root=openislet_root, ) last_holds_r08 = r_arch["holds"] pqa_arch = r_arch["prior_qualification_authentication"] if not ( rc_arch == 2 and r_arch["composite_verdict"] == "HOLD_COMPOSITE_RELEASE" and expected_direct_hold in r_arch["holds"] and "HOLD_ARCHIVED_BANK_ENVELOPE_MISMATCH" in r_arch["holds"] and "HOLD_MISSING_OR_INVALID_ARCHIVED_BANK_PAYLOAD" in r_arch["holds"] and pqa_arch.get("archived_bank_payload_verified") is False and pqa_arch.get("archived_bank_payload_live_revalidation_passed") is False and pqa_arch.get("archived_bank_payload_live_g0v_revalidation_passed") is False and pqa_arch.get("archived_bank_payload_live_legacy_revalidation_passed") is False and pqa_arch.get("archived_bank_payload_live_composite_revalidation_passed") is False ): parity_ok = False cases.append({ "case": case_name, "expected_verdict": "HOLD_COMPOSITE_RELEASE", "actual_verdict": "HOLD_COMPOSITE_RELEASE" if parity_ok else "PARITY_DRIFT_OR_UNEXPECTED_PASS", "operational_tier": "LOT_RELEASE_SURROGATE", "legacy_passed": True, "legacy_tier": LEGACY_PASS_TIER, "legacy_resolved_pvid": pv_lead, "gate0v_passed": False, "gate0v_verdict": "HOLD_INCOMPLETE_OR_UNDERPOWERED", "expected_token": expected_direct_hold, "exit_code": 2 if parity_ok else -1, "direct_verdict": direct_r08["composite_verdict"], "archived_bank_payload_verified": False if parity_ok else None, "archived_bank_payload_live_revalidation_passed": False if parity_ok else None, "hard_stops": [], "holds": last_holds_r08[:5], "passed": parity_ok, }) # 55. R08-B1a: Conflicting qualification_tier=BANK_QUALIFICATION + operational_tier=LOT_RELEASE_SURROGATE # held identically in BOTH direct composite AND archived composite across BOTH store layouts! _run_r08_b1_parity_case( "r08_b1a_both_layouts_conflicting_archived_operational_tier_matches_direct_hold_exit_2", lambda doc: doc.update( qualification_tier="BANK_QUALIFICATION", operational_tier="LOT_RELEASE_SURROGATE" ), "HOLD_COMPOSITE_OPERATIONAL_TIER_MISMATCH", ) # 56. R08-B1b: Missing top-level canonical product_variant_id (alias-only product_variant) # held identically in BOTH direct composite AND archived composite across BOTH store layouts! _run_r08_b1_parity_case( "r08_b1b_both_layouts_alias_only_missing_top_product_variant_id_matches_direct_hold_exit_2", lambda doc: doc.__setitem__("product_variant", doc.pop("product_variant_id")), "HOLD_COMPOSITE_MISSING_TOP_PRODUCT_VARIANT_ID", ) # 57. R08-B1c: Conflicting top-level qualification_tier=LOT_RELEASE_SURROGATE (with operational_tier # omitted or BANK_QUALIFICATION) held identically in BOTH direct AND archived across BOTH layouts! _run_r08_b1_parity_case( "r08_b1c_both_layouts_conflicting_top_qualification_tier_matches_direct_hold_exit_2", lambda doc: doc.update( qualification_tier="LOT_RELEASE_SURROGATE", operational_tier="BANK_QUALIFICATION" ), "HOLD_COMPOSITE_OPERATIONAL_TIER_MISMATCH", ) # 58. R08-B1d: Conflicting nested gate0v operational_tier=LOT_RELEASE_SURROGATE held identically # in BOTH direct AND archived across BOTH store layouts! def _mut_nested_g0v_op_tier(doc: Dict[str, Any]) -> None: doc["gate0v_wholegraft_payload"]["operational_tier"] = "LOT_RELEASE_SURROGATE" doc["gate0v_wholegraft_payload"]["payload_sha256"] = v38.compute_canonical_lot_sha256( doc["gate0v_wholegraft_payload"] ) _run_r08_b1_parity_case( "r08_b1d_both_layouts_conflicting_nested_gate0v_operational_tier_matches_direct_hold_exit_2", _mut_nested_g0v_op_tier, "HOLD_COMPOSITE_OPERATIONAL_TIER_MISMATCH", ) # ------------------------------------------------------------------ # Round-09 Final-Closure Regressions (R09-B1 Strict JSON & R09-M1 NW-08 CLI Coupling) # ------------------------------------------------------------------ # 59. R09-B1a: Direct composite lot file rejects top-level, nested, and unicode-escaped # duplicate JSON object keys with structured HOLD_COMPOSITE_RELEASE (exit 2)! raw_bank_str = json.dumps(bank_bundle, sort_keys=True) dup_top_f = Path(td) / "r09_b1a_top_dup.json" dup_top_f.write_text( '{"product_variant_id": "ISLET1_FAKE_VARIANT", ' + raw_bank_str[1:], encoding="utf-8", ) dup_nested_f = Path(td) / "r09_b1a_nested_dup.json" dup_nested_f.write_text( raw_bank_str.replace( '"gate0v_wholegraft_payload": {', '"gate0v_wholegraft_payload": {"qualification_tier": "LOT_RELEASE_SURROGATE", ', 1, ), encoding="utf-8", ) dup_uni_f = Path(td) / "r09_b1a_unicode_dup.json" dup_uni_f.write_text( '{"lot_\\u0069d": "FAKE-LOT", ' + raw_bank_str[1:], encoding="utf-8", ) r09_d1a_ok = True r09_d1a_holds: List[str] = [] for f_dup in (dup_top_f, dup_nested_f, dup_uni_f): res_d, rc_d = evaluate_composite_lot_file( f_dup, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, openislet_root=openislet_root, ) r09_d1a_holds = res_d["holds"] if not ( rc_d == 2 and res_d["composite_verdict"] == "HOLD_COMPOSITE_RELEASE" and "HOLD_COMPOSITE_AMBIGUOUS_OR_NONCANONICAL_LOT_JSON:DUPLICATE_JSON_KEY" in res_d["holds"] ): r09_d1a_ok = False cases.append({ "case": "r09_b1a_direct_composite_lot_file_top_nested_unicode_duplicate_keys_hold_exit_2", "expected_verdict": "HOLD_COMPOSITE_RELEASE", "actual_verdict": "HOLD_COMPOSITE_RELEASE" if r09_d1a_ok else "UNEXPECTED_ACCEPT",