# Circuit breakers have state

Principle `circuit-breakers-have-state`. A breaker stops doomed calls and controls probes before restoring traffic.

Also searched as: circuit breaker, half-open probe.

A circuit breaker differs from retry. Its state determines whether a dependency call is attempted. Threshold accounting must match the actual implementation.

> calls to the circuit breaker fail immediately, without any attempt to execute the real operation.

Source: [Q06](/bibliography#q06); [B4](/bibliography#b4-release-it), [B11](/bibliography#b11-property-based-testing).

## Failure it prevents

Callers keep spending capacity on a known-unhealthy dependency.

## Our Effect 4.0.5 reading

No dependency circuit-breaker API was found. Compose timeout and typed failure handling with an explicit XState lifecycle. Define whether state is local or shared.

Source: `packages/effect/src/Effect.ts`, `packages/effect/src/Schema.ts`.

## How to check

Generate success, failure, timeout, cooldown, and probe histories. Verify exact threshold semantics and visible state changes. This is our proposed verification, not a quoted procedure.

Continue with [Bulkheads isolate scarce capacity](/principles/bulkheads-isolate-capacity), [Supervision chooses what restarts](/principles/supervision-is-a-recovery-policy).

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
- Nygard, Michael T. *Release It!: Design and Deploy Production-Ready Software*. Pragmatic Bookshelf, 2007. [Link](https://archive.org/details/releaseitdesignd0000nyga). ([b4-release-it](/bibliography#b4-release-it))
- Hebert, Fred. *Property-Based Testing with PropEr, Erlang, and Elixir*. Pragmatic Bookshelf, 2019. [Link](https://pragprog.com/titles/fhproper/property-based-testing-with-proper-erlang-and-elixir/). ([b11-property-based-testing](/bibliography#b11-property-based-testing))

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