Expressions are pure
JSONLogic trees, exact decimals and the injected clock.
Conditions, calculations and cell comparisons are JSONLogic trees evaluated by
json-logic-engine, with a small vocabulary registered on top. Nothing in an expression can
perform I/O or read the clock: the execution time is injected as $now, so a replay produces
the same answer. Anything that needs the outside world is a node, not an expression.
Arithmetic is exact
Arithmetic uses decimal.js: 0.1 + 0.2 is exactly 0.3 before a threshold compares it, so
money limits do not drift. Comparisons are numerically exact when both sides are numbers and fall
back to normal ordering otherwise.
The vocabulary
| Group | Functions |
|---|---|
| Arithmetic | dec_add, dec_sub, dec_mul, dec_div, … |
| Comparison | dec_gt, dec_gte, dec_lt, dec_lte, dec_eq, between |
| Text | matches, … |
| Lists | in, list helpers |
| Missing values | coalesce |
| Dates | days_between, … |
Comparisons across two numbers use the dec_* functions, so they are exact.
Authors type formulas (totalMonthlyDebt / monthlyIncome) in the UI; the expression is stored as
the tree, and the tree can always be rendered back to text.