Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-renovate-branch-updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Auto-merge no longer merges the base branch into dependency-bot PRs (a `renovate/*` head branch or a `renovate[bot]`, `dependabot[bot]` or `mergeraptor[bot]` author) once they are out of hold: the lanes' update-branch, the current-base refresh, merge-forward, the merge train's sibling update and rebase requests, the trusted-author fixer rebase, adopted-PR recovery and `hive-merge --update-branch` all leave the rebase to the bot, and a behind bot branch holds as `behind` instead. A hive commit made Renovate stop rebasing the branch for good.
22 changes: 22 additions & 0 deletions src/cmd/hive/adopted_pr_fixer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,28 @@ func TestWriteMergeEligible_UntrustedConflictIsNotHiveRebaseWork(t *testing.T) {
}
}

// projectbluefin/utah#1097: a dirty Renovate branch is never the fixer's
// rebase work, even under a trusted author's identity — the bot resolves
// its own conflicts, and a hive push would stop it rebasing the branch for
// good. The same PR on an ordinary branch is (TestWriteMergeEligible_
// TrustedAuthorConflictGetsRebaseKickWithLoopGuard).
func TestWriteMergeEligible_TrustedDependencyBotConflictIsNotHiveRebaseWork(t *testing.T) {
useMemoryRebaseAttempts(t)
cfg := trustedAuthorRebaseConfig()
pr := github.PullRequest{Number: 15091, Repo: "hive", Author: "clubanderson", HeadSHA: "fff6666",
HeadRef: "renovate/go-deps", HeadRepo: "hivecommons/hive", BaseRef: "v5",
Mergeable: github.MergeableNo, MergeableState: "dirty", CIStatus: "pending", Labels: []string{"needs-rebase"}}
_, failing := runWriteMergeEligible(t, []github.PullRequest{pr}, mergeEligibleInputs{org: "hivecommons", cfg: cfg})
if len(failing) != 0 {
t.Fatalf("ci_failing = %+v, want nothing for a dependency bot's conflict", failing)
}
pr.HeadRef = "feat/x"
_, failing = runWriteMergeEligible(t, []github.PullRequest{pr}, mergeEligibleInputs{org: "hivecommons", cfg: cfg})
if len(failing) != 1 || !failing[0].TrustedAuthor {
t.Fatalf("ci_failing = %+v, want the ordinary branch listed as trusted-author rebase work", failing)
}
}

// sweepRebaseLogged runs one writeMergeEligible sweep at now and returns the
// ci-failing rows and the number of "routed to fixer for rebase" lines.
func sweepRebaseLogged(t *testing.T, prs []github.PullRequest, now time.Time) ([]failingEntry, int) {
Expand Down
15 changes: 2 additions & 13 deletions src/cmd/hive/main_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func enforceHoldGuard(
// pinned, and advancing a baseline that was never pinned would plant a wrong
// one.
//
// Branches a dependency bot owns (dependencyBotBranch) are skipped too: the
// Branches a dependency bot owns (github.DependencyBotBranch) are skipped too: the
// bot rebases them itself, and a hive commit on the branch makes Renovate stop
// rebasing it for good.
func maintainHeldPRMergeability(
Expand All @@ -354,7 +354,7 @@ func maintainHeldPRMergeability(
if state != "behind" && state != "dirty" {
continue
}
if dependencyBotBranch(pr) {
if github.DependencyBotBranch(pr.HeadRef, pr.Author) {
logger.Debug("hold guard: held PR branch belongs to a dependency bot; leaving the base sync to the bot",
"repo", repo, "pr", pr.Number, "head_ref", pr.HeadRef, "author", pr.Author, "mergeable_state", state)
continue
Expand Down Expand Up @@ -448,17 +448,6 @@ func maintainHeldPRMergeability(
}
}

// dependencyBotBranch reports whether a PR's head branch belongs to a
// dependency bot that keeps it up to date itself: a `renovate/` head ref (any
// Renovate deployment, whatever App it runs as) or a dependencyBots author.
// Renovate refuses to rebase a branch once another identity has committed to
// it, so a hive merge-from-base on such a branch strands it behind its base
// for good (projectbluefin/utah#1097: three hive base merges, then "will not
// automatically rebase … does not recognize the last commit author").
func dependencyBotBranch(pr github.PullRequest) bool {
return strings.HasPrefix(pr.HeadRef, "renovate/") || dependencyBots[pr.Author]
}

// intentConfigFromCfg maps config.IntentConfig onto the intent package's
// classification config. Shared by writeIntentVerdicts (human merge lane) and
// the App self-merge sweep's IntentGate (#6258) so both lanes classify with
Expand Down
24 changes: 7 additions & 17 deletions src/cmd/hive/main_sweeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,14 @@ func redPRFixOwner(agent string) string {
return review.DefaultFixerAgent
}

// dependencyBots are forge bots whose PRs are dependency bumps, not hive fix
// attempts. They carry the "[bot]" suffix that otherwise marks a PR as
// agent-authored, but nothing in the hive opened them and no hive agent is
// iterating on them, so a red one is not a fix loop to break: escalating it
// only pages a human with "1 distinct fix attempts" about a crate bump that
// renovate will rebase on its own. Mirrors the hub's default contribute
// deny-authors list (config: hub.contribute_deny_authors).
var dependencyBots = map[string]bool{
"renovate[bot]": true,
"dependabot[bot]": true,
"mergeraptor[bot]": true,
}

// isHiveAgentAuthor reports whether a PR author is one of OUR agents — the
// configured ai_author, the App bot identity agents author as, or another
// bot account — excluding the dependency bots above. Shared by every fix-loop
// path (staleness clock, reaper, escalation sweep) so they classify PRs
// identically.
// bot account — excluding the dependency bots (github.IsDependencyBotAuthor):
// nothing in the hive opened those and no hive agent iterates on them, so a
// red one is not a fix loop to break — escalating it only pages a human with
// "1 distinct fix attempts" about a crate bump the bot rebases on its own.
// Shared by every fix-loop path (staleness clock, reaper, escalation sweep)
// so they classify PRs identically.
func isHiveAgentAuthor(cfg *config.Config, author string) bool {
if author == "" {
return false
Expand All @@ -166,7 +156,7 @@ func isHiveAgentAuthor(cfg *config.Config, author string) bool {
if eff := cfg.EffectiveAIAuthor(); eff != "" && author == eff {
return true
}
return strings.HasSuffix(author, "[bot]") && !dependencyBots[author]
return strings.HasSuffix(author, "[bot]") && !github.IsDependencyBotAuthor(author)
}

// isIndependentCIControl reports whether a PR supplies human-authored evidence
Expand Down
5 changes: 4 additions & 1 deletion src/cmd/hive/merge_eligibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,11 @@ const mergeTrainRebaseRequester = "merge-train"
// would merge it unattended) whose head the hive can push to. Its rebase is
// the hive's: the trusted-author lane never rebases, and the author is a
// person who opened it through the hive and expects the hive to carry it.
// A dependency bot's branch never is: the bot resolves its own conflicts,
// and a fixer push would stop it rebasing the branch for good
// (github.DependencyBotBranch).
func trustedAuthorRebasePR(cfg *config.Config, fullRepo string, pr github.PullRequest) bool {
if cfg == nil || github.ReachableAction(pr) != github.ReachableActionPush {
if cfg == nil || github.ReachableAction(pr) != github.ReachableActionPush || github.DependencyBotBranch(pr.HeadRef, pr.Author) {
return false
}
policy := trustedAuthorPolicyFunc(cfg)()
Expand Down
22 changes: 20 additions & 2 deletions src/docs/hive-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,21 @@ holds a behind head until the update lands. On current-base-gated repositories
the separate preparation owner above refreshes the next admitted head, rather
than refreshing every waiting sibling when a front merges.

**Dependency-bot branches are the bot's to rebase.** A PR whose head ref is
`renovate/*` or whose author is `renovate[bot]`, `dependabot[bot]` or
`mergeraptor[bot]` never gets a hive commit merging its base: no lane
update-branch, no current-base refresh, no merge-forward, no merge-train
update or rebase request, no trusted-author fixer rebase, no adopted-PR
recovery update and no `hive-merge --update-branch`. Renovate stops rebasing
a branch for good once another identity has committed to it
([projectbluefin/utah#1097](https://github.com/projectbluefin/utah/pull/1097)).
A behind bot branch holds as `behind` (logged once per head as `leaving the
base sync to the bot`) until the bot rebases it — Renovate does so on its own
when the repository requires up-to-date branches, and resolves conflicts on
its own. On a repository gated only by `require_current_base_default` (no
GitHub up-to-date rule, so no bot rebase is coming) such a head merges as
tested, like a head the App may not write.

The train's order is **readiness first**. Each pass the lane sorts the
members by what it last saw of their heads: a head at the merge gate —
green, approved, soaking or waiting on a sweep — leads; a head the lane has
Expand Down Expand Up @@ -1154,7 +1169,8 @@ the head when it is behind (GitHub update-branch, which works on a fork the
maintainers may edit) or re-runs the failed workflow jobs when it is current,
at most once per (head, base tip) and three times per adoption, logged as
`adopted PR recovery` with `reason=update-branch`, `rerun-failed-jobs` or
`skipped:<why>`; an escalation already in place for that head is released
`skipped:<why>` (`skipped:dependency-bot-branch` for a behind `renovate/*` or
dependency-bot branch, which is never updated); an escalation already in place for that head is released
(hivecommons/hive#14500). An adoption with nothing the hive can
push past the dwell — after that recovery was tried and the head is still
red — goes to `stage/085-needs-decision` as
Expand Down Expand Up @@ -1435,7 +1451,9 @@ lookup fails), the script prints an error naming the token-cache path and
When set, the watcher syncs the PR branch with its base before attempting the
merge (resolves the common "behind main" case). A failure to update the
branch is not fatal — the merge attempt still proceeds and surfaces the real
blocker.
blocker. A dependency bot's branch (`renovate/*` head ref, or a Renovate,
Dependabot or Mergeraptor author) is never updated: the watcher logs the skip
and goes straight to the merge attempt, leaving the rebase to the bot.

## It is asynchronous, by design

Expand Down
Loading
Loading