Skip to main content

Module kernel

Module kernel 

Source
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 for traversals (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§

EngineCore
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.
InputDef
Definition of a named input to the Polydat graph.
ManifestEntry
One entry in a program’s output manifest: typed, modifier- aware view of a single output name.
OutputAccessor
Memoized output accessor for a named subset of outputs.
PolydatKernel
A compiled Polydat Kernel: an Arc<PolydatProgram> plus one PolydatState.
PolydatProgram
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.
PolydatState
Polydat evaluation engine using precomputed per-input dependent lists.
ProvMask
Exact multi-word input-provenance mask: bit i set means the carrier transitively depends on graph input i. Replaces the one-word u64 whose ≥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: set grows 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).
ProvScanState
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.
ScopeCoord
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).
SharedCellEntry
One named shared cell propagated through the parent → child scope chain. Carried on PolydatKernel (and surfaced through ScopeKernel::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.
SharedCellInner
A cross-kernel mutable cell for a shared-modifier wire.

Enums§

InputKind
Classification of a named input by its evaluation lifecycle.
KernelOptLevel
Optimization level for op-template kernel synthesis.
WireSource
Source of a value for a node input port.
WriteError
Error returned by Dataflow::set_wire_idx / Dataflow::set_wire when 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.
KernelProgram
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: Kernel carries 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 PolydatProgram values 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§

SharedCell
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).