Repository navigation
π fix(automerge): update-branch honours the stage record's fork guard when the index has no entry - #17383
Conversation
β¦ when the index has no entry Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Danathar <6772335+Danathar@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 |
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. 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 Review findings from Read One gap in the new code that sits inside the exact scenario this fixes (medium):
Not a regression against today's behaviour (the index path has the same hole after a restart), so I'd not block on it, but it is cheap to close here. I have not changed anything. Review findings from Intent alignment: approve (advisory). Read at head c526d8b against #17380. Each acceptance criterion maps to the diff: index-first then record fallback ( One advisory gap between the PR body and the code:
|
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.
Looks correct to me. Read the new waitingForkGuard/forkGuardRedOnHead against the v6 tree at c526d8b and the callers, not just the diff.
What I checked:
automerge_sweep_trusted.go:919-924β the only caller; the held-update reason staysrequired-check-failing:<check>, so the stage path is unchanged and a held PR still parks at 085 rather than 072.automerge_fork_guard_carry.go:40-55βrecordedForkGuardparses thefork-guard:reason; the fallback here usesrec.ForkGuardChecksfirst and the reason only when that is empty, matching howrecordStage/foldForkGuardalready read the record.pkg/github/fork_guard.go:43-64β the index (ForkGuardChecksFor) only ever names failing checks, so the record fallback countingfailure/action_requiredon the latest run per check (by max run ID) is the same "red" the index would have produced. A green latest run clears it, which answers the old doc comment's objection to consulting the record.- Fail-closed on an unreadable check list (
warn+ return the full guard) is the right side to err on; it costs one tick, an update costs the maintainer's run. - Same-repo PRs never reach this (
isForkPRgate at :917); the test covers red/forbidden/5xx/green,ForkGuardCheckswithout a reason, and the same-repo case.
One open question, not a defect β it is parity with the existing index path: when the maintainer's exact-head run is in_progress (latest run not completed), forkGuardRedOnHead skips it (automerge_fork_guard_carry.go, the GetStatus() != "completed" continue), so an update-branch could still land mid-run and discard it. If that window matters for #917, holding on a non-completed guard run would close it in a follow-up.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
β¦ch update forkGuardRedOnHead only reported completed failure/action_required runs. A newer queued or in_progress run for the guard name won latest[] and was skipped, so the update merged main over the maintainer's live run. A non-completed latest guarded run is now held. Hive-Fix-Attempt: 1/6 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.
Read automerge_fork_guard_carry.go, the single caller at automerge_sweep_trusted.go:919, recordedForkGuard, stageStoreOrShared, and stagelabels/store.go:NoteForkGuard on v6. The change looks correct to me.
Verified
- The fallback is reached only on the
forkbranch ofupdateBranchAndSkip(automerge_sweep_trusted.go:917-918), so same-repo heads are untouched; the index-first order means the three existingTestUpdateBranchSkipsForkGuardedHeadcases take the old path unchanged. recordedForkGuard(automerge_fork_guard_carry.go:36) is only used whenrec.ForkGuardChecksis empty, so a record with either field holds; the!okguard after it prevents a nil record from reaching the REST call.- Fail-closed on an unreadable head (
return guardafter the warn) matches the stated tick-vs-maintainer-run trade; the test covers both 403 and 500. - "Latest run" by max check-run ID is the same heuristic the index uses elsewhere, and
in_progress/queuedcounting as held is right β that is the maintainer's run.
One observation, not a defect
stagelabels.Store.NoteForkGuard (store.go:2586) only ever sets ForkGuardChecks; nothing clears it. So once a fork PR has had a guard recorded, every later update-branch attempt for it β including after the Canary is green, when the index correctly has no entry β pays one paginated ListCheckRunsForRef on the head before updating. Bounded (one call per behind-fork-PR per tick) and strictly less than the maintainer-run it protects, but worth knowing given the hourly REST caps being discussed in #17378/#17385. If it ever matters, clearing the field when the stage leaves 085 would remove it.
CI was still in progress at the head I read (65c8387); tide pending as usual.
β hive: agent=reviewer-2 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 #17380
Why
updateBranchAndSkipholds a fork head that waits on a maintainer-run fork-guarded check (the fork Canary). Mergingmaininto it creates a new head and throws away the run the PR is waiting for. The guard (waitingForkGuard) read only the shared-CI index. That index lives in process memory, is rebuilt from scratch on every enumeration, and has no entry after a restart or after a pass that could not read the check's annotations (REST rate-limit windows). In each of those gaps the contributor lane ranupdate-branch. On projectbluefin/utah-packages#917 that happened five times in 22 hours while the PR sat at 085 onfork-guard:Canary.The stage record already persists the guard (
ForkGuardChecksand thefork-guard:reason). The stage path falls back to it inrecordStageandfoldForkGuard. The branch-update guard was the only fork-guard reader that did not.What changes
waitingForkGuardreads the record's guard (rec.ForkGuardChecks, orrecordedForkGuardfor afork-guard:reason). It then checks the latest run of those checks on this exact head.failureoraction_required), the update is held and the reason staysrequired-check-failing:<check>, so the stage keeps the PR at 085.waitingForkGuardnow says when the record is consulted and why that is safe. A changelog fragment is added.Tests
TestUpdateBranchHonoursRecordedForkGuardis a new sibling ofTestUpdateBranchSkipsForkGuardedHead. It uses an index that is empty for every head and a stage record parked onfork-guard:Canary. It checks that:Canarycompleted/failureon the head, no update is sent and the reason isrequired-check-failing:Canary;Canaryruncompleted/success, exactly one update is sent;ForkGuardChecks(nofork-guard:reason) also holds the update;The three existing cases in
TestUpdateBranchSkipsForkGuardedHeadare unchanged: no stage record exists there, so the new fallback is never reached. I did not run any tests locally; CI is the verdict.β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@Danathar