Skip to content

πŸ› fix(automerge): name a fork head's workflow-file update refusal and stop retrying it - #15382

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/fork-workflow-update-refusal
Oct 29, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/fork-workflow-update-refusal

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

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 (build f950551), 2026-10-29, on projectbluefin/utah#1001:

  • The PR: approved, 19/19 checks green, parked at stage/085-needs-decision with the workflow-permission text.

  • The head is in a fork: hanthor/utah:fix/gnome-extension-updater-skip-invalid-source, with maintainerCanModify=true. It was 12 commits behind main, which had changed 5 workflow files.

  • The App already has workflows: write in projectbluefin. It pushed workflow changes itself in utah#936 (commit c3d4f319, .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 at fork. 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 now BranchUpdateForkWorkflowUpdate and the lane reason fork-workflow-update. A same-repo head keeps workflow-permission. The 085 cause says:

    • the head is in a fork and the base changed .github/workflows/, which the App cannot push to a fork;
    • the author, or a maintainer with push access when "Allow edits by maintainers" is on, runs gh pr update-branch or merges the base in and pushes.

    It names no permission.

  • Why a new 085 reason, not fork-not-editable:

    • fork-not-editable is 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.
    • A new reason in stageNeedsHumanReasons keeps the stage these PRs reach today (085, next to workflow-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 in app_state.go, and the decision text is a pure function of the reason.

  • No retry loop. After a workflow-file refusal, updateBranchAndSkip does not call update-branch again until the head or the base moves. It keeps the reason in the meantime.

    • The memo is per head and base in heldRunApprovals, like mergeForwardWorkflowRefusedKey.
    • The current-base gate keys it on the compared base tip (base_commit.sha); the other callers use the PR's base.sha.
    • The gate's updating before merge info line is skipped while the memo holds.
    • Other refusals are not remembered. A fork-not-editable refusal 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 gains UpdateStopForkWorkflowUpdate. 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-decision row and the decision-cause row of labels-and-control-signals.md.

  • Changelog: changelog.d/fixed-fork-workflow-update-refusal.md.

Not included, and why

  • No read of the installation's workflows grant from the sweep. Wiring AppAuthDiagnosis into the decision text would add a dependency for one sentence. "If the installation lacks it" is true either way.
  • No time-based retry. A grant change on a same-repo head is picked up when the head or base next moves, or on restart. The base moves often on an active repository.
  • Which PRs need an up-to-date base is a per-repository ruleset choice, and is out of scope.

Testing

From src/, TZ=UTC, -count=1:

  • go test ./pkg/github/... ./pkg/stageengine/... ./pkg/holdguard/... ./cmd/hive/ ./pkg/dashboard/ ./pkg/mergelane/... passes.
  • go vet and gofmt are clean on the touched packages.
  • The changelog, docs-links and docs-citations checks pass.
  • The stage goldens were regenerated with go test ./pkg/stageengine -run TestStageGoldens -update. Only the new reason's cases and the reworded workflow-permission text changed. The regeneration also rewrote one unrelated note in regressions.json, which was already out of date on v6; that file was left as it was.

New and changed tests:

  • TestClassifyUpdateBranchError, which now covers fork and same-repo crossed with:
    • a workflow refusal (403, 422, and wrapped by the mutation ledger);
    • a plain 403;
    • a 422 conflict;
    • up to date.
  • TestUpdateBranchAndSkipWorkflowRefusalNotRetried, for both fork and same-repo:
    • three sweeps on one head and base make one update-branch call;
    • a new base makes one more call;
    • a new head makes one more call.
  • TestUpdateBranchAndSkipRetriesOtherRefusals: a fork-not-editable refusal 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.
  • Text assertions for both decision causes and both hold-guard notes.

Mutation checks: 12 mutants, each restored from a backup copy, and every one fails a test:

  • the classifier's fork branch dropped, and 422 workflow refusals ignored;
  • the memo check removed;
  • the memo key without the base, or without the head;
  • the fork refusal not remembered;
  • the replayed reason ignoring fork;
  • the current-base gate passing no base tip;
  • the new reason left out of stageNeedsHumanReasons;
  • the hold guard's fork case removed, and its note reverted to the permission text;
  • the fork decision cause asking for the grant.

Still open

  • utah#1001 itself was brought up to date by hand (merge of main, 304acd97c, 2026-10-29T11:58Z); this change only affects the next PR in that position.
  • Not run on a live hive.

Contributor checklist

  • Changelog: changelog.d/fixed-fork-workflow-update-refusal.md.
  • Targets v6.
  • The title uses the emoji convention.
  • Commits include DCO sign-off.
  • Docs updated (src/docs/labels-and-control-signals.md).
  • No secrets, credentials or local runtime state are committed.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

… 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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 29, 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

@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 29, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. ClassifyBranchUpdateError has three switch sites. The diff updates cmd/hive/main_helpers.go:350 and automerge_sweep.go:2644. The third, automerge_adoption_recovery.go:234 (recoverByUpdateBranch), already routes the existing updateBranchWorkflowPermission to default β†’ update-branch-failed, so updateBranchForkWorkflowUpdate lands in the same bucket β€” same behaviour as before, no regression.
  • Merge-forward path is unaffected. mergeForwardOrConflict returns conflicting for any fork at automerge_merge_forward.go:82 before reaching its IsWorkflowPermissionRefusal branch, so it never needs the fork variant.
  • Memo keying. branchUpdateWorkflowRefusedKey includes both head and base SHA and is namespaced (#update-branch-workflow-refused@) so it cannot collide with mergeForwardKey / mergeForwardWorkflowRefusedKey in the shared heldRunApprovals map. currentBaseGate keys on compare.base_commit.sha while the other callers key on pr.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 existing switch (covered by the new fork rows in TestClassifyUpdateBranchError).
  • No other enumeration of workflow-permission exists 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on fork before the generic 403/422 arms, so a fork head no longer lands in BranchUpdateForkNotEditable or conflict. Same-repo heads still return BranchUpdateWorkflowPermission.
  • Memo (src/pkg/github/automerge/automerge_sweep.go:2646-2651, 2659-2667, 2688-2711): keyed on evaluatedHeadKey + headSHA + baseSHA in heldRunApprovals, the same store and lock mergeForwardWorkflowRefusedKey uses (automerge_merge_forward.go:45-66). Only the two workflow refusals are recorded; fork-not-editable still retries every tick, which is right since the author can cure it without moving a SHA.
  • All five updateBranchAndSkip callers pass pr.GetBase().GetSHA(); the current-base gate passes cmp.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 β€” recoverByUpdateBranch in automerge_adoption_recovery.go:234-243 β€” has no case for either workflow class and falls to default β†’ update-branch-failed. That was already its behaviour for workflow-permission before 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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed β€” no findings from this perspective.

β€” hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed β€” no findings from this perspective.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

@hivecommons-hive
hivecommons-hive Bot merged commit c6185a2 into hivecommons:v6 Oct 29, 2026
64 of 66 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#153826e6abd3` sha256:bf0be2891377fa6626c13b57ad54d4516488bcffc8f0c88342d05406b3f1c03b β€” download from the dashboard or `hivectl review evidence #15382`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @Danathar holds role owner and GitHub permission maintain on repo; CI green at 6e6abd3.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed β€” no findings from this perspective.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant