Cardinality
The second main dimension. Where mutation asks does this touch Context, cardinality asks how many values does it yield.
Definition
Each atom yields in one of three shapes:
- SCALAR - one value.
- STREAM - 0..N values.
- VOID - nothing.
Plus one polymorphic case:
- TRANSPARENT - forwards whatever the child yields (Span).
What this forces
Yielding kinds split by cardinality:
- Query ->
ScalarQuery(one value) orStreamQuery(many). - Action ->
ScalarAction(one value) orStreamAction(many).
Refs are SCALAR (one address, one value). Commands and Flows are VOID (no yield, so the split doesn't apply). Span is TRANSPARENT (forwards its body).
Consequence
A scalar consumer can't honestly accept a stream producer - there's no canonical reduction (first? last? sum? collect?). The choice belongs to the consumer, named explicitly: a reduction.
Reduction
Cardinality is what an atom yields. Reduction is what one slot takes: a consumer names one reduction slot that takes a stream; its other slots take one value.
A slot role, not a kind. Any kind yielding one value or nothing can reduce, keeping its own mutation and yield:
| Reduction | Kind | Example |
|---|---|---|
| QueryReduction | ScalarQuery | First, Collect, Reduce(op, init) |
| ActionReduction | ScalarAction | PutStream(store, stream) -> id |
| CommandReduction | Command | AppendAll(list_ref, stream) |
An ActionReduction is one write fed many values - the input-side twin of StreamAction's one write yielding many (INSERT ... SELECT vs DELETE ... RETURNING). N separate writes would lose the same atomicity.
Laws:
- a stream child outside a reduction slot is refused;
- a reduction slot holding a scalar is refused.
Stream consumers (StreamQuery, StreamAction), Flows and Spans are outside: they take streams on their own terms.