Repository navigation
✨ feat(mergelane): serialized lane core with durable front record and pinned merge - #10897
Conversation
…inned merge Signed-off-by: scanner <scanner@hive.kubestellar.io>
|
[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 |
|
hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
Read lane.go and store.go in full against the v6 tree; the core looks correct to me. The two red checks are pre-existing on v6 HEAD, not from this PR.
What I verified:
- Every
pkg/github/pkg/configsymbol the package borrows exists onv6with the semantics the lane assumes:BranchRulesResult.Known/Required/Reason/SortedRequired(src/pkg/github/branch_rules.go:30-44,150),ClassifyRequiredCheckmapping skipped/neutral→passed and failure/cancelled/timed_out/action_required→failed (branch_rules.go:136-147),MergeableFromState(client.go:3337),HasHoldLabel/HasExemptLabel(client.go:2342,2505),config.MergeStrategyHiveSerialized(src/pkg/config/repo_policy.go:29). - Fencing:
round.save/round.leaveboth re-checkPR+Epochunder the store transaction before writing, andmerge()savesStageMerging(fenced) before the GitHubMergecall, so a front taken away by expiry/Release/restart cannot complete a merge round.Newbumps the epoch and clearsEvaluatedHeadfor every persisted front, so a pre-restart holder is fenced as the body claims. - Store:
updatetakes the in-process mutex andflock(LOCK_EX)onfronts.json.lock, reloads, applies, then temp+fsync+rename and a directory fsync — matches the described ledger idiom; an unparseable file errors out ofOpenStorerather than being overwritten. - Post-merge
verifychecksparents[0] == validated tip. That is correct for both merge methods hive'sMergePRissues (squash, andmergefor forward-merges —src/pkg/github/pullrequest.go:245-256); there is norebasemethod anywhere inpkg/config/pkg/github, so the first-parent check cannot false-alert on a multi-commit rebase. Worth keeping in mind if rebase is ever added. - No existing file is touched, so "nothing changes for
directrepositories" is accurate.
CI on 4ce2f22: test (rest 5/5) failed in setup (npm missing from PATH, the #10518 runner cache issue — no Go test failed in the log), and relative links and anchors resolve reports 102 api-reference citation drifts in pkg/dashboard/api.go, which this PR does not modify. Both checks are also failure on current v6 HEAD (gh api repos/hivecommons/hive/commits/v6/check-runs), so a re-run / base fix is what's needed, not a change here.
Nothing blocking from my side; a maintainer should sanity-check the state-machine semantics against #10884's R8–R13 since that is a design judgement, not something I can settle from the code alone.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Deferred to shared CI incident #10899: 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
…i-reference citations TestInvalidMergeStrategyFailsValidationAndStopsAutoMerge built an agentless config, so Validate() stopped at 'at least one agent must be configured' before reaching the merge_strategy check. Use ValidateWithOptions with RequireAgents unset, matching the other agentless config tests. Also rewrite the 102 api-reference.md source citations drifted by the pkg/dashboard/api.go route additions (check-api-reference-citations --fix). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <scanner@hive.kubestellar.io>
|
hive/awaiting-ci: pushed e01ca19 — agentless config test now uses ValidateWithOptions (RequireAgents unset) and api-reference.md citations re-synced via check-api-reference-citations.sh --fix. CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #10888
Part of #10884
Summary
New self-contained package
src/pkg/mergelane/(4 files incl. tests): the serialized lane core forhive-serializedrepositories. It is not wired into any merge path (next child, #10889), so nothing changes fordirectrepositories or any existing test.Durable front record (
store.go)/data/mergelane/fronts.json, reloaded under an exclusiveflockand rewritten atomically (unique temp name, fsync, rename) on every transaction, the same pattern as the convergence claim ledger. A corrupt file is refused and left untouched, so the lane fails closed.Gate API (
lane.go)Acquire(repo, branch, pr, path): records eligibility. The oldest eligible PR reaches the front. Everyone else getsdeferred: not at the front of the laneand their position.Advance(ctx, repo, branch, pr, authorize): runs one round for the front PR (validate → update → wait → final re-check → pinned merge → verify). Non-front callers are deferred and no GitHub call is made for them.Release(repo, branch, pr, reason): called when the path no longer finds the PR eligible. If the PR becomes eligible again, it rejoins at the back.Snapshot: returns the durable state for later dashboard/API use.Newfences every front left by a previous process (epoch bump, validation reset), so after a restart the validation is repeated in full.GitHubinterface (PR, branch tip, comparetip...head, the lane-onlyBranchRulesResultfrom ✨ github: lane-only branch-rules reader (ruleset required checks, up-to-date enforcement, native merge-queue detection) #10887, check runs, pinnedUpdateBranch(expectedHead), head-pinnedMerge, commit parents, PRs for a commit). The policy hooks (strategy viaconfig.MergeStrategyHiveSerializedfrom ✨ config: per-repo merge_strategy (direct | hive-serialized) with validation, asymmetric permission and API #10886, auto-merge, pause, labels, front timeout override) are callbacks. Any callback left nil fails closed.State machine (R8–R13, R15–R19, fail closed)
mergeable_state: behind. Only the front PR is updated, with a merge update pinned to the evaluated head. A changed head means no update; the new head is re-evaluated and the PR keeps the front. After an update the lane waits for the head to move off the pinned SHA.unknownmeans no merge this round), the required set and its results, hold/do-not-merge/exempt/pause labels, repo pause, strategy, auto-merge, and the path's authorization callback.ErrHeadMoved) restarts validation. Any other error means no merge this round. The epoch is fenced right before the merge call.directends validation without a merge and without a GitHub call.Note:
UpdateBranchExpectedHead(#10864) is not onv6yet. The lane's interface takes the expected head, and the wiring child will adapt it to that helper.Acceptance criteria covered (unit/scenario tests with fakes, injected clock, no sleeps)
direct, auto-merge off, path authorization lost, a new required check, a check failing during validation.— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@Danathar