Version: dev

materialize_value_invention

Stable function · Load-time lowering and templates

Tier: stable · Kind: function · Topic: Load-time lowering and templates

JuliaTypeScriptPythonRustGo
not exportednot exportedmaterialize_value_inventionmaterialize_value_inventionnot exported

Julia

Julia does not export this function.

TypeScript

TypeScript does not export this function.

Python

materialize_value_invention(model_json: Mapping[str, Any], const_arrays: Mapping[str, Any] | None = None, params: Mapping[str, Any] | None = None, const_array_boundaries: Mapping[str, Sequence[str]] | None = None, index_sets: Mapping[str, Any] | None = None, maps_only: bool = False) -> ValueInventionResult

Run the build-time value-invention engine over a raw model document.

const_arrays supplies the build-time factor arrays (the connectivity / coordinates the keys are computed from); params supplies scalar parameter overrides. A producer that classifies CONTINUOUS is rejected (§5.7 guard 2).

maps_only restricts the pass to the skolem BIN maps and their surfaced ValueInventionResult.join_key_buffers — the arg-witness maps, the grouped / derived chain, and the index-set producers are all skipped. This is the build’s join-key PRE-PASS (simulation_array._build_numpy_rhs), which needs the broad-phase equi-join columns available BEFORE the full observed hoist that the join-carrying observeds ride: it is fed only the binning-coordinate closure, so a full producer materialisation (which may read a wider const factor) could raise — maps_only guarantees the bins are produced regardless.

index_sets is the document-scoped index-set registry (RFC §5.2), which lives at the top level of the document rather than on each model — mirrors reference_resolution.build_reference_graph . When omitted it falls back to a model-local model_json["index_sets"] key, so a caller need not splice the document registry onto the model dict before calling.

const_array_boundaries optionally declares a per-const-array, per-dimension out-of-range gather policy: a mapping of array name → an iterable of per-dimension policy strings, each one of “periodic” | “clamp” | “error”. A const-array gather at an out-of-range 1-based index then resolves declaratively (“periodic” wraps via 1-based modulo, “clamp” edge-extends); any array WITHOUT a declared policy (or one with “error”) keeps raising a structured ValueInventionError , so genuine out-of-bounds bugs in connectivity / stencil-weight factors stay caught.

A no-op (empty result) for a model with no skolem/distinct/rank node — the evaluator front-door then behaves byte-identically to before.

Source

Rust

pub fn materialize_value_invention(model_json: &Value, const_arrays: &HashMap<String, ArrayD<f64>>, params: &HashMap<String, f64>, const_array_boundaries: &HashMap<String, Vec<BoundaryKind>>) -> Result<ValueInventionResult, ValueInventionError>

Run the build-time value-invention engine over a raw model document.

Value invention mints new entities from data, once at setup: unique edge IDs from a mesh, dense ranks from a categorical column, bin keys from coordinates. This evaluates every value-invention aggregate in model_json (a faq with distinct: true, or whose body or key is skolem / rank, plus the arg-witness and grouped buffers that depend on them) and returns what it materialized as a ValueInventionResult . Pass that result to apply_value_invention to rewrite the model so the array runtime can compile it.

  • model_json is the raw model document, not the typed Model : the typed expression tree does not keep an aggregate’s key and distinct fields.
  • const_arrays supplies the build-time factor arrays (connectivity, coordinates) the keys are computed from.
  • params supplies scalar parameter overrides.
  • const_array_boundaries optionally gives a per-array, per-dimension BoundaryKind for a gather at a 1-based index outside 1..=n (periodic wrap or edge clamp). An array absent from the map, or a dimension beyond its listed kinds, errors on an out-of-range index; pass an empty map for that everywhere.

A model with no skolem, distinct or rank node returns an empty result.

Errors

Returns a ValueInventionError when a producer classifies as continuous (its entities would change every step, CONFORMANCE_SPEC.md §5.7 guard 2), when a key cannot be evaluated from the build-time data, or on an out-of-range gather with no boundary policy.

Source · Rust docs

Go

Go does not export this function.