-
Notifications
You must be signed in to change notification settings - Fork 2
refactor(memory): Arc-wrap EmbeddingStore and FuturesUnordered context preparation #1223
Description
Summary
Prerequisite refactors required before graph memory integration (Phase 0).
Parent epic: #1222
Tasks
1. Arc-wrap EmbeddingStore in SemanticMemory
EmbeddingStore wraps Box<dyn VectorStore> and does not implement Clone. Phase 4 of graph memory needs to spawn background tasks that access the embedding store.
Change: Wrap qdrant field in SemanticMemory from Option<EmbeddingStore> to Option<Arc<EmbeddingStore>>. All existing &self.qdrant usages continue to work via Deref. This is an internal refactor with no public API change.
Files: crates/zeph-memory/src/semantic.rs
2. FuturesUnordered context preparation
The current prepare_context in crates/zeph-core/src/agent/context.rs uses tokio::try_join! with cfg-gated branches, creating combinatorial explosion when adding new context sources. Adding graph facts would create a 4-way branching matrix.
Change: Refactor prepare_context to use FuturesUnordered with tagged ContextSlot enum:
enum ContextSlot {
Summaries(Vec<String>),
SemanticRecall(Vec<RecalledMessage>),
CrossSession(Vec<SessionSummaryResult>),
CodeContext(Vec<String>),
#[cfg(feature = "graph-memory")]
GraphFacts(Vec<GraphFact>),
}Each context source is a fetchers.push() call with its own #[cfg] gate. No more duplicated try_join blocks.
Files: crates/zeph-core/src/agent/context.rs
Acceptance Criteria
-
SemanticMemory.qdrantfield isOption<Arc<EmbeddingStore>> - All existing tests pass without modification
-
prepare_contextusesFuturesUnorderedpattern - No cfg-gated
try_join!duplication remains -
cargo clippy --workspace -- -D warningspasses