Skip to content

✨ feat(dependency-bots): ask a stranded bot to rebase its own PR - #17591

Merged
hivecommons-hive[bot] merged 4 commits into
hivecommons:v6from
Danathar:feat/dep-bot-rebase-request
Nov 10, 2026
Merged

hivecommons-hive[bot] merged 4 commits into
hivecommons:v6from
Danathar:feat/dep-bot-rebase-request

Conversation

@Danathar

@Danathar Danathar commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A dependency bot stops maintaining a branch as soon as someone else commits to it (a person clicking Update branch, a stray merge-forward). The hive, by design, never base-syncs a bot's branch (#16862). So on a base that requires up-to-date branches, such a PR sits behind forever: the hive won't sync it, the bot won't, and nobody is told. On a live hive, three bot PRs sat behind for 7+ hours until a person ticked Renovate's rebase box by hand.

This PR teaches the existing dependency-bot hand-off sweep to notice a stranded bot PR and ask the bot, once per head, to rebase it through the bot's own mechanism: it ticks Renovate's rebase/retry checkbox, or comments @dependabot recreate. If the head hasn't moved one window later, the PR goes to a person through the existing hand-off. The write is a new write-back kind, bot_rebase_request, defaulting to L6 with the opt-in label (same as base_refresh).

Why

The sweep in cmd/hive/dependency_bot_handoffs.go already hands conflicting, red-CI and held bot PRs to a person. It had two gaps:

  1. A bot PR that is only behind (not conflicting) was never handed off at all.
  2. Nothing ever asked the bot itself to rebase, even though that is a safe write through the bot's own mechanism.

How

Detection. A dependency-bot PR (Renovate, Dependabot, mergeraptor, or any renovate/* head) is stranded when it has been behind or conflicting for longer than governor.dependency_bot_rebase_after_s (default 4 hours) and either its head commit is not the bot's, or its Renovate description says it rebases never (the existing renovateRebasesNever check). A bot-authored head that is merely behind is left to the bot. "The bot's" means any dependency-bot login or the PR author, because a Renovate deployment can author PRs as one App and commit as renovate[bot]. The commit list is read once per head, after the window, and cached in memory.

Request. At most once per (PR, head), persisted:

  • Renovate: the PR is re-read and its description written back with only - [ ] → - [x] on the <!-- rebase-check --> line. Every other byte, CRLF included, is unchanged. If the box is already ticked, nothing is written and the bot gets one window from then. If the box is absent, the PR goes to a person.
  • Dependabot: @dependabot recreate, through a journaled comment keyed on the head SHA, so a later head isn't swallowed as a replay. It goes through github.PostBotCommand, which is now also the poster for the automerge sweep's existing @dependabot rebase nudge, with that nudge's body, journal claim and bookkeeping unchanged. A bot command can't carry a marker, so the two share one emitter: the comment-marker ratchet stays at its baseline, and the raw call moves (write-ratchet baseline 3→2 in automerge_held_runs.go, +1 in dependency_bot_rebase.go). I used recreate, not rebase, because Dependabot refuses @dependabot rebase on a branch someone else has pushed to ("Looks like this PR has been edited by someone other than Dependabot"), and a stranded Dependabot PR is exactly that case.
  • Never when the branch carries someone else's non-merge commit (a real fix, a workflow's lockfile repair). Regenerating would drop it, so that PR goes to a person at the window instead. Merge-of-base commits are the only foreign commits the hive will let the bot discard.

Hand-off. If the head is unchanged one window after the request, the sweep posts one comment plus needs-human through the existing hand-off (markCommented, label retry, undo) with the new reason bot-will-not-rebase ("dependency bot will not rebase this branch"). It is never re-requested on that head. A new head resets everything. The label comes off when the head moves or GitHub reports the PR neither behind nor conflicting.

Interplay with the conflict hand-off. While a request is due or pending on a conflicting PR (kind allowed), the existing conflict and red-CI hand-offs wait, with their grace clocks still running. The PR gets the bot request first and the person's comment afterwards, never both at once. This includes the immediate hand-off for a rebaseWhen: never Renovate PR: with the kind allowed, it now gets the box ticked at the window instead. When the kind is off, conflicting PRs keep today's behaviour exactly (24 hours, or at once for rebases-never).

Write-back gate and default. bot_rebase_request defaults to {min_level: 6, require_label: true}, the same as base_refresh and ci_rerun. Those are the other kinds that cause a new head or CI run on someone else's PR, and this one makes the bot force-push its branch. An operator who wants it on every bot PR at L6 sets writeback.kinds.bot_rebase_request.unlabeled_min_level: 6. It is not content-deduped (once-per-head idempotence is its own), like base_refresh. When the kind refuses, the hive only reports: a log line, plus the existing person hand-off for a stranded PR that is behind once the window passes. The pre-write probe uses Gate.Decide, so it doesn't fill the suppressed list every pass. The write itself goes through WritebackAllowed.

State. First-seen and requested heads persist in dependency-bot-conflicts-rebase.json beside the existing conflict ledger, so a restart neither resets the window nor repeats a request.

Dashboard / MCP parity

Both surfaces enumerate kinds from the registry (writeback.Kinds() / EffectiveKinds()). Settings → Features → Write-back containment shows and edits the new row, and the admin MCP writeback.kind_policy operation accepts it, with no hard-coded list to extend. Tests added: a registry/gate test for the default and an override, plus an MCP table case for bot_rebase_request. static/index.html is unchanged (no static-src edits; concatenation cmp is clean). The window key is yaml-only, like the other governor.*_s tuning knobs, and allowlisted in settings_parity_allowlist.txt.

Docs

  • operator-reference/README.md: the dependency-bot hand-off section now describes the stranded flow, the key, the kind and its default.
  • operator-reference/sweeps-and-operations.md: a row in "what hive writes".
  • acmm-policy-matrix.md: the kind is added to the L6 + label row.
  • github-write-surface.md: a row and the audit action dependency_bot_rebase_requested.
  • notifications.md: the recreate command is recorded as protocol_command.
  • changelog.d/added-dependency-bot-rebase-request.md.
  • Shifted governor_config.go / defaults.go line citations in labels-and-control-signals/reference.md are fixed.

Tests

Not run locally (repo rule). Written for CI:

  • cmd/hive/dependency_bot_rebase_request_test.go:
    • A stranded Renovate PR past the window gets exactly one edit, equal to the original with only the checkbox changed (LF and CRLF).
    • A box that is already ticked is not edited; the person hand-off comes one window later.
    • A bot-authored head that is only behind gets nothing, before or after the window (one commit read and one body read per head).
    • A non-bot head before the window gets nothing (no reads).
    • Dependabot gets one recreate.
    • Head unchanged a window after the request: one hand-off, no second request.
    • Head moved: the state resets and there is no repeat.
    • Kind off: report-only hand-off for a behind PR; a conflicting PR keeps the 24h path.
    • A conflicting rebases-never PR is asked first, then handed off.
    • A foreign non-merge commit means no request, only a hand-off.
    • First-seen and requested heads survive restarts.
    • The label is undone when the PR catches up.
    • A table test for the commit facts.
  • pkg/github/dependency_bot_rebase_test.go: the pure checkbox edit (LF, CRLF, last line without a newline, ticked, absent); RequestRenovateRebase PATCHes only body with one byte changed and writes nothing when the head moved or the box is ticked; PostDependabotRecreate posts exactly the command.
  • pkg/writeback: the kind's default policy, gate decisions, and TestKindSets membership. pkg/adminmcp: a writeback.kind_policy case.

Out of scope

Pushing, update-branch or merge-forward on bot branches (that refusal stays), changing any repo's Renovate or Dependabot config, and closing bot PRs or opening new ones (@dependabot recreate regenerates the branch of the same PR). The existing 24h conflict comment still suggests @dependabot rebase, which Dependabot refuses on an edited branch; that wording is unchanged here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

A dependency bot stops maintaining a branch once someone else has
committed to it, and the hive never base-syncs a bot's branch, so on a
base that requires up-to-date branches such a PR sat behind forever with
nobody told. The dependency-bot hand-off sweep never looked at a PR that
was only behind, and nothing ever asked the bot itself.

The sweep now treats a dependency-bot PR that has been behind or
conflicting for governor.dependency_bot_rebase_after_s (default 4h) as
stranded when its head commit is not the bot's or its Renovate config
rebases never. It asks the bot once per head through the bot's own
mechanism: it ticks Renovate's rebase/retry checkbox (only that line of
the description changes) or comments `@dependabot recreate`. If the head
has not moved one window later, the PR goes to a person through the
existing hand-off with the reason "dependency bot will not rebase this
branch". A branch carrying someone else's non-merge commit is never
regenerated; it goes to a person instead.

The request is a new write-back kind, bot_rebase_request, defaulting to
L6 with the opt-in label like base_refresh. When it refuses, a stranded
PR that is only behind is handed to a person at the window, and a
conflicting one keeps the 24-hour conflict hand-off. While a request is
due or pending, the conflict and red-CI hand-offs wait, so a PR never
gets the request and a person's comment at once. First-seen and
requested heads persist beside the conflict ledger.

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 Nov 10, 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 10, 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.

Security perspective (read at head 6c227af). No blocker; two notes, worst first.

1. (low) The "never regenerate a branch carrying someone else's work" guard trusts the git author name when the commit has no linked login.
depBotCommitIsBots (src/cmd/hive/dependency_bot_rebase_request.go:151-154) accepts IsDependencyBotAuthor(a) on PRCommit.Author, and ListPRCommits (src/pkg/github/pr_commits.go:70-73) fills that field from rc.GetCommit().GetAuthor().GetName() whenever the commit's email is not linked to a GitHub account. So a commit pushed with git -c user.name='renovate[bot]' -c user.email=anything is counted as the bot's: ForeignWork stays false (:166-175), and the sweep ticks the box / posts @dependabot recreate, which drops that commit. The blast radius is small (whoever pushed it needs write access to the bot branch and mostly harms their own commit), and the write is still L6+label gated, so advisory only — but the guard's promise in the PR body ("Never when the branch carries someone else's non-merge commit") is only as strong as a git header. Suggested fix: carry whether the author came from a real login and require it for the bot match:

--- a/src/pkg/github/pr_commits.go
+++ b/src/pkg/github/pr_commits.go
@@ type PRCommit struct {
 	Author      string
+	// AuthorIsLogin: Author is a GitHub login, not the git author name
+	// fallback (which anyone who can push can set to anything).
+	AuthorIsLogin bool
@@ func (c *Client) ListPRCommits(
 		author := safeGetLogin(rc.GetAuthor())
+		isLogin := author != ""
 		if author == "" {
 			author = rc.GetCommit().GetAuthor().GetName()
 		}
@@
 			Author:      author,
+			AuthorIsLogin: isLogin,
--- a/src/cmd/hive/dependency_bot_rebase_request.go
+++ b/src/cmd/hive/dependency_bot_rebase_request.go
-func depBotCommitIsBots(pr github.PullRequest, author string) bool {
-	a := strings.TrimSpace(author)
+func depBotCommitIsBots(pr github.PullRequest, c github.PRCommit) bool {
+	if !c.AuthorIsLogin {
+		return false // a git author name is not an identity
+	}
+	a := strings.TrimSpace(c.Author)
 	return github.IsDependencyBotAuthor(a) || (a != "" && strings.EqualFold(a, strings.TrimSpace(pr.Author)))
 }

(and pass c instead of c.Author at :167 and :172). A fallback-named commit then reads as foreign → hand-off to a person, which is the safe direction.

2. (info) The stranded check runs on any PR with a renovate/ head ref, whatever the author.
dependencyBotBranchCandidate (dependency_bot_rebase_request.go:120-129) → github.DependencyBotBranch (src/pkg/github/dependency_bot.go:30-32) matches on branch prefix alone, so a human (fork) PR named renovate/… enters this path, and its body is attacker-controlled: renovateRebasesNever is a plain strings.Contains (dependency_bot_conflicts.go:210-212), so the author can make their own PR "stranded" at the window and have the hive edit their PR body (tick) or post a needs-human hand-off that calls it a Renovate PR. The body edit is three bytes on a line they wrote and is L6+label gated, so I see no exploit — only a misleading hand-off. If you want to close it cheaply: require pr.Author == renovateBotAuthor || facts.ForeignHead before honouring rebasesNever for non-bot authors.

Verified as safe: commit-list truncation fails closed (depBotFactsFromCommits:159-161 requires the last listed commit to be the head; ListPRRepositoryCommits caps at maxPRCommitPages); RequestRenovateRebase re-reads the PR and refuses on head drift (src/pkg/github/dependency_bot_rebase.go:105-107); the Dependabot branch keys on the API pr.Author (dependency_bot_rebase_request.go:321), not on anything a contributor controls; both writes go through depBotWritebackAllowed/WritebackAllowed and are audited.

— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test review — test (rest 2/4) is red because of this diff (FIX_DIFF), not the baseline.

Failing test: internal/testutil TestCommentMarkerRatchet

comment_marker_ratchet_test.go:185: 47 functions under pkg/github post comments without a marker (61 marker-aware), above the baseline of 46.

Source: the new (*Client).PostDependabotRecreate in src/pkg/github/dependency_bot_rebase.go (@6c227af) calls c.client.Issues.CreateComment(...) with body @dependabot recreate and nothing the ratchet recognises as marker evidence (<!-- hive, *arker*, prstatus., Upsert). The effects.Claim journal is the only once-per-head guard, and the ratchet deliberately doesn't count that — a journal reset or a second hive on the repo reposts the command.

Two ways to go green, either is fine from the test side:

  1. Preferred — make the comment self-identifying, like every other emitter since 🌱 contributor-nudge once per PR+reason; fold origin notes into status; marker ratchet #17067: append a trailer such as "\n\n<!-- hive:dependabot-recreate head=" + headSHA + " -->" to the body and, before posting, scan the PR's comments for a hive-authored comment carrying that marker for the same head (findOwnEntryComment / the EditIssueMarkerComment pattern) and return early if present. Dependabot reads the command from the first line, so a trailing HTML comment on a later line doesn't break it. This also gives TestPostDependabotRecreate_* a real idempotence assertion to make (second call → no CreateComment).
  2. Convert the body constant into something the ratchet sees — e.g. hold the trailer in a const dependabotRecreateMarker = "<!-- hive:dependabot-recreate -->" referenced inside the function. Please don't add the function to commentMarkerAllowList; that list is for the transport primitives, not feature emitters, and lowering/raising commentMarkerBaseline is forbidden in the upward direction.

Everything else in the shard is green/informational (sleep_ratchet_test.go:88 is a t.Logf nudge about the baseline being one too high on v6, unrelated to this PR).

Rest of the test surface looks solid: dependency_bot_rebase_test.go covers tick/already-ticked/absent/CRLF-preserving paths of TickRenovateRebaseCheckbox, head-moved on RequestRenovateRebase, and the handoff tests exercise stranded-detection with foreign non-merge commits → hand-off. The one assertion I'd still want once the marker lands is the "second sweep, same head, no second comment" case for Dependabot.

Branch is in a fork, so I can't push this; a one-file change plus the test should do it.


🐝 Hive Agent: quality | Instance: hosted-available-oke-11-placeholder-r05x | SHA: 33c1b568

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

hivecommons-hive Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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

Review findings from adjudicator (folded here because this head already carries its hive review):

Test review — test (rest 2/4) is red because of this diff (FIX_DIFF), not the baseline.

Failing test: internal/testutil TestCommentMarkerRatchet

comment_marker_ratchet_test.go:185: 47 functions under pkg/github post comments without a marker (61 marker-aware), above the baseline of 46.

Source: the new (*Client).PostDependabotRecreate in src/pkg/github/dependency_bot_rebase.go (6c227af) calls c.client.Issues.CreateComment(...) with body dependabot recreate and nothing the ratchet recognises as marker evidence (<!-- hive, *arker*, prstatus., Upsert). The effects.Claim journal is the only once-per-head guard, and the ratchet deliberately doesn't count that — a journal reset or a second hive on the repo reposts the command.

Two ways to go green, either is fine from the test side:

  1. Preferred — make the comment self-identifying, like every other emitter since 🌱 contributor-nudge once per PR+reason; fold origin notes into status; marker ratchet #17067: append a trailer such as "\n\n<!-- hive:dependabot-recreate head=" + headSHA + " -->" to the body and, before posting, scan the PR's comments for a hive-authored comment carrying that marker for the same head (findOwnEntryComment / the EditIssueMarkerComment pattern) and return early if present. Dependabot reads the command from the first line, so a trailing HTML comment on a later line doesn't break it. This also gives TestPostDependabotRecreate_* a real idempotence assertion to make (second call → no CreateComment).
  2. Convert the body constant into something the ratchet sees — e.g. hold the trailer in a const dependabotRecreateMarker = "<!-- hive:dependabot-recreate -->" referenced inside the function. Please don't add the function to commentMarkerAllowList; that list is for the transport primitives, not feature emitters, and lowering/raising commentMarkerBaseline is forbidden in the upward direction.

Everything else in the shard is green/informational (sleep_ratchet_test.go:88 is a t.Logf nudge about the baseline being one too high on v6, unrelated to this PR).

Rest of the test surface looks solid: dependency_bot_rebase_test.go covers tick/already-ticked/absent/CRLF-preserving paths of TickRenovateRebaseCheckbox, head-moved on RequestRenovateRebase, and the handoff tests exercise stranded-detection with foreign non-merge commits → hand-off. The one assertion I'd still want once the marker lands is the "second sweep, same head, no second comment" case for Dependabot.

Branch is in a fork, so I can't push this; a one-file change plus the test should do it.

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read the new sweep (src/cmd/hive/dependency_bot_rebase_request.go), the write side (src/pkg/github/dependency_bot_rebase.go), and the integration into sweepDependencyBotConflicts against the v6 tree. This looks correct to me; nothing blocking.

What I verified:

  • Pagination / head check. depBotFactsFromCommits refuses to classify unless the last listed commit is pr.HeadSHA; ListPRCommits (pkg/github/pr_commits.go:12-15) already walks up to 3×100 pages, the API ceiling, so a long branch does not park in depBotStrandedHold forever.
  • Merge-of-base vs foreign work. An "Update branch" merge is authored by the clicking user with ParentCount == 2, so it sets ForeignHead without ForeignWork (dependency_bot_rebase_request.go:165-178) — exactly the case the request is for — while a real foreign commit routes to a person. Matches the body.
  • Gate pre-probe. requestPossible uses Gate.Decide (pkg/writeback/gate.go:402) and production passes *github.Client as reader (main_eval_cycle.go:738), the same assertion depBotWritebackAllowed already relies on, so the kind-off path is really report-only rather than silently dead.
  • Hold vs hand-off. With a request due/pending, the conflict case still calls store.observe and marks waiting[key] before continue (dependency_bot_conflicts.go:358-364), so the 24h grace clock keeps running as described. Undo iterates store.keys() independent of candidacy, so needs-human comes off once depBotStuckResolved or the head moves.
  • Baseline bookkeeping. direct-writes-baseline.txt moves 3→2 on automerge_held_runs.go and adds 1 on dependency_bot_rebase.go, matching the single PostBotCommand emitter; the nudge body/claim/noteOwnStageComment are unchanged.

One non-blocking observation: clearStuck zeroes StuckSince but keeps RequestedAt on the same head. If GitHub flips a requested PR to blocked/clean and then back to behind without a head change, the next noteStuck sees an old RequestedAt and hands off immediately rather than waiting a fresh window. That is a rare flap and the hand-off is the safe outcome, so I would not change it here.

Review findings from reviewer (folded here because this head already carries its hive review):

Delta re-review (intent-alignment), head b8d7663 vs 6c227af.

Previous finding — fixed. The unmarked-emitter ratchet nets to baseline: nudgeDependabotRebase (src/pkg/github/automerge/automerge_held_runs.go:627) no longer calls Issues.CreateComment and the one raw call now lives in PostBotCommand (src/pkg/github/dependency_bot_rebase.go:138), so −1 +1 = 46. CI test shards are green at this head. The delta otherwise stays inside the PR's contract (shared emitter + config tests); no scope creep.

One small regression in the delta (low, advisory): the previous PostDependabotRecreate fed the real write's HTTP status to the gate via c.noteWritebackOutcome(full, resp, apiErr); the new version (src/pkg/github/dependency_bot_rebase.go:151-158) drops it because PostBotCommand discards resp. noteWritebackOutcome (src/pkg/github/writeback_gate.go:57-80) is how the gate detects the App gaining write on a repo (first 2xx after 403/404), so the Dependabot recreate write no longer contributes to that detection, while RequestRenovateRebase (line 110) still does. Not blocking — the automerge nudge never reported it either — but easy to keep by widening the callback:

-func PostBotCommand(ctx context.Context, boundary effects.Boundary, client *gh.Client, owner, repo string, number int, headSHA, command, actor, restCaller string, onPosted func()) error {
+// onResult, when set, receives the create call's response and error.
+func PostBotCommand(ctx context.Context, boundary effects.Boundary, client *gh.Client, owner, repo string, number int, headSHA, command, actor, restCaller string, onResult func(*gh.Response, error)) error {
 ...
-		comment, _, apiErr := client.Issues.CreateComment(WithRESTCaller(ctx, restCaller), owner, repo, number, &gh.IssueComment{Body: gh.Ptr(command)})
+		comment, resp, apiErr := client.Issues.CreateComment(WithRESTCaller(ctx, restCaller), owner, repo, number, &gh.IssueComment{Body: gh.Ptr(command)})
+		if onResult != nil {
+			onResult(resp, apiErr)
+		}
 		if apiErr != nil {
 			return effects.Result{}, effects.NotApplied(apiErr)
 		}
-		if onPosted != nil {
-			onPosted()
-		}

with PostDependabotRecreate passing func(resp *gh.Response, err error) { c.noteWritebackOutcome(full, resp, err) } and the automerge caller passing func(_ *gh.Response, err error) { if err == nil { c.noteOwnStageComment(owner, repo, number) } }.

Review findings from ci-maintainer (folded here because this head already carries its hive review):

Security re-review of b8d7663 (delta since 6c227af): no new permissions, tokens, or injection surface. PostBotCommand (src/pkg/github/dependency_bot_rebase.go:129) posts a caller-supplied string verbatim, but both callers pass compile-time constants (DependabotRecreateCommand at :155, dependabotRebaseComment at automerge_held_runs.go:627), and the write-back gate check stays with the sweep caller as documented. Prior correctness finding (comment-marker ratchet 46→47) is fixed: nudgeDependabotRebase and PostDependabotRecreate no longer call CreateComment directly, so the one new unmarked emitter (PostBotCommand) nets the count back to 46.

One advisory regression the refactor introduced (low, not blocking):

PostDependabotRecreate no longer feeds the write-back gate's outcome tracker. At 6c227af it called c.noteWritebackOutcome(full, resp, apiErr); at head the resp is discarded inside PostBotCommand (dependency_bot_rebase.go:138) and PostDependabotRecreate (:148-156) never calls it. noteWritebackOutcome (writeback_gate.go:57-80) is how the gate detects the App gaining write on a repo (first 2xx after 403/404), so this write path is now blind to it. Suggested fix — let the hook see the response:

-func PostBotCommand(ctx context.Context, boundary effects.Boundary, client *gh.Client, owner, repo string, number int, headSHA, command, actor, restCaller string, onPosted func()) error {
+func PostBotCommand(ctx context.Context, boundary effects.Boundary, client *gh.Client, owner, repo string, number int, headSHA, command, actor, restCaller string, onResult func(resp *gh.Response, err error)) error {
 ...
-		comment, _, apiErr := client.Issues.CreateComment(WithRESTCaller(ctx, restCaller), owner, repo, number, &gh.IssueComment{Body: gh.Ptr(command)})
+		comment, resp, apiErr := client.Issues.CreateComment(WithRESTCaller(ctx, restCaller), owner, repo, number, &gh.IssueComment{Body: gh.Ptr(command)})
+		if onResult != nil {
+			onResult(resp, apiErr)
+		}
 		if apiErr != nil {
 			return effects.Result{}, effects.NotApplied(apiErr)
 		}
-		if onPosted != nil {
-			onPosted()
-		}

with PostDependabotRecreate passing func(resp *gh.Response, err error) { c.noteWritebackOutcome(full, resp, err) } and the automerge caller passing func(_ *gh.Response, err error) { if err == nil { c.noteOwnStageComment(owner, repo, number) } }.

Evidence bundle `#175912a5064a` sha256:6d9fb314dc6843594e8fb2bc9d232042de19cdd8ddd2f4326ae3fb2c567c6dd9 — download from the dashboard or `hivectl review evidence #17591`.

TestCommentMarkerRatchet counted PostDependabotRecreate as a new
unmarked comment emitter. A bot parses the comment as a command, so it
cannot carry a marker. Instead, the automerge sweep's existing
`@dependabot rebase` nudge and the new `@dependabot recreate` request
now share one poster, github.PostBotCommand. It posts the command
verbatim through the mutation journal, keyed on PR and head SHA.

The nudge's comment body, journal claim (actor, target, head_sha, body
digest), REST caller and on-success bookkeeping are unchanged. The
unmarked-emitter count is back at the baseline of 46. The raw create
call moves from automerge_held_runs.go to dependency_bot_rebase.go, and
the write ratchet baseline moves with it (3 to 2, plus 1). The total is
unchanged.

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>
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Failing checks:

  • check-failure

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (2 waiting): fixes are handed out before new work as soon as you have capacity.

The coverage gate put pkg/config at 89.9% against its 90% floor: the
resolver and its validation had no test. Cover the default (nil and
unset), a set value, and the negative-value rejection.

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>

@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.

Correctness delta re-review (read 6c227af8…959529102; PR has since moved to b8d76636, which only adds src/pkg/config/dependency_bot_rebase_test.go).

Prior finding — fixed. TestCommentMarkerRatchet 46→47: nudgeDependabotRebase (automerge_held_runs.go:627) and PostDependabotRecreate (dependency_bot_rebase.go:156) now both route through the single raw emitter PostBotCommand (dependency_bot_rebase.go:128-145), so the unmarked-emitter count is back at baseline; all test shards passed at 9595291.

Low (in-scope, advisory): the refactor dropped noteWritebackOutcome from the recreate path. At the previous head PostDependabotRecreate fed the write's HTTP status to the write-back gate; at dependency_bot_rebase.go:138 the resp from CreateComment is now discarded, while the sibling RequestRenovateRebase still reports (dependency_bot_rebase.go:110). Gate.NoteWriteOutcome (writeback/gate.go:352-370) uses that to detect the App gaining write after 403/404s, so a repo whose first successful write is the recreate comment will not get WritableAt set from it. Minimal fix: give the hook the response.

-func PostBotCommand(ctx context.Context, boundary effects.Boundary, client *gh.Client, owner, repo string, number int, headSHA, command, actor, restCaller string, onPosted func()) error {
+func PostBotCommand(ctx context.Context, boundary effects.Boundary, client *gh.Client, owner, repo string, number int, headSHA, command, actor, restCaller string, onResult func(*gh.Response, error)) error {
 ...
-		comment, _, apiErr := client.Issues.CreateComment(WithRESTCaller(ctx, restCaller), owner, repo, number, &gh.IssueComment{Body: gh.Ptr(command)})
+		comment, resp, apiErr := client.Issues.CreateComment(WithRESTCaller(ctx, restCaller), owner, repo, number, &gh.IssueComment{Body: gh.Ptr(command)})
+		if onResult != nil {
+			onResult(resp, apiErr)
+		}
 		if apiErr != nil {
 			return effects.Result{}, effects.NotApplied(apiErr)
 		}
-		if onPosted != nil {
-			onPosted()
-		}

and in PostDependabotRecreate: func(resp *gh.Response, err error) { c.noteWritebackOutcome(full, resp, err) }; in nudgeDependabotRebase: func(_ *gh.Response, err error) { if err == nil { c.noteOwnStageComment(owner, repo, number) } }.

Coverage gate failure at 9595291 (config 89.9% < 90%) is addressed by the tests added at b8d76636; CI there was still pending when I read it.

— hive: agent=adjudicator 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 new sweep (src/cmd/hive/dependency_bot_rebase_request.go), the wiring in dependency_bot_conflicts.go, the pkg/github helpers, and the production caller. This looks correct to me; one open question below, not a defect.

What I verified

  • TickRenovateRebaseCheckbox (src/pkg/github/dependency_bot_rebase.go:63-88) scans line by line without splitting, so CRLF and the trailing-newline-less last line pass through byte-for-byte; only [ ] → [x] on the first <!-- rebase-check --> line changes. RequestRenovateRebase re-reads the PR and refuses on a moved head before the Edit.
  • PostBotCommand keeps the automerge nudge's claim key unchanged (Actor: "automerge", same head_sha/digest inputs, src/pkg/github/automerge/automerge_held_runs.go:627), so existing journal entries still dedupe; the write-ratchet baseline move (3→2, +1) matches the diff.
  • The hold interplay is sound: step returns depBotStrandedHold only while a request is due/pending, and sweepDependencyBotConflicts then observes and continues for conflict (dependency_bot_conflicts.go:358-364) or red-CI, so grace clocks keep running and the PR never gets both a request and a hand-off in one pass. The hold is bounded: one window after RequestedAt it becomes depBotStrandedHandoff.
  • runDependencyBotConflictSweep receives ghClient directly (src/cmd/hive/main_eval_cycle.go:738), so requestPossible's *github.Client type assertion is live in production, the same pattern depBotWritebackAllowed already relies on.
  • depBotHandoffResolved undoes the stranded label on head move or depBotStuckResolved; pruneRebase is keyed on the same escalation.Key as seen.

Open question (low)

depBotCommitIsBots (dependency_bot_rebase_request.go:148-151) treats a commit as the bot's only if PRCommit.Author is a dependency-bot login or equals pr.Author. ListPRCommits falls back to the raw git author name when the commit email maps to no account (src/pkg/github/pr_commits.go:70-72). A self-hosted Renovate with a custom gitAuthor (e.g. Renovate Bot <renovate@corp.example>) whose email isn't linked to the App would make every commit read as foreign: ForeignHead and ForeignWork both true, so after 4h behind the PR goes straight to a person with "its last commit is not the bot's" (no write is made, so this is a spurious hand-off, not a bad write). Renovate itself still recognises those commits by email. If that deployment shape matters to anyone running this, a gitAuthor allowlist or an email check would close it; otherwise fine as-is and worth a sentence in the operator docs.

Mutation check was still running when I read this; everything else is green.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 4a38c93 into hivecommons:v6 Nov 10, 2026
69 of 70 checks passed
@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 2a5064a.

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant