class HandoffRejectedError(Exception): pass def run_pipeline(account_id: str, account_data: dict, local_grader) -> AccountHistoryPayload: payload = AccountHistoryPayload(**account_data) verdict = grade_handoff(account_id, payload, local_grader) if not verdict.is_plausible: # this replaces what used to be a wrong email going out quietly - # a raised exception here is annoying, a refund that shouldn't exist isn't raise HandoffRejectedError(f"account_id={account_id}: {verdict.reason}") return payload # safe to hand off to whatever drafts the resolution