pub struct ExperienceStore { /* private fields */ }Expand description
Persistent store for experience memory nodes and edges.
Wraps the experience_nodes, experience_edges, and experience_entity_links
tables created by migration 076_experience_memory.sql.
Implementations§
Source§impl ExperienceStore
impl ExperienceStore
Sourcepub fn new(pool: DbPool) -> Self
pub fn new(pool: DbPool) -> Self
Create a new experience store using the provided connection pool.
Sourcepub async fn record_tool_outcome(
&self,
session_id: &str,
turn: i64,
tool_name: &str,
outcome: &str,
detail: Option<&str>,
error_ctx: Option<&str>,
) -> Result<i64, MemoryError>
pub async fn record_tool_outcome( &self, session_id: &str, turn: i64, tool_name: &str, outcome: &str, detail: Option<&str>, error_ctx: Option<&str>, ) -> Result<i64, MemoryError>
Record a tool execution outcome as an experience node.
Returns the row ID of the newly inserted experience node.
§Errors
Returns MemoryError if the database insert fails.
§Examples
let id = store
.record_tool_outcome("session-1", 3, "shell", "success", Some("exit 0"), None)
.await?;Sourcepub async fn link_to_entities(
&self,
experience_id: i64,
entity_ids: &[i64],
) -> Result<(), MemoryError>
pub async fn link_to_entities( &self, experience_id: i64, entity_ids: &[i64], ) -> Result<(), MemoryError>
Link an experience node to one or more knowledge graph entities.
Uses INSERT OR IGNORE to tolerate duplicate links gracefully.
§Errors
Returns MemoryError if any database insert fails.
Sourcepub async fn link_sequential(
&self,
prev: i64,
next: i64,
) -> Result<(), MemoryError>
pub async fn link_sequential( &self, prev: i64, next: i64, ) -> Result<(), MemoryError>
Record a sequential followed_by link between two experience nodes.
§Errors
Returns MemoryError if the database insert fails.
Sourcepub async fn evolution_sweep(
&self,
graph_store: &GraphStore,
confidence_threshold: f32,
) -> Result<EvolutionSweepStats, MemoryError>
pub async fn evolution_sweep( &self, graph_store: &GraphStore, confidence_threshold: f32, ) -> Result<EvolutionSweepStats, MemoryError>
Run a graph evolution sweep on the knowledge graph.
Performs two pruning passes on the graph_edges table via graph_store:
- Removes self-loops (
source_entity_id = target_entity_id). - Removes low-confidence edges with zero retrievals that have no expiry set.
This is a maintenance operation; it never blocks the agent loop.
§Errors
Returns MemoryError if any database operation fails.
Auto Trait Implementations§
impl Freeze for ExperienceStore
impl !RefUnwindSafe for ExperienceStore
impl Send for ExperienceStore
impl Sync for ExperienceStore
impl Unpin for ExperienceStore
impl UnsafeUnpin for ExperienceStore
impl !UnwindSafe for ExperienceStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request