Repository navigation
fix(memory-wiki): avoid full vault reads for multi-term metadata searches - #166355
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 8:18 PM ET / October 7, 2026, 00:18 UTC. ClawSweeper reviewWhat this changesMemory Wiki’s search now admits compiled metadata containing all query tokens, avoiding unnecessary page reads when those candidates fill the requested results, with a regression covering that behavior. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still has the reported admission mismatch. The focused repair and supplied production-path evidence support it, and no actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherMemory Wiki searches OpenClaw’s Markdown knowledge vault using compiled metadata to select pages before reading and scoring them. Its results feed agent tools, CLI searches, and Gateway clients. flowchart TD
A[Wiki search query] --> C[Metadata candidate selection]
B[Compiled vault metadata] --> C
C --> D[Read candidate pages]
D --> E[Visibility checks and scoring]
E --> F{Enough results}
F -->|Yes| H[Ranked search results]
F -->|No| G[Read remaining vault pages]
G --> E
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +41. Total +41 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Use the existing token matcher for digest admission while retaining live scoring, visibility checks, and the documented body-search fallback. Do we have a high-confidence way to reproduce the issue? Yes: current-main source rejects distributed metadata tokens before selecting pages, forcing a full scan when no phrase candidate exists. Contributor baseline/candidate Gateway measurements corroborate this path; the reviewer did not execute it. Is this the best way to solve the issue? Yes: reusing the existing phrase-or-all-token matcher is a narrow repair of candidate admission, and the regression observes unrelated reads rather than merely testing the predicate. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against de3d26ee61a0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…ches (openclaw#166355) Admit digest candidates whose metadata contains every query token, matching the live page scorer, so multi-term wiki_search queries no longer fall back to reading the whole vault. Analysis by @etzelm. Fixes openclaw#166302. Co-authored-by: Ayaan Zaidi <[email protected]>
Fixes #166302
What Problem This Solves
Multi-term
wiki_searchqueries read the whole vault even when every query token appears in a page's compiled metadata, because the digest prefilter requires a contiguous phrase.User Impact
Queries can use the existing digest candidate path when all their tokens match compiled metadata. Scoring, result formatting, fallback behavior, and stored data formats are unchanged; no migration or recompile is required for this fix.
Why This Change Was Made
Reuse the existing query tokens and
lineMatchesQueryhelper for digest admission rather than introducing a separate tokenizer or matching policy. Update the stale scoring comment and add a regression that checks result equality with a live scan while ensuring unrelated pages are not opened.Thanks to @etzelm for the report and analysis.
Evidence
Built baseline (
24b93dea01ea65f3f9e8944c998656ad6baccef6) and candidate Gateways in an isolated Linux/Node 24 container. Invoked the realwiki_searchtool throughPOST /tools/invokeagainst a generated 3,000-page compiled vault, requesting the top result. Counted actual Markdown file opens:cobalt quartz amber lantern(tokens spread across title, ID, aliases, questions; never a phrase)route-questionAll five result objects, including scores and snippets, were identical before and after. The distributed-token result retained score 32.
query.reads.test.tsandquery.test.ts: 81 tests passed, 29.81 seconds wall time for the focused wrapper invocation (CI time pending).pnpm tsgo:extensionstypecheck completed without diagnostics; built candidate withpnpm build.gpt-5-minicall with low reasoning and a 4,096-token output budget selectedwiki_search; executing its arguments through the built candidate Gateway returned the expected page.The existing candidate limit and full-scan fallback remain unchanged. A query still scans remaining pages when digest candidates do not fill the requested result count.