Repository navigation
π [v6] contribute: never dispatch rework for a merged or closed PR - #17403
hivecommons-hive[bot] merged 5 commits into
Conversation
hivecommons#17385 merged at 13:13:58Z; at ~14:25Z the hub still handed Danathar's relay "fix-pr hive#17385", and the relay ran it twice. Hub: - Queue a nudged PR under owner/name, not the nudge's Display (the bare configured name on a hive that lists repos without the org). Resolve keys on owner/name, so the bare entry was never removed when the PR left stage 072, and the relay could not match the task's repo "hive" to an owner/name. - Before dispatching a queued fix, check its PR is still open (state cache first, else one PR read tagged hive:contribute_fix_dispatch). Merged or closed PRs leave the queue with a log line; an unreadable state holds the dispatch for this tick. fixqueue.Next previews what a dispatch would take so only those PRs are checked. - Send a boundary fix task once: the ready handler ships the returned message, so sendFixTask no longer pushes it as well. - Progress for an in-flight fix task (a boundary fix runs as the relay's primary task) is not a resume claim and is no longer revoked. Relay: - A fix-pr task_id the relay already runs (primary, parallel, preempting or deferred) is ignored on a second task_assign, with a log line naming where it runs; a fix that becomes the primary task says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <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 |
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. |
|
@Danathar this PR is back in your court ( Failing checks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Your relay session received this as a |
|
Check report for the one red required check,
Suggested action: no code change is needed in this PR for this check. A re-run of the hive/awaiting-ci: fork PR β comment only; sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Read the diff against v6 at be24159c0 plus the callers; this looks correct to me.
What I verified:
src/pkg/forgestate/store.go:334βReadThroughreturnsok=falsefor a closed/merged/gone item and refuses withErrNotReady/ErrStalerather than guess, so the mapping infixPRStateOf(absent-after-fresh-read β gone; stale/not-ready β fall through to one REST read) matches the store's contract.bound=0resolves toOptions.FreshnessBound, as the body says.src/pkg/dashboard/contribute_select.go:495βselectTaskreturnsselectFixTask's message to thereadyhandler, so a boundary dispatch is indeed already shipped there;sendFixTask(..., !boundary)removes the second send without touching the non-boundary callers (Nudge,completeFixTask, reroute), which still push.src/pkg/dashboard/contribute_ws.go:4098β the early return sits inside thecurrentTask == nilbranch and only fires for atask_idinfixTasks, so the C4 resume gate still rejects unknown task IDs. Fix tasks hold no lease, so skippinglookupLeasedrops nothing they relied on.src/pkg/fixqueue/fixqueue.goβNextandpopsharecoalescesanddispatchableLocked, so the preview can't disagree with the pop on the same queue state.NudgeβFixWorkFor(contribute_fixqueue.go:332) checks both in-flight and queued, so the offline-relay path (enqueued, not dispatched) still reportsqueued.
One open question, low severity, not a blocker: dispatchFixes calls sched.Next β dropClosedFixes β sched.Dispatch* without holding a lock across them (contribute_fixqueue.go:438-456). dispatchFixes is reachable concurrently from the sweep (Nudge), the ws session (selectFixTask, completeFixTask) and reroute. If another caller pops the previewed item in that window, this caller's Dispatch can hand out the next item without its state having been checked. The consequence is one dispatch with today's behaviour, not a regression, so I'd leave it unless you want the preview+pop fused into one scheduler call.
CI: the only red is test (agent 5/5) in pkg/agent, which this PR does not touch; every dashboard and shuffle shard passed.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Correctness review at head 1. (low) A 404 on the direct PR read is treated as "gone" and silently drops the fix β contribute_fixqueue.go:535-538. A PR cannot be deleted, so 2. (low) Preview/pop window in Review findings from docs-currency (read at head One advisory, operator-facing: when a PR's state cannot be read, and in stage 080-awaiting-merge-admission β 072-returned-to-contributor: check-failure Reviewed by Reviewer notesRead the diff against v6
The state read runs from the sweep goroutine / the |
β¦tah-packages#972) projectbluefin/utah-packages#972, 2026-11-09: the relay refused fix-karibhou-1, the hub requeued it and served it at the next ready as fix-karibhou-2 on the same connection, and the relay's progress for the retry (repo empty, client_gen 1870) was answered with "no matching server-issued lease" and task_revoke at 14:50:21Z and 14:54:36Z. The handleTaskProgress change in this PR already covers it; this test drives the real fail -> requeue -> boundary dispatch path and sends progress without a repo, as the relay did, so the retried task id must be tracked on the connection and never revoked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com>
When a queued fix's PR state could not be read, selectFixTask answered task_unavailable/fix_pr_in_flight, so the relay got no new issue either. That happens when GitHub is struggling or the API budget is low, the time the hive needs its contributors most. The fix now stays queued and is retried on the next ready, and the relay takes ordinary work meanwhile. Busy fix slots still answer task_unavailable as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Douglas Baggett <doug.baggett@gmail.com>
There was a problem hiding this comment.
Read the diff against the v6 tree plus the callers (contribute_select.go:495, forgestate/store.go:329-334, the relay's assignmentInScope). The five fixes each do what the body says; looks correct to me.
What I verified:
- Open-state check (
contribute_fixqueue.go,dropClosedFixes/fixPRStateOf):forgestate.Store.ReadThroughdocumentsok == falseas "closed, merged or gone" (store.go:333), so treating a fresh-read miss asfixPRStateGoneis right, andErrStale/ErrNotReady/ErrUnknownRepofall through to the directPullRequests.Getrather than being reported as errors. A read error returnsUncheckedwitherr, whichdropClosedFixesturns intohold, so an outage never dispatches. NextβDispatchparity (fixqueue.go): both go throughdispatchableLocked, andpopandNextsharecoalesces(), so the preview is the set that would be taken. Thedropped β continueloop terminates becauseRemoveis keyed on the sameRepo/Numberthe preview returned.- Send-once at a boundary:
sendFixTask(β¦, push=false)still registersc.fixTasks[d.ID]/fixTasksAtbefore skipping the websocket write, sofailFixTask,handleTaskProgressand thereadyhandler all still see the task. - No revoke for an in-flight fix (
contribute_ws.go:4094-4100): the early return is gated ons.contributor.fixTasks[msg.TaskID], a server-populated map of task IDs the hub issued to this connection; a client cannot assert an arbitrary task_id into it, so the C4 resume-claim protection below is not weakened. nudgeFixRepo: the relay's scope gate derives the repository identity from the task URL (assignmentRepositoryID), not from the barerepostring, so sendingowner/namecannot newly fail scope.- Relay dedupe:
fixPRRunningWhereis checked after the polling-slot gate and before thecurrentTaskinterrupt branch; no conflict with #17405's exemption (trial merge of the two heads is clean).
One open question, info-level, not a defect: Next β dropClosedFixes (a GitHub read, up to fixPRStateTimeout = 10s) β Dispatch runs without the scheduler lock held across the three, so a Nudge that enqueues a higher-priority item during the read makes Dispatch pop an item the preview did not check. The consequence is bounded β a just-nudged PR is open by construction β so I would not change it, just noting the window exists.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the diff at aa39520 against the v6 tree (2b549c8), including the callers. The change does what the body says, and the one place I expected a gap holds up. Looks correct to me.
What I checked:
- Boundary task sent once.
selectTask(contribute_select.go:495) returnsselectFixTask's message andhandleReady(contribute_ws.go:3816) sends it, so the oldsendFixTaskpush at a boundary really was a second copy.dispatchFixesalready breaks after one pop whenboundaryis true, so dropping the push leaves exactly onetask_assign; no other caller passesboundary=true. The three non-boundary callers (Nudge,Resolve,contribute_reroute.go:191) still push via!boundary. - Cache path can't mistake a cache miss for "gone".
forgestate.Store.ReadThrough(store.go:352-374) only returnsok=falsewith a nil error after it has fetched the item (ErrNotFoundβ removed, or upserted and still absent). An absent cache entry triggers the fetch; it is not read as closed. Stale/not-ready fall through to the REST read as intended. - Progress early-return is not a trust regression.
fixTasksis populated only bysendFixTaskon the server side, so a relay can't use the new branch inhandleTaskProgressto claim a task it was never issued; the branch just returns without minting anything, and the test still assertsnot-mineis revoked. - Relay guard.
fixPRRunningWherecoverscurrentTaskinhandleFixPRInterrupt(wherecurrentTaskis guaranteed set) and the parallel/preempting/deferred sets on the no-task path. The!currentTaskbranch is placed before the "Already has active task" reject, so a duplicate is silently dropped rather than failed back to the hub, matching the test.
Minor, not a defect: Next for boundary=true skips the NotBefore check, which matches DispatchAtBoundary's existing guard, so preview and pop stay consistent.
CI was still in progress when I looked; nothing red at this head.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
Summary
The hive sent Danathar's relay a
fix-prtask for #17385 more than an hour after that PR merged, and the relay then ran the one task twice. About 4.5 minutes were lost and nothing was pushed. Five separate bugs lined up to cause it: the fix queue stored the repo under the wrong name, so the entry was never cleared; nothing checked that a queued PR was still open; a fix handed out between tasks was sent to the relay twice; the relay accepted both copies; and the hub then revoked the run that should have survived. With this PR, a merged or closed PR leaves the fix queue instead of going to a relay, fix tasks name the repo asowner/name, a fix handed out between tasks is sent once and is not revoked, and the relay runs any one fix task in only one place.What went wrong
Evidence from the hivecommons hive (
hosted-kubestellar-hive-ojv6), checked on GitHub:reason=conflicting head=6be425aβ¦ mode=queued, "Queued in your relay fix queue (1 waiting)"). That is the only nudge on the PR. Its comment was never edited afterwards.f55e50d, then9715e04) were reviewed at 13:05Z and 13:12Z. The PR merged at 13:13:58Z. The "merged by Hive trusted-author auto-merge" comment followed at 13:14:05Z.Task assignedfor that PR (kindfix-pr, repohive),Task prompt sent to CLIandspawning a parallel fix session (1/1). It then loggedTask revoked: fix-danathar-1 β no active lease for this task. It also loggedIgnoring authorized-repo candidate that is not shaped like owner/name: "hive".I could not read that hive's log for the
contributor nudged/fix queue enqueuelines, because I have no access to the hivecommons hive's logs. So I worked out from the code which path queued the fix. Only two code paths put a PR in a contributor's fix queue:automerge_contributor_nudge.gocallsContributeWSHub.Nudge). It runs only for an open PR that a sweep has just listed.Reroute, from the repo-item decision API). It reads the PR first and refuses one that is not open.Neither one can queue an already-merged PR. Here is what happened instead, step by step:
hive, becauseNudgeuses the nudge'sDisplay, the bare configured name on a hive whose repos are listed without the org.Resolve("hivecommons", "hive", 17385).Resolvelooks uphivecommons/hive#17385, which does not match the stored name, so the entry stayed in the queue.sendFixTaskpushed thetask_assignitself, and then thereadyhandler sent the returned copy as well. The relay ran the first copy as its primary task. The second copy arrived while that task was running, so it looked like a mid-task interrupt, and the relay spawned a parallel session for the sametask_id.task_revoke.Refs #17385
What changes
owner/name.Resolvenow finds it, and the fix task the relay receives carrieshivecommons/hive, nothive.hive:contribute_fix_dispatch.fix queue: dropped a PR that is no longer open.fixqueue.Nextpreviews them without taking them from the queue.sendFixTaskno longer pushes a fix that is handed out when the relay asks for work, because thereadyhandler already sends it.task_revoke.task_assignwith thetask_idof a fix the relay is already running is ignored, whether that fix runs as the primary task, in a parallel session, as a preempting fix, or deferred. The log names where the fix runs, and a fix that becomes the primary task logs that too.Out of scope: review-verdict routing and merge policy.
Files
src/pkg/dashboard/contribute_fixqueue.go:owner/namequeueing, the open-state check, sending a fix handed out between tasks only oncesrc/pkg/dashboard/contribute_ws.go: progress reports for an in-flight fix are not revoked; test hook fieldsrc/pkg/fixqueue/fixqueue.go:Next, plus the shared dispatch guards and coalescing rulebin/contributor-relay.js: duplicatefix-prguard and path loggingsrc/docs/contributor-relay.md,changelog.d/fixed-contribute-no-rework-for-merged-pr.mdcontribute_fixqueue_closed_pr_test.go(new),fixqueue_test.go,contributor-relay.test.js; two existing tests adjusted for the newsendFixTaskargument and a fixture PR the GitHub mock does not serveTests
No tests were run locally (repo policy); CI is the check. Each test below would fail on
be24159c0:TestFixQueueBareConfiguredRepoQueuesOwnerName: a nudge withDisplay: "hive"gets a task with repohivecommons/hive, andResolveclears the queued entry. On the tip, the repo ishiveand the entry survivesResolve.TestFixQueueBoundaryDropsPRThatMergedWhileQueued: a PR that merged while queued is dropped when the relay next asks for work. No task goes out, and the relay falls through to issue selection. On the tip, the fix goes out.TestFixQueueDispatchSkipsClosedPRAndServesTheNextOpenOne: only the merged PR is dropped; the open PR behind it is still dispatched.TestFixQueueNudgeForMergedPRDispatchesNothing: a nudge for a PR that has already merged queues nothing, and the nudge is reported as comment-only.TestFixQueueHoldsDispatchWhenPRStateUnreadable: an unreadable state dispatches no fix and keeps it queued,selectFixTaskreturns nothing so the relay gets ordinary work, and the fix goes out once the state can be read again.TestFixQueueBoundaryTaskIsSentOnce: a realreadyover a websocket delivers exactly onetask_assign. On the tip, it delivers two.TestFixTaskProgressIsNotRevoked: progress for an in-flight fix task gets notask_revoke, while a task the hub never issued still gets one. On the tip, both are revoked.TestNextPreviewsDispatchWithoutTakingIt(fixqueue):Nextmatches whatDispatchtakes, and returns nil wheneverDispatchwould.#17385 a fix-pr task_id delivered twice runs once, as the primary task: on the tip, the second copy spawns a parallel session.#17385 a fix-pr task_id already in a parallel session is not also started as the primary task: on the tip, the duplicate becomes the primary task.Also seen on projectbluefin (follow-up test)
The same revoke hit a retried fix on the projectbluefin hive. On projectbluefin/utah-packages#972 (2026-11-09) the relay refused
fix-karibhou-1, and the hub served it again at the relay's nextreadyasfix-karibhou-2, a boundary fix on the same connection. The relay's progress for it (14:50:21Z and 14:54:36Z, with an empty repo andclient_gen1870) was answered withtask_progress resume rejected: no matching server-issued leaseandtask_revoke. ThehandleTaskProgresschange above already covers this. The extra commit addsTestRetriedBoundaryFixProgressIsNotRevoked, which drives the real fail β requeue β boundary dispatch path and sends progress with no repo, as the relay did. It asserts that the retried task is never revoked, while the first task, which the relay failed, still is. Onbe24159c0both would be revoked.π€ Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1