Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 8s
Add _line_of(content, pos) helper that computes the 1-indexed line number
from a character position in any content string. Thread it through every
document check:
check_frontmatter
- Missing frontmatter → line 1
- Malformed frontmatter → line 1
- Missing type field → line 1
- Invalid type → exact line of the 'type:' field in the frontmatter block
check_links
- Broken relative link → exact line of the [text](url) span
check_code_fences
- Unclosed fence → line number of the last unpaired backtick delimiter
- Switch from counting fence strings to enumerating (line_no, line) pairs
check_mermaid
- Pair every raw block line with its file-level line number via
fence_line + 1 + i so each issue can report an exact location
- Structural issues (unbalanced subgraph, sequenceDiagram blocks)
anchor to the diagram header line
- Edge-label issues anchor to the exact line where the label appears
- Empty diagram block anchors to the first line after the fence
Update report() to render 'path:line message' prefixes via _location();
fall back to 'path message' when line is None, or bare message for
tool-level issues where path is also None.
Clean redundant path embedding from all error message strings — the
location is now structural data in Issue, not prose.
Smoke-tested: all six assertion cases pass with exact line numbers.