Skip to content

fix(memory-core): preserve keyword-only hybrid results#92524

Open
yu-xin-c wants to merge 2 commits into
openclaw:mainfrom
yu-xin-c:openmeta/agent-92337-memory-core-mergehybridresults-i-1781293408228
Open

fix(memory-core): preserve keyword-only hybrid results#92524
yu-xin-c wants to merge 2 commits into
openclaw:mainfrom
yu-xin-c:openmeta/agent-92337-memory-core-mergehybridresults-i-1781293408228

Conversation

@yu-xin-c

@yu-xin-c yu-xin-c commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes hybrid memory search so keyword-only FTS hits survive the post-merge minScore boundary even when another vector result already passes the strict threshold.

Fixes #92337.

Real Behavior Proof

  • Behavior addressed: Hybrid search no longer drops valid keyword-only FTS hits just because at least one vector result is already strict.
  • Real environment tested: Local OpenClaw checkout at /Users/stellarfish/openclaw-92337-boundary, running the memory-core manager through node_modules/.bin/tsx --conditions=development with a real sqlite memory index, trigram FTS enabled, and a local mock embedding provider registered through OpenClaw's provider registry.
  • Exact steps or command run after this patch: Created an isolated workspace with memory/vector.md and memory/keyword.md, configured store.fts.tokenizer: "trigram", synced through getMemorySearchManager(...).sync(), then ran manager.search("飞书", { maxResults: 10, minScore: 0.35 }).
  • Evidence after fix:
{
  "query": "飞书",
  "fts": {
    "enabled": true,
    "available": true
  },
  "resultCount": 2,
  "results": [
    {
      "path": "memory/vector.md",
      "score": 0.7,
      "vectorScore": 1,
      "textScore": 0,
      "snippet": "# Vector\nvector-anchor semantic entry\n"
    },
    {
      "path": "memory/keyword.md",
      "score": 0.3,
      "vectorScore": 0,
      "textScore": 1,
      "snippet": "# Keyword\n飞书插件配置 已完成\n"
    }
  ]
}
  • Observed result after fix: The strict vector result remains first, and the keyword-only trigram FTS result is also preserved with vectorScore: 0, textScore: 1, and weighted score 0.3, even though minScore is 0.35.
  • What was not tested: Live user Ollama embeddings; the proof uses OpenClaw's real manager/sqlite/FTS path with a deterministic local embedding provider to avoid external credentials.

Changes

  • Move the preservation behavior to the manager search filtering boundary instead of inferring chunk identity from overlapping line ranges.
  • Keep mergeHybridResults exact-id semantics and leave the shared FTS token normalizer untouched.
  • Preserve current main's relaxed keyword-backed fallback when all weighted hybrid scores are below minScore, including overlapping vector+keyword hits.
  • Preserve keyword-only FTS hits when strict results exist while keeping the order already returned by mergeHybridResults, including MMR/temporal ordering.
  • Add regression coverage for keyword-only hybrid hits, overlapping keyword-backed fallback, and merge-order preservation.

Validation

Latest main refresh at c461225:

  • three focused selection regressions — 3 passed, 75 skipped
  • node scripts/run-vitest.mjs extensions/memory-core/src/memory/hybrid.test.ts — 15 passed
  • changed-file oxfmt and oxlint — passed
  • git diff --check upstream/main...HEAD — passed
  • incremental source type check — no changed-file errors; the shared linked dependency tree only reports two unrelated missing @openclaw/fs-safe/advanced exports
  • GitHub CI — 47 checks passed, including openclaw/ci-gate

Risks

  • The result window is still capped by maxResults, so keyword-only hits can be trimmed if higher-ranked selected results fill the requested limit.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: S triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 12, 2026
@clawsweeper

clawsweeper Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 21, 2026, 2:25 AM ET / 06:25 UTC.

Summary
The branch changes memory-core hybrid result selection so keyword-only FTS hits can survive minScore alongside strict vector hits, and adds regression tests for fallback and ordering behavior.

PR surface: Source +24, Tests +144. Total +168 across 2 files.

Reproducibility: yes. from source and supplied proof: the manager path can produce a keyword-only weighted result below minScore beside a strict vector result, and the branch demonstrates the changed selection result through real SQLite/FTS manager execution. The review did not independently execute that scenario in this read-only pass.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/memory/index.test.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager.ts, vector/embedding metadata: extensions/memory-core/src/memory/index.test.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Rebase onto current main and show the focused selection cases still pass against the current hybrid implementation.
  • State explicitly how this rule coexists with or replaces the overlapping merge-layer proposal.

Risk before merge

  • [P1] Merging without rebasing against current main could choose a manager-side preservation rule that conflicts with newer hybrid retrieval behavior or duplicates the still-open merge-layer proposal.
  • [P1] The patch intentionally lets a keyword-only result below minScore remain when strict results exist; this is a retrieval-policy and session-state behavior change that needs maintainer acceptance across the related hybrid-search fixes.

Maintainer options:

  1. Rebase and compare selection semantics (recommended)
    Refresh this branch against current main and explicitly prove that its manager-side rule remains compatible with current hybrid ordering and the overlapping open proposals.
  2. Accept a separate recall policy
    Land the manager-side rule only if maintainers intentionally want keyword-backed recall to bypass the normal weighted-score boundary.
  3. Pause for one canonical proposal
    Pause this branch if a consolidated hybrid-search patch is preferred over maintaining separate merge and selection fallbacks.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main, compare against the active memory-core hybrid PRs, and add focused current-main coverage for strict, keyword-only, and overlapping candidates before requesting merge.

Next step before merge

  • [P2] The remaining blocker is a maintainer choice among overlapping hybrid-retrieval policies, not a narrow mechanical repair.

Maintainer decision needed

  • Question: Should OpenClaw preserve below-threshold keyword-only hybrid hits at the manager selection boundary, or consolidate that behavior with the overlap-aware merge approach in fix(memory-core): CJK textScore=0 and empty MATCH LIKE fallback #92341?
  • Rationale: Both paths address non-overlapping vector and keyword results but establish different long-term retrieval invariants; code review cannot safely choose the product ranking policy without maintainer intent.
  • Likely owner: rrriiiccckkk — They are the strongest evidenced technical contact across the overlapping non-overlap and CJK retrieval reports, though final product acceptance remains with repository leadership.
  • Options:
    • Adopt manager-side preservation (recommended): Rebase this PR and accept keyword-backed recall as a manager selection policy while keeping exact-id merge semantics.
    • Consolidate with merge-layer work: Ask the authors to produce one current-main patch that resolves the same user case without parallel fallback rules.
    • Defer ranking policy: Keep both proposals open until maintainers define the intended minScore and hybrid-recall contract.

Security
Cleared: The diff is limited to memory result selection and tests; it adds no dependency, workflow, secret, permission, artifact, or supply-chain execution surface.

Review details

Best possible solution:

Rebase onto current main, compare this manager-side selection rule directly with the live merge-layer proposal, and land one tested canonical hybrid-retrieval policy that preserves valid keyword-only recall without creating competing fallback semantics.

Do we have a high-confidence way to reproduce the issue?

Yes from source and supplied proof: the manager path can produce a keyword-only weighted result below minScore beside a strict vector result, and the branch demonstrates the changed selection result through real SQLite/FTS manager execution. The review did not independently execute that scenario in this read-only pass.

Is this the best way to solve the issue?

Unclear. The manager-side boundary is a plausible narrow fix and avoids inferring overlap from line ranges, but the best permanent rule must be compared with the active merge-layer approach before merge.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f1205f5f0bcd.

Label changes

Label justifications:

  • P2: This is a bounded memory-search correctness and recall improvement with no evidence of an emergency outage or data loss.
  • merge-risk: 🚨 session-state: Changing hybrid result selection can alter which persisted memory and session-context results are returned to users for the same query.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides an after-fix real manager/SQLite/FTS execution with observable returned results; no private credentials are exposed in the supplied output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides an after-fix real manager/SQLite/FTS execution with observable returned results; no private credentials are exposed in the supplied output.
Evidence reviewed

PR surface:

Source +24, Tests +144. Total +168 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 52 28 +24
Tests 1 144 0 +144
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 196 28 +168

What I checked:

Likely related people:

  • rrriiiccckkk: Authored the detailed reports behind the exact-id/non-overlap and CJK keyword-search paths and the overlapping open proposal, making them a strong technical routing contact for selection semantics. (role: related implementation author; confidence: medium; files: extensions/memory-core/src/memory/hybrid.ts, extensions/memory-core/src/memory/manager.ts)
  • yu-xin-c: Authored the current branch and its real-manager proof, including the manager-side alternative to overlap inference. (role: current selection-boundary proposer; confidence: high; commits: fa4cf8a7f886, c461225bb8f0; files: extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/index.test.ts)
  • openclaw-clownfish[bot]: Its merged PR fix(memory): use per-keyword FTS search in hybrid mode #39484 #73976 is the supplied provenance for a recent related hybrid FTS repair, so it is useful history context rather than a decision owner. (role: recent merged adjacent-repair author; confidence: medium; commits: e1d3f12d7f5b; files: extensions/memory-core/src/memory)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (3 earlier review cycles)
  • reviewed 2026-06-21T19:03:11.421Z sha 0f5dd47 :: needs maintainer review before merge. :: none
  • reviewed 2026-06-30T23:46:56.366Z sha 0f5dd47 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-21T05:43:07.915Z sha c461225 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 12, 2026
@yu-xin-c
yu-xin-c force-pushed the openmeta/agent-92337-memory-core-mergehybridresults-i-1781293408228 branch from 83e2b8c to ece616c Compare June 12, 2026 20:10
@yu-xin-c yu-xin-c changed the title fix(memory-core): preserve overlapping hybrid keyword scores fix(memory-core): preserve keyword-only hybrid results Jun 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: supplied External PR includes structured after-fix real behavior proof. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 12, 2026
@yu-xin-c

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 12, 2026
@yu-xin-c

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 14, 2026
@yu-xin-c

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 21, 2026
@yu-xin-c
yu-xin-c force-pushed the openmeta/agent-92337-memory-core-mergehybridresults-i-1781293408228 branch from 0f5dd47 to c461225 Compare July 21, 2026 05:39
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 22, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory-core: mergeHybridResults ignores textScore when keyword/vector chunk IDs don't overlap

1 participant