pub enum Node {
Agent(AgentNode),
Tool(ToolNode),
Gate(GateNode),
Branch(BranchNode),
Map(MapNode),
Fold(FoldNode),
}Expand description
One node in a graph: exactly one of the six kinds the runtime knows how to execute.
Adjacently tagged like the event enum: each node serializes as {"kind": "...", "payload": {...}}. The tag (kind) and content (payload) live in
separate keys, which never collides with a payload field and does not force
payloads to be JSON objects. deny_unknown_fields on the enum rejects any
key other than kind and payload.
The stable node id lives inside each payload (every payload struct carries
an id), reachable generically through Node::id. Keeping the id in the
payload is what lets the outer shape stay exactly the two-key adjacent
tagging the event log uses, with no third common field to special-case.
Variants§
Agent(AgentNode)
A full agent loop (model, prompt, tools, budget). The whole v0.1 product becomes one node kind. It references its agent definition BY CONTENT HASH, never an embedded definition, so this crate stays a leaf that does not depend on the agent-definition schema.
Tool(ToolNode)
A single direct tool invocation, no model in the loop.
Gate(GateNode)
Human approval: suspends the graph run and renders in the approval inbox.
Branch(BranchNode)
Routes on a typed output. The cases (conditions and their names) are recorded as DATA here; this crate never evaluates them.
Map(MapNode)
Fan-out: spawn a sub-run per element of a typed list, join on completion, with a concurrency cap.
Fold(FoldNode)
Bounded iteration: run a body repeatedly, accumulating across passes, until a stop predicate holds or an iteration bound is reached, then join the passes into one value. Models an adversarial refine loop (draft, score, review, revise) as one node. Execution is not implemented: the fold exists in the format, the validator, the projection, and the canvas; the engine records a typed refusal for it.
Implementations§
Source§impl Node
impl Node
Sourcepub fn kind_name(&self) -> &'static str
pub fn kind_name(&self) -> &'static str
The kind name ("agent", "tool", …), for error messages.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
The node’s optional display name, whatever its kind. See the module docs’ “The optional node display name” section.
Sourcepub fn input_schema(&self) -> Option<&Value>
pub fn input_schema(&self) -> Option<&Value>
The JSON Schema this node declares for the payload it CONSUMES, if any. Absent means the node does not declare an input type, and an edge into it passes the type-compatibility check unchecked.
Sourcepub fn output_schema(&self) -> Option<&Value>
pub fn output_schema(&self) -> Option<&Value>
The JSON Schema this node declares for the payload it PRODUCES, if any. Absent means the node does not declare an output type, and an edge out of it passes the type-compatibility check unchecked.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Node
impl JsonSchema for Node
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more