Skip to content

fix(memory): search by filenames and paths - #104449

Merged
steipete merged 1 commit into
mainfrom
codex/pr-96052-memory-path-search
Jul 11, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/pr-96052-memory-path-search

Conversation

@steipete

@steipete steipete commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #94102

Maintainer-owned replacement for #96052. This keeps @Pick-cat's implementation as the credited base while allowing the reviewed tree to use current main ancestry; the contributor fork's verified web-editor path could update its tree but could not rewrite its stale ancestry.

What Problem This Solves

Fixes an issue where memory search would miss relevant notes when users searched for a filename or path term that was absent from the note body.

Why This Change Was Made

Indexes normalized paths in a separate one-row-per-source FTS table, preserving the existing body index, BM25 scores, snippets, and embeddings. Exact full-path, basename, and stem matches receive deterministic precedence; partial Unicode path matches, multi-term fallback, source filters, atomic shadow-index publication, and temporal/MMR ranking retain their existing owner boundaries.

User Impact

Users can find memories by full path, filename, stem, or partial Unicode path text without polluting body relevance. Existing content and semantic search behavior remains unchanged when paths do not match, and disabling FTS still removes all FTS-owned tables.

Evidence

  • Exact replacement head: daea62fb242784c5f73f53b8d9238ba57dab4a96; GitHub-verified, based directly on 96f0983a85b5a7798d35e97d8f530fed9b567929, and tree-identical to the reviewed local branch.
  • Fresh full-branch autoreview and independent full-surface audit: clean across bounded candidate partitions, Unicode/fallback ranking, temporal/MMR behavior, stable FTS row identity, shadow publication, and the atomic agent-database v1-to-v2 migration.
  • Regression coverage includes full path/basename/stem/partial matching, NFC/NFD and non-Latin text, exact/non-exact candidate caps, multi-term fallback, body/path score separation, temporal decay, MMR grouping, malformed-schema rollback, and concurrent owner/version claims.
  • Exact-head sanitized AWS/Linux proof: run_297dcc97f02a passed 237 focused SDK, schema, migration, ranking, and tool tests; hosted CI run 29161927119 completed with 72 pass, 27 intentional skips, and 0 failures.
  • Exact-head package proof: run_2eda117a0eb1 built and validated the tarball, installed it into an isolated prefix, passed 8/8 JSON/human search assertions (including exact/partial Unicode and a negative control), and passed 2/2 rename/reindex assertions.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Jul 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03d2db14cb

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +15 to +18
dropMemoryPathFtsTriggers,
ensureDir,
ensureMemoryIndexSchema,
ensureMemoryPathFtsTriggers,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Commit the SDK API baseline hash

These added exports intentionally enlarge the public plugin-sdk/memory-core-host-engine-storage API, but the diff only raises the surface-count budgets. The repo's plugin-sdk:api:check path compares the generated API baseline hash and fails with instructions to run pnpm plugin-sdk:api:gen when public SDK exports change; because docs/.generated/plugin-sdk-api-baseline.sha256 is unchanged in this commit, the plugin-SDK changed lane will reject this API addition until the updated hash is committed.

Useful? React with 👍 / 👎.

@steipete steipete closed this Jul 11, 2026
@steipete
steipete force-pushed the codex/pr-96052-memory-path-search branch from 03d2db1 to 6c415c4 Compare July 11, 2026 11:56
@steipete steipete reopened this Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 1:47 PM ET / 17:47 UTC.

Summary
Adds filename/path-aware memory retrieval through a per-source FTS index, migrates agent databases to stable memory-source IDs, expands the memory SDK, preserves backend ranking, and adds regression tests and documentation.

PR surface: Source +1167, Tests +2907, Docs +9, Generated +2, Other 0. Total +4085 across 25 files.

Reproducibility: yes. The canonical report and current body-only FTS implementation establish that exact filename or date-stem queries can miss the matching indexed source.

Review metrics: 2 noteworthy metrics.

  • Stored schema change: 1 version bump, v1 to v2. Existing per-agent databases migrate synchronously during runtime open, so rollback and upgrade behavior matter before merge.
  • Public SDK expansion: 3 exports added, 2 callable. The bundled memory plugin now depends on a wider supported SDK contract for path-index publication.

Stored data model
Persistent data-model change detected: database schema: extensions/memory-core/src/memory/manager-db.ts, database schema: src/state/openclaw-agent-db.test.ts, database schema: src/state/openclaw-agent-db.ts, serialized state: extensions/memory-core/src/memory/index.test.ts, serialized state: src/state/openclaw-agent-db.generated.d.ts, serialized state: src/state/openclaw-agent-db.test.ts, and 27 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #94102
Summary: This PR is the focused replacement candidate for the canonical filename-ranking bug; the older contributor PR is superseded as a viable landing branch.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until 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:

  • Remove the CHANGELOG.md entry.
  • Post exact-head installed CLI and version-1-to-version-2 migration output or linked artifacts, redacting private paths, IP addresses, endpoints, credentials, phone numbers, and other identifiers.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The exact-head PR body still says Linux tests, package installation, live installed CLI behavior, and source-blind validation are in progress without inspectable run IDs or output; add redacted terminal or log evidence, then update the PR body to trigger a fresh review, or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] Runtime startup upgrades shipped per-agent SQLite databases from schema version 1 to 2; a migration defect could prevent database opening or damage memory index state.
  • [P1] The three new exported memory SDK symbols, including two callable trigger helpers, become compatibility commitments for plugin consumers.
  • [P1] The branch is behind current main, so the final integrated head needs refreshed review and proof; stale-base drift alone is not evidence that a three-way merge removes current-main behavior.

