All problems

Equal-Priority Relay Jobs Lose Their Arrival Order

Level 2 · node · API · Incorrect tie handling in priority-ordered job lists

Scenario

A fictional remote equipment relay displays queued jobs for each zone in descending priority. Jobs with equal priority must remain in arrival order. The current ordering changes the order of tied jobs, making the operator display unpredictable. Inspect the repository, service, and controller flow.

Requirements

Sort by descending priority while retaining arrival order among tied jobs. Preserve zone isolation, invalid input rejection, returned-data isolation, and empty-list behavior.

Acceptance criteria

  • Higher-priority jobs appear before lower-priority jobs.
  • Jobs with equal priority retain their original arrival order.
  • Job lists for different zones remain independent.
  • Invalid registrations are rejected without changing existing jobs.
  • Mutating returned items does not alter stored jobs.
  • A zone with no jobs returns an empty list.