NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::graph::SubgraphNode Class Reference

Node that runs a compiled GraphEngine as a single node (hierarchical composition). More...

#include <node.h>

Inheritance diagram for neograph::graph::SubgraphNode:
[legend]
Collaboration diagram for neograph::graph::SubgraphNode:
[legend]

Public Member Functions

std::string checkpoint_thread_id (const std::string &parent_thread_id, int parent_step, std::string_view task_id, std::string_view graph_invocation_id={}) const
 Reconstruct an inspection namespace from its parent path and invocation.
 
std::string get_name () const override
 Get the node's unique name within the graph.
 
asio::awaitable< NodeOutput > run (NodeInput in) override
 v0.4 PR 9a: unified run — drives the child engine via run_async (or run_stream_async when in.stream_cb is non-null), maps channels through input_map / output_map.
 
 SubgraphNode (const std::string &name, std::shared_ptr< GraphEngine > subgraph, std::map< std::string, std::string > input_map={}, std::map< std::string, std::string > output_map={}, SubgraphPersistence persistence=SubgraphPersistence::Legacy)
 Construct a subgraph node.
 

Detailed Description

Node that runs a compiled GraphEngine as a single node (hierarchical composition).

Enables the Supervisor pattern and nested workflows. Input mappings seed the child from the parent's current channel values. Output mappings forward only child-produced ChannelWrite deltas, in execution order and with Mode intact; they never feed the child's final state snapshot through the parent reducer. An explicit child Mode::Overwrite is the snapshot-replacement operation.

Runtime context is deliberately derived at the engine boundary rather than stored in additional public RunContext fields: cancellation reaches a child through a descendant operation token; usage, deadline, trace ID, and stream mode are inherited; and a non-empty child thread ID is a deterministic derivative of the parent invocation. An unscoped parent (empty thread ID) leaves the child unscoped, preserving the checkpoint coordinator's disabled behavior. A parent Store or checkpoint backend takes precedence when present, otherwise the child engine keeps its own configured resource. Parent ToolGate policy runs before the child's policy, so a child can narrow access but cannot bypass a parent deny or interrupt. A resumed parent resumes a child only when that child's derived checkpoint identity exists.

// Map parent "messages" -> child "messages", child "result" -> parent "findings"
auto sub = std::make_shared<SubgraphNode>("inner", subgraph,
{{"messages", "messages"}}, // input_map: parent -> child
{{"result", "findings"}}); // output_map: child -> parent

Definition at line 343 of file node.h.

Constructor & Destructor Documentation

◆ SubgraphNode()

neograph::graph::SubgraphNode::SubgraphNode ( const std::string &  name,
std::shared_ptr< GraphEngine >  subgraph,
std::map< std::string, std::string >  input_map = {},
std::map< std::string, std::string >  output_map = {},
SubgraphPersistence  persistence = SubgraphPersistence::Legacy 
)

Construct a subgraph node.

Parameters
nameUnique node name within the parent graph.
subgraphCompiled GraphEngine to run as a sub-workflow.
input_mapMapping of parent_channel -> child_channel for input.
output_mapMapping of child_channel -> parent_channel for ordered child write deltas. Empty means identity mapping.

Member Function Documentation

◆ checkpoint_thread_id()

std::string neograph::graph::SubgraphNode::checkpoint_thread_id ( const std::string &  parent_thread_id,
int  parent_step,
std::string_view  task_id,
std::string_view  graph_invocation_id = {} 
) const

Reconstruct an inspection namespace from its parent path and invocation.

PerInvocation requires the parent's persisted graph invocation ID.

◆ get_name()

std::string neograph::graph::SubgraphNode::get_name ( ) const
inlineoverridevirtual

Get the node's unique name within the graph.

Returns
Node name string.

Implements neograph::graph::GraphNode.

Definition at line 375 of file node.h.

◆ run()

asio::awaitable< NodeOutput > neograph::graph::SubgraphNode::run ( NodeInput  in)
overridevirtual

v0.4 PR 9a: unified run — drives the child engine via run_async (or run_stream_async when in.stream_cb is non-null), maps channels through input_map / output_map.

in.ctx.cancel_token flows through into the child run's RunConfig so a parent cancel cascades to the subgraph.

Implements neograph::graph::GraphNode.


The documentation for this class was generated from the following file: