Skip to content

fix(memory-wiki): exclude vault's own pages from unsafe-local import - #125160

Merged
obviyus merged 1 commit into
openclaw:mainfrom
rajmp999:fix/125139-unsafe-local-self-import-loop
Aug 30, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
rajmp999:fix/125139-unsafe-local-self-import-loop

Conversation

@rajmp999

@rajmp999 rajmp999 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #125139

What Problem This Solves

In unsafe-local mode, a backup or mirror of the Memory Wiki vault can sit below a configured scan path. The importer treated each copied generated source page as a new source because the copy had a different canonical path. Repeated import and status runs then created nested unsafe-local- pages without a bound.

Why This Change Was Made

The unsafe-local collector owns source eligibility. It now rejects two forms of self-import before deduplication and persistence:

  • Any source whose canonical path is inside the active vault.
  • Any copied bridge- or unsafe-local- page whose content matches the existing generated-source wrapper contract.

The filename gate limits content parsing to names produced by OpenClaw. A legitimate file with the same prefix remains importable unless it also has the complete generated wrapper. Isolated mode has no local import path. Bridge mode keeps its existing canonical vault containment rule.

User Impact

Unsafe-local import and status runs no longer multiply copied generated vault pages. Legitimate files, including ordinary files named with bridge- or unsafe-local- prefixes, remain eligible.

Evidence

Live filesystem and command-registration proof used the same import, mirror-copy, status, mirror-refresh, and import cycle on both revisions:

Revision First import Status after copied vault Import after refreshed copy
1505218b3e42 (main) 1 artifact 7 generated sources 13 artifacts, 6 new
467c544a03a9 (fixed) 1 artifact 6 generated sources 6 artifacts, 0 new

The six retained artifacts in the fixed run are the legitimate source plus five ordinary vault scaffold or log files from the copied tree. Their generated source pages stay at six after the mirror refresh. The recursive generated pages are excluded.

Regression proof:

  • A physical copy at a different canonical path fails before the fix with 4 artifacts instead of 3, then passes after the fix.
  • An active-vault page configured by its canonical path fails before the fix with 2 artifacts instead of 1, then passes after the fix.
  • node scripts/run-vitest.mjs extensions/memory-wiki/src: 39 files and 466 tests passed.
  • Focused format, Oxlint, max-lines, assertion-safety, dead-export, import-cycle, and conflict-marker checks passed.
  • Production delta: +19 lines. Test delta: +68 lines. The production growth adds canonical containment and reuses the existing generated-page classifier; filename prefiltering avoids rereading normal Markdown sources.

Hosted CI owns TypeScript type-check and build validation for this host.


This PR was drafted with AI assistance (Claude). The maintainer repair preserved Raj Muppala's authorship and replaced the stale patch with the current-main implementation and proof.

@clawsweeper

clawsweeper Bot commented Aug 17, 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 P2 Normal backlog priority with limited blast radius. 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. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 10:18 AM ET / 14:18 UTC.

ClawSweeper review

What this changes

This PR prevents unsafe-local Memory Wiki imports from re-ingesting pages inside the active vault and copied generated bridge or unsafe-local source pages.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: fetched current main still sends every discovered unsafe-local file directly into the deduped artifact set, while this PR adds the missing pre-persistence eligibility checks and focused regressions. Recorded filesystem before/after evidence supports the fix; exact-head hosted validation must finish cleanly before merge. Likely related people: Vincent Koc (original unsafe-local work), Peter Steinberger (recent Memory Wiki work), and TurboTheTurtle (analogous bridge repair).

