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>
1.3 KiB
1.3 KiB
@runfusion/fusion
| @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, thencreatedAtASC, then id ASC). ManualonMergeresolvers still run before auto-merges so awaited callers aren't starved. - Startup, periodic, global-unpause, and engine-unpause sweeps now sort their
listTasksresult by priority before enqueueing, so the first task picked up bydrainMergeQueue's single-item fast path is the highest-priority eligible one rather than the oldest. All four sweeps share a newenqueueEligibleInReviewTaskshelper. - Hardened the picker against concurrent queue mutation: it now re-locates the chosen task via
indexOfafter awaitinggetTask, so astop()clear or pause-handler removal that lands during the await can't splice out the wrong sibling. Drain and picker both re-checkshuttingDownafter the awaits to avoid starting a merge whose queue entry was already cleared. - Triage and todo→in-progress scheduling already used the shared
sortTasksByPriorityThenAgeAndIdcomparator and continue to apply dependency, overlap, and worktree constraints after the priority sort.