Skip to content

update_custom_food: stop trusting defaultMeasureId; require measure_id when ambiguous - #8

Merged
ColinToft merged 3 commits into
mainfrom
colin/custom-food-default-measure
Oct 13, 2026
Merged

ColinToft merged 3 commits into
mainfrom
colin/custom-food-default-measure

Conversation

@ColinToft

@ColinToft ColinToft commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Problem

defaultMeasureId isn't the serving: live, it follows the last-logged measure. Logging a cup + g custom food by g moved the default to g, and logging by cup moved it back. update_custom_food then edited g:

  • calories=130 stored 13,000 kcal/100 g;
  • serving_grams=250 resized g, and every gram-logged entry was rescaled (100 g turned into 10,000 g).

Fix

  • The serving is the sole measure, or the new measure_id when there are several. Ambiguous or unknown measure ids are refused, and so is measure_id without an edit.
  • g and oz measures can't be renamed or resized.
  • _default_measure and _only_measure are replaced by _custom_food_serving.
  • update_recipe already ignored the default.

Verification

  • pytest: 688 passed; ruff is clean.
  • The tests cover each kind of edit against defaults of serving, g, 0 and stale ids.
  • Live run of the fix: the ambiguous edit was refused, measure_id=cup worked, and resizing g was refused. The ZZ test foods were retired, and the test day 2027-03-24 was emptied.

🤖 Generated with Claude Code

ColinToft and others added 3 commits October 13, 2026 11:51
…d when ambiguous

Live probes showed defaultMeasureId is the measure logged last, not the
food's serving: logging a two-measure custom food by "g" moved its default to
"g". update_custom_food then edited that measure, so calories=130 meant
130 kcal per gram, and serving_grams=250 resized "g" itself, which rescaled
every gram-logged diary entry (a 100 g entry read back as 10,000 g).

- The serving is the food's only measure, or the new measure_id argument
  when it has several; ambiguity is refused, listing the measures.
- A "g" or "oz" measure is never renamed or resized.
- _default_measure and _only_measure are replaced by _custom_food_serving.
- get_food_details documents what default_measure_id really is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- update_custom_food refuses serving_name "g"/"oz", which would otherwise
  create a weight-unit measure the tool can then never fix.
- get_food_details no longer returns default_measure_id: it is just the
  last-logged measure, so exposing it invites the same mistake.
- Tool Args no longer say "default serving"; old test names renamed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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