Repository navigation
fix(memory): Unicode support for MMR and FTS tokenizers - #38945
jarimustonen wants to merge 3 commits into
Conversation
Greptile SummaryThis PR fixes Unicode handling in two memory search tokenizers — Key changes:
Minor note: In Confidence Score: 4/5
Last reviewed commit: 0826768 |
a290bc2 to
439fb7c
Compare
The MMR tokenizer used /[a-z0-9_]+/g which dropped all non-ASCII
characters, causing Jaccard similarity to treat all non-English
snippets as identical (empty token sets → similarity 1.0). This made
MMR diversity re-ranking actively harmful for non-English users.
Replace with /[\p{L}\p{M}\p{N}_]+/gu to support all Unicode scripts
including combining marks (Thai tone marks, Devanagari virama, Arabic
diacritics). Add NFC normalization to prevent NFD/NFC mismatches.
Add test cases for Finnish, French, Chinese, Japanese, Korean, Russian,
Arabic, Hebrew, Thai, Hindi, and NFC normalization.
…okenizer
buildFtsQuery used /[\p{L}\p{N}_]+/gu which missed \p{M} (combining
marks), splitting Thai/Hindi/Arabic words at tone marks and virama.
Add \p{M} and .normalize("NFC") for consistent tokenization across
Unicode normalization forms.
Swap toLowerCase().normalize("NFC") → normalize("NFC").toLowerCase()
to follow Unicode best-practice order (normalize before fold) and
align with the style used in hybrid.ts.
439fb7c to
7398a23
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: the Unicode/NFC bug direction is still valid, but this PR is not merge-ready because it edits stale Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes, at source level. Current main still omits Is this the best way to solve the issue? No. The Unicode/NFC direction is right, but this branch targets stale files and needs a memory-core port that extends, rather than replaces, the current CJK tokenizer contract. Security review: Security review cleared: No concrete security or supply-chain concern found; the PR only changes tokenizer logic and colocated tests. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 9ff1a4371f68. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
ClawSweeper applied the proposed close for this PR.
|
Summary
src/memory/mmr.ts) used/[a-z0-9_]+/g, dropping all non-ASCII characters. Non-English memory snippets got empty token sets, making Jaccard similarity return 1.0 (identical) for all of them. This caused MMR diversity re-ranking to actively penalize non-English results as "duplicates". FTS tokenizer (src/memory/hybrid.ts) was missing\p{M}(combining marks), splitting Thai/Hindi/Arabic words at tone marks and virama.[\p{L}\p{M}\p{N}_]+with theuflag and NFC normalization.\p{L}= letters,\p{M}= combining marks (Thai tone marks, Devanagari virama, Arabic diacritics),\p{N}= numbers. NFC normalization prevents NFD/NFC mismatches (e.g. macOS filesystem returns NFD paths).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
src/memory/query-expansion.tsalready uses Unicode-aware patterns; this aligns the remaining two tokenizers.User-visible / Behavior Changes
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
Actual (before fix)
Evidence
Human Verification (required)
Compatibility / Migration
Failure Recovery (if this breaks)
src/memory/mmr.ts,src/memory/hybrid.tsRisks and Mitigations
\p{M}only affects scripts that use combining marks;\p{L}\p{N}behavior unchanged. NFC normalization is idempotent for already-NFC text.