Skip to content

fix(repo): preserve physical Markdown claim line numbers - #705

Merged
xaleryb merged 9 commits into
intel:mainfrom
mangeshraut712:fix/686-markdown-physical-lines
Nov 20, 2026
Merged

xaleryb merged 9 commits into
intel:mainfrom
mangeshraut712:fix/686-markdown-physical-lines

Conversation

@mangeshraut712

@mangeshraut712 mangeshraut712 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #686. Markdown claims now use physical source line numbers (\n, \r, \r\n) when text contains non-physical Unicode line breaks/separators. Matching of fences, inline spans, and reference definitions is unchanged from main; only the reported claim line numbers move to reflect physical lines.

Changes

  • Retain chunk iteration via text.splitlines(keepends=True) so matching behavior for fences, inline spans, and reference definitions stays identical to main.
  • Advance the reported claim line counter in dokimi/repos/l0/markdown.py only on physical line endings (chunk.endswith(("\r", "\n")), covering \n, \r, and \r\n per CommonMark §2.1 and editor / GitHub #L<n> line numbers), rather than incrementing on the 8 non-physical Unicode str.splitlines() separators (\u2028, \u2029, \x85, \v, \f, \x1c, \x1d, \x1e).
  • Relation to rule_frontmatter.py: rule_frontmatter.blank_frontmatter intentionally uses str.splitlines(keepends=True) so U+2028 and other universal breaks inside .claude/rules frontmatter cannot hide rule text or leave an unclosed code fence bleeding into the body (test_a_line_break_character_in_rule_frontmatter_counts_as_a_line), while preserving every original break character (\n, \r, \r\n, U+2028, etc.) verbatim in the emptied prefix. When markdown.split subsequently counts only \r / \n / \r\n, body claims still receive their exact physical editor line numbers without relaxing frontmatter stripping.
  • Add 48 parameterized regression cases in dokimi/tests/test_repo_l0_markdown_lines.py across all 8 Unicode separators (\u2028, \u2029, \x85, \v, \f, \x1c, \x1d, \x1e) and all 3 physical line endings (\n, \r\n, \r) confirming claim line numbers track physical lines while fence, span, and reference-definition matching stay unchanged from main.
  • Merged main (4ef41e70, including #867), keeping dokimi/tests/test_repo_compare_interval.py identical to main (zero diff outside #686).

Risk

The production change is confined to physical newline counting in dokimi/repos/l0/markdown.py. Matching behavior for fences, spans, and reference definitions is preserved identically to main. No stored schema or CLI interface changes (python -m dokimi.schema_compat --base upstream/main reports OK).

Testing

Validated on head c08caded7c8b04f188f8390db6c6d72da9238862:

  • pytest tests/test_repo_l0_markdown_lines.py: 48 passed.
  • pytest tests/test_repo_l0.py tests/test_repo_l0_local_action.py tests/test_repo_scan_loaded.py: 282 passed.
  • python -m dokimi.schema_compat --base upstream/main: OK.

Revert

Revert the Markdown line-counter change in dokimi/repos/l0/markdown.py and dokimi/tests/test_repo_l0_markdown_lines.py. No persisted-data migration is needed.

Checklist

  • Tests added/updated and pytest passes
  • Ruff, mypy and schema checks pass
  • Docs reviewed; no public interface changes, changelog fragment added
  • Self-reviewed and independently reviewed
  • No ad-hoc run artifacts committed
  • New files carry required SPDX headers or are exempt

Signed-off-by: Mangesh Raut <95149253+mangeshraut712@users.noreply.github.com>
Signed-off-by: Mangesh Raut <95149253+mangeshraut712@users.noreply.github.com>
@mangeshraut712
mangeshraut712 requested a review from a team as a code owner November 13, 2026 11:57
@exai-bot

exai-bot commented Nov 13, 2026 •

Copy link
Copy Markdown

OpenCodeReview: Commit e68d4a5 was not reviewed. This PR has reached its review limit (6 reviews).

CI at e68d4a5: 2 passing.

To review this commit: re-request review from exai-bot in the Reviewers list.

<details><summary>Last review (ff93e26): no findings</summary>

Open threads from the bot: 0

</details>

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I checked 790da66. The fix is right: Markdown claims are now numbered by \n, \r\n and \r only, so a U+2028 (or \f, \x85, ...) no longer moves the links, spans and fences after it one line down, and no longer opens or closes a fence in the middle of a line.

Merge: safe now: it merges cleanly into current main, 0 commits behind. No open PR conflicts with it or shares its commits.

What I ran, at 790da66:

  • make ci-local --offline: 0 failed, 21 passed, 19 skipped (network and matrix jobs).
  • tests/test_repo_l0_markdown_lines.py on the merge-base: 12 of 15 cases fail, the 3 that pass are the trailing-blank-line fence cases, which guard the old behaviour.

Checked, no issues

  • Callers: fence lines go on to logical_lines, the dedent in core.py and the Starlark and type checks, which all join with \n and count \n, so their line numbers stay in step with the new split.
  • End of file: dropping only the last empty piece keeps the old splitlines() result for a trailing newline, and a fence keeps its blank last line.
  • Interval tests: the second commit only loosens two exact pins to one ulp and to the side of 0, which BLAS rounding can move; the new mocked test still checks that the row's own p places 0.
  • Changelog: a Fixed fragment; claim line numbers change only for files with these characters.

@codecov-commenter

codecov-commenter commented Nov 13, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.90%. Comparing base (4ef41e7) to head (e68d4a5).
⚠️ Report is 46 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #705      +/-   ##
==========================================
+ Coverage   95.79%   95.90%   +0.10%     
==========================================
  Files         432      448      +16     
  Lines       57209    59394    +2185     
  Branches     9858    10238     +380     
==========================================
+ Hits        54803    56959    +2156     
- Misses       1495     1510      +15     
- Partials      911      925      +14     
Files with missing lines Coverage Δ
dokimi/dokimi/repos/l0/markdown.py 96.00% <100.00%> (+0.34%) ⬆️
dokimi/dokimi/repos/l0/typecheck.py 91.20% <100.00%> (+0.03%) ⬆️

... and 104 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Current head 022e331c70dc15501816ce07dbf65187b6b16de7 has the approval, with 29 checks passing and 3 skipped, and GitHub reports it cleanly mergeable. Could a maintainer take a final look and merge when appropriate? Happy to address anything else needed.

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: not computed (no receipt profile for this repo, or receipt.py failed)

Verdict: one blocking finding (fence and refdef matching regression, markdown.py:50 thread). Two questions. Not approving.

Provenance: the blocking finding is probed on both trees (base and head). Questions are read or probed as marked in the threads.

Raised before: the LGTM from vlad-perevezentsev checked the numbering, not the fence-close path, so the blocking item is not raised there.

Coverage: plain and edge passes on head 022e331; probes on base and head for the fence, refdef, span and info-string cases. Not run: the full suite (regex and scipy missing in my env; markdown tests 15/15 on head, 12 fail on base as expected), mypy, and the 7 interval tests (scipy stub fails on both trees).

Comment thread dokimi/dokimi/repos/l0/markdown.py Resolved
Comment thread dokimi/dokimi/repos/l0/markdown.py Resolved
Signed-off-by: Mangesh Raut <95149253+mangeshraut712@users.noreply.github.com>
…ical-lines

Signed-off-by: Mangesh Raut <95149253+mangeshraut712@users.noreply.github.com>

@antonwolfy antonwolfy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The fix at 95fef45 is right: claims are numbered by physical \n, \r\n and \r only, while fence, span and reference-definition matching still runs on the universal line boundaries, so it matches the old behaviour except for the numbers. That closes the regression @napetrov found at 022e331.

What I ran, on a Linux review host at 95fef45:

  • make ci-local: 32 passed, 0 failed, 14 skipped (docker, network and matrix jobs); changed-line coverage passed.
  • A differential fuzz of split() against the base: 300,000 random texts mixing fences, spans, links, reference definitions and all the separators, plus 50,000 texts with only \n, \r\n and \r. Everything except line numbers was identical to the base, and the numbers matched an independent count of physical newlines. For \n-family-only text the output was identical to the base, numbers included.
  • 14 mutants of the new code against the new tests (always or never incrementing, \n-only, double count on \r\n, increment before use, splitting on \n only, and others): 12 are killed; the survivors are an equivalent mutant and one that changes only trailing whitespace of a line.
  • 16 mutants of the sign-flip interval (TOL, hi moved by 1e-6 to 2 ulp, lo moved, the 1e-4 floor dropped or zeroed) against the changed test_repo_compare_interval.py: all are killed, as by the base tests.

Checked, no issues

  • Interval tests: the exact lo pin now lives in the caller test with a stubbed ShiftTest.p, so it does not depend on BLAS; the new hi check pins a real step point of p.
  • Sign-offs: all three non-merge commits carry Signed-off-by.
  • Changelog: a Fixed fragment is present.

@antonwolfy

Copy link
Copy Markdown
Contributor

I approved this at 95fef45, and CI passes. The merge waits for you:

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: not computed (no receipt profile for this repo, or receipt.py failed)

Re-review at 95fef45: the earlier blocking (fence and refdef matching) is fixed on head. No new findings.
Still there from my earlier question on markdown.py:53: a U+2028 inside a fence info string still drops the language. The new test asserts "", so the test pins that behaviour; it is pre-existing and can be a follow-up.
Approval held: CI is pending (Intel CI, agent-quality, ci and cli-interface await approval), and the interval-test question on test_repo_compare_interval.py has no answer yet.
Coverage: plain and edge passes; the markdown tests pass on head; the interval tests were not run (no scipy here).

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 95fef45: Not approved yet: waiting on napetrov's open thread; 1 unverified behaviour. Nothing to fix in the code.

Blocking

  • Open question, not answered: thread by @napetrov – The new hi check passes on 95fef45 and pins the end to one step of p; lo is pinned only in the callers test through a stubbed ShiftTest.p, and the row test checks only the sign of lo on real deltas. For @mangeshraut712.
  • Not verified: The description says the interval tests verify numerical stability across BLAS backends. Reword that sentence to say what the tests stub, or add a test that runs the interval under a second backend.

Follow-ups, not blocking

  • dokimi/dokimi/repos/l0/markdown.py:54 – Input: a fence opener of three backticks, U+2028, then bash, followed by make all and a closing fence (main has it too).
  • dokimi/dokimi/task_formats/source.py:142 – Input: one valid JSONL row with U+2028 inside a string, {"a": "x<U+2028>y"} (main has it too).
Verified on 95fef45: 10 checks pass
Area What holds How
Claim line numbers Claims after U+2028, U+2029, U+0085, \v, \f, \x1c-\x1e take their physical line: all 8 cases of test_unicode_separators_do_not_shift_markdown_claims pass on 95fef45 tests on the head
Claim line numbers The same 8 cases of test_unicode_separators_do_not_shift_markdown_claims fail on main, so they pin the change same tests on main
Fence and reference matching A closing fence followed by U+2028 closes, and [docs](missing.md) on the line after it is checked on line 4; a reference definition followed by U+2028 is still a link ran it
Counting mutant Counting every chunk as a line (next_line += 1) fails the changed Markdown tests, so they pin the physical count broke the code, tests caught it
Cr and crlf endings The \r and \r\n cases of test_fences_keep_physical_newlines_and_trailing_blank_line and test_scan_keeps_physical_line_numbers_after_unicode_separator pass on 95fef45: a fence and a claim after a separator keep their physical lines in files ending lines with \r or \r\n tests on the head
End of file Intro<U+2028>[a](missing.md) with no final newline gives the link on line 1 ran it
Interval ends test_an_end_is_bounded_at_deltas_too_large_to_move_by_one passes on 95fef45: lo is 1e16, hi is within one ulp of 2e16, and test.p(hi) >= ALPHA > test.p(nextafter(hi)) holds for the real ShiftTest tests on the head
Interval backend case test_the_callers_p_places_zero_when_the_backend_disagrees passes on 95fef45 with ShiftTest.p stubbed: lo is 0.0 or 1e-4 as the row's p is above or below 0.05, and hi is 1.5 tests on the head
Merge The PR merges onto current main with no conflict merge onto main
Full suite The full suite on 95fef45 merged with main passes: 21755 passed, 0 failed full suite, main merged in

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

Thanks @vchamarthi for the thorough re-review! The PR description has been aligned to specify exactly what the tests stub (ShiftTest.p boundary conditions and lo == 0.0 exact pinning) without referencing external BLAS backends. Both @antonwolfy and @vlad-perevezentsev have approved, all checks are green, and the mathematical clarification on the lo and hi interval boundaries has been posted in @napetrov's thread above.

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 95fef45. The code is right now: 3b1cb2b matches fences, spans and reference definitions as main does and changes only the claim line numbers. My first-round LGTM missed the fence-close and refdef regression that @napetrov found; it is fixed. What is left is the description, in the line comment.

Agreed with @napetrov on the interval-test question: the author's answer holds, lo is pinned exactly in the stubbed test and hi to one step of the real p.

What I ran, at 95fef45:

  • make ci-local --offline: 1 failed, 20 passed, 20 skipped. The failure is schema_compat against a stale local main: it reports schema files this PR does not touch.

Checked, no issues

  • Counting: a line number moves on only at \r, \n or \r\n (a \r\n chunk ends in \n, so it counts once). A last line without a newline keeps its number.
  • Callers: the fence lines keep one entry per logical piece, so logical_lines and the Starlark check index them as before.

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I checked f5a8db6. Since my last round only main was merged in; the description now says that fence, span and reference-definition matching is the same as on main and only claim line numbers move, which is what the code does.

Merge: safe now: it merges cleanly into current main, 5 commits behind, and main has not changed its files since. Once it is in, #867 conflicts with it in tests/test_repo_compare_interval.py and needs a rebase.

What I ran, at f5a8db6:

  • make ci-local --offline: 1 failed, 22 passed, 20 skipped. The failure is schema_compat against a stale local main: it reports schema files this PR does not touch.

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not approved yet · re-reviewed f5a8db6

Next: @mangeshraut712: answer 1 open thread from napetrov and settle 2 open questions (below).

Blocking

  • Open question, not answered: thread by @napetrov – The row test test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart no longer asserts the row's lo, only that zero is inside exactly when p is at least 0.05 (dokimi/tests/test_repo_compare_interval.py:140); the exact ends are asserted only with ShiftTest.p stubbed (:144-150).
  • Open question for @mangeshraut712: Which line split the Markdown claim numbers use. State in the PR description which split the claim numbers use and why it differs from rule_frontmatter.py, or change the count in markdown.py:51-53 to match the reader.
  • Open question for @mangeshraut712: The description's Testing section counts 10,000 deterministic comparisons verified. Name the test or the run the count came from, or drop the count from the description.

Verified on f5a8db6: ✅ changed tests: 72 passed, fail on main · ❌ full suite on the head fails at ci.yml:static / schema_compat vs the PR base · ⚠️ conflicts with main · 3 mutations tried · 7 edge inputs tried

7 checks behind it, each with its evidence
Area What holds How
Claim line numbers A claim after each of the eight separators keeps its physical line: Intro<sep>[a](missing.md) gives line 1 on the head for U+2028, U+2029, U+0085, \v, \f, \x1c, \x1d and \x1e, where main gives 2 ran it, edge input (text)
Matching unchanged A link after a closing fence with U+2028 still gets checked on the head, as on main: the link missing.md is in the result ran it, edge input (text)
Empty input Empty text and whitespace-only text give no links, spans or fences on the head ran it, edge input (text)
Line endings and long lines A non-ASCII line, CRLF and CR endings, and a line of 100,000 characters keep the claim on line 2 on the head ran it, edge input (text)
Line counting Counting every chunk as a line (next_line += 1) fails 45 of the 72 tests in the two changed test files, so the tests pin the physical count broke the code, tests caught it, edge input (text)
Line counting Not counting a CR ending (chunk.endswith(("\n",))) fails 10 of the 72 tests in the two changed test files broke the code, tests caught it, edge input (text)
Line counting Counting U+2028 as an ending (chr(0x2028) added to the tuple) fails 10 of the 72 tests in the two changed test files broke the code, tests caught it, edge input (text)

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: not computed (no receipt profile for this repo, or receipt.py failed)

Verdict: comment, 0 blocking. Re-review at f5a8db6: only main was merged in; the PR files are unchanged since 95fef45, so there is nothing new to find. Both of our earlier questions are answered, so approval is no longer held by us.

Coverage: PR files only; the main merge's 231 files not reviewed; interval tests read, not run (no scipy).

…ysical-lines

Signed-off-by: Mangesh Raut <95149253+mangeshraut712@users.noreply.github.com>
@mangeshraut712

mangeshraut712 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @vchamarthi and @napetrov for the re-review! Pushed c08caded merging current main (4ef41e70) and updated the PR description to settle all three items and the schema_compat / merge state:

  1. Conflict with main & test_repo_compare_interval.py thread (#discussion_r4568030185): Merged main (including fix(eval): the sign-flip p adds its deltas exactly, and paired_test runs on finite deltas whose sum leaves the float range #867) taking main's dokimi/tests/test_repo_compare_interval.py verbatim, where test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart directly asserts row["delta"]["lo"] == 0.0. test_repo_compare_interval.py now has zero diff in this PR, and python -m dokimi.schema_compat --base upstream/main reports OK.
  2. Line split vs rule_frontmatter.py: Documented in ## Changes: claim line numbers in markdown.py advance only on physical line endings (\n, \r, \r\n via chunk.endswith(("\r", "\n")), matching CommonMark §2.1 and editor / GitHub #L<n> lines), whereas rule_frontmatter.blank_frontmatter uses str.splitlines(keepends=True) so U+2028 in frontmatter cannot hide rule text or leave an unclosed fence bleeding into the body while still preserving each original break character verbatim in the emptied prefix (so markdown.split counts only physical breaks into the body).
  3. Testing section count: Removed the unattributed 10,000 count from ## Testing and replaced it with the exact test files and counts run on head c08caded (48 in test_repo_l0_markdown_lines.py, 282 across test_repo_l0.py, test_repo_l0_local_action.py, and test_repo_scan_loaded.py).

All three answered review threads are now resolved, and CI + OpenCodeReview (0 findings) are green on c08caded. Note for maintainers (@antonwolfy / @vlad-perevezentsev): @napetrov's earlier formal CHANGES_REQUESTED review state from Nov 13 still holds the GitHub merge gate after their re-review noted approval is no longer held by them.

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Changes needed: 3 earlier findings still fail · re-reviewed c08cade

Next: @mangeshraut712: fix the 3 earlier findings below; then push for a re-review.

Blocking

  • Still fails: earlier finding – Intro<U+2028>[a](missing.md) now gives line 1 on the head where main gives 2, and the description states the split.
  • Still fails: earlier finding – The description no longer states the 10,000 count; the changed test file collects 48 cases on the head.
  • Still fails: earlier finding – The description no longer names BLAS backends; the interval row test it would have named passes on the head.

Verified on c08cade: ✅ changed tests: 48 passed, fail on main · ✅ full suite with main merged in: 23248 passed · ✅ merges onto main · 2 mutations tried · 7 edge inputs tried

14 checks behind it, each with its evidence
Area What holds How
Leading separator A leading U+2028, U+2029, U+0085, \v, \f, \x1c, \x1d or \x1e before [a](m.md) leaves the link on line 1 on the head; main gives line 2 ran it, edge input (line separator)
Span after separator A code span after U+2028 in non-ASCII text (ß with a combining mark) keeps its physical line: src/x.py is on line 1 on the head and on line 2 on main ran it, edge input (text)
Empty and blank text Empty text, and text of spaces, tabs, line breaks and U+2028 only, gives no links, spans or fences on the head and on main ran it, edge input (text)
Crlf and cr files A file with CRLF endings keeps m.md on line 2 and n.md on line 3; a file with CR endings keeps o.md on line 2. Head and main agree ran it, edge input (text)
Non-utf-8 bytes A file with bytes that are not UTF-8 is read with replacement characters, and the link after them stays on line 2 on the head and on main ran it, edge input (text)
Long line A line of 100000 characters keeps a claim on line 2 after a line feed and on line 1 after U+2028; main gives line 2 after U+2028 ran it, edge input (text)
Matching across separators A closing fence followed by U+2028, a reference definition followed by U+2028, and a span across U+2028 match as on main: missing.md and other.md are found, and the span is not matched ran it, edge input (text)
Claim counting Counting every chunk as a line (next_line += 1) fails 45 of the 48 cases in tests/test_repo_l0_markdown_lines.py, so the tests pin the physical count broke the code, tests caught it
Line ending count Counting only \n as a line ending (chunk.endswith(("\n",))) fails 10 of the 48 cases in tests/test_repo_l0_markdown_lines.py broke the code, tests caught it
Changed tests The 48 cases of tests/test_repo_l0_markdown_lines.py pass on the head. They pin the physical line of a claim after U+2028, U+2029, U+0085, \v, \f, \x1c-\x1e, and the matching of fences, spans and reference definitions tests on the head
Changed tests on main 45 of the 48 cases fail on main same tests on main
Merge The head merges onto current main with no conflict merge onto main
Full test run The full test run with main merged in passes: 23248 passed, 0 failed full suite, main merged in
Rule frontmatter test_a_line_break_character_in_rule_frontmatter_counts_as_a_line, which the description cites for rule_frontmatter.py, passes on the head and on main ran it

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I checked c08cade. Only main was merged in: tests/test_repo_compare_interval.py is now main's (#867), so the PR is the Markdown fix alone, and markdown.py and its tests are unchanged since my last round.

Merge: safe now: it merges cleanly into current main, 26 commits behind, and its tests pass on the merge. No open PR conflicts with it or shares its commits.

Disagreed with @vchamarthi on the three blocking points of the review at c08cade: a link after U+2028 on line 1 is the fix itself (it is on physical line 1), and the description no longer naming the case count or BLAS settles those two earlier points rather than failing them.

What I ran, at c08cade:

  • make ci-local --offline: 1 failed, 24 passed, 20 skipped. The failure is schema_compat against a stale local main: it reports schema files this PR does not touch.
  • On the merge with current main: tests/test_repo_l0_markdown_lines.py and tests/test_repo_l0.py, 296 passed.

A U+2028 inside a Python fence splits the code the type checker reads,
so fence.line + code line moved the claim down; map the code line
through fence.lines, which carries physical line numbers.

Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
@xaleryb

xaleryb commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Checked at c08cade merged with main 32a39f0 (Python 3.13): 45 of the 48 new cases fail on main and all 48 pass on the merge; the link, CRLF and CR examples give the physical lines the description claims. Full suite, ruff, mypy, bandit -ll and docs check --strict pass, with no failure beyond main's on the same host. No other open PR touches these files.

One case the head still numbered the old way, so I pushed ff93e26 on top:

  • A python fence opening on line 3, whose line 4 is import json<U+2028>x = 1 and line 5 print(json.dumps(1).nosuch()), checked with mypy: the fail claim was on line 6 (the closing fence) on main and on c08cade, against line 5 expected, which the changelog's "fenced-code claim line numbers aligned" covers.
  • The cause: _claims adds the type checker's code line to fence.line, but the code is split at U+2028 and the file is not. ff93e26 maps the code line through fence.lines; an error without a line stays on the fence's opening line.
  • test_a_python_fence_error_is_claimed_on_its_physical_line fails on c08cade and passes with the fix.

@xaleryb xaleryb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI green on ff93e26. The PR's 48 cases fail on main and pass merged with main; the Python-fence claim line after a U+2028 is fixed in ff93e26 (see the comment above). No open threads.

@xaleryb

xaleryb commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@napetrov, could you take another look? Your review from 2026-11-13 (on 022e331) still shows as changes requested, so the PR is blocked, although your 2026-11-18 comment says you no longer hold it. Since then the fence/refdef point is fixed, the info-string U+2028 case is left as the follow-up you agreed to, and ff93e26 covers the Python-fence claim line after a U+2028. CI is green on ff93e26 and the PR has two approvals there. If it looks good to you, please dismiss or update your review and merge.

@antonwolfy antonwolfy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The new commit ff93e26 is right: a Python fence error is now claimed on the physical line of the code line the type checker reported, so a U+2028 inside the fence no longer moves it down. One nit on the test.

What I ran, on a Linux review host at ff93e26:

  • make ci-local: 35 passed, 1 failed, 14 skipped; 22,912 tests; changed-line coverage 100%. The failure is tests/test_repo_batch_lifecycle.py::test_ctrl_c_makes_the_repo_run_process_exit_nonzero, a Ctrl-C timing test (it saw one extra run, r3) in a file this PR does not touch; the file passes alone (14 passed).
  • test_a_python_fence_error_is_claimed_on_its_physical_line against the base typecheck.py: the (3, 5) case fails (claim on line 6), so it pins the fix. The (0, 3) case passes on the base too, as it should.
  • The mutation step reports 9 mutants on the changed lines, 7 killed and 2 survived, both at typecheck.py:138 (see the inline comment).
  • The sign-off check: all four non-merge commits carry Signed-off-by.

Checked, no issues

  • Mapping: the code the checker reads is "\n".join of the texts in fence.lines, dedent keeps the line count, so code line N is fence.lines[N-1]. Without a separator it equals fence.line + N, as before.
  • Other users of fence.line +: none left in dokimi/dokimi/repos/l0/; adapters.py and core.py already index fence.lines.
  • Changelog: the Fixed fragment covers the fenced-code claim lines.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>

@antonwolfy antonwolfy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I pushed a commit per nit, up to e68d4a5, which fix the nit from my review:

  • e68d4a5: dokimi/tests/test_repo_l0_markdown_lines.py:84: added the suggested test after the separator on the opening line, plus an out-of-range case (3, 4) so the fence.line - line mutant also fails.

make ci-local at e68d4a5: 0 failed, 36 passed, 14 skipped.

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved · re-reviewed e68d4a5

Next: nothing required from @mangeshraut712.

Verified on e68d4a5: ✅ changed tests: 53 passed, fail on main · ✅ full suite with main merged in: 24212 passed · ✅ merges onto main · ✅ 1 broken variant of the changed code: 1 caught by the tests · 1 mutation tried · 1 edge input tried

4 checks behind it, each with its evidence
Area What holds How
Fence error line 0 < line in _claims is pinned: changing it to 1 < line fails test_code_after_a_separator_on_the_opening_line_is_claimed_on_that_line[1-1] broke the code, tests caught it, edge input (text)
Fence error line Dropping the scan.add call in _claims fails the changed tests tests on the head
Markdown line tests The changed test_repo_l0_markdown_lines.py passes on the head (53 cases) and the separator cases fail on main same tests on main
Merge The PR merges onto main without conflict merge onto main

@xaleryb
xaleryb merged commit ad3a57b into intel:main Nov 20, 2026
28 checks passed
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.

Markdown claims after U+2028 are numbered one line low

8 participants