interlock-cb
Installation
SKILL.md
interlock-cb: add a circuit breaker the right way
interlock-cb is a circuit breaker for Python 3.11+. One CircuitBreaker class guards sync and async callables as a decorator, a context manager or breaker.call(fn, ...). It trips on the failure rate over a sliding window (count- or time-based) and can count slow calls as failures. The core has zero dependencies; HTTP clients, web frameworks, tenacity, Redis and OpenTelemetry plug in as optional extras.
The library is from 2026, so your training data most likely predates it. Do not guess the API from pybreaker or circuitbreaker: every symbol you need is in this file, and the documentation links at the end cover the rest.
Ground rules
- Package
interlock-cb, importinterlock. Python 3.11 or newer; if the project is older, say so and stop. pybreaker or circuitbreaker remain the right choice there. - One breaker per dependency, keyed by host or by a named downstream. A failing host must never trip a healthy one.
- Thresholds come from observed traffic. Ship in shadow mode first (step 5), tune, then enforce.
- Every layer stays explicit: no hidden retries, no silent fallbacks, no swallowed
CircuitOpenError. Configis a frozen dataclass validated at construction: to change a value, build a new one.- Show the inventory and the plan to the user before editing code.