Skip to content

fix(memory): preserve wiki results in combined search under load - #135290

Draft
Agent-Aurelius wants to merge 1 commit into
openclaw:mainfrom
BenchAGI:fix/memory-wiki-supplement-deadline-104719
Draft

Agent-Aurelius wants to merge 1 commit into
openclaw:mainfrom
BenchAGI:fix/memory-wiki-supplement-deadline-104719

Conversation

@Agent-Aurelius

Copy link
Copy Markdown

Closes #104719

What Problem This Solves

Fixes an issue where memory_search with corpus: "all" could return memory hits plus a false Wiki-unavailable warning on large compiled vaults, even though the same Wiki query completed successfully on its own. The timed-out Wiki scan also kept reading files after the tool had already returned.

Why This Change Was Made

The existing 15-second tool deadline remains unchanged. The repair forwards its cancellation signal through the public corpus-supplement contract, Memory Wiki activation and source validation, digest/fallback lookup, directory walks, and page reads. Exhaustive body recall is still preserved while the call is on-budget; a raw-text candidate filter avoids expensive YAML/Markdown parsing for pages that cannot match.

User Impact

Combined memory + Wiki recall can return healthy Wiki hits from large vaults without a false timeout caused by parse overhead. Genuine stalls still fail closed with the existing per-corpus warning, and cancellation now stops later Wiki I/O instead of leaving orphan work behind.

Evidence

  • Read-only real-vault proof on 5,784 Markdown pages / 62,999,844 bytes, forcing the exhaustive fallback path with the issue query. Baseline: 11,712 / 10,094 / 11,690 ms. Candidate on the current rebased head: 5,763 / 2,818 / 3,181 ms. All six runs returned 10 results with the same ordered-path digest (429438066d6f0b9a).
  • node scripts/run-vitest.mjs extensions/memory-core/src/tools.citations.test.ts extensions/memory-core/src/memory-get-corpus.test.ts extensions/memory-wiki/src/corpus-supplement.test.ts extensions/memory-wiki/src/query.test.ts extensions/memory-wiki/src/compiled-cache.integration.test.ts — 122 passed.
  • pnpm build — passed, including all 147 public Plugin SDK subpaths.
  • pnpm test:contracts:plugins — passed on the current head (46 files / 1,111 tests); the broader channel + plugin contract suite also passed before the mechanical current-main rebase.
  • node scripts/check-changed.mjs -- <changed paths> — passed all selected core, plugin, docs, typecheck, lint, boundary, dead-export, and guard lanes.
  • Plugin SDK surface check and source/plugin import-boundary check — passed.
  • Fresh autoreview --mode branch --base origin/main — scoped clean.

The operator Gateway remains on the pre-fix runtime; loading this unmerged candidate there would require replacing and restarting that production Gateway. Candidate runtime proof therefore used the same real vault through a read-only source driver, alongside the bounded owner tests above.

Preserve exhaustive on-budget recall while forwarding cancellation through
memory corpus supplements, vault validation, enumeration, and page reads.
Prefilter raw nonmatches before expensive page parsing so large combined
searches finish inside the existing budget.

Closes openclaw#104719
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core extensions: memory-wiki size: M labels Sep 1, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The branch forwards memory-tool cancellation into Memory Wiki searches and reads, and filters raw Wiki pages before parsing to reduce work during large searches.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The real-vault search evidence is useful, but two P1 correctness findings and current-main integration work keep this pinned patch below merge quality.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured real-vault source-driver run exercises the changed Wiki search path on 5,784 Markdown pages and reports faster after-fix scans with the same ten ordered results; the prior exact-head review also judged this proof sufficient. It does not itself show a full Gateway call or a real post-abort file-open trace. No stored-data format changes are introduced.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Merge readiness

⛔ Blocked before merge - 10 items remain

Keep this PR open. Current main and the latest release still have the uncancelled Wiki fallback, but this unchanged PR head has two blocking result and plugin compatibility defects. The proof-positive successor at #145732 still needs integration with current main, so it is not yet a safe superseding landing path.

Priority: P1
Reviewed head: 96deb4ca35f2e87c274c508ed37cf9af912f5f2e

Before merge

  • Keep cancellation out of the established supplement input (P1) - The new call passes signal in the first argument to every supplement, including strict third-party implementations that accepted the prior shape. Such plugins can now reject both search and get. Pass an optional second execution-context argument and cover a strict validator; this remains unresolved from the prior review.
  • Preserve matches produced by YAML decoding (P1) - The pre-parse filter rejects pages whose raw bytes lack query tokens, although scoring searches decoded frontmatter. For example, a YAML-escaped title that decodes to alpha is a valid alpha hit but is skipped. This is a late finding on code unchanged since the earlier reviewed head; cover decoded metadata in the fallback regression.
  • Resolve merge risk - The pinned head adds the cancellation signal to the existing first plugin argument, which can make strictly validating supplements reject previously valid search and get calls.
  • Resolve merge risk - The raw prefilter can silently omit Wiki pages whose searchable metadata is created by YAML decoding.
  • Resolve merge risk - Integrating this branch with current main must preserve the newer vault-boundary reader and parsed-page reuse; a verified test-merge result is unavailable.
  • Resolve merge risk - The bug-fix branch adds about 107 net production lines. Consolidate repeated cancellation checks within the owning flow, or establish why the remaining growth is needed.
  • Complete next step - Resolve the first-argument compatibility and decoded-metadata findings, and preserve current main’s safe Wiki reader in an integrated head before merge.
  • Improve patch quality - Use an optional second supplement context and demonstrate that strict first-argument validators still work.
  • Improve patch quality - Cover YAML-escaped and folded metadata matches in the fallback scan.
  • Improve patch quality - Integrate with current main’s safe Wiki reader and validate the resolved head.

Findings

  • [P1] Keep cancellation out of the established supplement input — extensions/memory-core/src/memory-corpus.ts:219
  • [P1] Preserve matches produced by YAML decoding — extensions/memory-wiki/src/query.ts:398-408
Agent review details

How this fits together

The memory tool sends Wiki requests through a registered corpus supplement into a local Markdown vault. The Wiki results return to the agent under a deadline owned by the memory tool.

flowchart LR
  A[Agent memory search] --> B[Memory tool deadline]
  B --> C[Corpus supplement]
  C --> D[Wiki vault search]
  D --> E[Candidate page parsing]
  E --> F[Wiki results]
  F --> G[Agent response]
Loading

Technical review

Best possible solution:

Integrate one repair with current main’s safe Wiki reader: pass cancellation in a separate optional supplement context, keep candidate filtering conservative for decoded metadata, and absorb repeated checks into the owner where practical.

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

Yes, from source: current main still invokes an uncancelled exhaustive scan after digest underfill. This read-only review did not execute a current-main reproduction.

Is this the best way to solve the issue?

No for this pinned head: cancellation belongs in a separate execution context, and raw filtering must preserve matches from decoded metadata. The successor follows that direction but still needs current-main integration.

Full review comments:

  • [P1] Keep cancellation out of the established supplement input — extensions/memory-core/src/memory-corpus.ts:219
    The new call passes signal in the first argument to every supplement, including strict third-party implementations that accepted the prior shape. Such plugins can now reject both search and get. Pass an optional second execution-context argument and cover a strict validator; this remains unresolved from the prior review.
    Confidence: 0.98
  • [P1] Preserve matches produced by YAML decoding — extensions/memory-wiki/src/query.ts:398-408
    The pre-parse filter rejects pages whose raw bytes lack query tokens, although scoring searches decoded frontmatter. For example, a YAML-escaped title that decodes to alpha is a valid alpha hit but is skipped. This is a late finding on code unchanged since the earlier reviewed head; cover decoded metadata in the fallback regression.
    Confidence: 0.94
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 979a8beefb34.

Merge-risk options

Maintainer options:

  1. Integrate the successor (recommended)
    Resolve the successor PR’s current-main conflicts while preserving the safe reader, strict plugin inputs, and complete Wiki matching, then retire this draft when that path is viable.
  2. Repair this branch
    Move cancellation to an optional second argument, fix decoded-metadata matching, and rebase with focused compatibility and vault-boundary validation.
  3. Pause this draft
    Leave this branch unmerged while the successor’s integration and mergeability remain unresolved.

Security

None.

Evidence

What I checked:

PR surface

Source +107, Tests +150, Docs +3. Total +260 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 8 157 50 +107
Tests 5 151 1 +150
Docs 1 8 5 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 316 56 +260

Review metrics

Metric Value Why it matters
Production and test growth production +107 net lines; tests +150; docs +3 The bug-fix production growth spans cancellation propagation and candidate filtering; repeated checks warrant consolidation during integration.
Plugin call contract 1 established first-argument shape changed for 2 calls Search and get now expose cancellation in the argument that existing plugins may validate strictly.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #104719
Summary: The canonical issue reports this Wiki deadline failure; a newer open PR proposes the same repair but is not yet a safe superseding landing path.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Large Wiki scans can suppress agent recall at the tool deadline, while this patch can also silently omit valid Wiki hits.
  • merge-risk: 🚨 compatibility: The changed first argument can break existing strict third-party corpus supplements.
  • merge-risk: 🚨 security-boundary: Current main’s verified vault reader conflicts with this older branch, so integration must preserve its boundary checks.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-01T16:01:59.526Z sha 96deb4c :: needs changes before merge. :: [P1] Keep cancellation out of the existing supplement parameter object

Reviewed September 25, 2026, 5:07 PM ET / 21:07 UTC (Revision 2).

@smfworks

Copy link
Copy Markdown
Contributor

Rebased this PR onto current main (9e267031cd) and addressed the cancellation-passthrough finding on branch pr-135290-fix:

  • Rebase (60057c0b26): resolved conflicts in 4 files against the new vault.readText boundary, upstream's not-found fallthrough, and readExactWikiPage direct-lookup priority. Deadline semantics are preserved with throwIfAborted checks around page reads (the fs-safe boundary doesn't take a signal), and the page-read deadline test was adapted to spy on fs.open — the actual read-open path.
  • Compat fix (4a7c2bc14b): supplement cancellation now travels through an optional second execution-context argument (MemoryCorpusCallContext) for both search and get. The first argument's validated shape is unchanged, so strict third-party plugin input validation is unaffected.
  • Compatibility coverage added for the single-argument path (old call sites behave exactly as before).

Verification: 128/128 across the five touched test files; tsgo:all, plugin-sdk:surface:check, and plugins:boundary-report:ci all green. Final diff vs main: 14 files, +495/−111. (One note: check-changed's max-lines ratchet lane fails pre-existing on the fork's stale origin/main — unrelated to this change.)

qurdis commented Sep 14, 2026

Copy link
Copy Markdown

Current-main integration check from the independent Linux reproduction reported in #104719:

  • The candidate is currently 7,838 commits behind openclaw/openclaw:main at 7c665e63e2.
  • A clean cherry-pick of 96deb4ca35 onto that head conflicts in:
    • docs/plugins/sdk-overview.md
    • extensions/memory-wiki/src/compiled-cache.integration.test.ts
    • extensions/memory-wiki/src/query.ts
    • extensions/memory-wiki/src/vault.ts
  • The cherry-pick was aborted without running the candidate or changing the production Gateway.
  • The source-level repair still matches our observed failure mode: deadline propagation plus raw prefiltering of the exhaustive fallback.

Our sanitized production baseline and acceptance matrix are in #104719 (comment). A current-main rebase is needed before we can evaluate this candidate for deployment.

qurdis commented Sep 14, 2026

Copy link
Copy Markdown

One current-main conflict needs security-sensitive resolution rather than a mechanical pick:

Current main changed readQueryableWikiPagesByPaths() to read through fsRoot(rootDir, { hardlinks: "allow", maxBytes: Infinity }).readText(relativePath), preserving the verified vault boundary and distinguishing absence from boundary refusals. This PR's older head uses direct fs.readFile(..., { signal }).

Please preserve the current fsRoot boundary when rebasing. If the safe reader cannot accept an AbortSignal yet, cancellation checks before/after each bounded read plus stopping new concurrent tasks are preferable to restoring direct filesystem reads. The raw-text prefilter can still run after the safe read and before YAML/Markdown parsing.

Our acceptance criterion is unchanged visibility and vault-boundary behavior alongside the deadline fix.

@smfworks

Copy link
Copy Markdown
Contributor

Refreshed the branch against current main (77985738b8) — pr-135290-fix, now three commits on top of main:

  1. Rebase (af1ebec9ab): resolved the readQueryableWikiPagesByPaths conflict so upstream's verified vault boundary stays fully intact — page reads still go through fsRoot(rootDir, { hardlinks: "allow", maxBytes: Infinity }).readText(...) with the not-found fallthrough, and the PR's cancellation semantics layer on top: the shouldParseRaw pre-parse filter plus throwIfAborted checks around reads. scanWikiPageSummary is the only page-parsing path; the pre-rebase toWikiPageSummary reference is gone.
  2. Compat fix (ed17b1f434): unchanged from the earlier report — cancellation travels via the optional second execution-context argument ({ signal }); the validated first argument stays untouched.
  3. Test adaptation (9cbb7a3624): upstream fix(memory): explain partial search timeouts and allow 30 seconds #147702 raised the default memory search deadline to 30s (DEFAULT_MEMORY_SEARCH_TIMEOUT_MS, now in memory/search-deadline.ts). The stalled-supplement deadline test hardcoded the old 15s fake-time window and error string, so the deadline never fired inside its advance — the test now advances until the stalled supplement is actually aborted and derives the expected error string from the exported default.

Verification: all five touched suites green — 131/131 (memory-get-corpus, tools.citations, compiled-cache.integration, corpus-supplement, query).

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 26, 2026

This branch has not been deployed

No deployments
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 extensions: memory-wiki merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: memory-wiki supplement exhaustive fallback ignores tool deadline

3 participants