I run a small site of home-improvement cost calculators (costto.build) — pick a project, get a low / average / high estimate with a materials-and-labor breakdown. Boring on the surface. The interesting part is that every page has the same number in four different places, and for a while, those four places didn't agree.

This is a post about that bug, why it was inevitable, and the one rule that made it impossible to repeat.

Four sources of truth for one number

A single calculator page — say, the room-addition one — shows a cost in four spots:

The interactive widget, driven by a calculate() function (low/avg/high).