Expand description
Blueprint Compiler, CompiledAgentTable, and the three default
SpawnerFactory implementations.
§Pipeline
Blueprint (= flow + agents + hints + strategy + spawner_hints)
│
│ Compiler.compile(&bp) ← this module (AgentDef → SpawnerAdapter table)
▼
CompiledBlueprint {
router: Arc<CompiledAgentTable>, // ctx.agent → SpawnerAdapter lookup
flow: FlowNode, // the flow.ir source (evaluated via EngineDispatcher)
metadata: BlueprintMetadata,
}
│
│ service::linker::link(router, blueprint.spawner_hints.layers, &engine)
▼ ↑ Layer wrapping is done separately (src/service/linker.rs)
`Arc<dyn SpawnerAdapter>` (already wrapped with base + hint SpawnerLayers)
│
▼ EngineDispatcher::with_spawner → engine.dispatch_attempt_withCompiledAgentTable is a thin table: it looks up routes[name] by
ctx.agent and hands the spawn off to the matching SpawnerAdapter.
The routes map is built at compile time through SpawnerFactory
implementations. Layer wrapping is not part of this module — it lives
in service::linker::link.
Structs§
- Compiled
Agent Table - The compile result: an
agent name → SpawnerAdapterlookup table. - Compiled
Blueprint - The result of
Compiler::compile— a routing table plus the unmodified flow and metadata, ready to hand toEngineDispatcher::with_spawner/mlua_flow_ir::eval_async. - Compiler
- Turns a
Blueprintinto aCompiledBlueprintby resolving everyAgentDefagainst aSpawnerRegistry. One-shot: build a freshCompilerpercompile()call (or reuse it — it holds no per-compile state). - Host
Bridge - Rust-side bridge function callable from Lua.
- LuaIn
Process Spawner Factory - Factory for
AgentKind::Lua. Atbuildtime it looks thefn_idup in its internal registry and returns anInProcSpawnerwith the Lua-evalWorkerFnregistered underagent_name— oneInProcSpawnerinstance per agent. - LuaScript
Source - Carrier type for Lua script sources. Paths are not required — a source string plus an identifying label is all it holds.
- LuaWorker
- Concrete Worker type for the Lua kind — a handle to a Lua-eval task
inside an mlua VM. Embeds a
WorkerJoinHandler. Reserved as the home for future Lua-specific extensions (an mlua VM cancellation mechanism, Lua-side error type retention, and so on). - Operator
Spawner Factory - Factory for
AgentKind::Operator. Looks up theArc<dyn Operator>pre-registered underspec.operator_refand wraps it in anOperatorSpawner. - Rust
FnIn Process Spawner Factory - Factory for
AgentKind::RustFn. Atbuildtime it looks thefn_idup in its internal registry and returns anInProcSpawnerwith the Rust closureWorkerFnregistered underagent_name. - Rust
FnWorker - Concrete Worker type for the RustFn kind — a handle to a task that
directly calls a Rust closure. Embeds a
WorkerJoinHandler. Being a pure function, there is minimal kind-specific extension surface here; the primary purpose is to nail down the type binding. - Spawner
Registry AgentKind → SpawnerFactorymapping. The compiler looks entries up duringcompile().- Subprocess
Process Spawner Factory - Factory for
AgentKind::Subprocess. Turns the spec into aProcessSpawner.
Enums§
- Compile
Error - Everything that can go wrong while
Compiler::compileturns aBlueprintinto aCompiledBlueprint.
Traits§
- Spawner
Factory - Factory trait that interprets an
AgentDefand builds the concreteSpawnerAdapter. Register one per kind. Parsing the spec, validating it, and baking the profile are the implementation’s job. - Spawner
Factory Kind - Companion trait that carries the type-side source of truth for
the Adapter ↔
AgentKindcorrespondence.