You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0f531be
Browse filesBrowse the repository at this point in the historyBrowse files
fix(pr-pipeline): match pr-merge adoption candidates by actor id (#13852)
No related issue: removes the login coupling ahead of the release App
rename (owner decision Q11)
## Summary
pr-merge's candidate listing matched trusted actors by login: it turned
each `login` in `.github/standards/trusted-actors/trusted-actors.json`
into `app/<slug>` and compared it with the `author.login` that `gh pr
list` returns, which carries no numeric id. Once the release App is
renamed from `melodic-plugin-release` to `melodic-release`, its pull
requests would stop being listed until the json changed. The listing now
matches trusted actors by numeric id, so a rename has no effect on it.
## Fix
- The step `List the candidate PRs` in `.github/workflows/pr-merge.yml`
now does one paginated `gh api graphql` read of open pull requests into
main:
- `first: 100`, a hard cap of 10 pages, and `orderBy: CREATED_AT DESC`,
the same order `gh pr list` uses
([lister.go](https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/shared/lister.go)).
- `totalCount` comes back on every page.
- It reads the same fields as before (`id`, `number`, `headRefOid`,
`isDraft`, `updatedAt`, `labels`, `body`), plus `author { __typename
login ... on Bot { databaseId } ... on User { databaseId } }`. Labels
are normalized to the old `[{name}]` shape, so the prefilter and the
later steps are unchanged.
- Trusted actors (with `adoption.idle-hours` set) match on
`author.databaseId` against the json `id`. Only positive integers count,
which replaces the old login-shape regex.
- The lanes App (`merge.agent-identity`) and Dependabot are matched as
Bots by login and kept only by their own switches (`merge.lane-prs`,
`merge.dependabot.mode`), whatever their ids. So `lane-prs: native` and
Dependabot `off` still drop them even though both ids are on the trusted
list. Basis: this matches today's exclusion of `app/<slug>` and
`app/dependabot` from the adoption set (pr-merge.yml at origin/main),
and both of those come from config logins, not from trusted-actors.json.
- An author with no id (a deleted account, a mannequin) matches nothing.
- The try fails and is retried, keeping today's fail-safe green hold,
when:
- a 200 response carries `errors` or lacks the connection, or a page has
no `totalCount`;
- the count changes between pages;
- the listing holds a different number of unique PRs than the count.
- More than 10 pages holds the run green with `listing full` and is not
retried, as before. Exactly 1000 open PRs now lists; before, it held,
because `gh pr list --limit 1000` could not tell 1000 apart from more.
- Live check: GraphQL `Bot.databaseId` for the author of #13829
(`melodic-plugin-release`) returned 337859524, which is the `id` in
trusted-actors.json.
### API calls per run
N is the number of open PRs into main. Counts are per listing try; a try
retries at most 3 times.
| | Old | New |
|---|---|---|
| N < 1000 | ⌈N/100⌉ `gh pr list` pages (min 1) + 1 `totalCount` read |
⌈N/100⌉ GraphQL pages (min 1) |
| N ≥ 1000 | 10 pages, held | 10 pages (N = 1000 lists; N > 1000 held) |
The delta is −1 call per try below the cap, and 0 at the cap. Over a run
with retries that is up to −3. Basis: `gh pr list` pages 100 at a time
(`pageLimit := min(limit, 100)` in
[lister.go](https://github.com/cli/cli/blob/trunk/pkg/cmd/pr/shared/lister.go)),
and the old step made the separate `totalCount` read only when N was
below the limit (pr-merge.yml at origin/main). Each new page is a
separate call through the rate guard's `gh api` wrapper, so header
readings are now observed on every page.
Unchanged: permissions, tokens, which actors are trusted, and every
later step.
## Verification
- `node --test .github/scripts/pr-merge/merge-job.test.mjs`: 97/97 pass
(the three per-page failure cases were added after the local code
review: an open count that moves between pages, a 200 that carries
GraphQL errors, and a next page with no cursor; each holds the run after
three tries). The fake `gh` now serves GraphQL pages keyed by cursor.
New and changed cases:
- a trusted App renamed to a new login but with a matching id is listed
(`renamed-release`, id 2);
- a trusted login under an untrusted id is dropped, for both a User and
a Bot;
- a null author and a mannequin are dropped;
- a string id in the json is ignored;
- under `lane-prs: native` the lanes App is dropped even with its id
trusted;
- 1000 PRs list in 10 calls with 9 cursors;
- 1001 and 1500 PRs hold after 10 calls with no retry.
- `scripts/check-affected.sh --tests`: exit 0, "11 passed, 110 skipped
over 4 changed files"; the pre-push check-affected hook passed on the
pushed head.
- Local code and security reviews ran on the diff because both CI review
lanes were failing. Security review: no findings. Code review: the test
gaps above, plus two stale comments, all fixed.
## Related
- #13826 (the tracker-binding move this builds on)
- `docs/conventions/pr-pipeline/README.md` documents the listing and is
updated to match. The changelog fragment is in `.changes/pr-pipeline/`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
- pr-merge's candidate listing matches trusted-actors.json's accounts by numeric id (`User.databaseId`, `Bot.databaseId`) instead of login, so a renamed App's pull requests stay candidates without a change to the list. It reads the open pull requests in one paginated GraphQL query, at most 10 pages of 100, with the open count on each page, which drops the separate count read: one call fewer per try. A list of exactly 1000 open pull requests now lists; more than 1000 still holds the run green.
// The hold and its reason reach the sweep summary, whose listing_held
417
469
// monitor signal 12 counts.
418
470
assert.match(step("Count the sweep's refusals"),/\n{10}LISTING_HELD:\$\{\{steps\.candidates\.outputs\.held\}\}\n{10}LISTING_HELD_REASON:\$\{\{steps\.candidates\.outputs\.held-reason\}\}\n/);
419
471
});
420
472
421
-
test("a complete listing one short of the limit still lists every candidate",()=>{
0 commit comments