fix(store): match legacy mixed-case project names in MCP search#427
Merged
Conversation
… data
SQLite text comparisons are case-sensitive by default. Observations saved
by pre-normalization versions of engram (e.g. project "Ebook2Audio") cannot
be found when queried with the current normalized lowercase name ("ebook2audio")
because WHERE project = ? does not match.
Change ProjectExists, Search (FTS + topic-key paths), RecentObservations,
and RecentSessions to use LOWER(project) = ? so that legacy mixed-case
project names are matched by their normalized equivalents.
Also expose Store.DB() for integration tests that need to inject raw rows
without going through the normalizing public API.
Closes #146
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
mem_searchreturning empty results whileengram search(CLI) works for the same query and database.project = ?is case-sensitive. Legacy observations stored with mixed-case project names (e.g.Ebook2Audio) are invisible to normalized lowercase queries (ebook2audio). The MCP path normalizes before querying; the CLI path passes the user-typed name as-is, so it happened to match.LOWER(project) = ?inProjectExists,Search(FTS and topic-key paths),RecentObservations, andRecentSessions, so mixed-case legacy data matches its normalized equivalent.Test plan
TestSearchLegacyMixedCaseProject(store): seeds legacy mixed-case rows via raw SQL, asserts all four read paths find them with the normalized project nameTestHandleSearchLegacyMixedCaseProject(mcp): fullhandleSearchend-to-end with legacy data, nounknown_projecterror, results returnedgo test ./... && go vet ./... && go build ./...cleanCloses #146