feat(circuit-breaker): time-based failure-rate trip mode (0.13.0)#69
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Design + plan for the opt-in time-based failure-rate trip mode, and the Active Index entry. Bundle stays active/draft until merge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ship bookkeeping for PR #69: fill the 0.13.0 release-notes PR number, mark the bundle shipped (pr: 69), move it from changes/active/ to changes/archive/, flip its Index line to Archived, and trim the deferred "CircuitBreaker v2" item to the still-open axes (count-based window, manual control + state). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…validation Address PR #69 review: note that failure_rate_threshold is the sole mode switch (both-set → rate wins, not an error), and that window_seconds / minimum_calls are validated in both modes even when inert in classic. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in time-based failure-rate trip mode to
AsyncCircuitBreaker/CircuitBreaker. The classic consecutive-failure model stays the default and is byte-unchanged. Rate mode opens the circuit when the failure rate over a rolling time window meets a threshold, once a minimum call volume is observed — catching partial degradation (e.g. a steady 50% error rate that never forms a consecutive streak) that the classic breaker misses.Closes the deferred "CircuitBreaker v2 (a)" item. Ships as 0.13.0 (additive, no breaking changes).
What's in it
_RollingWindow— time-bucketed success/failure counters (10 buckets), eviction-on-read/write, with a Hypothesis property test.failure_rate_threshold(opt-in switch, range (0,1]),window_seconds(30.0),minimum_calls(20); threaded through the shared_CircuitBreakerStateso both clients reach parity.total ≥ minimum_callsandfailures/total ≥ threshold); checked after both successes and failures. Half-open recovery + event names identical to classic; window cleared on close. Mode-awarecircuit.openedmessage + rate attributes.architecture/resilience.md,docs/resilience.md, module docstring, and 0.13.0 release notes.Time-based (not count-based) was chosen because it matches the HTTP-service mental model and degrades sanely under variable traffic; Hystrix/Polly/Envoy are all time-based. Count-based windows, the slow-call axis, and manual control / state introspection remain deliberately deferred.
Design + plan:
planning/changes/active/2026-06-16.02-circuit-breaker-rate-mode/.Test plan
just test— 699 passed, 100% coveragejust lint— clean (ruff format/check + ty)minimum_calls, time eviction, clear-on-close; validation; observability attribute setmkdocs build --strict— clean🤖 Generated with Claude Code