# Retry needs idempotent effects

Principle `retry-needs-idempotency`. Repeating an operation must preserve its intended observable result.

Also searched as: idempotency, deduplication, effectively once.

A consumer can run an event again after failure. Processing guarantees inside one store do not cover every external side effect.

> In an idempotent system, the outcome of processing a message once is identical to the outcome of processing it multiple times.

Source: [Q10](/bibliography#q10); [B5](/bibliography#b5-building-event-driven-microservices), [B6](/bibliography#b6-fundamentals-of-data-engineering).

## Failure it prevents

A response disappears after a remote write succeeds, and retry repeats the write.

## Our Effect 4.0.5 reading

Workflow identity and Activity.idempotencyKey name work. Receiver-side keys or transactional dedupe must enforce the repeated effect’s semantics.

Source: `packages/effect/src/workflow/Workflow.ts`, `packages/effect/src/workflow/Activity.ts`, `packages/effect/src/workflow/DurableQueue.ts`.

## How to check

Lose the response after remote success. Retry the same identity and inspect the authoritative result. This is our proposed verification, not a quoted procedure.

Continue with [Checkpoints follow the promised commit](/principles/checkpoints-follow-commits), [Cleanup can be an idempotent postcondition](/principles/cleanup-can-be-an-idempotent-postcondition).

Connect this to [the existing rat-stack guidance](https://ratstack.sh/lore/concurrent-work-needs-an-owner).

Use [the durability skill](/skills/durability) for the full review. Return to [the durability index](/principles/durability).

## Skills
- [Durability starts with a recovery record](/principles/durability)

## Sources
- Bellemare, Adam. *Building Event-Driven Microservices: Leveraging Organizational Data at Scale*. O’Reilly, 2020. [Link](https://www.oreilly.com/library/view/building-event-driven-microservices/9781492057888/). ([b5-building-event-driven-microservices](/bibliography#b5-building-event-driven-microservices))
- Reis, Joe; Housley, Matt. *Fundamentals of Data Engineering*. O’Reilly. [Link](https://www.oreilly.com/library/view/fundamentals-of-data/9781098108298). ([b6-fundamentals-of-data-engineering](/bibliography#b6-fundamentals-of-data-engineering))

## References
- [Effect contributors. Effect 4.0.5. workflow/Workflow.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/workflow/Workflow.ts). Pinned source for our Effect mapping, not a claim from the book.
- [Effect contributors. Effect 4.0.5. workflow/Activity.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/workflow/Activity.ts). Pinned source for our Effect mapping, not a claim from the book.
- [Effect contributors. Effect 4.0.5. workflow/DurableQueue.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/workflow/DurableQueue.ts). Pinned source for our Effect mapping, not a claim from the book.
