pub trait CostModel {
type Prepared;
// Required methods
fn prepare(&self, step: &Step) -> Self::Prepared;
fn cost_prepared(&self, a: &Self::Prepared, b: &Self::Prepared) -> f64;
// Provided method
fn cost(&self, a: &Step, b: &Step) -> f64 { ... }
}Expand description
A step-vs-step alignment cost in [0, 1]: 0.0 = identical content, 1.0 = nothing in
common. Implementations must be deterministic and symmetric — the aligner’s output is part
of the reproducibility promise, and the fork rule’s tau thresholds compare against these
values directly.
The trait is split at the per-step precomputation seam: prepare
digests one step into whatever form the model compares — LexicalCost’s token sequence,
a future tf-idf model’s term vector, an embedding — and
cost_prepared scores two digests. The aligner prepares each
run once (O(n+m)) and only scores inside the O(n·m) cost matrix, so per-step work never
multiplies by the number of cells (issue #16).
Required Associated Types§
Required Methods§
Sourcefn cost_prepared(&self, a: &Self::Prepared, b: &Self::Prepared) -> f64
fn cost_prepared(&self, a: &Self::Prepared, b: &Self::Prepared) -> f64
Cost of aligning two prepared steps.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".