Skip to main content

Crate improv_engine

Crate improv_engine 

Source
Expand description

Improv computation engine.

Phase 1. Before building the full formula compiler on differential dataflow, this module contains the DD-viability spike (see AGENT_STEERING.md Constraint 1): proof that a Coordinate-keyed, f64-valued incremental computation (Revenue = Price * Quantity) works on differential dataflow, including a live delta after the initial run.

Encoding at the dataflow boundary (timely 0.13’s exchange bound is serde Serialize + Deserialize plus Ord + Hash for keys; a Coordinate’s BTreeMap and a raw f64 are encoded rather than used directly):

  • DD key = the coordinate as a sorted Vec<(u32, u32)> (category, item). Deterministic and Ord + Hash.
  • cell value = CellValue: a number as f64::to_bits() (so it is Eq + Hash), or a boolean, text, date (epoch ms) or error.
  • diff R stays isize multiplicity; a reduce collapses to one value/key.

core_model types convert to/from these encodings at the edge.

Modules§

builtins
Evaluation of the scalar built-in functions in [improv_core_model::functions::all]: one value per argument in, one value out. The dataflow maps this over aligned cells and the scalar evaluator calls it directly, so both give bit-identical results.
compiler
The formula compiler: core_model::Formula -> TypedExpr -> PlanNode.
dataflow
Build a differential-dataflow graph from compiled PlanNodes and run a whole Model to a set of computed derived-measure values.
external
Host-side evaluation of external-function measures (Phase 6).
plan
The operator plan: a lowered, dimension-explicit representation of a formula that maps directly onto differential-dataflow operators.
reduce
The reductions: what an aggregation (SUM(x OVER T), CORREL(x, y OVER T), NPV(rate, cf OVER T)) computes from one group’s rows.
scalar
A pure scalar evaluator: one formula, one value per input, no dimensions.
session
Live incremental edit API.
typed
Typed expression layer: the formula AST enriched with inferred value type and dimension (the set of categories a subexpression ranges over).

Enums§

CellValue
The dataflow encoding of a cell value.

Functions§

decode_coord
Decode a dataflow key back into a Coordinate.
display_number
A number as people read it: at most 15 significant digits, the precision an f64 always carries through decimal, so binary noise like 58.650000000000006 (from 1173 * 0.05) shows as 58.65. The value itself is untouched; exports (CSV, SQL, Postgres) keep every bit.
encode_coord
Encode a Coordinate as its dataflow key (BTreeMap already iterates sorted).
project_key
Project a coord key down to a subset of category ids (join key / broadcast). Exactly the pairs whose category is kept, in order (proven in improv_verified::keys::project).

Type Aliases§

CoordKey
The dataflow encoding of a coordinate: sorted (category_id, item_id) pairs.