fix(kitchen): cap a duration at 1000 years and warn (audit C3) #72

Merged
abiwab merged 4 commits from fix/audit-c3 into main 2026-09-30 20:52:13 +02:00
Owner

Audit C3, present since 1.3.0. A retro-planning offset or a timer of absurd length broke the timeline silently. Measured: exact up to ~1e9 days; at 1e15 days the preparation and the step become 0 minutes (precision lost); ~_{1e400h} gives a total of Infinity; ~{-1e308d} and beyond give NaN. Non-finite numbers are null in the compiled JSON, so the times were unreadable, with no warning.

Decision (maintainer, after a discussion on the value): cap at 1000 years and warn. The limit is a technical bound, not a judgement on recipes: a 100-year duration is left exactly as written, and so is the limit itself (365000 d); 1000 years is ~5.3e8 minutes, far from where precision is lost.

  • quantityToMinutes, the single conversion point (the CLI uses it too), caps its result; MAX_DURATION_MINUTES, isDurationTooLong and maxDurationIn are exported
  • new warning DURATION_OUT_OF_RANGE (severity warning) for a timer or a section's retro-planning offset past the limit; the quantity kept in the JSON is written back capped, in the unit written, so it agrees with the schedule (the retro-planning raw text is kept as written)
  • every extreme case now gives the same finite, capped timeline (checked from 365001 d to a 400-digit number and Infinity), with no null in the schedules or metrics

Not caught, on purpose: a stray digit under the limit (-300d -> -3000d, 8 years). No cap that leaves a solera alone can.

Docs EN/FR: a section in the warnings reference and a line in the time syntax page (the codes table is generated). 14 new tests, which cannot even import the new exports on the previous code. New minor changeset for kitchen (new warning code and exports). ci (1361 tests), conformance 98/98 and a full docs build pass.

Audit C3, present since 1.3.0. A retro-planning offset or a timer of absurd length broke the timeline silently. Measured: exact up to ~1e9 days; at 1e15 days the preparation and the step become 0 minutes (precision lost); `~_{1e400h}` gives a total of `Infinity`; `~{-1e308d}` and beyond give `NaN`. Non-finite numbers are `null` in the compiled JSON, so the times were unreadable, with no warning. Decision (maintainer, after a discussion on the value): cap at 1000 years and warn. The limit is a technical bound, not a judgement on recipes: a 100-year duration is left exactly as written, and so is the limit itself (365000 d); 1000 years is ~5.3e8 minutes, far from where precision is lost. - `quantityToMinutes`, the single conversion point (the CLI uses it too), caps its result; `MAX_DURATION_MINUTES`, `isDurationTooLong` and `maxDurationIn` are exported - new warning `DURATION_OUT_OF_RANGE` (severity warning) for a timer or a section's retro-planning offset past the limit; the quantity kept in the JSON is written back capped, in the unit written, so it agrees with the schedule (the retro-planning `raw` text is kept as written) - every extreme case now gives the same finite, capped timeline (checked from 365001 d to a 400-digit number and `Infinity`), with no `null` in the schedules or metrics Not caught, on purpose: a stray digit under the limit (`-300d` -> `-3000d`, 8 years). No cap that leaves a solera alone can. Docs EN/FR: a section in the warnings reference and a line in the time syntax page (the codes table is generated). 14 new tests, which cannot even import the new exports on the previous code. New minor changeset for kitchen (new warning code and exports). ci (1361 tests), conformance 98/98 and a full docs build pass.
abiwab scheduled this pull request to auto merge when all checks succeed 2026-09-30 20:50:20 +02:00
abiwab merged commit aebdab6891 into main 2026-09-30 20:52:13 +02:00
abiwab deleted branch fix/audit-c3 2026-09-30 20:52:13 +02:00
Sign in to join this conversation.
No description provided.