From f85035a8ecd82ab9ec0d2b75bc2307c31ec2a106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 25 Oct 2026 11:49:46 +0100 Subject: [PATCH] docs(coach): say what the labs block reads since it covers the whole record The labs block reads the whole record, or up to the lookback limit, not just recent readings, and a named read also comes back empty when no marker matches. The header of the labs snapshot and the note at its call site still described the earlier twelve-month window. --- src/lib/ai/coach/labs-snapshot.ts | 5 +++-- src/lib/ai/coach/snapshot.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/ai/coach/labs-snapshot.ts b/src/lib/ai/coach/labs-snapshot.ts index bb030f516..5d606dd35 100644 --- a/src/lib/ai/coach/labs-snapshot.ts +++ b/src/lib/ai/coach/labs-snapshot.ts @@ -48,8 +48,9 @@ * `userId` is narrowed from the authenticated session by the caller and feeds * the Prisma `where` field-by-field; it is never an input. Unlike the illness * block, Labs is intentionally NOT module-gated (mirrors `/api/labs` — the data - * is always owner-scoped and safe to read), so the block is `null` only when the - * account has no recent readings. + * is always owner-scoped and safe to read). The block is `null` only when no + * reading falls inside the lookback limit (the whole record when there is + * none), or, for a named read, when no marker matches the analyte. */ import { sameLabUnit } from "@/lib/labs/unit-normalise"; import { diff --git a/src/lib/ai/coach/snapshot.ts b/src/lib/ai/coach/snapshot.ts index b572218a7..7e884a756 100644 --- a/src/lib/ai/coach/snapshot.ts +++ b/src/lib/ai/coach/snapshot.ts @@ -668,8 +668,8 @@ async function buildCoachSnapshotImpl( // scope-gated metric: attached without a `registerBlock` so the budget // degrader never sheds it, and Labs is intentionally not module-gated (the // helper reads owner-scoped rows directly, mirroring `/api/labs`). The block - // carries the most-recent resolved reading per biomarker (last 12 months, - // capped) so the Coach can answer "what was my LDL" without re-deriving. + // carries the latest resolved reading per biomarker (whole record or the + // lookback limit, capped) so the Coach can answer "what was my LDL". const labsBlockPromise = buildLabsSnapshotBlock(userId, now, reach); // v1.38 — doctor-visit context. Like illness/labs it is attempted always (a