fix(memory): keep short pattern terms out of raw JSON metadata columns - #152
Open
DevMello wants to merge 1 commit into
Open
fix(memory): keep short pattern terms out of raw JSON metadata columns#152DevMello wants to merge 1 commit into
DevMello wants to merge 1 commit into
Conversation
Two-char tokens like "ts" skip FTS and hit the pattern channel, which LIKE-matched them against raw properties_json/info_json. Every trace carries the JSON key "ts", so unrelated recent memories outranked real hits. Short ASCII terms now only match id, key, value and tags; longer terms and CJK bigrams keep their metadata reach.
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.
Any query with a two-char token ("ts", "js", "id") matches almost every memory. FTS only indexes terms of 3+ chars, so short tokens go to the pattern channel, which LIKE-matches them against raw properties_json/info_json. Every trace row carries the JSON key "ts", so "fix ts build error" matched every trace, and the rank rewrite put the newest one at score 1.0, above the real hits.
Fix: short ASCII terms now only match id, memory_key, memory_value and tags. Longer terms and CJK bigrams can't collide with JSON keys and still match metadata values.
Verify:
cd Memory && npx vitest run tests/repository/memory-retrieval-index.test.ts. The test fails on v1.0.5 and passes with this change.