kiwi/tests/services/recipe
pyr0ball b5eb8e4772 feat: cross-encoder reranker for recipe suggestions (kiwi#117)
Integrates cf-core reranker into the L1/L2 recipe engine. Paid+ tier
gets a BGE cross-encoder pass over the top-20 FTS candidates, scoring
each recipe against the user's full context: pantry state, dietary
constraints, allergies, expiry urgency, style preference, and effort
preference. Free tier keeps the existing overlap sort unchanged.

- New app/services/recipe/reranker.py: build_query, build_candidate_string,
  rerank_suggestions with tier gate (_RERANKER_TIERS) and graceful fallback
- rerank_score field added to RecipeSuggestion (None on free tier, float on paid+)
- recipe_engine.py: single call after candidate assembly, before final sort;
  hard_day_mode tier grouping preserved as primary sort when reranker active
- Fix pre-existing circular import in app/services/__init__.py (eager import
  of ReceiptService triggered store.py → services → receipt_service → store)
- 27 unit tests (mock backend, no model weights) + 2 engine-level tier tests;
  325 tests passing, no regressions
2026-04-24 16:39:51 -07:00
..
__init__.py feat: ElementClassifier -- ingredient element tagging with heuristic fallback 2026-03-30 22:59:46 -07:00
test_assembly_build.py feat: add get_role_candidates() and build_from_selection() to assembly engine 2026-04-14 11:06:08 -07:00
test_element_classifier.py fix: ElementClassifier — guard empty input, safe JSON decode, dedup heuristic elements, strengthen test assertions 2026-03-30 23:10:49 -07:00
test_llm_recipe.py fix: address recipe/OCR quality issues from review 2026-04-02 12:41:59 -07:00
test_recipe_engine.py feat: cross-encoder reranker for recipe suggestions (kiwi#117) 2026-04-24 16:39:51 -07:00
test_reranker.py feat: cross-encoder reranker for recipe suggestions (kiwi#117) 2026-04-24 16:39:51 -07:00
test_staple_library.py fix: staple library — consistent tofu_firm slug, load error handling, typed yield_formats, expanded test coverage 2026-03-30 23:10:51 -07:00
test_style_adapter.py feat: recipe engine Phase 3 — StyleAdapter, LLM levels 3-4, user settings 2026-03-31 14:15:18 -07:00
test_substitution_engine.py fix: test fixture — add protein_delta to substitution_pairs inserts 2026-03-30 23:16:15 -07:00