Problem
MacroChef shows Cal -1797 but MF app shows consumed 3583 of target 2433 → expected remaining ≈ -100 (after 1050 active energy buffer). The difference is 647 cal.
Root Cause
get_goals() in macrofactor.py:641-662 reads planner.calories from MF Firestore. This is the base strategy target (1786 for this user on Wed Apr 22). MF's app displays the expenditure-adjusted target (2433). MacroChef never sees the adjusted value.
Arithmetic proof: 3583 (consumed) - 1786 (planner goal) = -1797 (matches MacroChef display). The delta 2433 - 1786 = 647 is MF's coaching/expenditure adjustment.
planner.tdeeValue IS already extracted (macrofactor.py:658-661) but never used in the remaining calculation (http_macrofactor_port.py:174).
Code Path
http_macrofactor_port.py:148 → goals = await mf.get_goals()
macrofactor.py:652-657 → reads planner.{calories,protein,carbs,fat} arrays
http_macrofactor_port.py:174 → cal = _pick(goals["calories"]) - consumed_cal
- Result stored as
session.remaining_cal (frozen at session creation)
- Template
session.html:19 → renders raw session.remaining_cal = -1797
- Stacked bar
web.py:230 → max(0.0, remaining) = 0 (hides the problem)
Investigation Needed
Related
- Active energy "over 2h old (122 min)" is a separate VT staleness issue, not related
- Meal generation stalling at 3/10 is a separate Ollama/recipe-DB issue
web.py:230 max(0.0, ...) is by-design for the stacked bar, not a bug itself
Problem
MacroChef shows Cal -1797 but MF app shows consumed 3583 of target 2433 → expected remaining ≈ -100 (after 1050 active energy buffer). The difference is 647 cal.
Root Cause
get_goals()inmacrofactor.py:641-662readsplanner.caloriesfrom MF Firestore. This is the base strategy target (1786 for this user on Wed Apr 22). MF's app displays the expenditure-adjusted target (2433). MacroChef never sees the adjusted value.Arithmetic proof: 3583 (consumed) - 1786 (planner goal) = -1797 (matches MacroChef display). The delta 2433 - 1786 = 647 is MF's coaching/expenditure adjustment.
planner.tdeeValueIS already extracted (macrofactor.py:658-661) but never used in the remaining calculation (http_macrofactor_port.py:174).Code Path
http_macrofactor_port.py:148→goals = await mf.get_goals()macrofactor.py:652-657→ readsplanner.{calories,protein,carbs,fat}arrayshttp_macrofactor_port.py:174→cal = _pick(goals["calories"]) - consumed_calsession.remaining_cal(frozen at session creation)session.html:19→ renders rawsession.remaining_cal= -1797web.py:230→max(0.0, remaining)= 0 (hides the problem)Investigation Needed
/debug/probe-mf-goalsroute to dump the fullplannerdict — find whether MF stores an adjusted target fieldtdeeValuecan be used to compute the adjustment (adjusted = planner.calories + (tdee - planner.calories))Related
web.py:230max(0.0, ...)is by-design for the stacked bar, not a bug itself