Skip to main content

rusty_eval/
error.rs

1//! Error types for Rusty Eval.
2//!
3//! All fallible operations in the crate return [`Result<T>`] with
4//! [`EvalError`] as the error type. A failed *run* is not an [`EvalError`] —
5//! it is evidence, recorded as [`crate::evidence::RunStatus::Failed`] on the
6//! case run. Errors here mean the experiment itself is broken: malformed
7//! datasets, unsupported format versions, agent factories that cannot build,
8//! judges that cannot answer.
9
10use thiserror::Error;
11
12/// The single error type for the whole crate.
13#[derive(Debug, Error)]
14pub enum EvalError {
15    /// Malformed dataset content: bad JSONL, missing header, duplicate case
16    /// ids, expectations that cannot convert into assertions. The message
17    /// carries the line number when the failure is line-local.
18    #[error("dataset error: {0}")]
19    Dataset(String),
20
21    /// The dataset's declared `format_version` is newer (or older) than this
22    /// build supports. Loading refuses to guess across versions.
23    #[error("unsupported dataset format version: found {found}, this build supports {supported}")]
24    UnsupportedVersion {
25        /// The version the dataset declares.
26        found: u64,
27        /// The version this build loads.
28        supported: u64,
29    },
30
31    /// Malformed or invalid human-feedback queue state.
32    #[error("feedback error: {0}")]
33    Feedback(String),
34
35    /// The feedback queue format is not supported by this build.
36    #[error("unsupported feedback format version: found {found}, this build supports {supported}")]
37    UnsupportedFeedbackVersion {
38        /// The version the queue declares.
39        found: u64,
40        /// The version this build loads.
41        supported: u64,
42    },
43
44    /// Malformed release-gate policy or decision evidence.
45    #[error("gate error: {0}")]
46    Gate(String),
47
48    /// A gate policy or decision uses an unsupported format version.
49    #[error(
50        "unsupported gate {artifact} format version: found {found}, this build supports {supported}"
51    )]
52    UnsupportedGateVersion {
53        /// Policy or decision.
54        artifact: &'static str,
55        /// Version declared by the artifact.
56        found: u64,
57        /// Version supported by this build.
58        supported: u64,
59    },
60
61    /// The agent factory failed to build a graph for a case, or the initial
62    /// state derived from the case input is not a JSON object.
63    #[error("agent build error: {0}")]
64    AgentBuild(String),
65
66    /// A judge failed to produce a verdict. Judge failures abort the
67    /// experiment rather than fabricating a score: a missing verdict is
68    /// infrastructure failure, not evidence about the agent.
69    #[error("judge error: {0}")]
70    Judge(String),
71
72    /// Invalid configuration or incomparable evidence for a statistical test.
73    #[error("statistics error: {0}")]
74    Statistics(String),
75
76    /// Invalid source evidence or a forged failure-cluster artifact.
77    #[error("failure clustering error: {0}")]
78    Clustering(String),
79
80    /// A run-level failure from the core runtime that escaped the evidence
81    /// path (factory-side graph compilation, journal setup).
82    #[error("runtime error: {0}")]
83    Runtime(#[from] rusty_agent_runtime::error::RustyError),
84
85    /// Filesystem failures loading or saving datasets and reports.
86    #[error("io error: {0}")]
87    Io(#[from] std::io::Error),
88
89    /// JSON (de)serialization failures outside dataset parsing (report
90    /// persistence).
91    #[error("serialization error: {0}")]
92    Serialization(#[from] serde_json::Error),
93}
94
95/// Crate-wide result alias.
96pub type Result<T> = std::result::Result<T, EvalError>;