Priority: P2
Reviewed head: f827dc1e14976005f1c7f9d9ff89c3005c73b6a3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused collector-boundary changes, regression coverage, and recorded after-fix filesystem behavior support a normal good-quality fix.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The changed production owner is the unsafe-local collector; the complete PR body supplies an after-fix physical filesystem mirror-copy/status/import cycle showing copied generated pages no longer create new artifacts, alongside focused owner-boundary regressions.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed production owner is the unsafe-local collector; the complete PR body supplies an after-fix physical filesystem mirror-copy/status/import cycle showing copied generated pages no longer create new artifacts, alongside focused owner-boundary regressions.
Evidence reviewed 7 items Current-main gap: The fetched main collector adds every scanned artifact to the deduped set without either containment or generated-page filtering; the PR is therefore not redundant.
Owner-boundary repair: The introduced collector checks canonical containment before deduplication and recognizes copied generated pages only when both the generated filename family and existing wrapper contract match.
Entrypoint and sibling invariant: The shared source-sync entrypoint dispatches unsafe-local mode to this collector, while bridge mode already performs the same canonical vault-containment exclusion.
Findings None None.
Security None None.

How this fits together

Memory Wiki’s unsafe-local importer scans operator-configured local paths and turns eligible files into generated vault source pages. The resulting source state is used by later status, compile, and import operations, so eligibility must be decided before sync-state writes.

flowchart LR
A[Configured local paths] --> B[Unsafe-local importer]
B --> C[Canonical path and generated-page checks]
C --> D[Eligible source artifacts]
D --> E[Source sync state]
E --> F[Generated vault pages]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head hosted validation is not complete, and the supplied check state includes a failed check-lint run; do not merge until that failure is resolved and required checks finish.
  • Resolve merge risk (P1) - The bug fix adds 26 production lines, but the two filters belong in the single collector before deduplication and state writes; duplicating them in command callers would weaken that owner boundary.
  • Complete next step (P2) - No discrete repair finding remains; resolve the current exact-head validation state through the normal PR workflow.
Agent review details

Security

None.

PR surface

Source +26, Tests +68. Total +94 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 26 0 +26
Tests 1 68 0 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 94 0 +94

Review metrics

Metric Value Why it matters
Production vs test LOC production +26, tests +68 The production growth is limited to collector-boundary eligibility filtering, with two behavior regressions covering the prior self-import paths.

Stored data model

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

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #125139
Summary: This PR directly implements the unsafe-local self-import bug reported by the canonical open issue; the earlier bridge repair is analogous but covers a distinct import mode.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the two pre-deduplication eligibility checks in the unsafe-local collector, then merge after exact-head validation is clean so the linked bug can close through the PR.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the two pre-deduplication eligibility checks in the unsafe-local collector, then merge after exact-head validation is clean so the linked bug can close through the PR.

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

Yes: the pre-fix collector’s unconditional deduplication is visible in fetched main, and the PR body records a physical mirror-copy cycle that changes from recursive growth to stable imports after the new filters.

Is this the best way to solve the issue?

Yes: filtering at the collector before deduplication and source-state persistence is the narrow owner-boundary fix; live-vault containment alone would not exclude copied generated pages at a different canonical path.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the unsafe-local collector; the complete PR body supplies an after-fix physical filesystem mirror-copy/status/import cycle showing copied generated pages no longer create new artifacts, alongside focused owner-boundary regressions.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed production owner is the unsafe-local collector; the complete PR body supplies an after-fix physical filesystem mirror-copy/status/import cycle showing copied generated pages no longer create new artifacts, alongside focused owner-boundary regressions.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded existing unsafe-local import defect that can accumulate unwanted generated wiki pages but has no emergency availability or security signal.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed production owner is the unsafe-local collector; the complete PR body supplies an after-fix physical filesystem mirror-copy/status/import cycle showing copied generated pages no longer create new artifacts, alongside focused owner-boundary regressions.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the unsafe-local collector; the complete PR body supplies an after-fix physical filesystem mirror-copy/status/import cycle showing copied generated pages no longer create new artifacts, alongside focused owner-boundary regressions.

Evidence

