Principle:23blocks OS Ai maestro Circuit Breaker Resilience
| Knowledge Sources | |
|---|---|
| Domains | Resilience, Mesh_Networking |
| Last Updated | 2026-10-26 10:00 GMT |
Overview
A circuit breaker pattern that fails fast when a peer host is repeatedly unavailable, with exponential backoff and a half-open probe state for recovery.
Description
The circuit breaker trips when a host fails `CIRCUIT_BREAKER_THRESHOLD` (default 3) times. Once open, requests fail fast without attempting the network call. The backoff is exponential (30s → 5min max). When the cooldown expires, the breaker enters a half-open state that allows one probe — if it succeeds, the breaker closes; if it fails, it re-opens with increased backoff.
`recordHostSuccess` clears the breaker state and offline metadata when a host recovers.
Usage
Use this principle when designing a system that calls remote hosts where:
- Repeated failures should fail fast (not retry indefinitely)
- Recovery should be tested with a single probe before fully trusting
- Backoff should be exponential to avoid hammering a recovering host
Theoretical Basis
The circuit breaker has three states:
CLOSED → failures < threshold → requests pass through
OPEN → failures >= threshold → requests fail fast
HALF_OPEN → cooldown expired → one probe allowed
probe success → CLOSED (recordHostSuccess)
probe failure → OPEN (increased backoff)
Failed to parse (syntax error): {\displaystyle \text{backoff} = \min(\text{INITIAL} \times 2^n, \text{MAX\_BACKOFF}) }