mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 15:02:04 +00:00
feat(coach): feed native strain and teach the glucose panel
Surface WHOOP's native day strain to the coach on its own 0-21 scale, distinct from the computed strain score, and instruct the model to prefer the device number — the gold-standard signal a WHOOP user connected was previously invisible to the coach. Document the glucose clinical block in the prompt so the model reads time-in-range, GMI, estimated A1C and variability correctly and never asserts them while still learning or off spot readings, and extend the non-English unit vocabulary to cover glucose. Centralize the glucose panel window and run the independent derived reads concurrently.
This commit is contained in:
commit
713fa3e926
10 files changed
+269
-21
No files matched your search
@@ -22,6 +22,7 @@ import { deriveBpWindow90 } from "@/lib/analytics/window-confidence";
|
||||
import { computeCorrelationHypothesesFastPath } from "@/lib/analytics/correlations-fast-path";
|
||||
import {
|
||||
computeGlucoseClinicalMetrics,
|
||||
GLUCOSE_PANEL_WINDOW_DAYS,
|
||||
type GlucoseClinicalMetrics,
|
||||
} from "@/lib/analytics/glucose-metrics";
|
||||
|
||||
@@ -346,7 +347,9 @@ async function buildAnalyticsResponse(user: AuthedUser) {
|
||||
// v1.4.29 H2 — bound to the trailing 30 days. The dashboard tile
|
||||
// path only reads the trailing window; pre-bound this query
|
||||
// walked every persisted BG row a multi-year user has written.
|
||||
const glucoseSince = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
|
||||
const glucoseSince = new Date(
|
||||
Date.now() - GLUCOSE_PANEL_WINDOW_DAYS * 24 * 60 * 60 * 1000,
|
||||
);
|
||||
const glucoseRows = await prisma.measurement.findMany({
|
||||
where: {
|
||||
userId: user.id,
|
||||
@@ -379,7 +382,7 @@ async function buildAnalyticsResponse(user: AuthedUser) {
|
||||
// "still learning" state from a populated object rather than a missing key.
|
||||
const glucoseClinical: GlucoseClinicalMetrics = computeGlucoseClinicalMetrics(
|
||||
glucoseRows.map((r) => ({ measuredAt: r.measuredAt, mgdl: r.value })),
|
||||
{ windowDays: 30, now: new Date() },
|
||||
{ windowDays: GLUCOSE_PANEL_WINDOW_DAYS, now: new Date() },
|
||||
);
|
||||
|
||||
// v1.4.20 phase B3 — three pre-defined correlation hypotheses.
|
||||
|
||||
Reference in new issue
Block a user