Description
circuit_breaker.rs exposes BreakerState::HalfOpen but does not throttle traffic through it: any call slips while the breaker is half-open. Add a quota-based scheduler so only N calls per minute are admitted in half-open before deciding to fully close or reopen.
Requirements and Context
- Add
HalfOpenQuota { calls_per_minute: u32, evaluation_window_s: u64 } to breaker config
- Track admission counter under temporary storage
- On quota exhaustion in window, transition to Closed; on any failure, back to Open
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b feature/circuit-breaker-halfopen-quota
- Implement changes
contracts/predictify-hybrid/src/circuit_breaker.rs
contracts/predictify-hybrid/src/circuit_breaker_tests.rs
- Test and commit
cargo test -p predictify-hybrid halfopen_quota
- Cover edge cases
- Include test output and notes in the PR
Example commit message
feat: add half-open quota scheduler to CircuitBreaker
Acceptance Criteria
Guidelines
- Validate auth, overflow, and storage TTL/archival
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
circuit_breaker.rsexposesBreakerState::HalfOpenbut does not throttle traffic through it: any call slips while the breaker is half-open. Add a quota-based scheduler so onlyNcalls per minute are admitted in half-open before deciding to fully close or reopen.Requirements and Context
HalfOpenQuota { calls_per_minute: u32, evaluation_window_s: u64 }to breaker configSuggested Execution
contracts/predictify-hybrid/src/circuit_breaker.rscontracts/predictify-hybrid/src/circuit_breaker_tests.rscargo test -p predictify-hybrid halfopen_quotaExample commit message
Acceptance Criteria
calls_per_minutecalls per evaluation windowunwrap()in any new code pathGuidelines