Skip to main content

Module runtime

Module runtime 

Source
Expand description

Runtime evaluator — walks an algebra Comprehension AST against a live parent kernel context to produce typed coordinate tuples.

§Why this is separate from the static IR interpreter

The static IR interpreter (super::ir::interpreter) walks a compiled stack-machine program over fully-statically- resolvable Source variants (IntRange, Literal). It has no notion of a runtime parent kernel, which is correct for the spec §9.5 consumption surfaces it serves.

Runtime comprehension evaluation is fundamentally different:

  • Source-text evaluation requires the parent kernel. Source::Generator { expr: "pre_{outer}" } and Source::WorkloadParamList { name } resolve against the parent kernel’s chain — {outer} substitution via interpolate_via_kernel, kernel.lookup(name) for workload params.
  • Cartesian is dependent-tuple, not independent. Clause N’s spec text may reference iter-vars from clauses 1..N-1. Per-branch kernels (via PolydatKernel::materialize_subscope) carry the prior values forward so each clause evaluates against the correct context. This is SRD-18b §“Dependent Tuple Iteration”.
  • Filter predicates evaluate against per-tuple kernels. The predicate text is interpolated against a kernel with every tuple value installed, then run through eval_const_expr.

All three depend on polydat-side primitives that exist today; this evaluator is the algebra-typed entry point for them.

§What this owns

evaluate_for_iteration is the public surface: (algebra AST + parent kernel + canonical kernel + workload params) → Vec<RuntimeTuple>. The returned tuples carry polydat Values ready for per-iteration kernel construction via PolydatKernel::for_iteration.

Order modifiers route through the unified Strategy::apply (spec §10.7.8): each node returns its tuples paired with the IndexFn the materialized stream satisfies; the Order node assembles an EvaluatedInput and invokes the strategy. V4 fires at this site, definitively.

§What this does NOT own

  • Per-iteration kernel construction. The evaluator returns tuples; the caller (executor or stream surface) builds the per-iter kernel via PolydatKernel::for_iteration.
  • Empty-clause policy (strict / warn). The caller passes an on_empty callback the same way enumerate_tuples does today.

Structs§

EmptyClause
Reason a clause produced no values, for the caller’s empty-clause policy callback.

Enums§

RuntimeError
Errors the runtime evaluator surfaces.

Functions§

evaluate_for_iteration
Evaluate a comprehension against the parent kernel and produce the typed coordinate-tuple list.

Type Aliases§

RuntimeTuple
Runtime tuple type — polydat-Value-based to preserve Ext typing (Partition / Json / etc.) through the iteration pipeline. The algebra layer’s Tuple uses TupleValue which is scalar-only; this RuntimeTuple is what the executor actually wants for per-iteration kernel binding via PolydatKernel::for_iteration.