Summary
Phase 4 of graph memory (#1222): non-blocking background extraction wired into the agent loop, with TUI spinner support.
Depends on: #1223 (Arc-wrap prerequisite), #1226 (retrieval)
Tasks
1. Background Extraction in SemanticMemory
Add to SemanticMemory:
spawn_graph_extraction(message: &str, context: &[Message], episode_id: MessageId) — spawns tokio::spawn with tokio::time::timeout(extraction_timeout_secs). The spawned task clones Arc<EmbeddingStore>, AnyProvider (already Clone), SqlitePool (already Clone). On timeout or error, logs warning and silently degrades.
2. Agent Loop Integration
In crates/zeph-core/src/agent/persistence.rs:
- After
remember_with_parts() stores a user message, call spawn_graph_extraction() if config.memory.graph.enabled.
- Tool output messages (
save_only()) are NOT extracted (too noisy, low entity density).
In crates/zeph-core/src/agent/context.rs:
3. TUI Status Spinner
When graph extraction is running in background:
- Set status: "Extracting entities..." with spinner
- On completion: clear status (or show "Extracted 3 entities, 5 edges")
- Use existing
StatusUpdate channel pattern from TUI
4. Extraction Counter Persistence
Increment extraction_count in graph_metadata table after each successful extraction. Used by Phase 5 to trigger community refresh when count % community_refresh_interval == 0.
Architecture Reference
See .local/plan/graph-memory-architecture.md Section 6 for Arc-wrapping details, spawning pattern, and context builder integration.
Acceptance Criteria
Summary
Phase 4 of graph memory (#1222): non-blocking background extraction wired into the agent loop, with TUI spinner support.
Depends on: #1223 (Arc-wrap prerequisite), #1226 (retrieval)
Tasks
1. Background Extraction in SemanticMemory
Add to
SemanticMemory:spawn_graph_extraction(message: &str, context: &[Message], episode_id: MessageId)— spawnstokio::spawnwithtokio::time::timeout(extraction_timeout_secs). The spawned task clonesArc<EmbeddingStore>,AnyProvider(already Clone),SqlitePool(already Clone). On timeout or error, logs warning and silently degrades.2. Agent Loop Integration
In
crates/zeph-core/src/agent/persistence.rs:remember_with_parts()stores a user message, callspawn_graph_extraction()ifconfig.memory.graph.enabled.save_only()) are NOT extracted (too noisy, low entity density).In
crates/zeph-core/src/agent/context.rs:FuturesUnorderedcontext preparation (from refactor(memory): Arc-wrap EmbeddingStore and FuturesUnordered context preparation #1223 refactor), add aGraphFactsfetcher gated by#[cfg(feature = "graph-memory")].graph_recall()from Phase 3.GRAPH_FACTS_PREFIXat appropriate position.3. TUI Status Spinner
When graph extraction is running in background:
StatusUpdatechannel pattern from TUI4. Extraction Counter Persistence
Increment
extraction_countingraph_metadatatable after each successful extraction. Used by Phase 5 to trigger community refresh whencount % community_refresh_interval == 0.Architecture Reference
See
.local/plan/graph-memory-architecture.mdSection 6 for Arc-wrapping details, spawning pattern, and context builder integration.Acceptance Criteria