Skip to content

feat(memory): FTS5 index for graph entities (#1232)#1254

Merged
bug-ops merged 2 commits intomainfrom
feat-m33-fts5-graph-entities
Mar 6, 2026
Merged

feat(memory): FTS5 index for graph entities (#1232)#1254
bug-ops merged 2 commits intomainfrom
feat-m33-fts5-graph-entities

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 6, 2026

Summary

  • Add FTS5 full-text search index for graph_entities table (migration 023_graph_entities_fts5.sql)
  • Replace LIKE '%query%' with FTS5 MATCH + bm25 ranking in find_entities_fuzzy
  • Reuse sanitize_fts5_query from messages module, add FTS5 operator filtering (AND/OR/NOT/NEAR)
  • unicode61 tokenizer with remove_diacritics=2, name column weighted 10x over summary
  • Content-sync triggers (INSERT/DELETE/UPDATE) keep FTS5 index in lockstep with graph_entities
  • No public API change — find_entities_fuzzy signature unchanged

Behavioral change: FTS5 prefix matching replaces LIKE substring matching. Searching "SQL" matches "SQLite" (prefix) but not "GraphQL" (mid-word substring). Documented in code and CHANGELOG.

Test plan

  • 7 new tests: summary match, empty query, special chars, prefix match, operator injection, entity update, only-special-chars
  • All 4251 workspace tests pass (--features full)
  • cargo +nightly fmt --check clean
  • cargo clippy --workspace --features full -- -D warnings clean

Follow-up issues

  • UPDATE trigger optimization: add WHEN clause to skip FTS sync on last_seen_at-only changes
  • Query length guard (SEC-DOS-01): add 512-byte cap in find_entities_fuzzy
  • Refactor retrieval.rs per-word loop to pass full query to FTS5 natively
  • Additional test coverage: hyphenated names, Unicode entities, null vs empty summary

Closes #1232
Part of #1222

Add FTS5 full-text search index for graph_entities table, replacing
LIKE '%query%' with FTS5 MATCH + bm25 ranking in find_entities_fuzzy.

- Migration 023_graph_entities_fts5.sql: FTS5 virtual table with
  unicode61 tokenizer (remove_diacritics=2), content-sync triggers
  (INSERT/DELETE/UPDATE), and backfill from existing entities
- find_entities_fuzzy: FTS5 MATCH with prefix wildcards, bm25 ranking
  (name 10x weight over summary), FTS5 operator filtering (AND/OR/NOT/NEAR)
- Reuse sanitize_fts5_query from messages module (pub(crate))
- 7 new tests (+1 during review fixes), test count 4244 -> 4251

Closes #1232
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes enhancement New feature or request size/L Large PR (201-500 lines) labels Mar 6, 2026
Resolve conflicts in CHANGELOG.md, README.md, and
docs/src/concepts/graph-memory.md — keep both branches' additions.
@bug-ops bug-ops enabled auto-merge (squash) March 6, 2026 02:01
@bug-ops bug-ops merged commit 3a40216 into main Mar 6, 2026
28 checks passed
@bug-ops bug-ops deleted the feat-m33-fts5-graph-entities branch March 6, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(memory): FTS5 index for graph entities

1 participant