# ADR : Deliver and recover across failures Status: proposed — template; decision and owner acceptance are not recorded. Date / source revision / owner / supersedes: ## Context and decision trigger Map the local transaction, event publication, n8n trigger and downstream side effects. Specify acknowledgment meaning, acceptable loss/duplication, per-key ordering, delivery latency and maximum recovery time. Identify who retries each boundary. No cross-system exactly-once behavior is assumed. ## Failure matrix | Failure window | Observable/ambiguous state | Required recovery / evidence | |---|---|---| | Local transaction rolls back | No committed business operation | No corresponding committed event effect | | Commit succeeds; delivery fails | Business change exists but consumer may know nothing | Durable pending delivery/reconciliation or explicitly accepted loss | | Consumer effect succeeds; acknowledgment is lost | Sender cannot distinguish success from failure | Idempotent replay or provider lookup/reconciliation | | Poison/permanent error | Retrying cannot succeed as-is | Quarantine, alert and owned remediation | | Late replay after schema/key expiry | Old contract or dedupe state may be absent | Explicit compatibility and replay decision | ## Alternatives and tradeoffs Compare synchronous calls with explicit failure contract, best-effort delivery with authorized loss tolerance, existing broker guarantees, transactional outbox/inbox, and reconciliation polling. An outbox is relevant to a commit/publication dual-write gap, not an automatic requirement for every workflow. Outbox delivery can still duplicate messages; consumers need appropriate idempotency. Choose saga/compensation only for a real multi-participant business transaction. ## Decision to complete Record delivery/acknowledgment contract; atomic persistence point; retry owner and bounded attempt/time budget/backoff; timeout/rate limits; ordering key; idempotency reference; retryable versus permanent classification; quarantine/replay authorization; recovery owner and alerting. Avoid multiplied retries at every layer. Define how operator replay avoids repeated irreversible effects. ## Validation and acceptance Kill/fail at each matrix window. Demonstrate pending work survives restart and is delivered/reconciled, rollback does not publish an invalid committed outcome, duplicate retries obey idempotency, permanent errors stop within limits, and replay works with version/retention constraints. Verify production trigger/error behavior on an authorized isolated n8n target; manual smoke execution may exercise a different path. ## Consequences, rollout and rollback Document eventual-consistency window, backlog/cost/retention, poison-message handling and visibility. Rollback must stop new triggers safely and drain/preserve pending deliveries; define compensations or manual reconciliation. JSON restoration cannot reverse an email, payment or other external action.