Skip to content

fix(insights): keep the Coach evidence block out of the briefing - #1764

Open
MBombeck wants to merge 2 commits into
mainfrom
fix/1761-briefing-sentinel
Open

MBombeck wants to merge 2 commits into
mainfrom
fix/1761-briefing-sentinel

Conversation

@MBombeck

@MBombeck MBombeck commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Refs #1761

The native Insights prompt (fr, es, it, pl) rendered every ground rule from the safety-contract matrix, including the Coach-only rule that asks for a ---KEYVALUES--- block after the reply. The model then wrote the block into dailyBriefing.paragraph, which passed validation, and the hero rendered it as text. EN, DE and the EN-backed locales (ko, nl, pt-BR, ru) never carried the rule.

Prompt

  • groundRuleKeysForSurface(locale, surface) in safety-contracts.ts returns the rules marked for the surface plus both, in matrix order. The native Coach and Insights builders both take their list from it. The Coach list is identical to the old hand-kept order, so the Coach prompt does not change; Insights loses the five Coach-only rules (2, 3, 5, 6, 16).
  • Guard ground-rule-surface-guard.test.ts: per locale and surface the rule set matches the matrix; no Insights prompt in any app locale carries the sentinel, while every Coach prompt still does; and the set of source files that spell the marker or render matrix rule bodies is frozen. Checked by pointing the Insights builder at the Coach rules: eight cases go red.

Output

  • stripKeyValuesBlocks / stripKeyValuesBlocksDeep in coach/keyvalues.ts cut each block via parseKeyValuesSentinel (closed or unterminated, text after a closed block kept, untouched values keep their identity).
  • Applied in gateBriefingBlocks (every model-written field before a reply is stored), in readDailyBriefing / readTrendAnnotations (snapshot, today read, re-roll), and in insightsPayloadForToday (the served advisor payload), so briefings cached before the fix are served clean.
  • Regression tests with the reported fixture: a paragraph carrying the block, the commit gate, and a cached row served through insightsPayloadForToday.

Gates run locally: typecheck, eslint and prettier on the changed files, vitest over src/lib/ai, src/lib/daily, src/lib/insights, src/app/api/insights and the i18n guards (499 files, 9208 tests green).

The native Insights prompt (fr, es, it, pl) rendered every ground rule of
the safety-contract matrix, including the Coach-only rule that asks for a
---KEYVALUES--- block after the reply. The model then wrote the block
into the briefing paragraph and the hero showed it as text.

Both native builders now take their rules from groundRuleKeysForSurface,
which keeps the rules marked for the surface plus the shared ones. The
Coach prompt is unchanged.

The server also strips any evidence block, closed or not, from every
model-written field with the Coach parser: in the commit gate before a
reply is stored, in the briefing reader, and in the payload served for
today, so briefings cached before the fix read clean.

Refs #1761
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant