Skip to main content

Module compiler

Module compiler 

Source
Expand description

The formula compiler: core_model::Formula -> TypedExpr -> PlanNode.

Phase 1 of AGENT_STEERING.md. Two passes:

  1. infer — walk the AST, infer value type + dimension for each node, resolving measure references against the model’s measure metadata. Catches structural errors (dimension mismatch) and type errors.
  2. build_plan — lower the typed tree to a PlanNode graph, inserting Join nodes to align operand dimensions and Aggregate nodes for aggregation functions.

IMPLEMENTED. This file defines the public API contract and both passes.

Structs§

CompileContext
Read-only context for compilation: the model’s measures, and its categories (their items’ order and names) when the caller has a model.

Enums§

CompileError

Constants§

FIXPOINT_MAX_ITER
The most rounds a FIXPOINT may run: its max_iter is at most this.

Functions§

build_plan
Pass 2: lower a typed expression to a plan.
compile_formula
Compile a formula for target measure into an operator plan.
derived_shape
The shape a new derived measure target named name takes from its formula: its value type and its categories, as the engine computes them (an OVER drops categories, @ITEM is text, DATE a date). A formula that reads the measure itself (a PREV recurrence) is typed with a provisional measure over the categories of the other measures it reads.
infer
Pass 1: type + dimension inference.
scalar_arity
The number of arguments a scalar (non-aggregating, non-lazy) built-in takes when that number is fixed; None for an unknown id. Kept for callers that only need “is this an element-wise built-in”.

Type Aliases§

Result