26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
48 lines
1.6 KiB
Rust
48 lines
1.6 KiB
Rust
//! Reproducibility contract for the scorecard (#211).
|
|
//!
|
|
//! The quality metrics (compression savings + recall/MRR) must be identical
|
|
//! across runs. Latency is wall-clock and intentionally excluded from the
|
|
//! determinism digest.
|
|
|
|
use lean_ctx::core::scorecard::run_scorecard;
|
|
|
|
#[test]
|
|
fn scorecard_quality_metrics_are_reproducible() {
|
|
let a = run_scorecard().expect("scorecard run a");
|
|
let b = run_scorecard().expect("scorecard run b");
|
|
assert_eq!(
|
|
a.determinism_digest, b.determinism_digest,
|
|
"scorecard quality metrics drifted between identical runs"
|
|
);
|
|
assert!(
|
|
!a.determinism_digest.is_empty(),
|
|
"digest must be populated and serialized into the artifact"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn scorecard_has_all_scenarios_and_sane_metrics() {
|
|
let sc = run_scorecard().expect("scorecard run");
|
|
let names: Vec<&str> = sc.scenarios.iter().map(|s| s.name.as_str()).collect();
|
|
assert_eq!(names, vec!["small", "medium", "large"]);
|
|
|
|
for s in &sc.scenarios {
|
|
assert!(s.files > 0, "{} has no files", s.name);
|
|
assert!(s.queries > 0, "{} has no queries", s.name);
|
|
assert!(s.raw_tokens > 0, "{} measured no tokens", s.name);
|
|
// Unique markers should make the right file easily retrievable.
|
|
assert!(
|
|
s.recall_at_10 >= 0.5,
|
|
"{} recall@10 unexpectedly low: {}",
|
|
s.name,
|
|
s.recall_at_10
|
|
);
|
|
// Bounds sanity.
|
|
assert!((0.0..=1.0).contains(&s.recall_at_5));
|
|
assert!((0.0..=1.0).contains(&s.mrr));
|
|
assert!(s.best_savings_pct >= 0.0);
|
|
}
|
|
|
|
assert!(sc.aggregate.avg_recall_at_10 >= 0.5);
|
|
}
|