fix(company): drain review backlogs in arrival order instead of newest-first
Review tasks and review work items were prepended (appendleft) to the role dispatch queue, so whenever a reviewer had more than one review waiting, the newest submission was always claimed first. Under a sustained flow of submissions the oldest review could be postponed indefinitely because every new arrival jumped ahead of it. Observed on a real run: with two reviews waiting on the same manager seat, the one created 30 seconds later was reviewed first while the earlier one waited another seven minutes. The prepend was redundant for its stated purpose: review-before-regular- work priority is already enforced at pop time, where _pop_next_queue_entry pulls the first review entry found anywhere in the queue. Its only net effect was inverting the order among reviews. The role serial queue (FIFO, on by default) could not compensate: its enqueue hook only fires on phase transitions, and review work items are inserted directly in READY, so they never enter the serial queue. Fix: append review entries like everything else. Reviews now drain in arrival order among themselves while still preempting regular work, including on the blocked-manager soft-wake path. Tests: three regressions (pop drains a review backlog oldest-first; enqueue_runnable_work_items preserves arrival order across batches — the observed inversion scenario; same contract for the review-Task path). The pre-existing queue-layout assertion that encoded the old prepend behavior now asserts the pop-time preemption contract instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1156,11 +1156,14 @@ class CompanyRuntime:
|
||||
review_tag = f"review-task::{task.id}"
|
||||
if task.id in queue or review_tag in queue:
|
||||
continue
|
||||
# Kanban-push review tasks take priority over regular work so a
|
||||
# manager role always clears its review backlog before dispatching
|
||||
# or executing its own work.
|
||||
# Review tasks still preempt regular work — that priority is
|
||||
# enforced at pop time (`_pop_next_queue_entry` pulls the first
|
||||
# review entry anywhere in the queue). Appending here keeps
|
||||
# reviews in arrival order among themselves; prepending would
|
||||
# invert a review backlog to newest-first and starve the oldest
|
||||
# submission while newer reviews keep jumping ahead.
|
||||
if bool((task.metadata or {}).get("review_task", False)):
|
||||
queue.appendleft(review_tag)
|
||||
queue.append(review_tag)
|
||||
else:
|
||||
queue.append(task.id)
|
||||
|
||||
@@ -1211,8 +1214,11 @@ class CompanyRuntime:
|
||||
review_tag = f"review-work-item::{work_item_id}"
|
||||
if work_tag in queue or review_tag in queue:
|
||||
continue
|
||||
# Same ordering contract as enqueue_runnable_tasks: review
|
||||
# priority lives in `_pop_next_queue_entry`, so reviews are
|
||||
# appended to preserve FIFO among a review backlog.
|
||||
if is_review_execution_work_item_metadata(metadata):
|
||||
queue.appendleft(review_tag)
|
||||
queue.append(review_tag)
|
||||
else:
|
||||
queue.append(work_tag)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user