Repository navigation
🐛 fix(automerge): read ruleset required checks when classic protection lists none - #15372
Conversation
…n lists none On a rulesets-only branch the classic protection API answers "Branch not protected" (403 without Administration) and the branch payload reports protection disabled with no contexts. RequiredStatusCheckContextsDetailedWithSource took either as a known-empty required set and never read the rules endpoint, so projectbluefin/testsuite and bluefin-bling heads whose fork runs GitHub holds sat at ci-unverified and the registry-trusted held-run approver (which acts on required-check-missing) never fired. A classic "nothing required" answer now defers to the branch's ruleset required checks when it lists any. The held-run approver also acts at ci-unverified when every pull_request run for the head repository is action_required. Signed-off-by: Danathar <Danathar@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
docs-currency — one advisory, no blocker.
src/docs/hive-merge.md:484-492 (new paragraph) under-describes the behaviour src/pkg/github/commit_ci.go now has:
- It names two "nothing required" cases (unprotected, protection without checks) but omits the third one the code handles (
commit_ci.go:212-216, branch endpoint payload with no checks) — which per the PR body is the shape actually seen onprojectbluefin/testsuite(403 without Administration →source=branch). An operator reading the doc against that log line will not find their case. - It does not say that rulesets are not read when classic protection already lists checks (no union;
commit_ci.go:193-199), nor that a failed/empty rules read leaves the classic known-empty answer standing (commit_ci.go:237-243). The PR body states both explicitly under "Not included"; the operator doc should too, since a repo with both classic and ruleset checks will still see only the classic set.
The required checks come from classic branch protection first. When classic
protection says nothing is required (the branch is unprotected, protection
lists no checks, or — without **Administration: Read-only** — the branch
payload lists none), the sweep also reads the branch's rulesets
(`GET /repos/{owner}/{repo}/rules/branches/{branch}`) and uses their
`required_status_checks` if any (`source=rules`). If that read fails or lists
none, the classic empty answer stands. When classic protection already lists
checks the rulesets are not read, so the sets are not unioned; GitHub still
enforces any ruleset check the hive missed at merge time. On a rulesets-only
repository the classic answer is always empty, so before this the sweep logged
`automerge required checks source … source=branch known=false count=0`, a
held head stayed at `ci-unverified`, and its runs were never approved
(projectbluefin/testsuite, bluefin-bling).
operator-reference.md:503 row and the changelog fragment match the code paths at automerge_contributor_held_runs.go:67,124-128.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (style/maintainability) — no blockers; two readability notes, both optional.
src/pkg/github/automerge/automerge_contributor_held_runs.go:103— the all-held gate testsmissing == ""as a proxy for "the reason isci-unverified". The intent only becomes clear after reading lines 85–88. Testing the reason directly reads as the comment describes it:
if reason == contributorHeldRunsCIUnverified && len(held) != len(workflowRunsForHeadRepo(runs.WorkflowRuns, headRepo)) {
automerge_contributor_held_runs.go:171/:185—heldWorkflowRunsForHeadnow duplicates the head-repo filter thatworkflowRunsForHeadRepointroduces. Composing them keeps the repo-matching rule in one place:
func heldWorkflowRunsForHead(runs []*gh.WorkflowRun, headRepo string) []*gh.WorkflowRun {
var held []*gh.WorkflowRun
- for _, run := range runs {
- if run == nil || !strings.EqualFold(run.GetConclusion(), workflowRunConclusionActionRequired) {
- continue
- }
- if run.GetHeadRepository() == nil || !strings.EqualFold(run.GetHeadRepository().GetFullName(), headRepo) {
- continue
- }
- held = append(held, run)
+ for _, run := range workflowRunsForHeadRepo(runs, headRepo) {
+ if strings.EqualFold(run.GetConclusion(), workflowRunConclusionActionRequired) {
+ held = append(held, run)
+ }
}
return held
}Advisory: src/pkg/github/commit_ci.go:194, :202, :214 repeat the same if rules, ok := rulesetRequiredWhenClassicEmpty(...); ok { return rules, true, false, false, "rules" } block three times; fine as-is, but a single classicEmpty(source) closure would make the fallback shape read once. Tests cover all three paths (merge_ci_policy_gap_test.go:230-240).
— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Summary
On a rulesets-only repository, the automerge sweep read the required checks as "none". A registry-trusted contributor's held fork runs were then never approved, and the PR sat at
ci-unverified.Seen on
hosted-projectbluefin-knuckle-gjvq(buildf950551), 2026-10-29:role/trustedauthor, wait on heldpull_requestruns.automerge required checks source repo=projectbluefin/testsuite branch=main source=branch known=false count=0for every testsuite PR.What GitHub returns for both repos (read 2026-10-29):
branches/main/protection/required_status_checksBranch not protected(403 for an App without Administration)branches/mainprotected:true,protection.enabled:false, emptycontexts,enforcement_level:"off"rules/branches/mainrequired_status_checks:Lint & syntax,Behave dry-run,pytest(testsuite)RequiredStatusCheckContextsDetailedWithSource(pkg/github/commit_ci.go) accepted the first two answers as a known-empty set and returned before it reached the rules endpoint. With a known-empty set,commitGreenasks only for positive CI evidence. A head whose runs are all held has none, so the lane reason isci-unverified.approveHeldRunsForRegistryTrustedacts only onrequired-check-missing:<ctx>, so it never fired.The serialized lane's
ReadBranchRules(pkg/github/branch_rules.go, #10894 / #10985) already treats a classic "branch not protected" as not authoritative. This brings the sweep's reader in line with it.Change
Required checks (
commit_ci.go). When classic protection says nothing is required, the sweep now readsGET /repos/{o}/{r}/rules/branches/{b}. If the rules list required checks, they are the set, with sourcerules. "Nothing required" covers three answers:If the rules endpoint fails or lists none, the classic known-empty answer stands as before. When classic protection lists checks, the rules endpoint is not read.
Held-run approver (
automerge_contributor_held_runs.go). It also acts atci-unverified, but only when everypull_requestrun for the PR's head repository isaction_required. All other conditions are unchanged:.github/workflows/**diff;This covers repositories whose required checks the hive cannot read at all. A head with any run already started is an ordinary evidence gap and is left alone.
Docs:
hive-merge.md(contributor lane and required-check source) and theapprove_held_runs_for_registry_trustedrow ofoperator-reference.md.Changelog:
changelog.d/fixed-required-checks-rulesets.md.Not included, and why
Testing
From
src/,TZ=UTC,-count=1:go test ./pkg/github/... ./cmd/hive/ ./pkg/mergelane/... ./pkg/dashboard/passes.go vetandgofmtare clean.New tests:
TestRequiredStatusCheckContexts, 7 new cases:enabled:falsebranch payload each defer to ruleset checks;TestContributorLaneApprovesHeldRunsOnRulesetsOnlyBranch: the testsuite shape, end to end through the lane. It stops atrequired-check-missing:<ctx>and approves the held fork runs once.TestContributorLaneApprovesHeldRunsWhenCIUnverifiedAndAllHeld:Five existing
commitGreen/ CI-trail fixtures failed on any unexpected request. They now serve an emptyrules/branchesanswer: no rulesets, so the same result as before.Mutation checks: 9 mutants, each restored from a backup copy, and every one fails a test:
Still open
hive:unauthorizedand waits for a click, as documented in Mark lanes unauthorized when the App lacks rights for the next step (held-run approval 403) #14589.Contributor checklist
changelog.d/fixed-required-checks-rulesets.md.v6.src/docs/hive-merge.md,src/docs/operator-reference.md).🤖 Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1