Skip to main content

Module ast

Module ast 

Source
Expand description

Core types for Polydat nodes: values, ports, metadata, and the evaluation trait.

The Polydat type system has three layers:

  1. Runtime values (Value) — the enum that flows through the DAG at evaluation time. Every buffer slot holds a Value.

  2. Port types (PortType) — compile-time type tags on node input/output ports. The assembler validates that wiring connects compatible types and auto-inserts adapters when not.

  3. Slot types (SlotType) — distinguishes wire inputs (cycle-time values) from constant parameters (baked at construction). The DSL compiler uses these to decide whether a literal in a function call is a wire promotion or a const arg.

The PolydatNode trait is what every node function implements. A node declares its port metadata via NodeMeta and evaluates via eval(&[Value], &mut [Value]).

Structs§

Bits128
A value flowing through the DAG at runtime.
CompiledSlotKit
A slot-compiled node’s closure plus its scratch declaration (one ScratchElem per vector-producing output, in port order). Returned by PolydatNode::compiled_slot.
FusionSubgraph
Borrowed view of the subgraph a fusion node replaced. Local wiring convention: WireSource::Input(i) refers to the fusion node’s i-th input wire in the OUTER graph; NodeOutput(j, p) refers to member j’s port p.
NodeMeta
Metadata describing a node’s interface: its input slots and output ports.
NodeState
Node-defined state held by a kernel state (ScratchElem::State): what a node keeps between its evaluations in one state, typed by the node and never shared between states. Empty until the node first fills it; a clone is empty, since a clone of a state is a new state (compiled_handles.md §3).
Port
Descriptor for a single input or output port on a node.
SimdVariant
Semantic contract for a scalar node’s explicitly registered SIMD variant.
SliceArc
Arc-managed typed slice. Holds a borrow into a parent Arc’d owner — typically either an owned backing buffer (Arc<[T]>) or a long-lived resource like an mmap’d dataset. Cloning is one Arc::clone (atomic increment, zero allocations); the owner is type-erased as Arc<dyn Any + Send + Sync> so the same SliceArc<T> shape covers both modes.

Enums§

Commutativity
Declares which inputs of a node are interchangeable.
CompileLevel
The maximum compilation level a node supports.
ConstValue
A concrete constant value stored in node metadata.
JitType
JIT-compatible primitive carriers.
Lifecycle
The lifecycle of a port’s value.
PortType
Compile-time type tag for a port on a Polydat node.
Purity
Per-node purity classification per runtime_model.md’s D2 axiom and composition_substrate.md’s T1+T2 axioms.
RegLanes
Lane-typing view tag for Value::Reg128 — which interpretation a 128-bit register word currently carries (type_system_alignment.md §8.4 layer 2). Raw is the algorithm-defined buffer-state view (heterogeneous lane roles); the typed views are homogeneous [T; N] readings. All views are free bitcasts of one another.
ScratchBuf
One kernel-owned scratch buffer. A Ref2 output port’s (ptr, len) buffer slots view its scratch — the kernel owns the allocation, so the pointer is valid exactly as long as the producing step doesn’t rerun (and a rerun rewrites the slots before any consumer reads them). No Arc traffic, no allocation after warmup: a string or byte string is rewritten in place, a value is replaced.
ScratchElem
Element type of one kernel-owned scratch buffer (type_system_alignment.md §8.4 layer 3). One entry per Ref2-colored output port of a slot-compiled node: a typed vector, a string, a byte string, or a value held by reference.
SideChannelSink
Where a Purity::SideChannel node writes its observable side effects. Hosts reasoning about side-channel determinism (D2) pattern-match on this to know what observable surface to expect.
Slot
A single logical input to a node: either a runtime wire or an assembly-time constant. The positional order in NodeMeta.slots matches the function call syntax in the DSL.
SlotColor
Slot color of a PortType in compiled kernel buffers — axiom S1: static, total, three-valued. Imm* slots carry immediate data only (never addresses); Ref2 pairs carry a (ptr, len) reference to storage with a proven owner: the step’s own scratch, an extern’s stored value, an interned constant, or a boundary value alive for the call. They are engine-internal per axiom S2.
SlotType
The type discriminant for a slot: wire or typed constant.
Value
A typed value on a wire: what a node reads and produces on the interpreter, and what a host sets and pulls on every engine.
ValueRef
A borrowed view of a Value (SRD 115 §6.1): what a compiled helper or closure sees for an argument it does not own. A scalar is carried by value, a string or byte string by reference into the arena or the interner, a JSON value by reference into the value table, and any other variant by reference to the Value itself. The P1 nodes build the same view from their Value inputs, so one body serves both tiers without copying a string argument to inspect it.
WireCost
Cost class for an input wire, indicating how expensive it is to change the value on this port.

Traits§

PolydatNode
Runtime evaluation interface for a Polydat node.
ReflectedValue
Trait for adapter-contributed value types.
SlotShape
What a port type means to a compiled buffer: its slot color, the width that follows from it, and the scratch element a by-reference producer owns. The type itself is the grammar’s (polydat_grammar::PortType); these are the runtime’s reading of it, and every layout, codegen, and guard decision derives from them.

Functions§

compile_level_of
Determine the compile level of a node (works on trait objects).

Type Aliases§

CompiledSlotOp
Compiled closure for a node with typed-slice ports (§8.4 layer 3). Same calling shape as CompiledU64Op plus the step’s scratch buffers: slice inputs arrive as (ptr, len) slot pairs in inputs; vector outputs are written into scratch and their (ptr, len) into outputs.
CompiledU64Op
A compiled u64-only evaluation step.