completeCookingSession now forwards actualPortionsEaten and
leftoverEstimatePortions (after applying wrapper defaults) into
completeCookingSessionCore, so API callers omitting leftovers get
correct 100% deduction when mealBoxPortions is provided instead of
core's fallback to 0. Added regression test with leftovers omitted.
- consumptionPortions = min(planned, actualPortionsEaten + leftoverEstimatePortions).
Meal boxes are a subset of leftovers; raw inventory is only retained for
portions that were never cooked.
- Added validation leftoverEstimatePortions >= mealBoxPortions with localized
400 error (cooked.leftoverLessThanBox) in server i18n + all 12 locales.
- Removed unused COOKING_SESSION_STATUSES / MEAL_BOX_STATUSES imports from
apps/api/src/lib/cooking.ts.
- Hardened test cleanup to delete mealBoxes/meals/recipeCooks/cookingSessions
by household before dropping storageLocations.
- New regression tests: meal-box double-counting, eaten+leftover split, and
leftover < box rejection.
- Updated FAS3-COOKING-SESSIONS-AUDIT.md with corrected physics semantics.
- cookRecipeInputSchema utökas med actualPortionsEaten, leftoverEstimatePortions, leftoverNote
- completeCookingSession-wrapper i apps/api/src/lib/cooking.ts hanterar summavalidering,
persistens av svar, profiluppdateringar och analytics (started+completed) för båda vägarna
- Legacy POST /v1/recipes/:id/cook använder wrappern med emitStartedEvent
- GET /v1/recipes/:id/cooking-assumptions väljer deterministiskt bland icke-valfria ingredienser
- i18n: nyckel cooked.portionsSumExceedsPlanned i samtliga 12 lokaler + server-i18n
- Nya tester för legacy /cook och cooking-assumptions med valfri första ingrediens
Refs: steg 3b-fix, granskningsrunda 2026-08-07