What I checked:

  • Current-main gap: The fetched main collector adds every scanned artifact to the deduped set without either containment or generated-page filtering; the PR is therefore not redundant. (extensions/memory-wiki/src/unsafe-local.ts:109, 0a6c013be5f5)
  • Owner-boundary repair: The introduced collector checks canonical containment before deduplication and recognizes copied generated pages only when both the generated filename family and existing wrapper contract match. (extensions/memory-wiki/src/unsafe-local.ts:114, f827dc1e1497)
  • Entrypoint and sibling invariant: The shared source-sync entrypoint dispatches unsafe-local mode to this collector, while bridge mode already performs the same canonical vault-containment exclusion. (extensions/memory-wiki/src/source-sync.ts:54, f827dc1e1497)
  • Containment contract: The plugin SDK path guard treats a descendant as inside its root; its strict variant explicitly excludes equality, so a directly configured vault page is also excluded. (src/infra/path-guards.ts:15, f827dc1e1497)
  • Regression coverage: The two new owner-boundary tests cover a copied generated page at a different canonical path and a configured page inside the active vault; both assertions would fail against the pre-PR collector. (extensions/memory-wiki/src/unsafe-local.test.ts:209, f827dc1e1497)
  • After-fix behavior proof: The complete PR body records the same physical mirror-copy/status/import cycle on the merge base and head: generated sources grow from 7 to 13 before the fix but remain at 6 with zero new imports after it. (f827dc1e1497)

Likely related people:

  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • TurboTheTurtle: 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.

  • Resolve the current check-lint failure and wait for exact-head required validation to complete before merge.

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 (5 earlier review cycles)
  • reviewed 2026-08-17T08:05:21.564Z sha 4353fb115777e1dd40d07393b9ce327bbdda7612 :: needs real behavior proof before merge. :: [P1] Handle copied vault pages, not only the live vault root
  • reviewed 2026-08-20T07:48:50.076Z sha 4353fb115777e1dd40d07393b9ce327bbdda7612 :: needs real behavior proof before merge. :: [P1] Handle copied vault pages, not only the live vault root
  • reviewed 2026-08-23T21:10:20.330Z sha 4353fb115777e1dd40d07393b9ce327bbdda7612 :: needs real behavior proof before merge. :: [P1] Exclude copied vault trees, not only the live vault root
  • reviewed 2026-08-29T21:21:55.740Z sha 4353fb115777e1dd40d07393b9ce327bbdda7612 :: needs real behavior proof before merge. :: [P1] Rebase onto the current containment API | [P1] Detect copied generated source pages
  • reviewed 2026-08-29T21:29:10.408Z sha 4353fb115777e1dd40d07393b9ce327bbdda7612 :: needs real behavior proof before merge. :: [P1] Filter copied vault pages, not only the live vault root

@obviyus
obviyus force-pushed the fix/125139-unsafe-local-self-import-loop branch from 4353fb1 to f827dc1 Compare August 30, 2026 14:09
@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: 🧂 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. labels Aug 30, 2026
@obviyus
obviyus force-pushed the fix/125139-unsafe-local-self-import-loop branch from f827dc1 to 467c544 Compare August 30, 2026 14:22
@obviyus

obviyus commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks @rajmp999!

Proof: With one legitimate source, copying the generated vault into the configured unsafe-local tree made wiki status expose 7 generated sources and the next import grow to 13 artifacts on current main. The repaired head stays at 6 artifacts after the same mirror refresh and creates 0 new pages.

  • Bug: Unsafe-local collection identified sources only by canonical file path, so copied generated pages received new identities and recursively re-entered the vault.
  • Fix: The collector now rejects the active vault by canonical containment and recognizes copied generated source pages before persistence, while ordinary files with similar names remain eligible.
  • Tests: node scripts/run-vitest.mjs extensions/memory-wiki/src passed 39 files and 466 tests.
  • Gates: Exact-head openclaw/ci-gate passed in https://github.com/openclaw/openclaw/actions/runs/33316689480, and local ClawSweeper passed at tier B with no findings or rank-up moves.

Example

Before After
A refreshed vault copy grows nested unsafe-local- pages on status or import. Generated page count stays stable; legitimate sources remain imported.

@obviyus
obviyus merged commit aea8ee8 into openclaw:main Aug 30, 2026
104 of 106 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
Prevent unsafe-local scans from importing the active vault or copied generated source pages.

Reuse canonical containment and the existing generated-page classifier while keeping legitimate files eligible.

Closes openclaw#125139.

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

extensions: memory-wiki 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: S 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]: memory-wiki unsafe-local import re-imports its own vault pages — the loop fixed for bridge mode in #95666 is not covered

2 participants