veerdiff 0.1.0

Semantic diff engine for LLM and agent execution traces — find exactly where two runs veer apart.
Documentation
//! Diff two traces from Rust and render the result.
//!
//! Run with: `cargo run --example programmatic`

use serde_json::json;
use veerdiff::model::{Step, StepKind, Trace};
use veerdiff::report::{RenderOptions, ReportFormat, render};
use veerdiff::{Config, diff_normalized};

fn main() {
    let before = Trace::from_steps(vec![
        Step::new(StepKind::Message)
            .with_role("user")
            .with_content("Refund order 12345"),
        Step::new(StepKind::ToolCall)
            .with_name("lookup_order")
            .with_args(json!({ "order_id": "12345" })),
        Step::new(StepKind::ToolCall)
            .with_name("issue_refund")
            .with_args(json!({ "order_id": "12345", "amount": 49.99 })),
    ]);

    let after = Trace::from_steps(vec![
        Step::new(StepKind::Message)
            .with_role("user")
            .with_content("Refund order 12345"),
        Step::new(StepKind::ToolCall)
            .with_name("lookup_order")
            .with_args(json!({ "order_id": "12345" })),
        // Regression: the new prompt refunds the full amount instead of 49.99.
        Step::new(StepKind::ToolCall)
            .with_name("issue_refund")
            .with_args(json!({ "order_id": "12345", "amount": 59.99 })),
    ]);

    let cfg = Config::default();
    let (d, na, nb) = diff_normalized(before, after, &cfg);

    println!("identical? {}", d.is_identical());
    println!("similarity: {:.3}", d.similarity);
    println!();
    print!(
        "{}",
        render(
            &d,
            &na,
            &nb,
            ReportFormat::Human,
            RenderOptions {
                color: false,
                verbose: true,
                context: 2,
            },
        )
    );
}