graphrt_eval/lib.rs
1//! # graphrt-eval
2//!
3//! Evaluate graphrt workflows against test cases, in CI or from `cargo test`.
4//!
5//! - [`EvalSuite`]: an eval file (`*.eval.yaml`, Promptfoo-shaped `tests` /
6//! `assert` / `defaultTest`) plus an optional JSONL dataset.
7//! - [`Runner`]: runs every case against a [`Target`] (usually an
8//! [`EngineTarget`] around one compiled graph), concurrently, and scores it.
9//! - [`assertion`]: deterministic output checks, latency and token budgets,
10//! agent trajectory checks and retrieval metrics, behind the [`Assertion`]
11//! trait so other crates can add types.
12//! - [`judge`]: LLM judges written as graphrt workflows (`type: judge`),
13//! compiled once through a [`judge::JudgeLoader`] and versioned by fingerprint.
14//! - [`stats`]: unbiased pass@k / pass^k over trials, and judge agreement
15//! (TPR, TNR, Cohen's kappa) for [`calibration`] suites.
16//! - [`online`]: evaluators that score a sample of production runs in
17//! `graphrt serve` (no expected answers: judges, regexes, schemas, budgets,
18//! trajectories), with deterministic per-run sampling and filters.
19//! - [`EvalReport`]: the summary, the gate verdict, the [`baseline`]
20//! comparison, and JSON / JUnit output.
21//!
22//! The harness is not part of the engine: it only consumes the run's event
23//! stream, so runs evaluated here behave exactly like production runs.
24//!
25//! ```no_run
26//! # async fn demo(engine: graphrt_core::Engine) -> Result<(), graphrt_eval::EvalError> {
27//! use graphrt_eval::{EngineTarget, EvalSuite, Runner, RunnerOptions};
28//!
29//! let suite = EvalSuite::load(std::path::Path::new("evals/hello.eval.yaml"))?;
30//! let report = Runner::new(RunnerOptions::default())
31//! .run(&suite, &EngineTarget::new(engine), |result| eprintln!("{}", graphrt_eval::report::format_result_line(result)))
32//! .await?;
33//! assert!(report.gate_passed(), "{}", graphrt_eval::report::format_summary(&report));
34//! # Ok(())
35//! # }
36//! ```
37
38pub mod assertion;
39pub mod baseline;
40pub mod calibration;
41pub mod capture;
42pub mod config;
43pub mod error;
44mod glob;
45pub mod judge;
46pub mod online;
47pub mod path;
48pub mod report;
49pub mod runner;
50pub mod schema;
51pub mod stats;
52
53pub use assertion::{Assertion, AssertionContext, AssertionRegistry, AssertionResult, Outcome};
54pub use capture::{RetrievalHit, RunCapture, RunStatus, ToolCallRecord};
55pub use config::{AssertionSpec, Calibration, EvalSuite, Gate, TestCase, Tolerance};
56pub use error::EvalError;
57pub use judge::{JudgeLoader, Verdict};
58pub use report::{EvalReport, Summary, TestResult, TestStatus};
59pub use runner::{EngineTarget, Runner, RunnerOptions, Target};