1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! # veer
//!
//! A semantic diff engine for LLM and agent execution traces — *find exactly
//! where two runs veer apart*.
//!
//! Ordinary text diffs are useless on agent traces: request ids and timestamps
//! churn, JSON keys come back in a different order, and "the same" step is
//! rarely byte-identical between runs. `veer` imports traces from several
//! formats into a normalized [`model::Trace`], strips incidental noise with a
//! configurable [`normalize::Normalizer`], and then *aligns* the two runs with
//! an edit-distance dynamic program whose substitution cost is a semantic
//! similarity score. The result pinpoints the first meaningful divergence and
//! gives a field-level account of every change.
//!
//! ## Quick start
//!
//! ```
//! use veerdiff::{Config, diff};
//! use veerdiff::model::{Step, StepKind, Trace};
//! use serde_json::json;
//!
//! let before = Trace::from_steps(vec![
//! Step::new(StepKind::ToolCall)
//! .with_name("get_weather")
//! .with_args(json!({"city": "Paris"})),
//! ]);
//! let after = Trace::from_steps(vec![
//! Step::new(StepKind::ToolCall)
//! .with_name("get_weather")
//! .with_args(json!({"city": "Berlin"})),
//! ]);
//!
//! let d = diff(&before, &after, &Config::default());
//! assert_eq!(d.stats.changed, 1);
//! assert!(!d.is_identical());
//! ```
//!
//! ## Importing provider traces
//!
//! ```
//! use veerdiff::{Config, import, diff};
//!
//! let a = import::import_str(r#"[{"role":"user","content":"hi"}]"#, import::Format::Auto).unwrap();
//! let b = import::import_str(r#"[{"role":"user","content":"hi there"}]"#, import::Format::Auto).unwrap();
//! let d = diff(&a, &b, &Config::default());
//! assert_eq!(d.stats.changed, 1);
//! ```
pub use ;
pub use Config;
pub use ;
pub use ;
/// Diff two traces, applying the configuration's normalization first.
///
/// This clones and normalizes both inputs, then aligns them. If you need the
/// normalized traces for rendering, normalize explicitly and call
/// [`align::align`] instead:
///
/// ```
/// use veerdiff::{Config, align, model::{Step, StepKind, Trace}};
///
/// let cfg = Config::default();
/// let mut a = Trace::from_steps(vec![Step::new(StepKind::Message).with_content(" hi ")]);
/// let mut b = Trace::from_steps(vec![Step::new(StepKind::Message).with_content("hi")]);
/// cfg.normalizer.apply(&mut a);
/// cfg.normalizer.apply(&mut b);
/// let d = align::align(&a, &b, &cfg);
/// assert!(d.is_identical()); // whitespace was normalized away
/// ```
/// Normalize two traces in place and diff them, returning the diff alongside the
/// normalized traces (handy for rendering with [`report`]).