feat(memory): background graph extraction and agent loop integration (Phase 4, #1227)#1255
Merged
feat(memory): background graph extraction and agent loop integration (Phase 4, #1227)#1255
Conversation
…(Phase 4, #1227) Wire graph entity extraction into the agent loop as a fire-and-forget background task with configurable timeout and graceful degradation. - Add spawn_graph_extraction() to SemanticMemory with tokio::spawn, cloning Arc<EmbeddingStore>, AnyProvider, and SqlitePool - Integrate in persistence.rs: trigger after remember_with_parts(), skip tool outputs, skip injection-flagged messages (S2) - Add ContextSlot::GraphFacts to FuturesUnordered context pipeline - Add fetch_graph_facts() with token-budgeted formatting and entity name escaping against prompt injection (R-IMP-02) - Add recall_graph() with fuzzy entity match, BFS traversal, HashMap cache for N+1 elimination, and SQLite bind-param cap (R-SUG-01/03) - Runtime-conditional budget split: 5% semantic + 3% graph when enabled, 8% semantic + 0% graph when disabled (S3/S4) - Atomic SQL extraction counter in graph_metadata table (S1) - TUI status spinner during background extraction - Security doc + startup warning for PII redaction gap (R-IMP-03) - Remove dead GraphExtractionConfig.model field (R-IMP-01)
Reconcile Phase 4 changes with Phase 3 (graph retrieval) that landed on main: - Remove duplicate recall_graph (keep graph::retrieval module version) - Remove duplicate fetch_graph_facts (keep main's, add injection escaping) - Remove duplicate GRAPH_FACTS_PREFIX (keep [known facts] prefix) - Adopt GraphConfig as non-Option field (main's approach) - Adopt balanced budget reallocation (7/7/3/29/4% with graph enabled) - Adopt MAX_FRONTIER constant from main, keep visited_ids cap - Fix test helpers to set graph_store on SemanticMemory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 4 of graph memory epic (#1222): wire entity extraction into the agent loop as a fire-and-forget background task.
spawn_graph_extraction()onSemanticMemory—tokio::spawnwith configurable timeout (default 15s), graceful degradation on timeout/errorremember_with_parts()inpersistence.rs, skips tool outputs and injection-flagged messagesContextSlot::GraphFactsadded toFuturesUnorderedpipeline,fetch_graph_facts()with token-budgeted formatting and entity name escapingrecall_graph()with fuzzy entity match + BFS traversal, HashMap cache for N+1 elimination, SQLite bind-param capgraph_metadatatable15 files changed, +1036/-18, 4216 tests passing (+4 net).
Closes #1227
Test plan
cargo +nightly fmt --checkcargo clippy --workspace -- -D warnings(without graph-memory)cargo clippy --workspace --features full -- -D warningscargo nextest run --workspace --features full --lib --bins(4216 passed, 0 failed)