Skip to content

feat: auto-assign relevant reviewers based on past contributions#16

Open
ymelois wants to merge 1 commit intomainfrom
feat/auto-assign-reviewer
Open

feat: auto-assign relevant reviewers based on past contributions#16
ymelois wants to merge 1 commit intomainfrom
feat/auto-assign-reviewer

Conversation

@ymelois
Copy link
Copy Markdown
Contributor

@ymelois ymelois commented Mar 1, 2026


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 ReviewerService domain, new GitHub client methods (fetch_codeowners, fetch_pr_files, fetch_file_contributors, request_reviewers), and comprehensive unit tests.

Written by Mendral for commit e6abba3.

Copy link
Copy Markdown

@pratrol pratrol bot left a comment

Choose a reason for hiding this comment

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

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.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 1, 2026

Deploying pratrol with  Cloudflare Pages  Cloudflare Pages

Latest commit: e6abba3
Status: ✅  Deploy successful!
Preview URL: https://23d0d34c.pratrol.pages.dev
Branch Preview URL: https://feat-auto-assign-reviewer.pratrol.pages.dev

View logs

mendral-app[bot]

This comment was marked as outdated.

@ymelois ymelois force-pushed the feat/auto-assign-reviewer branch from 53e0693 to e6abba3 Compare March 1, 2026 16:06
Copy link
Copy Markdown

@mendral-app mendral-app bot left a comment

Choose a reason for hiding this comment

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

🤖 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

Comment on lines +249 to +262
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)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🐛 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
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)
}

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