Add review risk assessment and optional repository review rules#2391
Add review risk assessment and optional repository review rules#2391xiaodeng666a wants to merge 25 commits into
Conversation
Review Summary by QodoAdd review risk assessment, merge recommendations, and repository review rules
WalkthroughsDescription• Add risk assessment and merge recommendation fields to PR reviews • Implement optional repository-specific review rules injection • Add review history tracking and retrieval from JSONL file • Enhance markdown rendering for new review fields Diagramflowchart LR
A["PR Review Process"] --> B["Load Review Rules"]
A --> C["Load Review History"]
B --> D["Inject into Prompt"]
C --> D
D --> E["Generate Review"]
E --> F["Extract Risk Level"]
E --> G["Extract Merge Recommendation"]
E --> H["Extract Priority Files"]
F --> I["Store in Memory"]
G --> I
H --> I
I --> J["Render Markdown"]
File Changes1. pr_agent/algo/utils.py
|
Code Review by Qodo
1.
|
|
Persistent review updated to latest commit 104a696 |
|
Persistent review updated to latest commit fc8ee1d |
|
Persistent review updated to latest commit d8cbb89 |
|
Persistent review updated to latest commit e237f87 |
|
Persistent review updated to latest commit 13136c6 |
|
Persistent review updated to latest commit 03e0a0d |
|
Persistent review updated to latest commit 2d099fa |
| elif "Review priority files" in key_nice.lower(): | ||
| if not value: | ||
| markdown_text += f"### {emoji} Priority files: None\n\n" | ||
| else: | ||
| markdown_text += f"### {emoji} Priority files\n\n" | ||
| for priority_file in value: | ||
| markdown_text += f"- {priority_file}\n" | ||
| markdown_text += "\n" |
There was a problem hiding this comment.
1. Priority files condition unreachable 📘 Rule violation ≡ Correctness
The new convert_to_markdown_v2() branch intended to render review_priority_files is effectively dead code because it checks for a capitalized/mixed-case substring against key_nice.lower(), so it can never match. As a result, review_priority_files falls through to the generic renderer instead of being formatted as the intended priority-files list/output.
Agent Prompt
## Issue description
The `review_priority_files` rendering branch in `convert_to_markdown_v2()` is unreachable because it performs a case-sensitive substring search using a mixed/capitalized literal (e.g., `"Review priority files"`) against `key_nice.lower()`, which is always lowercase.
## Issue Context
`key_nice` is transformed and then compared via `key_nice.lower()`. With the current mixed-case substring in the condition, the match can never succeed, so the new priority-files rendering path never runs and `review_priority_files` falls through to the generic renderer instead of being formatted as the intended priority-files list/output.
## Fix Focus Areas
- pr_agent/algo/utils.py[175-180]
- pr_agent/algo/utils.py[255-263]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
|
||
|
|
||
|
|
||
| from collections import OrderedDict |
There was a problem hiding this comment.
2. Extra blank lines in imports 📘 Rule violation ⚙ Maintainability
The PR introduces three consecutive blank lines within the import block, which is likely to fail Ruff/PEP8 blank-line rules and create unnecessary diff noise. This can break linting CI and violates the repository formatting conventions.
Agent Prompt
## Issue description
There are too many consecutive blank lines inside the imports section, which can violate Ruff/PEP8 formatting rules.
## Issue Context
The file currently has three blank lines between `import traceback` and the next import group.
## Fix Focus Areas
- pr_agent/tools/pr_reviewer.py[4-7]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| elif "risk level" in key_nice.lower(): | ||
| risk_value = str(value).strip().lower().replace("_", " ") | ||
| risk_display = risk_value.capitalize() if risk_value else "Unknown" | ||
| markdown_text += f"### {emoji} Risk level: {risk_display}\n\n" | ||
|
|
||
| elif "merge recommendation" in key_nice.lower(): | ||
| recommendation = str(value).strip().replace("_", " ") | ||
| recommendation_display = ( | ||
| recommendation.capitalize() if recommendation else "Unknown" | ||
| ) | ||
| markdown_text += ( | ||
| f"### {emoji} Merge recommendation: {recommendation_display}\n\n" | ||
| ) |
There was a problem hiding this comment.
3. Headings break gfm table 🐞 Bug ≡ Correctness
When gfm_supported is true, convert_to_markdown_v2() opens an HTML <table> but the new risk_level and merge_recommendation branches emit Markdown headings (### ...) rather than <tr><td>...</td></tr>. This produces malformed mixed HTML/Markdown output and can render the review comment unpredictably.
Agent Prompt
## Issue description
`convert_to_markdown_v2()` writes markdown headings for `risk_level` / `merge_recommendation` even while a `<table>` is open in GFM mode, breaking the table structure.
## Issue Context
The function opens `<table>` when `gfm_supported` is true, and most branches emit `<tr><td>...</td></tr>`. The new branches should follow the same pattern (or close the table before emitting headings).
## Fix Focus Areas
- pr_agent/algo/utils.py[171-173]
- pr_agent/algo/utils.py[241-253]
- pr_agent/algo/utils.py[347-349]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Persistent review updated to latest commit 71011b3 |
|
Persistent review updated to latest commit 20a256d |
|
Persistent review updated to latest commit b71e7be |
| @@ -1,6 +1,9 @@ | |||
| import copy | |||
| import copy | |||
There was a problem hiding this comment.
1. Bom character in import copy 📘 Rule violation ⚙ Maintainability
pr_reviewer.py now begins with a hidden UTF-8 BOM/zero-width character before import copy, which can cause linting/pre-commit failures, inconsistent behavior across linters/formatters, and confusing diffs across editors/tools. This violates repository hygiene expectations for clean, stable text formatting in changed files.
Agent Prompt
## Issue description
`pr_agent/tools/pr_reviewer.py` has a hidden UTF-8 BOM/zero-width character (U+FEFF) at the very start of the file (before `import copy`). This non-printable character can break tooling, create inconsistent linter/formatter behavior, and violate pre-commit hygiene expectations.
## Issue Context
The diff shows the first line as `+import copy` (note the hidden character before `import`). This is typically introduced by an editor/encoding change and should be removed so the file starts directly with the import statement.
## Fix Focus Areas
- pr_agent/tools/pr_reviewer.py[1-1]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Persistent review updated to latest commit b97e833 |
| require_risk_assessment=false | ||
| require_merge_recommendation=false | ||
| require_priority_files=false | ||
| enable_review_rules=true | ||
| review_rules_paths=[".pr_agent/review_rules.md",".github/review_rules.md","docs/review_rules.md"] | ||
| max_review_rules_tokens=1200 |
There was a problem hiding this comment.
1. .pr_agent.toml missing new keys 📘 Rule violation ⚙ Maintainability
New /review configuration knobs were added to pr_agent/settings/configuration.toml, but the mirrored root .pr_agent.toml was not updated to include these options, risking divergence and user confusion about available/default behavior. This violates the mirror-sync requirement when behavior/config surface area changes.
Agent Prompt
## Issue description
New `pr_reviewer` settings were added in `pr_agent/settings/configuration.toml` but are not reflected in the root `.pr_agent.toml` mirror, making mirrored configuration sources inconsistent.
## Issue Context
The repo uses both a packaged default config (`pr_agent/settings/*.toml`) and a root `.pr_agent.toml` as a mirror/example for behavior changes.
## Fix Focus Areas
- pr_agent/settings/configuration.toml[84-89]
- .pr_agent.toml[1-20]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Persistent review updated to latest commit 983d227 |
|
Persistent review updated to latest commit 9298146 |
|
Persistent review updated to latest commit 20673da |
|
I’ve addressed the automated review feedback, added targeted tests, and narrowed the scope to structured review assessment plus optional repository review rules. At this point the persistent review is updating to the latest commit, so I’ll pause here unless you’d like any further changes. |
|
Persistent review updated to latest commit d2f6982 |
|
Persistent review updated to latest commit 6020941 |
|
Persistent review updated to latest commit ca9ab5e |
|
Persistent review updated to latest commit c133868 |
|
Persistent review updated to latest commit b2b3f6a |
|
Persistent review updated to latest commit fecf295 |
Summary
This PR introduces two related review enhancements for PR-Agent:
risk_levelmerge_recommendationreview_priority_filesMotivation
These changes make review output more actionable and more adaptable to repository-specific expectations, while keeping the default behavior backward-compatible.
Notes