Expand description
Type and value assertion nodes.
Polydat’s runtime contract: node eval trusts its inputs. Bad input
panics, by design, because the hot path stays branch-free. The
“guarded” version of a node that would otherwise panic is built
as an assembly of two functions — the original node, and an
assertion node spliced in front of one of its inputs (SRD 15
§“Type and Value Assertion Nodes”). The assertion runs the
check; the downstream node still trusts its inputs.
Two families:
-
Type assertions — one per supported
PortType. They confirm the runtimeValuevariant matches the static port type and pass it through. Useful when provenance can’t prove the wire already carries the right type (dynamic JSON navigation,Extunwraps, cross-adapter values). -
Value assertions — one per
PortType, parameterised by aConstConstraint. Pass the value through if the constraint holds, otherwise panic with a structured message. The same vocabulary the const-constraint metadata uses onParamSpecis reused onPort(SRD 15 §“Strict Wire Mode”) and on these nodes.
Auto-insertion is the compiler’s job (M2 §“Strict Wire Mode”) — these nodes are also user-callable from Polydat source for ad-hoc guards.
Structs§
- Assert
Type - Pass-through guard that confirms the runtime value variant
matches a declared
PortType. Panics on mismatch. - Assert
Value - Runtime value-constraint guard. Holds a
ConstConstraintthe value must satisfy each cycle. Panics with a structured message on violation; passes the value through otherwise.
Functions§
- assert_
type_ node - Construct the right type assertion node for a given
PortType. - assert_
value_ node - Construct a value assertion node for the given (type, constraint) pair.