if len(primary_entries) != 1: fail_reasons.append("FAIL_CONSTRUCT_SWITCH_REGISTRY_REQUIRES_EXACTLY_ONE_PRIMARY") construct_verified = False else: p_sw_id, p_sw_meta = primary_entries[0] p_sw_locus = p_sw_meta.get("locus") p_sw_sha = p_sw_meta.get("sequence_sha256") p_sw_var = p_sw_meta.get("variant") prod_spec = CANONICAL_PRIMARY_SWITCH_SPEC_BY_PRODUCT.get(product_id_str) if product_id_str is not None else None prim_ok = sw_entries_ok and bool(valid_seq_shas) if prod_spec is not None: if p_sw_id not in prod_spec["allowed_switch_ids"]: fail_reasons.append("FAIL_CONSTRUCT_PRIMARY_SWITCH_ID_PRODUCT_MISMATCH") prim_ok = False if not _is_clean_str(p_sw_locus) or p_sw_locus not in prod_spec["allowed_loci"]: fail_reasons.append("FAIL_CONSTRUCT_PRIMARY_SWITCH_LOCUS_PRODUCT_MISMATCH") prim_ok = False if p_sw_id in ("ACTB::iCasp8", "ACTB_iCasp8"): if p_sw_var == "D315A": fail_reasons.append("FAIL_CONSTRUCT_SWITCH_REGISTRY_INVALID_VARIANT") prim_ok = False registered_primary_benchmark_arm = "ACTB_iCasp8" registered_primary_is_icasp8 = True registered_primary_is_d315a = False elif p_sw_id in ("TBP::iCasp9_D315A", "TBP_iCasp9_D315A", "TBP::iCasp9(D315A)") or ( p_sw_id == "TBP::iCasp9" and p_sw_var == "D315A" ): if not prod_spec["allows_d315a"]: fail_reasons.append("FAIL_CONSTRUCT_PRIMARY_SWITCH_D315A_PROHIBITED_FOR_PRODUCT") prim_ok = False registered_primary_benchmark_arm = "TBP_iCasp9_D315A" registered_primary_is_icasp8 = False registered_primary_is_d315a = True elif p_sw_id in ("TBP::iCasp9", "TBP::iCasp9_WT", "TBP_iCasp9_WT") and p_sw_var in (None, "WT"): registered_primary_benchmark_arm = "TBP_iCasp9_WT" registered_primary_is_icasp8 = False registered_primary_is_d315a = False elif p_sw_id == "AAVS1::iCasp9": registered_primary_benchmark_arm = None registered_primary_is_icasp8 = False registered_primary_is_d315a = False else: fail_reasons.append("FAIL_CONSTRUCT_PRIMARY_SWITCH_ID_UNRECOGNIZED") prim_ok = False if prim_ok: registered_primary_switch_id = p_sw_id registered_primary_switch_locus = p_sw_locus registered_primary_switch_verified = True else: construct_verified = False # Verify secondary switch requirement strictly from canonical product spec / arm manifest if prod_spec["requires_secondary"]: if len(secondary_entries) != 1: fail_reasons.append("FAIL_DUAL_SWITCH_ARM_MISSING_SECONDARY_SWITCH_IN_REGISTRY") construct_verified = False else: s_sw_id, s_sw_meta = secondary_entries[0] s_sw_locus = s_sw_meta.get("locus") s_sw_sha = s_sw_meta.get("sequence_sha256") sec_ok = sw_entries_ok and bool(valid_seq_shas) if s_sw_id not in CANONICAL_SECONDARY_SWITCH_IDS: fail_reasons.append("FAIL_CONSTRUCT_SECONDARY_SWITCH_ID_MISMATCH") sec_ok = False if not _is_clean_str(s_sw_locus) or s_sw_locus not in CANONICAL_SECONDARY_SWITCH_LOCI: fail_reasons.append("FAIL_CONSTRUCT_SECONDARY_SWITCH_LOCUS_MISMATCH") sec_ok = False if _is_nonzero_sha256_hex(s_sw_sha) and _is_nonzero_sha256_hex(p_sw_sha) and s_sw_sha == p_sw_sha: fail_reasons.append("FAIL_CONSTRUCT_SECONDARY_SWITCH_SEQUENCE_ALIASES_PRIMARY") sec_ok = False if sec_ok: registered_secondary_switch_id = s_sw_id registered_secondary_switch_locus = s_sw_locus registered_secondary_switch_seq_sha = s_sw_sha registered_secondary_switch_verified = True else: construct_verified = False else: if len(secondary_entries) > 0: fail_reasons.append("FAIL_SINGLE_SWITCH_ARM_UNEXPECTED_SECONDARY_SWITCH_IN_REGISTRY") construct_verified = False else: construct_verified = False # 1. Authentic genomic sequence provenance, construct-digest-bound cHS4 FI VEZF1 & CBX3 700-bp UCOE barrier rules, & DNA hygiene req_bool("authentic_genomic_provenance_only", expected=True, fail_code="FAIL_SYNTHETIC_OR_RNG_FILLER_DNA_PROHIBITED") uses_chs4_fi = req_bool("uses_unqualified_chs4_fi_vezf1_variant") if construct_contains_chs4_fi and uses_chs4_fi is False: fail_reasons.append("FAIL_CONSTRUCT_MANIFEST_CHS4_FI_DECLARATION_CONTRADICTION") chs4_barrier_required = bool(uses_chs4_fi is True or construct_contains_chs4_fi) chs4_barrier_verified = True if chs4_barrier_required: chs4_barrier_verified = False if payload.get("chs4_barrier_assay_record") is None: hold_reasons.append("HOLD_CHS4_FI_VEZF1_VARIANT_UNQUALIFIED_PENDING_ARCHIVED_BARRIER_ASSAY") else: b_rec, b_ok = _resolve_archived_record( "chs4_barrier_assay_record", prefix="CHS4_BARRIER_ASSAY", expected_gate_source=CHS4_BARRIER_GATE_SOURCE, allowed_decisions=frozenset({"PASS", "SYNTHETIC_SELF_TEST_PASS"}), role="supporting", wetlab_allowed_decisions=frozenset({"PASS"}), synthetic_allowed_decisions=frozenset({"SYNTHETIC_SELF_TEST_PASS"}), ) if b_rec is not None: t_cid = b_rec.get("tested_construct_id") t_csha = b_rec.get("tested_construct_sha256") t_seq_sha = b_rec.get("tested_sequence_sha256") meth_pct = b_rec.get("methylation_protection_retained_pct") if not construct_verified or not construct_seq_sha_map_verified: fail_reasons.append("FAIL_CHS4_BARRIER_ASSAY_UNVERIFIED_CONSTRUCT_MANIFEST") b_ok = False elif not _is_clean_str(t_cid) or t_cid not in construct_seq_sha_map_verified: fail_reasons.append("FAIL_CHS4_BARRIER_ASSAY_CONSTRUCT_ID_MISMATCH") b_ok = False else: # Resolve tested_construct_id against archived construct_manifest_record digest map! registered_cid_digest = construct_seq_sha_map_verified[t_cid] if registered_cid_digest != CHS4_0C9_V090_SEQ_SHA256: fail_reasons.append("FAIL_CHS4_BARRIER_ASSAY_CONSTRUCT_ID_REGISTERED_DIGEST_MISMATCH") b_ok = False if not _is_nonzero_sha256_hex(t_csha) or t_csha != registered_cid_digest or t_csha != CHS4_0C9_V090_SEQ_SHA256: fail_reasons.append("FAIL_CHS4_BARRIER_ASSAY_CONSTRUCT_SHA256_MISMATCH") b_ok = False if t_seq_sha is not None and (not _is_nonzero_sha256_hex(t_seq_sha) or t_seq_sha != registered_cid_digest or t_seq_sha != CHS4_0C9_V090_SEQ_SHA256): fail_reasons.append("FAIL_CHS4_BARRIER_ASSAY_SEQUENCE_SHA256_MISMATCH") b_ok = False if not _is_finite_number(meth_pct) or float(meth_pct) < 80.0 or float(meth_pct) > 100.0: fail_reasons.append("FAIL_CHS4_BARRIER_METHYLATION_PROTECTION_LT_80PCT") b_ok = False chs4_barrier_verified = b_ok # Construct-linked CBX3 700-bp UCOE barrier & aberrant-splicing/promoter-leakage archive check (Muller-Kuller et al. 2015, PMID:25605798) uses_cbx3_ucoe = req_bool("uses_cbx3_700bp_ucoe_candidate") if construct_contains_cbx3_ucoe and uses_cbx3_ucoe is False: fail_reasons.append("FAIL_CONSTRUCT_MANIFEST_CBX3_UCOE_DECLARATION_CONTRADICTION") cbx3_barrier_required = bool(uses_cbx3_ucoe is True or construct_contains_cbx3_ucoe) cbx3_barrier_verified = True if cbx3_barrier_required: cbx3_barrier_verified = False if payload.get("cbx3_barrier_assay_record") is None: hold_reasons.append("HOLD_CBX3_700BP_UCOE_UNQUALIFIED_PENDING_ARCHIVED_BARRIER_AND_SPLICING_ASSAY") else: c_rec, c_ok = _resolve_archived_record( "cbx3_barrier_assay_record", prefix="CBX3_BARRIER_ASSAY", expected_gate_source=CBX3_BARRIER_GATE_SOURCE, allowed_decisions=frozenset({"PASS", "SYNTHETIC_SELF_TEST_PASS"}), role="supporting", wetlab_allowed_decisions=frozenset({"PASS"}), synthetic_allowed_decisions=frozenset({"SYNTHETIC_SELF_TEST_PASS"}), ) if c_rec is not None: c_tid = c_rec.get("tested_construct_id") c_tsha = c_rec.get("tested_construct_sha256") c_sseq_sha = c_rec.get("tested_sequence_sha256") c_stab = c_rec.get("long_term_expression_stability_pct") c_days = c_rec.get("differentiation_stability_days") c_aberrant = c_rec.get("aberrant_splicing_detected") c_splice_pct = c_rec.get("aberrant_splice_junction_pct") c_leak_clear = c_rec.get("promoter_leakage_readthrough_clear") if not construct_verified or not construct_seq_sha_map_verified: fail_reasons.append("FAIL_CBX3_BARRIER_ASSAY_UNVERIFIED_CONSTRUCT_MANIFEST") c_ok = False elif not _is_clean_str(c_tid) or c_tid not in construct_seq_sha_map_verified: fail_reasons.append("FAIL_CBX3_BARRIER_ASSAY_CONSTRUCT_ID_MISMATCH") c_ok = False else: reg_cbx3_digest = construct_seq_sha_map_verified[c_tid] if reg_cbx3_digest != CBX3_700BP_UCOE_SEQ_SHA256: fail_reasons.append("FAIL_CBX3_BARRIER_ASSAY_CONSTRUCT_ID_REGISTERED_DIGEST_MISMATCH") c_ok = False if not _is_nonzero_sha256_hex(c_tsha) or c_tsha != reg_cbx3_digest or c_tsha != CBX3_700BP_UCOE_SEQ_SHA256: fail_reasons.append("FAIL_CBX3_BARRIER_ASSAY_CONSTRUCT_SHA256_MISMATCH") c_ok = False if c_sseq_sha is not None and (not _is_nonzero_sha256_hex(c_sseq_sha) or c_sseq_sha != reg_cbx3_digest or c_sseq_sha != CBX3_700BP_UCOE_SEQ_SHA256): fail_reasons.append("FAIL_CBX3_BARRIER_ASSAY_SEQUENCE_SHA256_MISMATCH") c_ok = False if c_stab is None: hold_reasons.append("HOLD_MISSING_CBX3_EXPRESSION_STABILITY_PCT") c_ok = False elif not _is_finite_number(c_stab) or float(c_stab) < 80.0 or float(c_stab) > 100.0: fail_reasons.append("FAIL_CBX3_EXPRESSION_STABILITY_LT_80PCT") c_ok = False if c_days is None: hold_reasons.append("HOLD_MISSING_CBX3_STABILITY_DAYS") c_ok = False elif not _is_strict_int(c_days) or c_days < 28: fail_reasons.append("FAIL_CBX3_STABILITY_DURATION_LT_28D") c_ok = False if c_aberrant is None: hold_reasons.append("HOLD_MISSING_CBX3_ABERRANT_SPLICING_FLAG") c_ok = False elif not _is_strict_bool(c_aberrant) or c_aberrant is not False: fail_reasons.append("FAIL_CBX3_PROMOTER_ORIGINATING_ABERRANT_SPLICING_DETECTED") c_ok = False if c_splice_pct is None: hold_reasons.append("HOLD_MISSING_CBX3_ABERRANT_SPLICE_JUNCTION_PCT") c_ok = False elif not _is_finite_number(c_splice_pct) or float(c_splice_pct) < 0.0 or float(c_splice_pct) > 1.0: fail_reasons.append("FAIL_CBX3_ABERRANT_SPLICE_JUNCTION_GT_1PCT") c_ok = False if c_leak_clear is None: hold_reasons.append("HOLD_MISSING_CBX3_PROMOTER_LEAKAGE_FLAG") c_ok = False elif not _is_strict_bool(c_leak_clear) or c_leak_clear is not True: fail_reasons.append("FAIL_CBX3_PROMOTER_LEAKAGE_READTHROUGH_DETECTED") c_ok = False cbx3_barrier_verified = c_ok req_int("max_single_aav6_packaged_bp", lo=1, hi=4700, fail_code="FAIL_AAV6_PACKAGING_CEILING_EXCEEDED_4700BP", domain_code="FAIL_NON_INTEGER_OR_OUT_OF_DOMAIN_AAV6_BP") req_int("synthetic_payload_max_homopolymer_nt", lo=1, hi=6, fail_code="FAIL_HOMOPOLYMER_GE_7NT_OR_T20_PRESENT", domain_code="FAIL_INVALID_HOMOPOLYMER_COUNT") req_int("synthetic_payload_disjoint_dr_ge20_count", exact=0, fail_code="FAIL_DISJOINT_DIRECT_REPEAT_GE_20BP", domain_code="FAIL_NON_INTEGER_DR_COUNT") req_int("synthetic_payload_disjoint_ir_ge20_count", exact=0, fail_code="FAIL_DISJOINT_INVERTED_REPEAT_GE_20BP", domain_code="FAIL_NON_INTEGER_IR_COUNT") req_pct("synthetic_payload_max_gc100_pct", max_allowed=72.0, fail_code="FAIL_SYNTHETIC_GC100_GT_72PCT") req_pct("synthetic_payload_max_gc50_pct", max_allowed=78.0, fail_code="FAIL_SYNTHETIC_GC50_GT_78PCT") req_int("peptide_2a_scar_count", exact=0, fail_code="FAIL_2A_PEPTIDE_SCAR_PRESENT", domain_code="FAIL_NON_INTEGER_2A_SCAR_COUNT") # 2. Switch locus, MHC routing, manifest & construct-registry switch identity, single-vs-dual enforcement, PMID:11242052/23572523 pan_locus_raw = payload.get("pan_lineage_switch_locus") pan_locus_str: Optional[str] = None if pan_locus_raw is None: hold_reasons.append("HOLD_MISSING_PAN_LINEAGE_SWITCH_LOCUS") elif not _is_clean_str(pan_locus_raw) or pan_locus_raw not in {"TBP_CHR6_3UTR_IRES", "ACTB_CHR7_3UTR_IRES"}: fail_reasons.append("FAIL_INVALID_PAN_LINEAGE_LOCUS_AAVS1_OR_GAPDH_BLOCKED") else: pan_locus_str = pan_locus_raw if arm_id_str is not None and pan_locus_str not in ALLOWED_PAN_LINEAGE_LOCI_BY_ARM[arm_id_str]: fail_reasons.append("FAIL_PAN_LINEAGE_LOCUS_ARM_MANIFEST_MISMATCH") mhc_i_intact = req_bool("arm_retains_classical_mhc_i") if mhc_i_intact is not None and arm_id_str is not None: if mhc_i_intact is not ARM_RETAINS_MHC_I_CANONICAL[arm_id_str]: fail_reasons.append("FAIL_ARM_MHC_I_STATUS_CANONICAL_MANIFEST_MISMATCH") dual_req = req_bool("dual_switch_required_for_release") uses_hsv_tk = req_bool("uses_cdk1_hsv_tk") uses_d315a = req_bool("uses_icasp9_d315a") uses_htmpk = req_bool("uses_htmpk_f105y") may_c07 = req_bool("patient_may_carry_hla_c07") uses_icasp8 = req_bool("uses_icasp8") dual_claim = req_bool("dual_layer_escape_claim_present") if arm_cfg is not None and arm_id_str is not None: expected_dual_req = bool(arm_cfg["dual_switch_required_for_release"]) if dual_req is not None and dual_req is not expected_dual_req: fail_reasons.append("FAIL_DUAL_SWITCH_REQUIRED_MANIFEST_MISMATCH")