Skip to content

Read PR author association with the kernel-internal app token - #27

Merged
tnsardesai merged 1 commit into
mainfrom
hypeship/pr-risk-app-token-association
Oct 27, 2026
Merged

tnsardesai merged 1 commit into
mainfrom
hypeship/pr-risk-app-token-association

Conversation

@tnsardesai

@tnsardesai tnsardesai commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#26 didn't fix the "author is not an org member" skips. On the first run after it merged, the pull_request event payload also reported CONTRIBUTOR for an org member, the same as the workflow token. Every Kernel member's membership is private, so every human PR is still skipped.

This mints a read-only kernel-internal token (contents: read, pull-requests: read, scoped to the current repo) before Gather, and uses it to read the PR, including author_association. Breakglass already relies on this: it checks PR authors through the API with its org-installed app's token, and that check passed for a private member (kernel/kernel#4948). The script goes back to reading author_association from the PR response, and the event-payload input from #26 is removed.

The credential split for the model is unchanged. The model step still has no GitHub token and no tools, and the token that can comment is still minted only after the model finishes.

Testing

  • Unit tests are back to reading the association from the PR. A workflow test checks that Gather uses the read token, that the token has only read permissions, and that it's minted before Gather. All 40 repo tests pass and actionlint is clean.
  • Not verified yet: that the kernel-internal token sees MEMBER for private members. The first PR from an org member after this merges will show it, either a risk comment or the same skip in the Gather log.

Note

Medium Risk
Changes CI credential flow and org-member gating for auto-risk comments; misconfiguration could skip eligible PRs or widen token use during gather.

Overview
Fixes PR risk Gather so org-member eligibility works when membership is private. Workflow token and pull_request event both expose those authors as CONTRIBUTOR, so every human PR was incorrectly skipped as “not an org member.”

A new Generate read token step mints a read-only kernel-internal app token (contents/pull-requests: read) before Gather; Gather uses that token instead of github.token. pr_risk.py drops the AUTHOR_ASSOCIATION env/event input and again uses author_association from the PR API (documented as valid only with the app token). The model step still has no GitHub token; the write token for comments is unchanged and still minted after classify.

Tests assert read-token ordering/permissions in the workflow and drive membership checks via mocked PR author_association.

Reviewed by Cursor Bugbot for commit b21890b. Bugbot is set up for automated code reviews on this repo. Configure here.

@tnsardesai
tnsardesai merged commit 0eeb376 into main Oct 27, 2026
2 checks passed
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.

2 participants