1use serde::{Deserialize, Serialize};
7
8use crate::event::{RawEvent, SourceTier};
9use crate::intent::IntentBatch;
10use crate::SanitizedEvent;
11
12fn default_source_tiers() -> Vec<SourceTier> {
13 Vec::new()
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct GoldenTrace {
28 pub trace_id: String,
30 pub window_start_ms: i64,
32 pub window_end_ms: i64,
34 pub raw_events: Vec<RawEvent>,
36 pub expected_sanitized: Vec<SanitizedEvent>,
38 pub expected_intents: IntentBatch,
40 pub expected_actions: Vec<ExecutedAction>,
42 #[serde(default = "default_source_tiers")]
46 pub source_tiers: Vec<SourceTier>,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct ExecutedAction {
52 pub action_type: String,
54 pub target: Option<String>,
56 pub executed_at_ms: i64,
58 pub success: bool,
60 pub error_reason: Option<String>,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct ReplayResult {
67 pub trace_id: String,
69 pub sanitization_match: bool,
71 pub sanitization_divergences: Vec<usize>,
73 pub policy_match: bool,
75 pub policy_divergences: Vec<String>,
77 pub execution_match: bool,
79 pub execution_divergences: Vec<usize>,
81}
82
83impl ReplayResult {
84 pub fn all_match(&self) -> bool {
87 self.sanitization_match && self.policy_match && self.execution_match
88 }
89}