Skip to content

improve(memory-wiki): keep the gateway responsive during large wiki searches - #166433

Merged
roboclaw-bot merged 2 commits into
openclaw:mainfrom
etzelm:feat/memory-wiki-worker-vault-scan
Oct 20, 2026
Merged

roboclaw-bot merged 2 commits into
openclaw:mainfrom
etzelm:feat/memory-wiki-worker-vault-scan

Conversation

@etzelm

@etzelm etzelm commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #166304

Design decisions:

  • Single-page reads stay on the calling thread. An exact-path wiki_get, a digest claim-id read and every other one-path read run readWikiPagesTask in the gateway thread, with the same reader the worker runs; only whole-vault scans (wiki_search without digest candidates or underfilling them, wiki_get id lookups and misses, wiki_apply update_metadata) go through the pool. A short read therefore never waits behind a scan, and results stay byte-identical across the two paths (the identity test covers both).
  • Scans run on a two-worker shared-compute pool and yield at checkpoints. maxWorkers: 2 lets a lookup overtake a long search and two searches overlap. A whole-vault scan is one listing task and then one scan task that, every 64 pages, asks the host over the pool's existing request channel whether to go on. The pool aborts the task's yieldSignal when another task is waiting for that task's shared compute permit or its worker; the host then answers "yield", the worker returns what it has read so far (with readPages), the task settles and returns its permit, the waiting task is admitted, and the host resubmits the unread rest. An uncontended scan stays one task and pays no task boundary per segment. This is the cooperative checkpoint the pool already offers to tasks that exchange with the host (packages/worker-runtime/src/worker-task-pool-core.ts, requestCheckpoint and the contender loop in dispatch()); the wiki worker now makes those exchanges. Search keeps a running top maxResults with a stable sort, in the worker across segments and on the host across resubmissions, which reproduces one whole-vault sort exactly; a lookup collects { relativePath, id } keys, the host resolves the lookup over the complete listing with the existing priority and reads the one matched page on the calling thread, where it must still match. The checkpoint size comes from a sweep (Evidence, "Checkpoint size").
  • Deadline ownership is exactly main's: the pool adds no timeout of its own. wiki_search keeps fix(memory-wiki): stop long searches on deadline or turn cancellation #166329's 30 s deadline and turn cancellation (tool.ts keeps main's deadline lines verbatim), and the signal it already threads through searchMemoryWiki is forwarded to every pool task of the scan. Callers that pass no signal on main (the openclaw wiki CLI, the wiki.search and wiki.get RPCs, the memory_search and memory_get supplements, wiki_get id lookups and misses, wiki_apply update_metadata) still run their scan to completion, now in a worker instead of on the gateway thread. The pool requires a watchdog on each checkpoint reply; the reply carries MAX_TIMER_TIMEOUT_MS from openclaw/plugin-sdk/number-runtime, so no scan gains a deadline. Choosing operator budgets for unsignalled callers is a policy change this PR does not make; the deadline-ownership table under Evidence shows the unsignalled CLI search, the unsignalled CLI lookup and the deadlined tool search completing or timing out exactly as on main on a vault whose scan takes about 50 s (captured before fix(memory-wiki): avoid full-vault reads for path lookups #171961, when the CLI lookup there was a basename scan; the id-lookup and miss shape of the same call is measured through the built Gateway at the merge head under Built Gateway).
  • Why checkpoints rather than one pool task per fixed batch: both release the permit within 64 pages, and the previous revision of this branch did the second (832afc5b07d). Measured in this sitting, the fixed batches cost 16% to 19% more process CPU and 5% more wall time on an uncontended 10,000-page search (a task boundary, a pipeline drain and a merge every 64 pages, and two to four times the worker's mark-compacts), and a waiting task still had to queue for the batch in flight. With checkpoints a scan only splits when something is waiting.
  • Why not a non-shared pool: it would escape the isolate-wide compute budget that memory-core's pools honour, and that budget is what lets a waiting memory-core task take the permit at the scan's next checkpoint. Why not more workers: each worker is another V8 isolate (heap peak about 100 MB while scanning the 140 MB vault measured below), the pool has no backpressure beyond its pending limits, and the event loop is already protected by the first worker.
  • Merged with fix(memory-wiki): avoid full-vault reads for path lookups #171961 (the reviewed rewrite of perf(memory-wiki): resolve wiki_get path lookups without reading every page #164781, landed 2026-10-14) on 2026-10-14, head b998e21c797. query-page-lookup.ts stays the lookup owner exactly as merged: getMemoryWikiPage hands resolveQueryableWikiPageForLookup an exact read and the per-candidate path-tier reads, which run on the calling thread through this branch's one-page reader, a listing that runs on the calling thread, and a full read that is this branch's worker lookup scan over that same listing and returns only the page the lookup resolves to, which the owner's final resolve re-checks. A basename or extensionless-path hit therefore reads one page on this branch exactly as on main; only an id lookup or a miss is still a whole-vault read, and that read is what moves off the gateway thread.

What Problem This Solves

A wiki_search or wiki_get lookup over a large memory wiki freezes the gateway for every other client until it finishes.

User Impact

User impact: a whole-vault wiki read no longer saturates the gateway event loop, a short read no longer waits behind one, and on a host with one shared compute permit a long scan hands the permit to a waiting memory-core task within 64 pages. On the capture machine, under the background load recorded in evidence/load-during-capture.txt, a 10,000-page scan that holds the loop at utilization 1 on main for the whole search (100 ms timers firing up to 17 ms late, an fs.access probe taking up to 17.7 ms) leaves the calling thread at 37 ms of CPU and timers within 2.7 ms of schedule, with every result object identical; an exact-path wiki_get issued while that scan runs answers in 3 ms (p50) instead of waiting 7,657 ms (p50) for the scan, as it does when single-page reads share the scan worker; and with the isolate pinned to one shared compute permit, a task for memory-core's retrieval pool issued during an unsignalled 20,000-page scan completes in 83 to 99 ms (p50, max 617 ms), where a pool that runs each scan as one task that never yields holds it for 25,108 to 25,198 ms (p50, max 51,242 ms, 22 of 52 in each of two runs past memory_search's 30 s deadline). Nothing changes in the tool, CLI or RPC surfaces, no caller gains or loses a deadline, and there is no new config.

Compatibility: there is no schema, config, stored-data or on-disk format change (the on-disk compatibility check under Evidence hashes every file of a vault compiled by main after main and this head query it: identical). The only contract changes are in error objects: a vault boundary refusal still arrives as FsSafeError with its original name, code and message (rebuilt on the host from the worker's { select: "refused", code, message }; the test "rebuilds a worker boundary refusal as the same error on the host" proves the rebuild), and other errors from inside a scan arrive as WorkerTaskError with code failed carrying the original message.

Differences an operator can observe:

  • Whole-vault scans run on two worker threads. Scan starters that pass no signal run to completion as on main: the wiki.search RPC (gateway.ts), memory_search's wiki corpus supplement (corpus-supplement.ts) and the openclaw wiki search CLI (cli.ts) call searchMemoryWiki with no signal; every wiki_get id lookup or miss is a whole-vault lookup task (a basename or extensionless-path hit reads one page since fix(memory-wiki): avoid full-vault reads for path lookups #171961) whose callers pass no caller signal (the wiki_get tool forwards only the plugin lifecycle signal, tool.ts:286; the wiki.get RPC at gateway.ts:330, openclaw wiki get at cli.ts:646 and the memory_get supplement at corpus-supplement.ts:29 pass none); a wiki_apply update_metadata runs a whole-vault scan under the vault mutation lock from the tool (lifecycle signal only), the wiki.apply RPC (gateway.ts:315, request signal) and the CLI (cli.ts:683 and :707, none). Each such scan holds one worker and one of the max(1, cores - 1) shared compute permits until another task waits for either, and then hands it over at its next 64-page checkpoint; on main it occupies the gateway thread for the whole scan. On a host with two cores or fewer that is the only shared permit, so a memory-core task issued during a scan waits for the segment in flight: 83 to 99 ms p50 and 617 ms at most during the 20,000-page scans measured below, against 12 ms p50 (max 34 ms) on main, where the scan takes no permit (see Gaps).
  • A third concurrent scan takes a worker at the next checkpoint of a running one instead of waiting for a scan to finish, and concurrent scans then alternate per segment; with fewer permits than running scans they also alternate on the permit. On main concurrent scans interleave on the gateway thread itself (16-wide async page reads and a setImmediate every 16 pages while scoring). See Gaps for what this means for two scans racing one 30 s deadline.
  • Exact-path and claim-id wiki_get reads run on the calling thread as they did on main and are unaffected by the pool's state; they are the common path for an agent that already knows the page.
  • A new failure mode reaches scan callers: when the pool's pending limits or the shared admission limits are exceeded, wiki_search, wiki_get lookups and wiki_apply reject with WorkerTaskError("worker task capacity reached", "overloaded") instead of running the scan on the main thread (see the "Pool capacity" row).
  • wiki_get lookups become cancellable: the tool already spreads the plugin lifecycle signal into getMemoryWikiPage, and this PR forwards it to the pool, so a plugin stop during a lookup rejects the read instead of letting the scan finish.

Why This Change Was Made

A whole-vault read (wiki_search without digest candidates or with body-only matches, a wiki_get id lookup or miss, a basename lookup too until #171961, a wiki_apply metadata update) parses and scores every page on the gateway main thread. In the outage behind #166304 (8,928 pages, one wiki_search call) the event loop sat at utilization 1 for at least 311 s with p99 delay 359.7 to 453.8 ms, sessions.catalog.list took 11.2 s to 46.6 s, three websocket handshakes timed out, and the agent turn stayed blocked for 584 s. Three merged changes narrowed the problem without moving the scan:

What remains is the placement: scanWikiPageSummary, parseWikiMarkdown and toWikiSearchResult still execute on the main thread for every page of a whole-vault read. That is the half #158517 described ("there is no worker offload anywhere in extensions/memory-wiki/src") and the part #166304 asks for. This PR is not a reopen of #158517; it moves the scan to a plugin-owned worker pool on top of the three fixes above and keeps their behaviour (deadline, cancellation, token prefilter).

Two alternatives were built and measured against this design. A single-worker variant that sends every page read through the pool, single-page reads included (a5af25c3924, fork branch variants/166304-single-worker), has head-of-line blocking: an exact wiki_get waits behind whatever scan holds the worker, and a queued wiki_search spends its 30 s deadline before starting (the concurrent-read table under Evidence). A pool-timeout variant that puts a 30 s timeoutMs on every scan task (492827c8100, fork branch variants/166304-pool-timeout) bounds worker occupancy but makes scans that complete on main fail on a large vault: measured for the CLI search and the CLI lookup (the deadline-ownership table; a basename on the trees of that capture, where it was a whole-vault read), and by the same unsignalled call shape for the RPC, supplement and update_metadata scans. The design above takes neither: short reads never enter the pool, scans get two workers, and every caller keeps main's deadline.

AGENTS.md "Small core, capable plugins": "New capability takes the first fitting step of the capability ladder: existing owner, existing plugin contract, narrow generic core/SDK capability, then universal core surface." The owner exists (memory-wiki owns page reads and scoring) and the contract exists (openclaw/plugin-sdk/process-runtime for the host pool and openclaw/plugin-sdk/worker-task-server for the worker, the shape memory-core already runs in manager-cpu-worker-runtime.ts and manager-search.worker.ts), so the first two rungs fit and no core or SDK edit is needed. The placement follows the rule AGENTS.md states for the one CPU-bound workload it names: "Database access runs in worker threads (read-only worker scope, SQLite writer broker), never on the Gateway main thread, which only awaits results and installs published facts." A page scan is not database access, so that line does not govern it; it is the same reasoning applied to the plugin's own CPU-bound read, with the main thread awaiting a result and merging it.

The alternative considered in the issue, yielding between pages, is partly in main already (#166329 yields every 16 pages while scoring). It bounds each stall but leaves the scan's CPU on the main thread for the whole budget and every page's raw and parsed on the main heap until the scan ends; a per-page yield would change neither. The worker does both: the scoring runs on another thread, and only the top maxResults WikiSearchResult objects (or { relativePath, id } keys for lookups) of each scan task cross the thread boundary. Each page is projected as it is read: a search keeps only results with a score above zero and folds each 64-page segment into a running top maxResults, which the host merges across resubmissions; a lookup returns one key per visible page, and the host resolves the lookup over all keys and reads the one matched page again on the calling thread. Reads run 16 at a time within a 64-page segment, so at most 16 raw pages plus one segment's projections and the running top are live in a worker at once (Evidence, "Where the scan runs", for what the sampled heap shows).

Overlapping open work, with merge order:

Open questions from the issue, answered here:

  • Visibility filter serializability: the sandbox filter closed over appConfig and a session key only to derive one lowercase agent id. The host now resolves that id (resolveWikiPageVisibility) and sends { scopedAgentId } or null; the worker applies the same predicate before scoring, so no larger candidate set is needed and nothing non-serializable crosses the boundary.
  • Deadline and cancellation: the signal main threads through searchMemoryWiki (fix(memory-wiki): stop long searches on deadline or turn cancellation #166329: the tool's 30 s deadline, the caller signal and the lifecycle signal joined with AbortSignal.any) is forwarded as WorkerTaskOptions.signal, so a timeout or turn cancellation rejects a queued task with the abort reason or cancels a running one and retires its worker. Inside the worker the reader polls the pool's control.throwIfCancelled() between pages, the same checkpoint shape main's reader uses for the signal, so a cancelled scan also stops early on its own. The pool task carries no timeoutMs: a caller without a signal waits for its scan, as on main (the scheduling test "leaves an unsignalled scan unbounded, as on main, and passes a caller signal through" pins this at the pool seam). wiki_apply and wiki_get forward the plugin lifecycle signal their tools already receive from WikiToolMemoryContext (wiki_apply destructures it, wiki_get spreads the whole context), so a plugin stop cancels those scans too (see User Impact).
  • Error contract: the pool transports only an error message, so the worker returns vault boundary refusals as { select: "refused", code, message } and the host rebuilds new FsSafeError(code, message); name, code and message match the original, cause and details do not cross. Other errors (walk limits from bounded-walk.ts, unexpected read failures) arrive as WorkerTaskError carrying the original message with code failed.
  • Direct hit resolution: unchanged from main since the merge. resolveQueryableWikiPageForLookup (fix(memory-wiki): avoid full-vault reads for path lookups #171961) still resolves the exact page through resolveQueryableWikiPageByLookup([exactPage], lookup); this branch supplies only its reads.

The change in one sentence

Move the scorer out of query.ts into query-scoring.ts, extend main's query-pages.ts reader into a self-contained list and read-and-score task that can stop at 64-page checkpoints, run single-page reads through it on the calling thread, and serve whole-vault scans from one lazily created WorkerTaskPool (maxWorkers: 2, sharedCompute: true, no timeout of its own) as a listing task plus a scan task that yields its permit and worker to a waiting task at the next checkpoint and is resubmitted for the unread rest; the pool is owned by the plugin and closed in its service stop().

Diff shape (git diff --numstat ebc4e6de603..94dd0a0e7f0): 22 files, +2,158 / -864 in total; production files +1,216 / -784, tests +929 / -79, docs, README and the baseline +13 / -1. Mechanical: the scorer moved from query.ts into query-scoring.ts (667 lines, of which 15 differ from the base query.ts text: the header comment, the import lines and export keywords on declarations that were module-private; #166355's token prefilter among the unchanged lines), its removal from query.ts, and the three importers of WIKI_SEARCH_MODES (tool.ts, cli.ts, gateway.ts) pointed at query-scoring.ts so query.ts carries no re-export. Behavioural, production: the visibility scope, task union (list, and search / keys / page over an explicit path list), per-page projection, segmented task runner and checkpoint in query-pages.ts, the pool, checkpoint answer, resubmission and merge in query-reader.ts, the worker entry, the dispatching host paths in query.ts, and the apply.ts, index.ts and package.json lines. At 2c54327b1ad, rebased onto main 072f977edd46, git diff --numstat 072f977edd46..2c54327b1ad gives 22 files, +2,156 / -857: git range-diff shows commits two to five unchanged and the first differing only in package.json, which now carries main's 2026.9.9 version line next to the same workerEntries key, and in query.reads.test.ts (+38 / -68 against the new base), because #169218 deleted on main two tests this branch had rewritten ("searches and reads without extracting unused links" and "reads %s without enumerating unrelated pages"; the link-extraction assertion of the first lives on in query-reader.test.ts as "reads query pages without extracting the link graph"). The pushed head 79fffcac1e7 gives 22 files, +2,197 / -857: its one further commit rewrites the service-stop test in index.test.ts (+50 against the base) and the queued-read test in query-reader.test.ts (+489), and makes that file's fresh-worker recovery test start from a closed reader. The merge of main 12fe41e2219 (2026-10-14, head b998e21c797, tree f569bc30e306): git diff --numstat origin/main..HEAD (evidence/merge-2026-10-14/numstat.txt, whole diff evidence/merge-2026-10-14/main-12fe-to-head.diff) gives 22 files, +2,250 / -853 (query.ts +118 / -730, query-pages.ts +177 / -22, query-reader.ts +215, query-reader.test.ts +498, index.test.ts +50, query.path-lookup.test.ts +28 / -15, query.reads.test.ts +41 / -75, apply.ts +6 / -4, package.json +4 / -1). Relative to 79fffcac1e7 the merge changes under extensions/memory-wiki only what main changed plus the resolution (evidence/merge-2026-10-14/head-79ff-to-head.memory-wiki.diff): query-page-lookup.ts and query-shared-memory.ts are main's files untouched; query.ts feeds the owner its reads and keeps readMemoryWikiPageByLookup for apply.ts, now scoped to an explicit page list when the owner passes one; query-pages.ts drops this branch's copy of resolveQueryableWikiPageByLookup, no longer moves normalizeLookupKey and exports isWikiPageVisible; query-reader.ts imports the owner's resolver; package.json carries main's 2026.10.3 next to workerEntries; index.test.ts keeps only the stop test main did not remove; query.path-lookup.test.ts (#171961's) changes in the two tests that watched the full read through the thread-local fs-safe open hook, and query-reader.test.ts in the test that asserted basename reads dispatch as lookups (Tests below). The per-file table keeps the numbers against the old base.

Per-file diff shape
File +/- Nature
extensions/memory-wiki/src/query-scoring.ts +667 New module: result types, snippet, tokens, claim and page scoring, mode boosts, digest candidate builder, result metadata, toWikiSearchResult, WIKI_SEARCH_MODES, moved from query.ts (including #166355's token prefilter); 15 lines differ from the base text (header comment, imports, added export keywords). Pure functions; no behavioural change
extensions/memory-wiki/src/query-pages.ts +198 / -22 main's reader (#166329) with its signal checkpoints kept. Since the merge of #171961, resolveQueryableWikiPageByLookup and normalizeLookupKey stay where main keeps them (query-page-lookup.ts, query-shared-memory.ts), and isWikiPageVisible is exported for the lookup owner's canReadPage. Behavioural additions: WikiPageVisibility and the visibility predicate, the WikiPageReadTask / WikiPageReadResult union (list with optional excludes; search, keys and page over an explicit path list; search and keys results carry readPages), excludeWikiPagePaths, a project callback on the reader so each page is reduced as it is read, WIKI_SCAN_CHECKPOINT_PAGES (64), WIKI_SCAN_YIELD, and readWikiPagesTask, which both the worker and the calling thread run; a search or key task reads in 64-page segments, keeps a running top maxResults (search) or appends keys, and asks an optional shouldYield between segments. Of main's four exports, readQueryableWikiPages is deleted (the reader's task union replaces it), QUERY_PAGE_READ_CONCURRENCY and listWikiMarkdownFiles become module-private and readQueryableWikiPagesByPaths becomes the module-private projecting reader
extensions/memory-wiki/src/query.ts +81 / -744 Mechanical removal of the moved scorer; behavioural: resolveWikiPageVisibility, searchWikiCorpus dispatching two bounded searches, candidates then the rest of the vault (replaces main's in-thread scorePages loop and its setImmediate yields), readWikiPage running one-path reads in-thread through readWikiPagesTask, readMemoryWikiPageByLookup through the pool; main's throwIfAborted checkpoints and vault-initialization signal kept
extensions/memory-wiki/src/query-reader.ts +215 New host module: WikiPageScanTask (search or lookup over a scope), entrypoint descriptor, lazy two-worker pool, answerScanCheckpoint (yield when the pool has aborted the task's yieldSignal, watchdog MAX_TIMER_TIMEOUT_MS), readMemoryWikiPages (one listing task, then scan tasks resubmitted from readPages until the listing is read; a running top maxResults for search; key collection, host-side resolution and an in-thread read and re-check of the match for lookup; a reply that read nothing is rejected as invalid; the caller's signal on every task, no timeout added, refusal rebuilt as FsSafeError), closeMemoryWikiQueryReader (keeps the closing pool referenced until close settles)
extensions/memory-wiki/src/query-reader.worker.ts +36 New worker entry: serveWorkerTasks around readWikiPagesTask, the checkpoint as channel.request(null) answered by the host, pool cancellation polled between pages, refusal encoding
extensions/memory-wiki/src/tool.ts +2 / -1 WIKI_SEARCH_MODES imported from query-scoring.ts; the deadline lines are main's, unchanged
extensions/memory-wiki/src/cli.ts, gateway.ts +2 / -6, +2 / -1 WIKI_SEARCH_MODES and WikiSearchMode imported from query-scoring.ts
extensions/memory-wiki/src/apply.ts +6 / -4 update_metadata lookup through readMemoryWikiPageByLookup, the lifecycle signal applyMemoryWikiMutation receives forwarded
extensions/memory-wiki/src/query-shared-memory.ts 0 since the merge main's file; normalizeLookupKey stays here (the branch no longer moves it)
extensions/memory-wiki/src/query-page-lookup.ts 0 main's lookup owner (#171961), untouched; query.ts supplies its readExactPage, listFiles, readPages and canReadPage
extensions/memory-wiki/index.ts +2 closeMemoryWikiQueryReader() in service stop()
extensions/memory-wiki/package.json +4 / -1 openclaw.build.workerEntries: ["./src/query-reader.worker.ts"]
extensions/memory-wiki/README.md, docs/plugins/memory-wiki.md +1, +12 Where scans run, the 64-page checkpoint that hands the permit or worker to a waiting task, that the pool adds no deadline, and that single-page reads stay in-thread, next to #166329's deadline paragraph
config/max-lines-baseline.txt -1 Shrink-only ratchet maintenance: query.ts no longer needs its grandfathered oxlint-disable max-lines, and the suppression ratchet rejects a stale baseline entry
extensions/memory-wiki/src/query.reads.test.ts +40 / -75 Regression test that whole-vault pages are never parsed on the calling thread (only a lookup's one matched page is); swap tests rewritten without thread-local fs-safe hooks; #166355's hook-based candidate test moved to the pool seam in query-reader.test.ts, the basename case of the swap test dropped when the basename route was a worker scan (since the merge it is a one-page read again, see Gaps); at the merge head the lookup half of the regression test is an id lookup, the one route that still scans
extensions/memory-wiki/src/query.abort.test.ts +50 / -4 #166329's mid-scan cancellation test kept at the reader seam (the parse spy is thread-local; it lists the vault first, as the pool does) plus a whole-vault search whose dispatched task is cancelled through the pool
extensions/memory-wiki/src/query-reader.test.ts +483 (+489 at the pushed head) Identity across the pool and the calling thread (results and page objects byte-identical; in-thread references list the vault, then read it), underfill dispatch and merge, candidate-only dispatch for distributed tokens, exact paths and basename hits read in-thread and id lookups dispatched as whole-vault scans, no link extraction, sandbox scope in worker, listing-then-swap refusal, refusal rebuilt on host, already-aborted signal (no worker created), read queued behind two running scans (the pool snapshot shows it waiting when it is cancelled), running read cancelled then recovered on a fresh worker, a lookup whose match changed id before the in-thread re-read returns no page, close and recreate
extensions/memory-wiki/src/query-scheduling.test.ts +181 Scheduling, with no timing, polling or completion-order assertion: an exact read completes while the search scan is held at the dispatch seam, and only the search is dispatched; every listing and scan task carries no timeoutMs and receives the caller's signal unchanged; an uncontended 131-page scan is one listing task and one scan task, every checkpoint is answered "continue" with the timer-maximum watchdog, and its results (114 of them, then 10, so segment cuts and ties across segment boundaries are both exercised) are byte-identical to one in-thread whole-vault read, and a lookup resolves a page in the last segment; three scans submitted at once leave the pool (read from getSnapshot() immediately after submission) with maxWorkers: 2, three admitted, one or two running and the rest queued, and settle on at most two workers with identical results
extensions/memory-wiki/src/query-shared-compute.test.ts +97 With os.availableParallelism() mocked to 2 (one shared permit; the capacity is a process-wide singleton, so this file owns the pin), a second shared-compute pool shaped like memory-core retrieval (one worker) submits a task while the scan task holds the permit; the recorded order is listing, scan, retrieval queued, checkpoint yield, retrieval admitted, scan resubmitted, and every later checkpoint is "continue"; results byte-identical to one in-thread read. The retrieval task records admission while preparing its input and stops there, so no second worker starts
extensions/memory-wiki/src/query-scan.test-support.ts +63 The tied-page vault builder, the scan task and the in-thread whole-vault reference shared by the two files above
extensions/memory-wiki/index.test.ts +15 (+50 at the pushed head) Service stop terminates every worker that a whole-vault lookup started on the reader
extensions/memory-wiki/src/query.path-lookup.test.ts +28 / -15 (since the merge) #171961's eight cases run against this branch's reads; the id-lookup-and-miss case and the refused-page case are adapted at the reader seam because the fs-safe open hook they used is thread-local (Tests)

Growth, per AGENTS.md "Prefer smaller, simpler production code; explain necessary growth": the production growth is one pool with its lifecycle, checkpoint answer and resubmission (query-reader.ts, 215 lines), one worker entry (36 lines), one build entry, and the serializable visibility scope, task union and segmented task runner (query-pages.ts, +198 / -22 on top of main's 73-line file against the old base, +177 / -22 at the merge head). The scorer had to leave query.ts because the worker imports it and must not pull the host-only query graph (compiled cache store, shared memory, config, the pool itself) into the worker; it is a separate sibling of main's query-pages.ts because the repository's line-cap ratchet caps a new file at 700 counted lines (query.ts itself carried a grandfathered oxlint-disable max-lines). query.ts shrank from 1,047 to 384 lines against the old base; at the merge head it is 423 lines against main's 1,035, and the merge-head numstat gives production files +1,231 / -765 (query.ts +118 / -730, the moved scorer plus the in-thread search loop the dispatch replaces) and tests +1,006 / -87. Against the old base, production files totalled +1,216 / -784; without query-scoring.ts on the add side that delta was +549 / -784, 744 of the removed lines query.ts's.

Contract table

Input case Expected outcome
wiki_search, compiled digest with candidates, enough scoring hits The candidate paths are read by one scan task (resubmitted for the rest if it yields), scoring each page as it is read and returning its top maxResults; the host's running top maxResults is returned, every result object identical to main's
wiki_search, candidates underfill maxResults A listing task (the whole vault minus the candidate paths) and its scan task follow; host concatenates and merges exactly as before (each read returns at most maxResults, and the merge never consumes more than that from the wiki corpus)
wiki_search, no digest or no candidates One listing task, then one scan task over the listing, resubmitted for the unread rest each time it yields; each page scored as it is read, a running top maxResults kept across segments in the worker and across tasks on the host. The stable sort keeps ties in listing order, so the result equals one whole-vault sort (tested with every page tied on title across segment boundaries, and with a yield in the middle)
wiki_get, digest claim id One-path read on the calling thread with the visibility scope applied; never enters the pool
wiki_get, exact path One-path read on the calling thread; an invisible or missing page falls through to the path tiers and then to the whole-vault lookup task, in #171961's order
wiki_get, basename, extensionless path or id main's resolveQueryableWikiPageForLookup (#171961) runs unchanged: the exact read, then the path-tier candidates from the listing one at a time, each a one-page read on the calling thread with the visibility scope applied; when no path tier hits (an id lookup, or a miss) its full read is this branch's lookup scan over that listing: a key task (resubmitted if it yields) projects each visible page to { relativePath, id } in the worker, the host resolves the lookup over all keys with the owner's priority and reads only the matched page again on the calling thread, re-checked against the lookup, and the owner's final resolve checks it once more (summary, raw, parsed). A page that disappears, or whose id changes, between the two reads yields null
wiki_apply update_metadata The whole-vault lookup scan (listing task, then key task) without a visibility scope, where main reads the whole vault, under the vault mutation lock as before; the page's parsed.frontmatter and parsed.body feed the write, and the plugin lifecycle signal the tool passes is forwarded
Sandboxed caller Host resolves { scopedAgentId }; every scan task and the in-thread read of a lookup's match admit non-bridge pages and bridge pages owned by that id; unresolved id admits only non-bridge pages (fail closed, as before)
Page missing or replaced by a directory Reader returns null for that page (absence falls through to discovery, as before)
Page replaced by a symlink outside the vault In-thread read throws FsSafeError directly; a scan task catches it in the worker, returns { select: "refused", code, message }, and the host throws new FsSafeError(code, message), discarding the partial results

Scheduling:

Input case Expected outcome
Exact-path or claim-id wiki_get while a scan runs Completes on the calling thread without touching the pool (the test holds the search scan at the dispatch seam, so it cannot settle first, and asserts that the read resolves and that the only dispatched task is the search)
Uncontended scan One listing task and one scan task; every checkpoint is answered "continue" (the test asserts the task sequence and that every reply is null with the timer-maximum watchdog)
Another pool waits for the scan's shared compute permit At the scan's next checkpoint the pool has aborted its yieldSignal (the capacity calls every holder's requestCheckpoint when a pool starts waiting and again whenever a checkpoint opens), the host answers "yield", the task returns and releases the permit, the waiting pool is admitted, then the host resubmits the rest. The shared-compute test pins one permit and asserts that order
A third scan waits for a worker The pool aborts the yieldSignal of one host-waiting running task per queued contender, so the queued scan gets a worker at the next checkpoint and the yielding scan is queued behind it; the running scans then alternate per segment
Two scans at once Both run, one per worker when shared compute grants two permits; results identical to a serial run. On a one-permit host the second waits for the permit, and the two alternate at checkpoints
Three scans at once Admission is bounded by maxWorkers: 2: immediately after the third submission the pool reports three admitted tasks (each scan's listing task) with one or two running (two whenever shared compute has two permits free, as on any host with three or more cores) and the rest queued; at most two workers are ever created (the test reads getSnapshot() rather than completion order)
Scan started without a signal (CLI, wiki.search / wiki.get RPC, supplements, id lookups and misses, update_metadata) Runs to completion in a worker, as it ran to completion on the gateway thread on main; no task timeout (the test asserts every listing and scan task carries timeoutMs: undefined; the checkpoint reply's watchdog is the timer maximum; the deadline-ownership table under Evidence drives it through a 48 to 53 s scan)
wiki_search tool deadline (30 s, from #166329) Unchanged, tool.ts deadline lines identical to main: the tool aborts the joined signal with wiki_search timed out after 30s, the pool cancels the task, and tool.deadline.test.ts still asserts that message
Caller aborts the signal before dispatch Rejects with the abort reason; nothing is dispatched (the test starts from a closed pool and asserts that no worker thread is created)
Caller aborts the signal while the task is queued behind running scans The queued task rejects with the abort reason; the running scans complete normally
Caller aborts the signal between a yield and the resubmission The signal travels with every task, so the resubmitted task rejects with the abort reason at submission (the pool behaviour the already-aborted test pins)
Caller aborts the signal while the task is running The task rejects with the abort reason, the pool retires that worker, and the next scan starts a fresh one (the test counts the process's worker events: exactly one new worker is created for the recovery read)
Shared compute (sharedCompute: true) Every listing and scan task takes one isolate-wide shared compute permit at dispatch and returns it when it settles (packages/worker-runtime/src/worker-task-capacity.ts, built by src/infra/worker-task-capacity.ts with max(1, availableParallelism() - 1) permits). A scan that yields is resubmitted only after its task settles, and the capacity admits waiting pools first come, first served and never lets a newly submitting pool overtake a waiting one, so a pool already waiting (memory-core retrieval) is admitted before the resubmitted scan
Checkpoint size 64 pages per segment (WIKI_SCAN_CHECKPOINT_PAGES), bounded in pages, not bytes. A waiting task from another pool waits for the segment in flight, and when a segment takes longer than the gap between that pool's tasks they queue behind each other; the sweep under Evidence shows both (1,024 pages: p50 17,497 to 17,987 ms), and 64 keeps the wait at 85 to 95 ms p50 for 37 to 38 ms of calling-thread CPU per 10,000-page scan
Pool capacity Per-pool defaults maxPendingTasks: 128 and maxPendingBytes: 256 MiB (packages/worker-runtime/src/worker-task-pool-core.ts), plus the isolate-wide shared admission of every sharedCompute pool, memory-core's included (packages/worker-runtime/src/worker-task-capacity.ts:50-57). Exceeding either rejects with WorkerTaskError("worker task capacity reached", "overloaded") (worker-task-pool-core.ts:241-248), deliberately unhandled, the same bound memory-core's search pool carries; it reaches scan callers (see User Impact)
Worker heap No resourceLimits are set (same as memory-core's pools); a worker inherits the process V8 flags. Measured below: worker heap peak 99 to 119 MB on the 10,000-page vault (283.9 MB on the previously published head) and 915.6 MB on the 20,000-page, 558.7 MB vault (1,388 MB on the previously published head), an upper bound that includes uncollected garbage
Plugin service stop() closeMemoryWikiQueryReader awaits the pool's close while keeping it referenced, so a scan issued during the stop rejects with the pool's closed error instead of opening an orphan pool; a scan after the close settles recreates the pool lazily
Idle worker The pool unrefs a worker as soon as it is idle (packages/worker-runtime/src/worker-task-pool-core.ts:735 at the merge head: idle() calls slot.worker.unref() unless a resource closure is pending) and retires it after 60 s idle. The harness holds a ref'd timer through its sampling window because of that unref; neither the unref nor the 60 s retirement was observed directly
Build openclaw.build.workerEntries emits dist/extensions/memory-wiki/src/query-reader.worker.js from both the standalone plugin build and the root bundled build (Build below)

Evidence

Evidence files: https://github.com/etzelm/openclaw/tree/13b39fd0d8cb5cecf54a8e122159f657a87e6ad0 (branch assets/166304-pr-evidence on etzelm/openclaw, commit 13b39fd0d8cb, 181 files; every evidence/ path below links to the raw file at that commit, and its README.md lists each file and how it was produced). The merge of main on 2026-10-14 adds merge-2026-10-14/ at commit 7d5f93c7f805 on the same branch (tree; its README section "Merge of main on 2026-10-14" lists each file); paths below written evidence/merge-2026-10-14/ link there.

All of the following ran on one Mac Studio (darwin arm64, Apple M3 Ultra, 32 cores, Node v24.21.0) in one checkout at af0d2a13c409aa86fa8b9635550df2d7330884c0 (base ebc4e6de603c5c1ce55086f13565e21feb1c297d), in one sitting on 2026-10-07 between 21:49 and 22:56 UTC. Head 94dd0a0e7f0b7f7dda61da0a9494c0ac55914f23 differs from that tree only in comments, the docs paragraph, the README line and the watchdog constant, now imported as MAX_TIMER_TIMEOUT_MS instead of written out as the same value 2_147_000_000 (evidence/af0d2a1-to-head.diff, 3 files, +11 / -10); the owning lane and check:changed were re-run at the pushed head (evidence/head-94dd-lane.log: Tests 514 passed | 1 skipped (515); evidence/head-94dd-check-changed.log: exit 0). 2c54327b1ad6d979a8b4123eb181afca168d8ff5 is 94dd0a0e7f0 rebased onto main 072f977edd46c7134dbdb05ec00fac03f6cf8069 (evidence/rebase-94dd-to-2c54.range-diff: commits two to five unchanged, the first differing only in package.json's version line and in query.reads.test.ts); on 2026-10-11, on the same machine and Node, the owning lane and check:changed ran in a checkout with its tree (37c8c9db3cc3d1e817cb353d36ecf538c6d32600). The pushed head 79fffcac1e7165084014f91df4f408c81b42755e adds one commit to it that changes only index.test.ts and query-reader.test.ts; the lane and check:changed ran again with the pushed head's tree (c611e484e8b3af25e7adbcaf6148b3ec6d0346cf; Tests and Other checks), and the built-Gateway runs (Built Gateway, end to end) use the production files of 2c54327b1ad, which the pushed head does not change. Every comparison tree was produced in the capture checkout by restoring only extensions/memory-wiki, with the tree recorded beside each capture: base (main, scan on the calling thread), the previously published head (19353569c95, labelled prev / before-r4 in file names: this pool with each scan as one task that never yields), the fixed-batch variant (832afc5b07d: a listing task plus one pool task per 64 pages, submitted one at a time), the pool-timeout variant (492827c8100: the never-yielding pool with a 30 s timeoutMs on every scan task) and the single-worker variant (a5af25c3924, labelled first-draft / before-pr: every read, single-page reads included, through one worker). The checkpoint sweep changes only the value of WIKI_SCAN_CHECKPOINT_PAGES in the working tree. Background load is sampled at the start of every phase in evidence/load-during-capture.txt (one-minute load 1.96 to 9.85; a local model server and a Docker VM ran throughout), so wall times are loaded-machine figures and only paired comparisons and outcomes are read. The head b998e21c797 (tree f569bc30e306) merges main 12fe41e2219 into 79fffcac1e7; the capture checkout records that tree as commit 638a701311c in every meta.txt, and the pushed head is the same tree re-committed with a signature; with that tree, on 2026-10-14, the owning lane, check:changed, git diff --check, both builds and the built-Gateway probe were run again (Built Gateway, Tests, Other checks).

Build

Standalone plugin build ([...] marks omitted chunk lines; evidence/build-standalone.log); the entry: line is where openclaw.build.workerEntries is consumed:

ℹ entry: extensions/memory-wiki/index.ts, extensions/memory-wiki/src/query-reader.worker.ts, extensions/memory-wiki/api.ts, extensions/memory-wiki/cli-metadata.ts, extensions/memory-wiki/doctor-contract-api.ts
[...]
ℹ extensions/memory-wiki/dist/src/query-reader.worker.js               0.84 kB │ gzip:  0.48 kB
[...]
ℹ 11 files, total: 345.31 kB
✔ Build complete in 39ms
[plugin-npm-runtime-build] built memory-wiki runtime (5 entries)

Root bundled build (evidence/build.log for the build's own output; the lines below are that step of evidence/evidence2-run.log, quoted whole):

=== BUILD: root bundled build (pnpm build)
2026-10-07T22:28:44Z
--- load: 15:28  up 3 days, 23:25, 1 user, load averages: 3.15 3.76 3.96
pnpm build exit=0
[build-all] phase timings: total 56s; slowest tsdown-unified 15.7s; ui:build 7.94s; check-cli-bootstrap-imports 7.19s; write-unified-entry-dts 6.28s; runtime-postbuild 4.41s; write-cli-startup-metadata (reused) 3.58s; external-plugins:local-dist 3s; tsdown-ai (reused) 1.59s; tsdown-packages (reused) 1.54s; plugins:assets:build 1.34s; plugins:assets:copy 1.22s; check-plugin-sdk-exports 945ms; build-stamp 910ms; runtime-postbuild-stamp 174ms; write-build-info 93ms; native-protocol 49ms
-rw-r--r--  1 openclaw  openclaw  944 Oct  7 15:29 dist/extensions/memory-wiki/src/query-reader.worker.js
--- worker imports
from "../../../fs-safe-RQzDLrgq.mjs"
from "../../../worker-task-server-DSC0g5JY.mjs"
from "../../../query-pages-Cor8G9XG.mjs"

Built Gateway, end to end

Both trees were built with pnpm build in two checkouts on the same Mac Studio and Node on 2026-10-11 (main 072f977edd46, tree fc87743d1071; this branch at 2c54327b1ad, tree 37c8c9db3cc3). For each run, evidence/gateway-e2e/run-tree.sh starts node openclaw.mjs gateway run --port <p> --bind loopback from one build with its own state directory and config: token auth, and memory-wiki on a fresh APFS clone of one generated vault with ingest.autoCompile: false, so no compiled digest exists and every search reads the whole vault (the case in #166304). A separate Node process, evidence/gateway-e2e/gateway-probe.mjs, waits for /healthz, warms the Gateway with one exact read and one search, takes ten idle samples of each probe, then sends one wiki_search (cobalt lantern ledger harbor, maxResults: 10) through POST /tools/invoke and, until it answers, issues GET /healthz every 250 ms and an exact-path wiki_get (entities/page-N.md, a different page each time) through POST /tools/invoke every 500 ms, without waiting for earlier probes. Each run directory (gateway-e2e/) holds meta.txt (tree, Node, UTC start, uptime), probe.json (every probe and the whole search response), the Gateway's own gateway.log (hostname replaced by <host>) and its openclaw.json (token replaced by <redacted>). Other builds and test suites shared the machine throughout (one-minute load 41.9 to 71.5 in the meta.txt files), so the times below are loaded-machine figures and only the paired comparison is read.

4,000-page vault (60 lines and 30 claims per page, 56.2 MB):

Run wiki_search wall /healthz during the search: n, p50 / p99 / max exact-path wiki_get during the search: n, p50 / p99 / max idle wiki_get p50 (10 samples)
main, run 1 17,456.6 ms 68, 22.5 / 116.7 / 116.7 ms 34, 928.6 / 1,400 / 1,400 ms 54.4 ms
this branch, run 1 17,543.6 ms 69, 2.8 / 50.9 / 50.9 ms 35, 78.6 / 188.5 / 188.5 ms 134.6 ms
main, run 2 13,340.2 ms 52, 17.0 / 78.6 / 78.6 ms 26, 803.8 / 941.8 / 941.8 ms 34.0 ms
this branch, run 2 10,608.3 ms 41, 1.1 / 31.7 / 31.7 ms 21, 35.7 / 90.0 / 90.0 ms 32.1 ms

Every probe answered 200, every wiki_get found its page, and the four wiki_search responses are identical, the whole /tools/invoke body compared (evidence/gateway-e2e/results-compare.txt: all identical: True). On main an exact read issued during the search waits for the scan's 16-page slices on the Gateway thread; on this branch it is answered in roughly its idle time. The idle samples are taken before the search and vary between runs on both trees.

Repeated on 2026-10-14 at the merge, main 12fe41e2219 (tree a88837fcd2eb) against this branch at b998e21c797 (tree f569bc30e306), each built with pnpm build in a fresh checkout on the same machine and Node (evidence/merge-2026-10-14/build-main-12fe.log; evidence/merge-2026-10-14/build-head.log is the incremental build of the final tree, reusing the cached phases of evidence/merge-2026-10-14/build-head-full-08250a4.log, the same checkout's full build at an earlier commit of the merge whose tree differs from the final one by two renamed locals and the empty-listing guard), the same two scripts and the same generated 4,000-page vault, four runs started within 72 s of each other (gateway-e2e-2026-10-14/; check:changed ran on the same machine, one-minute load 12.8 to 17.3 in the meta.txt files):

[build-all] phase timings: total 17m 8s; slowest tsdown-packages 13m 49.1s; write-unified-entry-dts 1m 17.9s; tsdown-ai 1m 1.3s; tsdown 17s; ui:build 10.7s; check-cli-bootstrap-imports 7.79s; external-plugins:local-dist 7.44s; runtime-postbuild 4.76s; plugins:assets:build 3.76s; write-cli-startup-metadata 3.51s; plugins:assets:copy 2.33s; check-plugin-sdk-exports 1.18s; build-stamp 640ms; write-build-info 92ms; runtime-postbuild-stamp 68ms; native-protocol 50ms
[build-all] phase timings: total 1m 0.6s; slowest tsdown 17.6s; ui:build 10.2s; check-cli-bootstrap-imports 7.65s; runtime-postbuild 4.63s; write-unified-entry-dts 4.06s; write-cli-startup-metadata (reused) 3.55s; external-plugins:local-dist 3.21s; plugins:assets:build 2.99s; plugins:assets:copy 2.25s; tsdown-packages (reused) 1.81s; tsdown-ai (reused) 1.47s; check-plugin-sdk-exports 1.13s; build-stamp 118ms; write-build-info 92ms; runtime-postbuild-stamp 63ms; native-protocol 54ms
Run wiki_search wall /healthz during the search: n, p50 / p99 / max exact-path wiki_get during the search: n, p50 / p99 / max idle wiki_get p50 (10 samples)
main, run 1 5,465.4 ms 21, 8.9 / 18.6 / 18.6 ms 11, 328.4 / 341.4 / 341.4 ms 13.4 ms
this branch, run 1 5,259.1 ms 20, 0.8 / 1.1 / 1.1 ms 10, 13.8 / 19.0 / 19.0 ms 13.4 ms
main, run 2 5,448.3 ms 21, 9.2 / 20.3 / 20.3 ms 11, 325.2 / 345.4 / 345.4 ms 12.8 ms
this branch, run 2 5,317.7 ms 21, 0.8 / 1.2 / 1.2 ms 11, 14.5 / 16.8 / 16.8 ms 14.5 ms

Every probe answered 200, every wiki_get found its page, and the four wiki_search responses are identical (evidence/merge-2026-10-14/gateway-e2e-2026-10-14/results-compare.txt: 6,821 characters each, all identical: True). The search itself takes a third of the 2026-10-11 time on both trees (the machine carried a fifth of that sitting's load), and the paired difference is the same: an exact read issued during the scan waits 325 to 328 ms p50 on main and 14 to 15 ms on this branch, within 1 ms of its idle time, and /healthz answers in 9 ms p50 on main against 0.8 ms.

The id-lookup and miss shape of wiki_get, the one lookup route that still reads every page after #171961, through the same built Gateways on the same vault: evidence/merge-2026-10-14/gateway-e2e-2026-10-14/gateway-probe-get.mjs and run-tree-get.sh are the two files above with the one timed call changed from wiki_search to wiki_get and the lookup passed as an argument (two changed lines each), the concurrent probes unchanged. Runs base-4k-id and head-4k-id look up concept.page-14 (an id: no path tier matches it, so both trees read the whole vault), base-4k-miss and head-4k-miss look up absent (wiki-get-summary.txt; one-minute load 1.8 to 14.0):

Run wiki_get wall and answer /healthz during the lookup: n, p50 / p99 / max exact-path wiki_get during the lookup: n, p50 / p99 / max idle wiki_get p50
main, id 5,143.1 ms, concepts/page-14.md found 20, 6.8 / 27.4 / 27.4 ms 10, 328.0 / 367.9 / 367.9 ms 13.1 ms
this branch, id 4,955.1 ms, concepts/page-14.md found 19, 0.8 / 1.2 / 1.2 ms 10, 13.6 / 19.0 / 19.0 ms 15.4 ms
main, miss 5,172.4 ms, Wiki page not found: absent 20, 10.0 / 31.8 / 31.8 ms 10, 326.8 / 391.7 / 391.7 ms 15.4 ms
this branch, miss 5,023.9 ms, Wiki page not found: absent 19, 0.8 / 1.1 / 1.1 ms 10, 13.3 / 17.4 / 17.4 ms 15.4 ms

Both trees answer the id lookup and the miss alike (the same page, the same not-found text; every probe 200, every concurrent exact read found its page), the lookup takes about 5 s on both, and during it main holds the Gateway thread (exact reads wait 327 to 328 ms p50, /healthz 7 to 10 ms) where this branch answers them in their idle time. The listing for a lookup runs on the calling thread on this branch as it does on main (a directory walk of the four page groups, readWikiPagesTask({ select: "list" }) in listWikiPages); the parse and scoring of every listed page, the part #166304 is about, runs in the worker.

In the 2026-10-11 sitting (main 072f977edd46 against 2c54327b1ad), the same probe on the 10,000-page vault (140.5 MB) under that load runs past wiki_search's 30 s deadline on both trees, and both Gateways log the same failure, quoted whole from base-10k/gateway.log and head-10k/gateway.log:

2026-10-11T15:57:06.082-07:00 [tools-invoke] tool execution failed: Error: wiki_search timed out after 30s
2026-10-11T15:51:03.096-07:00 [tools-invoke] tool execution failed: Error: wiki_search timed out after 30s

While that search ran, /healthz answered at p50 26.6 ms (max 131.4 ms, 116 probes) on main and 2.7 ms (max 62.8 ms, 119 probes) on this branch, and exact-path wiki_get at p50 1,034.8 ms (max 1,358.7 ms, 58 probes) on main and 93.8 ms (max 265.2 ms, 60 probes) on this branch.

Behaviour, case by case

The harness (evidence/harness.mts) generates deterministic vaults (four page groups, seeded PRNG), initializes them without compiling (no digest, so every search reads the whole vault) and drives the plugin's real entrypoints. search runs searchMemoryWiki while sampling perf_hooks.monitorEventLoopDelay (10 ms resolution), a 100 ms timer-chain probe (timer lateness plus fs.access latency), process.threadCpuUsage() of the calling thread, process.memoryUsage() and Worker.getHeapStatistics() for every worker announced on process.on("worker"), and stores every result object whole; it passes a never-aborted signal, as the wiki_search tool does, so main takes its signal-gated yield path. concurrent starts one whole-vault search and issues 20 exact-path getMemoryWikiPage reads, one every 500 ms without waiting for the previous one. budget runs one caller shape: cli-search, cli-get and cli-apply call searchMemoryWiki, getMemoryWikiPage and applyMemoryWikiMutation (update_metadata) with no signal, the call shapes of openclaw wiki search, wiki get and wiki apply metadata (cli.ts:615, :646 and :707), and tool executes the real wiki_search tool returned by createWikiSearchTool, whose 30 s deadline applies. contention is described with its table.

Shared compute on a one-permit host. contention runs with a --require preload (evidence/single-permit.cjs) that sets os.availableParallelism() to 2 before the capacity exists, so getWorkerComputeCapacity() grants one permit, as on a one- or two-core host; every file records limit: 1 from the capacity's own snapshot. It starts an unsignalled whole-vault searchMemoryWiki (the call shape of the wiki.search RPC and the memory_search supplement) and, once a second while the scan runs, submits a task to memory-core's real retrieval pool (runMemoryPresenceInspection from extensions/memory-core/src/memory/manager-cpu-worker-runtime.ts: the pool memory-core keyword search runs in, maxWorkers: 1, sharedCompute: true), timing each task from submission to result. Idle, that task takes 1 to 2 ms. Same query on the 20,000-page vault of the deadline-ownership table and the 10,000-page vault of the search table; every per-task timing is in evidence/contention/<tree>/<vault>-rep<n>.json (files):

Tree Vault Scan wall Retrieval tasks issued during the scan p50 p99 max Past memory_search's 30 s deadline
main (scan on the calling thread, takes no permit) 20,000 53,754 ms 49 12 ms 34 ms 34 ms 0
previously published head (each scan one task, never yields), run 1 20,000 52,160 ms 52 25,108 ms 51,159 ms 51,159 ms 22
previously published head, run 2 20,000 52,242 ms 52 25,198 ms 51,242 ms 51,242 ms 22
this head, run 1 20,000 55,030 ms 54 99 ms 611 ms 611 ms 0
this head, run 2 20,000 55,232 ms 55 83 ms 617 ms 617 ms 0
main 10,000 13,443 ms 12 1 ms 10 ms 10 ms 0
previously published head, run 1 10,000 13,163 ms 13 6,151 ms 12,161 ms 12,161 ms 0
previously published head, run 2 10,000 13,684 ms 13 6,673 ms 12,683 ms 12,683 ms 0
this head, run 1 10,000 13,629 ms 13 35 ms 81 ms 81 ms 0
this head, run 2 10,000 13,414 ms 13 39 ms 76 ms 76 ms 0

On main the scan takes no permit, so a retrieval task waits only for the gateway thread between page reads. The previously published head holds the only permit for the whole scan, so at most two tasks issued during it finished before the scan did, and on the 20,000-page vault 22 of 52 waited past 30 s. This head hands the permit over at the next 64-page checkpoint, so a task waits for the segment in flight: every task finished while the scan was still running. The ten result objects are identical across the three trees, every field (evidence/contention/results-compare-10k.json, evidence/contention/results-compare-20k.json for the previously published head against this head, evidence/contention/results-compare-base-head-10k.json and evidence/contention/results-compare-base-head-20k.json for main against this head: identicalResults: true, differences: []). The scan wall times include the retrieval tasks, which run while the scan waits for its resubmission.

Checkpoint size. The same 20,000-page contention run and a default-capacity 10,000-page search, two runs per size, with only WIKI_SCAN_CHECKPOINT_PAGES changed in the working tree (evidence/sweep/sweep-run.log; 64 is the head's value):

Pages per checkpoint Retrieval task p50 / max (one permit, 20,000 pages), two runs Past 30 s Scan wall (one permit) 10,000-page search wall (default capacity) Calling-thread CPU in that search Worker heap peak
16 23 / 304 ms, 22 / 363 ms 0, 0 54,702 / 53,850 ms 13,163 / 13,178 ms 56 / 56 ms 100.8 / 105.4 MB
64 95 / 1,100 ms, 85 / 632 ms 0, 0 55,310 / 54,321 ms 13,303 / 13,509 ms 37 / 38 ms 101.4 / 102.6 MB
256 348 / 1,443 ms, 370 / 1,683 ms 0, 0 56,553 / 54,997 ms 13,063 / 13,185 ms 27 / 28 ms 106.7 / 114.6 MB
1,024 17,987 / 35,003 ms, 17,497 / 33,512 ms 8, 6 55,036 / 53,533 ms 12,970 / 13,006 ms 24 / 24 ms 140.9 / 135.2 MB

The wait grows with the segment until a segment takes longer than the one-second gap between retrieval tasks (about 2.8 s for 1,024 pages here); from there each yield admits one queued task and the rest queue behind it. Smaller segments cost calling-thread CPU for the extra checkpoint round trips. 64 keeps the median wait under 100 ms with headroom for a host several times slower than this one; 16 cuts it to about a quarter for about 19 ms more calling-thread CPU per 10,000 pages.

Checkpoints against fixed batch tasks. Default-capacity 10,000-page search with --trace-gc, this head and the fixed-batch variant alternating, three runs each (evidence/post-run.log, "CPU"; per-run JSON and GC traces in cpu/):

Run Process CPU, head / fixed batches Search wall, head / fixed batches Worker heap peak, head / fixed batches Mark-compacts of the busiest isolate, head / fixed batches
1 14,761 / 17,496 ms 13,183 / 13,938 ms 99.0 / 100.1 MB 35 / 83
2 14,791 / 17,111 ms 13,217 / 13,856 ms 101.0 / 103.4 MB 32 / 81
3 14,815 / 17,631 ms 13,294 / 14,013 ms 102.6 / 94.5 MB 33 / 129

Where the scan runs. 10,000 pages (60 lines, 30 claims, 140.5 MB), query cobalt lantern ledger harbor, maxResults: 10; BEFORE = base (main), AFTER = this head, plus the previously published head for the memory rows (evidence/before/search.json, evidence/after/search.json, evidence/before-r4/search.json):

Measure BEFORE (main) AFTER (this head) Previously published head
Search wall time 13,505 ms 13,077 ms 13,280 ms
Event loop utilization during the search 1 0.004 0.002
Calling-thread CPU during the search 13,462 ms 37 ms 21 ms
Event-loop delay p50 / p99 / max 18.3 / 22.5 / 25.0 ms 12.0 / 12.4 / 12.8 ms (the monitor's 10 ms resolution floor) 12.0 / 12.1 / 12.6 ms
100 ms timer lateness p50 / p99 / max 2.0 / 16.1 / 17.0 ms 0.9 / 2.7 / 2.7 ms 1.2 / 2.5 / 2.6 ms
fs.access probe latency p50 / p99 / max 0.4 / 17.0 / 17.7 ms 0 / 0.1 / 0.1 ms 0 / 0 / 0 ms
Calling-thread heap peak (heapUsed) 1,145.2 MB 153.8 MB 149.7 MB
Worker heap peak (used_heap_size, sampled every 100 ms; an upper bound that includes uncollected garbage) no worker thread (0 announced) 118.9 MB (one worker busy, 130 samples) 283.9 MB
Process RSS peak 1,415.0 MB 847.4 MB 1,023.9 MB
Result objects compared, every field 10 of 10 identical (identicalResults: true, differences: [])

On the 20,000-page, 558.7 MB vault (evidence/before-r4-20k/search.json, evidence/after-20k/search.json) this head against the previously published head: search wall 52,817 / 51,737 ms, calling-thread CPU 151 / 91 ms, worker heap peak 915.6 / 1,388.0 MB, process RSS peak 2,755.0 / 3,321.8 MB, timer lateness max 3.2 / 2.8 ms.

What was compared: evidence/results-compare.json holds JSON.stringify equality over the complete results arrays of the BEFORE and AFTER runs, every result object with every field (corpus, path, title, kind, score, snippet, searchMode, metadata, matched-claim fields, evidence lists), in order, plus a per-index diff list that is empty when they are identical. The suite compares the same way on fixtures, for the pool against an in-thread read (six query modes and four lookups on a 16-page fixture, and 114 and 10 results on a 131-page fixture whose pages tie across segment boundaries, uncontended and with a yield).

Reading the rows: with #166329's yield every 16 pages the main thread is never blocked for more than tens of milliseconds at a time, but the loop stays at utilization 1 for the whole search and every other callback waits its turn behind 16 parses. AFTER, the calling thread spends 37 ms of CPU on the whole search (dispatch, checkpoint replies, result transfer, the merge) and the probe's timers stay within a few milliseconds of schedule. On memory: BEFORE retains every page's raw and parsed on the calling thread until the scan ends; the worker reads 16 pages at a time and keeps only projections, so its live set is bounded, but its sampled heap peak (which includes garbage V8 has not yet collected) still rises with vault size: 118.9 MB at 10,000 pages, 915.6 MB at 20,000 larger pages, both below the previously published head's. In this pair the search was 3% faster than main's; the deadline-ownership table shows 2% and 4% faster on the 20,000-page vault.

Concurrent reads during a scan. Same 10,000-page vault and query, 20 exact-path reads of entities/page-N.md issued every 500 ms from 0.5 s after the scan started; BEFORE = the single-worker variant (every read through one worker), AFTER = this head (evidence/before-pr/concurrent.json, evidence/after/concurrent.json, every per-read timing inside):

Measure BEFORE (one worker for every read) AFTER (in-thread reads, two-worker pool)
Scan wall time (whole-vault searchMemoryWiki, 10 results) 13,133 ms 13,384 ms
Reads issued while the scan was running 20 of 20 20 of 20
Exact-path read latency p50 / p99 / max 7,657 / 12,633 / 12,633 ms 3 / 12 / 12 ms
Exact-path read latency min 3,161 ms (the last read, issued 10 s in, still waited for the scan) 3 ms
Every read found its page yes yes

Deadline ownership. 20,000 pages, 120 body lines and 60 claims per page (558.7 MB), query cobalt lantern ledger harbor, lookup page-14321 (a basename, a whole-vault lookup on every tree when this was captured; since #171961 a basename hit reads one page on main and on this branch alike, and the whole-vault lookup keeps this call shape for id lookups and misses). One process per cell; each cell's JSON is evidence/budget/<tree>/<step>.json (base, pool-timeout, head):

Caller shape main (base) pool-timeout variant this head
CLI search, no signal resolved, 10 results, 53,665 ms rejected after 30,013 ms: Error: wiki_search timed out after 30s resolved, 10 results, 52,691 ms
CLI basename wiki get, no signal (a whole-vault read on all three trees of this capture; since #171961 this row's shape is the id lookup or miss) resolved, entities/page-14321.md, 49,880 ms rejected after 30,009 ms: Error: wiki page lookup timed out after 30s resolved, entities/page-14321.md, 47,946 ms
wiki_search tool (30 s deadline) rejected after 30,040 ms: Error: wiki_search timed out after 30s rejected after 30,041 ms: Error: wiki_search timed out after 30s rejected after 30,051 ms: Error: wiki_search timed out after 30s

Every outcome on that head (af0d2a13c40) matches that main's (ebc4e6de603), and the CLI search's 10 result objects are identical to main's, every field (evidence/budget/results-compare.json: identicalResults: true, differences: []). The middle column is why this PR adds no pool timeout: with one, the operator calls that complete on main fail.

On-disk and stored-data compatibility. A 2,000-page vault initialized and compiled by main's code was copied for each run (compat/; evidence/compat/vault-compat-now.sha256 is its tree, 2,019 files). Reads: one copy was searched (no signal) and read by basename (a whole-vault read on both trees of that capture) by main, another by this head; afterwards both trees hash identical to the source tree (evidence/compat/tree-after-base-queries.sha256, evidence/compat/tree-after-head-queries.sha256; the comparison is printed in evidence/evidence2-run.log: "base queries left the tree identical", "head queries left the tree identical"), and the two search result arrays are identical, every field (evidence/compat/results-compare.json). Writes: one copy was given the same update_metadata (status: reviewed, one question, no signal, the wiki apply metadata call shape) by main, another by this head; both resolved with changed: true on concepts/page-1234.md. With every ISO-8601 timestamp normalized only .openclaw-wiki/log.jsonl differs (evidence/compat/tree-after-base-apply.ts-normalized.sha256, evidence/compat/tree-after-head-apply.ts-normalized.sha256, evidence/compat/apply-ts-normalized.diff), and evidence/compat/log-diff/log-jsonl.ts-normalized.diff (another pair of fresh copies) shows that its two compile lines differ only in the compile's random reservation and publication ids and in compiledCacheSourceGeneration, a SHA-256 over page bytes (log.ts:163-168 at the merge head) that differs because the pages' updatedAt differs. git diff --stat between base and head over the modules that define stored formats (compiled-cache.ts, compile.ts, vault.ts, markdown.ts, log.ts, source-sync-state.ts, import-runs-state.ts, vault-page-write.ts, openclaw.plugin.json) is empty (evidence/compat/persisted-modules-diffstat.txt). The files a data-model detector might flag carry no stored data: query-pages.ts, query-scoring.ts, query-reader.ts and query.ts hold in-memory task and result types that live for one query; apply.ts changes only how update_metadata finds its page, and the write above lands the same bytes apart from timestamps and ids; the one package.json change is the build key openclaw.build.workerEntries: ["./src/query-reader.worker.ts"]. Nothing needs a migration.

Other cases are covered by the tests below: candidate-only dispatch for distributed tokens (#166355's case, asserted on the task the host dispatches), underfill (candidate read followed by a whole-vault read excluding the candidates), exact paths and basename hits read in-thread and id lookups dispatched as whole-vault scans, sandbox scope applied in the worker, boundary refusal rebuilt as FsSafeError on the host, listing-then-swap refusal on the reader, mid-scan cancellation on the reader (#166329's test, kept at the reader seam), a whole-vault search whose dispatched task is cancelled through the pool, a read rejected when its signal is already aborted, a read queued behind two running scans rejected while the scans complete, a running read cancelled and the next read served by a fresh worker, a lookup whose match changed before the in-thread re-read, segment shape and identity across segment boundaries, a yield to another shared-compute pool at the next checkpoint, the admission bound, plugin stop() terminating every worker the reader started, and a closed reader recreated by the next read.

Tests

Owning lane at the merge head b998e21c797, pnpm vitest run extensions/memory-wiki/ (evidence/merge-2026-10-14/head-lane.log): Test Files 52 passed (52), Tests 368 passed | 1 skipped (369). query.reads.test.ts's "never parses whole-vault pages on the calling thread (#166304)" now looks up the id source.alpha instead of the basename alpha, because since #171961 a basename hit is a one-page read on main too and the test's lookup half would pass on a tree that scans on the calling thread; an id lookup still resolves only through the whole-vault read, so the assertion that the calling thread parses exactly the matched page keeps its teeth. The count is lower again than below because of the test removals merged on main since 072f977edd46 that touch extensions/memory-wiki (#169570, #169687, #169982, #170368, #170532, #172034, #172040), while #171961 added query.path-lookup.test.ts, whose eight cases now run against this branch's reads: the two basename and extensionless-path cases, the duplicate-basename case and the visibility case count exactly the opens #171961 asserts, because those are the calling thread's path-tier reads; the id-lookup-and-miss case, which counted the full read through the thread-local fs-safe beforeOpen hook, now asserts through the reader seam that each of the id lookup and the miss dispatches exactly one lookup scan over the listing and that the calling thread opens only the resolved page (p7.md, then nothing); and the refused-page case, which swapped an unrelated page for an outside symlink from that hook as it was opened, now swaps it from the reader seam once the lookup has been listed, since the directory walk skips symlinks and the hook cannot reach the worker, and asserts that the basename hit dispatches no scan while the miss rejects with FsSafeError. query-reader.test.ts's "reads exact paths on the calling thread and dispatches basename reads as whole-vault lookups" became "reads exact paths and basename hits on the calling thread and scans the vault for id lookups": exact and basename dispatch nothing, an id lookup dispatches one lookup scan over the listing.

Owning lane with the previously pushed head's tree (evidence/head-79ff-lane.log; the same count at 2c54327b1ad, evidence/head-2c54-lane.log). The count is lower than at 94dd0a0e7f0 on the old base (evidence/head-94dd-lane.log, Tests 514 passed | 1 skipped (515); the same lane at the captured tree is evidence/tests.log) because tests in extensions/memory-wiki were removed on main since the old base (#169218). The skipped test is obsidian.discovery.test.ts > preserves PATHEXT precedence, which the branch does not touch:

 Test Files  50 passed (50)
      Tests  393 passed | 1 skipped (394)
   Start at  16:41:26
   Duration  536.64s (tests 45%, import 29%, transform 16%, setup 10%)

Regression proof (red/green)

query-shared-compute.test.ts (new) and query-scheduling.test.ts hold the scheduling tests. None asserts a wall time, a latency ratio or a completion order between independent tasks, and none polls. The shared-compute test pins one permit by mocking os.availableParallelism() (the file owns the process-wide capacity singleton) and records events at the pool's run seam and at the checkpoint reply: admission and dispatch are synchronous, so when the scan task is submitted it holds the only permit, and a task submitted to a second shared-compute pool at that moment can only be admitted when the scan yields. The second pool's task records its admission while preparing its input and stops there, so no worker is started for it. The uncontended-scan test checks the submitted task sequence, every checkpoint reply and its watchdog, and byte identity with one in-thread read at 114 and at 10 results. The exact-read test holds the search at the dispatch seam until the read has resolved; the admission test reads getSnapshot() synchronously after the third submission.

Red runs the head's changed test files against extensions/memory-wiki restored to the previously published head (evidence/red/red-query-shared-compute.log, evidence/red/red-query-scheduling.log; [...] marks omitted lines of the vitest output). The shared-compute test fails on the event order: with each scan one task that never checkpoints, the retrieval task is admitted only after the scan's single task has settled, and nothing of the scan follows it:

 ×  extension-memory  extensions/memory-wiki/src/query-shared-compute.test.ts > memory wiki scans under shared compute contention > yields a scan at its next checkpoint to a pool waiting for the only permit 422ms
   → expected [ 'wiki search', …(2) ] to deeply equal [ 'wiki list', 'wiki search', …(4) ]
[...]
- Expected
+ Received

  [
-   "wiki list",
    "wiki search",
    "retrieval queued",
-   "checkpoint yield",
    "retrieval admitted",
-   "wiki search",
  ]
[...]
 Test Files  1 failed (1)
      Tests  1 failed (1)
 ✓  extension-memory  extensions/memory-wiki/src/query-scheduling.test.ts > memory wiki query scheduling > serves an exact-path read without the pool while a whole-vault search scan is held 379ms
 ×  extension-memory  extensions/memory-wiki/src/query-scheduling.test.ts > memory wiki query scheduling > leaves an unsignalled scan unbounded, as on main, and passes a caller signal through 55ms
   → expected [ undefined, undefined ] to deeply equal [ undefined, undefined, …(2) ]
 ×  extension-memory  extensions/memory-wiki/src/query-scheduling.test.ts > memory wiki query scheduling > reads an uncontended scan as one task that checkpoints between segments 130ms
   → expected [ 'search', 'search', 'lookup' ] to deeply equal [ 'list', 'search', 'list', …(3) ]
 ✓  extension-memory  extensions/memory-wiki/src/query-scheduling.test.ts > memory wiki query scheduling > admits at most two scans at once and queues the rest 367ms
[...]
 Test Files  1 failed (1)
      Tests  2 failed | 2 passed (4)

The same query-scheduling.test.ts against the single-worker variant (evidence/red/red-first-draft-query-scheduling.log) fails all four tests, among them → expected [ 'search', 'page' ] to deeply equal [ 'search' ] (the exact read dispatched to the pool) and → expected 1 to be 2 (one worker); against the pool-timeout variant (evidence/red/red-pool-timeout-query-scheduling.log) it fails two, among them → expected [ 30000, 30000 ] to deeply equal [ undefined, undefined, …(2) ] (a timeout on every scan task).

At the head (evidence/red/green-query-shared-compute.log, evidence/red/green-query-scheduling.log):

 ✓  extension-memory  extensions/memory-wiki/src/query-shared-compute.test.ts > memory wiki scans under shared compute contention > yields a scan at its next checkpoint to a pool waiting for the only permit 453ms
 Test Files  1 passed (1)
      Tests  1 passed (1)
 ✓  extension-memory  extensions/memory-wiki/src/query-scheduling.test.ts > memory wiki query scheduling > serves an exact-path read without the pool while a whole-vault search scan is held 370ms
 ✓  extension-memory  extensions/memory-wiki/src/query-scheduling.test.ts > memory wiki query scheduling > leaves an unsignalled scan unbounded, as on main, and passes a caller signal through 52ms
 ✓  extension-memory  extensions/memory-wiki/src/query-scheduling.test.ts > memory wiki query scheduling > reads an uncontended scan as one task that checkpoints between segments 194ms
 ✓  extension-memory  extensions/memory-wiki/src/query-scheduling.test.ts > memory wiki query scheduling > admits at most two scans at once and queues the rest 372ms
 Test Files  1 passed (1)
      Tests  4 passed (4)

Mutation check (mutants/, each .diff is the whole change and each .log the vitest output of query-scheduling.test.ts, query-shared-compute.test.ts and query-reader.test.ts, 19 tests): every mutant fails exactly the test that owns its construct.

Mutant Change Result
M1 worker merge puts the new segment before the running top ([...found, ...results], query-pages.ts) `Tests 1 failed
M2 host merge puts the resubmitted task's results before the earlier ones ([...read.results, ...results], query-reader.ts) `Tests 1 failed
M3 host never answers yield (input: null, query-reader.ts) `Tests 1 failed
M4 worker ignores a yield answer (return false, query-reader.worker.ts) `Tests 1 failed
M5 lookup match not re-checked after the in-thread re-read (const current = page, query-reader.ts) `Tests 1 failed

The other changed test files, against the previously published head and at the head (evidence/red/red-query-reader.log, evidence/red/green-query-reader.log, evidence/red/red-query.reads.log, evidence/red/green-query.reads.log, evidence/red/red-query.abort.log, evidence/red/green-query.abort.log): query-reader.test.ts fails three (Tests 3 failed | 11 passed (14)): "reads query pages without extracting the link graph" (TypeError: undefined is not iterable; it reads through the new keys task), "rejects a page swapped outside the vault between listing and reading" (promise resolved "{ select: 'page', page: { …(33) } }" instead of rejecting, the same task shape change) and "returns no page when a lookup's match changes before it is read again" (expected { …(33) } to be null: the previously published head read the match in the worker and never re-checked it); green Tests 14 passed (14). query.reads.test.ts "never parses whole-vault pages on the calling thread (#166304)" pins that the one page parsed on the calling thread is a lookup's match, → expected [] to deeply equal [ 'sources/alpha.md' ] against the tree that read the match in the worker, green Tests 15 passed (15) (that red was run when the test's lookup was the basename alpha; since the merge of #171961 a basename hit is a one-page read on main too, so the test's lookup is now the id source.alpha, which only a whole-vault read resolves, and the test keeps failing on a tree that scans on the calling thread; the red run was not repeated at the merge head); query.abort.test.ts passes on both (Tests 2 passed (2)), since its cancellation behaviour is unchanged.

The two tests rewritten at the pushed head, each run against one production mutation and at the head (evidence/red/). The service-stop test with await closeMemoryWikiQueryReader(); removed from the plugin service stop() (red-index-stop.mutation.diff, red-index-stop.log): the worker the lookup started is still alive when stop() resolves:

 ×  extension-memory  extensions/memory-wiki/index.test.ts > memory-wiki plugin > terminates the query reader worker when the plugin service stops 1421ms
   → expected +0 to be 1 // Object.is equality
[...]
 Test Files  1 failed (1)
      Tests  1 failed | 9 skipped (10)

The queued-read test with the pool at maxWorkers: 3 (red-query-reader-queued.mutation.diff, red-query-reader-queued.log): on this 32-core host shared compute admits a third task, so the read starts instead of waiting:

 ×  extension-memory  extensions/memory-wiki/src/query-reader.test.ts > memory wiki query reader > rejects a read queued behind two running scans and lets the scans finish 119ms
   → expected 3 to be less than or equal to 2
[...]
 Test Files  1 failed (1)
      Tests  1 failed | 13 skipped (14)

At the head (green-index-stop.log, green-query-reader-queued.log):

 ✓  extension-memory  extensions/memory-wiki/index.test.ts > memory-wiki plugin > terminates the query reader worker when the plugin service stops 857ms
 Test Files  1 passed (1)
      Tests  1 passed | 9 skipped (10)
 ✓  extension-memory  extensions/memory-wiki/src/query-reader.test.ts > memory wiki query reader > rejects a read queued behind two running scans and lets the scans finish 492ms
 Test Files  1 passed (1)
      Tests  1 passed | 13 skipped (14)

Other checks

Check Result
pnpm check:changed --base upstream/main exit 0 at the captured tree (evidence/check-changed.log) and at the pushed head (evidence/head-94dd-check-changed.log); every step ok, from conflict markers and the line-cap and max-lines ratchets through format, the dead export scan, type-aware lint extensions, typecheck extensions, typecheck extension tests, plugin boundaries, lint scripts and runtime import cycles. With the pushed head's tree on base 072f977edd46 (evidence/head-79ff-check-changed.log; the same outcome at 2c54327b1ad, evidence/head-2c54-check-changed.log) every step is ok except the dead export scan, whose 119 entries (ui/src, src/agents, src/commands, src/gateway, test/helpers; none under extensions/) are the same list pnpm deadcode:exports prints on main 072f977edd46 (evidence/main-072f-deadcode-exports.log). With that scan skipped (evidence/head-79ff-check-changed-skip-deadcode.log) every step is ok except lint extensions, whose one error is eslint(max-lines): File has too many lines (717). in extensions/crabbox/src/crabbox-worker-provider.ts, a file the branch does not touch. The four steps check:changed schedules after it, run one by one at the same tree (evidence/head-79ff-check-changed-remaining-steps.log), exit 0: Database-first legacy-store guard passed., check:media-download-helpers (no output), runtime-sidecar-loaders: local runtime sidecar loaders look OK., Import cycle check: 0 runtime value cycle(s).
pnpm check:changed --base origin/main at the merge head b998e21c797 evidence/merge-2026-10-14/head-check-changed.log: 33 of 36 steps ok, among them conflict markers, the line-cap growth ratchet, format, typecheck extensions, typecheck extension tests, plugin boundaries, lint scripts, the database-first guard and runtime import cycles. Three steps fail, each already failing on main 12fe41e2219 and none under extensions/memory-wiki: the max-lines suppression ratchet step passes its ratchet (533 grandfathered suppressions) and fails in the environment-variable count budget it also runs (OPENCLAW_* count 455 exceeds budget 454, the same line the script prints on main, evidence/merge-2026-10-14/main-12fe-max-lines-ratchet.log); the dead export scan lists 8 production and 17 full-tree entries, all under src/ and ui/, the same lists pnpm deadcode:exports prints on main (evidence/merge-2026-10-14/main-12fe-deadcode-exports.log); and lint extensions reports four max-lines errors, in extensions/anthropic/cli-runtime.test.ts, extensions/agentsapi/agentsapi-harness.persistence.test.ts, extensions/codex/src/app-server/run-attempt-resources.ts and extensions/codex/src/app-server/session-binding.ts, none of which the branch touches, the same four main prints (evidence/merge-2026-10-14/main-12fe-lint-extensions.log: Found 0 warnings and 4 errors.), while node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/memory-wiki prints Found 0 warnings and 0 errors. (evidence/merge-2026-10-14/head-oxlint-memory-wiki.log). The run used NODE_OPTIONS=--max-old-space-size=16384: with the default heap, check-changed.mjs itself dies with FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory while it enumerates this merge (evidence/merge-2026-10-14/head-check-changed-default-heap-oom.log)
git diff --check origin/main...HEAD at the merge head no output, exit 0 (evidence/merge-2026-10-14/head-diff-check.log)
git diff --check upstream/main...HEAD clean at 94dd0a0e7f0; git diff --check origin/main...HEAD clean with the pushed head's tree on base 072f977edd46 (evidence/head-79ff-diff-check.log)
Docs links docs/plugins/memory-wiki.md gained twelve lines of prose next to the existing deadline paragraph; no links added

Measured test cost

pnpm test <file> --maxWorkers=1, one worker, every file warmed by one untimed run of the same command immediately before the timed run, at the captured tree (evidence/evidence-run.log, "TEST COST", one-minute load 3.9 to 5.9). All files belong to the extension-memory vitest project of the bundled plugin lane:

File Tests vitest Duration wall (real)
src/query-shared-compute.test.ts (new) 1 5.05 s 7.15 s
src/query-scheduling.test.ts (new) 4 7.48 s 9.63 s
src/query-reader.test.ts (new) 14 10.26 s 12.35 s
src/query.reads.test.ts 15 8.82 s 10.95 s
src/query.abort.test.ts 2 6.11 s 8.20 s

The scheduling and shared-compute tests write a 131-page vault (two full 64-page segments and a remainder, the smallest shape with a cut and a cross-segment tie), and the shared-compute test runs alone in its file because the one-permit pin is process-wide; its file costs about 5 s, mostly transform. In the same sitting the previously published head's three-test query-scheduling.test.ts took 7.26 s (9.36 s wall). On AGENTS.md's rule that seconds-long tests must prove a contract no cheaper layer can: query-reader.test.ts, query-scheduling.test.ts and query-shared-compute.test.ts are the files whose time comes from the pool itself. Their identity, dispatch-shape, checkpoint, refusal, cancellation, admission, contention and lifecycle tests need the real pool and real workers (an in-thread reader test cannot observe serialization across the thread boundary, the checkpoint exchange, queued-task cancellation, pool admission, shared compute between pools, worker retirement, or stop()), and several tests intentionally retire and respawn a worker, which under vitest loads the plugin graph through tsx again. In a built checkout the spawn loads dist/ JavaScript instead. With the pushed head's tree, by the same command at one-minute load 12 to 16 (evidence/head-79ff-test-cost.log): index.test.ts, 10 tests, 11.79 s (15.48 s wall), and query-reader.test.ts, 14 tests, 12.86 s (16.29 s wall); the rewritten service-stop test took 0.86 s and the queued-read test 0.49 s in the green runs above. CI seconds are pending the first CI run of this head. At the pushed head query.reads.test.ts holds 8 tests (the lane log lists each; the cost row above was measured when it held 15), after #169218's deletions on main.

Gaps, stated plainly

pnpm changed:lanes --json --base upstream/main for this diff, the lanes block quoted from evidence/changed-lanes.json:

  "lanes": {
    "core": false,
    "coreTests": false,
    "ui": false,
    "extensions": true,
    "extensionTests": true,
    "scripts": false,
    "testRoot": false,
    "apps": false,
    "docs": true,
    "tooling": true,
    "liveDockerTooling": false,
    "bundledChannelConfigMetadata": true,
    "releaseMetadata": false,
    "all": false
  },
  "extensionImpactFromCore": false,
  "docsOnly": false,

Lanes that are true: extensions, extensionTests, docs, tooling (the one-line shrink of config/max-lines-baseline.txt counts as a tooling surface) and bundledChannelConfigMetadata. Everything else (core, coreTests, ui, scripts, testRoot, apps, liveDockerTooling, releaseMetadata, all) is false, and AGENTS.md does not mandate unrelated suites, so only the memory-wiki lane and check:changed (which runs the tooling guards itself) ran.

  • Closes rather than Related: the issue asks for exactly this placement change and nothing else in it stays open once this lands; [Feature]: Run memory-wiki whole-vault page reads and scoring off the gateway main thread (remaining after #152487) #166304 is a feature request, so if maintainers want the product decision recorded on the issue first, the first line becomes Related: #166304.
  • Shared compute on small hosts is bounded, not free. On a host with one shared permit, a memory-core task issued during a wiki scan waits for the segment in flight: 83 to 99 ms p50 and 617 ms at most during the 20,000-page scans above, where main answers it in 12 ms p50 (34 ms at most) because on main the scan takes no permit. Segments are bounded in pages, not bytes, so a vault of very large pages makes each segment, and the wait, longer. A pool that submits tasks faster than one per segment gets one task admitted per yield; the 1,024-page row of the sweep shows that queueing, and 64 pages keeps a segment at about 175 ms on this machine (20,000 pages in about 55 s), so on a host several times slower the same queueing starts at a task or two a second.
  • Concurrent scans alternate instead of finishing in submission order. When a scan waits for a worker or a permit held by another wiki scan, the running scan yields at its next checkpoint and goes back into the queue, so the two alternate per segment, as concurrent scans interleave on the gateway thread on main. With a permit per scan (any host with three or more cores, up to two scans) they run in parallel instead. Where they alternate, two wiki_search calls that each need most of their 30 s alone can both time out, where serving them in order would have finished the first; on main the same two searches interleave on one thread with the same result. Preferring a resumed scan over a new one, or yielding only to tasks from other pools, would need either a scheduling hook in the shared pool or plugin-side admission; neither is in this PR. A related pool-level effect: when one task waits, every permit holder that reaches a checkpoint before the waiter is admitted is asked to yield (requestCheckpoints counts waiters, not pending yields), so with two scans on two permits both can yield for one waiter; results are unaffected, it costs one extra resubmission.
  • Each yield resubmits the unread part of the listing (the paths cross the thread boundary again), so a scan that yields at every checkpoint copies O(n²/64) path strings in total; for a 20,000-page vault that is up to about 3 million path copies spread over the scan, and none at all when nothing is waiting.
  • Unsignalled scan starters: the wiki.search RPC, the memory_search and memory_get supplements, the CLI, every wiki_get id lookup or miss and every wiki_apply update_metadata start a scan with no deadline of their own (User Impact lists each call site), exactly as on main, and this PR keeps it that way. Each such scan holds a worker until it finishes or something else waits for it; it then alternates with the waiting scan at checkpoints instead of blocking it, and on a one-permit host it alternates with every other shared-compute task. On main the same scans hold the gateway thread itself, so every request waits, not only wiki scans. Giving those callers a budget of their own (fix(memory): large Wiki searches time out and keep reading files #145732's territory for the supplement, a follow-up for the RPC and CLI) is a policy change left to maintainers.
  • The contention test models memory-core's retrieval pool with a second pool of the same shape (one worker, sharedCompute: true) because extension tests cannot import another extension; the real memory-core pool is exercised by the contention harness above, which runs runMemoryPresenceInspection (a cheap task in the pool keyword search uses), not a full memory_search tool call. The admission wait is independent of the task kind; the task's own run time is not. No test drives two wiki scans on one permit or a caller abort while a checkpoint reply is outstanding; the pool's own suites cover cancellation during a host exchange.
  • The shared-compute test's event order relies on the waiting pool's task being admitted (its input prepared synchronously inside the capacity's drain()) before the host's await chain resubmits the scan. That is how the pool works today; a change that defers input preparation would reorder the events without changing the guarantee.
  • Admission test on small runners: with one shared permit the admission test sees one running and two queued tasks, so the two-worker bound is asserted through maxWorkers: 2 and workersCreated <= 2 rather than through two concurrent tasks.
  • The lookup owner's readPages callback is overloaded. resolveQueryableWikiPageForLookup (fix(memory-wiki): avoid full-vault reads for path lookups #171961) declares readPages(relativePaths) as "read these pages" and calls it with one candidate at a time for the path tiers and once with the whole listing for the full read. This branch's callback reads one path on the calling thread and, for more than one, runs the worker lookup scan over exactly those paths and returns only the page the lookup resolves to (or nothing). That satisfies the owner because its final step runs the same resolveQueryableWikiPageByLookup over whatever readPages returned, so the result equals the page a read of every listed page would pick, and the count-based split is right for every call the owner makes today (an empty listing returns nothing without a task; a one-file vault reads its page in-thread and resolves it the same way). The invariant is stated in the code comment; an owner change that read the full listing in pieces, or resolved before readPages returned, would need this seam revisited. Making the owner take a readLookup(relativePaths, lookup) step instead is a one-line owner change left to maintainers.
  • Pool ownership: query-reader.ts keeps one module-level pool, created by the first scan and closed by the plugin service's stop(), not tied to a service generation as extensions/AGENTS.md asks for work that outlives its caller. The CLI is why: openclaw wiki search, get and apply run with no service, so the pool must exist without one. Consequences: a scan after stop() recreates a pool no service will close (bounded by the idle unref and 60 s retirement), and if a plugin reload shares the module instance, the old service's stop() can close the pool under the new service's scans (they reject with the pool's closed error; the next scan recreates it). Tying the pool to a service generation with an explicit CLI close is a small follow-up if maintainers want it.
  • Worker spawn cost recurs: the first scan after process start spawns a worker, and the pool retires an idle worker after 60 s, so any scan after a minute of inactivity pays the spawn again. The spawn was not timed in isolation (the harness warms the pool before measuring), the dist/ spawn path was not measured, and the 60 s retirement itself was not observed (no run waited 60 s).
  • wiki_search tool calls longer than its 30 s deadline still fail, as on main (the deadline-ownership table shows it on all three trees); this PR changes where the 30 s is spent, not the budget.
  • Errors other than vault boundary refusals lose their class and code across the pool boundary (message preserved, WorkerTaskError with code failed); FsSafeError loses cause and details. No caller inspected those fields.
  • The worker-side cancellation checkpoint is a poll between pages; a single very large page is parsed to completion before the cancellation is observed, the same granularity main's reader has.
  • Narrowed public-entrypoint race coverage: main's query.reads.test.ts swapped a page for an outside symlink from a thread-local fs-safe beforeOpen hook, which never fires in a worker. The branch keeps the exact-read and compiled-candidate refusals through the public entrypoints by placing the symlink before the read, covers the listing-then-swap race on readWikiPagesTask, and covers the pool's refusal rebuild on a scoped lookup; the basename route through getMemoryWikiPage is no longer exercised with a mid-read swap; since the merge that route is a one-page read on the calling thread again, where fix(memory-wiki): avoid full-vault reads for path lookups #171961's own cases cover it, and the id route through getMemoryWikiPage is the one not exercised with a mid-read swap. fix(memory-wiki): avoid full-vault reads for path lookups #171961's query.path-lookup.test.ts counted the full read through the same hook; since the merge its id-lookup-and-miss case asserts the one worker scan through the reader seam and the calling thread's opens, and its refused-page case swaps the page after the listing from that seam (Tests), so neither observes the worker's own opens.
  • Identity: the suite's pool-versus-in-thread tests use the branch's own reader as the reference, so they prove the thread boundary, the segment merge and the resubmission merge are lossless, not identity with main; identity with main is shown by the 10,000-page, 20,000-page and on-disk compatibility comparisons above (every result object compared) and by the verbatim move of the scorer. No golden fixture captured from main lives in the test suite.
  • Diagnostics label the new workers other (src/infra/worker-diagnostic-script.ts and worker-request-kind.ts keep a core allowlist of script names). Adding query-reader.worker.js there is a core edit left out of this plugin-local PR.
  • Out of scope, follow-up: compile.ts still reads and parses the whole vault on the main thread, with link extraction and its own per-page yieldToEventLoop, after every wiki_apply and in the CLI process before a search. This PR moves query scans only.
  • The built-Gateway runs call the tools through POST /tools/invoke, which runs the real wiki_search and wiki_get tools in the Gateway without a model turn; no agent turn or channel was involved. They used ingest.autoCompile: false to keep the vault without a digest, one query, HTTP /healthz as the concurrent client request, and a machine under heavy unrelated load; the 10,000-page searches hit the 30 s deadline on both trees for that reason.
  • Not verified: Bun runtime behaviour of the worker entry and Windows path handling in the worker (the reader code is main's, unchanged).

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-wiki size: XL labels Oct 7, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Move Memory Wiki scans into cooperative worker threads while keeping single-page reads on the calling thread.

Example: Read entities/page-1.md while a 4,000-page wiki search runs.

  • Before: Concurrent exact reads took 328.4 ms median in the supplied baseline Gateway run.
  • After: Concurrent exact reads took 13.8 ms median, with identical search responses.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong shipped-entry-point evidence and no discrete introduced bug found; overall readiness awaits acceptance of the measured performance tradeoff.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Inspected built-Gateway /tools/invoke output on macOS with Node 24 for whole-vault search, ID lookup, misses, concurrent exact reads, and health requests; results match baseline and concurrent responsiveness improves, with worker production code verified against the captured revision.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: A large Wiki scan delays unrelated Gateway requests and short page reads.
Reason: The responsiveness benefit is demonstrated, but repository performance policy requires owner acceptance when a competing user-facing metric regresses.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR provides useful, distinct work: current main still parses and scores whole-vault searches on the Gateway thread, and the supplied Gateway traces demonstrate improved responsiveness.

Priority: P1
Reviewed head: acdd76b53fd8a4d2c288f6a0e56f2d1d633aef23
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Accept the additional Memory Core retrieval wait caused by 64-page Wiki checkpoints on one- and two-core hosts?
  • Recommendation: Accept the measured tradeoff: Keep 64-page checkpoints, accepting the recorded subsecond retrieval waits in exchange for substantially better Gateway responsiveness.
  • Why: The supplied experiment demonstrates a real competing-pool latency increase, and the performance policy requires owner acceptance of regressions; no recorded owner acceptance was found.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Tests

  • Missing end-to-end proof: The newly rewritten public-entry-point tests have no supplied red-on-base run.
Agent review details

How this fits together

Memory Wiki receives tool, CLI, RPC, and memory-supplement queries, reads Markdown vault pages, and returns ranked results or selected page content.

flowchart TD
  A[Tools CLI RPC and supplements] --> B[Wiki query owner]
  B --> C[Single page reader]
  B --> D[Shared compute worker pool]
  D --> E[Vault reading and scoring]
  E --> F[Ranked results or page keys]
  F --> B
  C --> G[Selected page content]
Loading

Technical review

Best possible solution:

Retain the plugin-local worker design and resolve the measured small-host scheduling tradeoff before merging.

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

Current-main source deterministically performs fallback parsing and scoring on the calling thread, and contributor-supplied baseline Gateway traces demonstrate the resulting interference; no target code was executed during this review.

Is this the best way to solve the issue?

The smallest complete approach uses the existing Wiki reader and lookup owner with the existing SDK worker pool, shares scoring rather than duplicating it, and preserves short reads, visibility, deadlines, and vault formats.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Wiki scoring, digest admission, and visibility keeps the original intent (5716d83: History restores the Wiki stack and subsequently adds digest retrieval, people routing, shared ranking, and sandbox visibility; the patch relocates those established rules.)
  • Deadline and cancellation ownership keeps the original intent (fix(memory-wiki): stop long searches on deadline or turn cancellation #166329: Bound direct wiki_search calls and honor cancellation without changing ranking or other tool budgets.)
  • Path lookup priority and shared owner changes intended behavior with a stated reason (refactor: consolidate non-channel feature and provider owners #173064: Consolidate lookup operations under one owner after the targeted path-read repair; injected reads are restored to support worker execution while retaining its resolution policy.)
  • Metadata update lookup keeps the original intent (d624ec3: Find the existing Wiki page before updating its frontmatter; this patch changes lookup execution placement while retaining the mutation lock and writer.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still needs worker isolation: Current main reads candidate or whole-vault pages and scores them in the calling process; cancellation and periodic scoring yields do not relocate that CPU work. (extensions/memory-wiki/src/query.ts:838, ba61d5d99526)
  • Rebased lookup preserves the existing owner: The lookup owner retains exact-path, path-tier, and ID priority; injected reads keep individual candidates in-thread and move the full-list fallback into the worker scanner. (extensions/memory-wiki/src/query.ts:341, acdd76b53fd8)
  • Shipped Gateway entry-point evidence: Inspected probe.json and results-compare.txt under merge-2026-10-14/gateway-e2e-2026-10-14: real POST /tools/invoke searches and concurrent reads succeeded, all search responses matched, and exact-read median latency fell from 328.4 to 13.8 ms. ID lookup and miss captures show the same responsiveness improvement. (merge-2026-10-14/gateway-e2e-2026-10-14/results-compare.txt, 7d5f93c7f805)
  • Runtime evidence remains applicable: Compared the captured b998e21c797 production files through GitHub with the review checkout: query-reader.ts and query-reader.worker.ts are identical; query-pages.ts differs only in the import location of WIKI_PAGE_GROUPS. (extensions/memory-wiki/src/query-reader.ts, b998e21c7979)
  • Measured competing-pool latency: The recorded one-permit, 20,000-page experiment runs Memory Core's real retrieval pool: its presence probe rises from 12 ms median and 34 ms maximum on baseline to 99 ms median and 611 ms maximum in the first candidate run, with no probe exceeding the search deadline. (contention/head/20k-rep1.json, 13b39fd0d8cb)
  • Feature-history ownership: History identifies Vincent Koc's original wiki/digest work and recent path-lookup repair, Peter Steinberger's shared-owner refactors, and Ayaan Zaidi's cancellation and digest-admission repairs. (extensions/memory-wiki/src/query.ts:831, ba61d5d99526)

Likely related people:

  • Vincent Koc: Raw commit 2c5a49a adds extensions/memory-wiki/src/query-page-lookup.ts:22 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2c5a49a35ff7; files: extensions/memory-wiki/src/query-page-lookup.ts)

PR surface

Source +469, Tests +169, Docs +13, Config +3, Other -1. Total +653 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 11 1234 765 +469
Tests 5 288 119 +169
Docs 2 13 0 +13
Config 1 4 1 +3
Generated 0 0 0 0
Other 1 0 1 -1
Total 20 1539 886 +653

Review metrics

Metric Value Why it matters
Production versus test changes Production +1,238/-766; tests +288/-119 The 667-line scorer is relocated existing code; remaining production growth supplies worker dispatch, bounded projections, cooperative scheduling, and lifecycle cleanup.

Root-cause cluster

Relationship: same_root_cause
Canonical: #166304
Summary: This PR implements the worker-isolation repair requested by the linked open issue; the merged cancellation and candidate-admission repairs address adjacent work.

Members:

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

Labels

Label changes:

  • add merge-risk: 🚨 availability: Wiki scans newly share Memory Core's compute budget, producing a measured retrieval-latency tradeoff on small hosts that awaits owner acceptance.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status no longer selects a status label.

Label justifications:

  • P1: Large-vault scans affect other Gateway clients and agent workflows, with observed outages and current-source confirmation.
  • merge-risk: 🚨 availability: Wiki scans newly share Memory Core's compute budget, producing a measured retrieval-latency tradeoff on small hosts that awaits owner acceptance.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • 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 (8 earlier review cycles)
  • reviewed 2026-10-07T03:48:29.766Z sha a5af25c :: blocked before merge. :: none
  • reviewed 2026-10-07T04:52:29.536Z sha 492827c :: blocked before merge. :: [P2] Assert worker admission rather than parallel completion order | [P2] Remove wall-clock assumptions from the short-read regression
  • reviewed 2026-10-07T17:58:54.382Z sha 19353569c95d0e77c33b30bcf7b4c6bb097087cf :: blocked before merge. :: [P2] Release shared compute between bounded Wiki scan batches
  • reviewed 2026-10-07T23:24:01.567Z sha 94dd0a0e7f0b7f7dda61da0a9494c0ac55914f23 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T21:43:32.899Z sha 2c54327b1ad6d979a8b4123eb181afca168d8ff5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-11T21:52:45.350Z sha 2c54327b1ad6d979a8b4123eb181afca168d8ff5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T00:25:51.299Z sha 79fffcac1e7165084014f91df4f408c81b42755e :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T00:35:45.880Z sha 79fffcac1e7165084014f91df4f408c81b42755e :: needs maintainer review before merge. :: none

Reviewed October 19, 2026, 8:38 PM ET / October 20, 2026, 00:38 UTC (Revision 9).

etzelm added a commit to etzelm/openclaw that referenced this pull request Oct 7, 2026
…und scan occupancy

Single-page reads (an exact-path wiki_get, a digest claim read) ran as tasks on
the same single worker as whole-vault scans, so a scan started without a signal
by the memory_search supplement, the CLI, the wiki.search RPC, a wiki_get
basename lookup or a wiki_apply update_metadata held them, and a queued
wiki_search's own 30 s deadline, for as long as it took. Read one-page lookups
on the calling thread with the same reader the worker runs, scan on a pool of
two shared-compute workers, and bound every scan task with the wiki_search
deadline constant so an unsignalled scan rejects with the same deadline error
instead of holding a worker and a compute permit without limit. Move the search
mode list's importers to query-scoring.ts and drop the query.ts re-export.

Follow-up to the review of openclaw#166433.
etzelm added a commit to etzelm/openclaw that referenced this pull request Oct 7, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 7, 2026
etzelm added a commit to etzelm/openclaw that referenced this pull request Oct 7, 2026
@etzelm
etzelm force-pushed the feat/memory-wiki-worker-vault-scan branch from 492827c to 083b81f Compare October 7, 2026 17:18
@etzelm
etzelm marked this pull request as ready for review October 7, 2026 17:19
@etzelm
etzelm force-pushed the feat/memory-wiki-worker-vault-scan branch from 083b81f to 1935356 Compare October 7, 2026 17:32
@etzelm

etzelm commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 7, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
etzelm added a commit to etzelm/openclaw that referenced this pull request Oct 12, 2026
@clawsweeper clawsweeper Bot added 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. and removed 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 Oct 12, 2026
etzelm and others added 2 commits October 20, 2026 00:19
…earches

Run whole-vault page reads and scoring in a plugin-owned worker so large
wiki searches and id lookups no longer block the Gateway event loop.

Rebased onto main as one commit; the original branch commits were:
- improve(memory-wiki): run whole-vault page reads and scoring in a plugin-owned worker
- docs(memory-wiki): note that whole-vault reads run in a plugin-owned worker
- improve(memory-wiki): keep short wiki reads off the scan queue and bound scan occupancy
- improve(memory-wiki): keep scan deadlines with the caller and make scheduling tests deterministic
- improve(memory-wiki): yield wiki scans to waiting shared-compute tasks
- test(memory-wiki): observe worker termination on service stop and queue a read behind two scans

Rebase notes: main's resolveQueryableWikiPageForLookup now takes the
caller's listFiles/readPages so the whole-vault fallback stays on the
reader worker; main's exact-path check replaces the PR's
resolveExactWikiPagePath, and main's claim-confidence check is carried
into query-scoring.ts.

Co-authored-by: jalehman <[email protected]>
Replace the reader-pool tests that spied on WorkerTaskPool.run, read pool
snapshots or relied on synchronous dispatch with tests that drive
searchMemoryWiki, getMemoryWikiPage and the plugin service:

- one concurrent-scan test checks ranking and id lookups against expected
  values built from the fixture, across checkpoint yields and resubmission
- cancellation is proven by an unreadable page the cancelled scan must
  never reach, followed by a successful search
- thread placement uses the thread-local fs-safe open hook; digest
  candidate admission and path-tier lookups use an unreadable page instead
  of spying on the scan dispatcher
- service stop is checked through a public id lookup, including a fresh
  reader for the next read

Drops tests already covered by query.test.ts (result identity, sandbox
scope) and query.reads.test.ts (worker refusal rebuild), and the internal
lookup re-read race test.

Co-authored-by: jalehman <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the feat/memory-wiki-worker-vault-scan branch from 7f0a887 to acdd76b Compare October 20, 2026 00:29
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

Rebased onto current main (d1e59da) and replaced the reader-pool internals tests with tests that go through searchMemoryWiki, getMemoryWikiPage and the plugin service. Rebase note: resolveQueryableWikiPageForLookup on main now reads pages itself, so it takes the caller's listFiles/readPages again to keep the whole-vault lookup on the reader worker.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed 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 Oct 20, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Maintainer decision (recorded at @jalehman's request): the measured Memory Core retrieval latency increase is accepted.

On a one-permit host with a 20,000-page wiki scan in flight, the Memory Core retrieval presence probe moves from 12 ms median / 34 ms max to 99 ms median / 611 ms max, never exceeding the search deadline. In exchange, concurrent Gateway exact reads drop from 328.4 ms to 13.8 ms median. Keeping the 64-page checkpoints as-is; the waits stay subsecond under an extreme concurrent scan, and the Gateway responsiveness gain is worth it.

@roboclaw-bot
roboclaw-bot merged commit 6a6ba1d into openclaw:main Oct 20, 2026
123 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

@etzelm
etzelm deleted the feat/memory-wiki-worker-vault-scan branch October 20, 2026 18:43
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…earches (openclaw#166433)

* improve(memory-wiki): keep the gateway responsive during large wiki searches

Run whole-vault page reads and scoring in a plugin-owned worker so large
wiki searches and id lookups no longer block the Gateway event loop.

Rebased onto main as one commit; the original branch commits were:
- improve(memory-wiki): run whole-vault page reads and scoring in a plugin-owned worker
- docs(memory-wiki): note that whole-vault reads run in a plugin-owned worker
- improve(memory-wiki): keep short wiki reads off the scan queue and bound scan occupancy
- improve(memory-wiki): keep scan deadlines with the caller and make scheduling tests deterministic
- improve(memory-wiki): yield wiki scans to waiting shared-compute tasks
- test(memory-wiki): observe worker termination on service stop and queue a read behind two scans

Rebase notes: main's resolveQueryableWikiPageForLookup now takes the
caller's listFiles/readPages so the whole-vault fallback stays on the
reader worker; main's exact-path check replaces the PR's
resolveExactWikiPagePath, and main's claim-confidence check is carried
into query-scoring.ts.

Co-authored-by: jalehman <[email protected]>

* test(memory-wiki): prove worker scans through public query entry points

Replace the reader-pool tests that spied on WorkerTaskPool.run, read pool
snapshots or relied on synchronous dispatch with tests that drive
searchMemoryWiki, getMemoryWikiPage and the plugin service:

- one concurrent-scan test checks ranking and id lookups against expected
  values built from the fixture, across checkpoint yields and resubmission
- cancellation is proven by an unreadable page the cancelled scan must
  never reach, followed by a successful search
- thread placement uses the thread-local fs-safe open hook; digest
  candidate admission and path-tier lookups use an unreadable page instead
  of spying on the scan dispatcher
- service stop is checked through a public id lookup, including a fresh
  reader for the next read

Drops tests already covered by query.test.ts (result identity, sandbox
scope) and query.reads.test.ts (worker refusal rebuild), and the internal
lookup re-read race test.

Co-authored-by: jalehman <[email protected]>

---------

Co-authored-by: jalehman <[email protected]>
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-wiki merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL

Projects

None yet

3 participants