fix(coach): compose deterministic memory facts in English by default

The deterministic fact-pattern pass fell back to German when no locale was
passed, the same de-default polarity the narrative surface just lost. Fact
text is model-facing memory, so English is the fallback for every locale
without a reviewed body; German stays for German readers.

Also correct the InsightNarrative.locale doc comment — the column holds any
shipped UI locale, not just de/en. Comment only, no SQL change.
This commit is contained in:
Marc-André Bombeck committed 2026-07-18 23:46:34 +02:00
1 parent 93738ae968
commit d6692e3a4b
2 files changed
+6 -2

No files matched your search

+2 -1
View File
@@ -5226,7 +5226,8 @@ model InsightNarrative {
userId String @map("user_id")
/// "week" | "month".
period String
/// Resolved UI locale of the prose ("de" | "en").
/// Resolved UI locale of the prose — any shipped UI locale, not just de/en:
/// the prose is generated per locale, so the row is keyed by it.
locale String
/// UTC YYYY-MM-DD boundary the narrative was generated for.
dateKey String @map("date_key")
+4 -1
View File
@@ -558,7 +558,10 @@ function deterministicFactText(
subject: string,
locale: string | undefined,
): string {
const de = locale?.toLowerCase().startsWith("de") ?? true;
// German only for a German reader; every other locale — and an absent one —
// composes ENGLISH. The fact text is model-facing memory, so English is the
// fallback body; the previous `?? true` made an unknown locale German.
const de = locale?.toLowerCase().startsWith("de") ?? false;
switch (kind) {
case "allergy":
return de