feat(fusion): make auto-merge queue priority-aware
Triage and the todo→in-progress scheduler already sorted by priority (urgent→low, then createdAt ASC, then id ASC); the auto-merge queue was strictly FIFO, so a backlogged low-priority task could merge ahead of an urgent one. drainMergeQueue now picks the highest- priority eligible task each iteration, and the four in-review sweeps (startup, periodic, global unpause, engine unpause) sort by priority before enqueueing so the single-item fast path also picks priority- first. Picker is hardened against concurrent queue mutation by stop() and pause-handler removal: it re-locates the chosen entry by id and re-checks shuttingDown after awaiting getTask. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
10
.changeset/merge-queue-priority.md
Normal file
10
.changeset/merge-queue-priority.md
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
"@runfusion/fusion": patch
|
||||
---
|
||||
|
||||
Apply task priority across all Fusion scheduling paths so urgent work overtakes older low-priority work — including the merge queue, which previously merged tasks strictly FIFO.
|
||||
|
||||
- The auto-merge queue now picks the highest-priority eligible task each iteration (`urgent → high → normal → low`, then `createdAt` ASC, then id ASC). Manual `onMerge` resolvers still run before auto-merges so awaited callers aren't starved.
|
||||
- Startup, periodic, global-unpause, and engine-unpause sweeps now sort their `listTasks` result by priority before enqueueing, so the first task picked up by `drainMergeQueue`'s single-item fast path is the highest-priority eligible one rather than the oldest. All four sweeps share a new `enqueueEligibleInReviewTasks` helper.
|
||||
- Hardened the picker against concurrent queue mutation: it now re-locates the chosen task via `indexOf` after awaiting `getTask`, so a `stop()` clear or pause-handler removal that lands during the await can't splice out the wrong sibling. Drain and picker both re-check `shuttingDown` after the awaits to avoid starting a merge whose queue entry was already cleared.
|
||||
- Triage and todo→in-progress scheduling already used the shared `sortTasksByPriorityThenAgeAndId` comparator and continue to apply dependency, overlap, and worktree constraints after the priority sort.
|
||||
Reference in New Issue
Block a user