---
slug: "CircuitBreaker"
name: "CircuitBreaker"
type: "Primitives"
layer: "Infrastructure"
ref: "CircuitBreaker#3caa"
sema_id: "sema:CircuitBreaker#mh:SHA-256:3caa9c387c04bb2ac66ec35a6cfe2665e11339f0d47576b96d68229226580c76"
tags: ["Infrastructure","Primitives"]
updated: 2026-11-11
mindscape: "bootstrap"
index_url: https://mindscape.world/scapes/bootstrap.json
url: https://mindscape.world/bootstrap/CircuitBreaker/
related: ["Backoff","State","Exception","FailClosed","Retry","Rollout","StopDrill","StopDrill#dcfb"]
---

# CircuitBreaker

Fail-fast protection against cascading failures

Layer: Infrastructure · Category: Primitives

## Mechanism

[State](https://mindscape.world/scapes/bootstrap/State.md) machine wrapper for fallible operations. Monitors failure rates of a target resource. States: (1) 'CLOSED': Requests pass normally. (2) 'OPEN': Requests fail immediately (Fail Fast) without invoking target. (3) 'HALF-OPEN': Limited trial requests allowed to test recovery. Transitions: 'CLOSED' -> 'OPEN' if failure count > threshold. 'OPEN' -> 'HALF-OPEN' after reset timeout. It wraps operations, switching to an open state on failure to prevent cascading overloads, while using [Backoff](https://mindscape.world/scapes/bootstrap/Backoff.md) and retry logic to schedule recovery probes.

## Invariants

- Fail Fast: If [State](https://mindscape.world/scapes/bootstrap/State.md) == 'OPEN', request MUST be rejected immediately with zero backend cost.
- Leakage Protection: In 'HALF-OPEN' state, concurrency is capped (default: 1) to prevent flood during recovery.
- [State](https://mindscape.world/scapes/bootstrap/State.md) Persistence: Failure counts reset only on successful transition to 'CLOSED'.

## Preconditions

- Failure threshold defined
- Target resource identified

## Postconditions

- Internal state updated based on outcome
- Request processed OR Blocked

## Failure modes

- Flapping: Threshold too sensitive causes circuit to oscillate between Open/Closed.
- Zombie [State](https://mindscape.world/scapes/bootstrap/State.md): Circuit stuck 'OPEN' because reset logic failed to trigger or persists in failure.
- False Positive: Transient network blips trip circuit, blocking healthy traffic.

## Parameters

- `failure_threshold` (Integer, [1, 100]): Default: 5
- `half_open_limit` (Integer, [1, 10]): Max probes allowed in half-open state
- `reset_timeout` (Duration, unspecified): Default: 60s

## Builds on

- [Backoff](https://mindscape.world/scapes/bootstrap/Backoff.md) (Infrastructure; References)
- [State](https://mindscape.world/scapes/bootstrap/State.md) (Infrastructure; References)

## Used by

- [Exception](https://mindscape.world/scapes/bootstrap/Exception.md) (Infrastructure; References)
- [FailClosed](https://mindscape.world/scapes/bootstrap/FailClosed.md) (Infrastructure; References)
- [Retry](https://mindscape.world/scapes/bootstrap/Retry.md) (Mind; References)
- [Rollout](https://mindscape.world/scapes/bootstrap/Rollout.md) (Society; Composes with)
- [StopDrill](https://mindscape.world/scapes/bootstrap/StopDrill.md) (Mind; References)

## Identity

- Sema ID: `sema:CircuitBreaker#mh:SHA-256:3caa9c387c04bb2ac66ec35a6cfe2665e11339f0d47576b96d68229226580c76`
- Ref: `CircuitBreaker#3caa`
- Supersedes:
  - `sema:CircuitBreaker#mh:SHA-256:41621375faf5609423cb05060fbdccf92c6d8f856607a2ae4bf35a76c90cbaec`
  - `sema:CircuitBreaker#mh:SHA-256:840fee4c2a300c1e17bd44e55debdf58d250ab62f79760f59c0189ca7d485824`

## Links

- [Pattern page](https://mindscape.world/bootstrap/CircuitBreaker/)
- [View in the interactive graph](https://mindscape.world/bootstrap/#CircuitBreaker)
- [JSON](https://mindscape.world/scapes/bootstrap/CircuitBreaker.json)
- [Index of all patterns](https://mindscape.world/scapes/bootstrap.json)
