pub struct GraphMemory { /* private fields */ }Expand description
High-level graph memory API - the main entry point for AINL memory.
Wraps a GraphStore implementation with a simplified 5-method API.
Implementations§
Source§impl GraphMemory
impl GraphMemory
Sourcepub fn new(db_path: &Path) -> Result<Self, String>
pub fn new(db_path: &Path) -> Result<Self, String>
Create a new graph memory at the given database path.
This will create the database file if it doesn’t exist, and ensure the AINL graph schema is initialized.
Sourcepub fn from_connection(conn: Connection) -> Result<Self, String>
pub fn from_connection(conn: Connection) -> Result<Self, String>
Create from an existing SQLite connection (for integration with existing memory pools)
Sourcepub fn from_sqlite_store(store: SqliteGraphStore) -> Self
pub fn from_sqlite_store(store: SqliteGraphStore) -> Self
Wrap an already-open SqliteGraphStore (for hosts that manage connections externally).
Sourcepub fn write_episode(
&self,
tool_calls: Vec<String>,
delegation_to: Option<String>,
trace_event: Option<Value>,
) -> Result<Uuid, String>
pub fn write_episode( &self, tool_calls: Vec<String>, delegation_to: Option<String>, trace_event: Option<Value>, ) -> Result<Uuid, String>
Sourcepub fn write_fact(
&self,
fact: String,
confidence: f32,
source_turn_id: Uuid,
) -> Result<Uuid, String>
pub fn write_fact( &self, fact: String, confidence: f32, source_turn_id: Uuid, ) -> Result<Uuid, String>
Sourcepub fn store_pattern(
&self,
pattern_name: String,
compiled_graph: Vec<u8>,
) -> Result<Uuid, String>
pub fn store_pattern( &self, pattern_name: String, compiled_graph: Vec<u8>, ) -> Result<Uuid, String>
Sourcepub fn write_procedural(
&self,
pattern_name: &str,
tool_sequence: Vec<String>,
confidence: f32,
) -> Result<Uuid, String>
pub fn write_procedural( &self, pattern_name: &str, tool_sequence: Vec<String>, confidence: f32, ) -> Result<Uuid, String>
Store a procedural pattern derived from a live tool sequence (heuristic extraction).
Sourcepub fn write_edge(
&self,
source: Uuid,
target: Uuid,
rel: &str,
) -> Result<(), String>
pub fn write_edge( &self, source: Uuid, target: Uuid, rel: &str, ) -> Result<(), String>
Write a graph edge between nodes (e.g. episode timeline follows).
Sourcepub fn recall_recent(
&self,
seconds_ago: i64,
) -> Result<Vec<AinlMemoryNode>, String>
pub fn recall_recent( &self, seconds_ago: i64, ) -> Result<Vec<AinlMemoryNode>, String>
Sourcepub fn recall_by_type(
&self,
kind: AinlNodeKind,
seconds_ago: i64,
) -> Result<Vec<AinlMemoryNode>, String>
pub fn recall_by_type( &self, kind: AinlNodeKind, seconds_ago: i64, ) -> Result<Vec<AinlMemoryNode>, String>
Recall nodes of a specific kind written in the last seconds_ago seconds.
Sourcepub fn write_persona(
&self,
trait_name: &str,
strength: f32,
learned_from: Vec<Uuid>,
) -> Result<Uuid, String>
pub fn write_persona( &self, trait_name: &str, strength: f32, learned_from: Vec<Uuid>, ) -> Result<Uuid, String>
Write a persona trait node.
Sourcepub fn store(&self) -> &dyn GraphStore
pub fn store(&self) -> &dyn GraphStore
Get direct access to the underlying store for advanced queries
Sourcepub fn sqlite_store(&self) -> &SqliteGraphStore
pub fn sqlite_store(&self) -> &SqliteGraphStore
SQLite backing store (for components such as ainl-graph-extractor that require concrete SQL access).
Sourcepub fn validate_graph(
&self,
agent_id: &str,
) -> Result<GraphValidationReport, String>
pub fn validate_graph( &self, agent_id: &str, ) -> Result<GraphValidationReport, String>
SqliteGraphStore::validate_graph for the same backing database (checkpoint / boot gate).
Sourcepub fn export_graph(&self, agent_id: &str) -> Result<AgentGraphSnapshot, String>
pub fn export_graph(&self, agent_id: &str) -> Result<AgentGraphSnapshot, String>
Sourcepub fn import_graph(
&mut self,
snapshot: &AgentGraphSnapshot,
allow_dangling_edges: bool,
) -> Result<(), String>
pub fn import_graph( &mut self, snapshot: &AgentGraphSnapshot, allow_dangling_edges: bool, ) -> Result<(), String>
SqliteGraphStore::import_graph — use allow_dangling_edges: false for normal loads; true only for repair.
Sourcepub fn agent_subgraph_edges(
&self,
agent_id: &str,
) -> Result<Vec<SnapshotEdge>, String>
pub fn agent_subgraph_edges( &self, agent_id: &str, ) -> Result<Vec<SnapshotEdge>, String>
Sourcepub fn write_node_with_edges(
&mut self,
node: &AinlMemoryNode,
) -> Result<(), String>
pub fn write_node_with_edges( &mut self, node: &AinlMemoryNode, ) -> Result<(), String>
SqliteGraphStore::write_node_with_edges (transactional; fails if embedded edge targets are missing).
Sourcepub fn insert_graph_edge_checked(
&self,
from_id: Uuid,
to_id: Uuid,
label: &str,
) -> Result<(), String>
pub fn insert_graph_edge_checked( &self, from_id: Uuid, to_id: Uuid, label: &str, ) -> Result<(), String>
Sourcepub fn read_runtime_state(
&self,
agent_id: &str,
) -> Result<Option<RuntimeStateNode>, String>
pub fn read_runtime_state( &self, agent_id: &str, ) -> Result<Option<RuntimeStateNode>, String>
Read persisted RuntimeStateNode for agent_id (most recent row).
Sourcepub fn write_runtime_state(
&self,
state: &RuntimeStateNode,
) -> Result<(), String>
pub fn write_runtime_state( &self, state: &RuntimeStateNode, ) -> Result<(), String>
Upsert persisted RuntimeStateNode for the given agent (stable node id per agent_id).
Sourcepub fn write_node(&self, node: &AinlMemoryNode) -> Result<(), String>
pub fn write_node(&self, node: &AinlMemoryNode) -> Result<(), String>
Write a fully constructed node (additive API for callers that set extended metadata).