# Restart must reconstruct known state

Principle `restart-from-known-state`. Execution recovery and state recovery need separate contracts.

Also searched as: crash recovery, rehydration, error kernel.

Letting a worker fail is useful when recovery returns it to a known state. Preserve indispensable recovery data; rebuild disposable state.

Book basis: [B1](/bibliography#b1-erlang-and-otp-in-action), [B2](/bibliography#b2-elixir-in-action), [B3](/bibliography#b3-designing-elixir-systems-with-otp).

## Failure it prevents

A fresh worker reuses inconsistent state or forgets critical coordination data.

## Our Effect 4.0.5 reading

Activity results and WorkflowEngine can support reconstruction with persistent storage. A new fiber does not restore old local variables or machine memory.

Source: `packages/effect/src/workflow/Activity.ts`, `packages/effect/src/workflow/WorkflowEngine.ts`, `packages/effect/src/Fiber.ts`.

## How to check

Recover from an incomplete step using durable authority. Check behavior rather than merely checking that the worker is running. This is our proposed verification, not a quoted procedure.

Continue with [Replay needs stable inputs](/principles/replay-needs-stable-inputs), [Durable timers need recovery](/principles/durable-timers-need-recovery).

Connect this to [the existing rat-stack guidance](https://ratstack.sh/lore/lifecycles-are-machines).

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
- Logan, Martin; Merritt, Eric; Carlsson, Richard. *Erlang and OTP in Action*. [Link](https://www.manning.com/books/erlang-and-otp-in-action). ([b1-erlang-and-otp-in-action](/bibliography#b1-erlang-and-otp-in-action))
- Jurić, Saša. *Elixir in Action*, Third Edition. Manning, 2024. [Link](https://www.manning.com/books/elixir-in-action-third-edition). ([b2-elixir-in-action](/bibliography#b2-elixir-in-action))
- Gray II, James Edward; Tate, Bruce A. *Designing Elixir Systems with OTP*. Pragmatic Bookshelf, 2019. [Link](https://pragprog.com/titles/jgotp/designing-elixir-systems-with-otp/). ([b3-designing-elixir-systems-with-otp](/bibliography#b3-designing-elixir-systems-with-otp))

## References
- [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/WorkflowEngine.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/workflow/WorkflowEngine.ts). Pinned source for our Effect mapping, not a claim from the book.
- [Effect contributors. Effect 4.0.5. Fiber.ts](https://github.com/Effect-TS/effect/blob/7f524e25cfb49a71ac39b0f44278d08d40dda5de/packages/effect/src/Fiber.ts). Pinned source for our Effect mapping, not a claim from the book.
