From 84af00d3a9675919f9a3cf82ed0e4b8ff5e8e1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 14 May 2026 18:18:57 +0200 Subject: [PATCH] feat(ai): safety-contract matrix as YAML per locale (single source of truth) Adds six locale-keyed YAML files plus a Zod-validated loader so the Coach and Insights system prompts can pull their 14 ground rules from a single matrix instead of carrying parallel hand-edited bodies. The matrix marks each rule with surface (coach / insights / both) and parser_critical so downstream tests can distinguish stylistic from safety-load-bearing clauses. GLP-1 brand names, evidence-block sentinels and JSON contract enums are pinned to identical values across every locale. The German body is derived from the existing two-year hand-curated COACH_PROMPT_DE / SYSTEM_PROMPT_DE wording. French / Spanish / Italian / Polish bodies are AI-drafted into the project's formal medical register (vouvoiement / usted / Lei / Pan-Pani). The refusal-probe test landing in a follow-up commit covers each ground rule x locale with 20+ adversarial paraphrasings. --- src/lib/ai/prompts/safety-contracts.de.yaml | 279 ++++++++++++++++ src/lib/ai/prompts/safety-contracts.en.yaml | 346 ++++++++++++++++++++ src/lib/ai/prompts/safety-contracts.es.yaml | 281 ++++++++++++++++ src/lib/ai/prompts/safety-contracts.fr.yaml | 284 ++++++++++++++++ src/lib/ai/prompts/safety-contracts.it.yaml | 284 ++++++++++++++++ src/lib/ai/prompts/safety-contracts.pl.yaml | 286 ++++++++++++++++ src/lib/ai/prompts/safety-contracts.ts | 207 ++++++++++++ 7 files changed, 1967 insertions(+) create mode 100644 src/lib/ai/prompts/safety-contracts.de.yaml create mode 100644 src/lib/ai/prompts/safety-contracts.en.yaml create mode 100644 src/lib/ai/prompts/safety-contracts.es.yaml create mode 100644 src/lib/ai/prompts/safety-contracts.fr.yaml create mode 100644 src/lib/ai/prompts/safety-contracts.it.yaml create mode 100644 src/lib/ai/prompts/safety-contracts.pl.yaml create mode 100644 src/lib/ai/prompts/safety-contracts.ts diff --git a/src/lib/ai/prompts/safety-contracts.de.yaml b/src/lib/ai/prompts/safety-contracts.de.yaml new file mode 100644 index 000000000..b8e7b3371 --- /dev/null +++ b/src/lib/ai/prompts/safety-contracts.de.yaml @@ -0,0 +1,279 @@ +# HealthLog v1.4.25 W14c — safety-contract matrix (DE). +# Translations of safety-contracts.en.yaml. DE bodies are derived from +# the existing hand-curated COACH_PROMPT_DE / SYSTEM_PROMPT_DE bodies in +# `src/lib/ai/coach/system-prompt.ts` and `src/lib/ai/prompts/insight- +# generator.ts` — these have been Marc-reviewed clause-by-clause for +# two years and are the calibration reference for FR/ES/IT/PL. + +ground_rules: + ground_rule_1_zero_hallucination: + parser_critical: true + surface: both + locale: | + Jede Aussage muss auf einer Zahl beruhen, die im übergebenen + SNAPSHOT sichtbar ist. Lässt sich die Aussage nicht einem + Snapshot-Feld zuordnen, lass sie weg. Extrapoliere nicht, beziehe + dich nicht auf "Menschen wie du", berechne keine Risiko-Scores. + must_contain: + - "SNAPSHOT" + + ground_rule_2_evidence_block_sentinel: + parser_critical: true + surface: coach + locale: | + Tragende Zahlen gehören in einen Evidenz-Block am Ende deiner + Antwort, eingerahmt von den Sentinels ---KEYVALUES--- und + ---END---. Format je Zeile: "