Expand description
Program-level contract and optimized execution strategies.
This module is the “planner + dispatcher” for JOSIE execution.
It takes a JSON program envelope and selects the fastest safe runtime strategy available for that specific shape.
Strategy tiers, from most specialized to most generic:
-
Fast internal plan (
CompiledProgramBody::FastInternal) Pattern-matched kernels for high-frequency pipeline shapes (loop/filter/branching/boolean/match/template/mixed workflow). These avoid per-node dynamic dispatch and run as tight Rust loops. -
Fast external map plan (
CompiledProgramBody::FastExternalMapI64) Specialized host-call flow for:x.a(p1,p2,size) -> for_each x.b(item). Uses typed host callbacks and optional metrics-only execution path. -
Compiled pipeline VM path (
CompiledProgramBody::CompiledPipeline) Pre-compilesdo,when, andargsexpressions to typed IR (Expr) and executes viavm::eval_exprwith iterator locals. -
Generic tree/pipeline fallback Preserves full semantics for any valid document not covered above.
Pipeline step contract summary:
| op | required fields | notes |
|---|---|---|
call | fn or from | optional into, args, when |
set | into, args[0] | writes to runtime var or client.*/server.* |
get | from | reads $prev, runtime vars, or state paths |
map/filter/for_each/reduce | from, do | reduce optionally uses init value from args[0] |
if/match/do/pipe | args | tree-style ops executed in pipeline flow |
| policy hints | run_hint | planner/runtime hint (inline/worker), not logic semantics |
Why this improves performance:
- Removes repeated parse and shape checks from hot loops.
- Avoids recursive
serde_json::Valueevaluation in known patterns. - Uses typed host fast-paths for external-heavy workloads.
- Keeps fallback semantics so optimization is additive, not breaking.
Structs§
- Compiled
Pipeline Step - A pipeline step with pre-compiled expressions for fast evaluation.
- Compiled
Program - Compiled execution artifact.
- Execution
Output - Execution result with final value and mutated state.
- Fast
External MapPlan - Fast
Internal Plan - Shape-specialized internal pipeline plan.
- Host
Functions - Host function registry used by optimized execution paths.
- Pipeline
Doc - Canonical pipeline document shape (
type = "pipeline"). - Pipeline
Step - Canonical pipeline step shape used by parser and executor.
- Program
- Parsed top-level program envelope.
- Runtime
Error - Structured runtime error produced during execution.
- Validation
Error - Structured validation error produced before execution.
Enums§
Functions§
- compile_
program - Compile a validated program into the most efficient execution body.
- execute_
compiled_ program - execute_
compiled_ program_ external_ metrics - Execute compiled program and return
(checksum, len)when possible. - execute_
compiled_ program_ with_ hosts - Execute a precompiled program with optional typed host function registry.
- execute_
program - execute_
program_ with_ hosts - Compile + execute in one call.
- parse_
program - validate_
pipeline - validate_
program
Type Aliases§
- Host
Call Fn - Generic host callback used by pipeline
callintegration. - Host
Generate I64Fn - Typed generator callback for optimized external map fast-paths.
- Host
MapI64 Fn - Typed mapper callback for optimized external map fast-paths.