feat(memory): community detection with label propagation and graph eviction (#1228)#1271
Merged
feat(memory): community detection with label propagation and graph eviction (#1228)#1271
Conversation
…cs (#1228) - Label Propagation Algorithm (50 iterations, tie-break by min label) via petgraph - Full-rebuild community upsert with ON CONFLICT(name) and label_index suffix to prevent collisions - scrub_content() inline sanitizer strips newlines and ASCII control chars from entity names and facts - run_graph_eviction: expired edge deletion, orphan entity pruning, LRU entity cap - GraphConfig: expired_edge_retention_days (default 90) and max_entities fields - community_refresh_interval triggers detection every N extractions in spawn_graph_extraction - graph_community_detection_failures counter in MetricsSnapshot via Arc<AtomicU64> in SemanticMemory - 11 unit tests: label propagation clusters, isolated nodes, persistence, extraction count
- Resolve CHANGELOG.md: keep Phase 5 entries + main's aggregator/FTS5/canonicalization entries - Resolve docs/graph-memory.md: keep Community Detection + Graph Eviction sections, add FTS5 section from main - Resolve zeph-memory/README.md: merge graph module description (canonicalization + community detection) - Update upsert_entity calls in community.rs and store.rs tests to include canonical_name parameter (added in main via #1231) - Regenerate config default snapshot
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
Implements Phase 5 of the graph-based knowledge memory epic (#1222): community detection, graph eviction, and community refresh metrics.
petgraph::UnGraph): groups entities into clusters (max 50 iterations, tie-break by smallest label, min 2 entities), generates LLM summaries, persists tograph_communitiesexpired_edge_retention_days, orphan entities with no active edges, enforces optionalmax_entitiescap — runs during community refresh cyclegraph_metadataSQLite table (INSERT ON CONFLICT DO UPDATE)scrub_content()applied to entity names and facts before LLM promptgraph_community_detection_failuresinMetricsSnapshotGraphConfigfields:expired_edge_retention_days(default 90),max_entities(default 0)petgraph = "0.8"added as optional workspace dependency, gated behindgraph-memoryfeatureTest plan
cargo nextest run --workspace --features full --lib --bins)Follow-up issues filed
FuturesUnorderedgraph_edges.expired_atEntityIdnewtype for BFS dynamic SQLCloses #1228