Repository navigation
fix(data): correct calorie rows behind #192's ingredient re-pins (kcal audit) - #205
Conversation
…g sqlite PR #192 re-pinned catalog ingredients for reach; four keys re-sourced per-100g nutrition from rows that describe a different preparation form than the recipes measure (cooked thigh on raw thigh lines, cooked rice on dry rice cups, canned-cooked tomatoes on as-sold product). This audit re-chooses the nutrient row per measurement form, keeps every identity pin, and rebuilds the sqlite from canonical (restoring #192's claimed reach, which the stale shipped sqlite had regressed). - evaluation/kcal-audit: report, script (real compiler, three vocab states, fidelity 0.0000 vs published 9e4a3af bundle), pytest gate - canonical catalog: add FDC 173627 (raw thigh meat only) -> 960 records - shipped sqlite rebuilt from canonical (uv run usda validate OK) Co-authored-by: Sam Gu <sgu07966@gmail.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: Sam Gu <sgu07966@gmail.com>
…ck-kcal-repin-audit
Row 173627 shipped with no alt_names, so users would see the raw USDA string. Adds five aliases in the style of neighbouring meat-only rows (mirrors 171129 Turkey Thigh (Raw, Meat Only)); the pipeline normalizes the parenthesized form. Rewrites the reach section to measured numbers with recorded inputs and states the branch scope: shipped calories are unchanged; vocabulary.json and the bundles belong to the rebuild packet. Co-authored-by: Sam Gu <sgu07966@gmail.com>
PR description lives on the pull request itself. Co-authored-by: Sam Gu <sgu07966@gmail.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Note Review skipped Codemetrics is installed on this repository, but it hasn't been added to your team yet. To enable AI code reviews for this repo, go to your dashboard and add FridgeLuck to your team's repositories. |
What this branch ships — and what it does not
Ships: the audit (
evaluation/kcal-audit/— report, script, pytest gate) and one catalog row — FDC 173627 "Chicken, broilers or fryers, dark meat, thigh, meat only, raw", with five search aliases — plus the catalog SQLite rebuilt from canonical (960 records). Nothing else.Does not ship: any change to
data/ingredients/vocabulary.json,data/recipes/build/recipes-v2.json,apps/ios/Resources/RecipeCatalog/recipes-v2.json, or the nutrition-changes file. Those belong to the rebuild packet (burst12-fridgeluck-catalog-rebuild), which owns the vocabulary and shipped bundles. Shipped per-serving calories are unchanged by this branch, andtest_kcal_drift.pyfails here exactly as it fails on alpha's head (the pre-rebuild changes-file assert).Context: PR #192 re-pinned catalog ingredient rows so typed pantry text resolves (reach v3). Eleven of those re-pins also re-sourced the vocabulary's per-100 g nutrition, and for four keys the new row describes a different preparation form than the recipes measure — cooked thigh on raw thigh lines, cooked rice on dry rice cups, "canned, cooked" on as-sold crushed/chopped tomatoes. On alpha,
test_kcal_drift.pyfails (16 recipes over the 40 percent drift gate with no recorded reason) andvalidate_bundle.py --real-bundlesreports the same 16 drift problems. This branch is the audit input that packet must apply.Fidelity anchor: corpus, rights, name mappings, and the compiler are unchanged
9e4a3af5..alpha(verified withgit diff --stat), so the audit's in-memory prev state reproduces the published bundle exactly: max |delta| 0.0000 kcal over all 762 recipes.For the rebuild packet: exact vocabulary pin changes to apply
Identity pins from #192 stay untouched (chicken thigh(s) 2706027, white rice 2708403, canned tomatoes 2709722). The packet must change only each entry's per-100 g nutrients and nutrition-source citation:
chicken_thighschicken_thighwhite_ricecanned_tomatoesEvidence per decision is in
evaluation/kcal-audit/kcal-audit.md(read from USDA FoodData Central bulk CSVs — Survey 2024-10-31, SR Legacy 2018-04, CC0 — not the web UI). Corpus form evidence: all 23chicken_thighslines are "boneless chicken thighs" pieces of 110 g; 41 of 41chicken_thighlines measure raw thigh; 59 of 60white_ricelines measure dry rice by cup (185 g), with the 14 cooked-rice lines (rcp-000573, 580, 586, 589, 599, 605, 610, 631, 634, 645, 649, 652, 686, 722) listed exceptions;canned_tomatoeslines use the as-sold product. Rows kept after verification (documented in the audit): lentils 172420 (352), sugar 169655 (387), banana 173944 (89), cinnamon 171320 (247), almonds 170567 (579), bacon 2705885 (484), heavy cream 2346386 (343.31), pork chop 2705866 (183, kept as closest cited row).For the rebuild packet: the exact nutrition-change records to write
The rebuild's changes file must record (recipe id, old kcal, new kcal, reason) for every recipe the fixed state moves more than 40 percent versus the published bundle — 55 records (16 pre-existing drifts plus honest corrections the audit surfaces). Full reasons per record are in
evaluation/kcal-audit/kcal-audit.md; the records:rcp-000213rcp-000221rcp-000260rcp-000266rcp-000267rcp-000270rcp-000279rcp-000293rcp-000298rcp-000304rcp-000305rcp-000322rcp-000352rcp-000373rcp-000378rcp-000386rcp-000402rcp-000410rcp-000411rcp-000428rcp-000429rcp-000461rcp-000465rcp-000482rcp-000486rcp-000487rcp-000488rcp-000504rcp-000511rcp-000512rcp-000516rcp-000518rcp-000524rcp-000525rcp-000546rcp-000548rcp-000564rcp-000567rcp-000569rcp-000573rcp-000580rcp-000586rcp-000597rcp-000599rcp-000605rcp-000610rcp-000631rcp-000634rcp-000645rcp-000649rcp-000652rcp-000666rcp-000686rcp-000702rcp-000728Reason groups: raw thigh row (fdc 173627) for thigh recipes; dry-rice row (fdc 168877) for white-rice recipes, with the 14 cooked-rice-line exceptions carrying their own exception reason; dry-lentil row (fdc 172420); granulated-sugar row (fdc 169655); crushed-canned row (fdc 170501).
Reach, re-measured (this review round)
python3 evaluation/catalog-reach/reach_report_v3.py --before-sqlite <origin/alpha b33239f5 sqlite> --before-bundle <origin/alpha data/recipes/build/recipes-v2.json>, after = this branch's head:b33239f5)Unbridged lines 1220 and not-in-pantry 28131 in both states. The two catalog databases differ only in physical row ordering/ids, the added row 173627, and its five aliases; the numbers above are the measured output of the replay over them. The after-state matches the after-numbers PR #192 published (exact 4.5 / 1.5 / 0 / 2.5 / 2.0; near 162.5 / 93.5 / 29 / 76 / 78; wrong-ID 0).
How I checked it (commands and results)
cd scripts/data && uv run usda validate --canonical catalog/usda_curated_ingredients.json— Validation OK (960 records, 3947 unique aliases, 14 required terms);uv run usda build-sqlite ...— 960 rows.python3 -m pytest evaluation/kcal-audit/test_kcal_audit.py -q— 4 passed (fidelity anchor; every gate recipe documented and nothing else; audit rows exist in canonical catalog with cited macros; idempotence over the rebuilt vocabulary).python3 -m pytest data/recipes/tools/tests -q— 75 passed, 1 failed, 1 skipped; the failure istest_kcal_drift.pychanges-file consistency, unchanged from alpha's head by design (this branch does not touch the shipped bundle).python3 evaluation/kcal-audit/kcal_audit.py— fidelity max |delta| 0.0000 kcal vs the published 9e4a3af bundle (762 recipes); 55 recipes above the gate at the fixed state, all tabulated; 16 above the gate at alpha./tmp/audit/reach-v3-review.jsonin the sandbox); alias and content diffs between the two catalog databases checked directly.origin/alpha(b33239f5, merge — no rebase; alpha's move — PRs feat(data): add shipped-bundle safety invariants with a claims-vs-gate sweep #194/fix(onboarding): real setup lands in your kitchen, not a demo #206/feat(evaluation): audit legacy recipes that mislead or slip past the safety boundary #209 — touches none of this branch's files or the shipped bundle/vocabulary).What I could not check
test_kcal_drift.pygoing green) are not in this PR.IngredientRepository.search, not the app binary.Assumptions
raw chicken thigh,chicken thigh meat only, ...); the pipeline normalized the parenthesized form tochicken thigh raw meat only.Human author: Sam Gu (sgu07966@gmail.com)
🔗 Obvious Project · 🧵 Obvious Thread · 🔀 Obvious PR Artifact