Skip to main content

NodeCatalog

Struct NodeCatalog 

Source
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

Source

pub fn new() -> Self

Create a new catalog with an in-memory state store.

Source

pub fn with_state_store(states: Arc<dyn StateStore>) -> Self

Create a catalog with a custom StateStore backend.

Source

pub fn register(&mut self, node_id: impl Into<String>, filter: Box<dyn Filter>)

Register a filter for a given node ID.

Source

pub fn register_step(&mut self, node_id: impl Into<String>, step: Box<dyn Step>)

Register a step for a given node ID.

Source

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

Source

pub fn len(&self) -> usize

Number of registered nodes, of either kind.

Source

pub fn is_empty(&self) -> bool

Whether the catalog is empty.

Source

pub fn node(&self, node_id: &str) -> Option<&NodeImpl>

What sits behind a node id.

Source

pub fn node_meta(&self, node_id: &str) -> Option<NodeMeta>

A node’s contract, whichever kind it is.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn node_ids(&self) -> Vec<&str>

Registered node ids, sorted, so listings are stable.

Source

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.

Source

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.

Source

pub fn clear_states(&self)

Drop all stored states (but keep the nodes).

Source

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

Source§

fn clone(&self) -> NodeCatalog

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for NodeCatalog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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>

A node’s contract — schemas, cacheability, effectfulness — whichever kind it is. None means the graph names a node nobody registered, which the compiler reports rather than guesses around.
Source§

fn config_hash(&self, node_id: &str) -> Option<CacheKey>

The node’s configuration identity, folded into cache keys. Required rather than derived because only the registry knows how a node’s configuration is canonicalized (Rust: canonical CBOR of fields; Python: qualname + config + source hash).
Source§

fn meta(&self, node_id: &str) -> Option<FilterMeta>

The computational view, for the phases that only make sense for a filter: gradient flow, differentiable collapsing. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

The receiver as &dyn Any, ready for downcast_ref.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more