Expand description
Pure planning logic for the discovery-driven request matrix (#501).
A discover: row enumerates a value-set at runtime (build source → drain →
project select → dedup); a for_each: [dims] row fans out over the
cartesian product of those value-sets, one invocation per tuple.
Everything here is pure (no I/O): projection, dedup, the cartesian product,
the per-tuple interpolation context, and the tuple state-key suffix — so the
fan-out semantics are unit-testable without a network. The only I/O (running
the discovery source) lives in the executor and feeds Dim::values.
Structs§
- Collected
Dim - A collected (list-valued) dimension (#531): a chained
discover:row (for_each: [...]+collect: true) that publishes the whole deduped value-set as one list per upstream tuple, keyed by that tuple. A consuming row injects the list into one request (${<id>.<alias>}→ comma-joined), rather than fanning out one invocation per element. - Dim
- One resolved discovery dimension: the discovery row id, the alias its projected value is exposed under, and the deduped value-set.
Constants§
- MAX_
MATRIX_ PRODUCT - Hard ceiling on the number of invocations a single
for_eachrow may expand to. A cartesian product multiplies quickly; above this the run fails rather than silently spawning an unbounded fleet.
Functions§
- cartesian
- Build the cartesian product of the dimensions as per-tuple interpolation
contexts. Each context maps
dim_id -> { alias: value }, so a token${dim_id.alias}resolves to that tuple’s value via the sameinterpolate_recordpath the parent/child matrix uses. An empty dimension yields no tuples. Pure. - collected_
tuple_ key - A canonical, symmetric key for one upstream tuple over
dims, derived from a per-tuple interpolation context ({dim_id: {alias: value}}). Both the storing side (the chained discovery, over its ownfor_eachdims) and the reading side (a consumingfor_eachrow, whose dims are a superset) compute the same key for the same tuple, so a collected list looks up correctly. Pure. - inject_
collected - Enrich a product tuple
ctxin place with every collected dimension whose list is available for this tuple, so${<id>.<alias>}resolves to the list. A collected dim with no entry for the tuple injects an empty list (the consuming request then renders an empty param — the “type has no properties” fallback). Pure. - product_
size - The number of invocations
dimsexpands to (the product of the value-set sizes). Returns0if any dimension is empty. Saturating, so it never overflows; compare againstMAX_MATRIX_PRODUCT. Pure. - project_
dedup - Project
select(a dot-path, optionally$-prefixed) from each record and dedup the results in first-seen order.null/ missing projections are skipped.$(or"") selects the whole record. Pure. - tuple_
state_ key_ suffix - Stable, collision-resistant state-key suffix for one product tuple, in
declared dimension order:
alias=value&alias=value….dimssupplies the order + aliases;ctxis one entry fromcartesian. Pure.