Invental/Review lessons/Code that silently does the wrong thing

Code that silently does the wrong thing

Sorting each batch is not a global order

Sorting inside each batch is not the same as ordering globally: if a priority has to win over a dependency graph, pick the next batch by priority first, then sort.

01 · Before and afterThe pattern

TypeScript
// before: every ready node installs this round; priority only reorders inside the round
let round = ready(worklist);
round.sort(byPriorityDesc);

// after: only the highest-priority ready nodes go this round; others wait
const top = Math.max(...round.map(n => n.priority));
round = round.filter(n => n.priority === top).sort(byId);

02 · Run it on your appThe check

For any “force this order” setting in your system, have you tested it with a dependency that pulls something forward?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.