pub struct NodeCatalog { /* private fields */ }Expand description
Every node a graph can execute, plus the states its filters have learned.
let mut lib = NodeCatalog::new();
lib.register("scaler", Box::new(MyScaler { scale: 2.0 }));
lib.register_step("researcher", Box::new(ReactStep::new("claude-opus-5")));
// Use as compiler registry
let result = somatize_compiler::compile(&graph, &lib, mode, cache)?;
// Use directly with executor — no conversion needed
executor::execute(&plan, &mut ctx, &lib, &cache)?;Cloning shares both the nodes and the state store, so a clone sees whatever the original has fitted. That is what lets one catalog serve many graph runs — an agent running pipelines back to back, for instance.
Implementations§
Source§impl NodeCatalog
impl NodeCatalog
Sourcepub fn with_state_store(states: Arc<dyn StateStore>) -> Self
pub fn with_state_store(states: Arc<dyn StateStore>) -> Self
Create a catalog with a custom [StateStore] backend.
Sourcepub fn register(&mut self, node_id: impl Into<String>, filter: Box<dyn Filter>)
pub fn register(&mut self, node_id: impl Into<String>, filter: Box<dyn Filter>)
Register a filter for a given node ID.
Sourcepub fn register_step(&mut self, node_id: impl Into<String>, step: Box<dyn Step>)
pub fn register_step(&mut self, node_id: impl Into<String>, step: Box<dyn Step>)
Register a step for a given node ID.
Sourcepub fn register_step_arc(
&mut self,
node_id: impl Into<String>,
step: Arc<dyn Step>,
)
pub fn register_step_arc( &mut self, node_id: impl Into<String>, step: Arc<dyn Step>, )
Register an already-shared step, for callers that built one elsewhere (the Python bindings do).
Sourcepub fn node_meta(&self, node_id: &str) -> Option<NodeMeta>
pub fn node_meta(&self, node_id: &str) -> Option<NodeMeta>
A node’s contract, whichever kind it is.
Sourcepub fn get(&self, node_id: &str) -> Option<Arc<dyn Filter>>
pub fn get(&self, node_id: &str) -> Option<Arc<dyn Filter>>
Get a filter by node ID. None if the id is a step, or unknown.
Sourcepub fn step(&self, node_id: &str) -> Option<Arc<dyn Step>>
pub fn step(&self, node_id: &str) -> Option<Arc<dyn Step>>
Get a step by node ID. None if the id is a filter, or unknown.
Sourcepub fn has_steps(&self) -> bool
pub fn has_steps(&self) -> bool
Does the catalog hold any effectful node at all?
The question a caller asks before building an effect driver, which costs a provider catalog read and a journal directory.
Sourcepub fn merge_from(&mut self, other: &NodeCatalog) -> Result<()>
pub fn merge_from(&mut self, other: &NodeCatalog) -> Result<()>
Copy every node of other into this catalog.
Registering the same id twice with the same configuration is a no-op; the same id behind a different configuration is an error, because whichever one lost would silently answer for the other’s cache entries. States are not merged — they follow this catalog’s store.
Sourcepub fn try_set_state(
&self,
node_id: impl Into<String>,
state: Value,
) -> Result<()>
pub fn try_set_state( &self, node_id: impl Into<String>, state: Value, ) -> Result<()>
Store a trained state for a node.
Errors bubble up from the underlying [StateStore] (e.g. I/O on
a disk-backed backend). The in-memory default never fails.
Sourcepub fn get_state(&self, node_id: &str) -> Option<Arc<Value>>
pub fn get_state(&self, node_id: &str) -> Option<Arc<Value>>
Retrieve the trained state for a node. The returned Arc<Value>
can be dereferenced (&*arc) for the forward hot path without
cloning the underlying value.
Sourcepub fn clear_states(&self)
pub fn clear_states(&self)
Drop all stored states (but keep the nodes).
Sourcepub fn state_store(&self) -> &Arc<dyn StateStore>
pub fn state_store(&self) -> &Arc<dyn StateStore>
Access the underlying [StateStore] (e.g. to share it across
sessions or inspect its contents).
Trait Implementations§
Source§impl Clone for NodeCatalog
impl Clone for NodeCatalog
Source§fn clone(&self) -> NodeCatalog
fn clone(&self) -> NodeCatalog
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for NodeCatalog
impl Default for NodeCatalog
Source§impl NodeRegistry for NodeCatalog
Implements [NodeRegistry] so the compiler can read metadata directly
from the registered implementations — filters and steps.
impl NodeRegistry for NodeCatalog
Implements [NodeRegistry] so the compiler can read metadata directly
from the registered implementations — filters and steps.
This is what closed the hole where a caller passing the filter half alone got the graph compiled with every step edge unchecked.
Source§fn node_meta(&self, node_id: &str) -> Option<NodeMeta>
fn node_meta(&self, node_id: &str) -> Option<NodeMeta>
None means the graph names a node nobody registered,
which the compiler reports rather than guesses around.