Skip to content

fix(memory-wiki): strip fenced code and inline code before wikilink extraction#98095

Merged
vincentkoc merged 7 commits into
openclaw:mainfrom
zhangqueping:fix/issue-97945-memory-wiki-markdown-aware
Jul 6, 2026
Merged

fix(memory-wiki): strip fenced code and inline code before wikilink extraction#98095
vincentkoc merged 7 commits into
openclaw:mainfrom
zhangqueping:fix/issue-97945-memory-wiki-markdown-aware

Conversation

@zhangqueping

@zhangqueping zhangqueping commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Related: #97945

What Problem This Solves

Fixes an issue where openclaw wiki lint could still report false broken-wikilink warnings for [[...]] text inside CommonMark code regions, including tilde fences, longer fences, fenced blocks inside lists or blockquotes, and multiline code spans.

The earlier masking on main handles simple backtick fences and single-line inline code, but ad hoc regex/scanner variants can either leak code text or hide genuine prose links around invalid or multi-backtick delimiters.

Why This Change Was Made

Memory Wiki now uses mdast-util-from-markdown to identify code and inlineCode source ranges, masks only those ranges, and then runs the existing wikilink and Markdown-link extraction logic unchanged.

This keeps parsing at the extractor boundary while delegating CommonMark fence, container, and code-span rules to the repository's existing parser stack. Link normalization, related-block filtering, frontmatter handling, and resolver behavior are unchanged.

User Impact

Memory Wiki lint output no longer includes code-origin false positives for standard CommonMark code regions, while genuine broken links in surrounding prose remain visible.

Evidence

  • node scripts/run-vitest.mjs extensions/memory-wiki/src/markdown.test.ts extensions/memory-wiki/src/lint.test.ts
    • 2 files passed
    • 35 tests passed
  • node_modules/.bin/oxfmt --check extensions/memory-wiki/src/markdown.ts extensions/memory-wiki/src/markdown.test.ts extensions/memory-wiki/src/lint.test.ts extensions/memory-wiki/package.json pnpm-lock.yaml
    • clean
  • Focused direct probes cover invalid backtick info strings, unmatched backtick runs, blockquote/list fences, multiline code spans, and separate multi-backtick spans; each preserves only the real prose link.
  • Structured Codex autoreview against current origin/main: clean, no actionable findings.

Local oxlint could not run after the merge from current main because this worktree intentionally shares an older dependency tree that lacks the newly configured oxlint rule. Exact-head CI and the external merge preflight are the authoritative toolchain gates.

@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 3:45 AM ET / 07:45 UTC.

Summary
The PR changes Memory Wiki wikilink extraction to mask mdast code and inlineCode ranges before link scanning, adds focused markdown and lint regressions, exports extractWikiLinks for tests, and declares mdast-util-from-markdown as a plugin dependency.

PR surface: Source +29, Tests +129, Config +1, Other +3. Total +162 across 5 files.

Reproducibility: yes. at source level: current main masks only simple backtick fences and single-line inline code, while the PR tests cover tilde fences, container fences, invalid fence-looking lines, and multiline code spans that current main does not handle. I did not run a live CLI repro in this read-only review.

Review metrics: 1 noteworthy metric.

  • Direct plugin dependency: 1 added. Memory Wiki now imports mdast-util-from-markdown at runtime, so maintainers should keep the exact-head dependency approval with the merge decision.

Stored data model
Persistent data-model change detected: unknown-data-model-change: extensions/memory-wiki/src/lint.test.ts, unknown-data-model-change: extensions/memory-wiki/src/markdown.test.ts, unknown-data-model-change: extensions/memory-wiki/src/markdown.ts, vector/embedding metadata: extensions/memory-wiki/src/lint.test.ts, vector/embedding metadata: extensions/memory-wiki/src/markdown.test.ts, vector/embedding metadata: extensions/memory-wiki/src/markdown.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: canonical
Canonical: #98095
Summary: This PR is the open viable landing path for the remaining CommonMark-aware Memory Wiki code-region masking after the earlier simple regex fix.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P2] No repair lane is needed; the remaining action is ordinary maintainer review of a clean, proof-backed PR with exact-head dependency approval.

Security
Cleared: Cleared: the added parser dependency is pinned to mdast-util-from-markdown 2.0.3, already present in the lockfile with registry integrity, and exact-head dependency approval is recorded.

Review details

Best possible solution:

Land the AST-backed code-region masking with its focused regressions after maintainer review, keeping the exact-head CI and dependency approval green.

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

