Skip to content

fix(memory): preserve wiki corpus in direct agent scopes - #133234

Merged
obviyus merged 2 commits into
openclaw:mainfrom
PollyBot13:fix/memory-wiki-registry-lifetime
Aug 30, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
PollyBot13:fix/memory-wiki-registry-lifetime

Conversation

@PollyBot13

@PollyBot13 PollyBot13 commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #133196.

A direct agent turn could bind an empty-base request plugin registry while the active same-workspace Gateway registry still owned a healthy memory-wiki runtime. memory_search then reported wiki: not-registered even though the plugin, vault, and wiki CLI remained healthy.

The first submitted fix copied only the corpus registration. It still dropped the wiki prompt registrations and rejected plugins that canonical config processing had enabled automatically.

Why This Change Was Made

Direct agent scopes now reuse the active root's exact memory sidecar objects without rerunning plugin registration code.

The handoff preserves all three sidecar types registered together by memory-wiki:

  • synchronous prompt guidance;
  • prepared prompt context;
  • corpus search and read.

The boundary stays narrow:

  • require the same resolved workspace;
  • require a loaded root owner;
  • honor canonical auto-enable, global disablement, allow/deny policy, entry disablement, workspace defaults, and bundled defaults;
  • reject a conflicting scoped plugin source;
  • preserve existing request-scoped registrations.

The direct binder carries its prepared metadata snapshot into the activation check. This avoids a second metadata lookup and keeps plugin policy in the existing activation owner.

User Impact

Configured wiki search and wiki prompt guidance remain available in direct agent turns whenever the active same-workspace runtime owns the wiki sidecars. Explicitly disabled, differently scoped, or shadowed plugins remain unavailable.

There is no configuration, schema, SDK, vault-data, or migration change.

Evidence

  • Current-main red: exact be67a8bdf62e04cd3ae4cc531371c5e8e582f390 loaded the real bundled memory-wiki owner and its corpus registration, then returned wiki: not-registered through the production direct-agent binder and Memory Core corpus consumer. Current main has no later behavior change in the four owner files.
  • Submitted-head gap: exact 8aad0f8f5ceb9f990e09c416ae4d10698a0e33bf fixed an explicitly enabled corpus, but a config-driven auto-enabled wiki still returned not-registered and the direct prompt omitted Compiled Wiki.
  • Exact-head green: exact 760e505b29edb8b6c7a5aa11935d9a61777c0c20 returned sources/runtime-proof.md for a unique query and included Compiled Wiki in the direct prompt. Global plugin disablement and another workspace both remained not-registered.
  • Regression proof: the owner integration test failed before the repair because the direct scope returned no wiki prompt lines. The final test covers config-driven auto-enablement, exact root object identity, all three sidecar types, workspace isolation, global disablement, and conflicting-source rejection.
  • Focused tests: 39 test executions passed across runtime-plugins.memory-corpus.integration.test.ts, runtime-plugins.test.ts, and memory-state.test.ts.
  • Sibling proof: context-engine and widget-presenter adoption suites passed before the final source-preserving simplification; the final runtime registry suite covers their composition calls.
  • Static checks: Oxfmt, type-aware Oxlint, deprecated API, plugin boundary, coercion helper, runtime-sidecar loader, import-cycle, conflict-marker, and diff-integrity checks passed. Hosted CI owns the full build and TypeScript checks.
  • Production shape: source +106/-2 (net +104); tests +128/-0. The growth defines one exact owner handoff for three runtime-only sidecar classes plus canonical activation. An attempted reuse of the normal plugin load plan was rejected because it reran plugin registration and broke exact root-object identity.

AI-assisted: yes (Codex).

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Aug 30, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 9:29 AM ET / 13:29 UTC.

ClawSweeper review

What this changes

The PR carries eligible root-owned memory corpus and prompt registrations into same-workspace direct agent scopes without rerunning plugin setup.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open: current main lacks the direct-scope handoff, and this PR remains the concrete linked fix candidate. Source review found no introduced functional or security defect; the adoption is gated by workspace, activation, and source ownership.

Priority: P2
Reviewed head: 760e505b29edb8b6c7a5aa11935d9a61777c0c20

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused root-boundary repair and stated production-path evidence are strong, with moderate added complexity at a plugin-registry lifecycle seam.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured PR body reports exact-head production direct-agent execution through the changed binder and Memory Core, including a returned corpus result and prompt content plus disabled and cross-workspace controls; the integration test independently maps to that owner boundary. Four captured comment bodies were not available and live GitHub was unreachable, but the supplied proof-sufficient record supports this classification.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured PR body reports exact-head production direct-agent execution through the changed binder and Memory Core, including a returned corpus result and prompt content plus disabled and cross-workspace controls; the integration test independently maps to that owner boundary. Four captured comment bodies were not available and live GitHub was unreachable, but the supplied proof-sufficient record supports this classification.
Evidence reviewed 8 items Direct-scope owner boundary: The direct binder deliberately loads with an empty base scope, then binds the resulting registry around the agent run; the PR adds adoption only when an active registry and resolved workspace match.
Canonical memory registration ownership: Memory corpus, synchronous prompt, and prepared prompt registrations are stored on the active plugin registry; the new helper copy-on-writes only those three sidecar collections after checking loaded status, effective activation, and source identity.
Why the scoped registry needs sidecar reuse: The agent load plan selects the configured memory-slot owner and selected runtime owners, while the direct binder supplies an explicit empty base list. Supplemental wiki registrations are therefore not implicitly materialized by that scoped load.
Findings None None.
Security None None.

How this fits together

Direct agent turns build a scoped plugin registry before memory search and prompt assembly consume it. The Gateway root registry holds fully initialized plugin sidecars, which this change conditionally reuses for the direct scope.

flowchart LR
  A[Gateway root plugin registry] --> B[Direct agent entry]
  B --> C[Discovery scoped registry]
  A --> D{Same workspace and plugin enabled?}
  D -->|Yes| E[Reuse memory sidecars]
  D -->|No| C
  E --> F[Memory search and prompt assembly]
  C --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +104, Tests +128. Total +232 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 106 2 +104
Tests 2 128 0 +128
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 234 2 +232

Review metrics

Metric Value Why it matters
Production versus test LOC production +106/-2 (net +104); tests +128/-0 The production growth implements one generic handoff for three registry-owned memory sidecars; the added integration and conflicting-source coverage exercise its eligibility boundaries.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/plugins/memory-state.ts, vector/embedding metadata: src/plugins/memory-state.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Retain the narrow, generic sidecar handoff at the direct-registry boundary, preserving the existing same-workspace, effective-activation, and source-identity controls.

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

Yes—source establishes the path: a direct agent scope starts with an empty base registry while the load plan only selects the memory-slot owner, leaving separately registered wiki sidecars absent. The submitted body also reports an exact-head production-boundary run, but this reviewer did not execute untrusted contributor code.

Is this the best way to solve the issue?

Yes. The repair is at the scoped-registry boundary that loses the registrations, reuses exact root objects without re-running plugin code, and leaves the Memory Core consumer unchanged.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: A configured wiki corpus and its prompt guidance can be unavailable to direct agent turns, with a bounded affected surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured PR body reports exact-head production direct-agent execution through the changed binder and Memory Core, including a returned corpus result and prompt content plus disabled and cross-workspace controls; the integration test independently maps to that owner boundary. Four captured comment bodies were not available and live GitHub was unreachable, but the supplied proof-sufficient record supports this classification.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body reports exact-head production direct-agent execution through the changed binder and Memory Core, including a returned corpus result and prompt content plus disabled and cross-workspace controls; the integration test independently maps to that owner boundary. Four captured comment bodies were not available and live GitHub was unreachable, but the supplied proof-sufficient record supports this classification.

Evidence

What I checked:

  • Direct-scope owner boundary: The direct binder deliberately loads with an empty base scope, then binds the resulting registry around the agent run; the PR adds adoption only when an active registry and resolved workspace match. (src/agents/runtime-plugins.ts:151, 760e505b29ed)
  • Canonical memory registration ownership: Memory corpus, synchronous prompt, and prepared prompt registrations are stored on the active plugin registry; the new helper copy-on-writes only those three sidecar collections after checking loaded status, effective activation, and source identity. (src/plugins/memory-state.ts:127, 760e505b29ed)
  • Why the scoped registry needs sidecar reuse: The agent load plan selects the configured memory-slot owner and selected runtime owners, while the direct binder supplies an explicit empty base list. Supplemental wiki registrations are therefore not implicitly materialized by that scoped load. (src/agents/harness/runtime-plugin-load-plan.ts:319, 760e505b29ed)
  • Consumer and producer agree on the contract: The wiki plugin registers all three sidecars synchronously, while Memory Core returns not-registered when the active registry has no corpus supplements. (extensions/memory-wiki/index.ts:180, 760e505b29ed)
  • Regression coverage: The new integration test uses the real loader fixture and verifies auto-enablement, root object identity, all three sidecars, a different workspace, and global plugin disablement; the focused unit test covers conflicting sources. (src/agents/runtime-plugins.memory-corpus.integration.test.ts:30, 760e505b29ed)
  • Current-main and shipping check: The fetched main revision has the pre-adoption direct binder; the two-dot comparison shows this handoff is introduced by the PR. No release tag contains the unmerged head. (src/agents/runtime-plugins.ts:151, f46f9b5aa39f)

Likely related people:

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

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 (4 earlier review cycles)
  • reviewed 2026-08-30T09:43:20.965Z sha 8aad0f8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T09:51:17.219Z sha 8aad0f8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T10:02:11.792Z sha 8aad0f8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T10:09:24.025Z sha 8aad0f8 :: needs maintainer review before merge. :: none

@PollyBot13

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 30, 2026
@obviyus
obviyus merged commit b4f8510 into openclaw:main Aug 30, 2026
263 checks passed
@obviyus

obviyus commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks @PollyBot13!

Proof: A direct agent turn with the configured bundled memory-wiki plugin found a unique wiki page through Memory Core and retained Compiled Wiki prompt guidance. Global plugin disablement and another workspace both remained unavailable.

  • Bug: Direct agent scopes could hide a healthy wiki corpus and its prompt guidance behind an empty request registry.
  • Fix: The direct registry binder now reuses the active same-workspace runtime's eligible memory sidecars without rerunning plugin setup.

Example

Before After
memory_search returned wiki: not-registered, and the prompt omitted wiki guidance. memory_search returns the matching wiki page, and the prompt includes Compiled Wiki.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…133234)

Direct agent scopes now reuse eligible same-workspace memory sidecars from the active plugin runtime.

This preserves wiki corpus search, prompt guidance, and prepared prompt context without rerunning plugin registration. Disabled, cross-workspace, and conflicting-source owners remain unavailable.

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

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: bundled memory-wiki corpus intermittently disappears from active registry

2 participants