or d28_vol_s is None or d28_vol_s < Decimal("1.0") or d28_lod_s is None or d28_lod_s <= Decimal(0) or d28_lod_s > Decimal("1.0") ): holds.append(f"HOLD_GATE0V_CD55_INVALID_DAY28_PLAQUE_OR_LOD_{s_tag}") s_ok = False elif d28_pfu_s > Decimal(0): hard_stops.append(f"FAIL_HARD_STOP_CD55_ADDENDUM_DAY28_SHEDDING_{s_tag}") s_ok = False lin_map = sb.get("day28_persistence_by_lineage") lin_out: Dict[str, Any] = {} strain_min_n: int | None = None strain_max_u: Decimal | None = None if not isinstance(lin_map, dict): holds.append(f"HOLD_GATE0V_CD55_MISSING_5LINEAGE_PERSISTENCE_{s_tag}") s_ok = False else: for lin in GRAFT_LINEAGES: l_tag = lin.upper() l_entry = lin_map.get(lin) if not isinstance(l_entry, dict): holds.append(f"HOLD_GATE0V_CD55_MISSING_LINEAGE_{s_tag}_{l_tag}") s_ok = False lin_out[lin] = {"passed": False} continue lk = l_entry.get("confirmed_k") ln = l_entry.get("cells_screened_n") l_ok = True l_n_indep: int | None = None u_l_str: str | None = None if not (_is_strict_int(lk) and _is_strict_int(ln) and ln >= 1 and 0 <= lk <= ln): holds.append(f"HOLD_GATE0V_CD55_INVALID_LINEAGE_COUNTS_{s_tag}_{l_tag}") l_ok = False else: if lk >= 1: hard_stops.append( f"FAIL_HARD_STOP_CD55_ECHOVIRUS_PERSISTENCE_DETECTED_{s_tag}_{l_tag}_K_{lk}" ) l_ok = False if not _check_estimand_sampling_unit_basis( l_entry.get("per_unit_counts"), k_val=lk, n_val=ln, label=f"CD55_{s_tag}_{l_tag}", zero_tolerance_hard_stop_token=f"FAIL_HARD_STOP_CD55_ECHOVIRUS_PERSISTENCE_DETECTED_{s_tag}_{l_tag}_K_UNIT_POS", ): l_ok = False if strain_min_n is None or ln < strain_min_n: strain_min_n = ln if overall_min_n is None or ln < overall_min_n: overall_min_n = ln if deff is None: l_ok = False else: l_n_indep = _exact_floor_div_by_decimal(ln, deff) if l_n_indep < 1: holds.append(f"HOLD_GATE0V_CD55_UNDERPOWERED_ECHOVIRUS_DENOMINATOR_{s_tag}_{l_tag}") l_ok = False elif lk == 0: u_l = sound_zero_event_clopper_pearson_upper( l_n_indep, alpha_3p, min_eta_cal, prec=80 )["u_thinned_upper_dec"] u_l_str = format(u_l, "f")[:24] if strain_max_u is None or u_l > strain_max_u: strain_max_u = u_l if overall_max_u is None or u_l > overall_max_u: overall_max_u = u_l if u_l > cap_frac_persist: holds.append(f"HOLD_GATE0V_CD55_UNDERPOWERED_ECHOVIRUS_DENOMINATOR_{s_tag}_{l_tag}") l_ok = False if not l_ok: s_ok = False lin_out[lin] = { "confirmed_k": lk if _is_strict_int(lk) else None, "cells_screened_n": ln if _is_strict_int(ln) else None, "effective_independent_n": l_n_indep, "u_cd55_upper_80d": u_l_str, "passed": l_ok, } # R04-B3 consistency: reject any extra non-canonical lineage keys inside CD55 strain block! for extra_lin, extra_entry in lin_map.items(): if extra_lin not in GRAFT_LINEAGES: el_tag = str(extra_lin).upper() holds.append(f"HOLD_UNRECOGNIZED_LINEAGE_KEY_GATE0V_CD55_{s_tag}_{el_tag}") s_ok = False if isinstance(extra_entry, dict): ek = extra_entry.get("confirmed_k") if _is_strict_int(ek) and ek >= 1: hard_stops.append( f"FAIL_HARD_STOP_CD55_ECHOVIRUS_PERSISTENCE_DETECTED_{s_tag}_{el_tag}_K_{ek}" ) if not s_ok: c55_ok = False per_strain_out[strain_id] = { "passed": s_ok, "detection_efficiency_assurance_level": "CONDITIONAL_ON_ASSUMED_MINIMUM_ETA_PENDING_LINKED_CALIBRANT_EVIDENCE", "assumed_minimum_eta_used": str(min_eta_cal), "min_cells_screened_n": strain_min_n, "max_u_cd55_upper_80d": format(strain_max_u, "f")[:24] if strain_max_u is not None else None, "lineage_results": lin_out, } # Adjudicate any extra submitted echovirus strains so adverse data is never silently dropped for extra_sid, extra_sb in strain_results_raw.items(): if extra_sid not in CD55_REQUIRED_ECHOVIRUS_STRAINS and isinstance(extra_sb, dict): es_tag = str(extra_sid).upper() et72 = _to_exact_decimal(extra_sb.get("titer_72h_log10_pfu_u95")) ed14 = _to_exact_decimal(extra_sb.get("day14_log10_reduction_l95")) ed28 = _to_exact_decimal(extra_sb.get("day28_supernatant_pfu_ml")) if et72 is not None and et72 > Decimal("2.0"): hard_stops.append(f"FAIL_HARD_STOP_CD55_ADDENDUM_72H_TITER_{es_tag}") c55_ok = False if ed14 is not None and ed14 < Decimal("3.0"): hard_stops.append(f"FAIL_HARD_STOP_CD55_ADDENDUM_DAY14_CLEARANCE_{es_tag}") c55_ok = False if ed28 is not None and ed28 > Decimal(0): hard_stops.append(f"FAIL_HARD_STOP_CD55_ADDENDUM_DAY28_SHEDDING_{es_tag}") c55_ok = False elin_map = extra_sb.get("day28_persistence_by_lineage") if isinstance(elin_map, dict): for elin, eent in elin_map.items(): if isinstance(eent, dict) and _is_strict_int(eent.get("confirmed_k")) and eent["confirmed_k"] >= 1: hard_stops.append( f"FAIL_HARD_STOP_CD55_ECHOVIRUS_PERSISTENCE_DETECTED_{es_tag}_{str(elin).upper()}_K_{eent['confirmed_k']}" ) c55_ok = False cd55_results = { "passed": c55_ok, "required_strains": list(CD55_REQUIRED_ECHOVIRUS_STRAINS), "all_strains_and_5_lineages_attributable_and_powered": c55_ok, "detection_efficiency_assurance_level": "CONDITIONAL_ON_ASSUMED_MINIMUM_ETA_PENDING_LINKED_CALIBRANT_EVIDENCE", "assumed_minimum_eta_used": str(min_eta_cal), "later_authorization_requirement": ( "Two-strain CD55 persistence bounds currently apply the assumed minimum detection " "efficiency eta = 0.80 and protocol SHA-256 attribution; linked strain-specific " "detection-efficiency calibrant evidence and measurement attribution are required " "prior to any later product authorization." ), "min_cells_screened_across_strains_and_lineages_n": overall_min_n, "max_u_cd55_upper_80d": format(overall_max_u, "f")[:24] if overall_max_u is not None else None, "strain_results": per_strain_out, } elif isinstance(cd55_add, dict): # B6 / R04-B4: Never silently drop submitted adverse CD55 addendum data (legacy OR per-strain)! supplemental_adjudicated.append("supplemental_addendum:cd55_tropic_echovirus_addendum") t72_55 = _to_exact_decimal(cd55_add.get("echovirus_titer_72h_log10_pfu_u95")) d14_55 = _to_exact_decimal(cd55_add.get("echovirus_day14_log10_reduction_l95")) d28_pfu_55 = _to_exact_decimal(cd55_add.get("echovirus_day28_supernatant_pfu_ml")) c55_k = cd55_add.get("echovirus_persistence_confirmed_k") if t72_55 is not None and t72_55 > Decimal("2.0"): hard_stops.append("FAIL_HARD_STOP_SUPPLEMENTAL_CD55_ADDENDUM_72H_TITER") if d14_55 is not None and d14_55 < Decimal("3.0"): hard_stops.append("FAIL_HARD_STOP_SUPPLEMENTAL_CD55_ADDENDUM_DAY14_CLEARANCE") if d28_pfu_55 is not None and d28_pfu_55 > Decimal(0): hard_stops.append("FAIL_HARD_STOP_SUPPLEMENTAL_CD55_ADDENDUM_DAY28_SHEDDING") if _is_strict_int(c55_k) and c55_k >= 1: hard_stops.append("FAIL_HARD_STOP_SUPPLEMENTAL_CD55_ECHOVIRUS_PERSISTENCE_DETECTED") sup_sr = cd55_add.get("strain_results") if isinstance(sup_sr, dict): for sid, sb in sup_sr.items(): if not isinstance(sb, dict): continue s_tag = str(sid).upper() st72 = _to_exact_decimal(sb.get("titer_72h_log10_pfu_u95")) sd14 = _to_exact_decimal(sb.get("day14_log10_reduction_l95")) sd28 = _to_exact_decimal(sb.get("day28_supernatant_pfu_ml")) if st72 is not None and st72 > Decimal("2.0"): hard_stops.append(f"FAIL_HARD_STOP_SUPPLEMENTAL_CD55_ADDENDUM_72H_TITER_{s_tag}") if sd14 is not None and sd14 < Decimal("3.0"): hard_stops.append(f"FAIL_HARD_STOP_SUPPLEMENTAL_CD55_ADDENDUM_DAY14_CLEARANCE_{s_tag}") if sd28 is not None and sd28 > Decimal(0): hard_stops.append(f"FAIL_HARD_STOP_SUPPLEMENTAL_CD55_ADDENDUM_DAY28_SHEDDING_{s_tag}") slin = sb.get("day28_persistence_by_lineage") if isinstance(slin, dict): for ln_name, l_ent in slin.items(): if ln_name not in GRAFT_LINEAGES: holds.append(f"HOLD_UNRECOGNIZED_LINEAGE_KEY_GATE0V_CD55_SUPPLEMENTAL_{s_tag}_{str(ln_name).upper()}") if isinstance(l_ent, dict) and _is_strict_int(l_ent.get("confirmed_k")) and l_ent["confirmed_k"] >= 1: hard_stops.append( f"FAIL_HARD_STOP_SUPPLEMENTAL_CD55_ECHOVIRUS_PERSISTENCE_DETECTED_{s_tag}_{str(ln_name).upper()}_K_{l_ent['confirmed_k']}" ) # ------------------------------------------------------------------ # 2. Non-Vacuous Gate 0V-A: Fixed 500 ng/mL poly(I:C) + Controls + >=2.0x in >=3/4 Markers # ------------------------------------------------------------------ poly_ic = payload.get("gate0v_a_poly_ic_sensing") if not isinstance(poly_ic, dict): holds.append("HOLD_GATE0V_A_POLY_IC_INNATE_SENSING_PANEL_MISSING") else: dose = _to_exact_decimal_nonneg(poly_ic.get("poly_ic_dose_ng_ml")) dur = _to_exact_decimal_nonneg(poly_ic.get("assay_duration_h")) veh_ok = poly_ic.get("vehicle_control_isg_baseline_verified") veh_sha = poly_ic.get("vehicle_control_evidence_sha256") pos_ctrl = poly_ic.get("positive_control_ifna_isg_fold") lin_isg = poly_ic.get("lineage_isg_fold_induction") if dose is None or dose != Decimal("500"): holds.append("HOLD_GATE0V_A_DOSE_MUST_BE_EXACT_500_NG_ML") if dur is None or not (Decimal("24") <= dur <= Decimal("48")): holds.append("HOLD_GATE0V_A_INVALID_OR_MISSING_ASSAY_DURATION_H") if veh_ok is not True or not _is_valid_sha256_hex(veh_sha): holds.append("HOLD_GATE0V_A_MISSING_VEHICLE_CONTROL_OR_DIGEST") if not isinstance(pos_ctrl, dict): holds.append("HOLD_GATE0V_A_MISSING_POSITIVE_CONTROL_PANEL") else: for lin in GRAFT_LINEAGES: pv = _to_exact_decimal_nonneg(pos_ctrl.get(lin)) if pv is None or pv < Decimal("4.0") or pv > Decimal("1000000"): holds.append(f"HOLD_GATE0V_A_POSITIVE_CONTROL_BELOW_4X_OR_MISSING_{lin.upper()}") for extra_lin in pos_ctrl.keys(): if extra_lin not in GRAFT_LINEAGES: holds.append(f"HOLD_UNRECOGNIZED_LINEAGE_KEY_GATE0V_A_POS_CTRL_{str(extra_lin).upper()}") if not isinstance(lin_isg, dict): holds.append("HOLD_GATE0V_A_MISSING_STRUCTURED_5LINEAGE_ISG_NUMERIC_PANEL") else: for lin in GRAFT_LINEAGES: l_entry = lin_isg.get(lin) if not isinstance(l_entry, dict): holds.append(f"HOLD_GATE0V_A_MISSING_ISG_LINEAGE_{lin.upper()}") continue valid_markers = 0 induced_ge_2x = 0 for mk in GATE0V_A_REQUIRED_ISG_MARKERS: mv = _to_exact_decimal_nonneg(l_entry.get(mk)) if mv is None or mv < Decimal(0) or mv > Decimal("1000000"): holds.append(f"HOLD_GATE0V_A_INVALID_ISG_{mk.upper()}_{lin.upper()}") else: valid_markers += 1 if mv >= Decimal("2.0"): induced_ge_2x += 1 if valid_markers == len(GATE0V_A_REQUIRED_ISG_MARKERS) and induced_ge_2x < 3: hard_stops.append( f"FAIL_HARD_STOP_GATE0V_A_INSUFFICIENT_ISG_INDUCTION_{lin.upper()}_{induced_ge_2x}_OF_4_LT_3" ) for extra_lin, extra_entry in lin_isg.items(): if extra_lin not in GRAFT_LINEAGES: el_tag = str(extra_lin).upper() holds.append(f"HOLD_UNRECOGNIZED_LINEAGE_KEY_GATE0V_A_ISG_{el_tag}") if isinstance(extra_entry, dict): ev_valid = 0 ev_ge_2x = 0 for mk in GATE0V_A_REQUIRED_ISG_MARKERS: mv = _to_exact_decimal_nonneg(extra_entry.get(mk)) if mv is not None and Decimal(0) <= mv <= Decimal("1000000"): ev_valid += 1 if mv >= Decimal("2.0"): ev_ge_2x += 1 if ev_valid == len(GATE0V_A_REQUIRED_ISG_MARKERS) and ev_ge_2x < 3: hard_stops.append(