Which export writes must survive together?
Separate the acceptance transaction from the later rendering work. Trace the credit, job and dispatch record through retries, claims and publication.
Authorize the snapshot
The HTTP process derives the tenant from the authenticated request and checks access to the immutable snapshot. Accounts supplies identity while Exports owns the write contract.
Claim request identity
A unique tenant, operation and request key identifies the intent. Record a fingerprint of the normalized input so an accepted duplicate can recover its original receipt.
Outgoing
Debit one credit
Only the winner attempts the conditional debit. The balance must still be positive at the write. With no qualifying row, roll back the transaction.
Outgoing
Commit four writes
The request receipt, quota debit, durable job and outbox record commit in one short transaction. Only then may the HTTP process return acceptance to the caller.
Outgoing
Recover the receipt
A matching authorized retry reads the same accepted job and status location. A changed snapshot under the same key conflicts with that recorded intention.
Relay the outbox
The relay sends a stable job ID and input version to the external broker. A crash after sending can cause a second publication of the same event.
Acquire a worker claim
The worker loads the authoritative job and takes a time-limited lease with a new generation. Rendering uses its own CPU allocation outside the database transaction.
Outgoing
Write an attempt object
Store the CSV under the tenant, job and generation as an immutable object. A second attempt can finish computation without changing the object of its predecessor.
Publish the current pointer
A later database transaction publishes the artifact pointer only if the claim generation still matches. A stale worker leaves an unreferenced object for cleanup.
Resolve provider effects
A paid provider may have acted before a timeout. A stable provider operation ID or an explicit reconciliation process covers that external effect.
Test an ownership split
Moving allowance to another service introduces a new partial state. Either keep the debit with admission or define who reserves, confirms, cancels and reconciles it.