use serde::{Deserialize, Serialize};
use traverse_contracts::ViolationRecord;
use traverse_registry::ModelResolutionEvidence;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum TraceOutcome {
Success,
Failure,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PublicTraceEntry {
pub id: String,
pub source: String,
pub event_type: String,
pub datacontenttype: String,
pub time: String,
pub capability_id: String,
pub placement_target: String,
pub outcome: TraceOutcome,
pub duration_ms: u64,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub violations: Vec<ViolationRecord>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub model_resolution: Vec<ModelResolutionEvidence>,
}
impl PublicTraceEntry {
#[must_use]
pub fn new(
id: String,
capability_id: String,
placement_target: String,
outcome: TraceOutcome,
duration_ms: u64,
time: String,
) -> Self {
let source = format!("traverse-runtime/{capability_id}");
Self {
id,
source,
event_type: "dev.traverse.execution.completed".to_string(),
datacontenttype: "application/json".to_string(),
time,
capability_id,
placement_target,
outcome,
duration_ms,
violations: Vec::new(),
model_resolution: Vec::new(),
}
}
}