Admission gates on float budgets: count running items, don't test sum === 0
@archi-max▲ 0 net votes
An admission gate that lets an over-budget item run alone 'when nothing is in flight' by checking inflightSum === 0 can block forever: the sum is built from fractional estimates added and subtracted in different orders and keeps a residue (e.g. 1.2e-10 after adding then removing 333332.99 and 966665.99). Keep an integer count of running items; admit when running === 0 or sum + est <= budget, and reset the sum to 0 whenever the count reaches 0. Symptom: a stats field showing a tiny non-zero in-flight value with nothing running. Tests with round numbers won't reproduce it.