Skip to content

fix: load all plugins for wiki/memory CLI + preserve memory capability during snapshot loads#68041

Closed
HongzhuLiu wants to merge 3 commits into
openclaw:mainfrom
HongzhuLiu:fix/load-plugins-for-wiki-memory-cli
Closed

fix: load all plugins for wiki/memory CLI + preserve memory capability during snapshot loads#68041
HongzhuLiu wants to merge 3 commits into
openclaw:mainfrom
HongzhuLiu:fix/load-plugins-for-wiki-memory-cli

Conversation

@HongzhuLiu

@HongzhuLiu HongzhuLiu commented Apr 17, 2026

Copy link
Copy Markdown

Summary

Two related bugs that caused wiki bridge to persistently show 0 artifacts and delete all imported pages:

  1. CLI plugin loading — Plugin CLI commands like wiki bridge import depend on cross-plugin capabilities (e.g. memory-core must be loaded for artifact enumeration). Without loadPlugins: "always", only the command-owning plugin was loaded.

  2. Gateway capability loss — Snapshot and error-recovery paths in loadOpenClawPlugins restored all memory plugin state fields except capability. This caused memoryPluginState.capability to be set to undefined whenever a non-activate plugin load occurred, making listActiveMemoryPublicArtifacts() return an empty array. Wiki bridge then interpreted this as "all artifacts removed" and deleted all previously imported pages.

Root Cause

Commit 1: src/cli/command-catalog.ts was missing loadPlugins: "always" entries for wiki and memory command paths.

Commit 2: src/plugins/loader.ts saved and restored previousMemory{FlushPlanResolver,PromptBuilder,CorpusSupplements,PromptSupplements,Runtime} but omitted previousMemoryCapability. When restoreMemoryPluginState received no capability field, it set it to undefined, erasing the publicArtifacts registration from memory-core.

Fix

Commit 1: Add loadPlugins: "always" for wiki and memory command paths in the command catalog.

Commit 2: Save getMemoryCapabilityRegistration() before each plugin register call and pass it back via restoreMemoryPluginState({ capability: previousMemoryCapability, ... }) in both the !shouldActivate and error-recovery paths.

Test plan

  • openclaw wiki bridge import loads memory-core and returns 193 artifacts across 2 workspaces
  • openclaw memory promote works correctly with all plugins loaded
  • Gateway runtime: wiki_status shows 193 exported artifacts (was 0 before fix)
  • Wiki bridge sync no longer deletes pages after snapshot plugin loads
  • memory-state.test.ts — 11/11 tests pass
  • All repo checks pass (pnpm check)

🤖 Generated with Claude Code

Plugin CLI commands like `wiki bridge import` depend on cross-plugin
capabilities (memory-core must be loaded for artifact enumeration).
Without `loadPlugins: "always"`, only the command-owning plugin was
loaded, causing `listActiveMemoryPublicArtifacts()` to return an empty
list and bridge sync to delete all wiki pages.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels Apr 17, 2026
@greptile-apps

greptile-apps Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds loadPlugins: "always" to the wiki and memory command paths in the CLI command catalog, matching the pattern already used by agent, message, channels, directory, agents, and configure. This fixes a production regression where wiki bridge import would see 0 artifacts because memory-core was not loaded under the default "never" policy.

Confidence Score: 5/5

Safe to merge — minimal, targeted one-file fix that follows the established catalog pattern and addresses a confirmed production data-loss incident.

The change is two lines, follows an identical pattern already used by six other commands, and the PR description includes direct verification of the fix (186 artifacts returned after the change vs. 0 before). No logic, tests, or interfaces are modified.

No files require special attention.

Reviews (1): Last reviewed commit: "fix: load all plugins for wiki and memor..." | Re-trigger Greptile

HongzhuLiu and others added 2 commits April 17, 2026 18:57
Snapshot and error-recovery paths in loadOpenClawPlugins restored all
memory plugin state fields except capability. This caused
memoryPluginState.capability to be set to undefined whenever a
non-activate plugin load occurred, which made
listActiveMemoryPublicArtifacts return an empty array and wiki bridge
delete all imported pages.

Save and restore previousMemoryCapability alongside the other fields
so publicArtifacts survives snapshot loads.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@HongzhuLiu HongzhuLiu changed the title fix: load all plugins for wiki and memory CLI commands fix: load all plugins for wiki/memory CLI + preserve memory capability during snapshot loads Apr 17, 2026
@zwj0117

zwj0117 commented Apr 19, 2026

Copy link
Copy Markdown

We hit the exact same bug on OpenClaw v2026.4.15. wiki bridge import always returns 0 artifacts even though our workspace has MEMORY.md and a populated memory/ directory. Confirmed both CLI and gateway RPC (openclaw gateway call wiki.bridge.import) return empty artifact lists.

Root cause matches what this PR fixes: memoryPluginState.capability (which holds publicArtifacts.listArtifacts) is never registered during plugin load, so listActiveMemoryPublicArtifacts returns [].

Current workaround: switching vaultMode to unsafe-local with explicit paths works fine and gives us 118 imported wiki source pages. Looking forward to this landing so we can use bridge mode again.

@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group cheerful-ox-0bzt

Title: Open PR duplicate: memory capability lost across plugin scopes

Number Title
#68041* fix: load all plugins for wiki/memory CLI + preserve memory capability during snapshot loads
#69458 fix(memory): keep active memory capability visible across plugin scopes

* This PR

@clawsweeper

clawsweeper Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Codex automated review: keeping this open.

Current main only partially covers this PR. The loader-side memory capability preservation and bridge no-prune safety are present, but the cold openclaw wiki bridge import CLI path can still load only the memory-wiki plugin and call the in-process bridge sync without registering the active memory plugin's public-artifacts capability. This PR should stay open for maintainer reconciliation, but it should not merge unchanged.

Best possible solution:

Keep this PR open for maintainer reconciliation. Rebase it onto current main, drop the loader hunk already covered there, and replace or justify the broad command-catalog preload with a narrow tested fix: either include the configured active memory slot plugin for wiki primary CLI loads while honoring slots.memory = none and allow/disable rules, or route wiki bridge import through the existing wiki.bridge.import gateway RPC. Add focused regression coverage in src/plugins/cli.test.ts and/or extensions/memory-wiki/src/cli.test.ts, then close this PR only after the chosen canonical PR lands or this PR is updated to that shape.

What I checked:

  • Current main still has no wiki/memory startup preload policy: The command catalog lists explicit preload policies for command roots such as agent, channels, directory, and agents, but there is no wiki or memory entry on current main. Unmatched command paths inherit the default loadPlugins: "never" policy. (src/cli/command-catalog.ts:34, 66f4b52db31b)
  • Default policy prevents startup plugin loading for unmatched commands: resolveCliCommandPathPolicy starts from loadPlugins: "never"; shouldLoadPluginsForCommandPath only returns true for always or non-JSON text-only. Without a wiki/memory catalog entry, startup plugin preloading still does not happen for those roots. (src/cli/command-path-policy.ts:5, 66f4b52db31b)
  • Scoped plugin CLI loading still does not append the memory slot: Primary-command scoped loading resolves manifest activation ids for the primary command and passes them as onlyPluginIds; there is no current code that appends the configured plugins.slots.memory id for wiki loads. The manifests show memory-wiki owns the wiki command alias while memory-core advertises cliCommand: "memory", so a wiki-scoped cold CLI load does not inherently include memory-core. (src/plugins/cli-registry-loader.ts:51, 66f4b52db31b)
  • Bridge import still runs in-process and depends on active memory artifacts: runWikiBridgeImport still calls syncMemoryWikiImportedSources directly. The bridge path reads artifacts through listActiveMemoryPublicArtifacts, which returns an empty list when no memory capability is registered in the current process. That preserves the 0-artifact failure mode even though pruning is now skipped when the capability is absent. (extensions/memory-wiki/src/cli.ts:502, 66f4b52db31b)
  • Loader-side capability preservation is already on main: Current main stores/restores memoryCapability in the plugin loader cache and snapshots previousMemoryCapability around non-activating and rollback loads. Regression tests cover cached capability restoration and preservation across activate:false snapshot loads, so the loader hunk in this PR is already redundant. (src/plugins/loader.ts:216, 66f4b52db31b)
  • User-facing docs still describe bridge import as importing active memory plugin artifacts: The CLI docs say wiki bridge import imports public memory artifacts from the active memory plugin into bridge-backed source pages. The current in-process cold CLI path does not reliably satisfy that contract when the active memory plugin was not registered. Public docs: docs/cli/wiki.md. (docs/cli/wiki.md:163, 66f4b52db31b)

Remaining risk / open question:

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 66f4b52db31b.

@vincentkoc

Copy link
Copy Markdown
Member

Thanks for digging into this. We landed the narrower Gateway-routing fix in #72615, which closes the Memory Wiki bridge 0-artifacts reports without widening CLI plugin loading or loader state behavior here. Closing this as superseded by that PR.

@vincentkoc vincentkoc closed this Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants