Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions QUALITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ synthetic Haiku output and its rendered backend replies, plus explicit contract
Playwright checks all five turns, all paragraphs, three prioritized ACTIONs, contextual
summary/follow-up, partial output and misleading AI metadata. It never calls Anthropic.
The raw model is not the only acceptance layer: visible UI text must match the backend.


## Task 4.6 task fulfilment

Coach replies carry an additive `task` contract. AI provenance is separate from whether the
request was fulfilled. Partial output shows requested/displayed counts; unavailable requests
remain explicit. The five exact real-user question formulations use synthetic stale-history
Haiku recordings, validated and rendered by the backend, then replayed locally in Playwright.
The fixture identifies recorded real outputs and the targeted Q3 rerun, not a second fresh
five-call run. No real Garmin data or paid model calls are used by CI.
15 changes: 14 additions & 1 deletion components/product/wellbeing-coach.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@ function Reply({
(!reply.rendering || reply.rendering.displayedParagraphs > 0);
const partial =
hasAIText &&
(reply.answerStatus === "partial" || reply.completion === "ai_partial");
(reply.answerStatus === "partial" ||
reply.completion === "ai_partial" ||
reply.task?.status === "partial");
return (
<div className="mt-4 text-sm text-slate-700">
<h3 className="font-semibold text-slate-900">{reply.headline}</h3>
Expand Down Expand Up @@ -449,6 +451,17 @@ function Reply({
? "Odgovor iz podataka — bez AI objašnjenja"
: "Evidence-only answer — not AI-generated"}
</p>
{!compact && reply.task?.status !== "complete" && reply.task && (
<p role="status" className="mt-2 text-amber-800">
{hr
? reply.task.status === "unavailable"
? "Za traženi odgovor nema dovoljno podataka."
: `Zahtjev je samo djelomično ispunjen.${reply.task.requestedItems ? ` Prikazano ${reply.task.intent === "action_plan" ? reply.task.actionItems : reply.task.patterns} od ${reply.task.requestedItems} traženih stavki.` : " Nedostaju traženi dijelovi odgovora."}`
: reply.task.status === "unavailable"
? "Insufficient evidence for the requested answer."
: "The request is only partially fulfilled; required answer elements are missing."}
</p>
)}
{!compact && (
<p
aria-label="Coach answer"
Expand Down
10 changes: 9 additions & 1 deletion lib/coach-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ export interface CoachReply {
latestWearableDate: string | null;
latestImportedDate?: string | null;
completion?: "ai_assisted" | "ai_partial" | "evidence_only";
answerStatus?: "complete" | "partial" | "fallback";
answerStatus?: "complete" | "partial" | "fallback" | "unavailable";
partialNotice?: string;
task?: {
intent: string;
status: "complete" | "partial" | "unavailable";
issues: string[];
requestedItems: number;
patterns: number;
actionItems: number;
};
rendering?: {
modelParagraphs: number;
validatedParagraphs: number;
Expand Down
51 changes: 48 additions & 3 deletions tests/coach.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ test("all five Croatian acceptance questions retain context and fulfil their spe
await coach.getByRole("button", { name: "Ask coach", exact: true }).click();
const answer = coach.getByLabel("Coach answer").last();
await expect(answer).toHaveText(acceptance.questions[i].answer);
expect(acceptance.questions[i].reply.task.status).toBe("complete");
expect(acceptance.questions[i].reply.context).toBeTruthy();
if (i === 0) expect(acceptance.questions[i].reply.task.patterns).toBe(3);
if (i === 1)
expect(
(await answer.innerText()).match(/(?:^|\n\n)[12]\. /g),
).toHaveLength(2);
if (i === 2)
expect(acceptance.questions[i].reply.task.intent).toBe(
"personal_context",
);

for (const paragraph of acceptance.questions[i].rawSelection.narrative) {
await expect(answer).toContainText(paragraph.text);
}
Expand All @@ -57,11 +69,16 @@ test("all five Croatian acceptance questions retain context and fulfil their spe
await expect(answer).toContainText("2.");
await expect(answer).toContainText("3.");
await expect(answer).toContainText("Razlog:");
expect(
(await answer.innerText()).match(/Provjera nakon 7 dana/g),
).toHaveLength(3);
}
if (i === 4) {
await expect(answer).toContainText("Glavni obrazac");
await expect(answer).toContainText("penjanje");
await expect(answer).toContainText("kasniji odlasci");
expect(acceptance.questions[i].reply.task.intent).toBe(
"conversation_summary",
);
await expect(answer).toContainText(/penj/i);

await expect(answer).toContainText("Ne znam");
expect(((await answer.innerText()).match(/\?/g) ?? []).length).toBe(1);
}
Expand Down Expand Up @@ -327,3 +344,31 @@ for (const scenario of [
}
});
}

test("missing requested actions stays visibly partial even when all model paragraphs are displayed", async ({
page,
}) => {
await page.setExtraHTTPHeaders({
"x-loadiq-e2e-session": "synthetic-e2e-local-only:alice",
"x-loadiq-e2e-scenario": "contract_incomplete_request",
});
await page.goto("/app");
const coach = page.getByRole("region", { name: "Wellbeing Coach" });
await coach
.getByLabel("Ask your Wellbeing Coach")
.fill("Predloži tri promjene za sljedeći tjedan.");
await coach.getByRole("button", { name: "Ask coach", exact: true }).click();
const expected = acceptance.contracts.incomplete_request;
await expect(coach.getByLabel("Coach answer").last()).toHaveText(
expected.answer,
);
await expect(
coach.getByText("Zahtjev je samo djelomično ispunjen.", { exact: false }),
).toBeVisible();
expect(expected.task.status).toBe("partial");
expect(expected.task.requestedItems).toBe(3);
expect(expected.rendering.displayedParagraphs).toBe(2);
await expect(
coach.getByText("AI odgovor — djelomično dovršen", { exact: false }),
).toBeVisible();
});
Loading
Loading