Skip to content

🐛 fix(automerge): keep contributor auto-promotion inside the search budget - #15091

Closed
Danathar wants to merge 1 commit into
hivecommons:v6from
Danathar:fix/15088-autopromo-search-budget
Closed

Danathar wants to merge 1 commit into
hivecommons:v6from
Danathar:fix/15088-autopromo-search-budget

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Fixes #15088

Summary

On the projectbluefin hive (19 repositories), GitHub's search secondary rate limit tripped five times on 2026-10-28 (17:22, 18:56, 19:43, 20:00 and 20:17 UTC), and two of those were nowhere near a restart. Every trip started with the same call, from the hive's log:

contributor-lane auto-promotion repo search failed; counting the PR's repository only
repo=projectbluefin/utah-packages author=github-actions[bot]
GET /search/issues?q=is:pr is:merged author:github-actions[bot] repo:… → 403 You have exceeded a secondary rate limit

Each trip put the hive into its rate-limit caution window, which shed the automerge sweeps and the dashboard refreshes. The Overview snapshot stayed at 19:59:45Z through the 20:17Z window.

The call comes from the hive-wide merged-history check that #14517 added to contributor-lane auto-promotion:

  • admitContributor (automerge_contributor_lane.go:629) runs contributorCleanMergedHistory for every author the claim path does not admit, bots included. A [bot] login can never hold a registry tier.
  • contributorMergedRepos (:808) chunks the hive's repositories into the 256-character q limit: 3–4 Search.Issues calls per PR on a 19-repository hive, repeated for every open PR by the author on every sweep. Nothing was cached.

Changes

  • contributorAutoPromotionExempt: [bot] logins (which includes the hive's own App) are exempt from auto-promotion. A bot is trusted only through the trusted bot authors setting. Without this, a workflow bot such as github-actions[bot] could in principle be promoted to trusted by merge count alone once the search succeeded, which bypasses that explicit setting. That is from reading the code; it was not observed in production.
  • Per (repository, author) cache: contributorMergedRepos caches the search answer for contributorMergedReposTTL (10 minutes), modelled on the existing maintainerPerm cache (automerge_contributor_adopt.go): the lock covers map access only, expired entries are pruned on write, and a failed search is not cached (it degrades to the PR's own repository exactly as before). The query itself is unchanged; the search is split out into searchContributorMergedRepos.
  • Changelog fragment: changelog.d/fixed-15088-autopromo-search-budget.md.

Merged history only grows, so a cached answer can at most delay a promotion by one window.

Tests

TestContributorAutoPromotionSearchBudget (fake GitHub counting search calls):

  • a github-actions[bot] PR with nine merges elsewhere makes 0 searches and is not promoted;
  • three sweeps of the same (repository, author) inside the window make 1 search and still walk the cached repository each time; after the window expires, a fourth sweep searches again;
  • a failed search (HTTP 422) is retried on the next sweep, not cached.

TestContributorAutoPromotionExempt covers the login check.

Against the unpatched v6 code, the bot and cache cases fail (searches = 1, want 0 and searches = 3 … want 1). With the change, go test ./pkg/github/automerge/ passes, and the existing TestTrySweepContributorLanePRAutoPromotion* cases are unchanged and green. gofmt and go vet are clean.

Out of scope

🤖 Generated with Claude Code

https://claude.ai/code/session_01SnzFs53Qcer1xDySyxv1Vj

…udget

The hive-wide merged-history search behind contributor-lane auto-promotion
(hivecommons#14517) ran for every open PR by an author on every sweep, and also for
`[bot]` authors, which can never be promoted. On a 19-repository hive that
is 3–4 search/issues calls per PR, and it tripped GitHub's search secondary
rate limit five times in one evening on a production hive, sending the
whole hive into its rate-limit caution window each time.

- Exempt `[bot]` logins from auto-promotion: a bot is trusted only through
  the trusted bot authors setting, never by counting its merges.
- Cache each (repository, author) answer for ten minutes, mirroring the
  maintainerPerm cache; a failed search is not cached.

Fixes hivecommons#15088

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SnzFs53Qcer1xDySyxv1Vj
Signed-off-by: Danathar <Danathar@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hanthor for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@Danathar

Copy link
Copy Markdown
Contributor Author

Superseded by #15090 (Karibhou), which fixes the same two causes and fits how the hive runs better: production calls the one-shot automerge.SweepContributorLaneAutoMerges (cmd/hive/main.go:9933), which builds a fresh Engine every tick, so this PR's engine-level 10-minute cache would only ever live for one sweep. #15090's per-sweep context cache is keyed per author across repositories, remembers a failed search for the rest of the sweep, and also exempts the configured App login. Closing this one in favour of it.

@Danathar Danathar closed this Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/L Denotes a PR that changes 100-499 lines, ignoring generated files. stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant