Skip to content

fix(memory): keep short pattern terms out of raw JSON metadata columns - #152

Open
DevMello wants to merge 1 commit into
MemTensor:v1.0.5from
DevMello:fix/pattern-terms-json-noise
Open

fix(memory): keep short pattern terms out of raw JSON metadata columns#152
DevMello wants to merge 1 commit into
MemTensor:v1.0.5from
DevMello:fix/pattern-terms-json-noise

Conversation

@DevMello

@DevMello DevMello commented Aug 5, 2026

Copy link
Copy Markdown

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant