Skip to content

fix(memory-wiki): publish dashboard snapshots - #132296

Merged
obviyus merged 10 commits into
openclaw:mainfrom
obviyus:codex/issue-132077-memory-wiki-snapshot
Aug 29, 2026
Merged

obviyus merged 10 commits into
openclaw:mainfrom
obviyus:codex/issue-132077-memory-wiki-snapshot

Conversation

@obviyus

@obviyus obviyus commented Aug 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #132077

What Problem This Solves

The Memory Wiki dashboard RPCs read and parsed every Markdown page on each Control UI request. A 229 MB vault made both dashboard calls take about 166 seconds and blocked the operator flow.

Why This Change Was Made

The compiled-cache publication now owns the Imported Insights and Memory Wiki overview projections.

  • Compile builds both bounded projections during its existing page scan.
  • Cache version 3 has one required dashboard shape; older rebuildable cache rows are rejected.
  • Dashboard RPCs start source sync in the background and never wait for a vault compile.
  • Recovery returns explicit rebuilding, compile-required, or failed states through structured Gateway errors.
  • ingest.autoCompile: false never triggers a hidden compile; the UI tells the operator to run openclaw wiki compile.
  • Background compile yields between large page parses so Gateway health traffic remains responsive.
  • Plugin shutdown retires cache owners before waiting for source sync, so a late compile cannot publish after lifecycle closure.
  • The service-generation abort signal reaches every Gateway and tool compile producer, page scan, and derived-write unit.
  • Both bounded dashboard results carry a required truncation flag; the UI shows returned and total item counts when the 2,500-item cap applies.

Ready dashboard response payloads are unchanged.

User Impact

Memory Wiki dashboards remain responsive on large vaults. Upgrades show a short rebuilding result and then use the new publication. Changed imports publish in the background. Operators who disable automatic compile keep that setting and receive a clear manual recovery command. A dashboard that reaches the item cap now states exactly how many items are shown and how many exist.

Evidence

The same built Control UI and isolated Gateway flow ran with 3,700 valid Markdown pages totaling 229,400,000 bytes, including 2,300 ChatGPT pages and a unique sentinel.

Case Initial dashboard result Final result Publications Concurrent health
Current main 8cd61f02bf48 ready after 166,149/166,347 ms contract failed n/a 2,281/2,281 passed; p95 101 ms; max 655 ms
Head fd44319486d4, warm ready in 230/231 ms ready 0 10/10 passed; max 585 ms
Head, version-2 upgrade rebuilding in 136/137 ms ready in 72/72 ms 1 630/630 passed; p95 31 ms; max 285 ms
Head, changed import prior snapshot in 206/206 ms refreshed in 78/78 ms 1 926/926 passed; p95 37 ms; max 555 ms
Head, changed import with auto-compile off prior snapshot in 221/220 ms compile-required in 38/38 ms 0 28/28 passed; p95 269 ms; max 586 ms

The upgrade and changed-import runs retained the sentinel and correct page counts. The changed-import run proved the new sentinel after publication. The disabled-auto-compile run recorded zero compile and publication events. All proof-owned Gateways, browsers, ports, and state were cleaned up.

A separate 2,501-item, 229.4 MB run returned 2,500 items with truncated: true from both real Gateway methods. Imported Insights answered in 230 ms and Memory Wiki in 238 ms. Both built Control UI tabs showed Showing the newest 2,500 of 2,501 items. Concurrent health passed 72/72.

A separate SIGTERM probe reached an active large-vault scan in three fresh runs and produced zero later publications. Gateway-wide drains prevented isolating the Memory Wiki abort latency and restart state, so that extra timing probe remains unverified. The owner-boundary regressions independently prove that queued manual compile stops before activation and an active scan stops at its 16 in-flight work units.

Control UI proof

Version-2 cache returns rebuilding

Recovered version-3 dashboard

Auto-compile disabled returns compile-required

Imported Insights discloses bounded results

Memory Wiki discloses bounded results

Validation

  • The dashboard request-boundary regression failed on pre-fix 812840adf85f because neither handler responded while source sync remained unresolved.
  • The queued dashboard-sync lifecycle regression failed on pre-fix 4baa0dabe749 because stopped work reactivated the vault owner, then passed on the repaired head.
  • The queued manual-compile and active-scan regressions failed on pre-fix a77e3fbf637b, then passed on the repaired head.
  • node scripts/run-vitest.mjs passed 205 focused Memory Wiki and Control UI tests across 12 owner and sibling files on exact head fd44319486d4; the two bounded-result tests rendered 2,500 real cards per view.
  • Live main 5b532a78ee1f has no Memory Wiki or Control UI memory-owner change after the exact 8cd61f02bf48 red run.
  • Exact-head production and test type checks, Oxlint, dependency and boundary guards, dead-export checks, database-first checks, and import-cycle checks passed.
  • Exact-head pnpm build passed, including the served Control UI bundle.
  • Docs MDX, internal links, and formatting checks passed.

Line Count

  • Production: +848/-337, net +511.
  • Tests and test support: +736/-103, net +633.
  • Docs: +10/-0.

The production growth adds bounded dashboard projections plus the cache-owned availability state, required truncation contract, visible disclosure, and one service-generation fence across every compile path. The absorbing refactor moved both projections into the existing compiler, uses the platform AbortController for lifecycle closure, removed the request-time raw readers, removed the optional version-2 dashboard shape, removed the hidden autoCompile: false compile path, and removed the temporary derived-write mode. The UI test split also removes the touched file's max-lines violation without a suppression.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 7:11 PM ET / 23:11 UTC.

ClawSweeper review

What this changes

The branch compiles Memory Wiki dashboard data into cached snapshots, serves dashboard requests from those snapshots, and discloses bounded results in the Control UI.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: this protected maintainer PR is a coherent candidate fix for the linked large-vault Gateway stall, and current main still performs the request-time path it removes.

Priority: P1
Reviewed head: fd44319486d4597fcff94a4f3f181c13e47086e3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch follows the compiler/cache owner boundary with focused lifecycle and UI coverage; exact-head CI remains in progress.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer PR includes described isolated Gateway and built Control UI after-fix evidence; no external-contributor proof action is required.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer PR includes described isolated Gateway and built Control UI after-fix evidence; no external-contributor proof action is required.
Evidence reviewed 7 items Current-main behavior: Current main awaits imported-source synchronization and then calls the dashboard reader on each import-insights and overview request; this is the request-time path behind the reported large-vault stall.
Snapshot owner boundary: The branch builds both dashboard projections during compilation, while the public readers only load compiled dashboard data.
Request behavior after change: The two dashboard Gateway methods schedule source synchronization in the background and respond through snapshot-only readers.
Findings None None.
Security None None.

How this fits together

Memory Wiki turns vault pages into dashboard data served through Gateway methods to the Control UI. This change moves expensive page parsing into compilation and makes requests consume a published snapshot.

flowchart LR
  Vault[Memory Wiki vault] --> Compiler[Background compiler]
  Compiler --> Cache[Compiled dashboard snapshots]
  Request[Gateway dashboard request] --> Reader[Snapshot reader]
  Cache --> Reader
  Reader --> UI[Control UI]
  Request --> Sync[Background source sync]
  Sync --> Compiler
Loading

Before merge

  • Resolve merge risk (P1) - Compiled-cache version 3 intentionally rebuilds existing dashboard data after upgrade, temporarily returning an explicit rebuilding or compile-required response until compilation completes.
  • Resolve merge risk (P1) - The repair adds a net 511 production lines; the growth is justified by the new cache projection, publication, and lifecycle owner boundary, but warrants exact-head validation.
  • Complete next step (P2) - The protected maintainer PR already owns the repair; it needs ordinary exact-head validation rather than a separate repair job.
Agent review details

Security

None.

PR surface

Source +585, Tests +559, Docs +10. Total +1154 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 20 922 337 +585
Tests 12 662 103 +559
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 33 1594 440 +1154

Review metrics

Metric Value Why it matters
Production versus test delta production +848/-337, net +511; tests/support +736/-103, net +633; docs +10/-0 Production growth implements the compiled dashboard, cache publication, and cancellation boundary; the test growth covers those lifecycle and UI paths.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/memory-wiki/src/compile.ts, persistent cache schema: extensions/memory-wiki/src/gateway.ts, persistent cache schema: extensions/memory-wiki/src/import-insights.ts, persistent cache schema: extensions/memory-wiki/src/wiki-overview.ts, serialized state: extensions/memory-wiki/src/ingest.ts, unknown-data-model-change: extensions/memory-wiki/index.ts, and 30 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept explicit cache recovery (recommended)
    Merge after exact-head validation confirms an invalidated prior cache rebuilds and dashboard callers receive the documented recovery response.
  2. Pause for immediate upgrade continuity
    Pause the PR if maintainers require dashboards to remain immediately available across a cache-format change.

Technical review

Best possible solution:

Retain the snapshot and lifecycle owner boundary, with the explicit temporary recovery state verified on the exact PR head before merge.

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

Yes: current-main source shows the request-time dashboard path, and the linked issue supplies a consistent large-vault operational trace; this read-only review did not execute it locally.

Is this the best way to solve the issue?

Yes: moving scans and projection construction to the compiler/cache owner eliminates repeated request-time parsing and preserves explicit recovery behavior when no snapshot is ready.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5b532a78ee1f.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer PR includes described isolated Gateway and built Control UI after-fix evidence; no external-contributor proof action is required.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The linked large-vault failure can starve Gateway and disconnect active channel and Control UI sessions.
  • merge-risk: 🚨 compatibility: The cache format changes from version 2 to 3, requiring existing dashboard caches to rebuild after upgrade.
  • merge-risk: 🚨 availability: Dashboard reads can temporarily return rebuilding or compile-required while the replacement snapshot is unavailable.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer PR includes described isolated Gateway and built Control UI after-fix evidence; no external-contributor proof action is required.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm exact-head CI covers cache-version recovery and cancellation before merging.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-29T02:56:16.785Z sha e11ea06 :: found issues before merge. :: [P1] Invalidate the loaded snapshot when publishing | [P1] Preserve dashboards when automatic compilation is disabled
  • reviewed 2026-08-29T03:34:00.926Z sha 74ffe18 :: needs changes before merge. :: [P1] Refresh snapshots after changed imports
  • reviewed 2026-08-29T04:22:52.860Z sha 812840a :: found issues before merge. :: [P1] Keep full cache rebuilds off dashboard RPCs
  • reviewed 2026-08-29T19:48:50.647Z sha f58d343 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T20:32:57.036Z sha 4baa0da :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T21:20:03.429Z sha 2de34b3 :: found issues before merge. :: [P1] Fence all compilation work on service shutdown | [P1] Observe cancellation during page scanning and writes
  • reviewed 2026-08-29T22:10:25.460Z sha a77e3fb :: found issues before merge. :: [P1] Bind manual compilation to service shutdown | [P1] Check cancellation throughout compilation

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 29, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 29, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL and removed size: L labels Aug 29, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 29, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Aug 29, 2026
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Aug 29, 2026
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 29, 2026
@obviyus

obviyus commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @etzelm!

Proof: On the built Control UI and isolated Gateway, the 229.4 MB vault took 166,149/166,347 ms on current-main behavior. Exact head fd44319486d4 answered warm dashboard calls in 230/231 ms, recovered a version-2 cache through one background publication, preserved autoCompile: false with an explicit manual command, and showed 2,500 of 2,501 on both bounded dashboard tabs. Concurrent health stayed responsive, and exact-head CI run 33280035675 passed.

  • Bug: Every dashboard request parsed the full vault, so a large import blocked the operator flow and could disconnect active clients.
  • Fix: The compiler publishes one bounded v3 dashboard snapshot; requests read it immediately, recovery has explicit states, and one service-generation abort signal fences every compile producer, scan, derived write, and publication.
  • Validation: node scripts/run-vitest.mjs passed 205 focused tests across 12 owner, lifecycle, cache, Gateway, tool, and Control UI files; pnpm check:changed and pnpm build passed on the exact head.
  • Proof gap: A separate SIGTERM timing probe could not isolate Memory Wiki abort latency from Gateway-wide drains. All three attempts produced zero post-stop publication; the queued-compile and active-scan owner regressions pass.

Example

Before After
Dashboard calls re-read 229.4 MB and took about 166 seconds. Warm calls return in about 230 ms; recovery is explicit and health remains responsive.
Results above 2,500 cards were silently omitted. Both tabs show Showing the newest 2,500 of 2,501 items.

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 29, 2026
@obviyus
obviyus merged commit 0e2e6c3 into openclaw:main Aug 29, 2026
205 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
Publish bounded Memory Wiki dashboard projections with the compiled cache so Control UI reads do not scan the full vault.

Keep recovery explicit, preserve disabled automatic compilation, disclose bounded results, and fence all compilation work at plugin service shutdown.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 27, 2026
…#188256)

Root cause: `extensions/memory-wiki/src/tool.ts:174` awaits `syncMemoryWikiImportedSources` (import, then a full compile) inside the 30 s `wiki_search` deadline, and `extensions/memory-wiki/src/gateway.ts:277` awaits the same sync before `wiki.search` with no deadline, so a large pending import fails or stalls searches for pages that are already on disk.

Related: #187429, #132296, #166329

## What Problem This Solves

Fixes: `wiki_search` fails with "wiki_search timed out after 30s", and the `wiki.search` Gateway method hangs, when a large vault has source changes waiting to import and compile. The pages being searched for are already on disk.

## User Impact

Searches answer from the current wiki at once while the Gateway imports and compiles in the background. Content that changed in the sources since the last refresh shows up on the next search, not this one. That one-search delay is the only staleness: pages written with `wiki_apply` are read live, and a vault with no compiled snapshot yet still answers through the existing full scan.

Unchanged: `wiki_get`, `openclaw wiki search`, imports, compile, lint, apply and status still wait for the sync. `ingest.autoCompile: false` still never compiles. A caller with no running wiki service (one-shot hosts) still waits as before.

## Why This Change Was Made

When the wiki service is running, `wiki_search` and `wiki.search` run the query first and then start the service-owned source sync that the Overview and Import Insights dashboards already use (#132296). That helper moves from `gateway.ts` to `source-sync.ts` as `refreshMemoryWikiImportedSources`. It still single-flights equal requests, queues on the vault mutation lock, is cancelled by the service signal and is joined at shutdown. The refresh starts after the query because a cold read owner activates through the same vault queue, so a refresh started first would block the search.

The helper runs the sync with `runInDetachedAsyncContext`. Without it the built Gateway aborted every refresh after the `/tools/invoke` response with `Failed to open the plugin state database. | This operation was aborted`, so nothing was ever published. The dashboard path on main has the same defect and this fixes it too.

This takes over Baumus's PR. Thanks @Baumus for finding this, carrying the fix in your own deployment since 2026.10.10 and for the real-Gateway proof (#188256 (comment)), which also found the async-scope abort. Your commits stay in the branch. The commits on top replace the refresh coordinator (60 s freshness window, 5–60 s retry backoff, retry handles), the move to the plugin service scheduler, the query hook, the README section and the test-line allocation with the existing dashboard helper. No new freshness or retry policy is needed: the next search or dashboard poll is the retry, as for dashboards today.

## Evidence

The built Gateway (dist) runs in an isolated profile with a task-owned state, config and port. Requests go through `/tools/invoke` → `wiki_search` and through `openclaw gateway call wiki.search`. The importer and compiler are the real unsafe-local ones, with no mocks or delays. Fixture: a compiled vault with one `entities/cobalt.md`, then 6,000 new synthetic source files. Source `0` contains "Zirconium publication evidence." Harness and raw captures: #188256 (comment).

| Run | Base 6052fff | This PR |
| --- | --- | --- |
| `wiki_search cobalt`, run 1 | HTTP 500 at 30.5 s, `wiki_search timed out after 30s` | HTTP 200 at 4.9 s, `entities/cobalt.md`, 0 pages imported, no new publication |
| `wiki_search cobalt`, run 2 | HTTP 500 at 30.4 s, `wiki_search timed out after 30s` | HTTP 200 at 4.3 s, `entities/cobalt.md` |
| `wiki_search zirconium` after publication | n/a | HTTP 200 at 8.4 s, the newly imported source page |
| `wiki.search` RPC (`openclaw gateway call`), twice | no answer within 600 s; all 6,000 imported, still no publication | `entities/cobalt.md` in 8.8 s and 7.7 s; after publication `zirconium` returns the new page |

Controls on this PR:
- Cold vault with no compiled snapshot: answers `cobalt` in 4.3 s through the scan fallback.
- Two concurrent searches plus one `wiki.overview` poll: all answer, and exactly one compile is published.
- SIGTERM during the refresh: exit 0 in 2.2 s, no publication, journal unchanged after exit.
- `ingest.autoCompile: false`: the search answers, all 6,000 sources import, and nothing compiles.
- One-shot `openclaw wiki search zirconium`: still waits for import and compile (508 s on a loaded host) and returns the new page.
- Without `runInDetachedAsyncContext`, both runs logged `background source sync failed: Failed to open the plugin state database. | This operation was aborted` and never published.

Unit: `tool.deadline.test.ts` "answers from the current index while the service refreshes" fails on base with `wiki_search timed out after 30s` and passes here. Focused memory-wiki suites pass: 8 files, 95 tests. Local review on the head reports no findings.

## Merge Danger

Two-way door. No config, schema, protocol or stored-data change; a revert restores the awaited sync. Blast radius: memory-wiki search through the agent tool and the `wiki.search` Gateway method while the plugin service runs.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…#188256)

Root cause: `extensions/memory-wiki/src/tool.ts:174` awaits `syncMemoryWikiImportedSources` (import, then a full compile) inside the 30 s `wiki_search` deadline, and `extensions/memory-wiki/src/gateway.ts:277` awaits the same sync before `wiki.search` with no deadline, so a large pending import fails or stalls searches for pages that are already on disk.

Related: #187429, #132296, #166329

## What Problem This Solves

Fixes: `wiki_search` fails with "wiki_search timed out after 30s", and the `wiki.search` Gateway method hangs, when a large vault has source changes waiting to import and compile. The pages being searched for are already on disk.

## User Impact

Searches answer from the current wiki at once while the Gateway imports and compiles in the background. Content that changed in the sources since the last refresh shows up on the next search, not this one. That one-search delay is the only staleness: pages written with `wiki_apply` are read live, and a vault with no compiled snapshot yet still answers through the existing full scan.

Unchanged: `wiki_get`, `openclaw wiki search`, imports, compile, lint, apply and status still wait for the sync. `ingest.autoCompile: false` still never compiles. A caller with no running wiki service (one-shot hosts) still waits as before.

## Why This Change Was Made

When the wiki service is running, `wiki_search` and `wiki.search` run the query first and then start the service-owned source sync that the Overview and Import Insights dashboards already use (#132296). That helper moves from `gateway.ts` to `source-sync.ts` as `refreshMemoryWikiImportedSources`. It still single-flights equal requests, queues on the vault mutation lock, is cancelled by the service signal and is joined at shutdown. The refresh starts after the query because a cold read owner activates through the same vault queue, so a refresh started first would block the search.

The helper runs the sync with `runInDetachedAsyncContext`. Without it the built Gateway aborted every refresh after the `/tools/invoke` response with `Failed to open the plugin state database. | This operation was aborted`, so nothing was ever published. The dashboard path on main has the same defect and this fixes it too.

This takes over Baumus's PR. Thanks @Baumus for finding this, carrying the fix in your own deployment since 2026.10.10 and for the real-Gateway proof (#188256 (comment)), which also found the async-scope abort. Your commits stay in the branch. The commits on top replace the refresh coordinator (60 s freshness window, 5–60 s retry backoff, retry handles), the move to the plugin service scheduler, the query hook, the README section and the test-line allocation with the existing dashboard helper. No new freshness or retry policy is needed: the next search or dashboard poll is the retry, as for dashboards today.

## Evidence

The built Gateway (dist) runs in an isolated profile with a task-owned state, config and port. Requests go through `/tools/invoke` → `wiki_search` and through `openclaw gateway call wiki.search`. The importer and compiler are the real unsafe-local ones, with no mocks or delays. Fixture: a compiled vault with one `entities/cobalt.md`, then 6,000 new synthetic source files. Source `0` contains "Zirconium publication evidence." Harness and raw captures: #188256 (comment).

| Run | Base 6052fff | This PR |
| --- | --- | --- |
| `wiki_search cobalt`, run 1 | HTTP 500 at 30.5 s, `wiki_search timed out after 30s` | HTTP 200 at 4.9 s, `entities/cobalt.md`, 0 pages imported, no new publication |
| `wiki_search cobalt`, run 2 | HTTP 500 at 30.4 s, `wiki_search timed out after 30s` | HTTP 200 at 4.3 s, `entities/cobalt.md` |
| `wiki_search zirconium` after publication | n/a | HTTP 200 at 8.4 s, the newly imported source page |
| `wiki.search` RPC (`openclaw gateway call`), twice | no answer within 600 s; all 6,000 imported, still no publication | `entities/cobalt.md` in 8.8 s and 7.7 s; after publication `zirconium` returns the new page |

Controls on this PR:
- Cold vault with no compiled snapshot: answers `cobalt` in 4.3 s through the scan fallback.
- Two concurrent searches plus one `wiki.overview` poll: all answer, and exactly one compile is published.
- SIGTERM during the refresh: exit 0 in 2.2 s, no publication, journal unchanged after exit.
- `ingest.autoCompile: false`: the search answers, all 6,000 sources import, and nothing compiles.
- One-shot `openclaw wiki search zirconium`: still waits for import and compile (508 s on a loaded host) and returns the new page.
- Without `runInDetachedAsyncContext`, both runs logged `background source sync failed: Failed to open the plugin state database. | This operation was aborted` and never published.

Unit: `tool.deadline.test.ts` "answers from the current index while the service refreshes" fails on base with `wiki_search timed out after 30s` and passes here. Focused memory-wiki suites pass: 8 files, 95 tests. Local review on the head reports no findings.

## Merge Danger

Two-way door. No config, schema, protocol or stored-data change; a revert restores the awaited sync. Blast radius: memory-wiki search through the agent tool and the `wiki.search` Gateway method while the plugin service runs.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit f9f7bf7)
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…#188256)

Root cause: `extensions/memory-wiki/src/tool.ts:174` awaits `syncMemoryWikiImportedSources` (import, then a full compile) inside the 30 s `wiki_search` deadline, and `extensions/memory-wiki/src/gateway.ts:277` awaits the same sync before `wiki.search` with no deadline, so a large pending import fails or stalls searches for pages that are already on disk.

Related: #187429, #132296, #166329

## What Problem This Solves

Fixes: `wiki_search` fails with "wiki_search timed out after 30s", and the `wiki.search` Gateway method hangs, when a large vault has source changes waiting to import and compile. The pages being searched for are already on disk.

## User Impact

Searches answer from the current wiki at once while the Gateway imports and compiles in the background. Content that changed in the sources since the last refresh shows up on the next search, not this one. That one-search delay is the only staleness: pages written with `wiki_apply` are read live, and a vault with no compiled snapshot yet still answers through the existing full scan.

Unchanged: `wiki_get`, `openclaw wiki search`, imports, compile, lint, apply and status still wait for the sync. `ingest.autoCompile: false` still never compiles. A caller with no running wiki service (one-shot hosts) still waits as before.

## Why This Change Was Made

When the wiki service is running, `wiki_search` and `wiki.search` run the query first and then start the service-owned source sync that the Overview and Import Insights dashboards already use (#132296). That helper moves from `gateway.ts` to `source-sync.ts` as `refreshMemoryWikiImportedSources`. It still single-flights equal requests, queues on the vault mutation lock, is cancelled by the service signal and is joined at shutdown. The refresh starts after the query because a cold read owner activates through the same vault queue, so a refresh started first would block the search.

The helper runs the sync with `runInDetachedAsyncContext`. Without it the built Gateway aborted every refresh after the `/tools/invoke` response with `Failed to open the plugin state database. | This operation was aborted`, so nothing was ever published. The dashboard path on main has the same defect and this fixes it too.

This takes over Baumus's PR. Thanks @Baumus for finding this, carrying the fix in your own deployment since 2026.10.10 and for the real-Gateway proof (#188256 (comment)), which also found the async-scope abort. Your commits stay in the branch. The commits on top replace the refresh coordinator (60 s freshness window, 5–60 s retry backoff, retry handles), the move to the plugin service scheduler, the query hook, the README section and the test-line allocation with the existing dashboard helper. No new freshness or retry policy is needed: the next search or dashboard poll is the retry, as for dashboards today.

## Evidence

The built Gateway (dist) runs in an isolated profile with a task-owned state, config and port. Requests go through `/tools/invoke` → `wiki_search` and through `openclaw gateway call wiki.search`. The importer and compiler are the real unsafe-local ones, with no mocks or delays. Fixture: a compiled vault with one `entities/cobalt.md`, then 6,000 new synthetic source files. Source `0` contains "Zirconium publication evidence." Harness and raw captures: #188256 (comment).

| Run | Base 6052fff | This PR |
| --- | --- | --- |
| `wiki_search cobalt`, run 1 | HTTP 500 at 30.5 s, `wiki_search timed out after 30s` | HTTP 200 at 4.9 s, `entities/cobalt.md`, 0 pages imported, no new publication |
| `wiki_search cobalt`, run 2 | HTTP 500 at 30.4 s, `wiki_search timed out after 30s` | HTTP 200 at 4.3 s, `entities/cobalt.md` |
| `wiki_search zirconium` after publication | n/a | HTTP 200 at 8.4 s, the newly imported source page |
| `wiki.search` RPC (`openclaw gateway call`), twice | no answer within 600 s; all 6,000 imported, still no publication | `entities/cobalt.md` in 8.8 s and 7.7 s; after publication `zirconium` returns the new page |

Controls on this PR:
- Cold vault with no compiled snapshot: answers `cobalt` in 4.3 s through the scan fallback.
- Two concurrent searches plus one `wiki.overview` poll: all answer, and exactly one compile is published.
- SIGTERM during the refresh: exit 0 in 2.2 s, no publication, journal unchanged after exit.
- `ingest.autoCompile: false`: the search answers, all 6,000 sources import, and nothing compiles.
- One-shot `openclaw wiki search zirconium`: still waits for import and compile (508 s on a loaded host) and returns the new page.
- Without `runInDetachedAsyncContext`, both runs logged `background source sync failed: Failed to open the plugin state database. | This operation was aborted` and never published.

Unit: `tool.deadline.test.ts` "answers from the current index while the service refreshes" fails on base with `wiki_search timed out after 30s` and passes here. Focused memory-wiki suites pass: 8 files, 95 tests. Local review on the head reports no findings.

## Merge Danger

Two-way door. No config, schema, protocol or stored-data change; a revert restores the awaited sync. Blast radius: memory-wiki search through the agent tool and the `wiki.search` Gateway method while the plugin service runs.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit f9f7bf7)
Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…openclaw#188256)

Root cause: `extensions/memory-wiki/src/tool.ts:174` awaits `syncMemoryWikiImportedSources` (import, then a full compile) inside the 30 s `wiki_search` deadline, and `extensions/memory-wiki/src/gateway.ts:277` awaits the same sync before `wiki.search` with no deadline, so a large pending import fails or stalls searches for pages that are already on disk.

Related: openclaw#187429, openclaw#132296, openclaw#166329

## What Problem This Solves

Fixes: `wiki_search` fails with "wiki_search timed out after 30s", and the `wiki.search` Gateway method hangs, when a large vault has source changes waiting to import and compile. The pages being searched for are already on disk.

## User Impact

Searches answer from the current wiki at once while the Gateway imports and compiles in the background. Content that changed in the sources since the last refresh shows up on the next search, not this one. That one-search delay is the only staleness: pages written with `wiki_apply` are read live, and a vault with no compiled snapshot yet still answers through the existing full scan.

Unchanged: `wiki_get`, `openclaw wiki search`, imports, compile, lint, apply and status still wait for the sync. `ingest.autoCompile: false` still never compiles. A caller with no running wiki service (one-shot hosts) still waits as before.

## Why This Change Was Made

When the wiki service is running, `wiki_search` and `wiki.search` run the query first and then start the service-owned source sync that the Overview and Import Insights dashboards already use (openclaw#132296). That helper moves from `gateway.ts` to `source-sync.ts` as `refreshMemoryWikiImportedSources`. It still single-flights equal requests, queues on the vault mutation lock, is cancelled by the service signal and is joined at shutdown. The refresh starts after the query because a cold read owner activates through the same vault queue, so a refresh started first would block the search.

The helper runs the sync with `runInDetachedAsyncContext`. Without it the built Gateway aborted every refresh after the `/tools/invoke` response with `Failed to open the plugin state database. | This operation was aborted`, so nothing was ever published. The dashboard path on main has the same defect and this fixes it too.

This takes over Baumus's PR. Thanks @Baumus for finding this, carrying the fix in your own deployment since 2026.10.10 and for the real-Gateway proof (openclaw#188256 (comment)), which also found the async-scope abort. Your commits stay in the branch. The commits on top replace the refresh coordinator (60 s freshness window, 5–60 s retry backoff, retry handles), the move to the plugin service scheduler, the query hook, the README section and the test-line allocation with the existing dashboard helper. No new freshness or retry policy is needed: the next search or dashboard poll is the retry, as for dashboards today.

## Evidence

The built Gateway (dist) runs in an isolated profile with a task-owned state, config and port. Requests go through `/tools/invoke` → `wiki_search` and through `openclaw gateway call wiki.search`. The importer and compiler are the real unsafe-local ones, with no mocks or delays. Fixture: a compiled vault with one `entities/cobalt.md`, then 6,000 new synthetic source files. Source `0` contains "Zirconium publication evidence." Harness and raw captures: openclaw#188256 (comment).

| Run | Base fa7a528 | This PR |
| --- | --- | --- |
| `wiki_search cobalt`, run 1 | HTTP 500 at 30.5 s, `wiki_search timed out after 30s` | HTTP 200 at 4.9 s, `entities/cobalt.md`, 0 pages imported, no new publication |
| `wiki_search cobalt`, run 2 | HTTP 500 at 30.4 s, `wiki_search timed out after 30s` | HTTP 200 at 4.3 s, `entities/cobalt.md` |
| `wiki_search zirconium` after publication | n/a | HTTP 200 at 8.4 s, the newly imported source page |
| `wiki.search` RPC (`openclaw gateway call`), twice | no answer within 600 s; all 6,000 imported, still no publication | `entities/cobalt.md` in 8.8 s and 7.7 s; after publication `zirconium` returns the new page |

Controls on this PR:
- Cold vault with no compiled snapshot: answers `cobalt` in 4.3 s through the scan fallback.
- Two concurrent searches plus one `wiki.overview` poll: all answer, and exactly one compile is published.
- SIGTERM during the refresh: exit 0 in 2.2 s, no publication, journal unchanged after exit.
- `ingest.autoCompile: false`: the search answers, all 6,000 sources import, and nothing compiles.
- One-shot `openclaw wiki search zirconium`: still waits for import and compile (508 s on a loaded host) and returns the new page.
- Without `runInDetachedAsyncContext`, both runs logged `background source sync failed: Failed to open the plugin state database. | This operation was aborted` and never published.

Unit: `tool.deadline.test.ts` "answers from the current index while the service refreshes" fails on base with `wiki_search timed out after 30s` and passes here. Focused memory-wiki suites pass: 8 files, 95 tests. Local review on the head reports no findings.

## Merge Danger

Two-way door. No config, schema, protocol or stored-data change; a revert restores the awaited sync. Blast radius: memory-wiki search through the agent tool and the `wiki.search` Gateway method while the plugin service runs.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation extensions: memory-wiki maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant