Insert-if-absent by key; on conflict the existing record is returned unchanged ('exists').
With lease, a new record is created already begun (sending, token 1, 1 attempt).
Optionallease: LeaseOptionspending/failed (due or not) → sending under a fresh token: the persisted
"about to call the provider" marker. null when the record is missing or in another state.
sending → sent with the provider ref.
sending → failed (due at retryAt) or dead. With refund, the claim made no
provider call (a split part deferred behind an earlier one): the attempt it counted is
given back, so waiting never uses up the record's retries.
Lease due pending/failed records and sending records whose lease expired
(returned with ambiguous: true), oldest createdAt first. Claimed records come back
sending under a fresh token.
Records, optionally by state and chat, oldest createdAt first.
Optionalfilter: { state?: OutboxState; chatId?: string; limit?: number }Operator retry: failed/dead/unknown → pending, due now.
Operator discard: delete the record (a later send with the same key goes out again).
Delete terminal records completed before before. Returns the count.
Persistence contract of the outbound journal.