diet-guard/app/lib/models
Krzysztof kuhy Rudnicki 83c3030b55 Derive meal slots from an eating window and a meal count
First step of the configurable meal schedule: the pure arithmetic, in both
languages, with nothing wired to it yet. MealSchedule(8, 20, 5) gives
08, 11, 14, 17, 20; the default MealSchedule(8, 20, 4) reproduces the hours
that are currently hardcoded, so nothing changes behaviour until a user picks
something else.

Two properties are load-bearing and both are tested rather than asserted in
prose:

Integer arithmetic only, no floats and no round(). Python's round() is
banker's (round(2.5) == 2) and Dart's is half-away-from-zero
(2.5.round() == 3), so a floating-point derivation would silently disagree
across devices -- and a slot one device offers but the other does not is a
checkpoint that can never be satisfied, i.e. a permanent lock. The shared
vector table plus an identical 6912-case sweep in both suites is what catches
that class of bug before it reaches a device.

Counts are clamped to the window width rather than rejected. A narrow window
(08-12 across 6 meals) would otherwise repeat an hour -- 8, 9, 10, 10, 11, 12
-- and slot hours are used as set members, map keys and notification ids, so a
repeat silently drops a checkpoint. Clamping also means the two languages
cannot disagree about which inputs are errors.

The enforcement cutoff is now derived as last + 2h (clamped to midnight)
rather than sharing the constant that also bounded the slot range. The clamp
matters: 23:00 + 2 = 25 would make `hour < cutoff` vacuously true and the
window would never close.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159b4E5hh512jYUeaJVNxfM
2026-08-16 14:21:12 +02:00
..
day_status.dart Add budget-adherence calendar, streaks, and freely-editable synced budget 2026-07-13 21:31:45 +02:00
food_bank_record.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00
food_entry.dart Remove the Snack chip from the phone's slot selector 2026-08-14 22:31:09 +02:00
food_suggestion.dart Add Flutter companion app skeleton with local meal logging 2026-06-22 18:22:42 +02:00
local_time.dart Add Flutter companion app skeleton with local meal logging 2026-06-22 18:22:42 +02:00
meal_component.dart Add Flutter companion app skeleton with local meal logging 2026-06-22 18:22:42 +02:00
meal_schedule.dart Derive meal slots from an eating window and a meal count 2026-08-16 14:21:12 +02:00
nutrition.dart Add Flutter companion app skeleton with local meal logging 2026-06-22 18:22:42 +02:00
period_average.dart Show weekly and monthly average intake on both devices 2026-08-09 14:59:40 +02:00
slot.dart Remove unused features; fix reminder false alarms; share all state 2026-07-26 16:39:52 +02:00