Skip to content

fix: list per-file global hunk indices in chunk prompt summaries - #83

Merged
2 commits merged into
mainfrom
fix/chunk-summary-hunk-indices
Sep 27, 2026
Merged

2 commits merged into
mainfrom
fix/chunk-summary-hunk-indices

Conversation

@vitali87

Copy link
Copy Markdown
Owner

Problem

In chunked mode every hunk in the diff is labelled with its per-file global index ([hunk_index=N]), and system-prompt rule 6 tells the model to use exactly those. But the chunk's file summary was built from hunk_count=len(indices_in_this_chunk) and printed indices 0..{count-1}. For a file split across chunks, chunk 2's summary said e.g. f.py: … (1 hunks, indices 0..0) while the diff below it showed [hunk_index=1] — a direct contradiction that invites the model to re-use index 0 (already assigned in chunk 1), producing overlaps and uncovered hunks that assign_uncovered_hunks then repairs noisily.

Fix

  • FileSummary gains hunk_indices.
  • ParsedDiff.stats fills 0..n-1; build_chunk_stats_from_hunks fills the chunk's actual sorted per-file global indices.
  • _format_file_summary prints indices 0..N when they are contiguous from 0 (unchanged wording for the single-shot prompt) and indices 1, 3 (this chunk only) otherwise.

Tests

  • second chunk of a 4-hunk file: summary carries [2, 3] and the continuation prompt says indices 2, 3 (this chunk only), not 0..1
  • prompt formatting for a non-contiguous index list
  • existing summary tests updated for the new field

Local review: 5/5. 446 tests pass, ruff clean.

The chunk file summary said 'indices 0..N-1' where N was the number of
that file's hunks in the chunk, while the diff labels (and the system
prompt's instructions) use per-file global indices. For a file split
across chunks the summary told the model to use indices already
assigned in an earlier chunk. FileSummary now carries the actual
indices and the summary lists them when they are not 0..N-1.
@coderabbitai

coderabbitai Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 6ee13fbd-4174-47c1-bc66-7f8c5818fc02

📥 Commits

Reviewing files that changed from the base of the PR and between 671a081 and d91f0e9.

📒 Files selected for processing (7)
  • pr_split/diff_ops/parser.py
  • pr_split/planner/chunker.py
  • pr_split/planner/prompts.py
  • pr_split/types_defs.py
  • tests/test_chunker.py
  • tests/test_prompts.py
  • tests/test_types_defs.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015rnEEjXWDBdePRhKMmZr1w
@vitali87 vitali87 closed this pull request by merging all changes into main in 8ca9e3b Sep 27, 2026
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.

2 participants