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%.
use super::calibration::{
    PredictionResult, calibration_curve, format_calibration_report, run_calibration_benchmark,
};

fn prediction(confidence_milli: u16, correct: bool) -> PredictionResult {
    PredictionResult {
        predicted_intent: "test".into(),
        gold_intent: "test".into(),
        confidence_milli,
        correct,
    }
}

#[test]
fn test_calibration_buckets() {
    let curve = calibration_curve(&[prediction(0, false), prediction(1000, true)]);
    assert_eq!(curve.buckets.len(), 5);
}

#[test]
fn test_perfect_calibration() {
    assert_eq!(
        calibration_curve(&[prediction(1000, true)]).brier_score,
        0.0
    );
}

#[test]
fn test_brier_score_bounded() {
    let curve = calibration_curve(&[prediction(0, true), prediction(1000, false)]);
    assert!((0.0..=1.0).contains(&curve.brier_score));
}

#[test]
fn test_benchmark_runs() {
    assert!(run_calibration_benchmark().total_predictions > 0);
}

#[test]
fn test_report_has_table() {
    assert!(format_calibration_report(&run_calibration_benchmark()).contains("Confidence Range"));
}