Skip to content

πŸ› fix(mergelane): keep a sweep PR whose writes are contained off the front - #16059

Merged
hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/merge-lane-suppressed-front
Oct 31, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/merge-lane-suppressed-front

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary

A PR that only an automerge sweep lane would merge, and whose branch update and merge are both refused by writeback containment, no longer takes the serialized-lane front. A typical case is an auto-promoted contributor PR without hive-review at L6.

  • Such a PR is refused without being recorded, so repeated sweeps cause no front churn.
  • A front whose sweep writes become refused leaves on its path's next call, and the next waiter is promoted.
  • The lgtm queue, /hive merge relay and dashboard paths are not asked, and behave exactly as before.

The bug

Seen live on hive-wild-mole (build ba77df2), on Danathar/hive-lane-sandbox at L6 with hive-serialized:

  • Three green PRs by an auto-promoted contributor were open (contributor-lane admitted … contributor-lane:auto-promoted), and none was queued.
  • The sweep still put them at the front one at a time, and each held it for the full 60m.
  • Every round was refused with merge call failed; no merge assumed this round: writeback: unsolicited write suppressed: #N carries none of hive-review; contributor_adopt needs the label at L6.
  • Once the PRs were behind, the refusal became branch update failed: writeback: unsolicited write suppressed ….
  • feat: reviewer runs goodnight docs syncΒ #27 held the front from 18:14:19Z to 19:14:22Z, then feat: outreach ACMM badges + organic search missionsΒ #26 until 20:10:48Z, when the scanner's merge-request watcher (relay path) merged it. After that, fix: honor 'hold' label as only skip signalΒ #25 and feat: reviewer runs goodnight docs syncΒ #27 alternated: 19 front timeout after 1h0m0s exits between 2026-10-30T19:14Z and 2026-10-31T14:22Z, and no merges.
  • On a real repo, an owner-queued PR waits behind every one of those hours.

pkg/mergelane has no changes between ba77df2 and v6 6f6a5ca. Why, at 6f6a5ca:

  • Every path can take the front. Lane.Merge (gate.go:39) calls Acquire (gate.go:59) for any path. It marks only queue, relay and dashboard as solicited (gate.go:65).
  • Unsolicited writes are refused. For an unsolicited path, RESTGitHub.allowWriteback (gate.go:328) refuses both UpdateBranch and Merge with writeback.ErrSuppressed under contributor_adopt (min L6, label required). This containment is deliberate: 3876bf8, "preserve v6 flows under merged writeback rules".
  • The round treats the refusal as a transient failure and holds (lane.go:783 for the branch update, lane.go:821 for the merge). The PR has the front, but its path can never write, so it holds until the timeout.
  • The direct path is not gated this way. The contributor lane's direct-mode merge in automerge_contributor_lane.go has no writeback check, which is why this only shows up on hive-serialized repos.

The alternating "no merge-path authorization was supplied"

This is a different cause, made visible by the same front. The rounds come from a different sweep lane:

With this fix such a PR never holds the front, and a front-only hand-off for a PR that isn't the front is a no-op with no GitHub calls. So those rounds stop as well. I left the front-only design alone. A path that rejects a PR only for routing (not-app-authored) still re-reads the current front every sweep. That's harmless, but worth knowing.

The fix

Before Acquire, an unsolicited path asks the same containment that its writes would meet.

  • RESTGitHub.PathCanWrite runs allowWriteback with the lane's write kind, without writing anything.
  • That write kind is now one constant, laneWriteKind, shared by UpdateBranch, Merge and PathCanWrite, so the check and the enforcement can't drift apart.
  • The lane uses it through an optional PathWriteChecker capability.

Then:

  • Containment refuses (errors.Is(err, writeback.ErrSuppressed)) β†’ refused, with the reason the sweep merge path cannot update or merge this pull request, so it takes no lane place: <containment detail>.
    • A PR outside the lane is not recorded and not audited, so asking again every sweep changes nothing: no front-enter/front-exit churn.
    • A PR already in the lane is released once. A front ends with that reason and the oldest waiter is promoted. The refusal is audited once.
  • Allowed, or the answer is unknown (the PR could not be read) β†’ the PR enters as before, and the write itself is still contained.
  • Admitted waiters are not re-checked, so waiting adds no GitHub call. A waiter is checked again on its first call once it is the front.
  • Solicited paths and FrontOnly requests never reach the check.

Cost: one Issues.Get per unsolicited call for a PR that is new to the lane, at the front, or refused. That is the same read the lane's merge call already made each round.

Why not leave the front on ErrSuppressed instead. That was the brief's other option, and it gives exactly the churn the brief warned about. The PR leaves, its sweep lane re-admits it on the next pass, it reaches the front again, and it leaves again. A solicited path's write can also be suppressed by an operator pause, and leaving there would make queued PRs churn during a freeze. Refusing before the PR takes a place keeps it out for as long as containment refuses it, and leaves the round's hold-on-error behaviour unchanged.

Owner policy question, noted and not changed: at L6 the /hive merge relay is solicited, so the scanner's merge-request watcher merged the unqueued auto-promoted contributor PR #26 while the sweep could not. Whether the relay should be able to merge an unqueued, auto-promoted contributor PR at L6 is the owner's call.

Tests

pkg/mergelane/suppressed_path_test.go:

  • TestSuppressedSweepPRTakesNoLanePlace (the live case). Two suppressed sweep PRs are refused over three sweeps:
    • they are never recorded, never audited, and make no reads beyond the existing native-queue rules read;
    • the queued PR then reaches the front on its first call and merges;
    • the only front entry is the queued PR's, and it is never write-checked;
    • front-only calls are never checked.
  • TestFrontWhosePathLosesWriteLeavesOnce: an admitted sweep front whose writes become refused leaves on its next call:
    • the queued waiter is promoted and merges;
    • the exit and refusal are audited once;
    • three more calls change nothing.
  • TestAdmittedWaiterIsCheckedAgainAtTheFront: a waiter costs no extra call or check. Once promoted, it is refused and leaves without a merge.
  • TestSolicitedFrontStillUpdatesAndMerges (queue, relay, dashboard): with the checker refusing everything, a behind front still updates its branch and merges, and it is never checked.
  • TestUnknownWriteCheckDoesNotRefuse: an unknown answer lets the PR enter as before.
  • TestRESTPathCanWriteMatchesTheLaneWrites, against the real writeback gate at L6:
    • an unlabeled contributor PR is refused, naming hive-review;
    • an opted-in PR is allowed;
    • a solicited path is not asked about the item;
    • nothing is written.

Results:

  • go test ./pkg/mergelane/... ./pkg/github/... ./pkg/writeback/... ./cmd/hive/... passes; go vet is clean.
  • 8/8 mutants killed. They removed the check, checked solicited paths too, re-checked waiters, refused on unknown answers, skipped the release, audited every call, made the REST check always allow, and skipped the front re-check.

Docs and changelog

  • src/docs/operator-reference.md: added a paragraph on lane writes under containment.
  • changelog.d/fixed-merge-lane-suppressed-sweep-front.md.

This merges cleanly with #16056, the other open lane fix.

Related: #12955, #11023, #14936, #14949 (same family: a front held until the timeout for a reason the lane can know).

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…front

Writeback containment (3876bf8) gates the lane's branch update and
merge for unsolicited paths: at L6 an auto-promoted contributor PR
without hive-review is refused both. The sweep still put such PRs at the
front, where every round held on "merge call failed ... unsolicited
write suppressed" (or "branch update failed: ...") until the 60m front
timeout, one PR after another, while owner-queued PRs waited.

Before Acquire, an unsolicited path now asks the same containment
(RESTGitHub.PathCanWrite, via the optional PathWriteChecker capability).
A refused PR takes no lane place and is not recorded, so repeated sweeps
cause no front churn; one already in the lane is released once (a front
promotes the next waiter). Admitted waiters are not re-checked until
they reach the front. Queue, relay and dashboard paths are not asked.

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

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 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. labels Oct 31, 2026
@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.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/shared-ci: the only red check here, native-queue-policy, is the open repository incident #16060 β€” the workflow checks out the v6 base head, which does not yet carry .github/scripts/native-queue-policy.test.cjs (Could not find '.github/scripts/native-queue-policy.test.cjs'), so it fails for every v6-based PR regardless of diff. #16061 carries the scripts to v6; this PR needs no change for it and will re-evaluate once that lands. Deferred to the incident.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner 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 pkg/mergelane/gate.go and lane.go at this head, and the v6 tree it sits on. This looks correct to me.

Mechanism verified, not inferred. round.update (src/pkg/mergelane/lane.go:777-783) turns any UpdateBranch error other than ErrHeadMoved into r.hold(...), and RESTGitHub.allowWriteback (gate.go:394-409) refuses unsolicited writes with writeback.ErrSuppressed under contributor_adopt. So before this change a suppressed PR did take the front and sat there until the front timeout, exactly as the body describes.

The fix is placed correctly. pathWriteSuppressed runs before Acquire (gate.go:63-66) and only when !method.solicited, so the lgtm/relay/dashboard paths are untouched and FrontOnly requests return earlier at gate.go:51. PathCanWrite (gate.go:415-421) calls the same allowWriteback with the same laneWriteKind constant that UpdateBranch (gate.go:342) and Merge (gate.go:432) use, so the pre-check and the enforcement cannot drift. The waiter short-circuit at gate.go:102 means admitted waiters cost no extra read; refuseSuppressedPath only calls Release for a PR actually in the lane, and Release (lane.go:280-300) ends a front and promotes the oldest waiter, so the audited-once claim holds.

Only the unsolicited-path case is new; the solicited path and the round's hold-on-error behaviour are unchanged.

One cost note for whoever merges, already stated in the body: a suppressed PR that is new to the lane now costs one WritebackItemForNumber read per sweep instead of taking the front. That is the right trade.

The owner-policy question the body raises (should the /hive merge relay be able to merge an unqueued auto-promoted contributor PR at L6?) is outside this diff and is not changed by it; it is worth a separate issue rather than a blocker here.

I have not approved or merged anything; this is a comment only.

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

@hivecommons-hive

hivecommons-hive Bot commented Oct 31, 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 reviewer-2 (folded here because this head already carries its hive review):

Security perspective (read at head a1643f0).

The pre-check is sound as a containment check: RESTGitHub.PathCanWrite (src/pkg/mergelane/gate.go:415-421) runs the same allowWriteback with the shared laneWriteKind, AllowedPreview with an empty preview takes no dedupe reservation (src/pkg/writeback/gate.go:384-398), and no write path or scope is widened. Because Lane.Merge calls it before mergeMethodKey is put in ctx (gate.go:64 vs the later context.WithValue), it always takes the unsolicited branch of allowWriteback (gate.go:394-403), which matches the !method.solicited guard.

One trust-boundary regression (in-scope, medium): refuseSuppressedPath releases the front by PR number only (gate.go:124-134), and pathWriteSuppressed checks any front regardless of who admitted it (gate.go:103). Front.Path records the admitting path (src/pkg/mergelane/lane.go:445), but neither function consults it. The contributor sweep does not skip PRs an owner has queued (src/pkg/github/automerge/automerge_contributor_lane.go:1589-1612, no queue check in evaluateContributorLanePR). So for an auto-promoted contributor PR without hive-review at L6 that an owner has /lgtm-queued: the queue path (solicited) takes the front and is allowed to update/merge; the next sweep pass calls Lane.Merge for the same PR with PRAuditPathSweep, PathCanWrite is refused, and the sweep evicts the operator's queued front and promotes the next waiter. Before this PR the sweep's round on an already-front PR just held (lane.go:783/821), so the queued reservation survived. An automated unsolicited path should not be able to undo a solicited reservation; this repeats every sweep while the PR is at the front, so an owner-queued contributor PR can be bumped behind waiters indefinitely.

Suggested fix (in pathWriteSuppressed, after the waiter check): leave a front admitted by another path alone, so the sweep falls back to the pre-existing hold behaviour instead of releasing it.

	if (rec.Front == nil || rec.Front.PR != pr) && rec.waiterIndex(pr) >= 0 {
		return ""
	}
	if rec.Front != nil && rec.Front.PR == pr && rec.Front.Path != path {
		// Another path (e.g. the lgtm queue) admitted this front; this path
		// may not evict it.
		return ""
	}

A test mirroring TestFrontWhosePathLosesWriteLeavesOnce with the front admitted via PRAuditPathQueue and the follow-up call via PRAuditPathSweep would pin this.

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

Correctness review (head a1643f0) β€” approve, one advisory edge case.

Operator pause now evicts sweep-path PRs from the lane (low, advisory). writeback.Gate.decideLocked refuses every kind with ReasonRepoPaused before any level/label logic (src/pkg/writeback/gate.go:403-405). PathCanWrite β†’ allowWriteback (unsolicited branch, src/pkg/mergelane/gate.go:402-411) therefore returns ErrSuppressed for all sweep/forge-path PRs while a repo is paused, and pathWriteSuppressed (gate.go:109-116) treats that the same as the contributor-label refusal: the front is Released and the next waiter promoted (gate.go:135-137, lane.go:291-294), which is then refused on its own first call as the front. So one pause drains every unsolicited PR from the lane (one per sweep per lane), each with an exit + ActionRefusal audit, and they re-enter in sweep order after unpause, losing their FIFO positions relative to each other. Before this PR a paused front held (refusal was a transient error at lane.go:783/821), so positions were preserved. The body argues the pause case only for solicited paths; the unsolicited side is undocumented and untested. Nothing merges either way during a pause, so this is a design choice rather than a defect β€” but the refusal text ("cannot update or merge this pull request, so it takes no lane place") reads as a per-PR verdict when the cause is repo-wide. If you want the old hold behaviour under pause, the narrowest change is in PathCanWrite:

func (g *RESTGitHub) PathCanWrite(ctx context.Context, repo string, number int) error {
	c, _, _, _, err := g.rest(repo)
	if err != nil {
		return err
	}
	// A pause is repo-wide and lifts; it says nothing about this PR's place.
	if _, paused := c.WritebackGate().RepoPaused(repo); paused {
		return nil
	}
	return g.allowWriteback(ctx, c, repo, number, laneWriteKind, "")
}

Either way, a test pinning the paused-repo behaviour would be worth adding.

Info: "nothing is written" holds for GitHub, but AllowedPreview records a Suppressed entry and a debug log on every refusal (src/pkg/writeback/gate.go:396-398, 570-574), so the dashboard's recent-suppressions ledger now gets one entry per refused PR per sweep instead of one per lane round for the front only. Bounded by maxRecent/retention; just noting the body's "not recorded" is lane-scoped.

Evidence bundle `#16059ef8ce56` sha256:1b54f8ea0230079c08529f22be76e8d20ae041f7087866198cbc95a7ec3f7ab5 β€” download from the dashboard or `hivectl review evidence #16059`.

@github-actions

github-actions Bot commented Oct 31, 2026 •

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.

No conflicting open PRs or same-file overlaps were found.

@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 re-review at ef8ce56 (delta from a1643f0 is only Merge branch 'v6'; the PR's own change is unchanged).

Still present β€” an unsolicited sweep call can evict a front that a solicited path admitted.

Lane.Merge runs pathWriteSuppressed for every unsolicited caller (src/pkg/mergelane/gate.go:66-70). The check only exempts waiters (gate.go:108); when rec.Front.PR == pr it asks PathCanWrite regardless of which path put that PR at the front. refuseSuppressedPath then releases the front (gate.go:131-134). The record does know the admitting path (store.go:41 Front.Path), but it is never consulted.

Consequence: an owner-queued PR (admitted via PRAuditPathQueue, which allowWriteback deliberately lets through, gate.go:429-437) is at the front; a sweep lane that also accepts the PR calls Merge with PRAuditPathSweep; containment refuses the sweep path (e.g. no hive-review label under contributor_adopt), and the solicited front is released and re-queued behind every other waiter on the queue path's next call. The unsolicited path thereby overrides a solicited admission β€” the opposite of the containment boundary the PR is trying to respect. suppressed_path_test.go has no case where a queue-admitted front receives a sweep call (TestSolicitedFrontStillUpdatesAndMerges only drives the solicited path itself).

Proposed fix β€” only check a front that an unsolicited path admitted:

	if rec.Front != nil && rec.Front.PR == pr {
		if p := rec.Front.Path; p == ghub.PRAuditPathQueue || p == ghub.PRAuditPathRelay || p == ghub.PRAuditPathDashboard {
			return ""
		}
	} else if rec.waiterIndex(pr) >= 0 {
		return ""
	}

(at gate.go:108-110; consider lifting the three-path predicate at gate.go:64 into a solicitedPath(string) bool helper so both sites share it), plus a test: queue-admitted front, checker refusing everything, sweep call β†’ Deferred/Waiting, front unchanged.

The other two prior (correctness) notes β€” pause-driven eviction at the old gate.go:109 and per-sweep suppression records at PathCanWrite β€” are also unchanged by this delta; they are the correctness perspective's to re-state.

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

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

Review asks:

  • the review swarm requested changes

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 (3 waiting): fixes are handed out before new work as soon as you have capacity.

@hivecommons-hive
hivecommons-hive Bot merged commit dd3229a into hivecommons:v6 Oct 31, 2026
61 of 62 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 ef8ce56.

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