mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
Pure, DB-free cycle prediction and phase-assignment engine under src/lib/cycle/. The math mirrors the offline-parity spec exactly so the server and the native client compute byte-identical forecasts from the same canonical inputs. - day-math: noon-UTC anchored YYYY-MM-DD arithmetic (dayDiff, addDays, round-half-up) that stays stable across timezones and DST transitions. - prediction: robust median+MAD cycle-length estimator over a trailing 12-cycle window with 3-MAD outlier exclusion and missed-log detection; period-length estimator; one-sigma Low/High date band widened by logging sparsity; luteal back-calculated ovulation + six-day fertile window; the CALENDAR -> symptothermal -> temperature-trend method ladder (sensiplan 3-over-6 + mucus-peak re-implemented from the published method) with documented blend precedence; a multiplicative confidence scalar shrinking with length variance, low cycle count, and sparse logging. - phase: day-of-cycle -> MENSTRUAL/FOLLICULAR/OVULATORY/LUTEAL boundary mapping with menstrual precedence on overlap. - 48 unit tests covering the regular, irregular, cold-start, outlier, symptothermal, temperature-trend, and every phase-boundary case; all assertions are timezone-independent and pin exact dates + confidence. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>