Skip to content

πŸ› adoption: keep a same-repo PR in place across a base workflow change when the fixer can push it - #19308

Merged
hivecommons-hive[bot] merged 3 commits into
hivecommons:v6from
Danathar:fix/update-branch-workflows-token
Nov 19, 2026
Merged

hivecommons-hive[bot] merged 3 commits into
hivecommons:v6from
Danathar:fix/update-branch-workflows-token

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

When a base-sync carries .github/workflows/ changes, an adopted same-repo PR now stays on its own branch if the agent that would rebase it can push workflow files. Before, it was always closed and re-opened as a copy. Fork heads are unchanged.

What was wrong

#12865 / #12872 superseded every adopted PR whose base-sync touched .github/workflows/. That was deliberate at the time. Its premise came from #6985: the App had no Workflows grant, so neither a fork nor the base repo could take the push.

The premise has since changed. Installations now grant workflows: write (#14664), and v6's pr_merge_state.go already fences only forks. Same-repo PRs were still being closed and re-opened, losing their approvals and numbers. On 11-18, projectbluefin/common#1689 was superseded into #1708, and castrojo's approval was lost. The log line was "base-sync touches .github/workflows/ which the App cannot push; superseding". No GitHub call had been refused.

What it wasn't: the governor's update-branch token isn't missing the grant. It's an unscoped installation token (AppAuth.Token(), minted with no options), so it carries every installation permission. The two 403s from 11-19 have different causes:

What changed

  • Who must be able to push. A conflicting adopted head is rebased by the fallback fixer (routeConflictFixAgent β†’ scanner). Red CI on an adopted head goes there too. So the gate asks that agent, not "any trusted lane": AgentWorkflowsPushable(ctx, FallbackFixAgent) needs the agent's tier to request Workflows (trusted or merger) and the installation to grant workflows: write.
    • It's checked once, at adoption time, because a head that's clean when adopted can still conflict later.
    • FallbackFixAgent is now one shared constant used by both routeConflictFixAgent and automerge.
  • Same-repo head with a base workflow change: kept in place when that holds, and superseded as before otherwise. A compare error still supersedes. The same check also lets a DCO-red adopted same-repo head be repaired in place instead of re-homed.
  • Fork heads: unchanged. They never consult the grant.
  • Adopted-PR recovery: a refused update-branch now logs fork-workflow-update or workflow-permission instead of the catch-all update-branch-failed.
  • No new setting.

On a hive whose scanner is below the trusted tier, these PRs still supersede. That's safe, and the docs now say so.

Tests

  • TestAgentWorkflowsPushable covers the real predicate:
    • grant present but the fixer at contributor tier (another lane trusted) β†’ false;
    • fixer trusted β†’ true;
    • token client β†’ false;
    • read-only grant β†’ false;
    • installation read error β†’ false;
    • nil client β†’ false.
  • TestAdoptionInPlaceWorkflowGuardHonoursGrant covers four outcomes: the fixer can push β†’ in place; it can't β†’ supersede; a compare error β†’ supersede; no workflow change β†’ no capability read. It also asserts that the agent asked is FallbackFixAgent.
  • TestAdoptionForkWorkflowGuardIgnoresGrant: a fork with the grant is still not adopted or copied, and the grant isn't read.
  • TestAdoptedRecoveryForkWorkflowRefusalNamed (end to end): a fork head 18 behind whose update-branch gets the 403 logs skipped:fork-workflow-update, with no copy. TestAdoptionRecoveryUpdateBranchSkip checks the reason mapping.
  • Docs: labels-and-control-signals/stage-labels.md (in-place and supersede modes) and hive-merge.md (recovery reasons). Changelog: changelog.d/fixed-adopt-in-place-workflows-grant.md.

No App permission change is needed or proposed.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

Danathar and others added 2 commits November 19, 2026 12:42
…e when the App can push it

canPushToPRBranch ran baseSyncTouchesWorkflows before its same-repo
check, and baseSyncTouchesWorkflows assumed the App can never push a
base-sync that carries a .github/workflows/ change. That holds for a
fork head (the fork is not in the installation), but on a branch of the
base repository the push lands once the installation grants
workflows: write. So the hive superseded same-repo PRs it could have
adopted in place, closing them and losing their approvals
(projectbluefin/common#1689 -> hivecommons#1708, hivecommons#1690 -> hivecommons#1710).

A same-repo head now supersedes on a base workflow change only when
hgithub.Client.WorkflowsPushable is false (no grant, or no trusted or
merger lane serving the repo). Fork heads and compare failures behave as
before.

Adopted-PR recovery also logs a refused update-branch with the merge
sweep's reasons (fork-workflow-update, workflow-permission) instead of
the catch-all update-branch-failed, which is what
projectbluefin/utah-packages#1173 and projectbluefin/actions#752 showed:
both are fork heads that no App grant can update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com>
…, not any lane

Review of the previous commit: WorkflowsPushable asks whether any
trusted or merger lane serves the repo, but an adopted head that
conflicts (or stays red) is pushed by the fallback fixer that
routeConflictFixAgent picks, scanner. A hive with ci-maintainer at
trusted and scanner at contributor tier passed the gate, adopted in
place, and then scanner's push was refused, the hivecommons#12865 dead end.

- pkg/github: FallbackFixAgent is the one name for that fixer, used by
  routeConflictFixAgent and the adoption sweep. AgentWorkflowsPushable
  reports an agent's own capability: its tier asks for Workflows
  (SetWorkflowsSelfPushFunc) and the installation grants
  workflows: write.
- automerge: baseSyncTouchesWorkflows keeps a same-repo head in place
  only when AgentWorkflowsPushable(FallbackFixAgent) holds. The comment
  now says the premise of hivecommons#12865 changed (hivecommons#14664 found the grant;
  pr_merge_state.go fences only forks).
- Tests: TestAgentWorkflowsPushable for the real predicate (contributor
  fixer with the grant, trusted fixer, token client, read-only grant,
  failed read); TestAdoptedRecoveryForkWorkflowRefusalNamed drives
  recoverByUpdateBranch end to end on a fork head.
- Docs and changelog name the fixer condition and the DCO in-place
  repair it also unlocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Danathar <6772335+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 Nov 19, 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 kellyaa 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#19311 πŸ› base red: read the base tip and hold automatic adoption until the base-red memory is published same files src/cmd/hive/merge_eligibility.go
src/docs/labels-and-control-signals/stage-labels.md
src/pkg/github/automerge/automerge_contributor_adopt.go

@hivecommons-hive
hivecommons-hive Bot merged commit 7087d5a into hivecommons:v6 Nov 19, 2026
71 checks passed
@hivecommons-hive

hivecommons-hive Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

Evidence bundle `#193084a39e77` sha256:87f5d0ff63a1d6d328da5849dc28a80d4e28ae02739935bf9f3e12b8406041a5 β€” download from the dashboard or `hivectl review evidence #19308`.

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

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant