- Merge leftovers into existing meal_box when same recipeId + cookedAt date + frozen + available.
- Store mealBoxMutations JSONB on cooking_sessions for deterministic undo.
- Undo decrements portions/remaining, discards box at zero, appends correction ledger rows.
- Mobile: undo button in cooking/[id].tsx after-flow and meal-boxes.tsx within 24h window.
- i18n undo strings across all 12 locales; parity test green.
- 6 new integration tests: merge, no cross-date merge, frozen split, undo restore, undo discard, ledger invariant.
- Update FAS3 audit doc with 3d semantics.
Closes Fas 3d
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