Skip to content

fix(memory): rank filename and path matches - #96052

Closed
Pick-cat wants to merge 8 commits into
openclaw:mainfrom
Pick-cat:fix/issue-94102
Closed

Pick-cat wants to merge 8 commits into
openclaw:mainfrom
Pick-cat:fix/issue-94102

Conversation

@Pick-cat

@Pick-cat Pick-cat commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

memory_search indexed only chunk bodies. Exact filename and date-stem queries such as 2026-06-17-1649 could therefore behave like vector-only semantic searches and omit the indexed file whose basename exactly matched the query.

Fixes #94102.

Why This Change Was Made

The maintainer rewrite keeps path retrieval separate from body retrieval instead of prefixing every chunk's FTS payload with its path. A one-row-per-source path FTS index is maintained from the canonical source table and rebuilt transactionally during shadow publication.

Search carries one closed specificity tier (full path > basename > stem > partial) through FTS-only and hybrid ranking. Exact identifiers remain ahead of semantic neighbors, while body/vector relevance orders duplicates within the same tier. Unicode normalization, short trigram terms, source scoping, temporal decay, MMR, existing-database backfill, VACUUM rowid changes, and duplicate basenames beyond the candidate cap have dedicated regressions.

This design leaves body FTS bytes, BM25 scores, snippets, embeddings, and embedding-cache identity unchanged; existing indexes gain only the derived path table and do not re-embed. The path table constant and canonical trigger owners cross the bundled-plugin boundary through the existing public memory SDK subpath; its pinned surface budget advances by exactly three exports, two callable.

User Impact

Searching an exact memory path, basename, filename stem, generated timestamp, or partial path now surfaces the intended memory file before unrelated semantic neighbors. Body searches keep their existing ranking and snippets, with no new configuration or reindex requirement.

Evidence

  • Exact pushed head: 33b3208573164354cc451fb41fdd83d0849637f3.
  • Hosted exact-head CI: run 29147962600, green.
  • Sanitized AWS focused proof: run_0f73781a787a, 121/121 across path/body search, hybrid/FTS-only ranking, schema startup and mutation triggers, shadow publication, duplicate basenames, Unicode NFC/NFD, CJK, temporal decay, and MMR.
  • Sanitized AWS changed gate: run_40cef702f5df, all 15 touched paths, routed lanes, types, lint, and guards green.
  • Package/install/index: run_b31ccb13999f; tarball integrity and global install passed, OpenClaw 2026.7.2 (33b3208), provider none.
  • Maintainer live CLI proof: run_ee24ec1fa100; duplicate filename/full-path/stem ordering, byte-identical body results across processes, zero false positives, vectors/cache disabled, and unchanged body-index fingerprint passed.
  • Independent source-blind behavior validation: satisfies_contract at confidence 0.97; 231 duplicate basenames, Unicode NFC/NFD, clean body snippets, human/JSON parity, restart stability, and filename/body mutation probes all passed.
  • Targeted oxfmt, oxlint, and git diff --check: clean.
  • Fresh branch review and budget-fix autoreview: clean; final confidence 0.98.

Co-authored-by: Pick-cat [email protected]

@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated: rebased on latest main, PR body with ## What Problem This Solves + ## Evidence, fresh proof with negative control, CI green.

@clawsweeper

clawsweeper Bot commented Jun 23, 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.

@clawsweeper

clawsweeper Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 7:44 AM ET / 11:44 UTC.

Summary
The branch implements separate filename/path indexing and ranking for memory search with tests and docs, while also carrying a large repository-wide set of unrelated workflow, dependency, SDK, app, channel, gateway, plugin, and UI changes.

Reproducibility: yes. The canonical issue provides a concrete CLI query where a healthy indexed exact filename stem loses to semantic neighbors, with content-search and index-health controls isolating the ranking defect.

Review metrics: 2 noteworthy metrics.

  • Intended diff concentration: 11 intended, 422 unrelated files. The useful memory change is a small subset of a repository-wide snapshot, which materially changes the merge decision.
  • Public SDK expansion: 3 memory exports added, 2 callable. The focused fix crosses the plugin boundary and must retain its API baseline/export validation when reconstructed.

Stored data model
Persistent data-model change detected: database schema: ui/src/pages/plugin/workspace-view.test.ts, serialized state: ui/src/lib/workspace/widgets/sessions.ts, serialized state: ui/src/pages/chat/components/chat-pull-requests.test.ts, unknown-data-model-change: ui/src/lib/workspace/widgets/sessions.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #94102
Summary: This PR is the active candidate fix for the canonical filename/date-token ranking issue; the earlier closed-unmerged PR is superseded by this separate-index design.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦐 gold shrimp
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

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

Rank-up moves:

  • Reconstruct or replace the branch with only the focused 11-file patch.
  • Post redacted installed-CLI proof for the final exact head.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR contains strong installed CLI and linked run evidence for 33b3208, but later commits changed exact-query scoping and relevance ordering; add redacted installed-CLI output for the reconstructed final head, then update the PR body to trigger a fresh review or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging the current branch would require resolving conflicts across 422 unrelated files and could unintentionally land dependency, public SDK, runtime, application, channel, plugin, and automation changes unrelated to memory search.
  • [P1] The dependency graph mutations are blocked by repository policy and expand supply-chain review beyond the stated fix.
  • [P1] The strongest installed-CLI proof targets 33b3208; two later commits changed exact-query scoping and net-relevance ordering, so current-head runtime behavior is not directly proven.

Maintainer options:

  1. Reconstruct the focused patch (recommended)
    Replace the current mixed branch with only the intended 11-file memory patch on current main and rerun exact-head proof.
  2. Close and resubmit narrowly
    Close this branch and open a fresh memory-only PR if preserving its history is not worth the conflict and contamination risk.

Next step before merge

  • [P1] The protected security label, blocked dependency graph changes, merge conflicts, and 422 unrelated files require a maintainer-controlled branch reconstruction or replacement decision rather than automated repair.

Maintainer decision needed

  • Question: Should the focused memory fix replace this PR's branch content, or should this mixed conflicting branch be closed and the fix resubmitted as a fresh PR?
  • Rationale: The useful implementation is separable and well motivated, but the security-labeled branch contains 422 unrelated files, blocked dependency changes, and merge conflicts; preserving this branch versus replacing it requires maintainer control.
  • Likely owner: steipete — They authored the rewrite, are assigned to the PR, and have the most direct context to reconstruct or replace the branch safely.
  • Options:
    • Reconstruct this PR (recommended): Replace the branch content with the focused 11-file patch on current main while preserving contributor credit and discussion history.
    • Open a fresh focused PR: Close this mixed branch and resubmit only the intended memory changes if reconstructing its history is riskier than replacement.

Security
Needs attention: The focused memory code has no identified security defect, but the branch mixes it with unrelated dependency-resolution and executable workflow changes that require removal or explicit security authorization.

Review findings

  • [P1] Remove the unrelated repository snapshot — .github/workflows/node22-compat.yml:1
Review details

Best possible solution:

Ship the separate path-FTS design as a clean current-main patch containing only the 11 intended memory, SDK, test, and documentation files, with exact-head installed-CLI proof that exact paths, basenames, stems, duplicate names, body relevance, snippets, temporal decay, and restart/backfill behavior remain correct.

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

Yes. The canonical issue provides a concrete CLI query where a healthy indexed exact filename stem loses to semantic neighbors, with content-search and index-health controls isolating the ranking defect.

Is this the best way to solve the issue?

Yes for the focused architecture: a separate path index preserves chunk-body FTS bytes, BM25, snippets, embeddings, and cache identity better than prefixing paths into body text. No for the current branch shape, which is not a safe merge vehicle.

Full review comments:

  • [P1] Remove the unrelated repository snapshot — .github/workflows/node22-compat.yml:1
    Only 11 of the 433 changed files belong to this memory fix; the other 422 include workflows, dependency manifests and lockfiles, unrelated public SDK behavior, apps, channels, gateway, plugins, and Control UI. The branch is conflicting and would land unrelated behavior and supply-chain changes, so reconstruct it on current main with only the focused memory, SDK, test, and docs changes.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add merge-risk: 🚨 compatibility: The branch includes unrelated dependency, public SDK, runtime, app, channel, and plugin changes that could alter existing installations and integrations.
  • add merge-risk: 🚨 automation: The branch adds or modifies unrelated GitHub Actions and CI-routing behavior that would execute after merge.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR contains strong installed CLI and linked run evidence for 33b3208, but later commits changed exact-query scoping and relevance ordering; add redacted installed-CLI output for the reconstructed final head, then update the PR body to trigger a fresh review or ask a maintainer to comment @clawsweeper re-review.

Label justifications:

  • P2: The underlying bug degrades exact memory retrieval for filename and timestamp queries but has a bounded blast radius.
  • merge-risk: 🚨 compatibility: The branch includes unrelated dependency, public SDK, runtime, app, channel, and plugin changes that could alter existing installations and integrations.
  • merge-risk: 🚨 automation: The branch adds or modifies unrelated GitHub Actions and CI-routing behavior that would execute after merge.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR contains strong installed CLI and linked run evidence for 33b3208, but later commits changed exact-query scoping and relevance ordering; add redacted installed-CLI output for the reconstructed final head, then update the PR body to trigger a fresh review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

Security concerns:

  • [high] Remove unrelated dependency graph changes — extensions/workspaces/package.json:1
    The branch changes pnpm-lock.yaml and extensions/workspaces/package.json dependency graph fields despite a memory-ranking-only purpose, expanding package resolution and supply-chain scope without relevant justification.
    Confidence: 0.99
  • [high] Remove unrelated workflow execution changes — .github/workflows/node22-compat.yml:1
    The branch adds and modifies GitHub Actions workflows, including a new Node compatibility workflow, so merging it would execute automation unrelated to the reviewed memory behavior.
    Confidence: 0.99

