MemoryRepository

Struct MemoryRepository 

Source
pub struct MemoryRepository { /* private fields */ }

Implementations§

Source§

impl MemoryRepository

Source

pub fn new(pool: PgPool) -> Self

Source

pub fn with_trigger_engine( pool: PgPool, trigger_engine: Arc<EventTriggeredScoringEngine>, ) -> Self

Source

pub fn pool(&self) -> &PgPool

Source

pub async fn create_memory( &self, request: CreateMemoryRequest, ) -> Result<Memory>

Source

pub async fn create_memory_with_user_context( &self, request: CreateMemoryRequest, user_id: Option<&str>, ) -> Result<Memory>

Source

pub async fn get_memory(&self, id: Uuid) -> Result<Memory>

Source

pub async fn update_memory( &self, id: Uuid, request: UpdateMemoryRequest, ) -> Result<Memory>

Source

pub async fn delete_memory(&self, id: Uuid) -> Result<()>

Source

pub async fn search_memories_enhanced( &self, request: MemoryAwareSearchRequest, ) -> Result<MemoryAwareSearchResponse>

Enhanced search method with memory-aware features for Story 9

Source

pub async fn search_memories( &self, request: SearchRequest, ) -> Result<SearchResponse>

Source

pub async fn search_memories_simple( &self, request: SearchRequest, ) -> Result<Vec<SearchResult>>

Source

pub async fn get_memories_by_tier( &self, tier: MemoryTier, limit: Option<i64>, ) -> Result<Vec<Memory>>

Source

pub async fn migrate_memory( &self, id: Uuid, to_tier: MemoryTier, reason: Option<String>, ) -> Result<Memory>

Source

pub async fn get_expired_memories(&self) -> Result<Vec<Memory>>

Source

pub async fn cleanup_expired_memories(&self) -> Result<u64>

Source

pub async fn get_migration_candidates( &self, tier: MemoryTier, limit: i64, ) -> Result<Vec<Memory>>

Source

pub async fn get_statistics(&self) -> Result<MemoryStatistics>

Source

pub async fn get_consolidation_analytics( &self, ) -> Result<Vec<ConsolidationAnalytics>>

Get consolidation analytics for all tiers

Source

pub async fn get_consolidation_events( &self, ) -> Result<Vec<ConsolidationEventSummary>>

Get consolidation event summary for the last week

Source

pub async fn find_migration_candidates( &self, tier: MemoryTier, limit: i32, ) -> Result<Vec<Memory>>

Find memories ready for tier migration based on recall probability

Source

pub async fn update_consolidation( &self, memory_id: Uuid, consolidation_strength: f64, decay_rate: f64, recall_probability: Option<f64>, ) -> Result<()>

Update memory consolidation parameters

Source

pub async fn log_consolidation_event( &self, memory_id: Uuid, event_type: &str, previous_strength: f64, new_strength: f64, previous_probability: Option<f64>, new_probability: Option<f64>, recall_interval: Option<PgInterval>, context: Value, ) -> Result<()>

Log a consolidation event

Source

pub async fn freeze_memory( &self, memory_id: Uuid, reason: Option<String>, ) -> Result<FreezeMemoryResponse>

Freeze a memory by moving it to compressed storage using zstd compression

Source

pub async fn unfreeze_memory( &self, frozen_id: Uuid, target_tier: Option<MemoryTier>, ) -> Result<UnfreezeMemoryResponse>

Unfreeze a memory and restore it to active status with zstd decompression

Source

pub async fn get_frozen_memories( &self, limit: i32, offset: i64, ) -> Result<Vec<FrozenMemory>>

Get all frozen memories with pagination

Source

pub async fn search_frozen_memories( &self, query: &str, limit: i32, ) -> Result<Vec<FrozenMemory>>

Search frozen memories by content or metadata

Source

pub async fn get_tier_statistics(&self) -> Result<Vec<MemoryTierStatistics>>

Get tier statistics for monitoring

Source

pub async fn update_tier_statistics(&self) -> Result<()>

Update tier statistics (typically called by a background job)

Source

pub async fn search_by_consolidation( &self, request: ConsolidationSearchRequest, ) -> Result<Vec<Memory>>

Search memories with consolidation criteria

Source

pub async fn update_memory_scores( &self, memory_id: Uuid, recency_score: f64, relevance_score: f64, ) -> Result<()>

Update three-component scores for specific memory

Source

pub async fn batch_update_three_component_scores(&self) -> Result<i64>

Batch update three-component scores for all active memories

Source

pub async fn get_memories_by_combined_score( &self, tier: Option<MemoryTier>, limit: Option<i32>, recency_weight: Option<f64>, importance_weight: Option<f64>, relevance_weight: Option<f64>, ) -> Result<Vec<Memory>>

Get memories ranked by three-component combined score using generated column

Source

pub async fn get_memories_for_consolidation( &self, tier: Option<MemoryTier>, batch_size: usize, min_hours_since_last_processing: f64, ) -> Result<Vec<Memory>>

Get memories for consolidation processing with batch optimization

Source

pub async fn batch_update_consolidation( &self, updates: &[(Uuid, f64, f64)], ) -> Result<usize>

Batch update consolidation values for multiple memories

Source

pub async fn batch_migrate_memories( &self, migrations: &[(Uuid, MemoryTier)], ) -> Result<usize>

Batch migrate memories to new tiers

Source

pub async fn get_simple_consolidation_candidates( &self, tier: Option<MemoryTier>, threshold: f64, limit: usize, ) -> Result<Vec<Memory>>

Get migration candidates using simple consolidation formula

Source

pub async fn log_simple_consolidation_event( &self, memory_id: Uuid, previous_strength: f64, new_strength: f64, previous_probability: Option<f64>, new_probability: f64, processing_time_ms: u64, ) -> Result<()>

Log simple consolidation event with performance metrics

Source

pub async fn get_simple_consolidation_stats( &self, ) -> Result<SimpleConsolidationStats>

Get simple consolidation statistics

Source

pub async fn get_trigger_metrics(&self) -> Option<TriggerMetrics>

Get trigger metrics if trigger engine is available

Source

pub async fn reset_trigger_metrics(&self) -> Result<()>

Reset trigger metrics if trigger engine is available

Source

pub async fn add_user_trigger_customization( &self, user_id: String, customizations: HashMap<TriggerEvent, TriggerPattern>, ) -> Result<()>

Add user-specific trigger customization

Source

pub fn has_trigger_engine(&self) -> bool

Check if trigger engine is enabled

Source

pub async fn batch_freeze_by_recall_probability( &self, max_batch_size: Option<usize>, ) -> Result<BatchFreezeResult>

Batch freeze memories that meet migration criteria (P(recall) < 0.2)

Source

pub async fn batch_unfreeze_memories( &self, frozen_ids: Vec<Uuid>, target_tier: Option<MemoryTier>, ) -> Result<BatchUnfreezeResult>

Batch unfreeze memories

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> Instrument for T

Source§

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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
Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,