Repository navigation
π fix(automerge): name a fork head's workflow-file update refusal and stop retrying it - #15382
Conversation
β¦ stop retrying it GitHub refuses update-branch when the base changed .github/workflows/ and the head lives in a fork the App is not installed on. The classifier checked for the workflow refusal before looking at the fork flag, so the PR parked at 085 as workflow-permission, asking the owner to grant Workflows: write the App already held (projectbluefin/utah#1001), and the sweep sent the same refused update-branch every tick. - A workflow-file refusal (403, or 422 with the same text) on a fork head is fork-workflow-update: 085, with a cause naming who can update the branch and no permission ask. Same-repo heads keep workflow-permission, now worded "if the installation lacks it". - updateBranchAndSkip remembers a workflow-file refusal per head and base and does not call update-branch again until one of them moves. - The hold guard shares the classifier and gains the fork stop reason and note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[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 |
There was a problem hiding this comment.
Read the diff against the v6 tree plus the callers. Looks correct to me; nothing blocking.
What I verified:
- New enum value does not fall through anywhere unhandled.
ClassifyBranchUpdateErrorhas three switch sites. The diff updatescmd/hive/main_helpers.go:350andautomerge_sweep.go:2644. The third,automerge_adoption_recovery.go:234(recoverByUpdateBranch), already routes the existingupdateBranchWorkflowPermissiontodefaultβupdate-branch-failed, soupdateBranchForkWorkflowUpdatelands in the same bucket β same behaviour as before, no regression. - Merge-forward path is unaffected.
mergeForwardOrConflictreturnsconflictingfor any fork atautomerge_merge_forward.go:82before reaching itsIsWorkflowPermissionRefusalbranch, so it never needs the fork variant. - Memo keying.
branchUpdateWorkflowRefusedKeyincludes both head and base SHA and is namespaced (#update-branch-workflow-refused@) so it cannot collide withmergeForwardKey/mergeForwardWorkflowRefusedKeyin the sharedheldRunApprovalsmap.currentBaseGatekeys oncompare.base_commit.shawhile the other callers key onpr.base.sha; both are the base tip, and a mismatch would only cost one extra attempt, not a loop. - Classifier widening to 422 is gated on the same
WorkflowPermissionRefusalPattern, so plain 422 conflicts / up-to-date still reach the existingswitch(covered by the new fork rows inTestClassifyUpdateBranchError). - No other enumeration of
workflow-permissionexists in Go or dashboard TS/JS outside the files the diff touches.
One note, not a finding: the memo is process-local, so a restart yields one fresh update-branch attempt per head/base β the body already says so, and it matches the merge-forward precedent.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the diff against the v6 merge-base and the callers it touches; this looks correct to me.
What I verified in the tree at 6e6abd3:
- Classifier (
src/pkg/github/branch_update_refusal.go:40-46): the workflow-text match is now checked on 403 and 422 and splits onforkbefore the generic 403/422 arms, so a fork head no longer lands inBranchUpdateForkNotEditableorconflict. Same-repo heads still returnBranchUpdateWorkflowPermission. - Memo (
src/pkg/github/automerge/automerge_sweep.go:2646-2651, 2659-2667, 2688-2711): keyed onevaluatedHeadKey + headSHA + baseSHAinheldRunApprovals, the same store and lockmergeForwardWorkflowRefusedKeyuses (automerge_merge_forward.go:45-66). Only the two workflow refusals are recorded;fork-not-editablestill retries every tick, which is right since the author can cure it without moving a SHA. - All five
updateBranchAndSkipcallers passpr.GetBase().GetSHA(); the current-base gate passescmp.GetBaseCommit().GetSHA()(automerge_current_base.go:70-74), so a base move does invalidate the memo there. - The third classifier caller the body does not mention β
recoverByUpdateBranchinautomerge_adoption_recovery.go:234-243β has no case for either workflow class and falls todefaultβupdate-branch-failed. That was already its behaviour forworkflow-permissionbefore this change, so nothing regresses; just noting it is intentionally untouched. - Hold guard (
cmd/hive/main_helpers.go:350-355,pkg/holdguard/holdguard.go:385, 758-760) and stage routing (pkg/stageengine/derive_pr_classify.go:286) both carry the new reason, so it reaches 085 rather than the transient-retry default.
The body matches the diff. Test shards are green on this head.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
Summary
The automerge sweep calls a fork PR's workflow-file update-branch refusal
workflow-permission. It parks the PR at 085 with advice to "grant the App Workflows: write", then sends the same refused update-branch again every tick.Seen on
hosted-projectbluefin-knuckle-gjvq(buildf950551), 2026-10-29, on projectbluefin/utah#1001:The PR: approved, 19/19 checks green, parked at
stage/085-needs-decisionwith theworkflow-permissiontext.The head is in a fork:
hanthor/utah:fix/gnome-extension-updater-skip-invalid-source, withmaintainerCanModify=true. It was 12 commits behindmain, which had changed 5 workflow files.The App already has
workflows: writein projectbluefin. It pushed workflow changes itself in utah#936 (commitc3d4f319,.github/workflows/post-testing-e2e.yml) and in ghostscript-printer-app#140 (scorecard.yml,validate.yml).The refusal comes from the fork. The App is not installed on the fork, so no grant on the base repository lets it push workflow files there. The 085 note sends the owner after a permission they already granted.
The log repeats every ~3 minutes:
automerge head is behind the current base; updating before merge(behind_by 12);automerge update-branch refused: the base changed workflow files and the app lacks the workflows permission;automerge skip reason=workflow-permission.It is the same head and base each time.
Cause:
ClassifyBranchUpdateError(pkg/github/branch_update_refusal.go) checked for a workflow refusal before it looked atfork.updateBranchAndSkip(pkg/github/automerge/automerge_sweep.go) kept no record of a refusal. The merge-forward path already records one per head (mergeForwardWorkflowRefusedKey); the update-branch path had nothing like it.Change
New reason
fork-workflow-update. A workflow-file refusal (403, or 422 with the same text) on a fork head is nowBranchUpdateForkWorkflowUpdateand the lane reasonfork-workflow-update. A same-repo head keepsworkflow-permission. The 085 cause says:.github/workflows/, which the App cannot push to a fork;gh pr update-branchor merges the base in and pushes.It names no permission.
Why a new 085 reason, not
fork-not-editable:fork-not-editableis a fixing reason (071/072). Its ask reads "enable "allow edits by maintainers" or rebase", which is wrong advice again when maintainer edits are already on, as on utah#1001.stageNeedsHumanReasonskeeps the stage these PRs reach today (085, next toworkflow-permission), so only the text changes. A person still has to act, and no hive agent can.Same-repo wording (
workflow-permission). It now says the token the hive used lacks the permission, which GitHub's refusal proves. It asks for the grant only "if the installation lacks it". The sweep has no cheap way to read the installation's grant: the permissions read lives inapp_state.go, and the decision text is a pure function of the reason.No retry loop. After a workflow-file refusal,
updateBranchAndSkipdoes not call update-branch again until the head or the base moves. It keeps the reason in the meantime.heldRunApprovals, likemergeForwardWorkflowRefusedKey.base_commit.sha); the other callers use the PR'sbase.sha.updating before mergeinfo line is skipped while the memo holds.fork-not-editablerefusal can be cured by the author ticking "Allow edits by maintainers" without moving either SHA.Hold guard (
cmd/hive/main_helpers.go,pkg/holdguard). It shares the classifier, so it gainsUpdateStopForkWorkflowUpdate. Its one-time note says the branch is in a fork and asks the author to merge the base in. Without that case, the new class would have fallen to the transient default and retried every pass.Docs: the
stage/085-needs-decisionrow and the decision-cause row oflabels-and-control-signals.md.Changelog:
changelog.d/fixed-fork-workflow-update-refusal.md.Not included, and why
workflowsgrant from the sweep. WiringAppAuthDiagnosisinto the decision text would add a dependency for one sentence. "If the installation lacks it" is true either way.Testing
From
src/,TZ=UTC,-count=1:go test ./pkg/github/... ./pkg/stageengine/... ./pkg/holdguard/... ./cmd/hive/ ./pkg/dashboard/ ./pkg/mergelane/...passes.go vetandgofmtare clean on the touched packages.go test ./pkg/stageengine -run TestStageGoldens -update. Only the new reason's cases and the rewordedworkflow-permissiontext changed. The regeneration also rewrote one unrelated note inregressions.json, which was already out of date onv6; that file was left as it was.New and changed tests:
TestClassifyUpdateBranchError, which now covers fork and same-repo crossed with:TestUpdateBranchAndSkipWorkflowRefusalNotRetried, for both fork and same-repo:TestUpdateBranchAndSkipRetriesOtherRefusals: afork-not-editablerefusal is still tried every tick.TestCurrentBaseGateWorkflowRefusalKeyedOnBaseTip: the utah#1001 path. Two sweeps on one compared base tip make one call, and a moved tip makes another.TestMaintainHeldPRMergeabilityStopsOnForkWorkflowRefusal: a held fork PR with maintainer edits on gets one attempt and one note, which names no permission.Mutation checks: 12 mutants, each restored from a backup copy, and every one fails a test:
fork;stageNeedsHumanReasons;Still open
main,304acd97c, 2026-10-29T11:58Z); this change only affects the next PR in that position.Contributor checklist
changelog.d/fixed-fork-workflow-update-refusal.md.v6.src/docs/labels-and-control-signals.md).π€ Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1