Claims the one send that can mail Jack Henry a second decision file.
ALREADY_SENT is a replay of the attempt SES accepted; IN_DOUBT is
an attempt that reached SES and never came back, which only a human
can resolve; anything else is a new deliberate send, including the
operator's resend, and stamps itself as the attempt in flight.
Both arms compare against sentAttemptId, not sentAt: a resend's sentAt
is already set by the original send, so reading it would report a lost
resend as a completed one.
Opens a file for businessDate and claims every unfiled row presented on
or before it in one UPDATE: the CASE default-denies whatever is still
PENDING, denies an APPROVED row its ledger account has not funded, and
files both in the same statement that sets fileId, so a concurrent
undo() can't land between a deny and a claim — Postgres re-evaluates the
CASE against the latest committed row on the concurrent-update recheck.
Idempotent on idempotencyKey: a retry re-finds its own file and recounts
from the rows carrying that file id, never from the UPDATE's row count —
which is zero on a retry because the rows are already claimed.
Unstamps an attempt SES definitively rejected, so the bounded retry behaves normally instead of meeting its own stamp and reporting IN_DOUBT. Only ever called where a response came back saying the mail was not taken.
A file that never reached the bank releases its rows: leaving them claimed
freezes undo, decide and confirmRequested on a file nobody can fix.
The default-deny stamps stay — they were correct at file time, and with the
lock gone ops can override them before the next send picks the rows up.
releaseClaim: false is the one exception: a send whose result was lost may
already be at the bank, so its rows must not go back in tomorrow's file.
OptionalreleaseClaim?: booleanFalse only when the send's result was lost and the bank may hold the file.
First send stamps the decisions and publishes; a resend only records the
time. Either way sent_attempt_id records which attempt SES accepted,
which is what beginSendAttempt reads to tell a completed send from a lost one.
OptionalbusinessDates?: string[]OptionalcreatedAt?: DbTimestampCriteriaOptionalids?: string[]OptionalorderBy?: DbOrderByCriterion<Defaults to createdAt descending.
Optionalpage?: numberDefaults to 1
OptionalpageSize?: numberDefaults to 50
Optionalstatuses?: ("FAILED" | "CLAIMED" | "SENT" | "EMPTY")[]OptionalupdatedAt?: DbTimestampCriteria
The process default: built from each dependency's own
instance().