LESSON 74 / 215·2 min readIntermediate

Idempotency, compensation, and human approvals

Should knowConcept lesson
01 Understand02 Recall03 Prepare

Words made simple

A few useful meanings before you read the explanation.

Idempotency
Making a repeated request have the same intended business effect as one request. It helps avoid duplicate submissions or payments.
Durable
Able to retain progress and recover across interruptions. Durable workflows require appropriate storage and retry behavior.

Overview

  • Idempotency makes repeating the same logical request avoid repeated effects.
  • Compensation is a business action that offsets an earlier action when later steps fail.
  • Human approvals are authenticated events permitting specific transitions.

Why this matters

Crashes can occur after a side effect succeeds but before its success is recorded.

An everyday example

A receipt number prevents paying the same invoice twice; a refund offsets a payment but does not erase its history.

A technical example

A unique (tenantId, action, idempotencyKey) prevents duplicate claim creation and reuses the existing receipt.

How it works

  1. Record request key and payload hash atomically
  2. Execute controlled business mutation
  3. Save outcome
  4. Reuse on retry
  5. Compensate according to policy if later work fails.

Architecture and flow

Request/key → deduplication + transaction → receipt → retry returns receipt; later failure → permitted compensation.

The insurance assistant example

Duplicate browser clicks produce one claim. If notification fails, retry notification without creating the claim again.

When to use it

Every externally retried write and every multi-service process with partial failure.

When to avoid it

Do not reuse a key for changed payloads or assume compensation can undo sending an email or disclosing data.

Interview answer

“I use scoped idempotency keys and durable receipts to prevent duplicate effects, and explicit compensation for recoverable partial business failures.”

Benefits, trade-offs, and production considerations

  • A read-then-insert check races; enforce uniqueness transactionally.
  • Unknown external outcomes require lookup/reconciliation.
  • Approval should bind to the exact payload hash and expire when business facts change.
PAUSE & RECALL

Can you explain it without the notes?

Idempotency, compensation, and human approvals

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

Idempotency makes repeating the same logical request avoid repeated effects. Compensation is a business action that offsets an earlier action when later steps fail. Human approvals are authenticated events permitting specific transitions.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Choosing orchestration tools

Adapted from 13_AI.MD · “Idempotency, compensation, and human approvals”. Examples are study fragments; framework behavior can depend on your version.