fix(memory): preserve FTS5 BM25 relevance in bm25RankToScore (#5767)#33757
fix(memory): preserve FTS5 BM25 relevance in bm25RankToScore (#5767)#33757lsdcc01 wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a bug in Root cause: SQLite FTS5's Fix: For negative ranks, use Key observations:
Confidence Score: 5/5
Last reviewed commit: ec77563 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec77563c8b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
| if (rank < 0) { | ||
| const relevance = -rank; | ||
| return relevance / (1 + relevance); |
There was a problem hiding this comment.
Keep keyword fallback reachable with finite BM25 scores
The new negative-rank mapping returns textScore < 1 for every finite FTS5 match, so keyword-only hybrid scores become strictly less than textWeight. In src/memory/manager.ts:335, the relaxed fallback still uses relaxedMinScore = min(minScore, textWeight), which means with the default minScore=0.35 and textWeight=0.3 a keyword-only result can no longer satisfy either filter (score = textWeight * textScore < 0.3). This regresses the fallback path that is supposed to keep lexical hits when vector results are absent/weak.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1438069d5f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
pnpm-lock.yaml
Outdated
| @@ -876,16 +876,16 @@ packages: | |||
| resolution: {integrity: sha512-/42G73JkuYdyWZ6m8d/CJtBrGl1Hegyc7Fy78m5Ob+jF85TOUmLR5XLce/U3LxYAw0kJ8CT5aI99RIvPHcGp/Q==} | |||
|
|
|||
| '@cloudflare/workers-types@4.20260120.0': | |||
| resolution: {integrity: sha512-B8pueG+a5S+mdK3z8oKu1ShcxloZ7qWb68IEyLLaepvdryIbNC7JVPcY0bWsjS56UQVKc5fnyRge3yZIwc9bxw==} | |||
| resolution: {integrity: sha1-wBnoj9UlUhhtvQ4IZL+oD7NGYzU=, tarball: https://artsz.zte.com.cn:443/artifactory/api/npm/it-npm-virtual/@cloudflare/workers-types/-/workers-types-4.20260120.0.tgz} | |||
There was a problem hiding this comment.
Remove private mirror tarballs from lockfile
This lockfile update pins package resolutions to https://artsz.zte.com.cn/... tarballs, so pnpm install will try to fetch from that private Artifactory host instead of the public registry. In any CI runner or contributor environment without access to that network, dependency installation will fail, which blocks builds and tests for this commit.
Useful? React with 👍 / 👎.
1438069 to
b2cbcd2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2cbcd2613
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (rank < 0) { | ||
| const relevance = -rank; | ||
| return relevance / (1 + relevance); |
There was a problem hiding this comment.
Keep finite BM25 scores able to pass keyword fallback
The new negative-rank normalization returns textScore < 1 for every finite FTS5 hit, so keyword-only hybrid scores become strictly less than textWeight. In the fallback path (src/memory/manager.ts), relaxed filtering still uses min(minScore, textWeight), which means with defaults (minScore=0.35, textWeight=0.3) keyword-only results can no longer meet the relaxed threshold when vector matches are absent/zero—the exact scenario this fallback is meant to preserve.
Useful? React with 👍 / 👎.
|
Landed on What I did:
Hashes:
Thanks @lsdcc01. |
…lsdcc01) Land openclaw#33757 by @lsdcc01 without the unrelated dependency bump. Preserve negative FTS5 BM25 ordering in hybrid scoring and add changelog coverage for openclaw#5767. Co-authored-by: 丁春才0668000523 <ding.chuncai1@xydigit.com>
…lsdcc01) Land openclaw#33757 by @lsdcc01 without the unrelated dependency bump. Preserve negative FTS5 BM25 ordering in hybrid scoring and add changelog coverage for openclaw#5767. Co-authored-by: 丁春才0668000523 <ding.chuncai1@xydigit.com>
…lsdcc01) Land openclaw#33757 by @lsdcc01 without the unrelated dependency bump. Preserve negative FTS5 BM25 ordering in hybrid scoring and add changelog coverage for openclaw#5767. Co-authored-by: 丁春才0668000523 <ding.chuncai1@xydigit.com>
…lsdcc01) Land openclaw#33757 by @lsdcc01 without the unrelated dependency bump. Preserve negative FTS5 BM25 ordering in hybrid scoring and add changelog coverage for openclaw#5767. Co-authored-by: 丁春才0668000523 <ding.chuncai1@xydigit.com>
…lsdcc01) Land openclaw#33757 by @lsdcc01 without the unrelated dependency bump. Preserve negative FTS5 BM25 ordering in hybrid scoring and add changelog coverage for openclaw#5767. Co-authored-by: 丁春才0668000523 <ding.chuncai1@xydigit.com>
…lsdcc01) Land openclaw#33757 by @lsdcc01 without the unrelated dependency bump. Preserve negative FTS5 BM25 ordering in hybrid scoring and add changelog coverage for openclaw#5767. Co-authored-by: 丁春才0668000523 <ding.chuncai1@xydigit.com>
…lsdcc01) Land openclaw#33757 by @lsdcc01 without the unrelated dependency bump. Preserve negative FTS5 BM25 ordering in hybrid scoring and add changelog coverage for openclaw#5767. Co-authored-by: 丁春才0668000523 <ding.chuncai1@xydigit.com>
Summary
Change Type
Scope
Linked Issue/PR
User-visible / Behavior Changes
Hybrid search (vector + keyword) now correctly ranks BM25 matches by relevance instead of treating all matches equally.
Security Impact
Evidence
Compatibility / Migration