Skip to content

fix(review): review pages number their source lines - #528

Merged
dan-petty merged 1 commit into
release/v0.2.23from
fix/499-review-page-line-numbers
Sep 24, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.23from
fix/499-review-page-line-numbers

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Closes #499.

Problem

Review pages gave the model source text without line numbers, and a later part of a split file started mid-file with no offset. Every reported line range was therefore the model's own count; the #415 defect at crypto/known_hosts.py:248 was reported at lines 127–130. Line numbers drive patching, duplicate consolidation by line overlap and the verifier's out-of-range check.

Split pages lost more than the offset (from #515):

  • Re-split: the orchestrated pipeline cut a file's page at arbitrary lines when it exceeded its window. A later page had no file header, no fence and no overlap, so a defect at the boundary was never seen whole.
  • Verifier excerpt: the excerpt counted lines from the top of the first page naming the file. A finding in a later part was shown other code, or none.

Changes

  • Numbered lines (chunker.number_source_lines): every page line carries its line number in the file and a tab. Lines are counted at newlines only, as git and editors count them, so a form feed no longer adds a line.
  • Numbered diffs (number_diff_lines): context and added lines carry new-file numbers; removed lines carry the tab alone. The hunk lengths in @@ headers decide where a hunk ends, so a removed line reading --- x is not taken for a file header.
  • Split pages keep their header and overlap (split_review_pages). Every window repeats the ### File: title and fence, or the diff preamble.
    • A diff page cut mid-hunk ends its preamble at the first numbered line.
    • One windowing helper serves path, branch and PR paging and the pipeline's re-split.
    • A single-file path review is paged like a directory's files.
  • Verifier:
    • the excerpt is found by line number across every part of the file, and same-named files are not mixed;
    • the orchestrated verifier reads the whole file numbered.
  • Prompts: the code, configuration and documentation review prompts and the paginated protocol ask personas to cite the numbers and never copy them into code or fixes. The verifier checks a finding's lines against them.
  • Contract grounding reads imports through the number column (strip_line_numbers).

Live corpus (#415, seed 1, 10 injections, all personas, same gateway)

Before After
Injections found 7 7
Found at their line 4 7
Still reported 6 6
Prompt tokens per review 505,376 520,891 (+3.1%)
Injection Reported at, before After
crypto/known_hosts.py:248 127-130, 154-156 248-250
core/repo.py:250 100-101, 106-110 245-250
security/suppression.py:200 140-147 186-217, 201-217
core/audit.py:95 58-78 89-95

Token cost:

  • The numbers add 14.5% to the source text (about 1.2 tokens a line, o200k_base). Source is a minority of each prompt, and the whole review rose 3.1%.
  • Reported findings beyond the injections rose from 24 to 37. Each is a distinct line, not a duplicate from the overlap. Candidate counts vary between 41 and 80 across this release's runs, so this rise is not attributed to numbering.

Test plan

  • tests/test_review_page_line_numbers.py (13 tests):
    • numbering of source and diffs, and stripping it back to the original text;
    • every line of every part carries its own file number, with the line-248 regression;
    • overlap and full coverage for the first split and for the pipeline's re-split;
    • split diffs;
    • verifier excerpts by number;
    • imports read through the numbers;
    • the prompt rule.
  • Existing paging, runner and verification tests unchanged and passing
  • uv run devops ci --force: all 13 gates pass

Review pages gave the model source without line numbers, and a later part of a split
file started mid-file with no offset, so every reported line was the model's own count:
the #415 defect at line 248 was reported at lines 127-130.

- Every page line carries its line number in the file and a tab, counted at newlines
  only. Diffs carry new-file numbers; removed lines carry the tab alone.
- Split pages overlap and repeat the file header or diff preamble, including when the
  pipeline re-splits a page for a smaller window; it used to cut at arbitrary lines.
- The verifier finds a finding's excerpt by number in any part of its file, and reads
  the whole file numbered.
- Persona prompts ask for the shown numbers; contract grounding reads imports through
  the number column.

On the 10-defect corpus, injections found at their line rose from 4 to 7 of the 7
found, and prompt tokens per review rose 3.1%.

Closes #499
@dan-petty dan-petty added this to the v0.2.23 milestone Sep 24, 2026
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/review Multi-persona code review engine, verification, and findings priority/p1-high Priority P1: high-impact work for the next planned milestone labels Sep 24, 2026
@dan-petty
dan-petty merged commit c2b3e6c into release/v0.2.23 Sep 24, 2026
7 checks passed
@dan-petty
dan-petty deleted the fix/499-review-page-line-numbers branch September 24, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p1-high Priority P1: high-impact work for the next planned milestone scope/review Multi-persona code review engine, verification, and findings type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant