Skip to content

Fix AI review reliability and diff coverage - #41

Merged
SwartzMss merged 3 commits into
mainfrom
agent/fix-ai-review-reliability
Jul 18, 2026
Merged

SwartzMss merged 3 commits into
mainfrom
agent/fix-ai-review-reliability

Conversation

@SwartzMss

Copy link
Copy Markdown
Owner

What changed

  • compact context-tool history before retrying AI review follow-ups after 504 or timeout
  • split oversized diff hunks by line and regenerate valid hunk headers with correct line numbers
  • migrate merge request diff loading to the paginated GitLab /diffs API with legacy compatibility
  • preserve collapsed, too_large, generated_file, and legacy overflow metadata
  • report unavailable GitLab diffs as incomplete coverage in the Dashboard

Why

Large tool histories could repeat the same oversized request after a timeout, oversized hunks could lose line-number mappings, and GitLab diff limits could silently produce incomplete reviews that appeared complete.

Impact

AI review retries now use compact evidence, findings from later oversized-hunk chunks retain valid added-line positions, and incomplete GitLab diff data is visible instead of being counted as fully reviewed.

Validation

  • cargo test (164 library tests, 5 binary tests, 21 end-to-end tests)
  • cargo fmt -- --check
  • git diff --check

@SwartzMss

Copy link
Copy Markdown
Owner Author

@codex

@SwartzMss
SwartzMss marked this pull request as ready for review July 18, 2026 07:23

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4f32eeb76

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/gitlab/client.rs Outdated
Ok(MergeRequestChanges {
changes,
diff_refs: metadata.diff_refs,
overflow: false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Detect limited /diffs responses

When a merge request hits GitLab's overall diff limits, the /diffs endpoint can still return 200 with only a limited set of files rather than an overflow field; this new path always sets overflow: false, so downstream coverage only sees the returned files and can mark the review complete while omitted files were never reviewed. I checked the GitLab List merge request diffs docs, which state this endpoint is subject to MR diff limits and returns limited results, so this path needs another signal such as MR changes_count/raw fallback to preserve incomplete coverage.

Useful? React with 👍 / 👎.

Comment thread src/review/ai.rs Outdated
let line_source_bytes = formatted_diff_line_bytes(&line);
chunk_lines.push(line);
let candidate = diff_hunk_from_lines(chunk_old_start, chunk_new_start, &chunk_lines);
if chunk_lines.len() > 1 && format_diff_hunk(&candidate).len() > max_chunk_diff_bytes {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve batch limits for single-line hunks

When a generated/minified diff contains one added or removed line whose line plus hunk header already exceeds max_batch_diff_bytes, this guard prevents splitting or marking it incomplete, leaving that oversized line as a single work item. The planner then accepts the item into an empty batch and later sends the full formatted payload, so the configured request-size limit is bypassed and the AI call can become huge or time out.

Useful? React with 👍 / 👎.

@SwartzMss
SwartzMss merged commit 1bc2f0e into main Jul 18, 2026
1 check 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.

1 participant