Skip to content

fix(review): deduplicate failure modes before the output cap - #4671

Merged
IsmaelMartinez merged 5 commits into
The-PR-Agent:mainfrom
rudycelekli:fix/deduplicate-failure-modes
Nov 16, 2026
Merged

IsmaelMartinez merged 5 commits into
The-PR-Agent:mainfrom
rudycelekli:fix/deduplicate-failure-modes

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

User description

Repeated failure-mode cases across review chunks currently consume the three-case output allowance and can crowd out a distinct failure mode from a later chunk. Deduplicate exact validated cases before applying that cap, preserving first occurrence order and meaningful differences such as coverage status.

The legacy renderer/consumer fixtures now use four distinct cases to verify the three-case cap, mixed invalid/duplicate cases to verify strict filtering, and assertions that the first three distinct cases reach every output consumer. Explicit duplicate expectations follow the new unique-case contract; source behavior is unchanged by those fixture corrections.

Validation:

  • Independent focused tests on this PR's exact head: 209 passed (renderer, reviewer-core, merge-shape and failure-mode regression suites).
  • LOCAL aggregate of all 20 campaign changes: complete unit suite 16,525 passed, 33 skipped, 290 warnings; packaging 3 passed. This is combined-change compatibility evidence, not a standalone full-suite run of each PR head.
  • That local aggregate passes locked Ruff 0.17.3, diff checks and exact unskipped pre-commit --files checks across all 43 changed Python files. Hooks with no applicable files report normal skips.
  • Frozen environment: Python 3.12.11, pytest 9.2.0, isolated uv 0.13.5 and pre-commit 4.7.0.
  • Hosted Build-and-test, pre-commit, CodeQL and Provider smoke report action_required at this head. Hosted success and maintainer acceptance remain pending; keep draft. No live provider acceptance is claimed.

PR Type

Bug fix, Tests


Description

  • Deduplicate validated failure modes before three-case cap.

  • Preserve first occurrence and distinct coverage values.

  • Verify chunk merging, rendering, and output consumers.


Diagram Walkthrough

flowchart LR
  input["Failure mode entries"]
  validation["Validate entries"]
  dedup["Deduplicate exact cases in order"]
  cap["Keep first three distinct cases"]
  output["Review output consumers"]
  input --> validation
  validation --> dedup
  dedup --> cap
  cap --> output
Loading

File Walkthrough

Relevant files
Bug fix
output_models.py
Deduplicate validated failure modes before output cap       

pr_agent/algo/output_models.py

  • Deduplicate validated failure modes using all field values before
    applying the three-case limit.
  • Preserve first-occurrence order and retain cases with different
    coverage values.
  • Continue skipping invalid entries.
+8/-2     
Tests
test_convert_to_markdown.py
Verify rendering caps three distinct failure modes             

tests/unittest/test_convert_to_markdown.py

  • Replace repeated cases with four distinct failure modes in the
    renderer cap test.
  • Assert the first three appear and the fourth is excluded.
+4/-1     
test_failure_mode_chunk_dedup.py
Add failure mode deduplication regression tests                   

tests/unittest/test_failure_mode_chunk_dedup.py

  • Add regression coverage for duplicates across review chunks.
  • Verify single-chunk duplicates do not consume the output allowance.
  • Assert coverage differences remain distinct in original order.
+29/-0   
test_pr_reviewer_core.py
Verify distinct failure modes reach output consumers         

tests/unittest/test_pr_reviewer_core.py

  • Mix invalid entries, duplicates, and four distinct failure modes in
    consumer fixtures.
  • Assert enabled output consumers receive the first three distinct valid
    cases.
  • Retain assertions that disabled output omits failure modes.
+3/-2     
test_review_merge_field_shapes.py
Align merge expectations with unique failure modes             

tests/unittest/test_review_merge_field_shapes.py

  • Update merge expectations so repeated identical failure modes produce
    one case.
  • Preserve existing validation and distinct-case cap coverage.
+2/-2     


⚙️ Agent run details
  • Model: openai/gpt-6.1-sol
  • Tokens: 6,327 in / 534 out / 6,861 total
  • Time cost: 9.2s
  • AI calls: 1

@github-actions github-actions Bot added the bug label Nov 4, 2026
@rudycelekli
rudycelekli marked this pull request as ready for review November 4, 2026 19:51
@the-pr-agent-bot

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks: exact duplicates crowding the cap is real, though it needs chunks to repeat a case byte for byte. if mode in modes: continue before the append does the same with three fewer lines, and your tests pass with it. This also flips the duplicate assertions #4012 added, so please update the failure_modes row in docs/docs/tools/review.md ("Concatenate valid cases ... at most three") to say duplicates are dropped.

@IsmaelMartinez

Copy link
Copy Markdown
Collaborator

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

Run locally: pr-agent e673a02, Claude Opus 5.5 as the model, published by @IsmaelMartinez.

@the-pr-agent-bot

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

⚙️ Agent run details
  • Model: openai/gpt-6.1-sol
  • Tokens: 8,095 in / 44 out / 8,139 total
  • Time cost: 2.9s
  • AI calls: 1

@the-pr-agent-bot

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.


⚙️ Agent run details
  • Model: openai/gpt-6.1-sol
  • Tokens: 6,268 in / 72 out / 6,340 total
  • Time cost: 2.6s
  • AI calls: 1

IsmaelMartinez and others added 2 commits November 16, 2026 19:59
Replace the fingerprint set with `if mode in modes: continue` and document the dedupe in the chunk-merge table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR. We pushed the shorter version ourselves: duplicates are dropped with a plain if mode in modes: continue before the append, so the fingerprint set is gone. Your tests are kept, and the chunk-merge row in docs/docs/commands/review.md now says exact duplicates are dropped. Near-duplicates that differ in whitespace or case are still kept, and the cap stays at three.

@IsmaelMartinez
IsmaelMartinez merged commit db099fb into The-PR-Agent:main Nov 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants