Expand description
Polydat — a variates construction engine: one function graph, compiled from Polydat source or built programmatically, run on the interpreter, as closures, or as native code, with the same values on every engine.
This crate is the facade over three crates and re-exports each at
the paths it always had: polydat_grammar (the language),
polydat_core (the runtime), and polydat_nodes (the node
library, under library beside the nodes the core keeps). A
program that compiles against polydat sees one crate.
§Quick start
§From DSL source
The simplest way to build a kernel is from Polydat DSL source, on the
default engine (native code with the jit feature, closures without):
use polydat::dsl::compile_polydat_kernel;
let mut kernel = compile_polydat_kernel(r#"
input cycle: u64
hashed := hash(cycle)
user_id := mod(hashed, 1000000)
"#).unwrap();
kernel.set_inputs(&[42]);
let user_id = kernel.pull("user_id").as_u64();
assert!(user_id < 1_000_000);§From the assembler API
For programmatic construction:
use polydat::compile::assembly::{PolydatAssembler, WireRef};
use polydat::library::hash::Hash;
use polydat::library::arithmetic::Mod;
let mut asm = PolydatAssembler::new(vec!["cycle".into()]);
asm.add_node("hashed", Box::new(Hash::new()), vec![WireRef::input("cycle")]);
asm.add_node("user_id", Box::new(Mod::new(1_000_000)), vec![WireRef::node("hashed")]);
asm.add_output("user_id", WireRef::node("user_id"));
let mut kernel = asm.compile().unwrap();
kernel.set_inputs(&[42]);
assert!(kernel.pull("user_id").as_u64() < 1_000_000);(The crate runs no doctests; both examples are
tests/rustdoc_examples.rs.)
§Documentation
The rustdoc covers the API. The narrative documentation lives in the
repository under crates/polydat/docs/, organized by the
documentation index.
Re-exports§
Modules§
- ast
- Core types for Polydat nodes: values, ports, metadata, and the evaluation trait.
- audit
- Cycle-time data-source audit log.
- binder
- Typed-binding contracts between adapters and the polydat runtime.
- compile
- Kernel compilation: assembled DAG → fast executable kernel.
- derive_
support - Trait surface that the
#[polydat_node]proc-macro (polydat-derive) calls into for boxing / unboxing wire values. - dsl
- Polydat DSL: lexer, parser, and AST for
.polydatkernel definition files. - iteration
- Iteration & coordinate algebra.
- kernel
- Polydat runtime kernel: compiled DAG with pull-through evaluation.
- library
- The node library: the nodes the compiler keeps
(
polydat_core::library) and the node library (polydat_nodes), side by side at the paths they always had. - numeric
- The numeric bodies the node library and the native lowerings
share. A node in
polydat-nodesis a thin wrapper over a function here, and the JIT helper for that node calls the same function, so the interpreter and native code compute the same bits by construction (compiled_handles.md §6, the corner suite). - resource
- Dependency-inverted resource-accessor bridge (SRD-104, Phase 0).
- tile
- Polytile at the host boundary (SRD 114 §5.6): build a tile from
template text, from structural JSON text, or from a parsed JSON
value, then compile it with a program via
tile::compile_polydat_with_tiles. - viz
- DAG visualization for Polydat Kernels.
Structs§
- Const
- SRD-80 PR B.5 — marker wrapper for const arguments in
#[polydat_node]function signatures. - Engine
Plan - What a kernel’s engine decided for its program: how much of it runs
as native segments, as closure steps, and on the interpreter. The one
planning detail a kernel exposes, on every engine
(
Kernel::plan).
Enums§
- Engine
- The engine a program runs on. Every engine accepts every program the
interpreter accepts, or refuses it with a reason
(
KernelError::Refused); the choice changes how fast the program runs and nothing else (docs/design/engine_parity.md). - JitMode
- How much of the interpreter’s graph is fused into native cones: the
interpreter engine’s one knob, carried by
Engine::Interpreterand settable per assembler withset_jit_mode. It is a property of the kernel being built, never of the process: two hosts in one process compiling under different modes get the kernels they each asked for. - Kernel
Error - Why a kernel was not built: the one error type of every constructor
that takes an
Engine. - Provenance
- How much of a kernel’s work is skipped when inputs repeat: the provenance mode a compiled engine is built with. Every mode computes the same values; the modes differ in what they recompute.
Statics§
- RESOURCE_
ACCESSOR - Process-global bridge to the host’s resource accessor, installed once by
the runtime at session start.
None(uninstalled) is the norm for any polydat use that has no host — the trait is a bridge, not a requirement.
Traits§
- 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. - Resource
Accessor - Type-erased accessor over the host’s live resource store.
Functions§
- resource_
lookup - Look up an already-attached resource’s accessor payload by fingerprint
keythrough the installedRESOURCE_ACCESSOR. - set_
panic_ reporting_ downstream - Declare that a downstream reporter will render eval-panic
diagnostics in full (see
PANIC_REPORTING_DOWNSTREAM).
Attribute Macros§
- polydat_
node #[polydat_node]— derive a polydat node from a typed Rust function signature.