What I checked:

Likely related people:

  • steipete: Authored all eight current PR commits, is assigned to the live PR, and has extensive merged history in memory-core architecture and refactors. (role: rewrite author and current assignee; confidence: high; commits: 6a525c04167d, 4c1130201c11, cad83db8b2; files: extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/manager-search.ts, src/plugin-sdk/memory-core-host-engine-storage.ts)
  • Vincent Koc: Recent merged history includes memory SQLite hot-path, provider bootstrap, sync typing, and release-path work adjacent to the affected search manager. (role: recent memory performance contributor; confidence: medium; commits: d648aebf4d, 7d6d112656, 7330e2ce23; files: extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/manager-db.ts)
  • Tak Hoffman: Merged history includes default QMD recall and related memory-search behavior, making them a useful secondary reviewer for retrieval semantics. (role: memory search feature contributor; confidence: medium; commits: 885209ed03; files: extensions/memory-core/src/memory/manager.ts)
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 (6 earlier review cycles)
  • reviewed 2026-07-02T13:14:34.527Z sha 81832f1946530d18cbf991016b969191d60cce1f :: needs maintainer review before merge. :: none
  • reviewed 2026-07-11T09:28:14.241Z sha 71c91bb :: needs real behavior proof before merge. :: [P2] Account for the new public SDK exports
  • reviewed 2026-07-11T09:44:38.645Z sha 33b3208 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T09:53:49.572Z sha 33b3208 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-11T10:25:28.451Z sha 33b3208 :: needs changes before merge. :: none
  • reviewed 2026-07-11T10:46:53.359Z sha 8487da9 :: needs real behavior proof before merge. :: [P1] Remove the unrelated repository snapshot from the final commit

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 23, 2026
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

Ready for review — all 4 PR body sections complete, CI green, negative control proof included, vitest 53/53 passed.

@clawsweeper clawsweeper Bot added status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 24, 2026
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 25, 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.

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. labels Jun 25, 2026
@Pick-cat

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 25, 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.

@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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 25, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Jul 11, 2026
@steipete
steipete requested review from a team as code owners July 11, 2026 10:32
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: matrix Channel integration: matrix app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: codex plugin: workspaces Agent-composable Workspaces plugin labels Jul 11, 2026
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Jul 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/workspaces/package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph changes are blocked

OpenClaw does not accept dependency graph changes through PRs unless a repository admin or security explicitly authorizes the current head SHA. Dependency updates are generated internally by maintainers so external PRs cannot change the resolved graph.

Detected dependency graph changes:

  • pnpm-lock.yaml changed.
  • extensions/workspaces/package.json changed dependencies, devDependencies, peerDependencies, peerDependenciesMeta, name, version.

Auto-scrub was not attempted because this PR changes package manifest dependency graph fields:

  • extensions/workspaces/package.json changed dependencies, devDependencies, peerDependencies, peerDependenciesMeta, name, version.

Dependency graph changes must be reviewed by security or handled by maintainers internally. Please remove lockfile changes manually if they are not needed.

To remove lockfile changes, restore them from the target branch:

git fetch origin
git checkout 'origin/main' -- 'pnpm-lock.yaml'
git commit -m 'chore: remove dependency lockfile change'
git push

If this PR intentionally needs a dependency graph change, ask a repository admin or member of @openclaw/openclaw-secops to comment:

/allow-dependencies-change

The action will approve the current head SHA (4c1130201c11acc50e1272bc18d15963564962c6) when it reruns. A later push requires a fresh approval.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added the channel: googlechat Channel integration: googlechat label Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(memory): rank filename and path matches This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete

Copy link
Copy Markdown
Contributor

Landed the credited replacement in #104449 as e9b7a9a912773217e8d6c51ee381266ee32e7661.

The final implementation keeps this PR as its base, then extends it with a separate path FTS index, bounded exact/non-exact candidate handling, Unicode and fallback controls, stable row identity, transactional v1-to-v2 migration, and exact-head Linux/package proof. We used a maintainer-owned replacement because GitHub's verified branch editor could update this fork's tree but could not rewrite its stale ancestry onto current main.

Thank you, @Pick-cat, for the original fix and test direction. For future PRs, keeping “Allow edits by maintainers” enabled helps with ordinary fixups; ancestry rewrites can still require a credited replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: macos App: macos app: web-ui App: web-ui channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: matrix Channel integration: matrix channel: telegram Channel integration: telegram cli CLI command changes commands Command implementations dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation extensions: codex extensions: memory-core Extension: memory-core gateway Gateway runtime merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: google-meet plugin: workspaces Agent-composable Workspaces plugin rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security Security documentation size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory_search ranks filename/date-token queries poorly despite clean index and working content search

2 participants