Skip to content

fix: ignore wikilinks inside inline code - #78

Open
bfs2021 wants to merge 1 commit into
tonydzi:mainfrom
bfs2021:fix/ignore-wikilinks-in-inline-code
Open

bfs2021 wants to merge 1 commit into
tonydzi:mainfrom
bfs2021:fix/ignore-wikilinks-in-inline-code

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 2, 2026

Copy link
Copy Markdown

Problem

sgm-stats counts a wikilink written inside inline code as a real graph edge, so a note that only mentions [[x]] as an example still links to x. Fixes #72.

Root cause

_links_in in brain_ask.py removes fenced code blocks before extracting wikilinks, but never removes inline code spans. Any `[[x]]` outside a fence survives the first pass and is picked up by WIKILINK_RX, which adds an edge that does not exist in the vault graph.

Fix

Added INLINE_CODE_RX = re.compile(r'+[^\n]*+')and strip inline spans right after fenced blocks in_links_in`. Fenced blocks are removed first, so the remaining backticks are inline spans only; multi-backtick spans are consumed as a unit. The docstring now says "code ignored" instead of "code fences ignored".

Testing

  • New case in tests/test_brain_ask.py: Write \[[example]]` to link.` yields no links; a real link next to inline code still resolves.
  • New test_link_in_inline_code_is_not_an_edge in tests/test_vault_stats.py builds the vault from the issue and asserts build_graph returns no edges.
  • Both fail on the previous code (3 failed) and pass with the fix.
  • python -m pytest -q: 210 passed, 1 skipped.

_links_in stripped fenced blocks but kept inline code, so a link
written as an example in backticks became a real graph edge.
Strip inline code spans too, after fenced blocks.
@tonydzi

tonydzi commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Hi, Mycroft here, Anton's synthetic AI co-founder. I read this before the human did, which is the one race I always win.

Logged your pull request ("fix: ignore wikilinks inside inline code") after 2 h of silence, which is on us. What a machine can already tell: 3 file(s) touched, +15/-1, CI no checks. A human from the lab reads it within 48 hours, as CONTRIBUTING.md promises; if that clock runs out, ping the thread, it is not rude.

— TonyDzi, Palo Alto AI Research Lab · more of the machine this came from (second brain + fleet coordination) lives at github.com/tonydzi, DMs open.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wikilinks inside inline code count as graph edges

2 participants