plexus.cli.procedure.lua_dsl.primitives.graph module
GraphNode Primitive - Graph-based knowledge representation.
Provides: - GraphNode.create(content, metadata) - Create a new node - GraphNode.root() - Get root node (if exists) - GraphNode.current() - Get current working node - GraphNode.get(node_id) - Get node by ID
Node methods (on returned node objects): - node:children() - Get child nodes - node:parent() - Get parent node - node:score() - Get node score - node:metadata() - Get node metadata - node:set_metadata(key, value) - Set metadata field
- class plexus.cli.procedure.lua_dsl.primitives.graph.GraphNodePrimitive(client, procedure_id: str, account_id: str)
Bases:
objectManages graph node operations for procedure execution.
Graph nodes provide tree-based data storage for procedures, useful for tree search, hypothesis tracking, etc.
Initialize GraphNode primitive.
- Args:
client: PlexusDashboardClient instance procedure_id: Procedure ID for node creation account_id: Account ID for node creation
- __init__(client, procedure_id: str, account_id: str)
Initialize GraphNode primitive.
- Args:
client: PlexusDashboardClient instance procedure_id: Procedure ID for node creation account_id: Account ID for node creation
- create(content: str, metadata: Dict[str, Any] | None = None, parent_node_id: str | None = None)
Create a new graph node.
- Args:
content: Text content for the node metadata: Optional metadata dict parent_node_id: Optional parent node ID (None for root)
- Returns:
NodeWrapper with methods: children(), parent(), score(), metadata(), set_metadata()
- Example (Lua):
local node = GraphNode.create(“My limerick here”, {type = “poem”}) Log.info(“Created node: “ .. node.id)
– Node methods available: local children = node:children() local parent = node:parent() node:set_metadata(“status”, “reviewed”)
- current()
Get the current working node.
- Returns:
NodeWrapper or None if no current node set
- Example (Lua):
local node = GraphNode.current() if node then
Log.info(“Current node: “ .. node.id) node:set_metadata(“visited”, true) – Node methods available
end
- root()
Get the root node for this procedure (if exists).
- Returns:
NodeWrapper or None if no root node exists
- Example (Lua):
local root = GraphNode.root() if root then
Log.info(“Root node exists: “ .. root.id) local children = root:children() – Node methods available
end
- set_current(node_id: str) bool
Set the current working node (for internal use).
- Args:
node_id: Node ID to set as current
- Returns:
True if successful
- class plexus.cli.procedure.lua_dsl.primitives.graph.NodeWrapper(node, client)
Bases:
objectWrapper for GraphNode database objects that provides Lua-callable methods.
This class wraps the GraphNode database model and exposes its methods in a way that’s accessible from Lua.
Initialize node wrapper.
- Args:
node: GraphNode database model instance client: PlexusDashboardClient for queries
- __init__(node, client)
Initialize node wrapper.
- Args:
node: GraphNode database model instance client: PlexusDashboardClient for queries
- children()
Get child nodes.
- Returns:
List of child node wrappers
- Example (Lua):
local children = node:children() for i, child in ipairs(children) do
Log.info(“Child: “ .. child.id)
end
- metadata()
Get node metadata.
- Returns:
Metadata dict
- Example (Lua):
local meta = node:metadata() Log.info(“Type: “ .. (meta.type or “unknown”))
- parent()
Get parent node.
- Returns:
Parent node wrapper or None
- Example (Lua):
local parent = node:parent() if parent then
Log.info(“Parent: “ .. parent.id)
end
- score()
Get node score.
- Returns:
Node score value or None
- Example (Lua):
local score = node:score() if score then
Log.info(“Score: “ .. score)
end
- set_metadata(key: str, value: Any)
Set a metadata field.
- Args:
key: Metadata key value: Value to set
- Returns:
True if successful
- Example (Lua):
node:set_metadata(“status”, “completed”) node:set_metadata(“score”, 0.95)