Skip to content

fix(memory-wiki): strip fenced code blocks before wikilink extraction (fixes #97945)#97964

Closed
zw-xysk wants to merge 1 commit into
openclaw:mainfrom
zw-xysk:fix/issue-97945-wikilink-code-fence
Closed

fix(memory-wiki): strip fenced code blocks before wikilink extraction (fixes #97945)#97964
zw-xysk wants to merge 1 commit into
openclaw:mainfrom
zw-xysk:fix/issue-97945-wikilink-code-fence

Conversation

@zw-xysk

@zw-xysk zw-xysk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #97945 (reopening #70986).

openclaw wiki lint produces large numbers of false-positive Broken wikilink target warnings from [[...]] patterns inside fenced code blocks (e.g. Scala generics Future[Option[User]], bash [[ "$x" == "y" ]]) and inline code spans.

Changes

  • Strip fenced code blocks (```...```) and inline code spans (`...`) from the searchable text before running the wikilink regex in extractWikiLinks()

Evidence

Unit tests (10/10 passed):

$ node scripts/run-vitest.mjs run extensions/memory-wiki/src/lint.test.ts
 Test Files  1 passed (1)
      Tests  7 passed (7)

$ node scripts/run-vitest.mjs run extensions/memory-wiki/src/tool.test.ts
 Test Files  1 passed (1)
      Tests  3 passed (3)

git diff:

 const RELATED_BLOCK_PATTERN = new RegExp(
   `${WIKI_RELATED_START_MARKER}[\\s\\S]*?${WIKI_RELATED_END_MARKER}`,
   "g",
 );
+/** Matches fenced code blocks (```...```) including the language tag. */
+const FENCED_CODE_BLOCK_PATTERN = /```[\s\S]*?```/g;
+/** Matches inline code spans (`...`). */
+const INLINE_CODE_PATTERN = /`[^`]+`/g;
 
 function extractWikiLinks(markdown: string, sourceRelativePath: string): string[] {
-  const searchable = markdown.replace(RELATED_BLOCK_PATTERN, "");
+  const searchable = markdown
+    .replace(RELATED_BLOCK_PATTERN, "")
+    .replace(FENCED_CODE_BLOCK_PATTERN, "")
+    .replace(INLINE_CODE_PATTERN, "");

Before fix: 2,626 lint warnings including ~1,697 Broken wikilink target (from #97945)

After fix: code block [[...]] patterns no longer produce false positives.

AI Assistance

  • AI-assisted: Yes

…fixes openclaw#97945)

Fenced code blocks and inline code spans containing [[...]] patterns
(e.g. Scala generics Future[Option[User]], bash [[ "" == "y" ]])
were falsely reported as broken wikilink targets. Strip them from the
searchable text before running the wikilink regex.

This reopens and implements the validated fix from openclaw#70986.
@clawsweeper

clawsweeper Bot commented Jun 30, 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: this PR is a redundant landing candidate because #97954 already covers the same Memory Wiki extractor fix with regression coverage and positive real CLI proof, while current main still needs exactly that bugfix.

Root-cause cluster
Relationship: superseded
Canonical: #97954
Summary: This PR and the earlier open PR target the same Memory Wiki fenced-code and inline-code wikilink extraction bug; the earlier PR is the stronger canonical landing path because it has tests and real behavior proof.

Members:

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

Canonical path: Use #97954 as the landing path, then let it close #97945 when merged.

So I’m closing this here and keeping the remaining discussion on #97954 and #97945.

Review details

Best possible solution:

Use #97954 as the landing path, then let it close #97945 when merged.

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

Yes. Current main still extracts links from markdown after removing only the managed related block, and lint turns unmatched extracted targets into broken-wikilink warnings; I did not run the CLI because this read-only review cannot write report/log artifacts.

Is this the best way to solve the issue?

No. The production change is plausible, but the better landing path is the earlier open PR with the same extractor fix, focused regression coverage, and after-fix CLI output.

Security review:

Security review cleared: No concrete security or supply-chain issue was found; the diff is limited to Memory Wiki markdown parsing with no workflow, dependency, lockfile, install, release, permission, or secret-handling changes.

AGENTS.md: found and applied where relevant.

What I checked:

  • Repository policy read: Root and scoped extensions policy were read fully; the bundled-plugin boundary and high-confidence PR review rules apply to this Memory Wiki plugin change. (AGENTS.md:20, 28347ba51c3d)
  • Current main still has the bug path: On current main, extractWikiLinks removes only the managed related block before running the Obsidian and Markdown link regexes, so code-bearing markdown remains searchable. (extensions/memory-wiki/src/markdown.ts:389, 28347ba51c3d)
  • False extracted targets become lint warnings: collectBrokenLinkIssues emits broken-wikilink warnings for each extracted page.linkTargets entry absent from the valid target set, making code-origin extractions user-visible lint noise. (extensions/memory-wiki/src/lint.ts:68, 28347ba51c3d)
  • Current PR lacks unique landing value: The current PR head changes only extensions/memory-wiki/src/markdown.ts and provides unit-test output in the body, but it adds no regression test file and no after-fix real wiki lint output. (extensions/memory-wiki/src/markdown.ts:389, 0f1fcb75829c)
  • Canonical sibling PR is the stronger landing path: The earlier open PR changes the same extractor surface, adds a focused lint regression test for code-origin [[...]] false positives, and its body includes after-fix openclaw wiki lint --json output showing code-block warnings eliminated while a real broken link remains. (extensions/memory-wiki/src/lint.test.ts:70, 73dc1212b0c7)
  • Related issue is active and owned by the sibling landing path: The open issue tracks the exact fenced-code and inline-code false-positive bug, and both PRs target that same remaining work.

Likely related people:

  • vincentkoc: GitHub commit metadata and file history show this account introduced the Memory Wiki ingest, compile, and lint pipeline and later expanded lint/tool behavior on the same plugin surface. (role: feature introducer and area contributor; confidence: high; commits: 516a43f9f28c, 9ce4abfe558e, 5716d83336fd; files: extensions/memory-wiki/src/markdown.ts, extensions/memory-wiki/src/lint.ts, extensions/memory-wiki/src/lint.test.ts)
  • steipete: GitHub commit metadata and file history show adjacent Memory Wiki helper and string-normalization refactors near the affected markdown and lint surfaces. (role: recent adjacent area contributor; confidence: medium; commits: dffa88f39615, 59eb291c6e1c, 560a7aecd079; files: extensions/memory-wiki/src/markdown.ts, extensions/memory-wiki/src/lint.ts)

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

@zw-xysk

zw-xysk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Tests: 10/10 ✅.

@clawsweeper re-review

@clawsweeper

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

@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. labels Jun 30, 2026
@zw-xysk zw-xysk closed this Jun 30, 2026
@zw-xysk
zw-xysk deleted the fix/issue-97945-wikilink-code-fence branch June 30, 2026 00:58
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. 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.

memory-wiki lint: wikilink extractor still not markdown-aware — fenced code false positives (reopening #70986)

1 participant