traverse_runtime/trace/
public.rs1use serde::{Deserialize, Serialize};
4use traverse_contracts::ViolationRecord;
5use traverse_registry::ModelResolutionEvidence;
6
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9pub enum TraceOutcome {
10 Success,
12 Failure,
14}
15
16#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
20pub struct PublicTraceEntry {
21 pub id: String,
23 pub source: String,
25 pub event_type: String,
27 pub datacontenttype: String,
29 pub time: String,
31 pub capability_id: String,
33 pub placement_target: String,
35 pub outcome: TraceOutcome,
37 pub duration_ms: u64,
39 #[serde(default, skip_serializing_if = "Vec::is_empty")]
41 pub violations: Vec<ViolationRecord>,
42 #[serde(default, skip_serializing_if = "Vec::is_empty")]
44 pub model_resolution: Vec<ModelResolutionEvidence>,
45}
46
47impl PublicTraceEntry {
48 #[must_use]
50 pub fn new(
51 id: String,
52 capability_id: String,
53 placement_target: String,
54 outcome: TraceOutcome,
55 duration_ms: u64,
56 time: String,
57 ) -> Self {
58 let source = format!("traverse-runtime/{capability_id}");
59 Self {
60 id,
61 source,
62 event_type: "dev.traverse.execution.completed".to_string(),
63 datacontenttype: "application/json".to_string(),
64 time,
65 capability_id,
66 placement_target,
67 outcome,
68 duration_ms,
69 violations: Vec::new(),
70 model_resolution: Vec::new(),
71 }
72 }
73}