delta-absent-not-infinite
Installation
SKILL.md
A change with no baseline is absent, not infinite
A screen that prints "514" tells the reader nothing they can act on; "514, a quarter more than last period" does. The whole value is in the comparison — which is exactly why the comparison must refuse to exist when it would be meaningless, rather than manufacture a number.
/** A change against the same span one period earlier, or null when there is nothing to compare to. */
fun percentDelta(now: Long, before: Long?): Int? {
if (before == null || before <= 0L) return null
return (((now - before) * 100.0) / before).toInt()
}
Two guards live at different levels and both are needed. At the state level the whole previous snapshot is dropped when it holds no events at all, so no figure on the screen gets a delta: