kiwi/app/db/migrations
pyr0ball 17e62c451f feat: visual label capture for unenriched barcodes (kiwi#79)
When a barcode scan finds no product in FDC/OFF, paid-tier users now see a
"Capture label" offer instead of a dead-end "add manually" prompt.

Backend:
- Migration 036: captured_products local cache table (keyed by barcode,
  UPSERT on conflict so re-capture refreshes rather than errors)
- store.get_captured_product / save_captured_product (with JSON decode for
  ingredient_names and allergens)
- app/services/label_capture.py: wraps cf-core VisionRouter (caption API);
  graceful fallback to zero-confidence mock when stub/error; JSON fence
  stripping; confidence clamped to [0,1]; KIWI_LABEL_CAPTURE_MOCK=1 for tests
- New schemas: LabelCaptureResponse, LabelConfirmRequest, LabelConfirmResponse
- POST /inventory/scan/label-capture — image to extraction (paid+ gate, 403)
- POST /inventory/scan/label-confirm — save confirmed product + optional
  inventory add
- Both scan endpoints now: check captured_products cache before FDC/OFF;
  set needs_visual_capture=True for gap products on paid tier; BarcodeScanResult
  gains needs_visual_capture field
- visual_label_capture feature gate added to tiers.py (paid)

Tests: 42 new tests (service, store/migration, API endpoints) — 367 total passing

Frontend:
- InventoryList.vue: capturePhase state machine (offer => uploading => reviewing)
- Offer card appears after scan gap (calm UX: no urgency, Discard always visible)
- Review form: pre-populated from extraction; amber label highlights for
  unread fields (confidence < 0.7); comma-separated ingredients/allergens
- api.ts: LabelCaptureResult + LabelConfirmRequest types; captureLabelPhoto()
  and confirmLabelCapture() API methods
2026-04-24 17:57:25 -07:00
..
001_initial_schema.sql chore: initial commit — kiwi Phase 2 complete 2026-03-30 22:20:48 -07:00
002_inventory_and_products.sql chore: initial commit — kiwi Phase 2 complete 2026-03-30 22:20:48 -07:00
003_receipt_data.sql chore: initial commit — kiwi Phase 2 complete 2026-03-30 22:20:48 -07:00
004_tagging_system.sql chore: initial commit — kiwi Phase 2 complete 2026-03-30 22:20:48 -07:00
005_receipt_staged_status.sql feat: migrations 005-011 — fix receipts column bug + recipe engine tables 2026-03-30 22:33:25 -07:00
006_element_profiles.sql feat: migrations 005-011 — fix receipts column bug + recipe engine tables 2026-03-30 22:33:25 -07:00
007_recipe_corpus.sql fix: data pipeline — R-vector parser, allrecipes dataset, unique recipe index 2026-03-31 21:36:13 -07:00
008_substitution_pairs.sql feat: migrations 005-011 — fix receipts column bug + recipe engine tables 2026-03-30 22:33:25 -07:00
009_staple_library.sql feat: migrations 005-011 — fix receipts column bug + recipe engine tables 2026-03-30 22:33:25 -07:00
010_recipe_feedback.sql feat: migrations 005-011 — fix receipts column bug + recipe engine tables 2026-03-30 22:33:25 -07:00
011_rate_limits.sql feat: migrations 005-011 — fix receipts column bug + recipe engine tables 2026-03-30 22:33:25 -07:00
012_user_settings.sql feat: recipe engine Phase 3 — StyleAdapter, LLM levels 3-4, user settings 2026-03-31 14:15:18 -07:00
013_background_tasks.sql fix: renumber background_tasks migration 006→013 (conflict with element_profiles) 2026-03-31 14:28:10 -07:00
014_nutrition_macros.sql feat: recipe engine — assembly templates, prep notes, FTS fixes, texture backfill 2026-04-02 22:12:35 -07:00
015_recipe_fts.sql fix: add FTS5 sync triggers so recipe inserts are indexed immediately 2026-04-02 23:14:22 -07:00
016_recipe_fts_triggers.sql fix: add FTS5 sync triggers so recipe inserts are indexed immediately 2026-04-02 23:14:22 -07:00
017_household_invites.sql feat: add household_invites migration (017) 2026-04-04 22:27:56 -07:00
018_saved_recipes.sql feat: saved recipes, recipe browser, and recipe detail panel 2026-04-08 14:35:02 -07:00
019_recipe_collections.sql feat: saved recipes, recipe browser, and recipe detail panel 2026-04-08 14:35:02 -07:00
020_browser_telemetry.sql feat: saved recipes, recipe browser, and recipe detail panel 2026-04-08 14:35:02 -07:00
021_recipe_browser_fts.sql perf(browser): replace LIKE scans with FTS5; cache category counts 2026-04-08 23:10:48 -07:00
022_meal_plans.sql feat(db): add meal_plans, slots, prep_sessions, prep_tasks migrations (022-025) 2026-04-12 13:11:34 -07:00
022_recipe_generic_flag.sql chore: commit in-progress work -- tag inferrer, imitate endpoint, hall-of-chaos easter egg, migration files, Dockerfile .env defense 2026-04-14 13:23:15 -07:00
023_meal_plan_slots.sql feat(db): add meal_plans, slots, prep_sessions, prep_tasks migrations (022-025) 2026-04-12 13:11:34 -07:00
024_prep_sessions.sql feat(db): add meal_plans, slots, prep_sessions, prep_tasks migrations (022-025) 2026-04-12 13:11:34 -07:00
025_prep_tasks.sql feat(db): add meal_plans, slots, prep_sessions, prep_tasks migrations (022-025) 2026-04-12 13:11:34 -07:00
028_community_pseudonyms.sql feat(community): migration 028 — community_pseudonyms table in per-user kiwi.db 2026-04-13 08:13:39 -07:00
029_inferred_tags.sql chore: commit in-progress work -- tag inferrer, imitate endpoint, hall-of-chaos easter egg, migration files, Dockerfile .env defense 2026-04-14 13:23:15 -07:00
030_opened_date.sql feat: pantry intel cluster — #61 expiry display, #64 cook log, #66 scaling, #59 open-package tracking 2026-04-16 06:01:25 -07:00
031_disposal_reason.sql feat: partial consumption tracking and waste/disposal logging (#12 #60) 2026-04-16 07:28:21 -07:00
032_meal_plan_unique_week.sql fix: meal planner week add button crashing on r.name / add duplicate guard 2026-04-16 10:46:28 -07:00
033_shopping_list.sql fix: recipe enrichment backfill, main_ingredient browser domain, bug batch 2026-04-18 15:38:56 -07:00
034_recipe_jobs.sql feat(recipes): async L3/L4 recipe job queue with poll endpoint 2026-04-19 21:44:27 -07:00
035_sensory_tags.sql feat: sensory profile filter — texture/smell/noise filtering for Browse and Find (kiwi#51) 2026-04-24 09:47:48 -07:00
036_captured_products.sql feat: visual label capture for unenriched barcodes (kiwi#79) 2026-04-24 17:57:25 -07:00