Repository navigation
fix(dedupe): scope words must not stand in for content (#421) - #422
Conversation
…ly (#421) contentTokens() tokenized haystack() (content + keywords + scope + type) and removed only the WHOLE scope/type strings. Since #417 the identifier tokenizer also emits the split words, so a snake_case scope like auth_token_refresh_policy left auth/token/refresh/policy standing in for content. Two unrelated non-Latin rows in one scope then shared a Jaccard-1 metadata vocabulary, cleared MIN_CONTENT on scope tokens alone, and dedup hid the older row through the composed handler. Reproduced verbatim from the post-merge report on #417; the new test file fails on main and passes with the fix.
WhollyMindless
left a comment
There was a problem hiding this comment.
Retested the original #417 composed-handler reproduction unchanged on 971852d, in an isolated store on Windows/Bun 1.4.4: both unrelated CJK rows now survive with dedup enabled, and both content-token sets are empty. The focused dedup suites also pass. This verifies the reported scope-token leak is addressed in this PR (which is still open), rather than a claim about private retrieval measurements. Disclosure: the base includes earlier contributions by me; no independent approval of that code is implied.
abogartz
left a comment
There was a problem hiding this comment.
Review verdict: APPROVE (posted as comment — GitHub refuses approve/request-changes on self-authored PRs; the ruleset's approving review needs a second account or an admin merge).
Reviewed the branch diff against main with the reporter's probe reconstructed: contentTokens() now reads content+kw only — type/scope/status/tags all out; the CJK regression test is faithful red-on-main; no scope creep. Findings: 0 blocking, 1 disclosure (suppression strictly weakens for all multi-token scopes; §17 replay numbers predate the vocabulary change — added to the PR body; re-run the replay before/after #426 flips the default), 2 nits (a comment line on the opposite-direction change; ambient OPENCODE_MEMORY_QUERY_GATE hygiene in the new test — verified harmless).
|
🎉 This PR is included in version 0.28.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What
contentTokens()built its vocabulary fromhaystack()(content + keywords + scope + type) minus the whole scope/type strings. The #417 identifier tokenizer also emits the SPLIT words of a snake_case scope, soauth_token_refresh_policyleftauth/token/refresh/policystanding in for content. Two unrelated non-Latin rows in that scope shared a Jaccard-1 vocabulary supplied entirely by metadata, cleared theMIN_CONTENT=4floor on scope tokens alone, and dedup hid the older row through the composed handler.Fix: construct the vocabulary directly from the content and keyword fields. Metadata never enters; the floor keeps doing what it exists for.
Evidence
memory_recallhandler:query=auth_token_refresh_policy,OPENCODE_MEMORY_DEDUP=0.8, two settled learning rows. On main: only the newer row returned. With the fix: both.test/dedupe-scope-leak.test.ts: red on origin/main (3 fail), green with the fix. Unit tests pin the leak (scope contributes zero tokens to a non-Latin row) and the intent (content + keywords still supply the vocabulary).Blast radius
Dedup is flag-gated (
OPENCODE_MEMORY_DEDUP); flag-off path untouched. Rows are never deleted — the bug hid recall results; the fix restores them.Closes #421. Post-merge follow-up to #417.
Disclosure (from review, 2026-11-17)
Suppression strictly weakens for every multi-token scope, not only non-Latin rows: shared metadata tokens previously raised pair Jaccard ((i+k)/(u+k)); removing them lowers every pair's score, and rows whose content+kw vocabulary is under MIN_CONTENT=4 are now never compared. The §17 threshold replay ("0.8 suppresses only near-identical copies") predates this vocabulary change. The fix is flag-gated, so no shipped-behavior change on main today; PR #426 flips the default to 0.8, and the replay should be re-run against the new vocabulary before or right after that merge.