Expand description
Canonical trajectory model for amberfork — the frozen contract every crate reads.
A Run is one agent trajectory: an ordered list of Steps plus optional DAG
Edges. This is the input seam — amberfork-ingest produces it from OTel/plain JSON,
and amberfork-align consumes it. It mirrors the public wire format documented in
docs/trace-format.md; once this crate exists, these types are the source of truth and
that document tracks them.
DiffResult is the matching output seam: what amberfork-align fills in and the CLI’s
--json and the Leptos UI render.
Design rules baked into the types (see docs/design/design-run-diff-debugger.md):
outcomeis a run-level verdict supplied by the user, never inferred from span status.- Timing (
t_start/t_end) is display-only and is never an alignment signal, so it stays a raw string here rather than a parsed timestamp. inputs/outputsdistinguish text from structured payloads in the type itself, because the diff engine text-diffs strings but field-diffs objects.
Structs§
- Attribution
- Where the regression is attributed and how far it propagated.
- Counterfactual
- The counterfactual evidence behind an attribution.
- Diff
Result - The complete result of diffing two runs — the frozen output contract.
- Edge
- A directed DAG edge between step indices,
[from, to]on the wire. A tuple struct so it serializes as a two-element array, matchingdocs/trace-format.md. - Field
Diff - A field-level difference within an aligned step pair (the object/text diff inside a sync move). Emitted only where the payloads actually differ.
- Fork
- The divergence point: the first non-sync block the alignment does not recover from (resync-k rule; see the 2026-07-08 amendment). Absent on a converged diff.
- Meta
- Envelope metadata for a result.
- Move
- One move in the alignment. The invariant tying
kindto the indices — sync has both, log has onlyb_idx, model has onlya_idx— is guaranteed by theMove::sync/Move::log/Move::modelconstructors. - Run
- One agent trajectory: the unit
amberfork diffaligns against another. - RunPair
- The two runs a diff is over.
aandbare neutral sides; which one failed is carried by each ref’sOutcome, and step indices inMove/Forkare relative to these. - RunRef
- A lightweight handle to a run — enough to label a side in the UI without re-embedding the whole trajectory.
- Schema
Version - Version of the trace-format / model contract. Breaking changes (renames, removals, semantic shifts) bump it; additive optional fields do not. Kept as a newtype so the version is a first-class, self-documenting value across the workspace rather than a bare string.
- Step
- One node in a trajectory.
- Warning
- A non-fatal diagnostic emitted while building the diff (e.g. unmapped attributes, content absent from a metadata-only trace).
Enums§
- Attribution
Mode - Whether attribution was computed structurally or by counterfactual re-execution.
- Field
Diff Kind - How a single field changed between two aligned steps.
- Move
Kind - The class of an alignment move, in the process-mining sense the aligner uses: a synchronous
move pairs a step from each run; a log/model move is a gap present on only one side. By
convention run
bis the “log” (observed/failing) and runais the “model” (reference), so aMoveKind::Logstep is extra inband aMoveKind::Modelstep is missing fromb. - Outcome
- Run-level verdict, if known. Deliberately supplied by the user (an assertion, a label, a gold answer) — amberfork never derives it from trace/span status.
- Payload
- A step’s
inputsoroutputs. The variant is the semantic seam the diff engine reads:Payload::Textgets text diffing,Payload::Objectgets field-level diffing. The untagged catch-allPayload::Otherkeeps the “any log massaged into this shape” promise alive — an array/number/bool payload is preserved verbatim instead of failing the parse. - Recovery
- Outcome of counterfactual re-execution: did patching the origin step recover the run? The
tri-state (rather than a bare
bool) makes “we did not verify” a first-class, honest value. - Source
- Which execution path produced the inputs: passively aligning existing traces, or an
amberfork recordcapture session. - Step
Kind - The structural class of a step. Part of the identity the aligner keys on. This is the
canonical, post-normalization vocabulary:
amberfork-ingestis responsible for mapping the many framework-specific span kinds down onto these four. - Warning
Code - Known warning codes. A closed set so the vocabulary stays single-sourced across crates; adding a code is a deliberate, versioned change to this contract.