Skip to content

fix(memory): skip memory-wiki vault subtree in workspace memory scan (#95657) - #95670

Closed
hansraj316 wants to merge 1 commit into
openclaw:mainfrom
hansraj316:fix/memory-wiki-self-import-loop-95657
Closed

hansraj316 wants to merge 1 commit into
openclaw:mainfrom
hansraj316:fix/memory-wiki-self-import-loop-95657

Conversation

@hansraj316

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #95657. With memory-wiki in bridge mode and the vault inside the workspace memory/ directory (the default layout), the recursive memory scan picked up the wiki's own bridge-generated sources/*.md pages as if they were user memory. Both consumers of that scan — the lancedb embedding indexer and the wiki bridge import — then re-ingested the wiki's own output, an unbounded self-import loop. Reporter saw the SQLite index grow to 1.5 GB in ~2 months (82% bridge duplicates), regenerating within hours of manual cleanup.

Why This Change Was Made

bridge.indexMemoryRoot: false only covers memory-root files, not the wiki vault subtree. Rather than plumb the vault path into the core scanner, the scan now detects a wiki vault generically by its .openclaw-wiki marker directory and skips that whole subtree. This breaks the cycle at its source — wiki sources are never exposed as memory artifacts, so neither the indexer nor the bridge re-ingests them — regardless of where the vault is placed inside memory/.

User Impact

No more unbounded SQLite growth or duplicate bridge-workspace-<id>-* regeneration for bridge-mode wikis nested under memory/. No config change; the fix is automatic on next index. Purely removes waste — no user data is dropped.

Evidence

  • src/plugin-sdk/memory-host-core.ts: listMarkdownFilesRecursive returns early on a .openclaw-wiki marker; both listMemoryHostPublicArtifacts (indexer) and listActiveMemoryPublicArtifacts (bridge) funnel through it.
  • New test in src/plugin-sdk/memory-host-core.test.ts asserts a vault nested under memory/wiki is skipped while sibling real notes are still indexed.
  • pnpm test src/plugin-sdk/memory-host-core.test.ts ✅ (5 passed).

…penclaw#95657)

A bridge-mode wiki vault placed inside workspace memory/ (the default
layout) had its bridge-generated sources/ pages picked up by the
recursive memory scan. Both consumers of that scan -- the lancedb
embedding indexer and the wiki bridge import -- then re-ingested the
wiki's own output, an unbounded self-import loop that bloated the
SQLite index. Detect a vault by its .openclaw-wiki marker and skip the
whole subtree during the scan, breaking the cycle at its source.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d9a32f48c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +31 to +33
if (entries.some((entry) => entry.isDirectory() && entry.name === WIKI_VAULT_MARKER)) {
return [];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Skip wiki vaults in the indexer scan too

In the bridge-mode nested vault case, this skip only affects listMemoryHostPublicArtifacts, but the memory-core embedding indexer still discovers files via listMemoryFiles (packages/memory-host-sdk/src/host/internal.ts:139-146) and syncMemoryFiles calls that scanner (extensions/memory-core/src/memory/manager-sync-ops.ts:1789-1793). That walker still descends every directory except .openclaw-repair, so memory/wiki/sources/*.md remains indexed and the SQLite growth loop can continue even though bridge import no longer sees those artifacts. Please share the vault-skip predicate with the indexer scan as well.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: the merged bridge-side fix now owns the linked self-import loop, and this branch is a partial SDK-only duplicate that would leave the package SQLite indexer scanner unchanged.

Canonical path: Keep the merged bridge-side fix as canonical; handle any separate desire to exclude wiki vaults from SQLite memory indexing as a focused scanner-wide follow-up.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Keep the merged bridge-side fix as canonical; handle any separate desire to exclude wiki vaults from SQLite memory indexing as a focused scanner-wide follow-up.

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

Yes from source for the scanner split: current main and this PR separate the SDK public-artifact walker from package listMemoryFiles, which the SQLite sync path still uses. I did not run the long-term DB growth scenario in this read-only review.

Is this the best way to solve the issue?

No. The merged bridge-side PR is the canonical fix for the self-import loop, while this branch is only a partial SDK scanner change and does not cover the package-level indexer path.

Security review:

Security review cleared: The diff only changes TypeScript filesystem scanning logic and a colocated unit test; it does not touch dependencies, workflows, secrets, downloads, or package execution surfaces.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • TurboTheTurtle: Authored the merged bridge-side candidate that now owns the linked memory-wiki self-import fix on current main. (role: merged fix author; confidence: high; commits: 9deca15bbb4f, 33b23214d945; files: extensions/memory-wiki/src/bridge.ts, extensions/memory-wiki/src/bridge.test.ts)
  • vincentkoc: Merged the canonical PR and authored the final vault-root adjustment used by the current bridge filter. (role: merger and recent area contributor; confidence: high; commits: 0f7462954775, 33b23214d945; files: extensions/memory-wiki/src/bridge.ts, extensions/memory-wiki/src/bridge.test.ts)

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

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 22, 2026
@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: memory-wiki bridge mode creates recursive self-import loop — wiki sources indexed by memory indexer and re-imported as bridge artifacts

1 participant