Skip to content

fix(graph): prioritize exact name match in /graph facts query#1493

Merged
bug-ops merged 5 commits intomainfrom
graph-facts-name-match
Mar 9, 2026
Merged

fix(graph): prioritize exact name match in /graph facts query#1493
bug-ops merged 5 commits intomainfrom
graph-facts-name-match

Conversation

@bug-ops
Copy link
Owner

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

Summary

Fixes /graph facts <name> returning the wrong entity when another entity's summary mentions the searched name.

  • find_entity_by_name now uses a two-phase lookup: exact case-insensitive match on name/canonical_name first, FTS5 prefix search only as fallback
  • Added 5 tests: regression scenario (Alice vs Google), case-insensitive exact, canonical_name branch, fuzzy fallback, unknown name

Root Cause

FTS5 searched both name and summary columns. Even with a 10x BM25 weight on name, an entity with the search term appearing multiple times in its summary could outscore an entity with that exact name.

Test Plan

  • cargo nextest run -p zeph-memory -E 'test(find_entity_by_name)' — 5/5 pass
  • cargo nextest run --workspace --features full --lib --bins — 4939/4939 pass
  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — clean

Closes #1472

bug-ops added 2 commits March 9, 2026 22:07
FTS5 search could return an entity whose summary mentions the searched
name instead of the entity with that exact name. For example,
`/graph facts Alice` returned "Google" because Google's summary
contained "Alice".

Implement two-phase lookup in find_entity_by_name:
1. Exact case-insensitive match on name/canonical_name (direct SQL query)
2. FTS5 prefix search fallback only when no exact match found

Closes #1472
Add test for canonical_name branch in find_entity_by_name exact-match
phase and update CHANGELOG.md [Unreleased].
@github-actions github-actions bot added bug Something isn't working documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes size/M Medium PR (51-200 lines) and removed bug Something isn't working labels Mar 9, 2026
@github-actions github-actions bot added the bug Something isn't working label Mar 9, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 9, 2026 21:35
@bug-ops bug-ops merged commit 328c6a7 into main Mar 9, 2026
18 checks passed
@bug-ops bug-ops deleted the graph-facts-name-match branch March 9, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Graph memory: /graph facts query prioritizes summary mentions over exact name match

1 participant