lean-ctx 3.9.19

Context Runtime for AI Agents with CCP. 79 MCP tools, 10 read modes, 95+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24+ AI tools. Reduces LLM token consumption by up to 99%.
//! Public deterministic circuit-breaker reference.
//!
//! The implementation is shared from `lean_ctx_protocol` so clients can use
//! the same state machine. It is intentionally frozen reference behavior:
//! production quality intelligence and adaptive routing remain in
//! `lean-ctx-enterprise` (Class D).

pub use lean_ctx_protocol::circuit_breaker::{
    CircuitBreaker, CircuitBreakerConfig, CircuitBreakerDecision, CircuitBreakerRoute,
    CircuitBreakerState,
};

#[cfg(test)]
mod tests {
    use super::*;
    use std::time::Duration;

    #[test]
    fn proxy_exposes_circuit_breaker_state_machine() {
        let mut breaker = CircuitBreaker::new(CircuitBreakerConfig {
            failure_threshold: 1,
            recovery_timeout: Duration::from_secs(1),
            half_open_requests: 1,
        });
        assert_eq!(
            breaker.state("coding", "provider"),
            CircuitBreakerState::Closed
        );
        breaker.record_quality_regression("coding", "provider");
        assert_eq!(
            breaker.state("coding", "provider"),
            CircuitBreakerState::Open
        );
    }
}