Skip to main content

codetether_agent/rlm/oracle/record/
mod.rs

1//! Serialisable oracle trace record and verdict conversion.
2//!
3//! [`OracleTraceRecord`] is the on-disk / S3 representation of
4//! an oracle result.  The [`OracleResult::to_record`] method in
5//! the sibling [`convert`] module flattens the enum into this
6//! flat struct for JSON serialisation.
7//!
8//! # Examples
9//!
10//! ```ignore
11//! let record = oracle_result.to_record();
12//! assert_eq!(record.verdict, "golden");
13//! ```
14
15mod convert;
16
17use serde::{Deserialize, Serialize};
18
19use super::trace_types::ValidatedTrace;
20
21/// Flat, serialisable snapshot of an oracle verdict plus its
22/// full trace — the unit of persistence for the spool and S3.
23///
24/// Produced by [`super::trace_types::OracleResult::to_record`].
25///
26/// # Examples
27///
28/// ```ignore
29/// let record = OracleTraceRecord {
30///     verdict: "golden".into(),
31///     reason: None,
32///     agreement_ratio: None,
33///     trace: validated_trace,
34/// };
35/// ```
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct OracleTraceRecord {
38    /// Classification string: `"golden"`, `"consensus"`,
39    /// `"unverified"`, or `"failed"`.
40    pub verdict: String,
41    /// Human-readable explanation when the verdict is not golden.
42    pub reason: Option<String>,
43    /// Consensus agreement ratio, present only for the
44    /// `Consensus` variant.
45    pub agreement_ratio: Option<f32>,
46    /// Complete validated trace snapshot.
47    pub trace: ValidatedTrace,
48}