← Back to Pull requests

fix: bulb converts like head for garlic; cook footer names a to-taste food once (#866, #867) #881

Open
unknown opened this pull request with 514 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 01, 2026 21:49 UTC
Author

Summary


Two small follow-ups to the unit-conversion PR #857.

  • Garlic stored as "bulb" now converts to cloves. 2 cloves garlic against a pantry row garlic 2 bulb used to come back imprecise because bulb was not a recognised unit. It is now read as a head, so the line is ready, flagged approximate, and deducts about 10 g (5 g a clove, 50 g a head, per ADR 0005).

  • The cook review footer names a to-taste food once. Two to-taste lines for salt used to read Not deducted: to taste (salt, salt); now (salt).
  • What changes


  • ai-service/bubbly_chef/domain/normalizer.py: bulb / bulbs added to the unit vocabulary as synonyms of head. Same typical weight as head (50 g for garlic), still flagged approximate.

  • nextjs/src/components/recipes/CookReviewBody.tsx: the to-taste name list is de-duplicated by display name, case-insensitively, keeping first-appearance order and casing.
  • Verify


    Backend and a small render fix, so verified by fixture and jest. No production build was run.

    | | main | this PR |
    |---|---|---|
    | 2 cloves garlic vs garlic 2 bulb | imprecise | ready, approximate, 10 g, 1.8 bulbs left (stored-base and derived-base) |
    | normalize_unit("bulb") | bulb | head |
    | two to-taste salt lines | (salt, salt) | (salt) |
    | salt, Pepper, Salt, salt, pepper | all five | (salt, Pepper) |

    Not covered by a screenshot: the cook route would need a mocked authenticated cook flow on a production build for a one-line text change, so #867 is covered by jest only. Nothing hit live Gemini or Ollama.

    Tests


  • Red on main, then green: unit_conversion_cases.py gained cloves-off-two-bulbs (runs the real cook matcher and deduct_pantry_item, in both stored-base and derived-base modes), plus normalize_unit spelling cases for bulb / bulbs. 4 failures before the fix.

  • Red on main, then green: jest cook-to-taste.test.tsx "names a food once when two to-taste lines repeat it, ignoring case". Before the fix it rendered (salt, Pepper, Salt, salt, pepper).

  • Gates: pytest 3743 passed / 4 skipped; ruff clean; mypy gate 0 new; tsc clean; jest 3727 passed; eslint 0 errors (31 pre-existing warnings).
  • Decisions


  • bulb is a global synonym of head in the unit vocabulary, not a garlic-only special case. The issue says "garlic (and shallots)", and a global alias is the smallest way to cover both. Alternative rejected: a per-food alias table, which is more machinery for the same result.

  • Real side effect, and how it is guarded: a bulb row became a package unit like head, so the ADR 0003 piece-vs-package guard must treat it as one. The first commit missed this (the guard read raw units without aliases), so 2 cloves shallots against shallots 3 bulb came out ready and deducted 2 whole bulbs. The guard's raw-unit table is now derived from the unit aliases, so a spelling can no longer resolve to a piece/package unit while slipping the guard. 2 cloves shallots vs 3 bulb is now imprecise with nothing deducted, same as a head row; 2 cloves garlic vs 2 bulb still converts; 1 bulb fennel vs a fennel head row matches as the same unit (the recipe-line parser now reads bulb as a unit too).

  • Sweep of every unit alias for the same escape found others, now fixed by the same derivation: tin(s), pack(s), packet(s), carton(s), tub(s), canister(s) (to can/package/container) and piece(s)/each (to item). Before, e.g. 4 slices bread against 1 tin gave a bogus shortfall. item/items were already guarded as the package unit item. A parametrized test asserts guard and normalize_unit agree for every alias. Rejected alternative: adding only bulb, which leaves the others open.

  • No shallot weight was added. There is no citable head weight for shallots, so shallots by bulb get the same-unit match but no cross-unit conversion (consistent with ADR 0005's "only citable figures").
  • Out of scope


  • Shallot head/clove weights; new unit synonyms.
  • Fixes #866
    Fixes #867

    🤖 Generated with Claude Code

    Diff: 514 lines (+385 / -129) across 6 files Reviewer: claude[bot] Review duration: 15m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.48) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 514 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #881"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.4% · Safe to merge
    25.4%