Maintainer options:

  1. Finish the landing gates (recommended)
    Remove the changelog entry, refresh onto current main, and attach exact integrated-head installed search and database-upgrade proof before merge.
  2. Pause for schema-owner review
    Keep the PR open for the database-area owner if the shipped migration or permanent SDK commitment cannot be confirmed.

Next step before merge

  • [P1] The protected maintainer PR should remain in explicit maintainer handling; remove the changelog line and obtain exact-head real behavior proof before merge.

Security
Cleared: The focused commit adds no dependency, workflow, permission, secret, package-resolution, publishing, or downloaded-code execution changes.

Review findings

  • [P2] Remove the release-owned changelog entry — CHANGELOG.md:32
Review details

Best possible solution:

Keep the separate per-source path index, remove the release-owned changelog entry, then attach exact integrated-head installed CLI and version-1-to-version-2 upgrade evidence before maintainer landing.

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

Yes. The canonical report and current body-only FTS implementation establish that exact filename or date-stem queries can miss the matching indexed source.

Is this the best way to solve the issue?

Yes. A one-row-per-source path index is narrower and more maintainable than injecting paths into every chunk because it preserves existing content BM25, snippets, embeddings, and cache identity.

Full review comments:

  • [P2] Remove the release-owned changelog entry — CHANGELOG.md:32
    This normal bug-fix PR still edits CHANGELOG.md, although repository policy reserves that file for release generation and keeps release-note context in the PR body or commit message. Remove this line to avoid conflicting with the generated release changelog; this finding remains from earlier review cycles.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add merge-risk: 🚨 compatibility: The PR changes a shipped persistent schema and expands a public plugin SDK subpath, requiring upgrade and caller-compatibility proof beyond green CI.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The exact-head PR body still says Linux tests, package installation, live installed CLI behavior, and source-blind validation are in progress without inspectable run IDs or output; add redacted terminal or log evidence, then update the PR body to trigger a fresh review, or ask a maintainer to comment @clawsweeper re-review.

Label justifications:

  • P2: This fixes a concrete but bounded memory retrieval failure for filename and path queries.
  • merge-risk: 🚨 compatibility: The PR changes a shipped persistent schema and expands a public plugin SDK subpath, requiring upgrade and caller-compatibility proof beyond green CI.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The exact-head PR body still says Linux tests, package installation, live installed CLI behavior, and source-blind validation are in progress without inspectable run IDs or output; add redacted terminal or log evidence, then update the PR body to trigger a fresh review, or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +1167, Tests +2907, Docs +9, Generated +2, Other 0. Total +4085 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 10 1282 115 +1167
Tests 8 2925 18 +2907
Docs 3 30 21 +9
Config 0 0 0 0
Generated 3 5 3 +2
Other 1 2 2 0
Total 25 4244 159 +4085

What I checked:

  • Current-main problem remains: Current main exposes body keyword/vector search but has no per-source path FTS table or path-specific retrieval, matching the canonical report that exact filename queries can miss the intended note. (extensions/memory-core/src/memory/manager.ts:95, 49ff54e63af5)
  • Focused implementation: The exact PR commit keeps paths in a one-row-per-source FTS table and carries explicit full-path, basename, stem, and partial-match specificity through memory ranking without changing body FTS payloads. (extensions/memory-core/src/memory/manager-search.ts:720, daea62fb2427)
  • Atomic database upgrade: The version-1 source table migration runs inside a savepoint nested in the agent opener's immediate transaction, validates canonical schema shape, preserves row identities, rebuilds path FTS when present, and rolls back on failure. (packages/memory-host-sdk/src/host/memory-schema.ts:218, daea62fb2427)
  • Upgrade ownership and concurrency: Agent ownership checks, supported-version checks, migration, schema application, and version metadata publication share one immediate write transaction. (src/state/openclaw-agent-db.ts:153, daea62fb2427)
  • Prior finding continuity: The release-owned changelog finding appeared in earlier review cycles and the exact current head still adds the same normal-fix entry. (CHANGELOG.md:32, daea62fb2427)
  • Current-head checks: GitHub reports no pending or failing current-head checks, and the focused commit passes whitespace validation; these checks supplement but do not replace real installed behavior proof. (daea62fb2427)

