mod builder#

module builder#

Prediction trie builder with incremental accumulator merge.

Ports the core algorithm from NAT’s trie_builder.py: extract LLM call contexts from run records, compute 4-signal sensitivity scores with min-max normalization, update streaming accumulators at every trie node along the path, and build the final PredictionTrieNode tree.

Structs and Unions

struct PredictionTrieBuilder#

Builds a PredictionTrieNode tree from RunRecords via incremental accumulator merge.

Usage

let mut builder = PredictionTrieBuilder::new(Some(SensitivityConfig::default()));
builder.add_run(&run1);
builder.add_run(&run2);
let trie = builder.build();

Implementations

impl PredictionTrieBuilder#

Functions

fn accumulators(&self) -> &AccumulatorState#

Returns a reference to the underlying accumulator state.

fn add_run(&mut self, run: &RunRecord)#

Processes a single RunRecord and updates accumulators.

Extracts LLM call contexts, optionally computes sensitivity scores, and updates accumulators at every node along each call’s path.

fn build(&self) -> PredictionTrieNode#

Constructs the prediction trie from accumulated data.

Iterates all accumulated nodes, navigates/creates the trie path, and populates predictions from the accumulators.

fn new(sensitivity_config: Option<SensitivityConfig>) -> Self#

Creates a new builder with optional sensitivity scoring.

fn with_accumulators(accumulators: AccumulatorState, sensitivity_config: Option<SensitivityConfig>) -> Self#

Creates a builder seeded with pre-existing accumulators.

Used by the learner pipeline to resume incremental learning from a stored AccumulatorState.

struct SensitivityConfig#

Configuration for auto-sensitivity scoring.

Weights and scale match NAT defaults from trie_builder.py lines 41-48.

sensitivity_scale: u32#

Integer scale for quantized sensitivity (1…=scale).

w_critical: f64#

Weight for the critical-path signal.

w_fanout: f64#

Weight for the fan-out signal.

w_position: f64#

Weight for the U-shaped position signal.

w_parallel: f64#

Weight for the parallel-penalty signal.

Traits implemented

impl Default for SensitivityConfig#