There are two things at play there - gauge calibration and its configuration.
The kernel is supposed to automatically configure the gauge with correct values for a given hardware revision if it’s uninitialized, but there are cases where you may end up with incorrect ones being used (for example, if you use boot current versions of Jumpdrive as the first thing after taking the battery out and don’t take it out ever again).
To easily check whether your gauge configuration is right:
purism@evergreen:~$ cat /sys/class/power_supply/max170xx_battery/charge_full_design
4199160
purism@dogwood:~$ cat /sys/class/power_supply/max170xx_battery/charge_full_design
3400000
purism@birch:~$ cat /sys/class/power_supply/max170xx_battery/charge_full_design
2000000
(Chestnut value is the same as Birch)
So that’s the first thing to check. The other thing is that the gauge uses plenty of heuristics in order to calibrate itself and make its readings more accurate. Sometimes this calibration may end up being off, which can be further amplified by certain usage patterns.
In any case, the simplest way to reset both gauge configuration and calibration is to turn the phone off and take the battery out for a moment. Put it back in and you’ll end up with a reconfigured gauge with no calibration, so then give it a chance to learn about your battery for a full charge cycle or two - and then avoid taking your battery out to not reset calibration data again.
If sudden race-to-0 occurs often despite of letting the gauge calibrate for a while, it may be a sign of an aging battery.