fix(memory-wiki): ignore wikilink-like text in code spans during lint#97977
fix(memory-wiki): ignore wikilink-like text in code spans during lint#97977hanZeng-08 wants to merge 2 commits into
Conversation
The wikilink extractor ran OBSIDIAN_LINK_PATTERN against raw markdown, so [[...]] inside fenced code blocks and inline code spans were reported as broken wikilinks. Strip fenced blocks (line-by-line, matching backtick and tilde fences of any length) and inline code spans before extraction. Fixes openclaw#97945
|
Codex review: needs changes before merge. Reviewed June 29, 2026, 10:45 PM ET / 02:45 UTC. Summary PR surface: Source +50, Tests +131. Total +181 across 2 files. Reproducibility: yes. Current main extracts wikilinks after removing only the related block, and the PR body plus a read-only regex probe show both the original false positives and the new inline-span false negative. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Keep the fix at the Memory Wiki extraction boundary, but replace the inline-code regex with span-by-span masking and add regression coverage for real wikilinks between inline code spans before choosing a landing branch. Do we have a high-confidence way to reproduce the issue? Yes. Current main extracts wikilinks after removing only the related block, and the PR body plus a read-only regex probe show both the original false positives and the new inline-span false negative. Is this the best way to solve the issue? No, not as submitted. The Memory Wiki extraction boundary is the right fix location, but the inline-code masking must preserve real prose wikilinks between adjacent inline code spans. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 54b09580f61b. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +50, Tests +131. Total +181 across 2 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
The wikilink extractor ran OBSIDIAN_LINK_PATTERN against raw markdown, so [[...]] inside fenced code blocks and inline code spans were reported as broken wikilinks. Strip fenced blocks (line-by-line, matching backtick and tilde fences of any length, including bare fences) and inline code spans before extraction. Fixes openclaw#97945
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Hi @steipete @vincentkoc, ClawSweeper re-reviewed and marked this PR as the canonical landing path for #97945; the competing PR #97987 was closed as superseded. Could you please approve the pending workflows and review when convenient? Thanks! |
|
Thanks for working this through. I’m closing this because the #97945 memory-wiki wikilink false-positive issue has already been fixed on main by the canonical PR #97954, merged as c896718. This branch now overlaps that landed implementation, so keeping it open would just create duplicate cleanup churn. If there is still a distinct markdown edge case not covered by main, please reopen it as a focused follow-up against current main. |
Fixes #97945
Reopens #70986 (Class 1 only)
What Problem This Solves
Fixes an issue where
openclaw wiki lintreports false-positiveBroken wikilink targetwarnings for[[...]]patterns that appear inside fenced code blocks and inline code spans. Real vaults with Scala/bash examples or bridged session transcripts see hundreds of spurious warnings, making the lint report noisy and hiding genuine link issues.Why This Change Was Made
The wikilink extractor ran its regex against the raw Markdown body after removing only the managed related-links block. It did not exclude code spans, so literal syntax like
Future[Option[User]],[[ "$x" == "y" ]], or[[reply_to_current]]was extracted as a link target.The fix strips fenced code blocks (line-by-line, supporting backtick and tilde fences of any length, including bare fences without an info string) and inline code spans (including multi-backtick forms) before extraction. This is safer than a single broad regex because it preserves real wikilinks that sit between two separate code blocks and handles malformed unclosed fences conservatively.
User Impact
Users running
openclaw wiki linton vaults containing code examples or bridged transcripts will see far fewer falseBroken wikilink targetwarnings. Genuine broken wikilinks in prose continue to be reported.Evidence
Environment: Linux, Node v22.23.1, pnpm 11.2.2, OpenClaw 2026.5.28, worktree SHA 1052652
Unit tests
$ pnpm test extensions/memory-wiki/src/lint.test.ts Test Files 1 passed (1) Tests 9 passed (9)Real behavior proof
Test vault at
/tmp/test-wiki-vault:sources/code-example.mdcontains bash[[ "$name" == "Alice" ]], ScalaFuture[Option[User]], and inline code[[ "$str" == "test" ]]inside fenced code blocks / inline code spans.entities/alpha.mdcontains one genuine prose broken wikilink[[real-link]].Configuration (
/tmp/openclaw-wiki-proof.json) enablesmemory-wikiand points it at the test vault:{ "plugins": { "entries": { "memory-wiki": { "enabled": true, "config": { "vault": { "path": "/tmp/test-wiki-vault", "renderMode": "obsidian" } } } } } }Command run on both old (
main) and patched (fix/...) builds:Before fix (current
main){ "issueCount": 5, "issues": [ { "code": "stale-page", "path": "entities/alpha.md", ... }, { "code": "broken-wikilink", "path": "entities/alpha.md", "message": "Broken wikilink target `real-link`." }, { "code": "stale-page", "path": "sources/code-example.md", ... }, { "code": "broken-wikilink", "path": "sources/code-example.md", "message": "Broken wikilink target `\"$name\" == \"Alice\"`." }, { "code": "broken-wikilink", "path": "sources/code-example.md", "message": "Broken wikilink target `\"$str\" == \"test\"`." } ] }Two of the three
broken-wikilinkwarnings are false positives originating from code spans.After fix (this branch)
{ "issueCount": 3, "issues": [ { "code": "stale-page", "path": "entities/alpha.md", ... }, { "code": "broken-wikilink", "path": "entities/alpha.md", "message": "Broken wikilink target `real-link`." }, { "code": "stale-page", "path": "sources/code-example.md", ... } ] }The code-span false positives are gone; the genuine prose broken link remains.
Lint/format clean
Summary
What problem does this PR solve? The wikilink extractor treats Markdown code spans as prose, producing false-positive broken-link warnings.
Why does this matter now? Real vaults are cluttered with spurious warnings, reducing trust in
wiki lint.What is the intended outcome? Only genuine prose wikilinks are evaluated.
What is intentionally out of scope? Title-based resolver matching (Class 2 in #70986) and markdown-link handling are not changed.
What does success look like? The new regression tests fail before the fix and pass after; the CLI no longer reports code-span false positives.
What should reviewers focus on? Correctness of the line-by-line fence scanner, handling of bare fences and unclosed fences, and whether multi-backtick inline code support is worthwhile.
Fix classification: Root-cause fix
Root cause:
extractWikiLinksrunsOBSIDIAN_LINK_PATTERNover the full Markdown body without excluding code spans.Why this is root-cause fix: It stops invalid targets from being extracted in the first place, rather than filtering them later.
Linked context
Closes #97945
Related #70986 (reopens the markdown-awareness part only)
Was this requested by a maintainer or owner? No direct maintainer request; follows user-reported issue.
Tests and validation
pnpm test extensions/memory-wiki/src/lint.test.tspasses (9/9)./node_modules/.bin/oxlint extensions/memory-wiki/src/markdown.ts extensions/memory-wiki/src/lint.test.tsreports 0 warnings/errorspnpm format:check extensions/memory-wiki/src/markdown.ts extensions/memory-wiki/src/lint.test.tspassesopenclaw wiki lint --jsonon a synthetic vault shows code-span false positives eliminatedRisk checklist
Did user-visible behavior change? Yes —
openclaw wiki lintnow reports fewer false-positive broken wikilinks for code spans.Did config, environment, or migration behavior change? No.
Did security, auth, secrets, network, or tool execution behavior change? No.
What is the highest-risk area? The fence scanner could mis-handle unusual fence lengths or content that looks like a fence inside a code block. The regression tests cover common cases, bare fences, and inter-block preservation.
How is that risk mitigated? The scanner requires the closing fence to use the same character and be at least as long as the opening fence (CommonMark convention). Unclosed fences are handled conservatively so real links after them are not lost.
Current review state
Ready for ClawSweeper re-review. Next action:
@clawsweeper re-review.