Expand description
Polydat runtime kernel: compiled DAG with pull-through evaluation.
§Architecture
PolydatProgram (Arc, immutable, shared across all fibers)
┌──────────────────────────────────────────────────────────────┐
│ nodes[] — Box<dyn PolydatNode> in topological order │
│ wiring[] — per-node input source tables │
│ input_names[] — graph input dimension names ("cycle") │
│ output_map — name → (node_idx, port_idx) │
│ (workload params injected as Polydat constant bindings) │
│ ports — external port definitions (captures) │
└──────────────────────────────────────────────────────────────┘
PolydatState (per-fiber, mutable, private — never shared)
┌──────────────────────────────────────────────────────────────┐
│ inputs[] — current input values (e.g., [cycle]) │
│ generation — advances on set_inputs(), used for │
│ memoization (skip re-evaluation) │
│ node_generation[] — last-evaluated generation per node │
│ buffers[][] — per-node output value slots: │
│ ┌───────────┐ │
│ │ node 0 │ [Value, Value, ...] (one per output port) │
│ │ node 1 │ [Value] │
│ │ node 2 │ [Value, Value] │
│ │ ... │ │
│ └───────────┘ │
│ port_values[] — external port values (captures) │
│ port_defaults[] — initial values for ports │
│ input_scratch[] — temp buffer for node input gathering │
└──────────────────────────────────────────────────────────────┘
Evaluation:
1. fiber.set_inputs(&[cycle]) → state.inputs = [cycle],
dirty affected nodes
2. state.pull(program, "name") → walk topologically, skip nodes
already evaluated this generation,
return &buffers[node][port]
Workload params:
Numeric and string workload params are injected into the GK
source as constant bindings before compilation. They resolve
as normal Polydat outputs — no separate globals mechanism needed.Buffer layout in PolydatState:
coords[0..C) | ports[0..P) | node_buffers[...]Re-exports§
pub use activation::Activation;pub use activation::CursorSlice;pub use activation::TraversalStream;pub use intern::StaticInterner;pub use intern::static_pair;
Modules§
- activation
- The activation runtime for
fortraversals (SRD 113 §3.4, §3.6, §5). - intern
- The static string interner: workload-compile-time string constants
with process lifetime. Every string literal,
Const<&str>argument, and tile static run is interned at kernel build; a compiled step that produces such a constant publishes a(ptr, len)pair to the interned bytes, which never move and are never freed, so the pair has a proven owner for the life of the process (jit_boundary.md, axiom S7). Interning the same text twice yields the same bytes. - interp
{name}-style template interpolation against a Polydat Kernel.- subcontext
- SRD-67 — parent-gated Polydat sub-context construction.
Structs§
- Engine
Core - Shared evaluation state for all Polydat engines. Contains the node output buffers, input values, and the eval loop. Engine types wrap this and provide their own invalidation strategy.
- Input
Def - Definition of a named input to the Polydat graph.
- Manifest
Entry - One entry in a program’s output manifest: typed, modifier- aware view of a single output name.
- Output
Accessor - Memoized output accessor for a named subset of outputs.
- Polydat
Kernel - A compiled Polydat Kernel: an
Arc<PolydatProgram>plus onePolydatState. - Polydat
Program - A compiled program: the nodes in topological order, their wiring,
the inputs, the outputs, and the metadata the compiler attached.
Immutable once built, and shared across kernels through an
Arc. - Polydat
State - Polydat evaluation engine using precomputed per-input dependent lists.
- Prov
Mask - Exact multi-word input-provenance mask: bit
iset means the carrier transitively depends on graph inputi. Replaces the one-wordu64whose ≥63 saturation aliased every high input (a real shape — a workload root’s params + shared wires crossed 64 inputs on 2026-08-03). Self-sizing:setgrows the word vector to the highest observed index, so callers never plumb an input-count and masks from different programs stay comparable (absent words read as zero). - Prov
Scan State - Polydat evaluation engine using provenance bitmask scanning.
- RawState
- Polydat evaluation engine with no provenance. Every
set_inputs()marks all nodes dirty. Baseline for benchmarking provenance overhead. - Scope
Coord - One scope’s worth of iteration coordinates — the LHS names
and current values of every
extern <var>: <type>clause that scope declared (excluding ones inherited from a parent). - Shared
Cell Entry - One named shared cell propagated through the parent → child
scope chain. Carried on
PolydatKernel(and surfaced throughScopeKernel::shared_cells_in_scope) so a descendant whose program declares a matching input slot can attach the cell — even when intermediate scopes’ bodies never name it and so have no input slot for it themselves. - Shared
Cell Inner - A cross-kernel mutable cell for a
shared-modifier wire.
Enums§
- Input
Kind - Classification of a named input by its evaluation lifecycle.
- Kernel
OptLevel - Optimization level for op-template kernel synthesis.
- Wire
Source - Source of a value for a node input port.
- Write
Error - Error returned by
Dataflow::set_wire_idx/Dataflow::set_wirewhen the typed-write contract at the composition-substrate boundary cannot be satisfied.
Traits§
- Construction
- Construction interface — the two sanctioned construction paths. Per the kernel-construction invariant:
- Dataflow
- The interpreter kernel’s healing write and raw read: write inputs, read wires.
- Kernel
- A kernel on any engine: the interpreter, the closure tier, the hybrid kernel, or pure native code. Every engine accepts every program the interpreter accepts, or refuses it at construction with a reason, and computes the same values for the same inputs; the choice of engine changes how fast a program runs and nothing else. This trait is the surface a host drives an engine through without knowing which one it has.
- Kernel
Program - A program on some engine, shared across threads through an
Arc; every kernel created from it computes the same values and owns its own inputs, buffers, and outputs. - Metadata
- Read-only metadata about the interpreter’s kernel: structural
shape, types, names, scope layering. Everything that’s a property
of the compiled program (or fiber-state instance) but isn’t itself
a runtime value. Interpreter-only:
Kernelcarries the names and types every engine reports. - WireKey
- A wire reference — either a pre-resolved index (fast path) or a name (resolved against the context’s input map).
Functions§
- extract_
manifest - Extract the output manifest from a compiled Polydat program. Returns one entry per output, in declaration order.
- format_
scope_ coordinate_ path - Format a scope-coordinate path as striated parens, leaf-first:
(k=10, limit=20), (table=…, optimize_for=…). Empty strata are skipped, so a chain that passes through a non-comprehension scope (e.g. a scenario node that’s just a phase list) doesn’t render an empty(). Returns""for an empty path so callers can wrap with(…)parens at their own discretion. - program_
count - Count the programs reachable from
program: itself plus every traversal body at every depth. This is the number of compiled programs a traversing kernel needs for its whole lifetime, however many tuples it dispenses. - programs_
built - Number of
PolydatProgramvalues constructed so far in this process, across every compile path. - set_
panic_ reporting_ downstream - Declare that a downstream reporter will render eval-panic
diagnostics in full (see
PANIC_REPORTING_DOWNSTREAM).
Type Aliases§
- Shared
Cell - Externally-held handle to a shared cell.
Arc<SharedCellInner>so a single cell can be referenced from many kernels at once. The handle is cheap to clone (Arc bump).