Skip to content

🌱 refactor: split src/pkg/github/automerge/automerge_sweep.go into 4 files - #15819

Merged
hivecommons-hive[bot] merged 4 commits into
v5from
scanner/fix-15513
Oct 30, 2026
Merged

hivecommons-hive[bot] merged 4 commits into
v5from
scanner/fix-15513

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

src/pkg/github/automerge/automerge_sweep.go was a ~3400-line monolith touched by many concurrent PRs. This is a pure move into 4 files in the same package: no logic, signature, name, or comment changes (only per-file import lists were trimmed to what each file uses). Tests are untouched.

  • automerge_sweep.go: transport interfaces, Options, Engine, New, interval/budget constants, config setters, trusted-author policy types, sweep event/result types.
  • automerge_sweep_loop.go: queued / self-authored / trusted-author sweep entry points, tick gating, the self-authored sweep loop and per-PR self-authored sweep.
  • automerge_sweep_trusted.go: lane selection, label/prefilter helpers, trusted-author per-PR sweep, update-branch handling.
  • automerge_sweep_queued.go: queued-PR sweep, Hive queue approval parsing, commit-green/required-check helpers, merge-effect and logging helpers.

Closes #15513

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

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 30, 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

@github-actions

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but carries no changelog entry
(no changelog.d/ fragment and no CHANGELOG.md edit).

