Skip to content

refactor(memory): Arc-wrap EmbeddingStore and FuturesUnordered context preparation #1223

@bug-ops

Description

@bug-ops

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.qdrant field is Option<Arc<EmbeddingStore>>
  • All existing tests pass without modification
  • prepare_context uses FuturesUnordered pattern
  • No cfg-gated try_join! duplication remains
  • cargo clippy --workspace -- -D warnings passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgraph-memoryKnowledge graph memory featurememoryzeph-memory crate (SQLite)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions