mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-21 19:22:18 +01:00
The phone is getting its own Kuchnia Wikinga importer so the feature works with the PC switched off. That turns a risk `_kuchnia_spread.py` called "theoretical" into a live one: two implementations must now agree exactly on which dishes are dropped, which slot each lands on, and the JSON a banked record encodes to. Disagreement means each device re-adds what the other dropped, and since `add_manual_entry` restamps `t` unconditionally, the whole curated bank republishes to every peer on every refresh. A slot mismatch is worse -- a checkpoint one device offers and the other does not can never be satisfied. So the port lands with its gate rather than after it. One shared fixture, `tests/fixtures/kuchnia_day.json`, is asserted by both `pytest` and `flutter test`: same input, same expected dishes, drops, slots, bank keys and records. Two suites written independently from the same prose is not a gate. The fixture is five real dishes (a scrubbed 2026-08-22 capture) plus synthetic meals that each pin one drop or fallback path -- a per-100 g mix-up, an absurd portion, a stringly-typed number, a non-dict entry, a missing `nutrition`, a missing `mealPriority`, and a twin-dish pair. Without those, "the same meals are dropped" is a vacuous assertion against an all-happy-path capture. Both halves were mutation-checked: flipping an expected slot, drop count or record value fails each suite, and flipping `435.0` to `435` fails the byte-identity test while the value comparison still passes, which is why both exist. Three traps the port had to survive, each caught before it shipped: - `_ENERGY_TOLERANCE` is **0.35**. The prose said "~1%", which describes how closely the captured day agreed, not the threshold; porting 0.01 would drop dishes the PC keeps. That paragraph now says so. - `jsonEncode(435)` emits `435` where Python emits `435.0`, so every Dart macro is forced to `double` and a canonical-encoding test pins it. - Dart's `List.sort` is unstable where Python's `sorted` is stable, so the Dart comparator carries the payload index as a final tiebreak. The real dishes live in their own file rather than as a literal in the generator: transcribing them by hand corrupted three of the five, and the error was invisible until the generated fixture was diffed against the capture. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QQpCiPaSbyRpwsLkH3dgsX
378 lines
9.5 KiB
JSON
378 lines
9.5 KiB
JSON
{
|
|
"_comment": "Shared parity fixture for the Kuchnia Wikinga catering import. Read by BOTH diet_guard/tests/test_kuchnia_parity.py and app/test/kuchnia_parity_test.dart -- same input, same expected result. Regenerate with scripts/build_kuchnia_fixture.py.",
|
|
"expected": {
|
|
"bank_keys": [
|
|
"marchewkowe pancakes, twarożek cynamonowy, sos truskawkowy",
|
|
"hummus paprykowy, mini wafle kukurydziane, warzywa",
|
|
"makaron farfalle z indykiem w sosie z batatów z suszonymi pomidorami, ser włoski",
|
|
"fit ciasto, jak twix white",
|
|
"kaszotto grzybowe z pieczonym kurczakiem i serem włoskim",
|
|
"no priority, kept",
|
|
"twin dish",
|
|
"twin dish"
|
|
],
|
|
"bank_records": [
|
|
{
|
|
"carbs_g": 54.64,
|
|
"count": 0,
|
|
"desc": "Marchewkowe pancakes, twarożek cynamonowy, sos truskawkowy",
|
|
"fat_g": 12.01,
|
|
"grams": 270.0,
|
|
"kcal": 435.0,
|
|
"protein_g": 25.86
|
|
},
|
|
{
|
|
"carbs_g": 41.67,
|
|
"count": 0,
|
|
"desc": "Hummus paprykowy, mini wafle kukurydziane, warzywa",
|
|
"fat_g": 17.26,
|
|
"grams": 205.0,
|
|
"kcal": 367.0,
|
|
"protein_g": 10.86
|
|
},
|
|
{
|
|
"carbs_g": 53.23,
|
|
"count": 0,
|
|
"desc": "Makaron farfalle z indykiem w sosie z batatów z suszonymi pomidorami, ser włoski",
|
|
"fat_g": 23.21,
|
|
"grams": 465.0,
|
|
"kcal": 594.0,
|
|
"protein_g": 42.47
|
|
},
|
|
{
|
|
"carbs_g": 25.18,
|
|
"count": 0,
|
|
"desc": "Fit ciasto, jak twix white",
|
|
"fat_g": 17.36,
|
|
"grams": 90.0,
|
|
"kcal": 268.0,
|
|
"protein_g": 5.85
|
|
},
|
|
{
|
|
"carbs_g": 35.56,
|
|
"count": 0,
|
|
"desc": "Kaszotto grzybowe z pieczonym kurczakiem i serem włoskim",
|
|
"fat_g": 13.02,
|
|
"grams": 318.0,
|
|
"kcal": 391.0,
|
|
"protein_g": 32.51
|
|
},
|
|
{
|
|
"carbs_g": 40.0,
|
|
"count": 0,
|
|
"desc": "No priority, kept",
|
|
"fat_g": 8.0,
|
|
"grams": 120.0,
|
|
"kcal": 300.0,
|
|
"protein_g": 10.0
|
|
},
|
|
{
|
|
"carbs_g": 45.0,
|
|
"count": 0,
|
|
"desc": "Twin dish",
|
|
"fat_g": 12.0,
|
|
"grams": 300.0,
|
|
"kcal": 400.0,
|
|
"protein_g": 25.0
|
|
},
|
|
{
|
|
"carbs_g": 45.0,
|
|
"count": 0,
|
|
"desc": "Twin dish",
|
|
"fat_g": 12.0,
|
|
"grams": 300.0,
|
|
"kcal": 400.0,
|
|
"protein_g": 25.0
|
|
}
|
|
],
|
|
"dishes": [
|
|
{
|
|
"carbs_g": 54.64,
|
|
"fat_g": 12.01,
|
|
"grams": 270.0,
|
|
"kcal": 435.0,
|
|
"name": "Marchewkowe pancakes, twarożek cynamonowy, sos truskawkowy",
|
|
"priority": 1,
|
|
"protein_g": 25.86,
|
|
"slot_label": "Śniadanie"
|
|
},
|
|
{
|
|
"carbs_g": 41.67,
|
|
"fat_g": 17.26,
|
|
"grams": 205.0,
|
|
"kcal": 367.0,
|
|
"name": "Hummus paprykowy, mini wafle kukurydziane, warzywa",
|
|
"priority": 2,
|
|
"protein_g": 10.86,
|
|
"slot_label": "II śniadanie"
|
|
},
|
|
{
|
|
"carbs_g": 53.23,
|
|
"fat_g": 23.21,
|
|
"grams": 465.0,
|
|
"kcal": 594.0,
|
|
"name": "Makaron farfalle z indykiem w sosie z batatów z suszonymi pomidorami, ser włoski",
|
|
"priority": 3,
|
|
"protein_g": 42.47,
|
|
"slot_label": "Obiad"
|
|
},
|
|
{
|
|
"carbs_g": 25.18,
|
|
"fat_g": 17.36,
|
|
"grams": 90.0,
|
|
"kcal": 268.0,
|
|
"name": "Fit ciasto, jak twix white",
|
|
"priority": 4,
|
|
"protein_g": 5.85,
|
|
"slot_label": "Podwieczorek"
|
|
},
|
|
{
|
|
"carbs_g": 35.56,
|
|
"fat_g": 13.02,
|
|
"grams": 318.0,
|
|
"kcal": 391.0,
|
|
"name": "Kaszotto grzybowe z pieczonym kurczakiem i serem włoskim",
|
|
"priority": 5,
|
|
"protein_g": 32.51,
|
|
"slot_label": "Kolacja"
|
|
},
|
|
{
|
|
"carbs_g": 40.0,
|
|
"fat_g": 8.0,
|
|
"grams": 120.0,
|
|
"kcal": 300.0,
|
|
"name": "No priority, kept",
|
|
"priority": 8,
|
|
"protein_g": 10.0,
|
|
"slot_label": "Przekąska"
|
|
},
|
|
{
|
|
"carbs_g": 45.0,
|
|
"fat_g": 12.0,
|
|
"grams": 300.0,
|
|
"kcal": 400.0,
|
|
"name": "Twin dish",
|
|
"priority": 5,
|
|
"protein_g": 25.0,
|
|
"slot_label": "Obiad"
|
|
},
|
|
{
|
|
"carbs_g": 45.0,
|
|
"fat_g": 12.0,
|
|
"grams": 300.0,
|
|
"kcal": 400.0,
|
|
"name": "Twin dish",
|
|
"priority": 5,
|
|
"protein_g": 25.0,
|
|
"slot_label": "Obiad"
|
|
}
|
|
],
|
|
"dropped_count": 5,
|
|
"slot_order": [
|
|
"Marchewkowe pancakes, twarożek cynamonowy, sos truskawkowy",
|
|
"Hummus paprykowy, mini wafle kukurydziane, warzywa",
|
|
"Makaron farfalle z indykiem w sosie z batatów z suszonymi pomidorami, ser włoski",
|
|
"Fit ciasto, jak twix white",
|
|
"Kaszotto grzybowe z pieczonym kurczakiem i serem włoskim",
|
|
"Twin dish",
|
|
"Twin dish",
|
|
"No priority, kept"
|
|
],
|
|
"slots": {
|
|
"8,12,16,20": [
|
|
8,
|
|
8,
|
|
12,
|
|
12,
|
|
16,
|
|
16,
|
|
20,
|
|
20
|
|
],
|
|
"8,12,16,20,22": [
|
|
8,
|
|
8,
|
|
12,
|
|
12,
|
|
16,
|
|
20,
|
|
20,
|
|
22
|
|
],
|
|
"first_three_8,12,16,20": [
|
|
8,
|
|
12,
|
|
16
|
|
]
|
|
}
|
|
},
|
|
"payload": {
|
|
"deliveryMenuMeal": [
|
|
{
|
|
"deliveryMealId": 1001,
|
|
"mealName": "Śniadanie",
|
|
"mealPriority": 1,
|
|
"menuMealName": "Marchewkowe pancakes, twarożek cynamonowy, sos truskawkowy",
|
|
"nutrition": {
|
|
"calories": 435.0,
|
|
"carbohydrate": 54.64,
|
|
"dietaryFiber": 2.03,
|
|
"fat": 12.01,
|
|
"protein": 25.86,
|
|
"salt": 0.52,
|
|
"saturatedFattyAcids": 1.92,
|
|
"sugar": 22.4,
|
|
"weight": 270.0
|
|
}
|
|
},
|
|
{
|
|
"deliveryMealId": 1002,
|
|
"mealName": "II śniadanie",
|
|
"mealPriority": 2,
|
|
"menuMealName": "Hummus paprykowy, mini wafle kukurydziane, warzywa",
|
|
"nutrition": {
|
|
"calories": 367.0,
|
|
"carbohydrate": 41.67,
|
|
"dietaryFiber": 9.18,
|
|
"fat": 17.26,
|
|
"protein": 10.86,
|
|
"salt": 1.27,
|
|
"saturatedFattyAcids": 1.59,
|
|
"sugar": 3.77,
|
|
"weight": 205.0
|
|
}
|
|
},
|
|
{
|
|
"deliveryMealId": 1003,
|
|
"mealName": "Obiad",
|
|
"mealPriority": 3,
|
|
"menuMealName": "Makaron farfalle z indykiem w sosie z batatów z suszonymi pomidorami, ser włoski",
|
|
"nutrition": {
|
|
"calories": 594.0,
|
|
"carbohydrate": 53.23,
|
|
"dietaryFiber": 3.83,
|
|
"fat": 23.21,
|
|
"protein": 42.47,
|
|
"salt": 1.08,
|
|
"saturatedFattyAcids": 7.03,
|
|
"sugar": 4.88,
|
|
"weight": 465.0
|
|
}
|
|
},
|
|
{
|
|
"deliveryMealId": 1004,
|
|
"mealName": "Podwieczorek",
|
|
"mealPriority": 4,
|
|
"menuMealName": "Fit ciasto, jak twix white",
|
|
"nutrition": {
|
|
"calories": 268.0,
|
|
"carbohydrate": 25.18,
|
|
"dietaryFiber": 0.36,
|
|
"fat": 17.36,
|
|
"protein": 5.85,
|
|
"salt": 0.15,
|
|
"saturatedFattyAcids": 10.76,
|
|
"sugar": 8.3,
|
|
"weight": 90.0
|
|
}
|
|
},
|
|
{
|
|
"deliveryMealId": 1005,
|
|
"mealName": "Kolacja",
|
|
"mealPriority": 5,
|
|
"menuMealName": "Kaszotto grzybowe z pieczonym kurczakiem i serem włoskim",
|
|
"nutrition": {
|
|
"calories": 391.0,
|
|
"carbohydrate": 35.56,
|
|
"dietaryFiber": 3.69,
|
|
"fat": 13.02,
|
|
"protein": 32.51,
|
|
"salt": 1.3,
|
|
"saturatedFattyAcids": 6.53,
|
|
"sugar": 1.99,
|
|
"weight": 318.0
|
|
}
|
|
},
|
|
{
|
|
"mealName": "Obiad",
|
|
"mealPriority": 6,
|
|
"menuMealName": "Per-100g mix-up, dropped",
|
|
"nutrition": {
|
|
"calories": 900.0,
|
|
"carbohydrate": 6.0,
|
|
"fat": 2.0,
|
|
"protein": 5.0,
|
|
"weight": 400.0
|
|
}
|
|
},
|
|
{
|
|
"mealName": "Kolacja",
|
|
"mealPriority": 7,
|
|
"menuMealName": "Absurd portion, dropped",
|
|
"nutrition": {
|
|
"calories": 500.0,
|
|
"carbohydrate": 60.0,
|
|
"fat": 15.0,
|
|
"protein": 30.0,
|
|
"weight": 9000.0
|
|
}
|
|
},
|
|
{
|
|
"mealName": "Przekąska",
|
|
"menuMealName": "No priority, kept",
|
|
"nutrition": {
|
|
"calories": 300.0,
|
|
"carbohydrate": 40.0,
|
|
"fat": 8.0,
|
|
"protein": 10.0,
|
|
"weight": 120.0
|
|
}
|
|
},
|
|
{
|
|
"mealName": "Obiad",
|
|
"mealPriority": 8,
|
|
"menuMealName": "Stringly typed, dropped",
|
|
"nutrition": {
|
|
"calories": "435",
|
|
"carbohydrate": 50.0,
|
|
"fat": 12.0,
|
|
"protein": 25.0,
|
|
"weight": 200.0
|
|
}
|
|
},
|
|
"not-a-meal",
|
|
{
|
|
"mealName": "Obiad",
|
|
"mealPriority": 9,
|
|
"menuMealName": "No nutrition, dropped"
|
|
},
|
|
{
|
|
"mealName": "Obiad",
|
|
"mealPriority": 5,
|
|
"menuMealName": "Twin dish",
|
|
"nutrition": {
|
|
"calories": 400.0,
|
|
"carbohydrate": 45.0,
|
|
"fat": 12.0,
|
|
"protein": 25.0,
|
|
"weight": 300.0
|
|
}
|
|
},
|
|
{
|
|
"mealName": "Obiad",
|
|
"mealPriority": 5,
|
|
"menuMealName": "Twin dish",
|
|
"nutrition": {
|
|
"calories": 400.0,
|
|
"carbohydrate": 45.0,
|
|
"fat": 12.0,
|
|
"protein": 25.0,
|
|
"weight": 300.0
|
|
}
|
|
}
|
|
],
|
|
"menuVisible": true,
|
|
"showNutrition": true
|
|
}
|
|
}
|