Repository navigation
fix(memory-core): include path in FTS indexed text so filename tokens are searchable - #94114
zhangguiping-xydt wants to merge 10 commits into
Conversation
6764c66 to
7bd5d27
Compare
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep this PR open as a meaningful candidate fix, but not an auto-close or automerge path: it changes persistent memory SQLite FTS state and has an open sibling PR with a competing strategy, so maintainers need to choose the canonical upgrade shape before merge. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this PR as superseded by #94135. So I’m closing this here and keeping the remaining discussion on #94135. Review detailsBest possible solution: Close this PR as superseded by #94135. Do we have a high-confidence way to reproduce the issue? Yes. Current main and v2026.6.8 store memory paths as UNINDEXED FTS metadata while writing only chunk body text into the indexed FTS column, and the linked issue plus PR proof show the filename/date-token query behavior. Is this the best way to solve the issue? Unclear as the final merge choice. The separate path-table design is coherent and has current-head CLI proof, but maintainers still need to choose it over the sibling path-prefixed payload design. Security review: Security review cleared: No concrete security or supply-chain concern was found; the diff changes local memory indexing/schema/tests and adds no dependencies, workflows, downloads, permissions, or secret handling. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against e012f2cd3cc8. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
15cb1f4 to
0fe93c1
Compare
|
ClawSweeper applied the proposed close for this PR.
|
What problem does this PR solve?
openclaw memory searchcan rank filename/date-token queries poorly or miss them when the filename token only lives in the derived path FTS index. The current PR was also stale against the canonicalmemory_index_*table migration, so the original fix needed to be rebased onto the current schema owner instead of keeping the oldchunks_*wiring.Why does this matter now?
The linked issue is a user-visible memory lookup failure: a clean memory index and working content search still did not reliably return the expected memory file for a filename/date-token query such as
2026-06-17-1649. Without this repair, users can have the right memory file indexed but still fail to retrieve it by the filename/date token they know.What is the intended outcome?
Filename/date-token keyword searches should find the matching memory file while body-text BM25 ranking remains based on body text only.
memory_index_chunksremains canonical, and both derived FTS tables are repaired or published from that canonical table.What is intentionally out of scope?
This does not change memory file format, vector search scoring, providers, auth, network behavior, gateway startup behavior, or the public memory API contract.
Summary
6e0e06e3acb7has CLI proof for the filename/date-token lookup, passes the focused memory schema/search regression suite, passes the extension test typecheck, and has a final ClawSweeper commit review result ofnothing_found.memory_index_chunksas the source of truth for bothmemory_index_chunks_ftsandmemory_index_chunks_fts_path. The repair path also needed to rebuild derived FTS rows atomically so an interrupted upgrade cannot drop previously usable lexical rows.memory_index_chunksinside a savepoint with set-based SQL; full shadow reindex publishing copiesmemory_index_chunks_fts_path; keyword search merges body/path rows, keeps the best rank per chunk id, sorts the merged rows, and only then applies the final limit.openclaw memory search "2026-06-17-1649"can findmemory/2026-06-17-1649.mdby filename/date token without prepending path text into the body index or weakening body BM25 relevance.memory_index_chunksremains canonical; FTS tables are derived indexes; schema setup and full reindex publish own derived-index repair; search owns merging body/path keyword candidates before result limiting.memory_index_metaand keyed by the derived FTS table names, so legacy or unmarked indexes rebuild once while clean current indexes avoid repeated correlated scans overUNINDEXEDFTS metadata columns.memory_index_*schema rather than the stale pre-rebase table shape.Linked context
Closes #94102
Related #94114
Real behavior proof (required for external PRs)
Behavior or issue addressed: memory search should find indexed memory files by filename/date tokens through the memory index/search path while preserving body BM25 ranking and keeping schema repair safe for existing local memory indexes.
Real environment tested: isolated local OpenClaw CLI memory indexing/search on current head
6e0e06e3acb7, using a temporary OpenClaw home/workspace andmemorySearch.provider: "none". This exercises the local memory indexing/search/schema code path changed by this PR.Exact steps or command run after this patch:
node ./openclaw.mjs memory index --force node ./openclaw.mjs memory search "2026-06-17-1649" --json --max-results 3 node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test-repro.tsbuildinfo OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs run packages/memory-host-sdk/src/host/memory-schema.test.ts extensions/memory-core/src/memory/manager-search.test.ts extensions/memory-core/src/memory/manager-db.test.ts extensions/memory-core/src/memory/index.test.tsEvidence after fix:
Observed result after fix: the current head returns
memory/2026-06-17-1649.mdfor the CLI filename/date-token query and passes the canonical memory search/schema regressions, including date-token filename lookup, merge-before-limit behavior, unmarked FTS repair frommemory_index_chunks, rollback preservation when unmarked FTS repair fails, clean-index scan skipping after the repair marker is current, legacy source migration, and shadow path FTS publication.This update did not exercise provider auth, external OAuth, gateway session delivery, or network behavior because the changed path is local memory indexing/search/schema repair.
Tests and validation
Which commands did you run?
node ./openclaw.mjs memory index --force node ./openclaw.mjs memory search "2026-06-17-1649" --json --max-results 3 node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test-repro.tsbuildinfo OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs run packages/memory-host-sdk/src/host/memory-schema.test.ts extensions/memory-core/src/memory/manager-search.test.ts extensions/memory-core/src/memory/manager-db.test.ts extensions/memory-core/src/memory/index.test.tsTarget test files:
packages/memory-host-sdk/src/host/memory-schema.test.tsextensions/memory-core/src/memory/manager-search.test.tsextensions/memory-core/src/memory/manager-db.test.tsextensions/memory-core/src/memory/index.test.tsWhat regression coverage was added or updated?
Body/path FTS candidates are merged before the requested result limit is applied, so a filename hit is not dropped when body matches fill the limit.
memory_index_chunks_fts/memory_index_chunks_fts_pathrow-count mismatch or missing repair marker rebuilds derived rows from canonicalmemory_index_chunks.Unmarked FTS repair now preserves previous derived FTS rows if the repair fails before completion.
Clean FTS schema setup skips repeated
WHERE NOT EXISTSvirtual-table drift scans after the repair marker is current.Full shadow memory reindex publication copies
memory_index_chunks_fts_path, so filename/date-token rows survive in-place reindex publish.Legacy memory stores without
sourcecolumns migrate into canonical rows with the defaultmemorysource before rebuilding derived FTS rows.Merged keyword rows use
toSorted, avoiding in-place ordering mutation while preserving rank order.Focused regression command after this patch: the four memory manager/schema test files above were run together against the current head and passed 99 tests.
Scenario locked in: canonical chunk rows remain the source of truth while body and path FTS tables are repaired/published separately, marked after repair, and merged before result limiting.
Why this is the smallest reliable guardrail: these tests exercise the changed search merge/rank behavior, the schema-owner repair path, the repair-marker skip path, the repair rollback path, the legacy migration path, and the full reindex publish path directly without requiring provider embeddings or gateway-only startup proof.
CI attribution
6e0e06e3acb7.check-test-typeswas PR-introduced: the new filename-token test passed an unsupportedstorePathfield tocreateCfg, causingTS2353. Current head removes that invalid test-only field and passes the same extension test typecheck.checks-node-core-toolingfailure was insrc/scripts/test-projects.test.ts, outside this PR's memory-core/memory-host-sdk diff. I did not change tooling code for that failure.checks-node-agentic-agents-core-runtimefailure was insrc/agents/code-mode.test.ts, outside this PR's memory-core/memory-host-sdk diff. I did not change agent runtime code for that failure.6e0e06e3acb7reportednothing_foundwithcheck_conclusion=success.Risk checklist
Did user-visible behavior change?
YesDid config, environment, or migration behavior change?
YesDid security, auth, secrets, network, or tool execution behavior change?
NoWhat is the highest-risk area?
Existing local memory SQLite stores may have derived FTS tables that are missing rows, use older FTS layouts, or were built before
sourceexisted on legacy memory tables.How is that risk mitigated?
The repair treats
memory_index_chunksas source of truth and rebuilds derived FTS rows when row counts differ or the repair marker is missing. The rebuild runs inside a SQLite savepoint and uses set-basedINSERT ... SELECT, so a failed repair rolls back to the previous derived FTS rows instead of leaving lexical search empty. After the marker is current, clean schema setup avoids repeated correlated scans over FTS virtual tables. It does not rewrite memory files, vectors, auth/config, provider state, or canonical chunk rows. Body-text FTS remains separate from path FTS, so filename lookup no longer changes body BM25 document-length normalization.Current review state
Which bot or reviewer comments were addressed?
memory_index_*schema.What is the next action?
Maintainers can compare this canonical-table approach with sibling PR #94135 and evaluate the normal remote checks on the current PR head.