If it is user-visible — a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking —
please add a fragment file changelog.d/<category>-<pr-or-slug>.md
containing exactly your entry (see changelog.d/README.md; the
category is one of added/changed/deprecated/fixed/security). Please
do not append to CHANGELOG.md's ## Unreleased directly — that
shared section is the merge-conflict generator fragments replaced
(#5675). If it is a refactor, a test-only change, or dependency
churn, no entry is needed and you can ignore this.

This is a reminder, not a gate; it never blocks a merge.

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

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

PR Title Relation Files
#15885 ✨ Add integration-aware orchestration above preparation and native queues same files src/pkg/github/automerge/automerge_sweep.go

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 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

clubanderson pushed a commit that referenced this pull request Oct 30, 2026
Generated by changelog-fragment-guard from the PR title (#5675).
Edit the wording freely, or replace this file with the no-changelog
label if the change is not user-visible.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me as a pure move. Verified at e7000e5 against merge-base 1b1a8a9:

  • Concatenating the four files (automerge_sweep.go 963 lines + _loop.go 848 + _queued.go 696 + _trusted.go 931) and normalising whitespace/blank lines yields exactly the merge-base automerge_sweep.go content; the only diff is the expected duplicated import lines (gh, hgithub, context, strings, …) each new file needs. No function body, comment or declaration changed.
  • go build ./pkg/github/automerge/ passes on this head.
  • The three doc citation updates are right: isHiveAppReviewAuthor is now at automerge_sweep_queued.go:256 (the old automerge_sweep.go:1221 cite was already stale — it lived at line 2958 at merge-base), and SweepQueuedAutoMerges opens automerge_sweep_loop.go.

One open question, not a finding: test (rest 1/4) and test (rest 2/4) are red at this head (run 41091510118) and I could not read the job logs from this pod. A same-package move cannot change behaviour, so I'd expect a flake or an unrelated package in that shard — but whoever merges should glance at the failing test name before assuming so.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this is a pure move at e7000e5 — looks correct to me.

  • Compared the merge-base automerge_sweep.go (2435 lines) against the four files it became: the sorted non-blank line multiset (excluding package/import lines) is identical, 3172 lines each side, and the set of top-level func/type/var/const declarations is identical (146 declarations). No body changed.
  • go build ./pkg/github/automerge/ succeeds on this head.
  • The two doc citations were retargeted correctly: isHiveAppReviewAuthor is at automerge_sweep_queued.go:256, and SweepQueuedAutoMerges moved from automerge_sweep.go:976 to automerge_sweep_loop.go:20, so automerge_sweep_loop.go:13-80 in labels-and-control-signals/reference.md covers the same region the old 966-1036 range did.
  • v5 has not touched automerge_sweep.go since the merge-base, so no drift to re-apply.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending — sweep will merge when green. (F3 source guards re-pointed at the package after the file split.)


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

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

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

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

@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

# Conflicts:
#	src/pkg/github/automerge/automerge_sweep.go
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: merged v5 (#15831's merge-train hold hunks ported into automerge_sweep_loop.go / automerge_sweep_trusted.go, where that code now lives after the split). CI pending — sweep will merge when green.


🐝 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 added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

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 84c9602; split verified byte-identical to the monolith apart from import lists)

F3 "gate is not blanket" guard narrowed by the split — src/pkg/github/automerge/f3_trusted_merger_source_test.go:229

TestF3TrustedMergerGateIsNotBlanket now reads only automerge_sweep_queued.go and asserts exactly one c.isTrustedMerger( call. At base it scanned the whole automerge_sweep.go, which contained all three sweep paths. Its own comment (f3_trusted_merger_source_test.go:225-227) says the point is to catch the queuer-login gate leaking onto the self-authored sweep, "which has no queuer at all" and would fail closed forever. That path now lives in automerge_sweep_loop.go:13-92 / trySweepSelfAuthoredPR, and the trusted-author path in automerge_sweep_trusted.go — both outside the scanned file, so the guard no longer fires for the exact regression it was written for. The other four F3 tests in this file were correctly switched to f3ReadPackage(t, "."); this one was not.

Fix: concatenate the four automerge_sweep*.go files (or f3ReadPackage filtered to the automerge_sweep prefix — a package-wide count is wrong because automerge_operator_admission.go, pr_approve_command.go etc. legitimately call isTrustedMerger) and keep want exactly 1. The decl in automerge_sweep.go:882 is ) isTrustedMerger( and does not match c\.isTrustedMerger\(, so the count stays 1 today.

Also: the PR body says "Tests are untouched" — this test file is changed; the changelog/body should say so.

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

Hive-Fix-Attempt: 2/6

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this is a lossless move. Looks correct to me.

  • Normalised the merge-base automerge_sweep.go (3460 lines) and the four files at d067e8e (blank lines, package/import blocks stripped, sorted) and diffed: 3242 ≡ 3242 lines, zero differences in either direction. No declaration, body line or comment was dropped or altered.
  • go build ./pkg/github/automerge/ ./pkg/writeback/ at the head is clean; the per-file import lists are exactly what each file uses.
  • src/pkg/writeback/testdata/direct-writes-baseline.txt: the old automerge_sweep.go 7 becomes _queued.go 3 + _trusted.go 4 = 7, so no raw write site was added or hidden.
  • f3_trusted_merger_source_test.go:226-245: TestF3TrustedMergerGateIsNotBlanket now concatenates all four sweep files before counting c.isTrustedMerger( call sites, so the "exactly one call site" guard still covers the loop/trusted paths after the split. The other F3 tests switch to f3ReadPackage(t, ".") (defined at :56), which is the right scope for a function that moved.

Two notes, neither blocking:

  • The body says "Tests are untouched"; the follow-up commit does edit f3_trusted_merger_source_test.go (necessarily — the source-scanning tests hard-coded the old filename). Worth a one-line body update so the description matches the diff.
  • The three doc citations (glossary-and-operations.md:134, reference.md:787, github-mention-triggers.md:132) were mapped by line offset. automerge_sweep.go:954-959 and the old :959-964 both land on AutoMergeSweepEvent struct fields, not the held-PR skip — that drift predates this PR at the merge-base, so it is not introduced here, but the isHiveAppReviewAuthor cite at automerge_sweep_queued.go:256 is the one that is exact.

CI: the three Sign-off survives the squash runs show CANCELLED rather than failed — looks like runner churn, not this diff.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified as a pure move. Method: I stripped package/import lines and blank lines from v5's automerge_sweep.go and from the concatenation of the four files on this branch, sorted both, and diffed — zero differences once the branch is test-merged with current v5.

One thing a maintainer should know: the branch is 9 commits behind v5, and #15757 (1dd1cea) added HiveSupersedingAutoMerge / SentinelAcknowledgedBy to Options/Engine/New after this split was cut. Those live in the part of automerge_sweep.go this PR retains, so GitHub's merge is clean (I reproduced it locally: Auto-merging src/pkg/github/automerge/automerge_sweep.go, no conflicts) and the merged result still matches v5 content exactly. No rebase needed for correctness; the arm64 build is the only check still running.

The f3_trusted_merger_source_test.go change to scan all non-test files in the package (f3ReadPackage) and the explicit four-file list in TestF3TrustedMergerGateIsNotBlanket keep the single-call-site invariant meaningful after the split. Looks correct to me.

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

@hivecommons-hive
hivecommons-hive Bot merged commit f7c67ad into v5 Oct 30, 2026
78 of 81 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15513 branch October 30, 2026 21:46
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#15819d067e8e` sha256:33e530fdc0ccfc1d8afa47874c141dcafc6cd482d59918143eb2b156722391d9 — download from the dashboard or `hivectl review evidence #15819`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

0 participants