Skip to content

fix(memory-wiki): scope wiki_status bridgePublicArtifactCount to calling agent - #103196

Closed
SunnyShu0925 wants to merge 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/wiki-status-agent-scope-103088
Closed

SunnyShu0925 wants to merge 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/wiki-status-agent-scope-103088

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

wiki_status and openclaw wiki doctor leak the existence of another agent's bridged memory artifacts via an unscoped bridgePublicArtifactCount.

  • Problem: resolveMemoryWikiStatus calls listActiveMemoryPublicArtifacts({ cfg }) with no agent identity, so bridgePublicArtifactCount reports every configured agent's artifacts process-wide. An agent with zero memory of its own learns whether another agent has bridge artifacts from the count and the derived bridge-artifacts-missing warning.
  • Solution: Thread the calling agent's agentId into the status resolver and filter bridgePublicArtifactCount by the artifact's existing agentIds field. The data needed for scoping already exists on every artifact — only the filter was missing.
  • What changed: createWikiStatusTool now accepts WikiToolMemoryContext (matching sibling wiki_search/wiki_get), passes agentId to resolveMemoryWikiStatus, which filters the artifact count by artifact.agentIds.includes(agentId).
  • What did NOT change: CLI openclaw wiki status/doctor (operator tools, no agentId → global count unchanged), gateway methods, bridge sync, plugin SDK, any other tool.

Change Type (select all)

  • Security hardening

Scope (select all)

  • Integrations
  • Memory / storage

Linked Issue/PR

Motivation

Multi-agent setups with bridge-enabled memory-wiki leak cross-agent artifact existence metadata through the status/diagnostics path. Each artifact already carries agentIds from discovery, but the status resolver ignores it and reports the process-wide total.

Evidence

Behavior addressed: wiki_status agent tool now reports bridgePublicArtifactCount scoped to the calling agent. Operator CLI wiki doctor remains global.

Real environment tested: origin/main commit 8e25c36, Node 22.19.0, Linux (x86_64), extensions/memory-wiki plugin.

Exact steps or command run after this patch:

$ pnpm test:serial extensions/memory-wiki/src/proof-103196.test.ts -- --reporter=verbose

 RUN  v4.1.9

stdout | proof: PR #103196 bridgePublicArtifactCount scoping > global (no agentId) = count 2
  global bridgePublicArtifactCount = 2
  global warnings = (none)

stdout | proof: PR #103196 bridgePublicArtifactCount scoping > agent main = count 1
  main bridgePublicArtifactCount = 1
  main warnings = (none)

stdout | proof: PR #103196 bridgePublicArtifactCount scoping > agent secondary = count 1
  secondary bridgePublicArtifactCount = 1
  secondary warnings = (none)

stdout | proof: PR #103196 bridgePublicArtifactCount scoping > agent third (no artifacts) = count 0 + warning
  third bridgePublicArtifactCount = 0
  third warnings = bridge-artifacts-missing

 ✓ |extension-memory| proof-103196.test.ts > ... > global (no agentId) = count 2 23ms
 ✓ |extension-memory| proof-103196.test.ts > ... > agent main = count 1 3ms
 ✓ |extension-memory| proof-103196.test.ts > ... > agent secondary = count 1 3ms
 ✓ |extension-memory| proof-103196.test.ts > ... > agent third (no artifacts) = count 0 + warning 4ms

 Test Files  1 passed (1)
      Tests  4 passed (4)

$ pnpm test:serial extensions/memory-wiki/src/status.test.ts
> Test Files  1 passed (1)
>      Tests  11 passed (11)

The new test filters bridgePublicArtifactCount by calling agentId covers 5 scenarios:

Caller agentId Artifact agentIds Before (count) After (count) bridge-artifacts-missing
"main" ["main"] + ["secondary"] 2 1 ❌ (not present)
"secondary" ["main"] + ["secondary"] 2 1 ❌ (not present)
"third-agent" ["main"] + ["secondary"] 2 0 ✅ (present)
(undefined / CLI) ["main"] + ["secondary"] 2 2 (unchanged) ❌ (not present)
"main" ["main"] 1 1 (unchanged) ❌ (not present)

Observed result after fix:

  • An agent calling wiki_status sees only its own bridge artifact count
  • An agent with no artifacts sees bridge-artifacts-missing warning (previously suppressed by other agents' artifacts)
  • CLI openclaw wiki status/doctor (no agentId) keeps the global count unchanged

What was not tested: The memory_get({corpus: "all"}) corpus-supplement fallback path; interaction with memory-lancedb or custom bridge providers (both delegate to the same listMemoryHostPublicArtifacts which populates agentIds); end-to-end gateway routing of wiki.status.

Root Cause (if applicable)

extensions/memory-wiki/src/status.ts:213-223 calls listActiveMemoryPublicArtifacts({ cfg }) with no agent identity. The derived warning at status.ts:164-175 inherits the same unscoped total. The createWikiStatusTool at tool.ts:117 had no memoryContext parameter to thread a calling-agent id, unlike sibling wiki_search/wiki_get.

Regression Test Plan (if applicable)

Added filters bridgePublicArtifactCount by calling agentId in status.test.ts covering 5 scenarios: own-artifact caller, other-agent caller, no-match caller, undefined agentId (CLI path), and correct warning behavior.

User-visible / Behavior Changes

  • wiki_status tool output: bridgePublicArtifactCount now reflects only the calling agent's artifacts
  • bridge-artifacts-missing warning now correctly appears when the calling agent has no artifacts, even if other agents have exported artifacts
  • CLI openclaw wiki status/doctor output: unchanged

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? Yes: wiki_status output changes (scoped vs global count)
  • Data access scope changed? Yes: cross-agent existence leak closed

Human Verification (required)

  • Verified scenarios: 5-scenario matrix above covers own-agent, other-agent, no-match, CLI-global
  • Edge cases checked: empty agentIds array, undefined agentId, multiple artifacts per agent
  • What you did NOT verify: custom bridge providers that omit agentIds (would be counted as 0 for any scoped caller)

Best-fix Verdict

  • Best fix: Yes — threads agent identity at the tool boundary (same pattern as sibling tools), filters at the caller boundary rather than pushing scope into the plugin SDK.
  • Refactor needed: No. The sibling memory-wiki vault-page reads have zero agent/session scoping, letting a sandboxed sub-agent read another agent's bridged memory content #103087 content-disclosure issue shares the same root cause but requires a larger query-pipeline change; this fix is the correct incremental step for the status/diagnostics path.
  • Alternative considered: Pushing agentId into listActiveMemoryPublicArtifacts SDK — would require changing the provider contract for all bridge implementations. The current approach (post-filter at the caller) is minimal and safe.

AI Assistance 🤖

  • AI-assisted: Yes
  • Co-Authored-By: deepseek-v4-flash [email protected]
  • Human confirmed understanding of code changes: Yes

Risks and Mitigations

Highest risk area: Third-party bridge providers that do not populate agentIds on their public artifacts would see those artifacts excluded from any agent-scoped status query. Mitigation: all built-in providers (memory-core, memory-lancedb) delegate to listMemoryHostPublicArtifacts which correctly populates agentIds. The CLI/operator path (no agentId) always returns the global count unaffected.

Compatibility: Fully backward-compatible. agentId is optional; callers that omit it (CLI operator, gateway, any existing code) get the exact same behavior as before.

Fixes #103088

…ing agent

wiki_status and openclaw wiki doctor reported bridgePublicArtifactCount from
all active memory plugins process-wide, without filtering by the caller's
agentId. Each artifact record already carries an agentIds[] field, but
resolveMemoryWikiStatus called listActiveMemoryPublicArtifacts({ cfg }) with
no agent identity, so an agent with zero memory of its own could learn
whether another agent had bridged artifacts.

Fix: thread agentId through createWikiStatusTool (via WikiToolMemoryContext,
matching the sibling wiki_search/wiki_get pattern), pass it to
resolveMemoryWikiStatus, and filter bridgePublicArtifactCount to artifacts
whose agentIds include the caller. Operator/CLI callers omit agentId to
preserve the global count.

Refs: openclaw#103088

Co-Authored-By: deepseek-v4-flash <[email protected]>
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 10, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

steipete added a commit that referenced this pull request Jul 10, 2026
* feat(memory-wiki): isolate per-agent vaults

Refs #63829.

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

* fix(memory-wiki): scope agent status metadata

Refs #103088 and #103196.

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

---------

Co-authored-by: SunnyShu <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

Thanks, @SunnyShu0925. The caller-scoped status behavior landed in canonical PR #103349 as 98b8c8c4ae29.

That PR also introduced per-agent vault routing across the same entrypoint/status surfaces, so this branch no longer applies cleanly as a separate change. Your artifact-ownership approach was adapted, both landed commits preserve your co-author credit, and the final behavior keeps operator status global while filtering agent-tool status. Closing as superseded by the landed canonical implementation.

@steipete steipete closed this Jul 10, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
* feat(memory-wiki): isolate per-agent vaults

Refs openclaw#63829.

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

* fix(memory-wiki): scope agent status metadata

Refs openclaw#103088 and openclaw#103196.

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

---------

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wiki_status leaks the existence of another agent's bridged memory artifacts via an unscoped count

2 participants