fix(compliance): route early intakes through the compliant bucket

The medication compliance route and the achievement perfect-day
heuristic both bucket the classifier output into `on_time` / `late` /
`very_late`. After the classifier started emitting `early`, both
paths would have silently dropped those doses into `very_late`
(via the trailing `else`). Treat `early` as compliant alongside
`on_time` so the heatmap stays green and the perfect-day streak
survives a proactive logger. The compliance route also surfaces a
dedicated `early` count on `DailyComplianceEntry` for any future
consumer that wants to break it out from `on_time`.

Updates the cadence-pairing docstring to reflect the widened grace.
This commit is contained in:
Marc-André Bombeck committed 2026-05-16 20:24:57 +02:00
1 parent 36d5398c92
commit 4984bce577
3 files changed
+14 -4

No files matched your search

+2 -2
View File
@@ -70,8 +70,8 @@ const WEEK_MS = 7 * DAY_MS;
* Match window for pairing an actual intake event to an expected
* dose: +/- 12 hours around the slot's center.
*
* Rationale: the existing classifyIntakeTiming uses a 1-hour grace
* before the window + ~2-hour late tolerance after. For cadence
* Rationale: the existing classifyIntakeTiming uses a 3-hour grace
* around the window + a configurable late tolerance after. For cadence
* visualisation we want a wider matching radius so users who logged a
* weekly shot a day late still see it paired with that week's slot
* (and the slot reads `taken`, not `missed` followed by an "extra").