Skip to content

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.

feat(audit): show Site trust n/5 in Site Audit, and count it in Quality's Trust (CE-043) (#1418)

Cihan1d3479bc498b
diff --git a/web/messages/en.json b/web/messages/en.json
index 900951d3b..44a78dc1d 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -2697,6 +2697,52 @@
"deleteConfirm": "This permanently deletes this audit and its results. This can't be undone.",
"cancel": "Cancel",
"auditsLeft": "audits left this month",
+ "siteTrust": {
+ "title": "Site trust {score}/5",
+ "titleLoading": "Site trust",
+ "description": "Read from your site's pages. Counts toward Trust in the Content Editor's Quality, not this audit score.",
+ "checkAgain": "Check again",
+ "checkAgainAt": "You can check again at {time}.",
+ "loading": "Reading your site",
+ "loadFailed": "Couldn't read your site trust.",
+ "retry": "Try again",
+ "checkedAt": "Checked {date}",
+ "passes": "passes",
+ "missingLabel": "missing",
+ "notAnswered": "Your site didn't answer; checking again in a few minutes.",
+ "notAnsweredLabel": "not read",
+ "open": "Open",
+ "openLabel": "Open the {name} (new tab)",
+ "refreshFailed": "Couldn't check again. The read above still stands.",
+ "checks": {
+ "about": {
+ "name": "About page",
+ "ok": "Found on your site.",
+ "missing": "Add a page that says who you are and what you do, at /about."
+ },
+ "contact": {
+ "name": "Contact page",
+ "ok": "Found on your site.",
+ "missing": "Add a page with how to reach you, at /contact."
+ },
+ "editorial": {
+ "name": "Editorial policy",
+ "ok": "Found on your site.",
+ "missing": "Add a page on how you write and check content, at /editorial-policy or /how-we-review."
+ },
+ "organizationSchema": {
+ "name": "Organization schema on the home page",
+ "ok": "Your home page names your organization in its JSON-LD.",
+ "missing": "Add Organization JSON-LD to your home page: name, logo, URL and profiles."
+ },
+ "authorPages": {
+ "name": "Author pages",
+ "ok": "{count, plural, one {Your author has a page.} other {All # authors have a page.}}",
+ "missing": "No page found for: {names}. Add one for each, such as /authors/their-name.",
+ "noAuthors": "Add your authors in Settings › Authors, then a page for each on your site."
+ }
+ }
+ },
"scoreOverTime": "Score over time",
"categoryBreakdown": "Category breakdown",
"inRange": "in range",
@@ -4119,6 +4165,12 @@
"tooShort": "Write a few paragraphs: Readability is read from the page as you write.",
"tooShortShort": "Too short yet",
"notScored": "Not scored yet",
+ "site": {
+ "label": "Site trust",
+ "score": "Site trust {score}/5",
+ "missing": "Missing: {checks}",
+ "fix": "Fix in Site Audit"
+ },
"pickAuthor": "Pick author",
"addAuthor": "Add author",
"editAuthor": "Edit author",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/audit/_site-trust-card.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/audit/_site-trust-card.test.tsx
new file mode 100644
index 000000000..6a8d787b1
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/audit/_site-trust-card.test.tsx
@@ -0,0 +1,177 @@
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { NextIntlClientProvider } from 'next-intl';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import messages from '../../../../../../messages/en.json';
+import type { SiteTrust } from '@/lib/content/site-trust';
+
+const getSiteTrust = vi.fn();
+vi.mock('@/lib/actions/audits', () => ({
+ getSiteTrust: (...args: unknown[]) => getSiteTrust(...args),
+}));
+
+const { SiteTrustCard } = await import('./_site-trust-card');
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =
+ true;
+
+/** Site trust in Site Audit (CE-043): five checks, each passing or saying what to add. */
+
+const TRUST: SiteTrust = {
+ checks: {
+ about: { ok: true, url: 'https://acme.com/about' },
+ contact: { ok: true, url: 'https://acme.com/contact' },
+ editorial: { ok: false, url: null },
+ organizationSchema: { ok: true, url: 'https://acme.com/' },
+ authorPages: {
+ ok: false,
+ authors: [
+ { name: 'Ada Lovelace', url: 'https://acme.com/authors/ada-lovelace' },
+ { name: 'Bob Stone', url: null },
+ ],
+ },
+ },
+ score: 3,
+ checkedAt: '2026-10-23T12:00:00.000Z',
+};
+
+let container: HTMLDivElement;
+let root: Root;
+
+beforeEach(() => {
+ getSiteTrust.mockReset().mockResolvedValue(TRUST);
+ container = document.createElement('div');
+ root = createRoot(container);
+});
+afterEach(() => act(() => root.unmount()));
+
+async function render(now?: Date) {
+ await act(async () => {
+ root.render(
+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC" now={now}>
+ <SiteTrustCard brandId="b1" />
+ </NextIntlClientProvider>,
+ );
+ });
+}
+
+const rows = () => [...container.querySelectorAll('li')].map((li) => li.textContent);
+const checkAgain = () =>
+ [...container.querySelectorAll('button')].find((b) => b.textContent === 'Check again')!;
+
+describe('SiteTrustCard', () => {
+ it('shows the score and each check, with its page or what to add', async () => {
+ await render();
+ expect(getSiteTrust).toHaveBeenCalledWith('b1', false);
+ expect(container.querySelector('#site-trust')!.textContent).toContain('Site trust 3/5');
+ expect(rows()).toEqual([
+ 'About page · passesFound on your site.Open',
+ 'Contact page · passesFound on your site.Open',
+ 'Editorial policy · missingAdd a page on how you write and check content, at /editorial-policy or /how-we-review.',
+ 'Organization schema on the home page · passesYour home page names your organization in its JSON-LD.Open',
+ 'Author pages · missingNo page found for: Bob Stone. Add one for each, such as /authors/their-name.',
+ ]);
+ expect(container.querySelector('a')!.getAttribute('href')).toBe('https://acme.com/about');
+ });
+
+ it('reads it again on Check again', async () => {
+ await render();
+ const again = [...container.querySelectorAll('button')].find(
+ (b) => b.textContent === 'Check again',
+ )!;
+ await act(async () => again.click());
+ expect(getSiteTrust).toHaveBeenLastCalledWith('b1', true);
+ });
+
+ it('holds Check again for 10 minutes after a read, and says until when', async () => {
+ await render(new Date('2026-10-23T12:04:00.000Z'));
+ expect(checkAgain().disabled).toBe(true);
+ expect(container.textContent).toContain('You can check again at 12:10 PM.');
+ expect(checkAgain().getAttribute('aria-describedby')).toBe('site-trust-recheck');
+ });
+
+ it("says the site didn't answer on the rows a partial read leaves failing", async () => {
+ getSiteTrust.mockResolvedValue({ ...TRUST, complete: false });
+ await render(new Date('2026-10-23T12:04:00.000Z'));
+ expect(rows()).toEqual([
+ 'About page · passesFound on your site.Open',
+ 'Contact page · passesFound on your site.Open',
+ "Editorial policy · not readYour site didn't answer; checking again in a few minutes.",
+ 'Organization schema on the home page · passesYour home page names your organization in its JSON-LD.Open',
+ "Author pages · not readYour site didn't answer; checking again in a few minutes.",
+ ]);
+ });
+
+ it('still asks for authors first on a partial read', async () => {
+ getSiteTrust.mockResolvedValue({
+ ...TRUST,
+ checks: { ...TRUST.checks, authorPages: { ok: false, authors: [] } },
+ complete: false,
+ });
+ await render(new Date('2026-10-23T12:04:00.000Z'));
+ expect(rows()[4]).toContain('Add your authors in Settings › Authors');
+ });
+
+ it('reads a partial read again once the 10 minutes are over', async () => {
+ vi.useFakeTimers({ toFake: ['Date', 'setInterval', 'clearInterval'] });
+ try {
+ vi.setSystemTime(new Date('2026-10-23T12:04:00.000Z'));
+ getSiteTrust.mockResolvedValue({ ...TRUST, complete: false });
+ await render();
+ expect(getSiteTrust).toHaveBeenCalledTimes(1);
+
+ await act(async () => vi.advanceTimersByTime(5 * 60 * 1000));
+ expect(getSiteTrust).toHaveBeenCalledTimes(1);
+ getSiteTrust.mockResolvedValue({ ...TRUST, checkedAt: '2026-10-23T12:10:00.000Z' });
+ await act(async () => vi.advanceTimersByTime(60 * 1000));
+ expect(getSiteTrust).toHaveBeenCalledTimes(2);
+ expect(getSiteTrust).toHaveBeenLastCalledWith('b1', false);
+ expect(rows()[2]).toContain('Add a page on how you write and check content');
+ } finally {
+ vi.useRealTimers();
+ }
+ });
+
+ it('asks for authors first when there are none', async () => {
+ getSiteTrust.mockResolvedValue({
+ ...TRUST,
+ checks: { ...TRUST.checks, authorPages: { ok: false, authors: [] } },
+ });
+ await render();
+ expect(rows()[4]).toContain('Add your authors in Settings › Authors');
+ });
+
+ it("says so when it can't be read", async () => {
+ getSiteTrust.mockRejectedValue(new Error('boom'));
+ vi.spyOn(console, 'error').mockImplementation(() => {});
+ await render();
+ expect(container.textContent).toContain("Couldn't read your site trust.");
+ });
+
+ it('says so when checking again fails, keeping the read', async () => {
+ await render();
+ getSiteTrust.mockRejectedValue(new Error('boom'));
+ vi.spyOn(console, 'error').mockImplementation(() => {});
+ const again = [...container.querySelectorAll('button')].find(
+ (b) => b.textContent === 'Check again',
+ )!;
+ await act(async () => again.click());
+ expect(container.textContent).toContain("Couldn't check again. The read above still stands.");
+ expect(container.textContent).toContain('Site trust 3/5');
+ });
+
+ it('scrolls into view when the address asks for it', async () => {
+ const scroll = vi.fn();
+ Element.prototype.scrollIntoView = scroll;
+ vi.spyOn(window, 'requestAnimationFrame').mockImplementation((cb) => {
+ cb(0);
+ return 0;
+ });
+ window.history.replaceState(null, '', '#site-trust');
+ document.body.appendChild(container);
+ await render();
+ expect(scroll).toHaveBeenCalledTimes(1);
+ window.history.replaceState(null, '', '#');
+ container.remove();
+ });
+});
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/audit/_site-trust-card.tsx b/web/src/app/[locale]/(dashboard)/dashboard/audit/_site-trust-card.tsx
new file mode 100644
index 000000000..8b452c82a
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/audit/_site-trust-card.tsx
@@ -0,0 +1,213 @@
+'use client';
+
+import { useCallback, useEffect, useRef, useState } from 'react';
+import { useFormatter, useNow, useTranslations } from 'next-intl';
+import { Check, Clock, ExternalLink, X } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { LoadingDots } from '@/components/ui/loading-dots';
+import { getSiteTrust } from '@/lib/actions/audits';
+import {
+ SITE_TRUST_CHECKS,
+ SITE_TRUST_RECHECK_MS,
+ type SiteTrust,
+ type SiteTrustCheck,
+} from '@/lib/content/site-trust';
+import { cn } from '@/lib/utils';
+
+/**
+ * Site trust (Content Editor Quality spec §8, CE-043): the brand's five
+ * site-level checks, "Site trust {n}/5", each with the page that passes it
+ * or what to add. Quality's "Fix in Site Audit" lands here (#site-trust),
+ * and the score is worth 5 Trust points on every page.
+ */
+export function SiteTrustCard({ brandId }: { brandId: string }) {
+ const t = useTranslations('audit.siteTrust');
+ const format = useFormatter();
+ const [trust, setTrust] = useState<SiteTrust | null>(null);
+ const [failed, setFailed] = useState(false);
+ const [checking, setChecking] = useState(false);
+
+ const load = useCallback(
+ async (refresh: boolean) => {
+ setChecking(refresh);
+ try {
+ setTrust(await getSiteTrust(brandId, refresh));
+ setFailed(false);
+ } catch (err) {
+ console.error('Failed to read the site trust:', err);
+ setFailed(true);
+ } finally {
+ setChecking(false);
+ }
+ },
+ [brandId],
+ );
+ useEffect(() => {
+ void load(false);
+ }, [load]);
+
+ // The API keeps a read for SITE_TRUST_RECHECK_MS when asked again, so Check
+ // again would answer the same read: it waits, and says until when.
+ const now = useNow({ updateInterval: 15_000 });
+ const recheckAt = trust ? Date.parse(trust.checkedAt) + SITE_TRUST_RECHECK_MS : 0;
+ const tooSoon = !!trust && now.getTime() < recheckAt;
+ // A partial read (the site didn't answer all of it) is read again once
+ // that wait is over, as its rows say.
+ const partial = trust?.complete === false;
+ useEffect(() => {
+ if (partial && !tooSoon) void load(false);
+ }, [partial, tooSoon, load]);
+
+ // Quality's "Fix in Site Audit" lands here (#site-trust): once the card has
+ // its read, and the cards above have theirs, it scrolls into view once.
+ const scrolled = useRef(false);
+ useEffect(() => {
+ if (!trust || scrolled.current || window.location.hash !== '#site-trust') return;
+ scrolled.current = true;
+ requestAnimationFrame(() => document.getElementById('site-trust')?.scrollIntoView());
+ }, [trust]);
+
+ return (
+ <Card id="site-trust" className="scroll-mt-24">
+ <CardHeader className="flex flex-row items-start justify-between gap-3 space-y-0">
+ <div className="min-w-0">
+ <CardTitle className="text-base">
+ {trust ? t('title', { score: trust.score }) : t('titleLoading')}
+ </CardTitle>
+ <p className="mt-0.5 text-xs text-muted-foreground">{t('description')}</p>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ className="shrink-0"
+ disabled={checking || !trust || tooSoon}
+ aria-describedby={tooSoon ? 'site-trust-recheck' : undefined}
+ onClick={() => void load(true)}
+ >
+ {checking && <LoadingDots className="mr-1.5" />}
+ {t('checkAgain')}
+ </Button>
+ </CardHeader>
+ <CardContent className="pt-0">
+ {!trust && !failed && (
+ <p className="text-sm text-muted-foreground" role="status" aria-busy="true">
+ <LoadingDots />
+ <span className="sr-only">{t('loading')}</span>
+ </p>
+ )}
+ {failed && !trust && (
+ <p className="text-sm text-destructive" role="alert">
+ {t('loadFailed')}{' '}
+ <button type="button" className="underline" onClick={() => void load(false)}>
+ {t('retry')}
+ </button>
+ </p>
+ )}
+ {trust && (
+ <>
+ <ul className="divide-y rounded-xl border">
+ {SITE_TRUST_CHECKS.map((check) => (
+ <CheckRow key={check} check={check} trust={trust} />
+ ))}
+ </ul>
+ {failed && (
+ <p className="mt-2 text-xs text-destructive" role="alert">
+ {t('refreshFailed')}
+ </p>
+ )}
+ <p className="mt-2 text-xs text-muted-foreground">
+ {t('checkedAt', {
+ date: format.dateTime(new Date(trust.checkedAt), {
+ dateStyle: 'medium',
+ timeStyle: 'short',
+ }),
+ })}
+ {tooSoon && (
+ <span id="site-trust-recheck">
+ {' · '}
+ {t('checkAgainAt', {
+ time: format.dateTime(new Date(recheckAt), { timeStyle: 'short' }),
+ })}
+ </span>
+ )}
+ </p>
+ </>
+ )}
+ </CardContent>
+ </Card>
+ );
+}
+
+function CheckRow({ check, trust }: { check: SiteTrustCheck; trust: SiteTrust }) {
+ const t = useTranslations('audit.siteTrust');
+ const format = useFormatter();
+ const result = trust.checks[check];
+ const ok = !!result?.ok;
+ const url = check === 'authorPages' ? null : (trust.checks[check].url ?? null);
+ const authors = check === 'authorPages' ? trust.checks.authorPages.authors : [];
+ const withoutPage = authors.filter((a) => !a.url).map((a) => a.name);
+ // With a partial read, a check that fails may only not have been read: no
+ // advice to add what the site may already have. No authors at all isn't
+ // the site's answer.
+ const unread = !ok && trust.complete === false && (check !== 'authorPages' || authors.length > 0);
+
+ let detail: string;
+ if (unread) {
+ detail = t('notAnswered');
+ } else if (check === 'authorPages') {
+ detail = !authors.length
+ ? t('checks.authorPages.noAuthors')
+ : ok
+ ? t('checks.authorPages.ok', { count: authors.length })
+ : t('checks.authorPages.missing', { names: format.list(withoutPage) });
+ } else {
+ detail = ok ? t(`checks.${check}.ok`) : t(`checks.${check}.missing`);
+ }
+
+ return (
+ <li className="flex items-start gap-2.5 px-3 py-2.5">
+ <span
+ aria-hidden
+ className={cn(
+ 'mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full',
+ ok
+ ? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300'
+ : unread
+ ? 'bg-muted text-muted-foreground'
+ : 'bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-300',
+ )}
+ >
+ {ok ? (
+ <Check className="h-3 w-3" />
+ ) : unread ? (
+ <Clock className="h-3 w-3" />
+ ) : (
+ <X className="h-3 w-3" />
+ )}
+ </span>
+ <div className="min-w-0 flex-1">
+ <p className="text-sm font-medium">
+ {t(`checks.${check}.name`)}
+ <span className="sr-only">
+ {' · '}
+ {ok ? t('passes') : unread ? t('notAnsweredLabel') : t('missingLabel')}
+ </span>
+ </p>
+ <p className="text-xs text-muted-foreground [overflow-wrap:anywhere]">{detail}</p>
+ </div>
+ {url && ok && (
+ <a
+ href={url}
+ target="_blank"
+ rel="noopener noreferrer"
+ aria-label={t('openLabel', { name: t(`checks.${check}.name`) })}
+ className="flex shrink-0 items-center gap-1 text-xs text-muted-foreground hover:text-foreground"
+ >
+ {t('open')}
+ <ExternalLink className="h-3 w-3" />
+ </a>
+ )}
+ </li>
+ );
+}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/audit/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/audit/page.tsx
index e28d9f4b7..36e878808 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/audit/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/audit/page.tsx
@@ -23,6 +23,7 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Skeleton } from '@/components/ui/skeleton';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import { qualityPhase } from '@/lib/content/quality';
import { useBrandStore } from '@/stores/use-brand-store';
import { useUserRole } from '@/hooks/use-user-role';
import {
@@ -46,6 +47,7 @@ import {
} from '@/lib/actions/audits';
import { pct, scoreColor, CATEGORY_META } from '@/components/audit/audit-report';
import { formatMonthDay, formatNumber } from '@/lib/format';
+import { SiteTrustCard } from './_site-trust-card';
import { ScoreTrendChart } from './_charts';
import { AuditPagesTable } from './_pages-table';
import { AuditBulkBar, ExportMenu } from './_bulk-bar';
@@ -716,6 +718,11 @@ export default function SiteAuditPage() {
</Card>
)}
+ {/* Site trust (Content Editor Quality, CE-043): with Quality's first phase */}
+ {activeBrandId && qualityPhase() >= 1 && (
+ <SiteTrustCard key={`site-trust-${activeBrandId}`} brandId={activeBrandId} />
+ )}
+
{loading ? (
<Card>
<CardHeader>
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.tsx
index e04b8424b..79c08b444 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
@@ -37,10 +37,12 @@ import {
startAgentWriting,
startPageRewrite,
} from '@/lib/actions/content-drafts';
+import { getSiteTrust } from '@/lib/actions/audits';
import { getContentAuthors } from '@/lib/actions/content-authors';
import { stopAgentRun } from '@/lib/content/agent-runs-client';
import { agentWriteRequest, useRuleDescriber } from '@/lib/content/agent-write';
import { authorInitials, canEditAuthor, type AuthorsRead } from '@/lib/content/authors';
+import type { SiteTrust } from '@/lib/content/site-trust';
import {
AGENT_POLL_MS,
CONTENT_LIBRARY_PATH,
@@ -453,6 +455,18 @@ export function DraftEditor({
const pageBlocks = useMemo(() => (qualityOn ? trustBlocks(pageHtml) : []), [qualityOn, pageHtml]);
const linkChecks = useLinkChecks(draft.id, autosave.savedAt, linksToCheck(pageBlocks), qualityOn);
const brandDomains = reads.sources?.data?.brandDomains;
+ // The site's trust (Site Audit, CE-043), read once: Trust's last 5 points.
+ const [siteTrust, setSiteTrust] = useState<SiteTrust | null>(null);
+ useEffect(() => {
+ if (!qualityOn) return;
+ let live = true;
+ getSiteTrust(draft.brandId)
+ .then((read) => live && setSiteTrust(read))
+ .catch((err) => console.error('Failed to read the site trust:', err));
+ return () => {
+ live = false;
+ };
+ }, [qualityOn, draft.brandId]);
// The brand's own links aren't sources: Trust waits for its domains.
const trustScore = useMemo(
() =>
@@ -461,10 +475,11 @@ export function DraftEditor({
blocks: pageBlocks,
links: linkChecks,
brandDomains,
+ siteTrust,
now: Date.now(),
})
: null,
- [qualityOn, pageBlocks, linkChecks, brandDomains],
+ [qualityOn, pageBlocks, linkChecks, brandDomains, siteTrust],
);
const qualityScore = qualityAverage([
eeatScore?.score ?? null,
@@ -480,6 +495,7 @@ export function DraftEditor({
canEdit: !!pageAuthor && !!authorsRead && canEditAuthor(pageAuthor, authorsRead.me),
hasAuthors: (authorsRead?.authors.length ?? 0) > 0,
brandName,
+ siteTrust,
}
: null;
// Quality's Pick author opens the header's menu.
diff --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.tsx
index 87d48a0a4..a9fbcb8a0 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
@@ -71,6 +71,7 @@ function read(
canEdit,
hasAuthors,
brandName: 'Acme',
+ siteTrust: null,
};
}
@@ -248,6 +249,34 @@ describe('QualityTab', () => {
expect(onShow).toHaveBeenCalledWith('Win rates rose 42% last year.');
});
+ it("shows the site's trust, what is missing and the way to Site Audit", async () => {
+ const siteTrust = {
+ checks: {
+ about: { ok: true, url: 'https://acme.com/about' },
+ contact: { ok: true, url: 'https://acme.com/contact' },
+ editorial: { ok: false, url: null },
+ organizationSchema: { ok: true, url: 'https://acme.com/' },
+ authorPages: { ok: false, authors: [{ name: 'Ada', url: null }] },
+ },
+ score: 3,
+ checkedAt: '2026-10-23T12:00:00.000Z',
+ };
+ await render({ ...read(result), siteTrust });
+ const site = container.querySelector('[aria-label="Site trust"]')!;
+ expect(site.textContent).toBe(
+ 'Site trust 3/5· Missing: Editorial policy and Author pagesFix in Site Audit',
+ );
+ expect(site.querySelector('a')!.getAttribute('href')).toBe('/dashboard/audit#site-trust');
+
+ const all = Object.fromEntries(
+ Object.entries(siteTrust.checks).map(([k, v]) => [k, { ...v, ok: true }]),
+ ) as typeof siteTrust.checks;
+ await render({ ...read(result), siteTrust: { ...siteTrust, checks: all, score: 5 } });
+ expect(container.querySelector('[aria-label="Site trust"]')!.textContent).toBe(
+ 'Site trust 5/5',
+ );
+ });
+
it('lists a broken link before Trust is scored, its gain out of the Phase 1 points', async () => {
const result = trust({
blocks: trustBlocks('<p>See <a href="https://gone.example/">that one</a>.</p>'),
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.tsx
index cfdf7d142..e7e2864b5 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
@@ -1,6 +1,6 @@
'use client';
-import { useTranslations } from 'next-intl';
+import { useFormatter, useTranslations } from 'next-intl';
import { Link } from '@/i18n/navigation';
import { Button, buttonVariants } from '@/components/ui/button';
import type { ContentAuthor } from '@/lib/content/authors';
@@ -20,6 +20,7 @@ import {
type Readability,
type ReadabilityCheck,
} from '@/lib/content/readability';
+import { SITE_TRUST_PATH, siteTrustMissing, type SiteTrust } from '@/lib/content/site-trust';
import { cn } from '@/lib/utils';
import { MANAGE_AUTHORS_PATH } from './_author-menu';
@@ -38,6 +39,8 @@ export interface QualityRead {
/** Whether the workspace has an author to pick (Settings › Authors). */
hasAuthors: boolean;
brandName: string;
+ /** The site's trust in Site Audit (CE-043), or null while not read. */
+ siteTrust: SiteTrust | null;
}
type ScoreName = 'eeat' | 'trust' | 'readability';
@@ -74,7 +77,10 @@ export function QualityTab({
}) {
const t = useTranslations('contentEditor.editor.quality');
const tAuthor = useTranslations('contentEditor.editor.author');
- const { readability, eeat, trust } = quality;
+ const tSite = useTranslations('audit.siteTrust.checks');
+ const format = useFormatter();
+ const { readability, eeat, trust, siteTrust } = quality;
+ const siteMissing = siteTrust ? siteTrustMissing(siteTrust) : [];
const scores: { name: ScoreName; score: number | null; empty: string }[] = [
{ name: 'eeat', score: eeat?.score ?? null, empty: t('notScored') },
{ name: 'trust', score: trust?.score ?? null, empty: t('notScored') },
@@ -147,6 +153,31 @@ export function QualityTab({
</ul>
)}
</section>
+
+ {siteTrust && (
+ <section
+ aria-label={t('site.label')}
+ className="flex flex-wrap items-center gap-x-2 gap-y-1 border-t pt-3 text-xs"
+ >
+ <span className="font-medium">{t('site.score', { score: siteTrust.score })}</span>
+ {siteMissing.length > 0 && (
+ <span className="min-w-0 text-muted-foreground [overflow-wrap:anywhere]">
+ <span aria-hidden>· </span>
+ {t('site.missing', {
+ checks: format.list(siteMissing.map((check) => tSite(`${check}.name`))),
+ })}
+ </span>
+ )}
+ {siteMissing.length > 0 && (
+ <Link
+ href={SITE_TRUST_PATH}
+ className="ml-auto font-medium text-foreground underline-offset-2 hover:underline"
+ >
+ {t('site.fix')}
+ </Link>
+ )}
+ </section>
+ )}
</div>
);
}
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.tsx
index b52c1a795..d4f4d8ce4 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
@@ -17,6 +17,10 @@ const saveContentDraft = vi.fn();
const setContentDraftPageType = vi.fn();
const setContentDraftAuthor = vi.fn();
const checkDraftLinks = vi.fn();
+const getSiteTrust = vi.fn();
+vi.mock('@/lib/actions/audits', () => ({
+ getSiteTrust: (...args: unknown[]) => getSiteTrust(...args),
+}));
const getContentAuthors = vi.fn();
vi.mock('@/lib/actions/content-authors', () => ({
getContentAuthors: (...args: unknown[]) => getContentAuthors(...args),
@@ -232,7 +236,8 @@ beforeEach(() => {
saveBlob.mockReset();
setContentDraftPageType.mockReset().mockResolvedValue(undefined);
setContentDraftAuthor.mockReset().mockResolvedValue(undefined);
- checkDraftLinks.mockReset().mockResolvedValue({ links: [] });
+ checkDraftLinks.mockReset().mockResolvedValue({ links: [], skipped: [] });
+ getSiteTrust.mockReset().mockRejectedValue(new Error('not in this test'));
getContentAuthors.mockReset().mockResolvedValue(null);
saveContentDraft
.mockReset()
diff --git a/web/src/lib/actions/audits-site-trust.test.ts b/web/src/lib/actions/audits-site-trust.test.ts
new file mode 100644
index 000000000..1ed615140
--- /dev/null
+++ b/web/src/lib/actions/audits-site-trust.test.ts
@@ -0,0 +1,53 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+/**
+ * Site trust's read (CE-043): what the card gets from the API, with whether
+ * the site answered all of it when the API says so.
+ */
+
+vi.mock('@/lib/supabase/server', () => ({
+ createClient: vi.fn(async () => ({
+ auth: { getSession: async () => ({ data: { session: { access_token: 'token' } } }) },
+ })),
+}));
+
+const { getSiteTrust } = await import('./audits');
+
+const READ = {
+ checks: {
+ about: { ok: true, url: 'https://acme.com/about' },
+ contact: { ok: false, url: null },
+ editorial: { ok: false, url: null },
+ organizationSchema: { ok: false, url: null },
+ authorPages: { ok: false, authors: [] },
+ },
+ score: 1,
+ checkedAt: '2026-10-23T12:00:00.000Z',
+};
+
+let body: unknown;
+
+beforeEach(() => {
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async () => new Response(JSON.stringify(body), { status: 200 })),
+ );
+});
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+});
+
+describe('getSiteTrust', () => {
+ it("passes on that the site didn't answer all of it", async () => {
+ body = { ...READ, complete: false };
+ expect(await getSiteTrust('b1')).toEqual({ ...READ, complete: false });
+ });
+
+ it('reads an older API without it', async () => {
+ body = READ;
+ const read = await getSiteTrust('b1');
+ expect(read).toEqual(READ);
+ expect('complete' in read).toBe(false);
+ });
+});
diff --git a/web/src/lib/actions/audits.ts b/web/src/lib/actions/audits.ts
index 7984656a8..e419a7764 100644
--- a/web/src/lib/actions/audits.ts
+++ b/web/src/lib/actions/audits.ts
@@ -2,6 +2,7 @@
import { createClient } from '@/lib/supabase/server';
import { API_BASE_URL } from '@/config/api';
+import type { SiteTrust } from '@/lib/content/site-trust';
const AEO_SERVER_URL = API_BASE_URL;
@@ -254,6 +255,30 @@ export async function getAuditQuota(): Promise<AuditQuota> {
return data.quota;
}
+/**
+ * The brand's site trust (CE-043): the day's read, or a new one when
+ * `refresh` (the API reads again at most every few minutes).
+ */
+export async function getSiteTrust(brandId: string, refresh = false): Promise<SiteTrust> {
+ const session = await getSession();
+ const res = await fetch(
+ `${AEO_SERVER_URL}/api/audits/site-trust?brandId=${encodeURIComponent(brandId)}${refresh ? '&refresh=1' : ''}`,
+ { headers: { Authorization: `Bearer ${session.access_token}` } },
+ );
+ if (!res.ok) {
+ const body = await res.json().catch(() => ({}));
+ throw new Error(body.message || `Server error: ${res.status}`);
+ }
+ const data = await res.json();
+ if (!Number.isFinite(data.score) || !data.checks) throw new Error('Unexpected site trust');
+ return {
+ checks: data.checks,
+ score: data.score,
+ checkedAt: data.checkedAt,
+ ...(typeof data.complete === 'boolean' && { complete: data.complete }),
+ };
+}
+
/** Score + category-score time series for the brand's primary domain. */
export async function getAuditTrend(brandId: string): Promise<AuditTrend> {
const session = await getSession();
diff --git a/web/src/lib/content/quality-checks.test.ts b/web/src/lib/content/quality-checks.test.ts
index ceafeb282..8631383af 100644
--- a/web/src/lib/content/quality-checks.test.ts
+++ b/web/src/lib/content/quality-checks.test.ts
@@ -199,4 +199,23 @@ describe('trust (Phase 1: figures and links)', () => {
expect(result.broken).toHaveLength(1);
expect(result.figures).toBe(1);
});
+
+ it("counts the site's trust checks beside the page's own, 5 points for all five", () => {
+ const run = (html: string) =>
+ trust({
+ blocks: blocks(html),
+ links: new Map(),
+ brandDomains: ['acme.com'],
+ siteTrust: { score: 3 },
+ now: NOW,
+ });
+ const result = run('<p>Up 40% (<a href="https://src.example/">source</a>).</p>');
+ expect(result.checks).toEqual([
+ { id: 'claimsSourced', points: 30, max: 30 },
+ { id: 'siteTrust', points: 3, max: TRUST_WEIGHTS.siteTrust },
+ ]);
+ expect(result.score).toBe(94);
+ // Alone, the site's 5 points would be the whole of the page's Trust.
+ expect(run('<p>No figures here.</p>').score).toBeNull();
+ });
});
diff --git a/web/src/lib/content/quality-checks.ts b/web/src/lib/content/quality-checks.ts
index ebcb08466..f45eabeda 100644
--- a/web/src/lib/content/quality-checks.ts
+++ b/web/src/lib/content/quality-checks.ts
@@ -36,9 +36,9 @@ export const EEAT_WEIGHTS = {
export type EeatCheckId = keyof typeof EEAT_WEIGHTS;
/**
- * Trust's checks and points; Phase 1 reads the page's links and figures:
- * sourced figures, fresh sources, working links. Site trust joins with Site
- * Audit (CE-043); the rest are Phase 2.
+ * Trust's checks and points; Phase 1 reads the page's links and figures
+ * (sourced figures, fresh sources, working links) and the site's trust
+ * (Site Audit, CE-043); the rest are Phase 2.
*/
export const TRUST_WEIGHTS = {
claimsSourced: 30,
@@ -243,16 +243,19 @@ export interface TrustRead extends Score<TrustCheckId> {
/**
* Trust from the page as written (Phase 1): figures with a source (a link
* to another site in the same block), sources from the last FRESH_MONTHS,
- * and links that answer. A check with nothing to read on the page (no
- * figure, no dated source, no link read yet) is left out, and Trust is
- * scored only once a figure or a dated source is there: working links alone
- * are 3 points, and one link would set the whole score (one dead link 0,
- * one working link 100), as Readability waits for MIN_WORDS.
+ * links that answer, and the site's trust (its five checks in Site Audit).
+ * A check with nothing to read (no figure, no dated source, no link read
+ * yet, no site trust read) is left out, and site trust counts only beside a
+ * check of the page's own. Trust is scored only once a figure or a dated
+ * source is there: working links alone are 3 points, and one link would set
+ * the whole score (one dead link 0, one working link 100), as Readability
+ * waits for MIN_WORDS.
*/
export function trust({
blocks,
links,
brandDomains,
+ siteTrust = null,
now,
}: {
/** The page's blocks (trustBlocks). */
@@ -260,6 +263,8 @@ export function trust({
/** Each link's read, by the link as the page has it; one not read yet isn't counted. */
links: Map<string, LinkCheck>;
brandDomains: string[];
+ /** How many of the site's five trust checks pass (CE-043), when read. */
+ siteTrust?: { score: number } | null;
now: number;
}): TrustRead {
const all = pageLinks(blocks, brandDomains);
@@ -312,6 +317,16 @@ export function trust({
});
}
+ // The site's 5 points weigh with what the page itself shows: alone, they'd
+ // be the page's whole Trust.
+ if (siteTrust && checks.length) {
+ checks.push({
+ id: 'siteTrust',
+ points: (TRUST_WEIGHTS.siteTrust * siteTrust.score) / 5,
+ max: TRUST_WEIGHTS.siteTrust,
+ });
+ }
+
const scored = checks.some((c) => c.id === 'claimsSourced' || c.id === 'freshSources');
return {
...(scored ? scoreOf(checks) : { score: null, checks }),
diff --git a/web/src/lib/content/site-trust.ts b/web/src/lib/content/site-trust.ts
new file mode 100644
index 000000000..29acdb3ed
--- /dev/null
+++ b/web/src/lib/content/site-trust.ts
@@ -0,0 +1,42 @@
+/**
+ * A brand's site trust (Content Editor Quality spec §8, CE-043), as the API
+ * reads it (site-trust.js, site_trust 00259): five site-level checks, shown
+ * in Site Audit as "Site trust {n}/5" and worth 5 Trust points on every page.
+ */
+
+export const SITE_TRUST_CHECKS = [
+ 'about',
+ 'contact',
+ 'editorial',
+ 'organizationSchema',
+ 'authorPages',
+] as const;
+export type SiteTrustCheck = (typeof SITE_TRUST_CHECKS)[number];
+
+export interface SiteTrust {
+ checks: Record<Exclude<SiteTrustCheck, 'authorPages'>, { ok: boolean; url: string | null }> & {
+ authorPages: { ok: boolean; authors: { name: string; url: string | null }[] };
+ };
+ /** How many of the five pass. */
+ score: number;
+ checkedAt: string;
+ /**
+ * False when the site didn't answer all of it (a timeout, a bot wall): a
+ * check that fails may only not have been read. An older API leaves it out.
+ */
+ complete?: boolean;
+}
+
+/**
+ * How long the API keeps a read when asked to check again, and before it
+ * reads a partial one again (site-trust.js RECHECK_MS).
+ */
+export const SITE_TRUST_RECHECK_MS = 10 * 60 * 1000;
+
+/** Where Quality's "Fix in Site Audit" goes: the card in Site Audit. */
+export const SITE_TRUST_PATH = '/dashboard/audit#site-trust';
+
+/** The checks that don't pass, in order. */
+export function siteTrustMissing(trust: SiteTrust): SiteTrustCheck[] {
+ return SITE_TRUST_CHECKS.filter((check) => !trust.checks[check]?.ok);
+}