Yes, at source level: current main masks only simple backtick fences and single-line inline code, while the PR tests cover tilde fences, container fences, invalid fence-looking lines, and multiline code spans that current main does not handle. I did not run a live CLI repro in this read-only review.

Is this the best way to solve the issue?

Yes. Parser-backed masking at the Memory Wiki extractor boundary is the maintainable fix because it delegates CommonMark code-region recognition to mdast-util-from-markdown while preserving the existing link extraction and lint reporting path.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a focused bundled Memory Wiki lint false-positive fix with real user diagnostic value but limited plugin blast radius.
  • 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 (terminal): The PR body and comments provide terminal-style evidence for focused extractor scenarios and the markdown/lint test suite, and the exact head has proof: sufficient plus a successful Real behavior proof check.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and comments provide terminal-style evidence for focused extractor scenarios and the markdown/lint test suite, and the exact head has proof: sufficient plus a successful Real behavior proof check.
Evidence reviewed

PR surface:

Source +29, Tests +129, Config +1, Other +3. Total +162 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 36 7 +29
Tests 2 163 34 +129
Docs 0 0 0 0
Config 1 1 0 +1
Generated 0 0 0 0
Other 1 3 0 +3
Total 5 203 41 +162

What I checked:

Likely related people:

  • vincentkoc: Git history shows Vincent Koc introduced the Memory Wiki ingest/lint pipeline and issue categories, restored the wiki stack, authored the PR head's CommonMark masking commit, and approved the exact dependency-changing head. (role: feature owner and recent 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: Git history shows Peter Steinberger worked on relative Markdown link target handling and nearby Memory Wiki helper/refactor surfaces that share the extractor and lint boundary. (role: recent adjacent area contributor; confidence: medium; commits: 2dcc13d6859d, dffa88f39615, 560a7aecd079; files: extensions/memory-wiki/src/markdown.ts, extensions/memory-wiki/src/lint.ts)
  • liuhao1024: The merged related PR introduced current main's simpler fenced-code and inline-code masking, which this PR now replaces with parser-backed masking for the remaining CommonMark cases. (role: prior related fix author; confidence: medium; commits: c896718acb2a; files: extensions/memory-wiki/src/markdown.ts, extensions/memory-wiki/src/lint.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • 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.
Review history (2 earlier review cycles)
  • reviewed 2026-06-30T11:13:35.040Z sha 7998553 :: needs real behavior proof before merge. :: [P2] Keep scanning past invalid fence-looking lines
  • reviewed 2026-07-06T06:39:20.666Z sha 3411c27 :: needs maintainer review before merge. :: none

@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
zhangqueping added a commit to zhangqueping/openclaw that referenced this pull request Jun 30, 2026
The FENCED_CODE_BLOCK_PATTERN used a regex backreference (\1)
that required the closing fence to be exactly identical to the
opening fence.  CommonMark allows the closing fence to be the
same character type and at least as long — e.g. ``` opening
with ```` closing is valid.  Switch to a function-based
replacement that compares fence character type and length.

Add regression test for the longer-closing-fence case per
ClawSweeper review feedback (openclaw#98095).
@zhangqueping

Copy link
Copy Markdown
Contributor Author

@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.

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 30, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 30, 2026
@zhangqueping

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 30, 2026
@zhangqueping

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

1 similar comment
@zhangqueping

Copy link
Copy Markdown
Contributor Author

@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.

@zhangqueping

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

…xtraction

The wikilink extractor in extractWikiLinks previously scanned
the full markdown content including fenced code blocks and
inline code spans.  Literal [[...]] syntax inside code regions
(e.g. bash test syntax, Scala generics like
Future[Option[User]]) produced false-positive broken-wikilink
lint warnings.

Add FENCED_CODE_BLOCK_PATTERN and INLINE_CODE_PATTERN and
strip those regions from the searchable text before running
the Obsidian and Markdown link regexes.  Five regression tests
cover backtick-fenced, tilde-fenced, 6-backtick-fenced, and
inline code scenarios plus a full vault lint round-trip.

Fixes openclaw#97945
The FENCED_CODE_BLOCK_PATTERN used a regex backreference (\1)
that required the closing fence to be exactly identical to the
opening fence.  CommonMark allows the closing fence to be the
same character type and at least as long — e.g. ``` opening
with ```` closing is valid.  Switch to a function-based
replacement that compares fence character type and length.

