Skip to main content

amberfork_align/
lib.rs

1//! The alignment engine — the moat crate.
2//!
3//! Takes two [`amberfork_model::Run`]s and produces the move-typed alignment, the fork, and
4//! ultimately the [`amberfork_model::DiffResult`] the CLI and UI render. Three parts, each an
5//! empirically locked decision (see `docs/design/design-run-diff-debugger.md`, Amendment
6//! 2026-07-08, and `docs/notebook.md` 001–003):
7//!
8//! - [`cost`]: the step-vs-step cost model. v1 default is lexical ([`LexicalCost`]) —
9//!   deterministic and dependency-free. Embeddings live behind the same [`CostModel`] trait
10//!   and must beat lexical on dev fixtures to earn default status (Amendment B).
11//! - affine-gap Needleman–Wunsch over those costs, emitting [`amberfork_model::Move`]s.
12//! - the resync-k fork rule: fork = first non-sync block the alignment does not recover
13//!   from within k synchronous moves (Amendment A).
14//!
15//! Sync + pure by design: no I/O, no async, no globals. Loading runs is `amberfork-ingest`'s
16//! job; this crate is a function from two runs to a diff.
17
18mod attribution;
19mod cost;
20mod diff;
21mod field_diff;
22mod fork;
23mod nw;
24mod params;
25
26pub use cost::{CostModel, LexicalCost};
27pub use diff::{DiffParams, diff};
28pub use fork::{ForkParams, find_fork};
29pub use nw::{AlignParams, align};
30pub use params::ParamError;