Likely related people:

  • vincentkoc: Commit e8c83ac introduced the current memory schema and agent-database opener that this PR migrates. (role: introduced database foundation; confidence: high; commits: e8c83ac0b4fd; files: packages/memory-host-sdk/src/host/memory-schema.ts, src/state/openclaw-agent-db.ts, src/state/openclaw-agent-schema.sql)
  • steipete: Commit 96f0983 appears in current-main history for the memory manager, and the live PR identifies this branch as the maintained replacement for the older contributor branch. (role: recent adjacent contributor and replacement owner; confidence: medium; commits: 96f0983a85b5; files: extensions/memory-core/src/memory/manager.ts, extensions/memory-core/src/memory/manager-search.ts, extensions/memory-core/src/tools.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 (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-11T13:37:40.198Z sha d8e466c :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry
  • reviewed 2026-07-11T15:29:35.544Z sha df9d2ce4a618a30d29dcbcf2d3e72394920b564e :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry | [P2] Regenerate the SDK baseline after refreshing onto main
  • reviewed 2026-07-11T15:36:35.844Z sha df9d2ce4a618a30d29dcbcf2d3e72394920b564e :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry | [P2] Regenerate the Plugin SDK baseline after resolving main
  • reviewed 2026-07-11T15:57:55.001Z sha 6d14dc3 :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry
  • reviewed 2026-07-11T16:16:38.043Z sha d816e22 :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry
  • reviewed 2026-07-11T16:26:32.683Z sha d816e22 :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry
  • reviewed 2026-07-11T16:56:55.503Z sha b305af2 :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry
  • reviewed 2026-07-11T17:09:17.773Z sha 4fbc35a9c169b896bcb6a3d1b279b8d5b61c515a :: needs real behavior proof before merge. :: [P2] Remove the release-owned changelog entry | [P2] Pin the callable-export budget to the measured surface

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39f09a7eab

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md Outdated
@@ -29,6 +29,7 @@ Docs: https://docs.openclaw.ai
### Fixes

- **Gateway service audit:** treat POSIX shell `-c` wrappers as opaque for the gateway-subcommand check, avoiding false missing-command warnings for shell-wrapped macOS LaunchAgents without parsing inner commands or ports. Fixes #81751. (#81778) Thanks @liaoandi.
- **Memory filename search:** index paths separately from chunk bodies so exact full-path, basename, and stem queries rank the intended memory file first without changing body BM25 scores, snippets, or embeddings. (#96052, #94102) Thanks @Pick-cat.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the normal-fix changelog entry

This is a normal memory fix, but it adds a hand-written CHANGELOG.md entry. The root AGENTS.md says CHANGELOG.md is release-only and that normal PR/direct-fix release-note context belongs in the PR body, squash message, or direct commit because release generation owns this file. Keeping this line can conflict with the generated release changelog, so move the note out of CHANGELOG.md.

Useful? React with 👍 / 👎.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 11, 2026
@steipete steipete closed this Jul 11, 2026
@steipete
steipete force-pushed the codex/pr-96052-memory-path-search branch from a5c3c8d to e681646 Compare July 11, 2026 13:05
@steipete steipete reopened this Jul 11, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 11, 2026
@steipete steipete closed this Jul 11, 2026
@steipete
steipete force-pushed the codex/pr-96052-memory-path-search branch from df9d2ce to 4b33199 Compare July 11, 2026 15:44
@steipete steipete reopened this Jul 11, 2026
@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. 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 Jul 11, 2026
@steipete steipete closed this Jul 11, 2026
@steipete
steipete force-pushed the codex/pr-96052-memory-path-search branch from 6d14dc3 to b769964 Compare July 11, 2026 16:10
@steipete steipete reopened this Jul 11, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. labels Jul 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head daea62fb242784c5f73f53b8d9238ba57dab4a96:

  • GitHub commit verification is valid; the replacement commit preserves Co-authored-by: Pick-cat <[email protected]> and the changelog thanks @Pick-cat.
  • Fresh structured review is clean. The production/docs and test slices were reviewed independently; after current-main reconciliation, targeted database/SDK and Unicode-search reviews also returned no actionable findings. The final mixed-query repair review was clean at 0.86 confidence.
  • Sanitized AWS/Linux run run_297dcc97f02a on lease cbx_a074164d27ca passed 237/237 focused tests across SDK budgets, agent DB schema/migration/concurrency, path ranking, Unicode/fallback behavior, tools, and the 10k-delete/1k-stale-row FTS stress case.
  • Hosted CI run 29161927119 completed on this head with 72 passing checks, 27 intentional skips, and 0 failures. Dependency Guard and Security Sensitive Guard also passed.
  • Sanitized installed-package run run_2eda117a0eb1 built and validated the package tarball, installed OpenClaw 2026.7.2 (daea62f) into an isolated prefix, passed 8/8 JSON/human search assertions, and passed 2/2 rename/reindex assertions. The live package lane caught the missing default-unicode61 partial match before landing; the repaired head now proves exact and partial Unicode, body-only recall, a single-token negative control, and stale-path cleanup.
  • The AWS lease used public networking, no Tailscale, no instance profile, no hydration, a temporary HOME, the trusted current-main bootstrap, and an exact-head SHA guard; it has been released.

Known proof gaps: none for the changed behavior.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 11, 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:

@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts 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

1 participant