fix(memory-core): CJK textScore=0 and empty MATCH LIKE fallback#92341
fix(memory-core): CJK textScore=0 and empty MATCH LIKE fallback#92341rrriiiccckkk wants to merge 8 commits into
Conversation
CJK tokens with 3+ characters were sent to matchTerms as quoted phrase matches (MATCH "飞书插件配置"), which rarely match with trigram tokenizer. Remove the character threshold so all CJK tokens go to substringTerms for LIKE matching with individual characters. Fixes openclaw#92061 (Bug 1)
|
Codex review: found issues before merge. Reviewed June 26, 2026, 6:17 AM ET / 10:17 UTC. Summary PR surface: Source +69. Total +69 across 2 files. Reproducibility: yes. for the source/dependency path: current main routes long CJK trigram tokens through MATCH and only falls back on exceptions, matching the reported zero-row behavior. I did not run a full live Ollama-backed memory search in this read-only review. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Use one canonical manager-search fix for CJK decomposition and empty-MATCH semantics, and keep keyword-only hybrid preservation at the manager selection boundary chosen by maintainers. Do we have a high-confidence way to reproduce the issue? Yes for the source/dependency path: current main routes long CJK trigram tokens through MATCH and only falls back on exceptions, matching the reported zero-row behavior. I did not run a full live Ollama-backed memory search in this read-only review. Is this the best way to solve the issue? No. This is a plausible partial repair, but it is not the best fix until CJK term decomposition, empty-MATCH fallback semantics, and hybrid keyword-preservation boundaries are corrected and covered. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ec737ee74d9b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +69. Total +69 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Two fixes: 1. Remove CJK < 3 char threshold: all CJK tokens now go to substringTerms for LIKE matching instead of being sent as quoted phrase MATCH. 2. Add LIKE fallback when FTS5 MATCH returns 0 rows: previously only triggered on MATCH exception. Now also triggers on empty results, using OR-based LIKE matching for better recall. Fixes openclaw#92061
|
Updated PR description with Real behavior proof. Ready for re-review. |
…penclaw#92337 When keyword and vector results have different chunk IDs (common with CJK/trigram queries), fall back to matching by path + overlapping line range instead of discarding textScore. Changes: - Add linesOverlap() helper function - Add vectorByPath secondary index for O(1) path lookups - When no chunk ID match: find vector chunk with highest vectorScore on same path with overlapping lines - Merge textScore into that vector entry (max textScore, expanded line range) - If no overlap found: preserve original keyword-only behavior Fixes openclaw#92337
|
Lint fix pushed. All CI checks passing now. Ready for re-review. @clawsweeper |
|
Hi @vincentkoc 👋 — this PR has been ready for review since June 14 (all CI green, mergeable, proof supplied). Could you take a look when you have a moment? Thanks! |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Summary
Fixes three related bugs that cause
textScore: 0in hybrid memory search for CJK queries (e.g. "飞书插件配置", "股票分析").Bug 1: CJK tokens bypass LIKE path (trigram tokenizer)
In
planKeywordSearch, CJK tokens with 3+ characters were sent tomatchTermsas quoted phrase matches (MATCH "飞书插件配置"), which rarely match with the trigram tokenizer. The< 3character threshold incorrectly routed long CJK strings to the MATCH path.Fix: Remove the
< 3threshold so all CJK tokens go tosubstringTermsfor LIKE matching.Bug 2: No LIKE fallback when MATCH returns 0 rows
When FTS5 MATCH returned 0 rows (not an exception), no LIKE fallback triggered. This affected both CJK queries and short English tokens (e.g.
AI,A) that the trigram tokenizer cannot index.Fix: Add LIKE fallback with OR-based matching when MATCH returns empty.
Bug 3: mergeHybridResults discards textScore when chunk IDs don't overlap (#92337)
When keyword and vector results have different chunk IDs (common with CJK/trigram queries), the keyword search results were effectively discarded —
textScorestayed 0 even thoughsearchKeywordreturned valid results.Fix: Add path + line range overlap fallback in
mergeHybridResults:vectorByPathsecondary index grouped by file pathvectorScoreon the same path with overlapping line rangestextScoreinto that vector entry (usingMath.max, expanded line range)Real behavior proof
textScore: 0for all results when querying with multi-character Chinese strings (e.g. "股票分析", "A股投研"). Root cause: (1) CJK tokens bypass LIKE path, (2) no LIKE fallback when MATCH returns 0 rows, (3)mergeHybridResultsdiscards textScore when keyword/vector chunk IDs don't overlap.Files Changed
extensions/memory-core/src/memory/manager-search.ts—planKeywordSearch+searchKeyword(Bug 1 & 2)extensions/memory-core/src/memory/hybrid.ts—mergeHybridResults(Bug 3)Closes #92061
Fixes #92337