|
NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
|
Singleton factory for creating graph nodes by type name. More...
#include <loader.h>
Public Member Functions | |
| json | config_schema (const std::string &type) const |
| Declared config schema for a node type. | |
| std::unique_ptr< GraphNode > | create (const std::string &type, const std::string &name, const json &config, const NodeContext &ctx) const |
| Create a node by type name. | |
| json | export_schema () const |
| Export a machine-readable description of the topology JSON format this engine accepts. | |
| json | node_effects (const std::string &type) const |
| Declared channel effects for a node type. | |
| void | register_type (const std::string &type, NodeFactoryFn fn) |
| Register a custom node type. | |
| void | register_type (const std::string &type, NodeFactoryFn fn, json config_schema) |
| Register a custom node type with a declared config schema. | |
| void | register_type (const std::string &type, NodeFactoryFn fn, json config_schema, json effects) |
| Register a custom node type with a declared config schema AND a declared channel-effect contract. | |
| std::vector< std::string > | registered_types () const |
| List all registered node type names, sorted. | |
Static Public Member Functions | |
| static NodeFactory & | instance () |
| Get the singleton instance. | |
Singleton factory for creating graph nodes by type name.
Maps node type names (used in JSON node definitions) to factory functions. Built-in types: "llm_call", "tool_dispatch", "intent_classifier", "subgraph".
| json neograph::graph::NodeFactory::config_schema | ( | const std::string & | type | ) | const |
Declared config schema for a node type.
Returns the schema passed to the 3-arg register_type overload, or the permissive {"type":"object"} default for types registered without one (never throws on unknown types — returns the permissive default; create() is where unknown types fail). Backs strict-mode consumed-key accounting in GraphCompiler and per-type introspection for external tooling.
| std::unique_ptr< GraphNode > neograph::graph::NodeFactory::create | ( | const std::string & | type, |
| const std::string & | name, | ||
| const json & | config, | ||
| const NodeContext & | ctx | ||
| ) | const |
Create a node by type name.
| type | Node type name. |
| name | Unique node name within the graph. |
| config | Node-specific configuration from JSON. |
| ctx | Node context with provider, tools, and model. |
| json neograph::graph::NodeFactory::export_schema | ( | ) | const |
Export a machine-readable description of the topology JSON format this engine accepts.
Intended for external tooling — notably a visual block-coding topology editor — so the editor's node palette and the engine cannot drift apart across NeoGraph versions. The returned document is JSON, shaped as:
neograph_version lets a tool detect when its cached schema is older than the engine and warn the user. The topology fragment is fixed (defined by the graph compiler); per-type config schemas come from register_type's 3-arg overload, or default to a permissive object for types registered without one. node_effects preserves each declared effect contract verbatim.
|
static |
Get the singleton instance.
| json neograph::graph::NodeFactory::node_effects | ( | const std::string & | type | ) | const |
Declared channel effects for a node type.
{"reads":[...],"writes":[...],"exports":[...]}, or null json for types registered without an effect contract. | void neograph::graph::NodeFactory::register_type | ( | const std::string & | type, |
| NodeFactoryFn | fn | ||
| ) |
Register a custom node type.
| type | Node type name (referenced in JSON node definitions). |
| fn | Factory function that creates the node. |
The node's config schema defaults to a permissive {"type":"object"} (any config object accepted). Existing callers keep working unchanged; external tooling that consumes export_schema() will simply render a free-form config for such a type. To declare a concrete config schema, use the 3-arg overload below.
| void neograph::graph::NodeFactory::register_type | ( | const std::string & | type, |
| NodeFactoryFn | fn, | ||
| json | config_schema | ||
| ) |
Register a custom node type with a declared config schema.
| type | Node type name (referenced in JSON node definitions). |
| fn | Factory function that creates the node. |
| config_schema | JSON Schema (Draft 2020-12) fragment describing this node type's accepted config fields. Used only by export_schema() for external tooling; the engine does not validate config against it at compile time. Additive: callers using the 2-arg overload are unaffected. |
| void neograph::graph::NodeFactory::register_type | ( | const std::string & | type, |
| NodeFactoryFn | fn, | ||
| json | config_schema, | ||
| json | effects | ||
| ) |
Register a custom node type with a declared config schema AND a declared channel-effect contract.
| effects | {"reads": ["ch", ...], "writes": ["ch", ...], "exports": ["result", ...]} — the channels instances of this type touch at runtime. Optional exports marks written channels that a caller consumes after graph execution, so they are not reported as write-only by E6. Only exported channels that are also declared in writes suppress E6; the graph must still declare the channel itself. Enables static effect checking (GraphValidator E4/E5/E6: writes to undeclared channels, overwrite races, dead channels). Effect analysis only runs on graphs where EVERY node's type declared effects — one unknown type disables it (soundness of the checker over coverage). |
| std::vector< std::string > neograph::graph::NodeFactory::registered_types | ( | ) | const |
List all registered node type names, sorted.