mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
fix(coach): mark withheld figures with an elision mark plus a per-message notice
Replace the internal "[unverified]" token the grounding guard left in a Coach reply with the editorial elision mark […], and add a quiet muted caption under the bubble explaining that some figures could not be checked against the user's data. The mark holds the slot grammar-safely mid-sentence, before a surviving unit, and inside a range; the notice carries the meaning. The withheld count rides the existing provenance envelope (unverifiedFigures) through the stream, persistence, and reload, and the fenced document-chat path carries a minimal envelope so its notice survives too. New i18n key across all six locales. Also fix an adjacent reload gap: provenanceFromJson restored only a subset of the serialised envelope, so a persisted suggestion card, confirm action card, and the tool trace were dropped on conversation reload despite the render layer expecting them to survive. Restore them defensively alongside the new field.
This commit is contained in:
1 parent
0b828e2c5a
commit
5ad66af565
24 files changed
+611
-22
No files matched your search
@@ -371,12 +371,42 @@ describe("POST — numeric grounding", () => {
|
||||
.join("");
|
||||
// 999 is not in the document (which says 160) → soft-stripped.
|
||||
expect(reply).not.toContain("999");
|
||||
expect(reply).toContain("[unverified]");
|
||||
expect(reply).toContain("[…]");
|
||||
// The persisted assistant turn carries the corrected prose.
|
||||
const assistantWrite = vi
|
||||
.mocked(appendMessage)
|
||||
.mock.calls.find((c) => c[0].role === "assistant");
|
||||
expect(assistantWrite?.[0].content).toContain("[unverified]");
|
||||
expect(assistantWrite?.[0].content).toContain("[…]");
|
||||
// v1.32.14 — the fenced path rides a MINIMAL provenance envelope so the
|
||||
// per-message notice renders + survives reload: count only, no windows/metrics.
|
||||
expect(assistantWrite?.[0].metricSource).toEqual({
|
||||
windows: [],
|
||||
metrics: [],
|
||||
unverifiedFigures: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("persists no provenance when the reply is clean", async () => {
|
||||
vi.mocked(runStreamingRawCompletionWithFallback).mockResolvedValue({
|
||||
result: {
|
||||
content: "Your LDL reading looks steady overall.",
|
||||
tokensUsed: 20,
|
||||
model: "claude",
|
||||
providerType: "anthropic",
|
||||
},
|
||||
workingProvider: { providerType: "anthropic", instance: {} },
|
||||
fallbackHops: [],
|
||||
} as never);
|
||||
const res = await POST(
|
||||
req("doc-1", { message: "how is my ldl?" }) as never,
|
||||
ctx("doc-1") as never,
|
||||
);
|
||||
await frames(res);
|
||||
const assistantWrite = vi
|
||||
.mocked(appendMessage)
|
||||
.mock.calls.find((c) => c[0].role === "assistant");
|
||||
// v1.32.14 — clean reply → metricSourceJson stays null (no notice on reload).
|
||||
expect(assistantWrite?.[0].metricSource ?? null).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user