Skip to content

rifle: smart reviewer selection; alternative to blunderbuss - #787

Open
smg247 wants to merge 8 commits into
kubernetes-sigs:mainfrom
smg247:smart-blunderbuss
Open

rifle: smart reviewer selection; alternative to blunderbuss#787
smg247 wants to merge 8 commits into
kubernetes-sigs:mainfrom
smg247:smart-blunderbuss

Conversation

@smg247

@smg247 smg247 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

rifle acts as a, mutually exclusive, smart alternative plugin to blunderbuss. It replaces random reviewer selection with blame-based scoring that ranks OWNERS candidates by code contribution to changed files.

  • Add GetBlame to GitHub client (GraphQL blame API with Apps auth)
  • Score reviewers: (lines × 10) + (recency × 5) + owner bonus
  • Smart fallback: when not enough reviewers found, search broader OWNERS scope ranked by blame scores, fill remaining slots randomly

Implements: #780

@kubernetes-prow

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2026
@smg247
smg247 marked this pull request as ready for review June 30, 2026 17:54
@netlify

netlify Bot commented Jun 30, 2026

Copy link
Copy Markdown

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit 6bb540d
🔍 Latest deploy log https://app.netlify.com/projects/k8s-prow/deploys/6a60f506bcf34f0008ef6dd7
😎 Deploy Preview https://deploy-preview-787--k8s-prow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2026
@kubernetes-prow kubernetes-prow Bot added the area/plugins Issues or PRs related to prow's plugins for the hook component label Jun 30, 2026
@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 30, 2026
@kubernetes-prow
kubernetes-prow Bot requested a review from Prucek June 30, 2026 17:54
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 30, 2026
@smg247
smg247 force-pushed the smart-blunderbuss branch from b878716 to 1882614 Compare June 30, 2026 18:12
@smg247
smg247 force-pushed the smart-blunderbuss branch from 1882614 to 9172af1 Compare June 30, 2026 18:37
@kubernetes-prow kubernetes-prow Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 30, 2026
@smg247

smg247 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

/hold going to make this into a new plugin so the old algorithm can be used by those that want it

@kubernetes-prow kubernetes-prow Bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. area/hook Issues or PRs related to prow's hook component labels Jun 30, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 30, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@kubernetes-prow kubernetes-prow Bot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 30, 2026
smg247 added 3 commits July 1, 2026 07:13
Split the blunderbuss plugin into two mutually exclusive plugins in a
shared review_assignment package: blunderbuss (random selection, original
behavior) and rifle (blame-based scoring). This addresses review feedback
that changing blunderbuss defaults would concentrate review load and work
against the contributor-ladder model.
Move shared reviewer-selection infrastructure (interfaces, GetReviewers,
FindReviewer, IsUserBusy, etc.) to pkg/reviewer/ as exported symbols.
Restore pkg/plugins/blunderbuss/ for random selection and create
pkg/plugins/rifle/ for blame-based selection as independent plugin
packages that import from pkg/reviewer/.
@smg247
smg247 force-pushed the smart-blunderbuss branch from 9a8fdc4 to 8d69f90 Compare July 1, 2026 11:16
@kubernetes-prow kubernetes-prow Bot removed the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 1, 2026
@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 1, 2026
- Aggregate errors in handleStatus loop instead of returning only the
  last iteration's error. Also change early returns to continues so
  all matching PRs are processed.
- Handle org/repo inheritance in validateMutuallyExclusivePlugins so
  configuring blunderbuss at org level and rifle at repo level (or
  vice versa) is caught, respecting ExcludedRepos.
@smg247

smg247 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

/hold cancel

@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 1, 2026
@smg247 smg247 changed the title blunderbuss: smart reviewer selection using git blame scoring rifle: smart reviewer; alternative to blunderbuss Jul 1, 2026
@smg247 smg247 changed the title rifle: smart reviewer; alternative to blunderbuss rifle: smart reviewer selection; alternative to blunderbuss Jul 1, 2026
- Fix alphabetical import ordering for rifle in checkconfig and
  plugin-imports files
- Fix orphaned doc comment on GetBlame in fakegithub, add BlameData
  field so tests can configure blame responses
- Add defaultRifleReviewerCount constant instead of reusing
  defaultBlunderbussReviewerCount
- Rewrite TestReviewerScorer to call scoreReviewers instead of
  manually replicating scoring logic
- Add MostRecentDate assertions to TestIntersectBlameWithChanges
Comment thread pkg/plugins/rifle/rifle.go
@stevekuznetsov

stevekuznetsov commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

What's the additional GitHub API quota load of this approach?

@smg247

smg247 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

What's the additional GitHub API quota load of this approach?

Up to 20 additional REST API calls for GetBlame per PR (capped by maxBlameFiles). The IsUserBusy GraphQL calls are the same as blunderbuss and are cached via busyReviewers to avoid duplicates.

Keep in mind, utilizing rifle instead of blunderbuss is optional, and would not be recommended if API token budget is low.

I will look into adding docs to clarify this.

smg247 added 2 commits July 22, 2026 12:43
When all candidates are busy, the selector returns "" without modifying
the candidate set, causing the loop condition to remain true forever.
Break out of both reviewer selection loops when the selector returns
empty to prevent this.
Document the rifle plugin as a blame-based alternative to blunderbuss
for reviewer selection, including its algorithm, GitHub API quota
impact, and fallback behavior.
@kubernetes-prow kubernetes-prow Bot added the area/documentation Issues or PRs related to documentation label Jul 22, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: smg247

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/documentation Issues or PRs related to documentation area/hook Issues or PRs related to prow's hook component area/plugins Issues or PRs related to prow's plugins for the hook component cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants