/** * Pure, total structural alignment + metric aggregation for comparing two * traces. Never throws (cycle-guarded), never does I/O. Deltas are honest: a * span present in only one trace has NO delta (never a fabricated 1:1 diff). */ import type { TraceSpan } from "./types.js"; export interface TraceMetrics { durationMs: number | null; totalTokens: number; costUsd: number; hasError: boolean; spanCount: number; } /** Aggregate whole-trace metrics: root duration, summed tokens/cost, any-error flag. Total. */ export declare function traceMetrics(root: TraceSpan): TraceMetrics; export interface NumericDelta { from: number | null; to: number | null; deltaPct: number | null; } export interface AlignDelta { durationMs?: NumericDelta; tokens?: NumericDelta; costUsd?: NumericDelta; } export interface AlignRow { key: string; depth: number; a?: TraceSpan; b?: TraceSpan; status: "matched" | "only-in-a" | "only-in-b"; /** Present ONLY when status === "matched" — an unpaired span has no honest delta. */ delta?: AlignDelta; } /** * Align two span trees structurally, matching children by name (greedy, * first-unused). Produces a flat, depth-annotated row list: matched pairs * carry a delta; only-in-a / only-in-b rows do not. Cycle-safe via a visited * set on span ids (a malformed self-referential tree cannot loop). */ export declare function alignSpanTrees(a: TraceSpan, b: TraceSpan): AlignRow[];