scripts/verify_iip0041_clinical_h1_cd64t_siglec.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0041_clinical_h1_cd64t_siglec.py · SHA-256: f004cf6d8259b8b4…
else:
if od_present and (not od_valid_container or od_bad_keys):
errs.append(
f"CMC_PRIMARY_RECIPIENT_BINDING_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"lot {lot_lbl} (lot_type={lt!r}, disposition={disp_raw!r}) has malformed recipient_outcomes; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
if rr_present and (not rr_valid_container or rr_malformed or rr_has_dups):
errs.append(
f"CMC_PRIMARY_RECIPIENT_BINDING_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"lot {lot_lbl} (lot_type={lt!r}, disposition={disp_raw!r}) has malformed or duplicate recipient_records; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
if ri_present and (not ri_valid_container or ri_bad_ids or ri_has_dups):
errs.append(
f"CMC_PRIMARY_RECIPIENT_BINDING_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"lot {lot_lbl} (lot_type={lt!r}, disposition={disp_raw!r}) has malformed or duplicate recipient_ids; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
# Require exact set agreement across ALL supplied raw recipient-binding fields on every non-rescue row!
bound_sets: list[tuple[str, list[str]]] = []
if od_present and od_valid_container and not od_bad_keys:
bound_sets.append(("recipient_outcomes", sorted(set(od_valid_ids))))
if rr_present and rr_valid_container and not rr_malformed:
bound_sets.append(("recipient_records", sorted(set(rr_valid_ids))))
if ri_present and ri_valid_container and not ri_bad_ids:
bound_sets.append(("recipient_ids", sorted(set(ri_valid_ids))))
if len(bound_sets) >= 2 and len({tuple(vals) for _lbl, vals in bound_sets}) > 1:
errs.append(
f"CMC_PRIMARY_RECIPIENT_BINDING_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"lot {lot_lbl} (lot_type={lt!r}, disposition={disp_raw!r}) has mutually contradictory "
f"recipient bindings {bound_sets!r}; ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
if lid is None or mid is None:
errs.append(
f"CMC_LEDGER_ANCESTRY_UNVERIFIABLE: raw PARALLEL_CMC_READINESS_LEDGER lot_ledger[{idx}] "
f"missing valid literal lot_id={entry.get('lot_id')!r} or mcb_id={entry.get('mcb_id')!r}."
)
conflict = True
continue
for ek, ev in sorted(entry.items(), key=lambda kv: str(kv[0])):
if ev is None or not isinstance(ek, str) or ek in CMC_LEDGER_KNOWN_BANK_KEYS:
continue
ek_lo = ek.lower()
if any(tok in ek_lo for tok in ("mcb", "wcb", "cell_bank", "bank_id")):
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: UNRECOGNIZED_BANK_ALIAS in raw "
f"PARALLEL_CMC_READINESS_LEDGER lot_id={lid!r}: unsupported bank key {ek!r}."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"RESCUE_REPEAT_LOT lot_id={lid!r} declares unsupported bank alias key {ek!r}; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
row_mcbs: set[str] = {mid}
for mcb_alias in ("master_cell_bank_id", "bank_id"):
if mcb_alias in entry and entry[mcb_alias] is not None:
amid = _strict_literal_id(entry[mcb_alias])
if amid is None or amid != mid:
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: CONFLICTING_MCB_ALIAS in raw "
f"PARALLEL_CMC_READINESS_LEDGER lot_id={lid!r} (disposition={disp!r}): "
f"{mcb_alias}={entry[mcb_alias]!r} contradicts mcb_id={mid!r}."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"RESCUE_REPEAT_LOT lot_id={lid!r} (disposition={disp!r}) declares "
f"{mcb_alias}={entry[mcb_alias]!r}, contradicting mcb_id={mid!r}; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
if amid is not None:
row_mcbs.add(amid)
if lid in ref_mcb_map and amid != ref_mcb_map[lid]:
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: raw PARALLEL_CMC_READINESS_LEDGER "
f"row lot_id={lid!r} (disposition={disp!r}) {mcb_alias}={amid!r} contradicts "
f"VERIFIED_LOT_TO_BANK_MANIFEST mcb_id={ref_mcb_map[lid]!r}."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"RESCUE_REPEAT_LOT lot_id={lid!r} (disposition={disp!r}) declares "
f"{mcb_alias}={amid!r}, contradicting VERIFIED_LOT_TO_BANK_MANIFEST mcb_id={ref_mcb_map[lid]!r}; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
row_wcbs: set[str] = set()
wid: str | None = None
if entry.get("wcb_id") is not None:
wid = _strict_literal_id(entry.get("wcb_id"))
if wid is None:
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: raw PARALLEL_CMC_READINESS_LEDGER "
f"row lot_id={lid!r} has invalid literal wcb_id={entry.get('wcb_id')!r}."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"RESCUE_REPEAT_LOT lot_id={lid!r} has invalid literal wcb_id={entry.get('wcb_id')!r}; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
else:
row_wcbs.add(wid)
if entry.get("working_cell_bank_id") is not None:
waid = _strict_literal_id(entry.get("working_cell_bank_id"))
if waid is None:
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: raw PARALLEL_CMC_READINESS_LEDGER "
f"row lot_id={lid!r} has invalid literal working_cell_bank_id={entry.get('working_cell_bank_id')!r}."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"RESCUE_REPEAT_LOT lot_id={lid!r} has invalid literal "
f"working_cell_bank_id={entry.get('working_cell_bank_id')!r}; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
else:
row_wcbs.add(waid)
if wid is not None and waid != wid:
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: CONFLICTING_WCB_ALIAS in raw "
f"PARALLEL_CMC_READINESS_LEDGER lot_id={lid!r}: working_cell_bank_id={waid!r} contradicts wcb_id={wid!r}."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"RESCUE_REPEAT_LOT lot_id={lid!r} declares working_cell_bank_id={waid!r}, "
f"contradicting wcb_id={wid!r}; ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
elif wid is None:
wid = waid
if lid in seen_lots_raw:
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: DUPLICATE_LOT_ID_IN_CMC_LEDGER "
f"for lot_id={lid!r} (ambiguous lot-to-bank ancestry)."
)
conflict = True
else:
seen_lots_raw[lid] = (mid, wid)
if disp == "RELEASED_INFUSED":
if lid not in ref_mcb_map:
errs.append(
f"CMC_INFUSED_LOT_MISSING_FROM_VERIFIED_MANIFEST: raw PARALLEL_CMC_READINESS_LEDGER "
f"infused {lt} lot_id={lid!r} (mcb_id={mid!r}) lacks independent "
"verified ancestry in VERIFIED_LOT_TO_BANK_MANIFEST."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER infused "
f"RESCUE_REPEAT_LOT lot_id={lid!r} (mcb_id={mid!r}) lacks independent verified "
"ancestry in VERIFIED_LOT_TO_BANK_MANIFEST; ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
if row_wcbs and lid not in ref_wcb_map:
errs.append(
f"CMC_INFUSED_LOT_WCB_MISSING_FROM_VERIFIED_MANIFEST: raw PARALLEL_CMC_READINESS_LEDGER "
f"infused {lt} lot_id={lid!r} declares wcb_id={sorted(row_wcbs)!r} absent from "
"VERIFIED_LOT_TO_BANK_MANIFEST."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER infused "
f"RESCUE_REPEAT_LOT lot_id={lid!r} declares wcb_id={sorted(row_wcbs)!r} absent from "
"VERIFIED_LOT_TO_BANK_MANIFEST; ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
if lid in ref_wcb_map and not row_wcbs:
errs.append(
f"CMC_INFUSED_LOT_MISSING_DECLARED_WCB_ID: raw PARALLEL_CMC_READINESS_LEDGER "
f"infused {lt} lot_id={lid!r} omits wcb_id/working_cell_bank_id while "
f"VERIFIED_LOT_TO_BANK_MANIFEST declares wcb_id={ref_wcb_map[lid]!r} for this lot."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER infused "
f"RESCUE_REPEAT_LOT lot_id={lid!r} omits wcb_id/working_cell_bank_id while "
f"VERIFIED_LOT_TO_BANK_MANIFEST declares wcb_id={ref_wcb_map[lid]!r}; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
if lid in ref_mcb_map and mid != ref_mcb_map[lid]:
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: raw PARALLEL_CMC_READINESS_LEDGER "
f"row lot_id={lid!r} (lot_type={lt!r}, disposition={disp!r}) declares "
f"mcb_id={mid!r}, contradicting VERIFIED_LOT_TO_BANK_MANIFEST mcb_id={ref_mcb_map[lid]!r}."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"RESCUE_REPEAT_LOT lot_id={lid!r} (disposition={disp!r}) declares mcb_id={mid!r}, "
f"contradicting VERIFIED_LOT_TO_BANK_MANIFEST mcb_id={ref_mcb_map[lid]!r}; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
for rw in sorted(row_wcbs):
if lid in ref_wcb_map and rw != ref_wcb_map[lid]:
errs.append(
f"CMC_ROW_ANCESTRY_CONFLICTS_WITH_VERIFIED_MANIFEST: raw PARALLEL_CMC_READINESS_LEDGER "
f"row lot_id={lid!r} (lot_type={lt!r}, disposition={disp!r}) declares "
f"wcb_id={rw!r}, contradicting VERIFIED_LOT_TO_BANK_MANIFEST wcb_id={ref_wcb_map[lid]!r}."
)
if lt == "RESCUE_REPEAT_LOT":
errs.append(
f"CLINICAL_CMC_RESCUE_IDENTITY_CONFLICT: raw PARALLEL_CMC_READINESS_LEDGER "
f"RESCUE_REPEAT_LOT lot_id={lid!r} (disposition={disp!r}) declares wcb_id={rw!r}, "
f"contradicting VERIFIED_LOT_TO_BANK_MANIFEST wcb_id={ref_wcb_map[lid]!r}; "
"ancestry verification and cluster statistics nullified fail-closed."
)
conflict = True
if lt == "RESCUE_REPEAT_LOT":
rescue_wcbs_seen.update(row_wcbs)
if lid in ref_wcb_map:
rescue_wcbs_seen.add(ref_wcb_map[lid])
# Unconditional Pass-0-backed recipient-level lot/MCB/WCB ancestry cross-check across raw CMC rows
# (catches recipient-to-lot/MCB/WCB swaps AND missing/contradictory rescue linkage even when
# follow-up/outcome is missing OR another row triggered an unrelated CMC ValueError!)
if lt != "RESCUE_REPEAT_LOT":
if (
entry.get("rescued_recipient_id") is not None
or entry.get("rescued_primary_lot_id") is not None
):
errs.append(
f"CMC_RESCUE_LINKAGE_MISPLACED_ON_NON_RESCUE_LOT: raw PARALLEL_CMC_READINESS_LEDGER "
f"non-rescue lot {lid!r} (lot_type={lt!r}) declares rescue linkage fields "
f"(rescued_recipient_id={entry.get('rescued_recipient_id')!r}, "
f"rescued_primary_lot_id={entry.get('rescued_primary_lot_id')!r}); "
"ancestry verification and cluster statistics nullified fail-closed."