Skip to main content

tirea_contract/runtime/run/
state.rs

1use serde::{Deserialize, Serialize};
2use tirea_state::State;
3
4/// Inference error emitted by the loop and consumed by telemetry plugins.
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
6pub struct InferenceError {
7    /// Stable error class used for metrics/telemetry dimensions.
8    #[serde(rename = "type")]
9    pub error_type: String,
10    /// Human-readable error message.
11    pub message: String,
12}
13
14/// Durable inference-error envelope persisted at `state["__inference_error"]`.
15#[derive(Debug, Clone, Default, Serialize, Deserialize, State)]
16#[tirea(path = "__inference_error")]
17pub struct InferenceErrorState {
18    #[tirea(default = "None")]
19    pub error: Option<InferenceError>,
20}
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn inference_error_state_defaults_to_none() {
28        let err = InferenceErrorState::default();
29        assert!(err.error.is_none());
30    }
31}