Skip to content

refactor: src/pkg/github/automerge/automerge_sweep.go is a merge hotspot — split into 4 units #15513

Closed

Description

@hivecommons-hive

src/pkg/github/automerge/automerge_sweep.go keeps being touched by pull requests that are open at the same time. In the last 7 days 6 distinct PRs changed it, 9 pairs of them were open concurrently, and 0 merge conflicts or rebase failures were blamed on it. Every concurrent pair is a rebase someone (or the merge train) has to redo, and a 3242-line file makes each of those rebases slower and riskier.

Proposed fix: a mechanical split into 4 files in the same package. No behaviour change, exported API unchanged, tests move with the code they cover. Land it when no other PR is open against this file (check the merge-train overlap first) so the split itself does not become one more collision.

Evidence

metric value
window 7 days
distinct PRs 6
concurrent PR pairs 9
conflicts attributed 0
lines 3242
kind code
score 13.5

PRs in window: #15308, #15430, #15442, #15455, #15485, #15491

Top-level units

  • AutoMergeSweepEvent
  • AutoMergeSweepOptions
  • AutoMergeSweepResult
  • Engine
  • MergerAuthorizer
  • New
  • Options
  • StartSelfAuthoredAutoMergeSweep
  • SweepContributorLaneAutoMerges
  • SweepQueuedAutoMerges
  • SweepTrustedAuthorAutoMerges
  • Transport
  • TrustedAuthorDecision
  • TrustedAuthorPolicy
  • TrustedAuthorizer
  • cautionSweepInterval
  • classifyUpdateBranchError
  • contextWithExpectedCheckCache
  • expectedCheckCache
  • expectedCheckCacheContextKey
  • expectedCheckCacheFromContext
  • hasLabel
  • hiveQueueApproval
  • isFreshHeadOrMissingExpectedReason
  • isGitHubStatus
  • isRateLimited
  • labelNames
  • levelHoldTransport
  • lowPriority
  • mergeAPIErrorNotApplied
  • mergeQueueBaseKey
  • mergeQueueRequiredMergeError
  • mergeTrainPolicyOption
  • mismatchedDeclaredChecks
  • newExpectedCheckCache
  • nextSelfAuthoredSweepInterval
  • parseHiveQueueReview
  • prMergeableStateConflicting
  • requiredChecksExpectedMergeError
  • selfAuthoredSweepInterval
  • selfAuthoredSweepIntervalForCandidates
  • sortedSetKeys
  • staleNeedsRebaseLabel
  • supersededCloserTransport
  • sweepTickDecision
  • trustedAuthorPermission
  • trustedRegistryClanker
  • updateBranchFailure

Split proposal

  1. src/pkg/github/automerge/automerge_sweep.go — core types and the entry points other files call; keeps AutoMergeSweepEvent, MergerAuthorizer, SweepContributorLaneAutoMerges, TrustedAuthorDecision, … 8 more
  2. src/pkg/github/automerge/automerge_sweep_automergesweepoptions.go — moves AutoMergeSweepOptions, New, SweepQueuedAutoMerges, TrustedAuthorPolicy, … 8 more
  3. src/pkg/github/automerge/automerge_sweep_automergesweepresult.go — moves AutoMergeSweepResult, Options, SweepTrustedAuthorAutoMerges, TrustedAuthorizer, … 8 more
  4. src/pkg/github/automerge/automerge_sweep_engine.go — moves Engine, StartSelfAuthoredAutoMergeSweep, Transport, cautionSweepInterval, … 8 more

Don't splinter

  • At most 4 resulting files, each at least 150 lines; fewer is better.
  • No behaviour change; the package, its exported API and every import path stay the same.
  • Tests move with the code they cover; no new test helpers.
  • One PR; land it when the file has no open PRs against it.

Filed by the hive's merge-hotspot advisor (GET /api/hotspots). It will not file another issue for this file while this one is open.

Activity

  1. added
    kind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.
    agent/ci-maintainerCreated or modified by the ci-maintainer agent
    on Oct 29, 2026
  2. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 29, 2026
  3. hivecommons-hive commented on Oct 29, 2026

    @hivecommons-hive
    ContributorAuthor

    🔒 Claimed by @mrbobbytables (contributor on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 30m0s without activity and renews while the work continues. Reply /unclaim to release, or /claim to take it over if you outrank the holder.

  4. hivecommons-hive commented on Oct 29, 2026

    @hivecommons-hive
    ContributorAuthor

    🔓 Claim by @mrbobbytables released (lease revoked).

  5. hivecommons-hive commented on Oct 29, 2026

    @hivecommons-hive
    ContributorAuthor

    Deferred this kick: #15308 (open, stage/050-review-pending) still edits src/pkg/github/automerge/automerge_sweep.go and automerge_sweep_test.go, so splitting now would make the split itself the collision this issue is meant to prevent. Will pick up once #15308 lands or closes.


    🐝 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

  6. hivecommons-hive commented on Oct 29, 2026

    @hivecommons-hive
    ContributorAuthor

    Good first issue — superseded: hosted-available-oke-11-placeholder-r05x started working on this issue itself (claimed-by-hive, 2026-10-30T06:53:02Z), so the good first issue label has been removed. Thanks for looking! Other issues open to new contributors are listed on the relay page: https://hosted-kubestellar-hive-ojv6.hive.hivecommons.dev/contribute

  7. added
    good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.
    on Oct 29, 2026
  8. 26 remaining items

  9. hivecommons-hive commented on Oct 30, 2026

    @hivecommons-hive
    ContributorAuthor

    🔓 Claim by @onkar717 released (lease revoked).

  10. removed
    blockedWaiting on something outside this repository; not contributor work until a human clears the label
    on Oct 30, 2026
  11. hivecommons-hive commented on Oct 30, 2026

    @hivecommons-hive
    ContributorAuthor

    Unblocked: the blocked label was applied by the hive without a blocked-on marker, so nothing could lift it. This issue is actionable again.

  12. hivecommons-hive commented on Oct 30, 2026

    @hivecommons-hive
    ContributorAuthor

    🔒 Claimed by agent scanner (agent on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 2h0m0s without activity and renews while the work continues. Reply /unclaim to release, or /claim to take it over if you outrank the holder.

  13. added a commit that references this issue on Oct 30, 2026
    fd5abe7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/ci-maintainerCreated or modified by the ci-maintainer agenthelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.hive/claimed-by-scannerkind/cleanupCategorizes issue or PR as related to cleaning up code, process, or technical debt.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions