Skip to main content

GraphMemory

Struct GraphMemory 

Source
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

Source

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.

Source

pub fn from_connection(conn: Connection) -> Result<Self, String>

Create from an existing SQLite connection (for integration with existing memory pools)

Source

pub fn write_episode( &self, tool_calls: Vec<String>, delegation_to: Option<String>, trace_event: Option<Value>, ) -> Result<Uuid, String>

Write an episode node (what happened during an agent turn).

§Arguments
  • tool_calls - List of tools executed during this turn
  • delegation_to - Agent ID this turn delegated to (if any)
  • trace_event - Optional orchestration trace event (serialized JSON)
§Returns

The ID of the created episode node

Source

pub fn write_fact( &self, fact: String, confidence: f32, source_turn_id: Uuid, ) -> Result<Uuid, String>

Write a semantic fact (learned information with confidence).

§Arguments
  • fact - The fact in natural language
  • confidence - Confidence score (0.0-1.0)
  • source_turn_id - Turn ID that generated this fact
§Returns

The ID of the created semantic node

Source

pub fn store_pattern( &self, pattern_name: String, compiled_graph: Vec<u8>, ) -> Result<Uuid, String>

Store a procedural pattern (compiled workflow).

§Arguments
  • pattern_name - Name/identifier for the pattern
  • compiled_graph - Binary representation of the compiled graph
§Returns

The ID of the created procedural node

Source

pub fn recall_recent( &self, seconds_ago: i64, ) -> Result<Vec<AinlMemoryNode>, String>

Recall recent episodes (within the last N seconds).

§Arguments
  • seconds_ago - Only return episodes from the last N seconds
§Returns

Vector of episode nodes, most recent first

Source

pub fn store(&self) -> &dyn GraphStore

Get direct access to the underlying store for advanced queries

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.