rig-evals 0.47.7

Evaluations for Rig agents: datasets of cases, built-in and LLM-judge evaluators, repetitions and pass-rate thresholds, JSON, JUnit and Markdown reports, OpenTelemetry GenAI evaluation events.
Documentation
use std::time::Duration;

use super::{escape, percentile};

#[test]
fn percentiles_use_the_nearest_rank() {
    let sorted: Vec<Duration> = (1..=20).map(Duration::from_millis).collect();
    assert_eq!(percentile(&sorted, 0.50), Duration::from_millis(10));
    assert_eq!(percentile(&sorted, 0.95), Duration::from_millis(19));
    assert_eq!(
        percentile(sorted.get(..1).unwrap(), 0.95),
        Duration::from_millis(1)
    );
    assert_eq!(percentile(&[], 0.5), Duration::ZERO);
}

#[test]
fn xml_escaping_covers_markup_and_forbidden_characters() {
    assert_eq!(
        escape("a<b & \"c\" 'd'>\u{1}\n"),
        "a&lt;b &amp; &quot;c&quot; &apos;d&apos;&gt;\n"
    );
}

#[test]
fn pass_at_k_and_pass_hat_k_match_their_binomial_forms() {
    use super::{pass_at, pass_hat};
    let close = |a: Option<f64>, b: f64| assert!((a.expect("defined") - b).abs() < 1e-12);
    // C(2,2) / C(3,2) = 1/3, so pass@2 = 2/3; C(1,2) = 0, so pass^2 = 0.
    close(pass_at(3, 1, 2), 2.0 / 3.0);
    close(pass_hat(3, 1, 2), 0.0);
    // Any pass with k = n: 1 - C(n - c, n) / C(n, n).
    close(pass_at(3, 0, 3), 0.0);
    close(pass_at(3, 1, 3), 1.0);
    close(pass_hat(3, 3, 3), 1.0);
    // One trial: both are the outcome itself.
    close(pass_at(1, 1, 1), 1.0);
    close(pass_hat(1, 0, 1), 0.0);
    // No overflow at large n: C(999, 500) / C(1000, 500) = 1/2.
    close(pass_at(1000, 1, 500), 0.5);
    // Undefined: k of 0, or more trials than the case has.
    assert_eq!(pass_at(2, 1, 0), None);
    assert_eq!(pass_hat(2, 1, 3), None);
}