Add iAUC (incremental area under the curve) metric to health dashboard

t-766·WorkTask·
·
·
Created1 week ago·Updated1 week ago·pipeline runs →

Description

Edit

Summary

Add iAUC (incremental area under the curve) computation to the health dashboard. iAUC measures total glucose exposure above baseline over a meal window, which is a better proxy for insulin demand than peak glucose (spike). A sharp spike that resolves quickly has a small iAUC; a moderate rise that lingers has a large one.

Context

Ben's CGM data shows fruit causes high peak spikes but he had his lowest insulin (20) during a fruititarian + high-running period. The hypothesis is that fruit spikes are sharp but brief (low iAUC = low insulin demand), especially with GLUT4 uptime from running. The dashboard currently only shows peak-based spike metrics, which may misrepresent the metabolic impact.

What to change

Analyze.hs

1. Add an iAUC computation function. The algorithm:

  • For each meal, identify the baseline BG (pre-meal reading, same as current mealSpike baseline logic)
  • Compute the window (until next meal or 3h, same as mealSpike windowing)
  • For each CGM reading in the window where glucose > baseline, sum up (glucose - baseline) * interval_minutes
  • This gives incremental AUC in mg/dL·min
  • Return the iAUC alongside existing spike data

2. Add MealIauc or extend MealSpikeRecord with an msrIauc :: Double field (mg/dL·min).

3. Add computeMealIaucRankings that ranks meals/categories by average iAUC (similar to computeFoodRankings but using iAUC instead of peak spike).

4. Add iAUC to DailyCgmStats — total daily iAUC across all meals would be a useful aggregate metric.

Web.hs

1. Add an iAUC column to the existing food rankings table and meal rankings table. 2. Optionally add a new section or integrate into the existing food rankings to show the iAUC perspective — meals ranked by iAUC vs by peak spike, so the user can see which foods are truly high-burden vs just high-peak.

Score.hs

No changes needed for now — scoring still uses spike thresholds. iAUC is informational.

CGM data format

CSV in /var/health/cgm.csv:

Date/Time,Blood Glucose (mg/dL),Meal Time,Sources
2026-02-19 22:21:00,122,,

5-minute intervals. Meals are in /var/health/meals.jsonl.

Acceptance criteria

  • computeMealIaucRankings exists and computes iAUC per meal from CGM+meal data
  • iAUC values appear on the /health dashboard (at minimum in the food rankings and meal rankings tables)
  • Existing tests pass, new tests cover iAUC computation
  • iAUC unit is mg/dL·min (standard in glycemic research)

Timeline (4)

🔄[human]Open → InProgress1 week ago
💬[human]1 week ago

Implemented iAUC end-to-end. Added msrIauc to MealSpikeRecord, dailyCgmStatsWithMeals + dcsIaucTotal, frAvgIauc in FoodRanking, computeMealIaucRankings, and wired iAUC columns into /health food + meal rankings tables. Added iAUC unit tests in Omni/Health/Analyze.hs and verified with: CODEROOT=/home/ben/omni/intent TERM=xterm-256color bild --test Omni/Health/Test.hs and bild Omni/Health/Web.hs. Commit: bf7596d4

🔄[human]InProgress → Review1 week ago