Files
HealthLog/src/lib/ai/coach/target-scope.ts
T
Marc-André Bombeck 17b8d8d2c2 chore(release): v1.4.25
Largest feature delta in the v1.4.x line. Insights expands into seven dedicated metric sub-pages; GLP-1 medication tracking lands end-to-end (drug-level chart with Research Mode acknowledgment, EMA titration ladder, cadence + compliance, side-effect taxonomy, pen/vial inventory); cross-source priority becomes a two-axis resolver; per-user timezone threads through ten analytics surfaces; Withings activity + sleep v2 sync; onboarding rebuilt as a nested-route wizard; Personal Records ship end-to-end; Health Score provenance accordion; Coach runs native first-party prompts across six locales with a 1800-assertion refusal-probe matrix; OpenAPI drift gate hard-fails; multi-arch GHCR image. Migrations 0043 through 0060 are additive and forward-only. PROMPT_VERSION 4.24.0 → 4.25.0 with GROUND RULE 9 (refuses dose recommendations) and GROUND RULE 15 (refuses drug-level estimates with MDR + MDCG 2021-24 cites).

See CHANGELOG.md for the full per-section delta.
2026-05-14 23:49:32 +02:00

49 lines
1.6 KiB
TypeScript

import type { CoachScopeSource } from "@/lib/ai/coach/types";
/**
* v1.4.25 W3e — per-target Coach scope source mapping.
*
* The per-card "Ask Coach about this" CTA narrows the snapshot to the
* single source the user is asking about. For derived metrics (BMI
* derives from weight; mood stability derives from mood) we map to the
* underlying source — the Coach prompt-builder knows how to talk
* about the derived view but the data it needs lives in the source.
*
* Targets without a CoachScopeSource counterpart (glucose contexts,
* steps, sleep, body-fat as of v1.4.23) fall back to an empty array,
* which the drawer reads as "do not narrow — use defaults". The
* Coach defaults already include the five-source set, so the snapshot
* stays useful even when this map has no opinion.
*/
export function coachScopeForTarget(
targetType: string,
): ReadonlyArray<CoachScopeSource> {
switch (targetType) {
case "WEIGHT":
case "BMI":
return ["weight"];
case "BLOOD_PRESSURE":
case "BLOOD_PRESSURE_IN_TARGET":
return ["bp"];
case "PULSE":
return ["pulse"];
case "MOOD_SCORE":
case "MOOD_STABILITY":
return ["mood"];
case "MEDICATION_COMPLIANCE":
return ["compliance"];
case "SLEEP_DURATION":
return ["sleep"];
case "ACTIVITY_STEPS":
return ["steps"];
case "BODY_FAT":
// No 1:1 source — the snapshot's weight + general blocks carry
// the surrounding context. Empty scope = "use defaults".
return [];
default:
// Glucose contexts + future targets — defaults will surface the
// available scopes in the drawer.
return [];
}
}