Research note · November 2026
Three ways one billing engine read a number twice
Each of these came from the same shape: one function reads one logical value through two different accessors, and the two readings disagree. The disagreement only matters when the readings reach different branches or different outputs, which is why these survive review. Nothing in the code looks wrong in isolation.
One: the zero-usage tier was read from an unsorted price
GraduatedTiered.TieredPriceCalculator walks the tiers in sorted order, but selects its zero-usage fallback from the unsorted input. Two reads of the same price, one sorted and one not.
That is harmless until the stored order is not ascending, and TieredPrice.Validate() accepts reversed tiers. So a mandatory first-bucket flat fee can be skipped entirely when usage is zero. The customer is billed nothing where a flat fee was owed.
The test used identical tiers in ascending and reverse storage order. Both prices validate. Before the fix, the ascending case returned 100 and the reversed case returned 0. The fix reads both paths from one sorted view.
PR #5347, merged 26 October 2026.
Two: a gross amount was treated as net
SplitLineHierarchy.SumNetAmount promises a net figure. It sums the persisted prior-line Amount, which is gross, and never subtracts DiscountsTotal. The persisted invoice line carries that field; the history model simply did not.
A prior line with 100 in gross amount and 40 in discounts therefore contributes 100 where the function's own name promises 60. The caller uses that figure to evaluate commitments, so the overstatement lands in a commitment decision rather than on a visible line.
This is the same shape as the first, in a different disguise: one quantity available two ways, gross and net, read through the accessor that does not match the contract. The fix carries DiscountsTotal into the history model and subtracts it.
PR #5367, merged 27 October 2026.
Three: a package count rounded past its own boundary
This one is not really about OpenMeter. Package.GetNumberOfPackages read one quantity through two accessors that disagree:
requiredPackages := qty.Div(packageSize).Floor()
if qty.Mod(packageSize).IsZero() {
return requiredPackages
}
return requiredPackages.Add(DecimalOne)
Div is not exact. Its fast path checks whether the division came out exact and otherwise falls through to DivRound at DivisionPrecision, which is 16, and rounds. Mod has no fast path and is always exact.
So when the true quotient sits just below a whole number, Div rounds up to it, Floor keeps it, and Mod still reports a remainder. The function then adds a package that is not owed. The customer pays for one unit more than they used.
The quantity that triggers it does not arrive from a single reading. MeterQueryRow.Value is a float64 and both snapshots accumulate sum.Add(alpacadecimal.NewFromFloat(row.Value)). Two ordinary values, 9.9 and 0.09999999999999999, sum to 9.99999999999999999.
A reviewer who tries a single usage value will not see this. We ran 520,000 single-float64 quantities across 13 package sizes and found no disagreement between the shipped count and an exact ceiling. The defect needs an accumulated sum, which is what production metering produces and what a unit test usually does not.
PR #5372, merged 27 October 2026.
Why the third one is the one to check in your own code
The first two were specific to OpenMeter. The third is a property of shopspring/decimal itself: Div is DivRound at a fixed precision and rounds half away from zero, while Mod goes through QuoRem and is exact. They do not share a quotient.
Any Go project that pairs those two calls on the same operands inherits the disagreement. alpacadecimal aliases the same precision constant and inherits it too. govalues/decimal does not have this particular problem, though it rounds silently in Parse instead.
That makes it a cheap thing to look for. Search your own money code for a Div and a Mod on the same two values inside one function, and check whether the results reach different branches.
What a maintainer did with them
All three were merged by the same maintainer within 28 hours of filing, each with a follow-up commit of his own. #5372 also added a nine-line normative rule to OpenMeter's AGENTS.md about using division and rounding before a boundary decision, which now constrains everyone who writes in that engine next.
We also filed one that was declined, on a service-period asymmetry, because a maintainer could state a competing semantic for it in one sentence. That is the test we now apply before filing: if the intended behaviour is a judgement call rather than a contradiction, it is a question, not a patch.
What this is and is not
These are defects found by reading source and reproducing against it. No customer data, no production access, no deployment. Nobody is running Nobulex in a billing path, and nothing here is a customer result.
Two Kill Bill pull requests from the same method, #2320 and #2321, remain open and unreviewed. Three defect reports at Medusa, #17268, #17513 and #17529, were closed as completed. One further OpenMeter issue, #5521, is open and has had no maintainer response.
If you own billing code and want the same reading done against it, that is the proposed study, which nobody has bought yet. If you would rather just check the Div/Mod pairing yourself, the description above is everything you need and costs nothing.
Back to Nobulex →
