Repository navigation
improve(memory-wiki): keep the gateway responsive during large wiki searches - #166433
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesMove 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.
Review scores
ProductKind: Performance · Worth it: Needs a maintainer decision · Fix scope: Complete 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 Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherMemory 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +469, Tests +169, Docs +13, Config +3, Other -1. Total +653 across 20 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (8 earlier review cycles)
Reviewed October 19, 2026, 8:38 PM ET / October 20, 2026, 00:38 UTC (Revision 9). |
…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.
…caller, deterministic scheduling tests)
492827c to
083b81f
Compare
083b81f to
1935356
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…e7 lane, checks and red/green
…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]>
7f0a887 to
acdd76b
Compare
|
@clawsweeper re-review Rebased onto current |
|
🦞👀 Re-review progress:
|
|
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. |
|
Merged via squash.
|
…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]>
Closes #166304
Design decisions:
wiki_get, a digest claim-id read and every other one-path read runreadWikiPagesTaskin the gateway thread, with the same reader the worker runs; only whole-vault scans (wiki_searchwithout digest candidates or underfilling them,wiki_getid 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).maxWorkers: 2lets 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'syieldSignalwhen 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 (withreadPages), 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,requestCheckpointand the contender loop indispatch()); the wiki worker now makes those exchanges. Search keeps a running topmaxResultswith 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").main's: the pool adds no timeout of its own.wiki_searchkeeps fix(memory-wiki): stop long searches on deadline or turn cancellation #166329's 30 s deadline and turn cancellation (tool.tskeepsmain's deadline lines verbatim), and the signal it already threads throughsearchMemoryWikiis forwarded to every pool task of the scan. Callers that pass no signal onmain(theopenclaw wikiCLI, thewiki.searchandwiki.getRPCs, thememory_searchandmemory_getsupplements,wiki_getid 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 carriesMAX_TIMER_TIMEOUT_MSfromopenclaw/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 onmainon 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).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.b998e21c797.query-page-lookup.tsstays the lookup owner exactly as merged:getMemoryWikiPagehandsresolveQueryableWikiPageForLookupan 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 onmain; 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_searchorwiki_getlookup 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 onmainfor the whole search (100 ms timers firing up to 17 ms late, anfs.accessprobe 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-pathwiki_getissued 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 pastmemory_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
mainaftermainand this head query it: identical). The only contract changes are in error objects: a vault boundary refusal still arrives asFsSafeErrorwith its originalname,codeandmessage(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 asWorkerTaskErrorwith codefailedcarrying the original message.Differences an operator can observe:
main: thewiki.searchRPC (gateway.ts),memory_search's wiki corpus supplement (corpus-supplement.ts) and theopenclaw wiki searchCLI (cli.ts) callsearchMemoryWikiwith no signal; everywiki_getid 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 (thewiki_gettool forwards only the plugin lifecycle signal,tool.ts:286; thewiki.getRPC atgateway.ts:330,openclaw wiki getatcli.ts:646and thememory_getsupplement atcorpus-supplement.ts:29pass none); awiki_apply update_metadataruns a whole-vault scan under the vault mutation lock from the tool (lifecycle signal only), thewiki.applyRPC (gateway.ts:315, request signal) and the CLI (cli.ts:683and:707, none). Each such scan holds one worker and one of themax(1, cores - 1)shared compute permits until another task waits for either, and then hands it over at its next 64-page checkpoint; onmainit 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) onmain, where the scan takes no permit (see Gaps).mainconcurrent scans interleave on the gateway thread itself (16-wide async page reads and asetImmediateevery 16 pages while scoring). See Gaps for what this means for two scans racing one 30 s deadline.wiki_getreads run on the calling thread as they did onmainand are unaffected by the pool's state; they are the common path for an agent that already knows the page.wiki_search,wiki_getlookups andwiki_applyreject withWorkerTaskError("worker task capacity reached", "overloaded")instead of running the scan on the main thread (see the "Pool capacity" row).wiki_getlookups become cancellable: the tool already spreads the plugin lifecycle signal intogetMemoryWikiPage, 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_searchwithout digest candidates or with body-only matches, awiki_getid lookup or miss, a basename lookup too until #171961, awiki_applymetadata update) parses and scores every page on the gateway main thread. In the outage behind #166304 (8,928 pages, onewiki_searchcall) the event loop sat at utilization 1 for at least 311 s with p99 delay 359.7 to 453.8 ms,sessions.catalog.listtook 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:includeLinks: falsefor query reads, removing the link-extraction share of each page parse; [Bug]: memory-wiki search falls back to parsing every vault page on the gateway main thread, saturating the event loop for over a minute #158517 was closed when it merged.maxResultsstill read every page.wiki_searchdrops the harness per-call abort signal and has no deadline owner, so an underfilled search runs unbounded (584 s observed) #166303) giveswiki_searcha 30 s deadline plus turn cancellation, threads the signal through the reader, and yields to the event loop (setImmediate) once every 16 pages during scoring. A stall is now bounded at 30 s and other callbacks get a turn every 16 parses, but the parse and scoring CPU still runs on the gateway main thread for the whole budget,rawandparsedare still retained for every page until the scan ends, and a search that needs longer than 30 s returns a timeout error instead of results.What remains is the placement:
scanWikiPageSummary,parseWikiMarkdownandtoWikiSearchResultstill 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 inextensions/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 branchvariants/166304-single-worker), has head-of-line blocking: an exactwiki_getwaits behind whatever scan holds the worker, and a queuedwiki_searchspends its 30 s deadline before starting (the concurrent-read table under Evidence). A pool-timeout variant that puts a 30 stimeoutMson every scan task (492827c8100, fork branchvariants/166304-pool-timeout) bounds worker occupancy but makes scans that complete onmainfail 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 andupdate_metadatascans. The design above takes neither: short reads never enter the pool, scans get two workers, and every caller keepsmain'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-runtimefor the host pool andopenclaw/plugin-sdk/worker-task-serverfor the worker, the shape memory-core already runs inmanager-cpu-worker-runtime.tsandmanager-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
mainalready (#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'srawandparsedon 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 topmaxResultsWikiSearchResultobjects (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 topmaxResults, 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:
AbortSignalintowalkMemoryWikiDirectoryand the supplement paths and adds a raw-text prefilter toreadQueryableWikiPagesByPaths. Both now run inside the worker, where cancellation arrives ascontrol.throwIfCancelled(), so whichever lands second moves the signal toWorkerTaskOptions.signaland the prefilter intoreadWikiPagesTask. Overlap:query.ts,corpus-supplement.tsand the reader.createWikiPageVisibilityFilter. This PR serializes the filter as{ scopedAgentId } | null; whichever lands second carries the ownership mode and delegation set through the sameWikiPageVisibilityseam inquery-pages.ts.query.tsread paths and thetool.tsimports; resolved on whichever lands second.Open questions from the issue, answered here:
appConfigand a session key only to derive one lowercase agent id. The host now resolves that id (resolveWikiPageVisibility) and sends{ scopedAgentId }ornull; the worker applies the same predicate before scoring, so no larger candidate set is needed and nothing non-serializable crosses the boundary.mainthreads throughsearchMemoryWiki(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 withAbortSignal.any) is forwarded asWorkerTaskOptions.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'scontrol.throwIfCancelled()between pages, the same checkpoint shapemain's reader uses for the signal, so a cancelled scan also stops early on its own. The pool task carries notimeoutMs: a caller without a signal waits for its scan, as onmain(the scheduling test "leaves an unsignalled scan unbounded, as on main, and passes a caller signal through" pins this at the pool seam).wiki_applyandwiki_getforward the plugin lifecycle signal their tools already receive fromWikiToolMemoryContext(wiki_applydestructures it,wiki_getspreads the whole context), so a plugin stop cancels those scans too (see User Impact).{ select: "refused", code, message }and the host rebuildsnew FsSafeError(code, message);name,codeandmessagematch the original,causeanddetailsdo not cross. Other errors (walk limits frombounded-walk.ts, unexpected read failures) arrive asWorkerTaskErrorcarrying the original message with codefailed.mainsince the merge.resolveQueryableWikiPageForLookup(fix(memory-wiki): avoid full-vault reads for path lookups #171961) still resolves the exact page throughresolveQueryableWikiPageByLookup([exactPage], lookup); this branch supplies only its reads.The change in one sentence
Move the scorer out of
query.tsintoquery-scoring.ts, extendmain'squery-pages.tsreader 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 createdWorkerTaskPool(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 servicestop().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 fromquery.tsintoquery-scoring.ts(667 lines, of which 15 differ from the basequery.tstext: the header comment, the import lines andexportkeywords on declarations that were module-private; #166355's token prefilter among the unchanged lines), its removal fromquery.ts, and the three importers ofWIKI_SEARCH_MODES(tool.ts,cli.ts,gateway.ts) pointed atquery-scoring.tssoquery.tscarries no re-export. Behavioural, production: the visibility scope, task union (list, andsearch/keys/pageover an explicit path list), per-page projection, segmented task runner and checkpoint inquery-pages.ts, the pool, checkpoint answer, resubmission and merge inquery-reader.ts, the worker entry, the dispatching host paths inquery.ts, and theapply.ts,index.tsandpackage.jsonlines. At2c54327b1ad, rebased ontomain072f977edd46,git diff --numstat 072f977edd46..2c54327b1adgives 22 files, +2,156 / -857:git range-diffshows commits two to five unchanged and the first differing only inpackage.json, which now carriesmain's2026.9.9version line next to the sameworkerEntrieskey, and inquery.reads.test.ts(+38 / -68 against the new base), because #169218 deleted onmaintwo 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 inquery-reader.test.tsas "reads query pages without extracting the link graph"). The pushed head79fffcac1e7gives 22 files, +2,197 / -857: its one further commit rewrites the service-stop test inindex.test.ts(+50 against the base) and the queued-read test inquery-reader.test.ts(+489), and makes that file's fresh-worker recovery test start from a closed reader. The merge ofmain12fe41e2219(2026-10-14, headb998e21c797, treef569bc30e306):git diff --numstat origin/main..HEAD(evidence/merge-2026-10-14/numstat.txt, whole diffevidence/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 to79fffcac1e7the merge changes underextensions/memory-wikionly whatmainchanged plus the resolution (evidence/merge-2026-10-14/head-79ff-to-head.memory-wiki.diff):query-page-lookup.tsandquery-shared-memory.tsaremain's files untouched;query.tsfeeds the owner its reads and keepsreadMemoryWikiPageByLookupforapply.ts, now scoped to an explicit page list when the owner passes one;query-pages.tsdrops this branch's copy ofresolveQueryableWikiPageByLookup, no longer movesnormalizeLookupKeyand exportsisWikiPageVisible;query-reader.tsimports the owner's resolver;package.jsoncarriesmain's2026.10.3next toworkerEntries;index.test.tskeeps only the stop testmaindid 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, andquery-reader.test.tsin 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
extensions/memory-wiki/src/query-scoring.tstoWikiSearchResult,WIKI_SEARCH_MODES, moved fromquery.ts(including #166355's token prefilter); 15 lines differ from the base text (header comment, imports, addedexportkeywords). Pure functions; no behavioural changeextensions/memory-wiki/src/query-pages.tsmain's reader (#166329) with its signal checkpoints kept. Since the merge of #171961,resolveQueryableWikiPageByLookupandnormalizeLookupKeystay wheremainkeeps them (query-page-lookup.ts,query-shared-memory.ts), andisWikiPageVisibleis exported for the lookup owner'scanReadPage. Behavioural additions:WikiPageVisibilityand the visibility predicate, theWikiPageReadTask/WikiPageReadResultunion (listwith optional excludes;search,keysandpageover an explicit path list;searchandkeysresults carryreadPages),excludeWikiPagePaths, aprojectcallback on the reader so each page is reduced as it is read,WIKI_SCAN_CHECKPOINT_PAGES(64),WIKI_SCAN_YIELD, andreadWikiPagesTask, which both the worker and the calling thread run; a search or key task reads in 64-page segments, keeps a running topmaxResults(search) or appends keys, and asks an optionalshouldYieldbetween segments. Ofmain's four exports,readQueryableWikiPagesis deleted (the reader's task union replaces it),QUERY_PAGE_READ_CONCURRENCYandlistWikiMarkdownFilesbecome module-private andreadQueryableWikiPagesByPathsbecomes the module-private projecting readerextensions/memory-wiki/src/query.tsresolveWikiPageVisibility,searchWikiCorpusdispatching two bounded searches, candidates then the rest of the vault (replacesmain's in-threadscorePagesloop and itssetImmediateyields),readWikiPagerunning one-path reads in-thread throughreadWikiPagesTask,readMemoryWikiPageByLookupthrough the pool;main'sthrowIfAbortedcheckpoints and vault-initialization signal keptextensions/memory-wiki/src/query-reader.tsWikiPageScanTask(search or lookup over a scope), entrypoint descriptor, lazy two-worker pool,answerScanCheckpoint(yield when the pool has aborted the task'syieldSignal, watchdogMAX_TIMER_TIMEOUT_MS),readMemoryWikiPages(one listing task, then scan tasks resubmitted fromreadPagesuntil the listing is read; a running topmaxResultsfor 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 asFsSafeError),closeMemoryWikiQueryReader(keeps the closing pool referenced until close settles)extensions/memory-wiki/src/query-reader.worker.tsserveWorkerTasksaroundreadWikiPagesTask, the checkpoint aschannel.request(null)answered by the host, pool cancellation polled between pages, refusal encodingextensions/memory-wiki/src/tool.tsWIKI_SEARCH_MODESimported fromquery-scoring.ts; the deadline lines aremain's, unchangedextensions/memory-wiki/src/cli.ts,gateway.tsWIKI_SEARCH_MODESandWikiSearchModeimported fromquery-scoring.tsextensions/memory-wiki/src/apply.tsupdate_metadatalookup throughreadMemoryWikiPageByLookup, the lifecycle signalapplyMemoryWikiMutationreceives forwardedextensions/memory-wiki/src/query-shared-memory.tsmain's file;normalizeLookupKeystays here (the branch no longer moves it)extensions/memory-wiki/src/query-page-lookup.tsmain's lookup owner (#171961), untouched;query.tssupplies itsreadExactPage,listFiles,readPagesandcanReadPageextensions/memory-wiki/index.tscloseMemoryWikiQueryReader()in servicestop()extensions/memory-wiki/package.jsonopenclaw.build.workerEntries: ["./src/query-reader.worker.ts"]extensions/memory-wiki/README.md,docs/plugins/memory-wiki.mdconfig/max-lines-baseline.txtquery.tsno longer needs its grandfatheredoxlint-disable max-lines, and the suppression ratchet rejects a stale baseline entryextensions/memory-wiki/src/query.reads.test.tsquery-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 scansextensions/memory-wiki/src/query.abort.test.tsextensions/memory-wiki/src/query-reader.test.tsextensions/memory-wiki/src/query-scheduling.test.tstimeoutMsand 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 fromgetSnapshot()immediately after submission) withmaxWorkers: 2, three admitted, one or two running and the rest queued, and settle on at most two workers with identical resultsextensions/memory-wiki/src/query-shared-compute.test.tsos.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 startsextensions/memory-wiki/src/query-scan.test-support.tsextensions/memory-wiki/index.test.tsextensions/memory-wiki/src/query.path-lookup.test.tsGrowth, 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 ofmain's 73-line file against the old base, +177 / -22 at the merge head). The scorer had to leavequery.tsbecause 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 ofmain'squery-pages.tsbecause the repository's line-cap ratchet caps a new file at 700 counted lines (query.tsitself carried a grandfatheredoxlint-disable max-lines).query.tsshrank from 1,047 to 384 lines against the old base; at the merge head it is 423 lines againstmain'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; withoutquery-scoring.tson the add side that delta was +549 / -784, 744 of the removed linesquery.ts's.Contract table
wiki_search, compiled digest with candidates, enough scoring hitsmaxResults; the host's running topmaxResultsis returned, every result object identical tomain'swiki_search, candidates underfillmaxResultsmaxResults, and the merge never consumes more than that from the wiki corpus)wiki_search, no digest or no candidatesmaxResultskept 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 idwiki_get, exact pathwiki_get, basename, extensionless path or idmain'sresolveQueryableWikiPageForLookup(#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 yieldsnullwiki_apply update_metadatamainreads the whole vault, under the vault mutation lock as before; the page'sparsed.frontmatterandparsed.bodyfeed the write, and the plugin lifecycle signal the tool passes is forwarded{ 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)nullfor that page (absence falls through to discovery, as before)FsSafeErrordirectly; a scan task catches it in the worker, returns{ select: "refused", code, message }, and the host throwsnew FsSafeError(code, message), discarding the partial resultsScheduling:
wiki_getwhile a scan runsnullwith the timer-maximum watchdog)yieldSignal(the capacity calls every holder'srequestCheckpointwhen 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 orderyieldSignalof 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 segmentmaxWorkers: 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 readsgetSnapshot()rather than completion order)wiki.search/wiki.getRPC, supplements, id lookups and misses,update_metadata)main; no task timeout (the test asserts every listing and scan task carriestimeoutMs: 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_searchtool deadline (30 s, from #166329)tool.tsdeadline lines identical tomain: the tool aborts the joined signal withwiki_search timed out after 30s, the pool cancels the task, andtool.deadline.test.tsstill asserts that messageworkerevents: exactly one new worker is created for the recovery read)sharedCompute: true)packages/worker-runtime/src/worker-task-capacity.ts, built bysrc/infra/worker-task-capacity.tswithmax(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 scanWIKI_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 scanmaxPendingTasks: 128andmaxPendingBytes: 256 MiB(packages/worker-runtime/src/worker-task-pool-core.ts), plus the isolate-wide shared admission of everysharedComputepool, memory-core's included (packages/worker-runtime/src/worker-task-capacity.ts:50-57). Exceeding either rejects withWorkerTaskError("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)resourceLimitsare 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 garbagestop()closeMemoryWikiQueryReaderawaits 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 lazilyunrefs a worker as soon as it is idle (packages/worker-runtime/src/worker-task-pool-core.ts:735at the merge head:idle()callsslot.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 thatunref; neither theunrefnor the 60 s retirement was observed directlyopenclaw.build.workerEntriesemitsdist/extensions/memory-wiki/src/query-reader.worker.jsfrom 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-evidenceon etzelm/openclaw, commit13b39fd0d8cb, 181 files; everyevidence/path below links to the raw file at that commit, and itsREADME.mdlists each file and how it was produced). The merge ofmainon 2026-10-14 addsmerge-2026-10-14/at commit7d5f93c7f805on the same branch (tree; its README section "Merge ofmainon 2026-10-14" lists each file); paths below writtenevidence/merge-2026-10-14/link there.All of the following ran on one Mac Studio (
darwin arm64, Apple M3 Ultra, 32 cores, Nodev24.21.0) in one checkout ataf0d2a13c409aa86fa8b9635550df2d7330884c0(baseebc4e6de603c5c1ce55086f13565e21feb1c297d), in one sitting on 2026-10-07 between 21:49 and 22:56 UTC. Head94dd0a0e7f0b7f7dda61da0a9494c0ac55914f23differs from that tree only in comments, the docs paragraph, the README line and the watchdog constant, now imported asMAX_TIMER_TIMEOUT_MSinstead of written out as the same value2_147_000_000(evidence/af0d2a1-to-head.diff, 3 files, +11 / -10); the owning lane andcheck:changedwere 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).2c54327b1ad6d979a8b4123eb181afca168d8ff5is94dd0a0e7f0rebased ontomain072f977edd46c7134dbdb05ec00fac03f6cf8069(evidence/rebase-94dd-to-2c54.range-diff: commits two to five unchanged, the first differing only inpackage.json's version line and inquery.reads.test.ts); on 2026-10-11, on the same machine and Node, the owning lane andcheck:changedran in a checkout with its tree (37c8c9db3cc3d1e817cb353d36ecf538c6d32600). The pushed head79fffcac1e7165084014f91df4f408c81b42755eadds one commit to it that changes onlyindex.test.tsandquery-reader.test.ts; the lane andcheck:changedran 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 of2c54327b1ad, which the pushed head does not change. Every comparison tree was produced in the capture checkout by restoring onlyextensions/memory-wiki, with the tree recorded beside each capture:base(main, scan on the calling thread), the previously published head (19353569c95, labelledprev/before-r4in 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 stimeoutMson every scan task) and the single-worker variant (a5af25c3924, labelledfirst-draft/before-pr: every read, single-page reads included, through one worker). The checkpoint sweep changes only the value ofWIKI_SCAN_CHECKPOINT_PAGESin the working tree. Background load is sampled at the start of every phase inevidence/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 headb998e21c797(treef569bc30e306) mergesmain12fe41e2219into79fffcac1e7; the capture checkout records that tree as commit638a701311cin everymeta.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); theentry:line is whereopenclaw.build.workerEntriesis consumed:Root bundled build (
evidence/build.logfor the build's own output; the lines below are that step ofevidence/evidence2-run.log, quoted whole):Built Gateway, end to end
Both trees were built with
pnpm buildin two checkouts on the same Mac Studio and Node on 2026-10-11 (main072f977edd46, treefc87743d1071; this branch at2c54327b1ad, tree37c8c9db3cc3). For each run,evidence/gateway-e2e/run-tree.shstartsnode openclaw.mjs gateway run --port <p> --bind loopbackfrom one build with its own state directory and config: token auth, andmemory-wikion a fresh APFS clone of one generated vault withingest.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 onewiki_search(cobalt lantern ledger harbor,maxResults: 10) throughPOST /tools/invokeand, until it answers, issuesGET /healthzevery 250 ms and an exact-pathwiki_get(entities/page-N.md, a different page each time) throughPOST /tools/invokeevery 500 ms, without waiting for earlier probes. Each run directory (gateway-e2e/) holdsmeta.txt(tree, Node, UTC start,uptime),probe.json(every probe and the whole search response), the Gateway's owngateway.log(hostname replaced by<host>) and itsopenclaw.json(token replaced by<redacted>). Other builds and test suites shared the machine throughout (one-minute load 41.9 to 71.5 in themeta.txtfiles), 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):
wiki_searchwall/healthzduring the search: n, p50 / p99 / maxwiki_getduring the search: n, p50 / p99 / maxwiki_getp50 (10 samples)main, run 1main, run 2Every probe answered 200, every
wiki_getfound its page, and the fourwiki_searchresponses are identical, the whole/tools/invokebody compared (evidence/gateway-e2e/results-compare.txt:all identical: True). Onmainan 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,
main12fe41e2219(treea88837fcd2eb) against this branch atb998e21c797(treef569bc30e306), each built withpnpm buildin 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.logis the incremental build of the final tree, reusing the cached phases ofevidence/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:changedran on the same machine, one-minute load 12.8 to 17.3 in themeta.txtfiles):wiki_searchwall/healthzduring the search: n, p50 / p99 / maxwiki_getduring the search: n, p50 / p99 / maxwiki_getp50 (10 samples)main, run 1main, run 2Every probe answered 200, every
wiki_getfound its page, and the fourwiki_searchresponses 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 onmainand 14 to 15 ms on this branch, within 1 ms of its idle time, and/healthzanswers in 9 ms p50 onmainagainst 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.mjsandrun-tree-get.share the two files above with the one timed call changed fromwiki_searchtowiki_getand the lookup passed as an argument (two changed lines each), the concurrent probes unchanged. Runsbase-4k-idandhead-4k-idlook upconcept.page-14(an id: no path tier matches it, so both trees read the whole vault),base-4k-missandhead-4k-misslook upabsent(wiki-get-summary.txt; one-minute load 1.8 to 14.0):wiki_getwall and answer/healthzduring the lookup: n, p50 / p99 / maxwiki_getduring the lookup: n, p50 / p99 / maxwiki_getp50main, idconcepts/page-14.mdfoundconcepts/page-14.mdfoundmain, missWiki page not found: absentWiki page not found: absentBoth 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
mainholds the Gateway thread (exact reads wait 327 to 328 ms p50,/healthz7 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 onmain(a directory walk of the four page groups,readWikiPagesTask({ select: "list" })inlistWikiPages); the parse and scoring of every listed page, the part #166304 is about, runs in the worker.In the 2026-10-11 sitting (
main072f977edd46against2c54327b1ad), the same probe on the 10,000-page vault (140.5 MB) under that load runs pastwiki_search's 30 s deadline on both trees, and both Gateways log the same failure, quoted whole frombase-10k/gateway.logandhead-10k/gateway.log:While that search ran,
/healthzanswered at p50 26.6 ms (max 131.4 ms, 116 probes) onmainand 2.7 ms (max 62.8 ms, 119 probes) on this branch, and exact-pathwiki_getat p50 1,034.8 ms (max 1,358.7 ms, 58 probes) onmainand 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.searchrunssearchMemoryWikiwhile samplingperf_hooks.monitorEventLoopDelay(10 ms resolution), a 100 ms timer-chain probe (timer lateness plusfs.accesslatency),process.threadCpuUsage()of the calling thread,process.memoryUsage()andWorker.getHeapStatistics()for every worker announced onprocess.on("worker"), and stores every result object whole; it passes a never-aborted signal, as thewiki_searchtool does, somaintakes its signal-gated yield path.concurrentstarts one whole-vault search and issues 20 exact-pathgetMemoryWikiPagereads, one every 500 ms without waiting for the previous one.budgetruns one caller shape:cli-search,cli-getandcli-applycallsearchMemoryWiki,getMemoryWikiPageandapplyMemoryWikiMutation(update_metadata) with no signal, the call shapes ofopenclaw wiki search,wiki getandwiki apply metadata(cli.ts:615,:646and:707), andtoolexecutes the realwiki_searchtool returned bycreateWikiSearchTool, whose 30 s deadline applies.contentionis described with its table.Shared compute on a one-permit host.
contentionruns with a--requirepreload (evidence/single-permit.cjs) that setsos.availableParallelism()to 2 before the capacity exists, sogetWorkerComputeCapacity()grants one permit, as on a one- or two-core host; every file recordslimit: 1from the capacity's own snapshot. It starts an unsignalled whole-vaultsearchMemoryWiki(the call shape of thewiki.searchRPC and thememory_searchsupplement) and, once a second while the scan runs, submits a task to memory-core's real retrieval pool (runMemoryPresenceInspectionfromextensions/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 inevidence/contention/<tree>/<vault>-rep<n>.json(files):memory_search's 30 s deadlinemain(scan on the calling thread, takes no permit)mainOn
mainthe 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.jsonfor the previously published head against this head,evidence/contention/results-compare-base-head-10k.jsonandevidence/contention/results-compare-base-head-20k.jsonformainagainst 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 onlyWIKI_SCAN_CHECKPOINT_PAGESchanged in the working tree (evidence/sweep/sweep-run.log; 64 is the head's value):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
searchwith--trace-gc, this head and the fixed-batch variant alternating, three runs each (evidence/post-run.log, "CPU"; per-run JSON and GC traces incpu/):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):main)fs.accessprobe latency p50 / p99 / maxheapUsed)used_heap_size, sampled every 100 ms; an upper bound that includes uncollected garbage)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.jsonholdsJSON.stringifyequality over the completeresultsarrays 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
rawandparsedon 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 thanmain'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.mdissued 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):searchMemoryWiki, 10 results)Deadline ownership. 20,000 pages, 120 body lines and 60 claims per page (558.7 MB), query
cobalt lantern ledger harbor, lookuppage-14321(a basename, a whole-vault lookup on every tree when this was captured; since #171961 a basename hit reads one page onmainand 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 isevidence/budget/<tree>/<step>.json(base, pool-timeout, head):main(base)Error: wiki_search timed out after 30swiki 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)entities/page-14321.md, 49,880 msError: wiki page lookup timed out after 30sentities/page-14321.md, 47,946 mswiki_searchtool (30 s deadline)Error: wiki_search timed out after 30sError: wiki_search timed out after 30sError: wiki_search timed out after 30sEvery outcome on that head (
af0d2a13c40) matches thatmain's (ebc4e6de603), and the CLI search's 10 result objects are identical tomain'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 onmainfail.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.sha256is 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) bymain, 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 inevidence/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 sameupdate_metadata(status: reviewed, one question, no signal, thewiki apply metadatacall shape) bymain, another by this head; both resolved withchanged: trueonconcepts/page-1234.md. With every ISO-8601 timestamp normalized only.openclaw-wiki/log.jsonldiffers (evidence/compat/tree-after-base-apply.ts-normalized.sha256,evidence/compat/tree-after-head-apply.ts-normalized.sha256,evidence/compat/apply-ts-normalized.diff), andevidence/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 incompiledCacheSourceGeneration, a SHA-256 over page bytes (log.ts:163-168at the merge head) that differs because the pages'updatedAtdiffers.git diff --statbetween 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.tsandquery.tshold in-memory task and result types that live for one query;apply.tschanges only howupdate_metadatafinds its page, and the write above lands the same bytes apart from timestamps and ids; the onepackage.jsonchange is the build keyopenclaw.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
FsSafeErroron 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, pluginstop()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 idsource.alphainstead of the basenamealpha, because since #171961 a basename hit is a one-page read onmaintoo 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 onmainsince072f977edd46that touchextensions/memory-wiki(#169570, #169687, #169982, #170368, #170532, #172034, #172040), while #171961 addedquery.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-safebeforeOpenhook, 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 withFsSafeError.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 at2c54327b1ad,evidence/head-2c54-lane.log). The count is lower than at94dd0a0e7f0on the old base (evidence/head-94dd-lane.log,Tests 514 passed | 1 skipped (515); the same lane at the captured tree isevidence/tests.log) because tests inextensions/memory-wikiwere removed onmainsince the old base (#169218). The skipped test isobsidian.discovery.test.ts > preserves PATHEXT precedence, which the branch does not touch:Regression proof (red/green)
query-shared-compute.test.ts(new) andquery-scheduling.test.tshold 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 mockingos.availableParallelism()(the file owns the process-wide capacity singleton) and records events at the pool'srunseam 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 readsgetSnapshot()synchronously after the third submission.Red runs the head's changed test files against
extensions/memory-wikirestored 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:The same
query-scheduling.test.tsagainst 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):Mutation check (
mutants/, each.diffis the whole change and each.logthe vitest output ofquery-scheduling.test.ts,query-shared-compute.test.tsandquery-reader.test.ts, 19 tests): every mutant fails exactly the test that owns its construct.[...found, ...results],query-pages.ts)[...read.results, ...results],query-reader.ts)input: null,query-reader.ts)return false,query-reader.worker.ts)const current = page,query-reader.ts)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.tsfails three (Tests 3 failed | 11 passed (14)): "reads query pages without extracting the link graph" (TypeError: undefined is not iterable; it reads through the newkeystask), "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); greenTests 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, greenTests 15 passed (15)(that red was run when the test's lookup was the basenamealpha; since the merge of #171961 a basename hit is a one-page read onmaintoo, so the test's lookup is now the idsource.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.tspasses 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 withawait closeMemoryWikiQueryReader();removed from the plugin servicestop()(red-index-stop.mutation.diff,red-index-stop.log): the worker the lookup started is still alive whenstop()resolves: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:At the head (
green-index-stop.log,green-query-reader-queued.log):Other checks
pnpm check:changed --base upstream/mainevidence/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-awarelint extensions,typecheck extensions,typecheck extension tests, plugin boundaries, lint scripts and runtime import cycles. With the pushed head's tree on base072f977edd46(evidence/head-79ff-check-changed.log; the same outcome at2c54327b1ad,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 underextensions/) are the same listpnpm deadcode:exportsprints onmain072f977edd46(evidence/main-072f-deadcode-exports.log). With that scan skipped (evidence/head-79ff-check-changed-skip-deadcode.log) every step is ok exceptlint extensions, whose one error iseslint(max-lines): File has too many lines (717).inextensions/crabbox/src/crabbox-worker-provider.ts, a file the branch does not touch. The four stepscheck:changedschedules 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/mainat the merge headb998e21c797evidence/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 onmain12fe41e2219and none underextensions/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 onmain,evidence/merge-2026-10-14/main-12fe-max-lines-ratchet.log); the dead export scan lists 8 production and 17 full-tree entries, all undersrc/andui/, the same listspnpm deadcode:exportsprints onmain(evidence/merge-2026-10-14/main-12fe-deadcode-exports.log); andlint extensionsreports fourmax-lineserrors, inextensions/anthropic/cli-runtime.test.ts,extensions/agentsapi/agentsapi-harness.persistence.test.ts,extensions/codex/src/app-server/run-attempt-resources.tsandextensions/codex/src/app-server/session-binding.ts, none of which the branch touches, the same fourmainprints (evidence/merge-2026-10-14/main-12fe-lint-extensions.log:Found 0 warnings and 4 errors.), whilenode scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/memory-wikiprintsFound 0 warnings and 0 errors.(evidence/merge-2026-10-14/head-oxlint-memory-wiki.log). The run usedNODE_OPTIONS=--max-old-space-size=16384: with the default heap,check-changed.mjsitself dies withFATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memorywhile it enumerates this merge (evidence/merge-2026-10-14/head-check-changed-default-heap-oom.log)git diff --check origin/main...HEADat the merge headevidence/merge-2026-10-14/head-diff-check.log)git diff --check upstream/main...HEAD94dd0a0e7f0;git diff --check origin/main...HEADclean with the pushed head's tree on base072f977edd46(evidence/head-79ff-diff-check.log)docs/plugins/memory-wiki.mdgained twelve lines of prose next to the existing deadline paragraph; no links addedMeasured 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 theextension-memoryvitest project of the bundled plugin lane:real)src/query-shared-compute.test.ts(new)src/query-scheduling.test.ts(new)src/query-reader.test.ts(new)src/query.reads.test.tssrc/query.abort.test.tsThe 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.tstook 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.tsandquery-shared-compute.test.tsare 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, orstop()), 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 loadsdist/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), andquery-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 headquery.reads.test.tsholds 8 tests (the lane log lists each; the cost row above was measured when it held 15), after #169218's deletions onmain.Gaps, stated plainly
pnpm changed:lanes --json --base upstream/mainfor this diff, thelanesblock quoted fromevidence/changed-lanes.json:Lanes that are
true:extensions,extensionTests,docs,tooling(the one-line shrink ofconfig/max-lines-baseline.txtcounts as a tooling surface) andbundledChannelConfigMetadata. Everything else (core,coreTests,ui,scripts,testRoot,apps,liveDockerTooling,releaseMetadata,all) isfalse, and AGENTS.md does not mandate unrelated suites, so only the memory-wiki lane andcheck:changed(which runs the tooling guards itself) ran.Closesrather thanRelated: 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 becomesRelated: #166304.mainanswers it in 12 ms p50 (34 ms at most) because onmainthe 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.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, twowiki_searchcalls that each need most of their 30 s alone can both time out, where serving them in order would have finished the first; onmainthe 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 (requestCheckpointscounts 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.wiki.searchRPC, thememory_searchandmemory_getsupplements, the CLI, everywiki_getid lookup or miss and everywiki_apply update_metadatastart a scan with no deadline of their own (User Impact lists each call site), exactly as onmain, 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. Onmainthe 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.sharedCompute: true) because extension tests cannot import another extension; the real memory-core pool is exercised by thecontentionharness above, which runsrunMemoryPresenceInspection(a cheap task in the pool keyword search uses), not a fullmemory_searchtool 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.drain()) before the host'sawaitchain resubmits the scan. That is how the pool works today; a change that defers input preparation would reorder the events without changing the guarantee.maxWorkers: 2andworkersCreated <= 2rather than through two concurrent tasks.readPagescallback is overloaded.resolveQueryableWikiPageForLookup(fix(memory-wiki): avoid full-vault reads for path lookups #171961) declaresreadPages(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 sameresolveQueryableWikiPageByLookupover whateverreadPagesreturned, 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 beforereadPagesreturned, would need this seam revisited. Making the owner take areadLookup(relativePaths, lookup)step instead is a one-line owner change left to maintainers.query-reader.tskeeps one module-level pool, created by the first scan and closed by the plugin service'sstop(), not tied to a service generation asextensions/AGENTS.mdasks for work that outlives its caller. The CLI is why:openclaw wiki search,getandapplyrun with no service, so the pool must exist without one. Consequences: a scan afterstop()recreates a pool no service will close (bounded by the idleunrefand 60 s retirement), and if a plugin reload shares the module instance, the old service'sstop()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.dist/spawn path was not measured, and the 60 s retirement itself was not observed (no run waited 60 s).wiki_searchtool calls longer than its 30 s deadline still fail, as onmain(the deadline-ownership table shows it on all three trees); this PR changes where the 30 s is spent, not the budget.codeacross the pool boundary (message preserved,WorkerTaskErrorwith codefailed);FsSafeErrorlosescauseanddetails. No caller inspected those fields.main's reader has.main'squery.reads.test.tsswapped a page for an outside symlink from a thread-local fs-safebeforeOpenhook, 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 onreadWikiPagesTask, and covers the pool's refusal rebuild on a scoped lookup; the basename route throughgetMemoryWikiPageis 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 throughgetMemoryWikiPageis the one not exercised with a mid-read swap. fix(memory-wiki): avoid full-vault reads for path lookups #171961'squery.path-lookup.test.tscounted 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.main; identity withmainis 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 frommainlives in the test suite.other(src/infra/worker-diagnostic-script.tsandworker-request-kind.tskeep a core allowlist of script names). Addingquery-reader.worker.jsthere is a core edit left out of this plugin-local PR.compile.tsstill reads and parses the whole vault on the main thread, with link extraction and its own per-pageyieldToEventLoop, after everywiki_applyand in the CLI process before a search. This PR moves query scans only.POST /tools/invoke, which runs the realwiki_searchandwiki_gettools in the Gateway without a model turn; no agent turn or channel was involved. They usedingest.autoCompile: falseto keep the vault without a digest, one query, HTTP/healthzas 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.main's, unchanged).