lean-ctx 3.9.16

Context Runtime for AI Agents with CCP. 71 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%.
Documentation
//! Quality retention metrics.

/// Quality retained: treatment pass rate as percentage of baseline pass rate.
pub(crate) fn quality_retained_pct(baseline_rate: f64, treatment_rate: f64) -> f64 {
    if baseline_rate <= 0.0 {
        return 0.0;
    }
    treatment_rate / baseline_rate * 100.0
}

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

    #[test]
    fn perfect_retention() {
        assert!((quality_retained_pct(0.95, 0.95) - 100.0).abs() < 1e-9);
    }

    #[test]
    fn partial_retention() {
        let r = quality_retained_pct(0.90, 0.81);
        assert!((r - 90.0).abs() < 1e-9);
    }
}