def inspect(c):
    e=[]
    required=["notification_intent_id","channel","purpose","preference_version","dispatch_id","idempotency_key","queued_at","retry_count","retry_budget"]
    for k in required:
        if c.get(k) in (None,""): e.append("DECISIVE_EVIDENCE_MISSING:"+k)
    if c.get("preference_version") != c.get("current_preference_version"): e.append("STALE_PREFERENCE_VERSION")
    if c.get("channel") == "push":
        if c.get("permission_state") != "GRANTED" or c.get("revocation_state") not in ("NONE",None,""): e.append("PUSH_REVOKED_OR_DENIED")
        if not c.get("subscription_active",False): e.append("PUSH_SUBSCRIPTION_INVALID")
    if c.get("channel") == "email" and not c.get("email_address_valid",False): e.append("EMAIL_ADDRESS_INVALID")
    if c.get("prior_logical_idempotency_key") and c.get("is_retry") and c.get("idempotency_key") != c.get("prior_logical_idempotency_key"): e.append("RETRY_IDEMPOTENCY_CHANGED")
    if c.get("claimed_delivery_state") == "DELIVERED" and not c.get("reliable_delivery_signal",False): e.append("FALSE_DELIVERY_CLAIM")
    if c.get("dkim_state") == "PASS" and c.get("dkim_used_as_delivery_proof",False): e.append("DKIM_AS_DELIVERY")
    if c.get("complaint_state") == "COMPLAINT": e.append("COMPLAINT_SUPPRESSION_REQUIRED")
    if c.get("bounce_class") == "PERMANENT": e.append("PERMANENT_BOUNCE_SUPPRESSION_REQUIRED")
    if c.get("is_retry") and int(c.get("retry_count",0)) >= int(c.get("retry_budget",0)): e.append("RETRY_BUDGET_EXHAUSTED")
    if c.get("fallback_requested"):
        if not c.get("fallback_policy_allows",False) or not c.get("fallback_currently_permitted",False): e.append("FALLBACK_NOT_PERMITTED")
    return e

def expected(c):
    e=inspect(c)
    if any(x.startswith("DECISIVE_EVIDENCE_MISSING") for x in e): return "HOLD_INSUFFICIENT_EVIDENCE"
    if "STALE_PREFERENCE_VERSION" in e: return "HOLD_STALE_PREFERENCE"
    if "PUSH_REVOKED_OR_DENIED" in e: return "SUPPRESSED_REVOKED" if c.get("fallback_currently_permitted") else "SUPPRESSED_REVOKED"
    if "PUSH_SUBSCRIPTION_INVALID" in e or "EMAIL_ADDRESS_INVALID" in e: return "HOLD_SUBSCRIPTION_INVALID"
    if "RETRY_IDEMPOTENCY_CHANGED" in e: return "HOLD_DUPLICATE_RISK"
    if "FALSE_DELIVERY_CLAIM" in e or "DKIM_AS_DELIVERY" in e: return "HOLD_FALSE_DELIVERY_CLAIM"
    if "COMPLAINT_SUPPRESSION_REQUIRED" in e: return "SUPPRESSED_COMPLAINT"
    if "PERMANENT_BOUNCE_SUPPRESSION_REQUIRED" in e: return "SUPPRESSED_PERMANENT_BOUNCE"
    if "RETRY_BUDGET_EXHAUSTED" in e: return "RETRY_BUDGET_EXHAUSTED"
    if "FALLBACK_NOT_PERMITTED" in e: return "HOLD_FALLBACK_NOT_PERMITTED"
    if c.get("temporary_failure") and c.get("is_retry") and int(c.get("retry_count",0)) < int(c.get("retry_budget",0)): return "RETRY_ALLOWED"
    if c.get("fallback_requested") and c.get("fallback_policy_allows") and c.get("fallback_currently_permitted"): return "FALLBACK_CANDIDATE"
    if c.get("reliable_delivery_signal",False): return "DELIVERED_EVIDENCED"
    if c.get("provider_accepted",False): return "UNKNOWN_DELIVERY"
    return "HOLD_INSUFFICIENT_EVIDENCE"

def inspect_transfer(c):
    e=inspect(c)
    if c.get("baseline_verdict_copied"): e.append("BASELINE_ORACLE_REUSE_FORBIDDEN")
    if not c.get("subscription_rotation_recomputed"): e.append("SUBSCRIPTION_ROTATION_NOT_RECOMPUTED")
    if not c.get("preference_update_recomputed"): e.append("PREFERENCE_UPDATE_NOT_RECOMPUTED")
    return e

def expected_transfer(c):
    e=inspect_transfer(c)
    if "BASELINE_ORACLE_REUSE_FORBIDDEN" in e: return "HOLD_BASELINE_ORACLE_REUSE"
    if "SUBSCRIPTION_ROTATION_NOT_RECOMPUTED" in e or "PREFERENCE_UPDATE_NOT_RECOMPUTED" in e: return "HOLD_TRANSFER_NOT_RECOMPUTED"
    return expected(c)
