fix: move all circuit breaker state to instance storage for consistency#310
Merged
hman38705 merged 1 commit intoMar 27, 2026
Merged
Conversation
- CircuitBreakerState moved from persistent to instance storage in: circuit_breaker.rs (_set_state_internal, get_state) monitoring.rs (track_error auto-open) governance.rs (emergency_pause) lib.rs (initialize) - ErrorCount and LastObservation moved from persistent to instance storage in monitoring.rs (track_error, reset_monitoring, tests) - OpenedAt was already in instance storage (no change needed) - Removed persistent TTL bump for CircuitBreakerState; instance storage expires as a unit so all safety state is always consistent - All breaker-related state now shares the same storage layer and lifecycle — if instance expires, counters and state reset together to a safe Closed default rather than leaving a stale Open state with zeroed counters Closes solutions-plug#38
|
@Fidelis900 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Title: fix: move all circuit breaker state to instance storage for consistency
Body:
Summary
Fixes #38 — Unify Circuit Breaker Storage Layers
CircuitBreakerState lived in persistent storage while OpenedAt (cool-down timer) lived in instance storage, and
ErrorCount/LastObservation also lived in persistent. If instance storage expired while persistent state survived, the
breaker could be Open with OpenedAt = 0, causing the cool-down to immediately resolve to HalfOpen on the next call —
or counters could reset to zero while the breaker stayed Open with no path to re-trigger it correctly.
Root Cause
The inconsistency meant the three components of the circuit breaker had different expiry lifecycles:
Changes
for CircuitBreakerState — instance storage expires as a unit, so no manual TTL management is needed.
including the auto-open write to CircuitBreakerState. Inline tests updated accordingly.
Consistency Guarantee
All safety-related state now shares the same storage layer and expiry lifecycle. If instance storage expires, every
key resets together — get_state returns Closed (the safe default), counters return 0, and the system is in a coherent
state rather than a partially-reset one.
closes #146