AI-assisted engineering/AI-collaboration build

Fix FairQueue so tenants take turns

AI-collaboration buildHard40 min

A hosted job runner shares one queue among all its tenants. Last week one tenant queued 40,000 report jobs and everyone else waited behind them. FairQueue is the fix, and it is not right yet.

Your task

Fix FairQueue so it honors its contract. The assistant may help, and it may be wrong more than once.

  • every queued high job comes out before any low job
  • within a priority, tenants take turns, starting after the tenant served last at that priority
  • the turn order is the order in which tenants first pushed at that priority, and a tenant whose jobs run out keeps its place
  • one tenant's jobs at one priority come out in the order pushed; pop() with nothing queued returns None
  • leave run_ops alone; it is what the tests call

Hidden tests run at submit. Your prompts, runs and edits are the trace the critique reads.