feat: implement semantic cache (#32) #121
Reference in New Issue
Block a user
Delete Branch "feature/issue-32-semantic-cache"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements an in-memory semantic cache for the Memory Service's
QueryMemorypipeline. Cache entries are keyed by query embedding cosine similarity (not exact match), enabling deduplication of semantically similar queries.Key changes
cache/module:SemanticCachewithRwLock-protected entries,CachedResulttype,CacheMetricswith atomic counterscache/similarity.rs: Pure-Rust cosine similarity with f64 intermediate precisionCacheConfiginconfig.rswithenabled,max_entries,ttl_secs,similarity_thresholdinvalidate_by_memory_id()ready for wiring intoWriteMemory(currently unimplemented)is_cachedandcached_extracted_segmentfields populated on cache hitsQuality gates
Files
cache/mod.rs,cache/similarity.rs,extraction/mod.rs,extraction/prompt.rs,issue-031.md,issue-032.mdmemory.proto,config.rs,service.rs,main.rs,lib.rs,_index.mdNote: This PR includes #31 (extraction step) changes as a dependency since #31's PR (#119) has not been merged yet.
Closes #32 | Plan:
implementation-plans/issue-032.md27477e2b15to0a48daa30b