# Circuit breakers have state

> For agents: start with the [agent guide](https://ratstack.sh/llms.txt). Every page is Markdown by default; add `Accept: text/html` for HTML.

Free workshop: [Build Agent Loops That Never Stop Shipping](/tokenmaxx#interested).

A circuit breaker is a stateful guard around a dependency. It 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](/lore/durability-bibliography#q06); [B4](/lore/durability-bibliography#b4-release-it), [B11](/lore/durability-bibliography#b11-property-based-testing).

## Failure it prevents

Callers keep spending capacity on a known-unhealthy dependency.

## Our Effect 4.0.0 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 check is our proposal. The books do not prescribe it.

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

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

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

## Sources

1. [Nygard, Michael T. Release It!: Design and Deploy Production-Ready Software. Pragmatic Bookshelf, 2007.](https://archive.org/details/releaseitdesignd0000nyga)
   Pragmatic Bookshelf. §4.4 Unbounded Result Sets; Chapter 5 Stability Patterns: §5.1 Timeouts, §5.2 Circuit Breaker, §5.3 Bulkheads, §5.4 Steady State, §5.5 Fail Fast, §5.6 Handshaking, §5.7 Test Harness, §5.8 Decoupling Middleware. Accessed 2026-10-23.

2. [Hebert, Fred. Property-Based Testing with PropEr, Erlang, and Elixir. Pragmatic Bookshelf, 2019.](https://pragprog.com/titles/fhproper/property-based-testing-with-proper-erlang-and-elixir/)
   Pragmatic Bookshelf. Chapter 7 Shrinking; Laying Out Stateful Properties; Testing Parallel Executions; Initial State for the State Machine; Adjusting the Model. Use the actual breaker’s threshold semantics. Accessed 2026-10-23.

3. [Effect contributors. Effect 4.0.0. Effect.ts](https://github.com/Effect-TS/effect/blob/67ba4e46a11ccda0b6761578bfd22c04ae00167d/packages/effect/src/Effect.ts)
   Effect-TS. Pinned source for our Effect mapping, not a claim from the book. Accessed 2026-10-23.

4. [Effect contributors. Effect 4.0.0. Schema.ts](https://github.com/Effect-TS/effect/blob/67ba4e46a11ccda0b6761578bfd22c04ae00167d/packages/effect/src/Schema.ts)
   Effect-TS. Pinned source for our Effect mapping, not a claim from the book. Accessed 2026-10-23.

## Lore on this page

- [Timeouts bound waiting](/lore/timeouts-bound-waiting)

## Linked from

- Agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms.txt)

- Change log → What changed in the files served here, newest first. → [Read page](https://ratstack.sh/log)

- Durability bibliography → Books, checked short quotations, source limits, and Effect mapping provenance. → [Read page](https://ratstack.sh/lore/durability-bibliography)

- Durability starts with a recovery record → A reading order for storage, replay, worker ownership, overload, and recovery tests. → [Read page](https://ratstack.sh/lore/durability)

- Full agent guide → An Effect stack so pure (aspirational) Kit Langton will blush. → [Read page](https://ratstack.sh/llms-full.txt)

- Rat Stack lore | rat-stack → Short, source-grounded notes on the ideas and decisions behind rat-stack. → [Read page](https://ratstack.sh/lore)

- Recovery needs model tests → Test sequences of failures and recoveries against explicit invariants. → [Read page](https://ratstack.sh/lore/recovery-needs-model-tests)

- Retry load needs a budget → One retry owner must control attempts, delay, and aggregate load. → [Read page](https://ratstack.sh/lore/retry-load-needs-a-budget)

- Source change history (log.md) → The generated change log as Markdown. → [Read page](https://ratstack.sh/log.md)

- Supervision chooses what restarts → Restart policy follows dependency shape and bounds repeated recovery. → [Read page](https://ratstack.sh/lore/supervision-is-a-recovery-policy)