Add regression test for the longer-closing-fence case per
ClawSweeper review feedback (openclaw#98095).
Fixes ESLint curly rule violation at line 403.
…extraction

Replace FENCED_CODE_BLOCK_RE regex/callback with a line-by-line scanner
that keeps searching past invalid fence-looking lines (e.g. a shorter
``` line inside a longer `````` block) until a valid closing
fence of the same character type and at least as long is found.

Also handles tilde fences and longer closing fences per CommonMark spec.

🦞 diamond lobster: L2 evidence (5 real function-call scenarios, all passing)

Ref. openclaw#98095
@zhangqueping
zhangqueping force-pushed the fix/issue-97945-memory-wiki-markdown-aware branch from 7998553 to 3411c27 Compare July 2, 2026 11:53
@zhangqueping

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Changes made:

  • Rebased onto current main (removed unrelated refactoring, diff now scanner + export only)
  • Replaced FENCED_CODE_BLOCK_RE regex/callback with line-by-line scanner (handles tilde fences, CommonMark longer closes, and invalid interior fence lines)
  • Added regression test: shorter fence-like line inside longer fenced block
  • Updated PR body with L2 evidence (5 real extractWikiLinks function-call scenarios, all passing)
  • 29/29 tests pass (18 markdown + 11 lint)

@clawsweeper

clawsweeper Bot commented Jul 2, 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 proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. and removed 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. labels Jul 2, 2026
@zhangqueping

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated evidence: fresh L2 proof via npx tsx (5/5 scenarios ✅) + full test suite (29/29 ✅). The line scanner already handles invalid fence-looking lines (scenario 3 verifies the P2 fix). Added terminal_output block with real run output.

@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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. labels Jul 6, 2026
* origin/main: (1287 commits)
  fix(android): block loopback canvas navigation (openclaw#99874)
  fix(hooks): suppress unhandled stdout/stderr stream errors in gmail watcher (openclaw#100519)
  fix(memory-core): guard qmd mcporter JSON.parse against non-JSON stdout (openclaw#98381)
  fix(build): fall back to tsx for build TypeScript scripts (openclaw#91262)
  feat(skills): suggest saving detected reusable workflows by default (openclaw#95477) (openclaw#100692)
  docs(changelog): remove generated release-note entries
  feat(telegram): offer BotFather web app flow in setup help and docs (openclaw#100540)
  fix(ios): unify Talk and Settings row typography on one branded detail row (openclaw#100515)
  feat(gateway): add persisted crash-loop breaker and fatal-config exit contract
  refactor(macos): lock and unify PortGuardian tunnel record persistence so concurrent app instances cannot lose orphan records (openclaw#100601)
  fix: stop reconnecting on protocol mismatch (openclaw#98414)
  fix(maint): reuse recent hosted gates after rebase (openclaw#100663)
  fix(ui): reopen web terminals without stale content (openclaw#100665)
  fix(browser): diagnose empty WSL2 Chrome replies (openclaw#100590)
  fix(ios): chat snaps back to bottom when scrolling to top via status-bar tap (openclaw#100502)
  Treat already-compacted CLI compaction as no-op (openclaw#99136)
  docs(changelog): remove direct main fix entry
  fix(feishu): strip internal tool-trace banners from outbound text (openclaw#98705)
  fix(message): thread --limit through to CLI formatter and surface provider pagination hints (openclaw#99089)
  fix(voyage): close response body stream when batch output JSONL parsing throws (openclaw#98840)
  ...

# Conflicts:
#	extensions/memory-wiki/package.json
@vincentkoc
vincentkoc requested a review from a team as a code owner July 6, 2026 07:09
@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/memory-wiki/package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Dependency graph change authorized

This PR includes dependency graph changes. A repository admin or member of @openclaw/openclaw-secops authorized this exact head SHA with /allow-dependencies-change.

  • Approved SHA: c2ae3d25e88ddb505f044aa3ebcaa9296603fb55
  • Approved by: @vincentkoc
  • Reason: mdast-util-from-markdown remains intentional on exact head c2ae3d25e88ddb505f044aa3ebcaa9296603fb55: it provides CommonMark code and inline-code source ranges so Memory Wiki masks code without hiding surrounding prose links.

A later push changes the PR head SHA and requires a fresh security approval.

@openclaw-barnacle openclaw-barnacle Bot added triage: blank-template Candidate: PR template appears mostly untouched. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

/allow-dependencies-change mdast-util-from-markdown is intentional: it provides CommonMark code and inline-code source ranges so Memory Wiki masks code without hiding surrounding prose links.

* origin/main:
  fix(ci): restore gateway architecture and lint gates (openclaw#100703)
  fix(openai): reuse Codex auth for realtime voice (openclaw#100671)
  perf(test): avoid provider runtime in auth doctor unit test
  docs(android): credit landed app improvements (openclaw#100702)
@vincentkoc

Copy link
Copy Markdown
Member

/allow-dependencies-change mdast-util-from-markdown remains intentional on exact head c2ae3d2: it provides CommonMark code and inline-code source ranges so Memory Wiki masks code without hiding surrounding prose links.

@vincentkoc

Copy link
Copy Markdown
Member

No description provided.

@vincentkoc
vincentkoc merged commit adc4136 into openclaw:main Jul 6, 2026
91 of 92 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
…xtraction (openclaw#98095)

* fix(memory-wiki): strip fenced code and inline code before wikilink extraction

The wikilink extractor in extractWikiLinks previously scanned
the full markdown content including fenced code blocks and
inline code spans.  Literal [[...]] syntax inside code regions
(e.g. bash test syntax, Scala generics like
Future[Option[User]]) produced false-positive broken-wikilink
lint warnings.

Add FENCED_CODE_BLOCK_PATTERN and INLINE_CODE_PATTERN and
strip those regions from the searchable text before running
the Obsidian and Markdown link regexes.  Five regression tests
cover backtick-fenced, tilde-fenced, 6-backtick-fenced, and
inline code scenarios plus a full vault lint round-trip.

Fixes openclaw#97945

* fix(memory-wiki): accept longer closing fence in code block stripping

The FENCED_CODE_BLOCK_PATTERN used a regex backreference (\1)
that required the closing fence to be exactly identical to the
opening fence.  CommonMark allows the closing fence to be the
same character type and at least as long — e.g. ``` opening
with ```` closing is valid.  Switch to a function-based
replacement that compares fence character type and length.

Add regression test for the longer-closing-fence case per
ClawSweeper review feedback (openclaw#98095).

* style(memory-wiki): add braces to if-body in fence replacement callback

Fixes ESLint curly rule violation at line 403.

* fix(memory-wiki): replace fence regex with line scanner for wikilink extraction

Replace FENCED_CODE_BLOCK_RE regex/callback with a line-by-line scanner
that keeps searching past invalid fence-looking lines (e.g. a shorter
``` line inside a longer `````` block) until a valid closing
fence of the same character type and at least as long is found.

Also handles tilde fences and longer closing fences per CommonMark spec.

🦞 diamond lobster: L2 evidence (5 real function-call scenarios, all passing)

Ref. openclaw#98095

* fix(memory-wiki): use CommonMark code masking

---------

Co-authored-by: Vincent Koc <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…xtraction (openclaw#98095)

* fix(memory-wiki): strip fenced code and inline code before wikilink extraction

The wikilink extractor in extractWikiLinks previously scanned
the full markdown content including fenced code blocks and
inline code spans.  Literal [[...]] syntax inside code regions
(e.g. bash test syntax, Scala generics like
Future[Option[User]]) produced false-positive broken-wikilink
lint warnings.

Add FENCED_CODE_BLOCK_PATTERN and INLINE_CODE_PATTERN and
strip those regions from the searchable text before running
the Obsidian and Markdown link regexes.  Five regression tests
cover backtick-fenced, tilde-fenced, 6-backtick-fenced, and
inline code scenarios plus a full vault lint round-trip.

Fixes openclaw#97945

* fix(memory-wiki): accept longer closing fence in code block stripping

The FENCED_CODE_BLOCK_PATTERN used a regex backreference (\1)
that required the closing fence to be exactly identical to the
opening fence.  CommonMark allows the closing fence to be the
same character type and at least as long — e.g. ``` opening
with ```` closing is valid.  Switch to a function-based
replacement that compares fence character type and length.

Add regression test for the longer-closing-fence case per
ClawSweeper review feedback (openclaw#98095).

* style(memory-wiki): add braces to if-body in fence replacement callback

Fixes ESLint curly rule violation at line 403.

* fix(memory-wiki): replace fence regex with line scanner for wikilink extraction

Replace FENCED_CODE_BLOCK_RE regex/callback with a line-by-line scanner
that keeps searching past invalid fence-looking lines (e.g. a shorter
``` line inside a longer `````` block) until a valid closing
fence of the same character type and at least as long is found.

Also handles tilde fences and longer closing fences per CommonMark spec.

🦞 diamond lobster: L2 evidence (5 real function-call scenarios, all passing)

Ref. openclaw#98095

* fix(memory-wiki): use CommonMark code masking

---------

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

Labels

dependencies-changed PR changes dependency-related files 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: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: blank-template Candidate: PR template appears mostly untouched.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants