feat: auto-assign relevant reviewers based on past contributions#16
feat: auto-assign relevant reviewers based on past contributions#16
Conversation
There was a problem hiding this comment.
Pratrol Triage Brief: 🟢 High Confidence
Pratrol assessed this pull request across the primary risk vectors below.
| Risk Vector | Score | Tier |
|---|---|---|
| Contributor Context | 72/100 | 🟢 High |
| Logic Risk (Mistral) | 83/100 | 🟢 High |
| Overall Confidence | 79/100 | 🟢 High |
Summary: Added functionality to auto-assign reviewers based on CODEOWNERS and past contributions.
Key Signal: The PR introduces a new domain for reviewer assignment with comprehensive tests.
Recommendation: Review the new reviewer assignment logic and test cases thoroughly.
Deploying pratrol with
|
| Latest commit: |
e6abba3
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://23d0d34c.pratrol.pages.dev |
| Branch Preview URL: | https://feat-auto-assign-reviewer.pratrol.pages.dev |
53e0693 to
e6abba3
Compare
There was a problem hiding this comment.
🤖 Code Review
Assessment ⚠️
The pagination bug from the previous review was fixed — fetch_pr_files now correctly paginates up to 3000 files. The partition_owners org-validation concern remains unaddressed. No new high-severity issues found in the new code.
Note
Tag @mendral-app with feedback or questions. View session
| pub fn partition_owners(owners: &HashSet<String>) -> (Vec<String>, Vec<String>) { | ||
| let mut users = Vec::new(); | ||
| let mut teams = Vec::new(); | ||
|
|
||
| for owner in owners { | ||
| if let Some((_org, team)) = owner.split_once('/') { | ||
| teams.push(team.to_owned()); | ||
| } else { | ||
| users.push(owner.clone()); | ||
| } | ||
| } | ||
|
|
||
| (users, teams) | ||
| } |
There was a problem hiding this comment.
🐛 bug (medium)
Previous comment not addressed: partition_owners strips the org prefix from team slugs without validating that the org matches the repo owner. If a CODEOWNERS file references a team from a different org (e.g. other-org/team), the slug is passed to the GitHub API which will silently fail or assign the wrong team. The org prefix should be validated against owner before accepting the team.
📝 Suggested change
| pub fn partition_owners(owners: &HashSet<String>) -> (Vec<String>, Vec<String>) { | |
| let mut users = Vec::new(); | |
| let mut teams = Vec::new(); | |
| for owner in owners { | |
| if let Some((_org, team)) = owner.split_once('/') { | |
| teams.push(team.to_owned()); | |
| } else { | |
| users.push(owner.clone()); | |
| } | |
| } | |
| (users, teams) | |
| } | |
| pub fn partition_owners(owners: &HashSet<String>, repo_owner: &str) -> (Vec<String>, Vec<String>) { | |
| let mut users = Vec::new(); | |
| let mut teams = Vec::new(); | |
| for owner in owners { | |
| if let Some((org, team)) = owner.split_once('/') { | |
| if org != repo_owner { | |
| warn!( | |
| message = "CODEOWNERS team org does not match repo owner, skipping.", | |
| team = %owner, | |
| ); | |
| continue; | |
| } | |
| teams.push(team.to_owned()); | |
| } else { | |
| users.push(owner.clone()); | |
| } | |
| } | |
| (users, teams) | |
| } |
Note
This PR adds automatic reviewer assignment by parsing CODEOWNERS rules and scoring candidates based on file ownership and past commit history. It introduces a
ReviewerServicedomain, new GitHub client methods (fetch_codeowners,fetch_pr_files,fetch_file_contributors,request_reviewers), and comprehensive unit tests.Written by Mendral for commit e6abba3.