Repository navigation
fix(memory): diversify canonically equivalent CJK snippets - #164660
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 7:27 AM ET / 11:27 UTC (Revision 2). ClawSweeper reviewWhat this changesNormalize memory similarity text before word and CJK tokenization so equivalent Korean and Japanese snippets no longer crowd out distinct search results. Merge readiness✅ Ready for maintainer review This PR remains useful: current main and the latest release still distinguish canonically equivalent CJK snippets. The pinned patch has no actionable correctness findings, and the recorded Gateway and Dreaming before/after evidence sufficiently demonstrates the repair. Priority: P2 Review scores
Verification
How this fits togetherMemory Core retrieves saved notes and orders results using relevance and snippet similarity. Its shared similarity tokenizer also helps Dreaming deduplicate recalled memories and identify diary coverage. flowchart TD
A[Retrieved memory snippets] --> C[Shared similarity tokenizer]
B[Dreaming recall and diary text] --> C
C --> D[NFC normalization]
D --> E[Word and CJK tokens]
E --> F[Diversity ranking]
E --> G[Recall deduplication and diary matching]
F --> H[Bounded search results]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -4, Tests +20. Total +16 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep canonical-equivalence handling in the shared in-memory similarity tokenizer while preserving stored memory bytes and existing ranking contracts. Do we have a high-confidence way to reproduce the issue? Yes: current-main source and the two ranking fixtures establish the normalization mismatch, and the captured baseline Gateway runs demonstrate duplicate snippets displacing distinct results. This read-only review did not execute the reproduction. Is this the best way to solve the issue? Yes: moving the existing normalization ahead of both tokenizer lanes repairs the shared owner without adding another implementation or changing stored data. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e318434756f9. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
@clawsweeper re-review Please review exact head 03e9db1. Current main including #164062 is merged. The PR body records real Gateway memory_search before/after proof, mixed-script and English controls, disabled-MMR adapter control, shared Dreaming recall-dedupe proof, and the exact-head live gate. Normalization changes only shared in-memory similarity, not stored index/FTS tokenization; no reindex is required. |
|
🦞👀 Re-review progress:
|
|
Landed as 214bb47. Thanks @ly85206559! |
…164660) With MMR, memory search treated canonically equivalent Korean or Japanese snippets in different Unicode normalization forms (NFC vs NFD) as distinct, so duplicates crowded out a distinct relevant result. The shared memory tokenizer now normalizes to NFC, so equivalent text tokenizes the same way. This composes with the mixed-script tokenization from openclaw#164062. In Dreaming, the same tokenizer drives recall dedupe and diary coverage, so equivalent snippets now count as one candidate. Existing memory content is never deleted or rewritten, stored index and FTS tokenization are unchanged, and no reindex is needed. Proof: in a real built Gateway, `memory_search` returned NFC/NFD duplicate pairs for Hangul and kana on base, and the primary snippet plus the distinct one with this change. The Cyrillic mixed-script case and English ordering and scores are unchanged. The Dreaming recall preview collapses the equivalent pair to one candidate and keeps an unrelated snippet. The regression tests fail on base and pass here. A live gpt-5-mini smoke call passed. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Memory search can return duplicate Korean or Japanese snippets ahead of a distinct relevant result when the same characters use different Unicode normalization forms.
User Impact
Canonically equivalent Hangul and kana snippets now receive the same MMR similarity tokens. With a two-result limit, the distinct relevant memory is no longer crowded out by an NFC/NFD duplicate. Snippet bytes and relevance scores are unchanged.
The shared similarity tokenizer also serves Dreaming recall deduplication and diary coverage matching. Canonically equivalent snippets now count as the same there too. Normalization is in-memory: it does not delete or rewrite existing source memory content, stored chunks, embeddings, or FTS tokens. Future derived Dreaming candidate/coverage decisions can differ because equivalent snippets match. No reindex or migration is needed.
Why This Change Was Made
Normalize once before both the word-token and adjacent-CJK lanes. Preserve the mixed-script tokenization from #164062. The contributor's commits are retained, with current main merged for the shared-tokenizer base change.
Thanks to @ly85206559 for the fix and regression cases. No overlap with Pash/Sarah changes.
Evidence
Baseline:
e28f1c00d89dacafa4794bd8773d994a0100437c. Candidate:03e9db176ff54fd28a43336c528bf9f63d6803d6.memory_searchcalls withmaxResults: 2:각,각; candidate:각,나.が,が; candidate:が,な.server Москва резервная копияandserver Берлин погода сегодняon both versions.previewRemDreamingrecall-deduplication path: the NFC/NFD pair contributes two candidates on baseline and one on candidate; unrelated나remains. Input recall records are unchanged.git diff --checkpasses. Contributor code, installs, builds, tests, and Gateway executions ran only in task-owned Docker isolation.Gateway fixture setup corrections were limited to disabling lazy tool discovery for direct scripted calls and lowering the weak Cyrillic distractor's embedding relevance; the same final fixture and scores were used for baseline and candidate. This proves the normal Gateway/model-tool/index/search path, not a live embeddings-provider API.
Live gate on the candidate: one real
gpt-5-minirequest through a passive proxy, reasoninglow, output budget 4096, HTTP 200, and the expected final Gateway response. Memory-core was enabled with stub embeddings; no live embedding-provider claim. Task credentials were removed and the proxy stopped.