Repository navigation
🌱 refactor: split src/cmd/hive/main.go into 4 files - #15690
Conversation
Mechanical move of whole top-level declarations out of the 11.8k-line main.go into three sibling files in package main; no behaviour change. - main_github_app.go: GitHub App auth, token heartbeat fields, failure classification, advisory post gates - main_eval_cycle.go: runEvalCycle and its kick/plan/lifecycle helpers - main_sweeps.go: escalation, periodic sweeps, review dispatch Closes #15585 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
hive/awaiting-ci: CI pending — sweep will merge when green. Known overlap: #15582 touches planReviewDispatchWith (now in main_sweeps.go); whichever lands second re-applies. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
stage 080-awaiting-merge-admission → 070-fixing: optional-check-failing:relative links and anchors resolve |
…d docs citations The six wrapper write calls baselined under cmd/hive/main.go now live in cmd/hive/main_sweeps.go, so TestDirectWriteRatchet saw an unbaselined file. Move the baseline line (count unchanged) and refresh the src/docs file:line citations that pointed past main.go's new length. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
TestF3AuthorizerIsWiredInMain pinned the MergerAuthorizer: trustedMergerFunc(cfg) guard to cmd/hive/main.go; the split moved that wiring into main_sweeps.go so the guard failed on pure code motion. Read the whole cmd/hive package via f3ReadPackage (as the trustedMergerFunc body check already does) so the assertion follows the declaration between files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verified this is a pure move, mechanically rather than by eye:
- Declarations: the set of top-level
func/type/var/constsignatures in the oldmain.go(at merge-based086be1) and in the union of the four new files is identical — 267 each,diffempty. - Bodies: stripping
package/importlines and sorting, the remaining non-blank lines of oldmain.govs. the four files differ by 0 lines. Nothing was edited in transit, only regrouped. go build ./cmd/hive/at headb1f71bbsucceeds;gofmt -lon the four files reports nothing.- Side changes are consistent with the move:
f3_trusted_merger_source_test.goswitches from readingmain.gotof3ReadPackage(..., "../../../cmd/hive")(the helper already existed and was already used two lines below), anddirect-writes-baseline.txtmoves onewrapentry tomain_sweeps.go. The sevensrc/docsedits re-pointfile:linecitations to the new files.
One scheduling note for whoever merges: #15582 adds a hunk at old main.go:~11105 (planReviewDispatchWith), which lands in one of the moved regions here. Whichever merges second needs a mechanical rebase; no semantic overlap.
Looks correct to me.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 080-awaiting-merge-admission → 060-reviewed: check-pending |
There was a problem hiding this comment.
Verified this is a content-preserving move, which is the thing a reader cannot check by eye on a 5.3k/5.2k-line diff:
- Sorted the non-blank, non-import lines of
v5:src/cmd/hive/main.goagainst the union ofmain.go+main_eval_cycle.go+main_github_app.go+main_sweeps.goat52ac97b: the only differences are thespokeimport alias now appearing in two files and the extrapackage mainlines. Everyfuncremoved frommain.gois added exactly once in a sibling file. gofmt -l src/cmd/hive/is clean andgo build ./cmd/hive/succeeds on this head.- Doc citations that pointed into
main.gowere remapped (src/docs/*.md, 11 files) and the write-ratchet baseline follows (src/pkg/writeback/testdata/direct-writes-baseline.txt).
Looks correct to me. Note for whoever merges: conflicts-with-open-pr is expected — #15645 adds to main_helpers.go (untouched here) but any open PR editing main.go will need a rebase onto the split; landing this first and rebasing the others is cheaper than the reverse.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 080-awaiting-merge-admission → 050-review-pending: check-pending |
There was a problem hiding this comment.
Verified the "verbatim move" claim mechanically rather than by reading 5k lines, and it holds. Looks correct to me.
What I checked
- Multiset of all non-blank, non-
import, non-packagelines inv5:src/cmd/hive/main.go(11,162 lines) equals the union of the four head files: 0 lines only in base, 0 only in head. Nothing was edited, dropped or added during the move. - Each of the four files is an order-preserving subsequence of the original, so declarations keep their original relative order as the body says.
- Source-scanning tests: the F3 test now reads the whole package via
f3ReadPackage(f3_trusted_merger_source_test.go:194), which is right sincetrustedMergerFuncand theMergerAuthorizer:needle no longer need to share a file;f3ReadSourceis still used at:100, so no dead helper. The other six tests that readcmd/hive/main.go(gfi,base_branch_red,request_dirs,governor_boot_kick,intent,reach) are unchanged andbuild-and-testis green, which runs./cmd/.... writeback/testdata/direct-writes-baseline.txt: the 6wraphits move frommain.gotomain_sweeps.go; consistent with where the sweeps went.- Docs: every updated
file:linecitation I spot-checked (main.go:5772/5956/6112/6899,main_eval_cycle.go:471/964/1127) lands on the named symbol at the head commit, and none of the 20 remaining barecmd/hive/main.goreferences insrc/docsnames a function that moved out ofmain.go.
For whoever sequences the merge train: this is a hotspot by design, so every open PR touching main.go will need a rebase after it. In particular #15582 edits planReviewDispatchWith, which here lands at main_sweeps.go:2294; whichever of the two merges second gets a trivial but real conflict. Only the arm64 build was still in progress when I looked.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 080-awaiting-merge-admission: no activity for 30m0s: merge-train:queued-behind#15582:2/2:0/0:main.go |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #15585
Why
src/cmd/hive/main.go(~11.8k lines) is a merge hotspot: 7 distinct PRs touched it in 7 days, with 7 concurrently-open pairs, and every concurrent pair is a rebase someone (or the merge train) has to redo on a huge file. This is the mechanical split the issue asks for.What
Whole top-level declarations (with their doc comments) moved verbatim, in original order, into sibling files in
package main. No behaviour change, no renames, no signature changes; only the import blocks differ per file.main(), theboottype and all its phase methods stay inmain.go, so every source-scanning test that readsmain.go(shutdown hooks, dashboard dispatch, request-dir gate, F3 merger authorizer, ClearLastKicks guard) still finds its needles there.main.goreporterName,main,boot+ allboot*Withphases, knowledge/hive-ID/snapshot persistence (persistState*), config overrides, nous state, logger, misc helpers,dispatchSubcommandmain_github_app.goprospectiveGitHubIdentity,nextInstallationID, GitHub App token heartbeat fields,githubAppStructuredFailure,githubAuth,initGitHubAuth,startDocsTokenRefresh,buildAgentMinter,healGitHubAppInstallation, rate-limit/App-failure classification (classifyGitHubApp*,appAuthID), advisory post gates (advisoryPostGate…advisoryIssueMissingError)main_eval_cycle.gobuildRepoActivityWire, provider-budget/fairness state, budget/no-cadence/mode alerts,agentKicker,planFromLabeledIssues,labelPlanSink,lifecycleRecorder,recordEnumeratedIssues,recordKick,issueRef/actionableIssueRef,actionableAfterGitHubEnumerate,markConfiguredReposStale,tokensForBackend,runEvalCyclemain_sweeps.goresolveRedPRFixer,deliverReEngagement,reapStuckRedPRs,runEscalationSweep), allrun*SweepIfDuesweeps + intervals, rotation check, sentinel, duplicate-PR guard / claim ledger, review relay/bots, review dispatch planning (planReviewDispatchWith…), review outcomes/fix audit, review-dispatch state persistenceTests are left in place (same package; no existing test file is dedicated solely to the moved code). Prose references in
src/docs/that name a moved function now point at its new file. Imports were computed withgoimportsand cross-checked by identifier scan;gofmt -lis clean. Verified the concatenated non-import lines of the four files are identical (as a multiset) to the originalmain.go.Known overlap
#15582 ("warn once per PR on review dispatch promotion") edits
planReviewDispatchWith, which now lives insrc/cmd/hive/main_sweeps.go; whichever lands second needs a trivial re-apply of that hunk in the new file.— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88