cauldron/cauldron
Kayos 6bcf79e5dc sterilize: recipe context + spell cleanup + defensive food.id preservation
Three improvements driven by Cobb's review of the fan-out output:

1. Recipe context. _parse_batch now accepts an optional recipe_context
   dict carrying recipe_name, recipe_description, and recipe_steps.
   preview_recipe builds the context from the Mealie recipe and passes
   it through. The Sonnet prompt has new USE RECIPE CONTEXT WHEN
   AMBIGUOUS rules: "1 cup flour" is ambiguous (AP / bread / cake);
   the cooking steps usually disambiguate ("knead until elastic" →
   bread flour, "sift with cocoa powder" + cake recipe → cake flour).
   Step text capped to 3000 chars so the user prompt stays modest;
   defaults to all-purpose flour when steps don't disambiguate.
   Brand/style hints in the description carry through too.

2. Spell + grammar cleanup. New SPELL/GRAMMAR CLEANUP rules in the
   prompt: silently fix typos in food and note ("tomatos" → "tomatoes",
   "chopped finly" → "chopped finely", "heavy cram" → "heavy cream").
   Normalize spacing. Critically: preserve EVERY semantic value —
   numeric quantities verbatim, every prep state, brand, color. When
   uncertain whether something is a typo or intentional ("yellow
   squash" is a real food, not a typo), keep it. Original strings
   stay in originalText for audit / rollback.

3. Defensive food.id preservation in apply_recipe. Three new safeguards
   protect against Sonnet hallucinations dropping live recipe data:

   a) If Sonnet returns a single all-null parsed item but the original
      Mealie row had a real food.id, pass the original through
      verbatim. (Sonnet probably parse-failed; never blank a real link.)

   b) When Sonnet returns a food name that we can't resolve in Mealie's
      catalog AND the original had a food.id, preserve the original
      link rather than emit food=null.

   c) When Sonnet explicitly returns food=null on the first child of
      an ingredient that originally had a food.id, treat that as a
      misread and preserve the original. Real section headers — where
      the original was ALREADY foodless — still pass through cleanly.

   Net effect: no apply path can drop a recipe's existing food
   reference. Sonnet can ADD food links (good), CHANGE them (good),
   or fail to parse (we keep what was there). It cannot remove them.

The is_new_food field also benefits from recipe context — Sonnet has
more evidence to set is_new_food=false (matched a known canonical)
when the steps confirm the ingredient identity.
2026-04-30 12:27:17 -07:00
..
data v0.3 step 5: lean shopping list — claude on-demand foods + game strip 2026-04-29 22:02:20 -07:00
templates Step 3: foods consolidator — cluster + merge dupes via Mealie's API 2026-04-30 12:00:20 -07:00
__init__.py v0.1 — backend bones + ingredient sterilizer 2026-04-28 16:59:11 -07:00
aggregator.py Step 2: re-key cauldron's food metadata by mealie_food_id 2026-04-30 11:52:25 -07:00
bulk_sterilize.py sterilize bulk: respect external cancel mid-loop 2026-04-30 10:02:53 -07:00
config.py fix: split MEALIE_API_URL (internal) from MEALIE_PUBLIC_URL (UI link) 2026-04-28 20:26:25 -07:00
consolidate_foods.py Step 3: foods consolidator — cluster + merge dupes via Mealie's API 2026-04-30 12:00:20 -07:00
crypto.py v0.2 foundation — Authentik OIDC + sulkta-mariadb DB + Fernet crypto 2026-04-28 19:47:47 -07:00
db.py Step 4 (partial): drop dead pick_points table + game-system DB methods 2026-04-30 12:02:58 -07:00
foods.py Step 2: re-key cauldron's food metadata by mealie_food_id 2026-04-30 11:52:25 -07:00
forge.py Step 3: foods consolidator — cluster + merge dupes via Mealie's API 2026-04-30 12:00:20 -07:00
mealie.py Step 3: foods consolidator — cluster + merge dupes via Mealie's API 2026-04-30 12:00:20 -07:00
oidc.py v0.2 foundation — Authentik OIDC + sulkta-mariadb DB + Fernet crypto 2026-04-28 19:47:47 -07:00
recipe_index.py search: local fuzzy recipe index — way smarter than Mealie's lexical default 2026-04-28 21:37:12 -07:00
server.py Step 3: foods consolidator — cluster + merge dupes via Mealie's API 2026-04-30 12:00:20 -07:00
sterilizer.py sterilize: recipe context + spell cleanup + defensive food.id preservation 2026-04-30 12:27:17 -07:00