// Package memory implements the long-term memory system for Cyrene. // It provides CRUD operations, semantic search via pgvector, deduplication, and decay. package memory import "time" // Memory represents a stored memory entry. type Memory struct { ID string `json:"id"` UserID string `json:"user_id"` SourceID string `json:"source_id"` // Group/private chat source Content string `json:"content"` Summary string `json:"summary"` // LLM-generated summary Keywords []string `json:"keywords"` // Extracted keywords Category string `json:"category"` // "fact", "preference", "event", "plan" Priority float64 `json:"priority"` // 0.0 - 1.0 Decay float64 `json:"decay"` // Decay factor, starts at 1.0 AccessCnt int `json:"access_count"` LastAcc time.Time `json:"last_accessed_at"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // SearchQuery represents a memory search request. type SearchQuery struct { UserID string SourceID string // Optional, filter by source Query string Limit int Category string // Optional filter } // MemoryResult wraps a memory with its search relevance score. type MemoryResult struct { Memory Memory `json:"memory"` Score float64 `json:"score"` } // Category constants const ( CatFact = "fact" CatPreference = "preference" CatEvent = "event" CatPlan = "plan" CatForgotten = "forgotten" ) // DecayThreshold is the decay value below which a memory is considered forgotten. const DecayThreshold = 0.1