Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat(content-editor): confirm a customer case may be published, not just link it (00280, CE-052, part d) (#1496)
Cihan243b29e2a690
diff --git a/supabase/migrations/00280_content_draft_confirmations.sql b/supabase/migrations/00280_content_draft_confirmations.sqlnew file mode 100644index 000000000..217e2088e--- /dev/null+++ b/supabase/migrations/00280_content_draft_confirmations.sql@@ -0,0 +1,73 @@+-- ============================================================================+-- 00280: Quality phase 3, CE-052 — what only the person can confirm+-- ============================================================================+-- What Quality can't verify on its own becomes a confirm step, never a pass+-- (Content Editor Quality spec §11): a customer's case (their name, logo or+-- results) goes out only with their permission, and only the person knows+-- they have it. Their statement is kept here, with who made it, by what it+-- is about: its kind, and its key (a customer case's, by its claim's words;+-- the page matches a case to it by those words). Category pages' intro+-- facts (CE-054) are confirmed here too.++create table if not exists public.content_draft_confirmations (+ draft_id uuid not null references public.content_drafts(id) on delete cascade,+ kind text not null check (kind in ('customer_case', 'intro_fact')),+ key text not null check (char_length(key) between 1 and 400),+ confirmed_by uuid references public.profiles(id) on delete set null,+ confirmed_at timestamptz not null default now(),+ primary key (draft_id, kind, key)+);++alter table public.content_draft_confirmations enable row level security;+revoke all on table public.content_draft_confirmations from anon, authenticated;+grant select, insert on table public.content_draft_confirmations to authenticated;+grant all on table public.content_draft_confirmations to service_role;++comment on table public.content_draft_confirmations is+ 'Quality CE-052 (00280): what a member confirmed that only they can (a customer case may be published; a category intro''s facts are right), by kind and key, with who and when. Members read their drafts'' and confirm as themselves; no update or delete.';++drop policy if exists "content_draft_confirmations: member select" on public.content_draft_confirmations;+create policy "content_draft_confirmations: member select"+ on public.content_draft_confirmations+ for select+ using (public.content_draft_member(draft_id));++-- A member confirms as themself, now.+drop policy if exists "content_draft_confirmations: member insert" on public.content_draft_confirmations;+create policy "content_draft_confirmations: member insert"+ on public.content_draft_confirmations+ for insert+ with check (+ public.content_draft_member(draft_id)+ and confirmed_by = auth.uid()+ and confirmed_at between now() - interval '1 minute' and now() + interval '1 minute'+ );++create or replace function public.content_draft_confirmations_cap()+returns trigger+language plpgsql+set search_path = ''+as $$+begin+ -- One confirm at a time a draft, so the count holds.+ perform pg_advisory_xact_lock(hashtext('content_draft_confirmations'), hashtext(new.draft_id::text));+ -- Confirmed already: the insert's ON CONFLICT leaves it as it is.+ if exists (+ select 1 from public.content_draft_confirmations+ where draft_id = new.draft_id and kind = new.kind and key = new.key+ ) then+ return new;+ end if;+ if (select count(*) from public.content_draft_confirmations where draft_id = new.draft_id) >= 50 then+ raise exception 'A draft keeps 50 confirmations at most' using errcode = '23514';+ end if;+ return new;+end;+$$;++drop trigger if exists content_draft_confirmations_cap on public.content_draft_confirmations;+create trigger content_draft_confirmations_cap+ before insert on public.content_draft_confirmations+ for each row execute function public.content_draft_confirmations_cap();++notify pgrst, 'reload schema';diff --git a/supabase/schema.sql b/supabase/schema.sqlindex 1584564af..db7e2f4fd 100644--- a/supabase/schema.sql+++ b/supabase/schema.sql@@ -39800,3 +39800,80 @@ comment on table public.catalog_sources isnotify pgrst, 'reload schema';+-- ─────────────────────────────────────────────────────────────────────────+-- migrations/00280_content_draft_confirmations.sql+-- ─────────────────────────────────────────────────────────────────────────+-- ============================================================================+-- 00280: Quality phase 3, CE-052 — what only the person can confirm+-- ============================================================================+-- What Quality can't verify on its own becomes a confirm step, never a pass+-- (Content Editor Quality spec §11): a customer's case (their name, logo or+-- results) goes out only with their permission, and only the person knows+-- they have it. Their statement is kept here, with who made it, by what it+-- is about: its kind, and its key (a customer case's, by its claim's words;+-- the page matches a case to it by those words). Category pages' intro+-- facts (CE-054) are confirmed here too.++create table if not exists public.content_draft_confirmations (+ draft_id uuid not null references public.content_drafts(id) on delete cascade,+ kind text not null check (kind in ('customer_case', 'intro_fact')),+ key text not null check (char_length(key) between 1 and 400),+ confirmed_by uuid references public.profiles(id) on delete set null,+ confirmed_at timestamptz not null default now(),+ primary key (draft_id, kind, key)+);++alter table public.content_draft_confirmations enable row level security;+revoke all on table public.content_draft_confirmations from anon, authenticated;+grant select, insert on table public.content_draft_confirmations to authenticated;+grant all on table public.content_draft_confirmations to service_role;++comment on table public.content_draft_confirmations is+ 'Quality CE-052 (00280): what a member confirmed that only they can (a customer case may be published; a category intro''s facts are right), by kind and key, with who and when. Members read their drafts'' and confirm as themselves; no update or delete.';++drop policy if exists "content_draft_confirmations: member select" on public.content_draft_confirmations;+create policy "content_draft_confirmations: member select"+ on public.content_draft_confirmations+ for select+ using (public.content_draft_member(draft_id));++-- A member confirms as themself, now.+drop policy if exists "content_draft_confirmations: member insert" on public.content_draft_confirmations;+create policy "content_draft_confirmations: member insert"+ on public.content_draft_confirmations+ for insert+ with check (+ public.content_draft_member(draft_id)+ and confirmed_by = auth.uid()+ and confirmed_at between now() - interval '1 minute' and now() + interval '1 minute'+ );++create or replace function public.content_draft_confirmations_cap()+returns trigger+language plpgsql+set search_path = ''+as $$+begin+ -- One confirm at a time a draft, so the count holds.+ perform pg_advisory_xact_lock(hashtext('content_draft_confirmations'), hashtext(new.draft_id::text));+ -- Confirmed already: the insert's ON CONFLICT leaves it as it is.+ if exists (+ select 1 from public.content_draft_confirmations+ where draft_id = new.draft_id and kind = new.kind and key = new.key+ ) then+ return new;+ end if;+ if (select count(*) from public.content_draft_confirmations where draft_id = new.draft_id) >= 50 then+ raise exception 'A draft keeps 50 confirmations at most' using errcode = '23514';+ end if;+ return new;+end;+$$;++drop trigger if exists content_draft_confirmations_cap on public.content_draft_confirmations;+create trigger content_draft_confirmations_cap+ before insert on public.content_draft_confirmations+ for each row execute function public.content_draft_confirmations_cap();++notify pgrst, 'reload schema';+diff --git a/web/messages/en.json b/web/messages/en.jsonindex 3534c9fae..51ad71415 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -4701,6 +4701,9 @@},"estimate": "Ansvisor estimates based on Google's published quality signals. Not a Google score.","addLine": "Add line",+ "confirmCase": "Confirm",+ "confirmCaseFailed": "Couldn't save that confirmation. Try again.",+ "confirmCaseFull": "This page keeps 50 confirmations already.","weightsFor": {"line": "Checks and weights for {type}{detected, select, yes { (detected)} other {}}:","noType": "an article (no page type yet)",@@ -4709,7 +4712,7 @@"article": "an author with experience, sourced claims, short sentences and the answer first.","product": "no author (your brand's), your own product photos, proof for claims, prices that match, shipping and returns, a specs table and short plain copy.","category": "your own product images, your brand's information on its site, prices and claims that match, an intro and a buying FAQ.",- "feature": "your own screenshots and data, sourced metrics, a price that matches, a comparison table, proof per section and use case steps in scannable sections.",+ "feature": "your own screenshots and data, customer cases you may publish, sourced metrics, a price that matches, a comparison table, proof per section and use case steps in scannable sections.","comparison": "an author who says how the picks were made and when they were last checked, balance and a disclosure, a side-by-side table, the summary first."},"tooShort": "Write a few paragraphs: Readability is read from the page as you write.",@@ -4814,7 +4817,14 @@"soften": "Link its proof, or soften the claim","customerCase": "Link the published case, and only with the customer's permission to name them"},- "done": "The proof is linked"+ "done": "The proof is linked",+ "confirmCase": {+ "title": "Confirm you may publish the customer case “{claim}”",+ "next": "confirm the customer case",+ "detail": "A customer's name, logo or results go out only with their permission: confirm you have it",+ "done": "You confirmed the customer may be named",+ "link": "Linking the published case raises Trust too (+{gain, number} Trust)"+ }},"title": "Your to-dos","left": "{count, plural, =0 {All done} other {# left · only you can do these}}",@@ -4877,7 +4887,8 @@"confirmImage": "Confirm now","pickReviewer": "Pick now","addImage": "Add now",- "addCheckDate": "Add now"+ "addCheckDate": "Add now",+ "confirmCase": "Confirm now"},"later": "Later"},diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsxindex 622258dc3..9e853c577 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx@@ -46,7 +46,9 @@ import {setContentDraftReviewer,confirmDraftAuthor,keepDraftSource,+ confirmDraftItem,confirmOwnImage,+ getDraftConfirmations,getOwnImages,setContentDraftPageType,startAgentWriting,@@ -124,7 +126,7 @@ import {weighed,weighedTrust,} from '@/lib/content/quality-profiles';-import { proofKey, qualityTodos } from '@/lib/content/quality-todos';+import { caseConfirmed, caseKey, proofKey, qualityTodos } from '@/lib/content/quality-todos';import { isByline, readability, sentencesOf, withTypeRules } from '@/lib/content/readability';import { brandFactsPath, factMismatches } from '@/lib/content/brand-facts';import {@@ -767,9 +769,7 @@ export function DraftEditor({// A comparison's check date (CE-052): E-E-A-T's check and its to-do.const checkDateRead = useMemo(() =>- qualityOn && profile === 'comparison'- ? checkDateOnPage(pageBlocks.map((b) => b.text))- : null,+ qualityOn && profile === 'comparison' ? checkDateOnPage(pageBlocks.map((b) => b.text)) : null,[qualityOn, profile, pageBlocks],);// A product page's shipping and returns (CE-052): Trust's check, and a@@ -814,10 +814,57 @@ export function DraftEditor({// A proof to-do asked for this session stays, checked once it has a link.const [hadProofs, setHadProofs] = useState<ReadonlySet<string>>(() => new Set());// The ones shown open: the first MAX_PROOF_TODOS with no link, as the to-dos list them.+ // Phase 3 (CE-052): a customer case is confirmed publishable, not linked.+ const casesOn = sourcesOn && qualityPhase() >= 3;+ const [caseConfirms, setCaseConfirms] = useState<ReadonlySet<string> | null>(null);+ // Whether they're read (or failed): until then a case's to-do waits, so+ // one confirmed before doesn't show open.+ const [casesRead, setCasesRead] = useState(false);+ useEffect(() => {+ if (!casesOn) return;+ let live = true;+ void getDraftConfirmations(draft.id)+ .then((rows) => {+ if (!live) return;+ setCasesRead(true);+ // A confirm made before the read lands stays.+ setCaseConfirms(+ (prev) =>+ new Set([+ ...rows.filter((r) => r.kind === 'customer_case').map((r) => r.key),+ ...(prev ?? []),+ ]),+ );+ })+ .catch((err) => {+ // A failed call (the network, a deploy): the confirms made so far, so E-E-A-T scores.+ console.error('Failed to read the confirmations:', err);+ if (!live) return;+ setCasesRead(true);+ setCaseConfirms((prev) => prev ?? new Set());+ });+ return () => {+ live = false;+ };+ }, [draft.id, casesOn]);+ // The page's customer cases, and how many are confirmed: E-E-A-T's (CE-052).+ const caseCount = useMemo(() => {+ if (!casesOn) return null;+ const asks = proofAsks.filter((ask) => ask.kind === 'customer_case');+ const confirms = caseConfirms ?? new Set<string>();+ return {+ total: asks.length,+ confirmed: asks.filter((ask) => caseConfirmed(confirms, ask)).length,+ };+ }, [casesOn, proofAsks, caseConfirms]);+ const isCase = (ask: (typeof proofAsks)[number]) => casesOn && ask.kind === 'customer_case';+ // A case's to-do once the confirms are read: open while not confirmed.+ const caseOpen = (ask: (typeof proofAsks)[number]) =>+ isCase(ask) ? casesRead && !caseConfirmed(caseConfirms ?? new Set(), ask) : !ask.linked;const newProofs = proofAsks- .filter((ask) => !ask.linked)+ .filter(caseOpen).slice(0, MAX_PROOF_TODOS)- .map(proofKey)+ .map((ask) => (isCase(ask) ? caseKey(ask) : proofKey(ask))).filter((key) => !hadProofs.has(key));if (newProofs.length > 0) setHadProofs(new Set([...hadProofs, ...newProofs]));// The page's images the person confirmed are their own, not stock (CE-049,@@ -858,7 +905,13 @@ export function DraftEditor({const brandInfoRead = !waitsForSiteTrust(profile) || siteTrustRead;const eeatScore = useMemo(() =>- qualityOn && authorsRead && !inputsPending && (!sourcesOn || visualRead) && brandInfoRead+ qualityOn &&+ authorsRead &&+ !inputsPending &&+ (!sourcesOn || visualRead) &&+ brandInfoRead &&+ // Phase 3: the customer cases' confirms are read (CE-052).+ (!casesOn || casesRead)? weighed(eeat({author: pageAuthor,@@ -869,6 +922,7 @@ export function DraftEditor({// The brand's own information: only a type that weighs it counts it.siteTrust,checkDate: checkDateRead === null ? null : checkDateRead.found,+ cases: caseCount,}),weights.eeat,)@@ -886,6 +940,9 @@ export function DraftEditor({authorConfirmed,siteTrust,checkDateRead,+ casesOn,+ casesRead,+ caseCount,brandInfoRead,weights,],@@ -896,6 +953,24 @@ export function DraftEditor({const pageReviewer = authorsRead?.authors.find((a) => a.id === reviewerId) ?? null;// Confirm: only the person can tell their own image from stock.const [confirmingImages, setConfirmingImages] = useState(false);+ // Quality's Confirm on a customer case (CE-052): the person's statement+ // that the customer may be named; put back if it can't be saved.+ const confirmCase = async (key: string) => {+ if (caseConfirms?.has(key)) return;+ setCaseConfirms((prev) => new Set([...(prev ?? []), key]));+ const takeBack = () =>+ setCaseConfirms((prev) => new Set([...(prev ?? [])].filter((had) => had !== key)));+ try {+ if ((await confirmDraftItem(draft.id, 'customer_case', key)) === 'full') {+ takeBack();+ toast.error(t('quality.confirmCaseFull'));+ }+ } catch (err) {+ console.error('Failed to confirm the customer case:', err);+ takeBack();+ toast.error(t('quality.confirmCaseFailed'));+ }+ };const confirmImage = async (src: string) => {// Already confirmed: nothing to take back if the save fails.const had = ownImages?.has(src) ?? false;@@ -1092,12 +1167,19 @@ export function DraftEditor({given: inputs ? inputsGiven(inputs) : null,trust: trustScore,brandFacts: brandFacts ? { pending: pendingFacts, had: hadPendingFacts } : null,- proofs: sourcesOn ? { asks: proofAsks, had: hadProofs } : null,+ // A case's to-do waits for the confirms' read (CE-052).+ proofs: sourcesOn+ ? {+ asks: casesOn && !casesRead ? proofAsks.filter((ask) => !isCase(ask)) : proofAsks,+ had: hadProofs,+ }+ : null,visual,// Once the authors are read: who the reviewer is, and whether any can be.reviewer: regulated && authorsRead ? { topic: regulated, picked: !!pageReviewer } : null,confirmed: authorConfirmed,shipping: shippingRead,+ cases: casesOn ? (caseConfirms ?? new Set<string>()) : null,checkDate:checkDateRead === null ? null : { ...checkDateRead, line: checkDateText(language) },off: checksOff(profile),@@ -1105,6 +1187,9 @@ export function DraftEditor({: [];const quality: QualityRead | null = qualityOn? {+ caseSentences: casesOn+ ? proofAsks.filter((ask) => ask.kind === 'customer_case').map((ask) => ask.sentence)+ : [],weightsFor:qualityPhase() >= 3? { type: pageType ?? null, detected: picked === null, profile }@@ -1999,10 +2084,22 @@ export function DraftEditor({return;}const items = handOffList;+ const context = agentContext(editor);+ // The customer cases' paragraphs (CE-052): the person vouches for them,+ // so the agent leaves them as it leaves a locked passage.+ const cases = casesOn+ ? proofAsks.filter((ask) => ask.kind === 'customer_case').map((ask) => ask.block)+ : [];setHandingOff(true);try {await runAgentFix(- () => handOffDraft(draft.id, draft.brandId, { items, origin, ...agentContext(editor) }),+ () =>+ handOffDraft(draft.id, draft.brandId, {+ items,+ origin,+ ...context,+ locked: [...context.locked, ...cases],+ }),handedOff,origin === 'auto',);@@ -3277,6 +3374,7 @@ export function DraftEditor({onPickAuthor={() => setAuthorMenuOpen(true)}onPickReviewer={() => setReviewerMenuOpen(true)}onAddCheckDate={htmlSource === null ? addCheckDate : undefined}+ onConfirmCase={(key) => void confirmCase(key)}onAddInput={addInput}onAddSource={sourcesOn ? addSource : undefined}onConfirmImages={() => setConfirmingImages(true)}@@ -3320,6 +3418,7 @@ export function DraftEditor({onPickAuthor={() => setAuthorMenuOpen(true)}onPickReviewer={() => setReviewerMenuOpen(true)}onAddCheckDate={htmlSource === null ? addCheckDate : undefined}+ onConfirmCase={(key) => void confirmCase(key)}onChangeType={() => setTypeMenuOpen(true)}handOff={handOffCard}yourInput={inputsRead.status === 'off' ? null : inputsRead}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.tsxindex a6181b005..879e64e48 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_next-nudge.tsx@@ -96,6 +96,7 @@ export function NextNudge({onAddImage,onPickReviewer,onAddCheckDate,+ onConfirmCase,onLater,onAct,}: {@@ -115,6 +116,7 @@ export function NextNudge({/** A regulated page's: the header's reviewer menu (CE-049). */onPickReviewer?: () => void;onAddCheckDate?: () => void;+ onConfirmCase?: (key: string) => void;onLater: () => void;/** It was acted on: it goes. */onAct: () => void;@@ -222,6 +224,20 @@ export function NextNudge({{t('act.pickReviewer')}</button>)+ ) : action === 'confirmCase' ? (+ onConfirmCase &&+ shown.todo.key && (+ <button+ type="button"+ className={actClass}+ onClick={() => {+ onAct();+ onConfirmCase(shown.todo.key!);+ }}+ >+ {t('act.confirmCase')}+ </button>+ )) : action === 'addCheckDate' ? (onAddCheckDate && (<buttondiff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsxindex ab88fc3c3..04c0e9611 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.test.tsx@@ -15,7 +15,7 @@ vi.mock('@/i18n/navigation', () => ({),}));-const { QualityTab, qualitySuggestions } = await import('./_quality-tab');+const { QualityTab, proofSentences, qualitySuggestions } = await import('./_quality-tab');type QualityRead = import('./_quality-tab').QualityRead;type HandOff = import('./_quality-tab').HandOff;@@ -187,6 +187,29 @@ describe('QualityTab', () => {expect(container.textContent).toContain('Say how shipping and returns work');});+ it('keeps a customer case’s sentence the person’s, confirmed or not, out of the agent’s sources (CE-052)', () => {+ const sentence = 'Acme cut close time 40% with Ledgerly.';+ expect(proofSentences([], [sentence])).toEqual(new Set([sentence]));+ // An open proof to-do's sentence, as before.+ expect(+ proofSentences([+ {+ id: 'proof',+ done: false,+ gain: 3,+ score: 'trust',+ action: 'addProof',+ proof: {+ claim: 'ISO 27001',+ block: 'We are ISO 27001.',+ kind: 'certification',+ sentence: 'We are ISO 27001.',+ },+ },+ ]),+ ).toEqual(new Set(['We are ISO 27001.']));+ });+it('shows the three scores with their bands, labelled an Ansvisor estimate', async () => {await render(result);const scores = container.querySelector('[aria-label="Quality scores"]')!;diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsxindex 22f76d69d..061c3e24b 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_quality-tab.tsx@@ -35,6 +35,11 @@ import { MANAGE_AUTHORS_PATH } from './_author-menu';/** What Quality reads from the draft and its author, for the segment and the header. */export interface QualityRead {+ /**+ * Phase 3 (CE-052): the page's customer cases' sentences: the person+ * confirms them, so Hand off never sources or removes them.+ */+ caseSentences?: string[];/*** Phase 3 (CE-052): the page type the checks and weights follow, whether* it was detected (not picked), and its profile; left out before.@@ -145,6 +150,7 @@ export function QualityTab({onAddImage,onPickReviewer,onAddCheckDate,+ onConfirmCase,handOff = null,onConfirmAuthor,onChangeType,@@ -176,6 +182,8 @@ export function QualityTab({onPickReviewer?: () => void;/** A comparison's check date to-do: Add line puts this month's under the answer (CE-052). */onAddCheckDate?: () => void;+ /** A customer case's Confirm: the person says the customer may be named (CE-052). */+ onConfirmCase?: (key: string) => void;/** Hand it off to Content Agent (CE-051): with Quality's phase 2. */handOff?: HandOff | null;}) {@@ -274,6 +282,7 @@ export function QualityTab({onAddImage={onAddImage}onPickReviewer={onPickReviewer}onAddCheckDate={onAddCheckDate}+ onConfirmCase={onConfirmCase}onConfirm={onConfirmAuthor}/>))}@@ -435,6 +444,17 @@ export function useTodoCopy() {};}// The page's own claims, their proof asked for by kind and business (CE-049).+ // A customer case in Phase 3 (CE-052): confirmed publishable, not linked.+ if (todo.id === 'proof' && todo.proof && todo.action === 'confirmCase') {+ return {+ title: t('proof.confirmCase.title', { claim: todo.proof.claim }),+ next: t('proof.confirmCase.next'),+ detail: [+ todo.done ? t('proof.confirmCase.done') : t('proof.confirmCase.detail'),+ ...(todo.trustGain ? [t('proof.confirmCase.link', { gain: todo.trustGain })] : []),+ ].join('. '),+ };+ }if (todo.id === 'proof' && todo.proof) {const { claim, kind } = todo.proof;return {@@ -575,6 +595,7 @@ function TodoRow({onAddImage,onPickReviewer,onAddCheckDate,+ onConfirmCase,onConfirm,}: {todo: QualityTodo;@@ -589,6 +610,8 @@ function TodoRow({onPickReviewer?: () => void;/** A comparison's check date to-do: Add line puts this month's under the answer (CE-052). */onAddCheckDate?: () => void;+ /** A customer case's Confirm: the person says the customer may be named (CE-052). */+ onConfirmCase?: (key: string) => void;onConfirm?: (what: 'real' | 'profile', on: boolean) => void;}) {const t = useTranslations('contentEditor.editor.quality');@@ -711,6 +734,18 @@ function TodoRow({{t('pickReviewer')}</Button>)+ ) : todo.action === 'confirmCase' ? (+ onConfirmCase &&+ todo.key && (+ <Button+ variant="outline"+ size="sm"+ className="h-7 shrink-0"+ onClick={() => onConfirmCase(todo.key!)}+ >+ {t('confirmCase')}+ </Button>+ )) : todo.action === 'addCheckDate' ? (onAddCheckDate && (<Button variant="outline" size="sm" className="h-7 shrink-0" onClick={onAddCheckDate}>@@ -769,7 +804,7 @@ const againstHandOff = (check: ReadabilityCheck) =>export function qualitySuggestions(t: T, quality: QualityRead): Suggestion[] {return [...readabilitySuggestions(t, quality.readability),- ...trustSuggestions(t, quality.trust, proofSentences(quality.todos), {+ ...trustSuggestions(t, quality.trust, proofSentences(quality.todos, quality.caseSentences), {balanced: quality.aiChecks?.balanced ?? null,disclosure: quality.aiChecks?.disclosure ?? null,brand: quality.brandName,@@ -1023,7 +1058,14 @@ function detail(t: T, check: ReadabilityCheck): string {return t(`checks.${check.id}.detail`);}-/** The sentences the open proof to-dos ask the person to prove (CE-049). */-export function proofSentences(todos: readonly QualityTodo[]): ReadonlySet<string> {- return new Set(todos.flatMap((todo) => (todo.proof && !todo.done ? [todo.proof.sentence] : [])));+/** The sentences the open proof to-dos ask the person to prove (CE-049), and its customer cases'. */+export function proofSentences(+ todos: readonly QualityTodo[],+ /** Phase 3 (CE-052): the page's customer cases' sentences, confirmed or not: the person's. */+ cases: readonly string[] = [],+): ReadonlySet<string> {+ return new Set([+ ...todos.flatMap((todo) => (todo.proof && !todo.done ? [todo.proof.sentence] : [])),+ ...cases,+ ]);}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsxindex 6c95c1dc6..fcfb8d12c 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_side-panel.tsx@@ -140,6 +140,7 @@ export function EditorSidePanel({onAddImage,onPickReviewer,onAddCheckDate,+ onConfirmCase,onChangeType,handOff = null,}: {@@ -212,6 +213,8 @@ export function EditorSidePanel({onPickReviewer?: () => void;/** Quality's Add line for a comparison's check date (CE-052). */onAddCheckDate?: () => void;+ /** Quality's Confirm on a customer case (CE-052). */+ onConfirmCase?: (key: string) => void;/** Quality's Change: the header's page type menu (CE-052). */onChangeType?: () => void;/** Hand it off to Content Agent, Quality's (CE-051). */@@ -469,6 +472,7 @@ export function EditorSidePanel({onAddImage={onAddImage}onPickReviewer={onPickReviewer}onAddCheckDate={onAddCheckDate}+ onConfirmCase={onConfirmCase}onChangeType={onChangeType}handOff={handOff}/>diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsxindex e29e057fa..aa4b48bea 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx@@ -25,6 +25,8 @@ const confirmDraftAuthor = vi.fn();const checkDraftClaims = vi.fn();const readDraftPage = vi.fn();const getOwnImages = vi.fn();+const getDraftConfirmations = vi.fn();+const confirmDraftItem = vi.fn();const confirmOwnImage = vi.fn();const getBrandFacts = vi.fn();const checkDraftLinks = vi.fn();@@ -106,6 +108,8 @@ vi.mock('@/lib/actions/content-drafts', () => ({checkDraftClaims: (...args: unknown[]) => checkDraftClaims(...args),readDraftPage: (...args: unknown[]) => readDraftPage(...args),getOwnImages: (...args: unknown[]) => getOwnImages(...args),+ getDraftConfirmations: (...args: unknown[]) => getDraftConfirmations(...args),+ confirmDraftItem: (...args: unknown[]) => confirmDraftItem(...args),confirmOwnImage: (...args: unknown[]) => confirmOwnImage(...args),checkDraftLinks: (...args: unknown[]) => checkDraftLinks(...args),}));@@ -313,6 +317,8 @@ beforeEach(() => {checkDraftClaims.mockReset().mockResolvedValue({ blocks: [], pending: 0, limited: false });readDraftPage.mockReset().mockResolvedValue({ error: 'off' });getOwnImages.mockReset().mockResolvedValue([]);+ getDraftConfirmations.mockReset().mockResolvedValue([]);+ confirmDraftItem.mockReset().mockResolvedValue('ok');confirmOwnImage.mockReset().mockResolvedValue('ok');getBrandFacts.mockReset().mockResolvedValue({facts: [],@@ -3235,6 +3241,47 @@ describe('the side panel', () => {expect(link?.textContent).toBe('the fastest forecasting app');});+ it('asks a feature page to confirm a customer case may be published, in phase 3 (CE-052)', async () => {+ process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '3';+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });+ const block = 'Acme cut its close time by 40% with Ledgerly in one quarter.';+ readDraftPage.mockResolvedValue({+ spots: [],+ proofs: [{ claim: 'Acme cut its close time by 40%', block, kind: 'customer_case' }],+ regulated: null,+ pending: false,+ limited: false,+ paused: false,+ });+ getContentDraft.mockResolvedValue({+ ...claimed,+ pageType: 'feature_page',+ bodyHtml: `${claimed.bodyHtml}<p>${block}</p>`,+ });+ window.innerWidth = 1440;+ await renderPage();+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));+ expect(getDraftConfirmations).toHaveBeenCalledWith('d1');+ const chip = [...container.querySelectorAll<HTMLButtonElement>('header button')].find((b) =>+ b.textContent?.startsWith('Quality'),+ )!;+ await act(async () => chip.click());+ const row = () =>+ [...panel()!.querySelectorAll('li')].find((li) =>+ li.textContent?.includes('Confirm you may publish the customer case'),+ )!;+ expect(row().textContent).toContain('only with their permission');+ await act(async () =>+ [...row().querySelectorAll('button')].find((b) => b.textContent === 'Confirm')!.click(),+ );+ expect(confirmDraftItem).toHaveBeenCalledWith(+ 'd1',+ 'customer_case',+ expect.stringMatching(/^case:/),+ );+ expect(row().textContent).toContain('You confirmed the customer may be named');+ });+it("asks for the proof of the brand's own claim, and Add proof link selects it (CE-049)", async () => {process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '2';vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });@@ -3301,6 +3348,51 @@ describe('the side panel', () => {expect(done.textContent).toContain('The proof is linked');});+ it('hands off with the customer cases’ paragraphs left as they are, in phase 3 (#1496 review)', async () => {+ process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '3';+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });+ getContentAuthors.mockResolvedValue({+ authors: [],+ brands: [{ id: 'b1', name: 'Ledgerly' }],+ me: { id: 'u1', role: 'admin' },+ });+ const block = 'Acme cut its close time by 40% with Ledgerly in one quarter.';+ readDraftPage.mockResolvedValue({+ spots: [],+ proofs: [{ claim: 'Acme cut its close time by 40%', block, kind: 'customer_case' }],+ regulated: null,+ pending: false,+ limited: false,+ paused: false,+ });+ const long = `Teams ${Array.from({ length: 39 }, () => 'plan').join(' ')}.`;+ getContentDraft.mockResolvedValue({+ ...claimed,+ pageType: 'feature_page',+ bodyHtml: `${claimed.bodyHtml}<p>${block}</p><p>${long}</p>`,+ });+ window.innerWidth = 1440;+ await renderPage();+ await act(async () => void (await vi.advanceTimersByTimeAsync(3_000)));+ const chip = [...container.querySelectorAll<HTMLButtonElement>('header button')].find((b) =>+ b.textContent?.startsWith('Quality'),+ )!;+ await act(async () => chip.click());+ const card = panel()!.querySelector('[aria-label="Hand it off to Content Agent"]')!;+ await act(async () =>+ [...card.querySelectorAll<HTMLButtonElement>('button')]+ .find((b) => b.textContent === 'Hand off')!+ .click(),+ );+ await act(async () => void (await vi.advanceTimersByTimeAsync(0)));+ // The server leaves a locked passage as it is: the case's paragraph is one.+ expect(handOffDraft).toHaveBeenCalledWith(+ 'd1',+ 'b1',+ expect.objectContaining({ locked: expect.arrayContaining([block]) }),+ );+ });+it("hands the page's open Quality suggestions off to the agent in one run (CE-051)", async () => {process.env.NEXT_PUBLIC_CONTENT_QUALITY_PHASE = '2';vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });diff --git a/web/src/lib/actions/content-drafts.test.ts b/web/src/lib/actions/content-drafts.test.tsindex 300b4cdd6..8726d1d55 100644--- a/web/src/lib/actions/content-drafts.test.ts+++ b/web/src/lib/actions/content-drafts.test.ts@@ -109,6 +109,8 @@ const {unmarkContentDraftReady,confirmOwnImage,getOwnImages,+ confirmDraftItem,+ getDraftConfirmations,setContentDraftReviewer,} = await import('./content-drafts');const { bodyHash } = await import('@/lib/content/editor');@@ -421,6 +423,33 @@ describe('own images (Quality CE-049, 00270)', () => {});});+describe('confirmations (Quality CE-052, 00280)', () => {+ const KEY = 'proof:Acmecutclosetime40%:abc123';++ it("reads the draft's confirmations by kind and key, leaving out kinds it doesn't know", async () => {+ list = [+ { kind: 'customer_case', key: KEY },+ { kind: 'something_new', key: 'x' },+ ];+ expect(await getDraftConfirmations(DRAFT)).toEqual([{ kind: 'customer_case', key: KEY }]);+ expect(calls[0].filters).toEqual([['eq', 'draft_id', DRAFT]]);+ expect(await getDraftConfirmations('d1')).toEqual([]);+ });++ it('confirms one as the member, now, once; says when the draft keeps 50', async () => {+ expect(await confirmDraftItem(DRAFT, 'customer_case', KEY)).toBe('ok');+ const { value, options } = calls[0].value as { value: unknown; options: unknown };+ expect(value).toEqual({ draft_id: DRAFT, kind: 'customer_case', key: KEY, confirmed_by: 'u1' });+ expect(options).toEqual({ onConflict: 'draft_id,kind,key', ignoreDuplicates: true });+ upsertError = { code: '23514', message: 'A draft keeps 50 confirmations at most' };+ expect(await confirmDraftItem(DRAFT, 'customer_case', KEY)).toBe('full');+ await expect(confirmDraftItem(DRAFT, 'other' as 'customer_case', KEY)).rejects.toThrow(+ 'invalid',+ );+ await expect(confirmDraftItem(DRAFT, 'customer_case', '')).rejects.toThrow('invalid');+ });+});+describe('confirmDraftAuthor (00271)', () => {it('ticks or unticks the author the site names, or their profile; the database stamps who and when', async () => {updated = { id: DRAFT };diff --git a/web/src/lib/actions/content-drafts.ts b/web/src/lib/actions/content-drafts.tsindex 85b38da56..5a95b1f0a 100644--- a/web/src/lib/actions/content-drafts.ts+++ b/web/src/lib/actions/content-drafts.ts@@ -2651,3 +2651,68 @@ export async function confirmOwnImage(id: string, src: string): Promise<'ok' | 'if (error) throw new Error(error.message);return 'ok';}++/** What a member can confirm on a draft that only they know (Quality CE-052, 00280). */+export type ConfirmationKind = 'customer_case' | 'intro_fact';+const confirmationKind = z.enum(['customer_case', 'intro_fact']);+const confirmationKey = z.string().min(1).max(400);++/**+ * The draft's confirmations (00280): what a member said only they could (a+ * customer case may be published; a category intro's facts are right), by+ * kind and key. Fails soft: none, when they can't be read.+ */+export async function getDraftConfirmations(+ id: string,+): Promise<{ kind: ConfirmationKind; key: string }[]> {+ if (!draftId.safeParse(id).success) return [];+ try {+ const supabase = await createClient();+ const { data, error } = await supabase+ .from('content_draft_confirmations')+ .select('kind, key')+ .eq('draft_id', id);+ if (error) throw new Error(error.message);+ return (data ?? []).flatMap((row) =>+ confirmationKind.safeParse(row.kind).success+ ? [{ kind: row.kind as ConfirmationKind, key: row.key }]+ : [],+ );+ } catch (err) {+ console.error('Failed to read the confirmations:', err);+ return [];+ }+}++/**+ * Confirms one (00280): the member's statement, kept with who made it, as+ * themself and now. Confirmed already is fine; 'full' when the draft keeps 50.+ */+export async function confirmDraftItem(+ id: string,+ kind: ConfirmationKind,+ key: string,+): Promise<'ok' | 'full'> {+ if (+ !draftId.safeParse(id).success ||+ !confirmationKind.safeParse(kind).success ||+ !confirmationKey.safeParse(key).success+ ) {+ throw new Error('invalid');+ }+ const supabase = await createClient();+ const {+ data: { user },+ } = await supabase.auth.getUser();+ if (!user) throw new Error('not_found');+ const { error } = await supabase+ .from('content_draft_confirmations')+ // When: the database's now (its default), the time its policy checks against.+ .upsert(+ { draft_id: id, kind, key, confirmed_by: user.id },+ { onConflict: 'draft_id,kind,key', ignoreDuplicates: true },+ );+ if (error?.code === OWN_IMAGES_FULL) return 'full';+ if (error) throw new Error(error.message);+ return 'ok';+}diff --git a/web/src/lib/content/quality-checks.test.ts b/web/src/lib/content/quality-checks.test.tsindex b727f87d4..3a61c1beb 100644--- a/web/src/lib/content/quality-checks.test.ts+++ b/web/src/lib/content/quality-checks.test.ts@@ -802,3 +802,13 @@ describe('trust: a product page’s shipping and returns (Phase 3, CE-052)', ()expect(run(null).shipping).toBeNull();});});++describe('eeat: customer cases (Phase 3, CE-052)', () => {+ it('counts the share confirmed publishable, and none where the page has no case', () => {+ const check = (cases: { total: number; confirmed: number } | null) =>+ eeat({ author: null, cases }).checks.find((c) => c.id === 'customerCase');+ expect(check({ total: 2, confirmed: 1 })).toEqual({ id: 'customerCase', points: 5, max: 10 });+ expect(check({ total: 0, confirmed: 0 })).toBeUndefined();+ expect(check(null)).toBeUndefined();+ });+});diff --git a/web/src/lib/content/quality-checks.ts b/web/src/lib/content/quality-checks.tsindex a8cfc6b2b..4126d90da 100644--- a/web/src/lib/content/quality-checks.ts+++ b/web/src/lib/content/quality-checks.ts@@ -45,11 +45,15 @@ export const EEAT_WEIGHTS = {brandInfo: 0,// Phase 3 (CE-052): a comparison's visible check date; weighed there.checkDate: 0,+ // Phase 3 (CE-052): a feature page's customer cases, confirmed publishable.+ customerCase: 0,} as const;/** The brand info check's points before a page type weighs it (weighed keeps its share). */const BRAND_INFO_POINTS = 10;/** The check date's points before a page type weighs it. */const CHECK_DATE_POINTS = 10;+/** The customer cases' points before a page type weighs them. */+const CUSTOMER_CASE_POINTS = 10;export type EeatCheckId = keyof typeof EEAT_WEIGHTS;/**@@ -280,8 +284,15 @@ export function eeat({confirmed = null,siteTrust = null,checkDate = null,+ cases = null,}: {author: ContentAuthor | null;+ /**+ * Phase 3 (CE-052): the page's customer cases (its proof asks of that+ * kind) and how many the person confirmed may be published; left out+ * where it has none.+ */+ cases?: { total: number; confirmed: number } | null;/*** Phase 3 (CE-052): whether a comparison shows when its products were* last checked (pageCheckDate); left out elsewhere.@@ -366,6 +377,15 @@ export function eeat({: 0,max: EEAT_WEIGHTS.authorBio,},+ ...(cases && cases.total > 0+ ? [+ {+ id: 'customerCase' as const,+ points: (CUSTOMER_CASE_POINTS * Math.min(cases.confirmed, cases.total)) / cases.total,+ max: CUSTOMER_CASE_POINTS,+ },+ ]+ : []),...(checkDate !== null? [{diff --git a/web/src/lib/content/quality-profiles.test.ts b/web/src/lib/content/quality-profiles.test.tsindex 12c4bf8b0..3ed5dddac 100644--- a/web/src/lib/content/quality-profiles.test.ts+++ b/web/src/lib/content/quality-profiles.test.ts@@ -58,6 +58,7 @@ describe('PROFILE_WEIGHTS', () => {expect([...checksOff('article')].sort()).toEqual(['brandInfo','checkDate',+ 'customerCase','shippingReturns','typeRules',]);diff --git a/web/src/lib/content/quality-profiles.ts b/web/src/lib/content/quality-profiles.tsindex abd06c80d..714a7896d 100644--- a/web/src/lib/content/quality-profiles.ts+++ b/web/src/lib/content/quality-profiles.ts@@ -85,6 +85,7 @@ export const PROFILE_WEIGHTS: Readonly<Record<QualityProfile, ProfileWeights>> =authorSchema: 0,brandInfo: 0,checkDate: 0,+ customerCase: 0,},trust: {claimsSourced: 25,@@ -125,6 +126,7 @@ export const PROFILE_WEIGHTS: Readonly<Record<QualityProfile, ProfileWeights>> =authorSchema: 0,brandInfo: 40,checkDate: 0,+ customerCase: 0,},trust: {claimsSourced: 25,@@ -150,20 +152,22 @@ export const PROFILE_WEIGHTS: Readonly<Record<QualityProfile, ProfileWeights>> =typeRules: 30,},},- // Product screenshots weigh most, then the person's data and use;+ // Product screenshots weigh most, then real customer cases (confirmed+ // publishable) and the person's data and use;// sourced metrics and a price that matches; scannable sections.feature: {eeat: {- experience: 25,- originalData: 25,+ experience: 20,+ originalData: 20,byline: 0,authorBio: 0,- visualProof: 50,+ visualProof: 35,whoHowWhy: 0,dates: 0,authorSchema: 0,brandInfo: 0,checkDate: 0,+ customerCase: 25,},trust: {claimsSourced: 35,@@ -205,6 +209,7 @@ export const PROFILE_WEIGHTS: Readonly<Record<QualityProfile, ProfileWeights>> =authorSchema: 0,brandInfo: 0,checkDate: 20,+ customerCase: 0,},trust: {claimsSourced: 25,diff --git a/web/src/lib/content/quality-todos.test.ts b/web/src/lib/content/quality-todos.test.tsindex 1f809e2fc..2c8327937 100644--- a/web/src/lib/content/quality-todos.test.ts+++ b/web/src/lib/content/quality-todos.test.ts@@ -3,7 +3,7 @@ import type { ContentAuthor } from './authors';import type { PageProof } from './page-read';import { eeat, trust, trustBlocks } from './quality-checks';import { PROFILE_WEIGHTS, checksOff, weighed, weighedTrust } from './quality-profiles';-import { proofKey, qualityTodos } from './quality-todos';+import { caseConfirmed, caseKey, proofKey, qualityTodos } from './quality-todos';/** Your to-dos (Quality spec §4, CE-040): only what the person can do, read from the checks. */@@ -134,6 +134,104 @@ describe('qualityTodos', () => {expect(run({ found: true, old: null, line: 'x' })).not.toHaveProperty('old');});+ it('asks to confirm a customer case may be published, not to link it, in Phase 3 (CE-052)', () => {+ const ask = (linked: boolean, kind: 'customer_case' | 'award' = 'customer_case') => ({+ claim: 'Acme cut close time 40%',+ block: 'Acme cut close time 40% with Ledgerly.',+ kind,+ sentence: 'Acme cut close time 40% with Ledgerly.',+ linked,+ });+ const run = (+ a: ReturnType<typeof ask>,+ cases: ReadonlySet<string> | null,+ had: string[] = [],+ ) =>+ qualityTodos({+ eeat: weighed(+ eeat({+ author: null,+ cases: { total: 1, confirmed: cases?.has(caseKey(a)) ? 1 : 0 },+ }),+ PROFILE_WEIGHTS.feature.eeat,+ ),+ author: null,+ hasAuthors: true,+ proofs: { asks: [a], had: new Set(had) },+ cases,+ off: checksOff('feature'),+ }).find((t) => t.id === 'proof');+ // Linked isn't enough: only the person knows they may name the customer.+ expect(run(ask(true), new Set())).toMatchObject({+ done: false,+ action: 'confirmCase',+ score: 'eeat',+ key: caseKey(ask(true)),+ });+ expect(run(ask(true), new Set())!.gain).toBeGreaterThan(0);+ expect(run(ask(false), new Set([caseKey(ask(false))]), [caseKey(ask(false))])).toMatchObject({+ done: true,+ gain: 0,+ });+ // Keyed by the claim alone: a typo fixed in its paragraph keeps the confirm.+ expect(caseKey({ claim: 'Acme cut close time 40%' })).toBe(+ caseKey({ claim: 'Acme cut close time 40% ' }),+ );+ // Before Phase 3 (or before they're read): the link, on Trust, as before.+ expect(run(ask(false), null)).toMatchObject({ action: 'addProof', score: 'trust' });+ // Another kind of proof stays a link in Phase 3.+ expect(run(ask(false, 'award'), new Set())).toMatchObject({+ action: 'addProof',+ score: 'trust',+ });+ });++ it('keeps a case confirmed when the next read picks other words of its sentence (#1496 review)', () => {+ const sentence = 'Acme cut its close time by 40% with Ledgerly in one quarter.';+ const shorter = { claim: 'Acme cut its close time', sentence };+ const longer = { claim: 'Acme cut its close time by 40%', sentence };+ // Confirmed on one slice, read again as the other: still confirmed, no second row.+ expect(caseConfirmed(new Set([caseKey(shorter)]), longer)).toBe(true);+ expect(caseConfirmed(new Set([caseKey(longer)]), shorter)).toBe(true);+ // Another case, or a name alone, isn't this one.+ const other = {+ claim: 'Brightline doubled its pipeline',+ sentence: 'Brightline doubled its pipeline.',+ };+ expect(caseConfirmed(new Set([caseKey(shorter)]), other)).toBe(false);+ expect(caseConfirmed(new Set(['case:acme']), longer)).toBe(false);+ // A confirm of another kind doesn't count.+ expect(caseConfirmed(new Set([`intro:${caseKey(longer).slice(5)}`]), longer)).toBe(false);+ });++ it('says linking a confirmed case still raises Trust (#1496 review)', () => {+ const sentence = 'Acme cut its close time by 40% with Ledgerly.';+ const read = trust({+ blocks: trustBlocks(`<p>${sentence}</p>`),+ links: new Map(),+ brandDomains: ['ledgerly.com'],+ now: Date.parse('2026-10-25'),+ });+ const ask = {+ claim: 'Acme cut its close time by 40%',+ block: sentence,+ kind: 'customer_case' as const,+ sentence,+ linked: false,+ };+ const row = qualityTodos({+ eeat: null,+ trust: read,+ author: null,+ hasAuthors: true,+ proofs: { asks: [ask], had: new Set([caseKey(ask)]) },+ cases: new Set([caseKey(ask)]),+ off: checksOff('feature'),+ }).find((t) => t.id === 'proof')!;+ expect(row).toMatchObject({ done: true, action: 'confirmCase' });+ expect(row.trustGain).toBeGreaterThan(0);+ });+it('asks to add an author when the workspace has none', () => {expect(todos(null, false)[0]).toEqual({id: 'byline',diff --git a/web/src/lib/content/quality-todos.ts b/web/src/lib/content/quality-todos.tsindex 860de452f..23df5f902 100644--- a/web/src/lib/content/quality-todos.ts+++ b/web/src/lib/content/quality-todos.ts@@ -53,7 +53,8 @@ export type QualityTodoAction =| 'addImage'| 'pickReviewer'| 'reviewBrandFacts'- | 'addCheckDate';+ | 'addCheckDate'+ | 'confirmCase';export interface QualityTodo {id: QualityTodoId;@@ -79,6 +80,11 @@ export interface QualityTodo {* names (00271), a tick box beside the to-do, and whether it's ticked.*/confirm?: { what: 'real' | 'profile'; on: boolean };+ /**+ * A customer case's Trust share while it isn't linked (CE-052): its+ * sentence is an unsourced claim until it is, confirmed or not.+ */+ trustGain?: number;/** A check date the page has, over a year old: Add line's own line (it replaces it), or the person's words. */old?: 'line' | 'text';}@@ -109,6 +115,7 @@ export function qualityTodos({confirmed = null,shipping = null,checkDate = null,+ cases = null,off = NONE_OFF,}: {eeat: Score<EeatCheckId> | null;@@ -161,6 +168,13 @@ export function qualityTodos({* and the line Add line puts in (null for a language without one).*/checkDate?: { found: boolean; old?: 'line' | 'text' | null; line: string | null } | null;+ /**+ * Phase 3 (CE-052): the customer cases the person confirmed may be+ * published, by their proof to-do's key: a case's to-do is that confirm,+ * not a link (only the person knows they may name the customer). Null+ * before Phase 3, or before they're read.+ */+ cases?: ReadonlySet<string> | null;/*** Phase 3 (CE-052): the checks the page's type leaves out (checksOff): no* to-do asks for them (a product page has the brand's byline, no author).@@ -197,19 +211,31 @@ export function qualityTodos({// The page's own claims, in its order: open while its paragraph has no// link, checked once it has; MAX_PROOF_TODOS open at once.let open = 0;+ // A customer case's share of E-E-A-T's customer cases, each confirm alike.+ const caseAsks = cases ? (proofs?.asks ?? []).filter((a) => a.kind === 'customer_case') : [];+ const unconfirmed = caseAsks.filter((a) => !caseConfirmed(cases!, a)).length;+ const caseGain =+ eeat && eeat.score !== null && unconfirmed > 0+ ? Math.round(scoreGain(eeat, ['customerCase']) / unconfirmed)+ : 0;const proofTodos: QualityTodo[] = (proofs?.asks ?? []).flatMap((ask) => {- const key = proofKey(ask);- if (ask.linked && !proofs?.had.has(key)) return [];- if (!ask.linked && (open += 1) > MAX_PROOF_TODOS) return [];+ const confirm = !!cases && ask.kind === 'customer_case';+ const key = confirm ? caseKey(ask) : proofKey(ask);+ const done = confirm ? caseConfirmed(cases!, ask) : ask.linked;+ // Linking the published case still raises Trust: said beside the confirm.+ const linkGain = confirm && !ask.linked ? sentenceGain(trust, ask.sentence) : 0;+ if (done && !proofs?.had.has(key)) return [];+ if (!done && (open += 1) > MAX_PROOF_TODOS) return [];return [{id: 'proof',key,- done: ask.linked,- gain: ask.linked ? 0 : sentenceGain(trust, ask.sentence),- score: 'trust',- action: 'addProof',+ done,+ gain: done ? 0 : confirm ? caseGain : sentenceGain(trust, ask.sentence),+ score: confirm ? 'eeat' : 'trust',+ action: confirm ? 'confirmCase' : 'addProof',proof: { claim: ask.claim, block: ask.block, kind: ask.kind, sentence: ask.sentence },+ ...(linkGain > 0 ? { trustGain: linkGain } : {}),} satisfies QualityTodo,];});@@ -351,6 +377,41 @@ function shortHash(text: string): string {export const proofKey = (ask: { claim: string; block: string }) =>`proof:${squeeze(ask.claim)}:${shortHash(squeeze(ask.block))}`;+/**+ * A customer case's confirmation key (CE-052, 00280): its claim alone, by+ * its words without spaces, so a typo fixed in its paragraph keeps the+ * confirm.+ */+export const caseKey = (ask: { claim: string }) =>+ `case:${squeeze(ask.claim).toLowerCase()}`.slice(0, 400);++/** The fewest letters a confirm's words match a case's sentence by: a name alone isn't its case. */+const CASE_WORDS = 12;++/**+ * Whether a customer case is confirmed (CE-052): by its own key, or by a+ * confirm's words, as the page read picks its claim's words again after a+ * save ("Acme cut its close time" one time, "Acme cut its close time by+ * 40%" the next): a confirmed claim's words in its sentence, or its claim's+ * in a confirmed one's.+ */+export function caseConfirmed(+ confirms: ReadonlySet<string>,+ ask: { claim: string; sentence: string },+): boolean {+ const key = caseKey(ask);+ if (confirms.has(key)) return true;+ const claim = key.slice('case:'.length);+ const sentence = squeeze(ask.sentence).toLowerCase();+ for (const confirmed of confirms) {+ if (!confirmed.startsWith('case:')) continue;+ const words = confirmed.slice('case:'.length);+ if (words.length >= CASE_WORDS && sentence.includes(words)) return true;+ if (claim.length >= CASE_WORDS && words.includes(claim)) return true;+ }+ return false;+}+/*** Who / how / why (CE-050): the page says how it was made (how it was* tested, how the picks were chosen, by whom). Only the person knows: Briefdiff --git a/web/src/types/supabase.ts b/web/src/types/supabase.tsindex 8a81d333c..ab0fe1dd3 100644--- a/web/src/types/supabase.ts+++ b/web/src/types/supabase.ts@@ -1397,6 +1397,45 @@ export type Database = {},]}+ content_draft_confirmations: {+ Row: {+ confirmed_at: string+ confirmed_by: string | null+ draft_id: string+ key: string+ kind: string+ }+ Insert: {+ confirmed_at?: string+ confirmed_by?: string | null+ draft_id: string+ key: string+ kind: string+ }+ Update: {+ confirmed_at?: string+ confirmed_by?: string | null+ draft_id?: string+ key?: string+ kind?: string+ }+ Relationships: [+ {+ foreignKeyName: "content_draft_confirmations_draft_id_fkey"+ columns: ["draft_id"]+ isOneToOne: false+ referencedRelation: "content_drafts"+ referencedColumns: ["id"]+ },+ {+ foreignKeyName: "content_draft_confirmations_confirmed_by_fkey"+ columns: ["confirmed_by"]+ isOneToOne: false+ referencedRelation: "profiles"+ referencedColumns: ["id"]+ },+ ]+ }content_draft_deliveries: {Row: {batch_id: string | null