Repository navigation
fix(memory): a code span before an angle destination is not whitespace to the link check (#1343) - #1436
Conversation
…e to the link check (intel#1343) The link check read the line with every blanked span turned into spaces, and the angle-link pattern allows spaces between `](` and `<`, so `[x]( `a` <y `b`>)` was taken for a link and `b` stayed text, although `a` is the destination and `<y` is no title. The same read was made for the unpaired-run check at the end of the line and for the paragraph above the line. The link check now reads a text in which a blanked span is a filler character (no space, bracket, parenthesis, quote, backtick or angle bracket), one per column; the lines the lint returns are still blanked with spaces. A line blanked whole by a fence or a comment keeps its spaces in the paragraph above. Two cases of an existing test that pinned the old output for `[x](`a`<`a`>)` and `[x](`a` <`a`>) `b`` now pin both spans blanked. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s). CI at Review limit reached. This PR has had 6 reviews, so it will only be reviewed again when you ask. Test notes (1)
Review details
|
Mutation of changed linesAt 7c7b682: 69 caught · 11 missed Each row is a small deliberate break (a mutant) of a line this PR changes that every test reaching that line still passes. Add a test that fails on it or, if it cannot change behaviour, put
Not checked:
Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1436 +/- ##
==========================================
- Coverage 96.31% 96.31% -0.01%
==========================================
Files 515 515
Lines 68908 68952 +44
Branches 11932 11936 +4
==========================================
+ Hits 66369 66410 +41
+ Misses 1564 1563 -1
- Partials 975 979 +4
🚀 New features to boost your workflow:
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head ad3600d)
- Contract: candidate. defaults dokimi/dokimi/memory/store.py:304; defaults dokimi/dokimi/memory/store.py:416
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
All ten focused blanking cases passed. Checking the public index reader on the example from #1343 showed it still reports a file for the invalid link. I posted the observed output inline.
Conflict in dokimi/dokimi/memory/store.py: main now reads the paragraph above a line through a cached `_paragraph_above(out, start, i)` and `_unpaired_run` takes a callable `before`, while this branch passes the lines with a blanked span as a filler. Both are kept: `_blank_blocks` hands the cached call the filled lines, and `_unpaired_run` takes main's callable `before` with the branch's `linked` argument. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…an as text (intel#1343) Settles the review point that `MemoryStore.index_targets()` still matched the link on the space-filled lines: for ``[x]( `a` <y `b`>)`` it returned `[(1, 'y ', True)]` although `prose_lines` blanked the spans correctly. `_blank_blocks` now returns the filled lines beside the blanked ones, and `index_targets` matches `_MD_LINK` on the filled text, where a blanked span is not a space that ends a bare destination. The target is read from the raw line, so a span inside a destination is kept as written. The regression test calls `index_targets()` directly. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@napetrov (#1436 (review)): The review's one finding is the inline thread 4742743297, answered above. Its change-class lines ask for no change of their own. |
Conflict in dokimi/dokimi/memory/store.py (MemoryStore.index_targets): main changed the link loop to match once, find the closing openers with _closing_openers and test the title spans through _merged; this branch reads each link's target from the raw text. Kept main's loop and its helpers, and took the target from the raw text (raw[m.start(1):m.end(1)]) as this branch does. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…he filled one Settles the review thread on store.py:123: the filled text reads a code span as text, so `[x](foo`(bar`)` matched with `foo` plus six fill characters and index_targets reported the raw slice `foo`(bar`` as a link target, though the destination's parenthesis is never closed. A match on the filled text is now kept only when the link grammar also matches the raw text at the same offset, and the target is the raw match's destination. `[x](foo`(bar`)` and `[x](`(`a)` report no target, and `[x](a`(b`)c)` reports the destination `a`(b`)c` whose parentheses balance in the raw text. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
|
Ready for another look at |
vchamarthi
left a comment
There was a problem hiding this comment.
@antonwolfy, could you fix the small thing I've marked fix before merge (in the line comments)? I'll approve once that's done.
What I checked on 3015ee5:
- When I changed the code on purpose, the tests still passed for 1 of 11 changes, and no test pins this one down yet (non-blocking):
dokimi/dokimi/memory/store.py:209(the call is dropped). - The 204 changed tests pass, and fail on main as expected.
- The full test suite passes with main merged in (36,137 tests), apart from failures main has too.
- It merges cleanly onto main.
Dropping the catch-up of the filled lines in _blank_blocks lost the link on the line after a fenced block or an HTML comment, and no test failed. One prose_lines case and two index_targets cases now fail then. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
|
There was a problem hiding this comment.
🟡 Changes recommended
Reference detection and raw-destination span handling still contain errors that can hide broken links, emit spurious targets, and incorrectly suppress orphan warnings.
2 open issues
What changed in this PR
2 new findings.
This PR addresses #1343 in dokimi’s memory lint by preventing blanked code spans from being mistaken for whitespace before angle-bracket link destinations.
Changes:
- Uses non-whitespace filler for link recognition while preserving space-blanked prose output.
- Validates index-link destinations against raw Markdown.
- Adds regression cases for inline and multiline parsing, target extraction, and line alignment.
| File | Description |
|---|---|
dokimi/tests/test_blank_inline.py |
Adds and updates parsing and target-extraction regression tests. |
dokimi/dokimi/memory/store.py |
Introduces filler-aware link recognition and raw-destination validation. |
dokimi/changelog.d/20261130_140000_memory-angle-link-blanked-span.md |
Documents the memory-lint fix for #1343. |
Review effort: Balanced
Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
…the raw text too _used_labels read inline links on the space-blanked lines, so a span before an angle destination hid a used definition, and a span in a bare destination marked an unused one checked. A filled match inside an accepted raw destination is no second link. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
@vchamarthi (#1436 (review)): The one blocking point is the |
|
@xaleryb (#1436 (comment)): Checked at the head: 6235e6d is on the branch and its three cases fail under the |
vchamarthi
left a comment
There was a problem hiding this comment.
Approving 7c7b682.
Still open: when I changed the code on purpose, the tests still passed for 1 of 12 changes, and no test pins this one down yet (non-blocking): dokimi/dokimi/memory/store.py:684 (it returns None).
What I checked: the 211 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (36,370 tests), apart from failures main has too; it merges cleanly onto main.
The earlier problem I raised is fixed now (link).
@vchamarthi (#1436 (review)): No change. The surviving mutant at |
|

Summary
The memory lint read the line with every blanked code span turned into spaces, and the angle-link pattern allows spaces between
](and<, so a span before<made the line look like a link. Onmain:main_blank_inline("[x](a<yb>)", False)[x]( <yb>)[x]( <y >)prose_lines("[x](a\n<yb>)")['[x]( ', '<yb>)']['[x]( ', '<y >)']prose_lines("[x](a<yz>)\nfoobar")['[x]( <yz>)', 'foobar']['[x]( <y ', ' bar']MemoryStore.index_targets()of an index[x](a<yb>)[(1, 'yb', True)]onmain;[(1, 'y ', True)]on this PR's first head[]In each,
ais the destination and<yis no title, so the line is no link and the spans are code. The first row is the issue. The other two are the same read in the unpaired-run check at the end of_blank_inlineand in the paragraph above a line.The fix reads the angle link on a text where a blanked span is a filler character (
\x00, one per column), not a space; the lines the lint returns stay blanked with spaces. The issue's other option (refuse a link whose blanks hide a span) is equivalent but needs a second pass, so it was not taken. The filler is not whitespace, bracket, parenthesis, quote, backtick or angle bracket, so it changes nothing_has_opener,_ANGLE_LINKor_BLANKSdecide except the one wanted: it is no blank before<.Closes #1343
Changes
dokimi/dokimi/memory/store.py:_BlankedLine._so_far(the text the angle-link check reads) fills a blanked range with_FILL;_BlankedLine.texttakes afill;_unpaired_runtakes the line to read links on, which_blank_inlinebuilds with the filler;_blank_blockskeeps a parallel list of its lines with spans filled, which is the paragraph above a line (_paragraph_aboveis unchanged). A line blanked whole by a fence, a comment or indented code keeps its spaces there, as Markdown starts a block of its own at it.dokimi/tests/test_blank_inline.py: a test per input above, and the unchanged cases ([x]( <yb>),[x](a<y b>),[x](<ab>), with a title, the destination on the next line, a span in the link label). The reference scan_rebuildingreads links on the filled line too.test_a_link_that_matches_only_once_a_code_span_is_blanked_still_holds_its_spanspinned the old output:[x](a<a>)was[x]( <a>)and[x](a<a>)b`` was[x]( <a`>) `. They now assert both spans blanked: `x` and `x `. The third case, `[x](<`<` `a`>)`, is unchanged.dokimi/dokimi/memory/store.py:_blank_blocksreturns the filled lines beside the blanked ones (prose_linesreturns the blanked ones, spaces only), andMemoryStore.index_targets()matches_MD_LINKon the filled text, so a blanked span is not a space that ends a bare destination there either. The target is cut from the raw line, so a span inside a bare destination ([x](abc)) stays as written.dokimi/tests/test_blank_inline.py:index_targets()is tested directly on the inputs above (and the destination on the next line, a bare destination holding a span, a real angle link), and_blank_blockskeeps one filled line per line of the text.dokimi/dokimi/memory/store.py:index_targets()keeps a match on the filled text only when_MD_LINKalso matches the raw text at the same offset, and reports the raw match's destination. The filled text reads a span as text, but its backticks and parentheses are plain characters of a destination:[x](foo(bar)and[x]((a)are no link (the parenthesis is never closed), and[x](a(b)c)is one with the destinationa(b)c.test_index_targets_reject_a_link_whose_destination_follows_a_code_spangains these three cases.Risk
The memory lint reads fewer links: a line such as
[x](a<yb>)is no link, so the backtick after<yopens a span as CommonMark reads it, which can blank more text on the line and the line below. Real angle links (a backtick in the destination, with or without a title, the destination on the next line) and a span in the link label are read as before. The returned lines keep their columns and spaces.MemoryStore.index_targets()(and soindex_links()and the memory lint's broken-link check) also reads fewer links: the same line gives no target, and a span inside a bare destination,[x](abc), is part of the targetabc; a destination whose parentheses do not balance in the raw text ([x](foo(bar)) is no link.main's lazy paragraph above (cache(partial(_paragraph_above, ...))) is merged into this branch and built from thefilledlines, not fromout, or the line-above case reads spaces again.mainis merged into this branch, with #1434's change tostore.pyandtest_blank_inline.pyin it: its one conflict, inindex_targets, keepsmain's link loop (_closing_openers,_merged) and cuts the target from the raw line as this branch does.Testing
On a Linux review host, at
3015ee57(onmaine1f77404):make ci-local: 38 passed, 0 failed, 16 skipped (steps that need docker, the network, or a PR: external-catalog-smoke, the matrix legs, semgrep, micromamba, the fuzz job). 32020 tests passed, 27 skipped; changed-line coverage 100% (26 lines). The mutation step lists 2 survivors,store.py:209(filled.extend(out[len(filled):])) andstore.py:223(_fill_blanks's early return).main's code, the new and changed cases fail on the assertion (5 failed, 8 passed of the 13 selected): e.g.assert '[x]( <yb>)' == '[x]( <y >)'; the unchanged cases pass there. The newindex_targets()test fails there on 4 of its 6 cases ([x](a<yb>),[x](a\n<yb>),[x](a<y b>),[x](abc))._so_farfails 3 cases ([x](a<yb>)and the two changed ones); reading the unpaired-run links on the spaced line fails thefoobarcase; passing the spaced paragraph above fails the[x](a\n<yb>)case; matchingindex_targets()on the blanked lines instead of the filled ones fails 4 of its 6 cases; cutting its target from the matched text instead of the raw line failsx; dropping the finalfilled.extendin_blank_blocksfails the one-filled-line-per-line test; dropping the raw-text match inindex_targets()fails 3 cases of the direct test ([x](foo(bar),[x]((a),x`), which also fail on the previous head's code.filled.extend(out[len(filled):])in_blank_blocks(store.py:210at7c7b682d) withpassfails 3 tests oftest_blank_inline.py: a fence above[x](\n<yb>)in theprose_linestest, and a fence or an HTML comment above it in theindex_targets()test.index_targets()of[x](a<y b>)\n\n[x]: missing.mdgives[(3, 'missing.md', True)], of[x](abc)\n\n[x]: missing.mdgives[(1, 'abc', True), (3, 'missing.md', False)], and of[x](a(b)[y](z))gives the one targeta`(`b)[y](z).Open questions
None.
Revert
A plain revert restores the old reading. Nothing is stored.
Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)