Skip to main content

MemoryStore

Struct MemoryStore 

Source
pub struct MemoryStore { /* private fields */ }
Expand description

Persistent store for agent memories, organized by category into subdirectories. Maintains a MEMORY.md index file.

Implementations§

Source§

impl MemoryStore

Source

pub fn maintenance_report( &self, policy: &MemoryMaintenancePolicy, ) -> MemoryMaintenanceReport

Build a dry-run report of memories that would be archived by the policy.

Source

pub fn apply_maintenance( &mut self, policy: &MemoryMaintenancePolicy, ) -> Result<MemoryMaintenanceReport>

Apply a maintenance policy by archiving the report’s candidate memories.

Source§

impl MemoryStore

Source

pub fn query(&self, query: MemoryQuery) -> Vec<MemoryEntry>

Query memories by metadata. Uses the in-memory cache — no disk I/O.

Source

pub fn search(&self, query: &str) -> Vec<MemoryEntry>

Search memories by keyword — matches name, description, tags, and body. Uses the in-memory cache — no disk I/O.

Source

pub fn top_by_usage(&self, n: usize) -> Vec<MemoryEntry>

Get the top N most-used memories for prompt injection.

Source

pub fn search_relevant( &self, query: &str, limit: usize, min_relevance: f64, ) -> Vec<MemoryEntry>

Score cached memories against a user query and return the top-K by keyword-overlap relevance. Non-deprecated entries only.

min_relevance (0.0-1.0) discards entries whose composite score falls below the threshold. A value around 0.10 filters out false-positive matches from very common tokens.

This is the primary method for dynamic memory injection — unlike query() + MemorySort::Relevance (which sorts by metadata), this uses the actual content of the user’s prompt to find semantically relevant memories via simple token overlap.

Source§

impl MemoryStore

Source

pub fn new(root: PathBuf) -> Self

Open or create a memory store at the given root directory.

Source

pub fn write(&mut self, entry: MemoryEntry) -> Result<()>

Write a memory entry to disk and update the index.

Source

pub fn upsert(&mut self, entry: MemoryEntry) -> Result<UpsertOutcome>

Write a new memory or merge into an existing one with the same name or description.

Source

pub fn read(&self, name: &str) -> Option<MemoryEntry>

Read a memory entry by name.

Source

pub fn list(&self) -> Vec<String>

Return all memory names.

Source

pub fn update_status(&mut self, name: &str, status: MemoryStatus) -> Result<()>

Update the status of a memory entry.

Source

pub fn record_use(&mut self, name: &str) -> Result<()>

Record that a memory was explicitly used.

Source

pub fn archive(&mut self, name: &str) -> Result<()>

Move a memory to the _archived directory (never delete).

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,