Skip to content

fix: keep expired food out of cooking decisions on iOS and PWA - #41

Open
1395490241lhj-code wants to merge 2 commits into
mainfrom
claude/km-expired-food-pool
Open

1395490241lhj-code wants to merge 2 commits into
mainfrom
claude/km-expired-food-pool

Conversation

@1395490241lhj-code

Copy link
Copy Markdown
Owner

Expired inventory (remainingDays < 0) was ranked as the most urgent "use first" food by every recipe recommendation, planning and AI path on iOS and the PWA. A spinach row five days past its date pushed recipes built on it to the top of Home, was pre-ticked in AI 做菜, was sent to AI as 临期食材, and on the PWA earned the largest expiring bonus with the reason "已过期,优先用".

After this change an expired row still appears in expiry alerts, but it is never a cooking candidate, a use-first priority, an "already have it" match or AI inventory. Rows due today or within three days keep their priority. This was the top item of the 2026-11-01 read-only AI logic audit.

What changed

iOS

  • InventoryItem.isExpired. recipeCreationInventory and recipeCreationExpiringItems exclude it, which covers Home local ranking, Home and Apple AI requests, AI 做菜, Special Plan and the weekly menu. expiringItems (alerts) is unchanged.
  • AI 做菜 preselection and 全选临期食材 take today and 1–3 day rows only.
  • QuickMealCandidate.pool drops expired inventory, covering Quick Meal and Component Meal. Prepared batches keep their own rule, because their date is the member's finish-by plan.
  • The Kitchen AI inventory context moves expired rows out of available and expiring into a new expired array. The context is not persisted.

PWA

  • inventory.js now owns isExpiryTracked, isExpiredItem, isUseSoonItem and getCookableInventory. Dry goods, 鸡蛋 and 牛奶 are never judged by days, as before.
  • Recipe coverage, the expiring bonus and reasons, clean-fridge, recipe variants and generic templates, the weekly AI payload and its local candidates, and AI inventory names all use the cookable inventory.

Tests

  • New iOS tests in InventoryItemKindTests, ConversationDomainToolsTests and QuickMealCandidateTests, each watched failing before the fix.
  • ConversationContextAssemblerTests: two fixtures used expired rows as the "most urgent" example. They now use today and soon rows with the same ordering and truncation assertions, and one asserts the new expired array.
  • New test/expired-food-priority.test.mjs (11 tests).

Validation

  • Full KitchenManagerTests on the final tree, xcodebuild fallback on an iOS simulator: 2856 run, 0 failed, 5 skipped.
  • node --test: 1678 run, 1665 passed, 13 failed. The same 12 files fail on the base tree in the same local environment because express and openai are not installed there; no new failure.
  • PWA Home smoke-checked in a browser with seeded expired inventory.
  • An independent three-lens review with two refuters per finding found the Quick Meal and PWA coverage gaps; both are fixed here.
  • Not run: UI tests, a physical device, real AI calls.

Known limits

  • The PWA 临期 modal still offers 用它做菜 on a row labelled 已过期.
  • The iOS AI 做菜 picker hides expired rows and shows its empty state when only expired food remains.
  • The uncommitted codex/km-prepared-workflow tree edits the same iOS files, so integrating that work will need a merge.

🤖 Generated with Claude Code

1395490241lhj-code and others added 2 commits November 2, 2026 10:38
Expired inventory (remainingDays < 0) was treated as the most urgent
"use first" food by every ranking and AI path: Home local ranking and
AI prompts, the AI recipe form preselection, Special Plan, weekly menu,
Quick Meal / Component Meal, the Kitchen AI inventory context, and on
the PWA the expiring bonus, clean-fridge, recipe coverage, variants and
AI inventory names.

Expired rows still show in expiry alerts, but are no longer a cooking
candidate, a use-first priority, an "already have it" match or AI
inventory. Rows due today or within three days keep their priority.

iOS: InventoryItem.isExpired; recipe-creation pools, AI recipe form
preselection and the Quick Meal pool exclude it; the conversation
context reports expired rows in a separate `expired` array. Prepared
batches keep their own finish-by rule.

PWA: inventory.js owns isExpiryTracked / isExpiredItem / isUseSoonItem /
getCookableInventory (dry goods, eggs and milk are never judged by
days), used by recipe coverage, clean-fridge, variants, the weekly AI
payload and AI inventory names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Pages workflow's `npm audit --omit=dev --audit-level=high` gate
started failing after GHSA-mrwp-f3q8-3g9p (high) was published against
follow-redirects 1.16.0-1.16.1. The fix is inside axios's existing
^1.16.0 range, so only package-lock.json changes:

  follow-redirects 1.16.1 -> 1.16.2

main carries the same lockfile, so it would fail this gate too.
Verified locally with the workflow's own steps: npm ci, npm test
(2026 pass, 0 fail), validate:recipe-packs, validate:recipe-pack-data
and the audit gate all exit 0. package.json is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant