feat(nutrition): Batch 4 — weekly wrap-up (adherence grade + takeaway) + alcohol parity verified#73
Open
drkostas wants to merge 1 commit into
Conversation
… + takeaway) + alcohol parity verified Weekly adherence never had a canonical implementation in soma. This ports macro-engine's M10A aggregator as a new pure-logic module so a future weekly-summary endpoint can drop it in without re-deriving the ±10% tolerance. - sync/src/nutrition_engine/weekly_wrapup.py: DayRecord + WeeklyWrapup dataclasses + compute_weekly_wrapup aggregator. Grade A>=90 / B>=80 / C>=70 / D>=60 / F. Adherence uses ±10% kcal target tolerance. Auto-generated takeaway string keyed to adherence + protein g/kg + training days + weight delta. Handles missing weight readings (ignores Nones in the delta computation) and open/closed day split. - adherence_grade(pct) + wrapup_takeaway(w) exposed for direct use. - sync/src/nutrition_engine/alcohol.py: parity-verified against macro-engine's canonical version — byte-identical except for the import path for DRINK_DATABASE (already fixed at Batch 0 of the nutrition engine). No change needed. Tests: 18 new pytest assertions for weekly_wrapup. Full Batch 1-4 module scope: 157 + 32 + 61 + 18 = 268 new tests, all green. Closes #69
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #72. Final batch of the "port macro-engine science into soma" series (#65).
Weekly wrap-up
Soma's web/api/nutrition has no existing weekly-adherence computation — this ports macro-engine's M10A aggregator as a pure-logic module so a future endpoint can drop it in.
compute_weekly_wrapup(days, weight_kg)returnsWeeklyWrapup { week_start, week_end, days_total, days_closed, adherence_pct, avg_kcal, avg_protein_g[/kg], training_days, weight_delta_kg, grade }.wrapup_takeaway(w)generates a short commentary string from adherence + protein g/kg + training days + weight delta.Alcohol parity
Byte-diffed soma's
nutrition_engine/alcohol.pyagainst macro-engine's — identical except for thefrom nutrition_engine.seed_data import DRINK_DATABASEline (already the right path). No change needed.Test plan
weekly_wrapup— green.alcoholtests remain green, unchanged.Batch 1-4 total new tests: 157 + 32 + 61 + 18 = 268 new pytest assertions, all green.
Closes #69