A property-management workload needs its missed webhooks recovered, but allowing a recovery worker to launch unbounded paid processing would defeat its spending cap before the invoice arrives. Resolve that tension by making replay an authorized, budget-reserving operation against a durable event ledger. TL;DR: read delivery history to establish what is missing, redrive your own dead-letter queue for events you already hold, and reserve a defensible upper bound on downstream spending before admitting either path. Keep the authorization and reservation attached to the event throughout recovery.
Delivery is evidence. Processing is another claim.
The design below is a proposed recovery contract for a property-management service that processes account events and may launch paid document analysis. Its examples are illustrative design inputs, not platform features or measured results. The question is operational: can an operator explain who recovered a particular event, which workload paid for it, and why a repeated attempt did not create another spending allowance?
How should delivery history guide replay of missed webhook events?
Start with the evidence available from the platform. If it exposes delivery history, inspect the documented event identifier, destination, attempt time, outcome, and available payload reference; record which fields actually exist rather than inventing a universal history schema. An attempt record and a local processing receipt answer different questions. A delivery marked successful does not, by itself, establish that the property's document analysis completed under your application's transaction rules. Conversely, an unsuccessful attempt does not establish that your application has never seen the event. Treat ambiguous outcomes as reconciliation work.
For this design, separate an event identity from a delivery-attempt identity. Store the provider's documented stable event identifier with the tenant, subscription scope, and source account, then associate any available attempts with that record. If the source does not supply an identity with the necessary stability, settle the deduplication contract before automated replay; a guessed key is an especially poor foundation for a spending limit.
Take a hypothetical event for property P-204 under workload lease-document-review. A recovery operator finds an unsuccessful platform delivery, while the local inbox shows the same event durably accepted and the worker ledger shows processing failed. That event belongs in local recovery. Asking the platform to resend it adds another delivery attempt without fixing the worker's failure.
Reverse the evidence and the action changes. If local durable acceptance is absent, use a documented provider replay or retrieval facility when one exists, with the required access authorization. Neither delivery-history access nor replay support should be assumed. Where history or payload retention is insufficient, reconcile against an authoritative business record through an explicitly designed repair process; do not silently manufacture the missing webhook.
The practical output is a recovery manifest: event identity, evidence references, tenant, workload, proposed action, and authorization scope. Record the inspected time range and any documented retention boundary too.
A gap remains a gap.
Make recovery a durable spending decision
A queue message should point to a durable event record. In this proposed layout, the inbox stores accepted event identity and a payload reference, the processing ledger records the business outcome, and the dead-letter queue holds failed processing work with a reason and attempt count. Preserve the original payload reference across redrives. A transformed replacement is a new input and needs its own provenance.
For the storage boundary, require the payload store to acknowledge the durability your application needs before marking the inbox record ready. Verify its documented consistency and retention behavior. A reference committed before the referenced bytes are available creates a recovery record that cannot be processed; a deletion policy that outlives neither the audit period nor the recovery period produces the same result later. Queue retention alone cannot satisfy that requirement.
Budget admission belongs beside deduplication. Let L be the workload's configured cap, S its settled usage, R its outstanding reservations, and U a conservative upper bound for this event's next paid operation, all expressed in the same internal accounting unit. Admit work only when S + R + U <= L, and commit the new reservation atomically with the event's admission record. These are design variables, not quoted prices.
The comparison must survive concurrency. Two workers independently reading the same remaining allowance can each make a locally reasonable decision and jointly exceed the cap, so an application-side comparison followed by an unrelated write is insufficient. Require a transaction or conditional mutation that enforces the allowance under concurrent admissions. Use the same rule for ordinary processing and recovery; otherwise replay becomes a second entrance around the cap.
Consider an illustrative cap of 100 units, 72 settled units, and 20 reserved units. An operation bounded at 9 units must wait because only 8 remain. Its age, delivery status, or urgency does not change the arithmetic. If the business wants an emergency exception, require a separately authorized cap change and retain the change record.
The limitation is explicit: this design is not suitable for guaranteeing an invoice cap when the external operation's maximum charge is unknown or its consumption cannot be constrained. Define that bound before launch, constrain the work to fit it, or describe the control as admission management. A retry after an ambiguous downstream result needs special care because a fresh invocation may incur fresh usage even when the original business event is a duplicate. Suppose, as a design exercise, that a worker has reserved its allowance and invoked the paid operation, then loses the response before recording completion. The recovery worker sees an incomplete local outcome, but that observation provides no evidence about external consumption. Issuing another invocation against the same reservation could therefore violate the bound that justified admission. Hold the event for reconciliation unless a documented downstream deduplication contract makes repeating the request safe; if a new paid attempt is necessary, it needs its own conservative allowance and authorization under the workload cap.
Don't release uncertainty.
A Python admission example with explicit boundaries
The following standard-library example makes the allowance decision inspectable. It deliberately operates on a supplied snapshot; the production transaction must read authoritative counters, check event state, and persist the reservation together. The sample is useful for reviewing the arithmetic, not as a concurrency control implementation.
from dataclasses import dataclass @dataclass(frozen=True) class WorkloadBudget: cap: int settled: int reserved: int def admission_reason(budget: WorkloadBudget, upper_bound: int) -> str: values = (budget.cap, budget.settled, budget.reserved, upper_bound) if any(type(value) is not int for value in values): raise TypeError("Accounting units must be integers") if any(value < 0 for value in values): raise ValueError("Accounting units must be nonnegative") if budget.settled + budget.reserved + upper_bound > budget.cap: return "hold_for_budget" return "eligible_for_atomic_reservation" budget = WorkloadBudget(cap=100, settled=72, reserved=20) assert admission_reason(budget, upper_bound=9) == "hold_for_budget" assert admission_reason(budget, upper_bound=8) == ( "eligible_for_atomic_reservation" ) Inside the real admission transaction, verify that the recovery principal is authorized for the manifest's tenant and workload, then check the processing identity and current recovery state. An existing completed event returns its prior outcome. An existing active operation returns its existing reservation. Only a permitted new operation can reserve additional units. Persist the manifest identity, principal identity, event identity, reservation amount, and decision alongside the state change. Reject a tenant mismatch before payload access.
Keep the transaction short.
Dispatch requires another explicit durability boundary: commit a pending dispatch record with the reservation, then let a dispatcher publish that work and mark its progress. A repeated dispatch must resolve to the same logical operation. Otherwise a crash between committing the allowance and sending the queue message can strand money indefinitely, while reversing those steps can start paid work without a committed reservation.
Completion settles actual usage against the reservation under the accounting contract. An unknown outcome keeps a reconciliation state; elapsed time alone is insufficient evidence that no spending occurred. Release unused allowance only when the operation's terminal state and accounting evidence justify it.
The trade-off is availability: uncertain work waits while its reservation remains unavailable to other admissions.
Compare the recovery paths after defining the invariants
The useful comparison is between recovery mechanisms and their evidence, not between product slogans. Read-only inspection can be broad enough to investigate a gap, while payload access and execution authority remain scoped to the tenant and workload being repaired.
| Recovery path | Evidence needed | Useful boundary | Failure mode to prevent |
|---|---|---|---|
| Platform resend, if documented | Source event identity and available delivery history | Recovers input absent from the durable inbox | Duplicate delivery starts another paid operation |
| Own dead-letter redrive | Durable payload reference and local failure record | Retries processing for input already accepted | Poison input circulates without a changed precondition |
| Business-state reconciliation | Authoritative record and an approved repair rule | Handles a gap that available event evidence cannot reconstruct | A repair is mistaken for an original historical event |
For a poison event, another attempt is justified only after an identifiable precondition changes: a parser correction, repaired payload access, or an approved input repair, for example. Preserve the failure classification and identify that change in the manifest. A larger retry count provides no such explanation.
Authorization deserves the same skepticism as storage durability. The OWASP Secrets Management Cheat Sheet discusses least privilege, auditing, rotation, and revocation; apply those principles to recovery credentials as well as ordinary ingestion credentials. A recovery worker should receive the access required for its task, and its audit trail should identify the acting principal without embedding the credential or copying sensitive document contents into logs. Secret rotation and credential revocation need a defined operational path. They are not reasons to grant every recovery worker unrestricted access.
Audit records should connect a human or service principal to a particular manifest and decision. A shared credential name alone leaves the business unable to distinguish a permitted repair from an operator using someone else's authority. Retain audit evidence under an explicit policy, with access controls appropriate to the underlying tenant data. Do not equate an editable log line with a complete audit design.
Roll out with a narrow recovery manifest
Begin with inspection that produces a manifest without dispatching work. For one tenant and one workload, verify that every candidate resolves to an explicit action or a documented hold, and that the proposed payload reads stay within the operator's scope. Then admit a deliberately bounded batch through the same reservation path used by normal processing.
Before expanding, exercise duplicate delivery, concurrent admissions near the cap, a crash after reservation, repeated dispatch, revoked credentials, and an ambiguous paid-operation outcome. Check durable state after each test: one business outcome per processing identity, no admission beyond the allowance, and an attributable decision for each recovered event. These are acceptance criteria for the proposed design, not claims of tests already run.
Observe held reservations, reconciliation age, authorization denials, recovery attempts, and the number of events whose local outcome disagrees with the recovery manifest. Keep payloads out of metric labels. Deployment rollback should stop new recovery admissions while preserving existing reservations and reconciliation records; deleting that evidence would make the apparent remaining allowance misleading.
The release criterion is concrete: a property manager can ask why P-204 was processed again and receive an event record, an authorized recovery decision, and an accounting explanation. Until those agree, recovery is still pending.
References
The reference below supports the credential-management principles. The ledger, reservation contract, example values, and rollout criteria above are proposed engineering choices; source-platform replay capabilities and retention limits require verification against that platform's documentation before implementation.
Sources
- OWASP Secrets Management Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html