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(action-center): read a result by the action's main metric, and say "mixed" when its metrics moved both ways (learning A4) (#1690)
Cihan517ced3842aa
diff --git a/docs/guides/action-center.mdx b/docs/guides/action-center.mdxindex 782b06875..9991cc758 100644--- a/docs/guides/action-center.mdx+++ b/docs/guides/action-center.mdx@@ -191,8 +191,8 @@ The **History** tab lists actions once they are In Progress, On Hold, CompletedClick an action to see **What was the goal?**, **What happened?** (the signals it was built from), its affected items and tasks, and the **Result**:-- When a completed action's week after closing is over, Ansvisor compares its metrics over the 7 days before it was raised with the 7 days after it closed. The result reads **Improved**, **No meaningful change** or **Declined**. It is measured after the action, not proven to be caused by it. An action that names its prompts or pages is measured on them, with the brand-wide figures over the same days beside. A Site Audit fix is judged by its pages audited again since it closed: the check that raised it passing, or a low score past the line; with none audited again yet, by the metrics. The History drawer also says what became of the signals that raised it by then: how many ended, turned into another, were dismissed, or are still open.-- A dismissed action is **Not measurable**, and so is one with no metric to read.+- When a completed action's week after closing is over, Ansvisor compares its metrics over the 7 days before it was raised with the 7 days after it closed. The result reads **Improved**, **Mixed**, **No meaningful change** or **Declined**, judged by the action's main metric (the first one it names): **Mixed** when another metric it names moved the other way, or, without the main one measured, when the ones it names moved both ways. Other metrics show beside but don't count. It is measured after the action, not proven to be caused by it. An action that names its prompts or pages is measured on them, with the brand-wide figures over the same days beside; when they can't show its main metric (citations, for prompts), it is measured brand-wide. A Site Audit fix is judged by its pages audited again since it closed: the check that raised it passing, or a low score past the line; with none audited again yet, by the metrics. The History drawer also says what became of the signals that raised it by then: how many ended, turned into another, were dismissed, or are still open.+- Only a completed action is measured: a dismissed one reads **Not measured**, dismissed. One with no metric to read is **Not measurable**.- An action sent from a prompt's Improve tab reports on how many platforms its position improved. It is read again daily while the action is open and for 30 days after it is completed.When an action is closed, its condition can open a new action after a two-week rest if it is still firing. The old one stays in History as the record of that round of work.diff --git a/server/src/lib/action-center/audit-recheck.js b/server/src/lib/action-center/audit-recheck.jsindex 6f2a05470..03e5c06af 100644--- a/server/src/lib/action-center/audit-recheck.js+++ b/server/src/lib/action-center/audit-recheck.js@@ -88,10 +88,10 @@ export async function auditRecheck(action) {/*** A fix's verdict from its pages audited again: its aim is the check* passing, more than any metric over a week. All passing reads improved;- * none, no meaningful change; some, improved (part of the work took).+ * none, no meaningful change; some, mixed (part of the work took).*/export function auditOutcome({ audited, passed }) {if (!audited) return null;if (passed === 0) return 'no_meaningful_change';- return 'improved';+ return passed === audited ? 'improved' : 'mixed';}diff --git a/server/src/lib/action-center/audit-recheck.test.js b/server/src/lib/action-center/audit-recheck.test.jsindex ec8332f3d..1b740dfc8 100644--- a/server/src/lib/action-center/audit-recheck.test.js+++ b/server/src/lib/action-center/audit-recheck.test.js@@ -113,7 +113,8 @@ describe('auditRecheck', () => {describe('auditOutcome', () => {it('judges a fix by its pages audited again, and leaves it to the metrics with none', () => {expect(auditOutcome({ audited: 2, passed: 2 })).toBe('improved');- expect(auditOutcome({ audited: 2, passed: 1 })).toBe('improved');+ // Part of the work took (learning A4).+ expect(auditOutcome({ audited: 2, passed: 1 })).toBe('mixed');expect(auditOutcome({ audited: 2, passed: 0 })).toBe('no_meaningful_change');expect(auditOutcome({ audited: 0, passed: 0 })).toBeNull();});diff --git a/server/src/lib/action-center/validate.js b/server/src/lib/action-center/validate.jsindex 13b5e93e9..73ff3e41f 100644--- a/server/src/lib/action-center/validate.js+++ b/server/src/lib/action-center/validate.js@@ -190,31 +190,53 @@ async function measureTraffic(brandId, from, to) {}/**- * The verdict, from the measured pairs alone.+ * The verdict, from the measured pairs alone (learning A4).** A metric counts as moved only past MEANINGFUL_CHANGE_RATIO — these numbers* drift week to week on their own, and calling a 1% wobble an improvement- * would make every outcome meaningless. Mixed movement reads as improved:- * something the action aimed at did move, and reporting that as "no change"- * would hide it.+ * would make every outcome meaningless.+ *+ * The action's main metric (`primary`, the one its aim reads in) decides+ * when it was measured: up is improved, down declined, still no meaningful+ * change, whatever the others did beside it, but `mixed` when another moved+ * the other way. Without one measured, every metric counts, and movement+ * both ways is `mixed`: it used to read as improved, which taught that+ * anything moving up was the work paying off.+ *+ * Given `aims` (the success metrics the action names), only those and the+ * main metric count: a basket reads every metric it can, and one the action+ * never aimed at drifting the other way isn't a mixed result. The others+ * stay in `metrics`, to see.*/-export function deriveOutcome(metrics) {- const measured = metrics.filter((m) => m.before != null && m.after != null);+export function deriveOutcome(metrics, primary = null, aims = null) {+ const counted = aims ? new Set([...aims, ...(primary ? [primary] : [])]) : null;+ const measured = metrics.filter(+ (m) => m.before != null && m.after != null && (!counted || counted.has(m.metric)),+ );if (measured.length === 0) return 'not_measurable';- let improved = 0;- let declined = 0;- for (const { before, after } of measured) {+ const direction = ({ before, after }) => {const floor = Math.abs(before) * MEANINGFUL_CHANGE_RATIO;// A metric that was zero before has no ratio to scale by; any real// arrival counts as movement.const threshold = before === 0 ? Number.EPSILON : floor;- if (after - before > threshold) improved += 1;- else if (before - after > threshold) declined += 1;+ if (after - before > threshold) return 1;+ if (before - after > threshold) return -1;+ return 0;+ };+ const moves = measured.map((m) => ({ metric: m.metric, dir: direction(m) }));+ const up = moves.some((m) => m.dir > 0);+ const down = moves.some((m) => m.dir < 0);++ const main = primary ? moves.find((m) => m.metric === primary) : null;+ if (main) {+ if (main.dir > 0) return down ? 'mixed' : 'improved';+ if (main.dir < 0) return up ? 'mixed' : 'declined';+ return 'no_meaningful_change';}-- if (improved > 0) return 'improved';- if (declined > 0) return 'declined';+ if (up && down) return 'mixed';+ if (up) return 'improved';+ if (down) return 'declined';return 'no_meaningful_change';}@@ -314,12 +336,17 @@ export async function validateAction(action, { now = new Date() } = {}) {// metrics. A fix whose pages were audited again is judged by that: the// check passing is its aim.const [signals, audit] = await Promise.all([signalOutcome(action.id), auditRecheck(action)]);- const finish = async (validation, outcome) => {+ // The verdict from the metrics kept, by its main metric; given `aims`,+ // only the metrics the action names count (see deriveOutcome).+ const finish = async (validation, aims = null) => {const beside = { ...(signals ? { signals } : {}), ...(audit ? { audit } : {}) };const kept =validation || Object.keys(beside).length? { measuredAt: now.toISOString(), ...(validation ?? {}), ...beside }: null;+ const outcome = validation+ ? deriveOutcome(validation.metrics, validation.primary, aims)+ : 'not_measurable';const verdict = (audit && auditOutcome(audit)) ?? outcome;await write(action.id, kept, verdict, now);return verdict;@@ -352,15 +379,18 @@ export async function validateAction(action, { now = new Date() } = {}) {before: before[metric],after: after[metric],}));+ // Its aim: the first of its success metrics a basket reads, else its visibility.+ const primary = (action.kpi_keys ?? []).find((key) => key in BASKET_KPIS) ?? 'ai_visibility';return finish({measuredAt: now.toISOString(),beforeWindow,afterWindow,metrics,+ primary,scope: { kind: 'basket', prompts: scope.promptIds.length, pages: scope.pages.length },},- deriveOutcome(metrics),+ action.kpi_keys ?? [],);}@@ -370,11 +400,17 @@ export async function validateAction(action, { now = new Date() } = {}) {// them (learning A1): "recover 6 prompts" moves those 6, which the whole// brand's numbers can bury. The brand-wide figures stay as a second line.// A basket that measured nothing (no answers, citations of prompts) leaves- // the action to the brand-wide measure below.+ // the action to the brand-wide measure below, and so does one that can't+ // read its main metric (citations of prompts): judged by another, a basket+ // could read "improved" while its aim fell brand-wide.+ let brand = null;+ let fallback = null;const targets = await targetScope(action);if (targets) {const asked = (action.kpi_keys ?? []).filter((key) => key in BASKET_KPIS);const keys = asked.length ? asked : Object.keys(BASKET_KPIS);+ // Its aim: the first metric it names, else what its targets read in.+ const primary = asked[0] ?? (targets.entity === 'pages' ? 'citations' : 'ai_visibility');const [before, after, brandBefore, brandAfter] = await Promise.all([measureBasket(action.brand_id, targets, beforeWindow.from, beforeWindow.to),measureBasket(action.brand_id, targets, afterWindow.from, afterWindow.to),@@ -389,7 +425,13 @@ export async function validateAction(action, { now = new Date() } = {}) {before: before[metric] ?? null,after: after[metric] ?? null,}));- if (metrics.some((m) => m.before != null && m.after != null)) {+ const read = (m) => m.before != null && m.after != null;+ const named = {+ entity: targets.entity,+ prompts: targets.promptIds.length,+ pages: targets.pages.length,+ };+ if (metrics.some((m) => m.metric === primary && read(m))) {const brandWide = kpiKeys.map((metric) => ({metric,unit: MEASURABLE_KPIS[metric],@@ -402,28 +444,31 @@ export async function validateAction(action, { now = new Date() } = {}) {beforeWindow,afterWindow,metrics,- scope: {- kind: 'targets',- entity: targets.entity,- prompts: targets.promptIds.length,- pages: targets.pages.length,- },+ primary,+ scope: { kind: 'targets', ...named },...(brandWide.length ? { brandWide } : {}),},- deriveOutcome(metrics),+ asked,);}+ // Read already, for the brand-wide measure below.+ if (kpiKeys.length) brand = { before: brandBefore, after: brandAfter };+ if (metrics.some(read)) {+ fallback = { kind: 'brand', reason: 'primary_not_in_basket', ...named };+ }}// An action with no success metrics has nothing to measure. That is a gap// in the rule that produced it, not a failure here — say so plainly rather// than inventing a metric it never claimed.- if (kpiKeys.length === 0) return finish(null, 'not_measurable');+ if (kpiKeys.length === 0) return finish(null);- const [before, after] = await Promise.all([- measureKpis(action.brand_id, kpiKeys, beforeWindow.from, beforeWindow.to),- measureKpis(action.brand_id, kpiKeys, afterWindow.from, afterWindow.to),- ]);+ const [before, after] = brand+ ? [brand.before, brand.after]+ : await Promise.all([+ measureKpis(action.brand_id, kpiKeys, beforeWindow.from, beforeWindow.to),+ measureKpis(action.brand_id, kpiKeys, afterWindow.from, afterWindow.to),+ ]);const metrics = kpiKeys.map((metric) => ({metric,@@ -432,10 +477,17 @@ export async function validateAction(action, { now = new Date() } = {}) {after: after[metric] ?? null,}));- return finish(- { measuredAt: now.toISOString(), beforeWindow, afterWindow, metrics },- deriveOutcome(metrics),- );+ // Its aim: the first success metric its signals name. Measured here for a+ // basket that couldn't read it, the scope says so.+ const primary = kpiKeys[0];+ return finish({+ measuredAt: now.toISOString(),+ beforeWindow,+ afterWindow,+ metrics,+ primary,+ ...(fallback ? { scope: fallback } : {}),+ });}async function write(actionId, validation, outcome, now) {diff --git a/server/src/lib/action-center/validate.test.js b/server/src/lib/action-center/validate.test.jsindex 32ddebea9..905636e9b 100644--- a/server/src/lib/action-center/validate.test.js+++ b/server/src/lib/action-center/validate.test.js@@ -89,10 +89,34 @@ describe('deriveOutcome', () => {expect(deriveOutcome([pair('citations', 100, 100 - wobble)])).toBe('no_meaningful_change');});- it('reports an improvement when one metric rose and another fell', () => {- expect(deriveOutcome([pair('citations', 100, 150), pair('mentions', 100, 50)])).toBe(- 'improved',- );+ it('reads one metric up and another down as mixed, not improved (learning A4)', () => {+ expect(deriveOutcome([pair('citations', 100, 150), pair('mentions', 100, 50)])).toBe('mixed');+ });++ it('lets the main metric decide, mixed when another moved the other way', () => {+ const up = pair('citations', 100, 150);+ const down = pair('mentions', 100, 50);+ const still = pair('ai_visibility', 40, 40);+ expect(deriveOutcome([up, still], 'citations')).toBe('improved');+ expect(deriveOutcome([up, down], 'citations')).toBe('mixed');+ expect(deriveOutcome([down, still], 'mentions')).toBe('declined');+ // Its aim didn't move: no meaningful change, whatever moved beside it.+ expect(deriveOutcome([up, still], 'ai_visibility')).toBe('no_meaningful_change');+ // A main metric not measured leaves it to the others.+ expect(deriveOutcome([up], 'mentions')).toBe('improved');+ });++ it('counts only the metrics the action aims at, given them', () => {+ const visibility = { metric: 'ai_visibility', unit: 'percent', before: 20, after: 30 };+ const lead = { metric: 'competitor_lead', unit: 'points', before: 0.4, after: 0.3 };+ // A basket reads its lead too; the action never aimed at it.+ expect(deriveOutcome([visibility, lead], 'ai_visibility', ['ai_visibility'])).toBe('improved');+ // One it names moving the other way is mixed.+ expect(+ deriveOutcome([visibility, lead], 'ai_visibility', ['ai_visibility', 'competitor_lead']),+ ).toBe('mixed');+ // None of them read: nothing it aims at could be.+ expect(deriveOutcome([lead], 'ai_visibility', ['ai_visibility'])).toBe('not_measurable');});// Nothing to scale a ratio by, so any real arrival counts.@@ -274,6 +298,34 @@ describe('validateAction', () => {expect(patch.validation.scope).toEqual({ kind: 'basket', prompts: 2, pages: 0 });});+ it('judges a basket by the metrics the action names, keeping the rest to see', async () => {+ // Visibility 20 → 30 on the prompts; the lead over the top competitor 0.4 → 0.3.+ const basket = (before, after) =>+ rpc.mockImplementation(async (_name, args) => ({+ data: args.p_from < daysAgo(20).slice(0, 10) ? before : after,+ error: null,+ }));+ const sent = (kpiKeys) =>+ action({ kind: 'mention_review', kpi_keys: kpiKeys, payload: { promptIds: ['p1'] } });++ let writes = mockWrites();+ basket(+ { cells: 100, visible: 20, top_competitor_visible: 19.6 },+ { cells: 100, visible: 30, top_competitor_visible: 29.7 },+ );+ expect(await validateAction(sent(['ai_visibility']), { now: NOW })).toBe('improved');+ const { validation } = writes.updated.find((w) => w.table === 'actions').patch;+ expect(validation.metrics.find((m) => m.metric === 'competitor_lead')).toMatchObject({+ before: 0.4,+ after: 0.3,+ });++ writes = mockWrites();+ expect(await validateAction(sent(['ai_visibility', 'competitor_lead']), { now: NOW })).toBe(+ 'mixed',+ );+ });+it('measures pages sent from AI Traffic on those pages (AT-006)', async () => {const writes = mockWrites();rpc.mockResolvedValue({ data: {}, error: null });@@ -426,6 +478,51 @@ describe('validateAction', () => {expect(validation.brandWide.map((m) => m.metric)).toEqual(['ai_visibility', 'citations']);});+ it('measures brand-wide when the basket can’t read its main metric', async () => {+ // Citations first, on prompts: a prompt basket has no pages to count them on.+ const writes = mockWrites();+ rpc.mockImplementation(async (name, args) => {+ if (name === 'opportunity_basket_metrics') {+ const before = args.p_from < daysAgo(20).slice(0, 10);+ return { data: { cells: 10, visible: 4, mention_answers: before ? 2 : 6 }, error: null };+ }+ const before = args.p_day_from < daysAgo(20).slice(0, 10);+ return {+ data: { total_citations: before ? 100 : 80, total_mentions: 50 },+ error: null,+ };+ });++ const outcome = await validateAction(+ action({+ kind: 'recover_lost_visibility',+ kpi_keys: ['citations', 'mentions'],+ payload: { targetEntity: 'prompts', targetCount: 1, targets: [{ id: P1 }] },+ }),+ { now: NOW },+ );++ // The prompts' mentions tripled; the citations it aims at fell brand-wide.+ expect(outcome).toBe('declined');+ const { validation } = writes.updated.find((w) => w.table === 'actions').patch;+ expect(validation.primary).toBe('citations');+ expect(validation.metrics).toEqual([+ { metric: 'citations', unit: 'count', before: 100, after: 80 },+ { metric: 'mentions', unit: 'count', before: 50, after: 50 },+ ]);+ expect(validation.scope).toEqual({+ kind: 'brand',+ reason: 'primary_not_in_basket',+ entity: 'prompts',+ prompts: 1,+ pages: 0,+ });+ expect(validation.brandWide).toBeUndefined();+ // The brand-wide figures were read once, not again.+ const brandCalls = rpc.mock.calls.filter(([name]) => name === 'insights_aggregates_daily');+ expect(brandCalls).toHaveLength(2);+ });+it('reads a page written as a path on the brand’s primary domain', async () => {mockWrites({ brand_domains: [{ domain: 'https://www.acme.example/' }] });answers({}, {});diff --git a/supabase/migrations/00365_action_outcome_mixed.sql b/supabase/migrations/00365_action_outcome_mixed.sqlnew file mode 100644index 000000000..9e96b3952--- /dev/null+++ b/supabase/migrations/00365_action_outcome_mixed.sql@@ -0,0 +1,25 @@+-- ============================================================================+-- 00365: an action's result can read "mixed" (learning A4)+-- ============================================================================+-- The validation sweep (server/src/lib/action-center/validate.js) compares an+-- action's metrics before it was raised and after it closed. One metric up+-- and another down used to read as "improved", which taught that anything+-- moving up was the work paying off. It now reads "mixed", as does a Site+-- Audit fix whose pages, audited again, only partly pass. The action's main+-- metric decides when it was measured; see deriveOutcome.++alter table public.actions+ drop constraint if exists actions_outcome_check;++alter table public.actions+ add constraint actions_outcome_check+ check (outcome in (+ 'pending_measurement',+ 'improved',+ 'mixed',+ 'no_meaningful_change',+ 'declined',+ 'not_measurable'+ ));++notify pgrst, 'reload schema';diff --git a/supabase/schema.sql b/supabase/schema.sqlindex 224ea6d98..eba5c3b50 100644--- a/supabase/schema.sql+++ b/supabase/schema.sql@@ -41860,6 +41860,35 @@ comment on table public.content_shopping_checks isnotify pgrst, 'reload schema';+-- ─────────────────────────────────────────────────────────────────────────+-- migrations/00365_action_outcome_mixed.sql+-- ─────────────────────────────────────────────────────────────────────────+-- ============================================================================+-- 00365: an action's result can read "mixed" (learning A4)+-- ============================================================================+-- The validation sweep (server/src/lib/action-center/validate.js) compares an+-- action's metrics before it was raised and after it closed. One metric up+-- and another down used to read as "improved", which taught that anything+-- moving up was the work paying off. It now reads "mixed", as does a Site+-- Audit fix whose pages, audited again, only partly pass. The action's main+-- metric decides when it was measured; see deriveOutcome.++alter table public.actions+ drop constraint if exists actions_outcome_check;++alter table public.actions+ add constraint actions_outcome_check+ check (outcome in (+ 'pending_measurement',+ 'improved',+ 'mixed',+ 'no_meaningful_change',+ 'declined',+ 'not_measurable'+ ));++notify pgrst, 'reload schema';+-- ─────────────────────────────────────────────────────────────────────────-- migrations/00367_content_suggestion_decisions.sql-- ─────────────────────────────────────────────────────────────────────────diff --git a/web/messages/en.json b/web/messages/en.jsonindex 08617532f..0b1debffe 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -1286,7 +1286,7 @@"task_run_failed": "{task} — the automatic attempt failed; it needs doing by hand","task_awaiting_approval": "{task} — waiting for your approval before it reaches outside Ansvisor","position_outcome_recorded": "{measurable, plural, =0 {30-day result: not enough data to compare positions} other {30-day result: position improved on {improved} of # platforms}}",- "outcome_measured": "{outcome, select, improved {Result: metrics improved after this action closed} declined {Result: metrics declined after this action closed} no_meaningful_change {Result: no meaningful change in metrics after this action closed} not_measurable {Result: could not be measured} other {Result measured}}"+ "outcome_measured": "{outcome, select, improved {Result: metrics improved after this action closed} mixed {Result: mixed after this action closed} declined {Result: metrics declined after this action closed} no_meaningful_change {Result: no meaningful change in metrics after this action closed} not_measurable {Result: could not be measured} other {Result measured}}"},"deleteTask": "Delete task","addTask": "Add task",@@ -2596,6 +2596,7 @@"triggeredBy": "Consolidated from {count, plural, one {# signal} other {# signals}}","measuredOn": "Measured on the {entity, select, pages {{count, plural, one {page} other {# pages}}} other {{count, plural, one {prompt} other {# prompts}}}} it named.","brandWide": "Brand-wide over the same days: {list}",+ "primary": "Judged by {metric}, its main metric.","auditAfter": "Audited again since it closed: {passed} of {audited} {audited, plural, one {page passes} other {pages pass}}.","auditNotYet": "None of its {pages, plural, one {page} other {# pages}} was audited again since it closed: the result is from the metrics.","signalsAfter": "Of the {total, plural, one {signal} other {# signals}} that raised it, when measured: {ended} ended{replaced, plural, =0 {} other {, # turned into another}}{dismissed, plural, =0 {} other {, # dismissed}}{open, plural, =0 {} other {, # still open}}.",@@ -2635,21 +2636,29 @@"outcomeHint": {"pending_measurement": "no result recorded","improved": "vs before",+ "mixed": "vs before","no_meaningful_change": "vs before","declined": "vs before",- "not_measurable": "action was dismissed"+ "not_measurable": "nothing to read"},"outcomeExplain": {"pending_measurement": "This action's effect has not been measured. The metrics below fill in once validation runs.","improved": "Measured after this action closed.",+ "mixed": "Measured after this action closed; some metrics moved up and others down, or only some of its pages pass.","no_meaningful_change": "Measured after this action closed; the metrics did not move.","declined": "Measured after this action closed; the metrics moved the wrong way.",- "not_measurable": "This action was dismissed, so nothing was measured."+ "not_measurable": "Measured after this action closed; nothing it aims at could be read."+ },+ "dismissedResult": {+ "label": "Not measured",+ "hint": "dismissed",+ "explain": "Not measured: it was dismissed, and only a completed action is measured."}},"actionOutcome": {"pending_measurement": "Not measured","improved": "Improved",+ "mixed": "Mixed","no_meaningful_change": "No meaningful change","declined": "Declined","not_measurable": "Not measurable"diff --git a/web/src/components/action-center/history-drawer.test.tsx b/web/src/components/action-center/history-drawer.test.tsxindex 2dcdc9fc3..796668ca0 100644--- a/web/src/components/action-center/history-drawer.test.tsx+++ b/web/src/components/action-center/history-drawer.test.tsx@@ -208,6 +208,43 @@ describe('HistoryDrawer', () => {);});+ it('names the main metric it was judged by, and reads a mixed result (learning A4)', async () => {+ getActionSignals.mockResolvedValue([]);+ render(+ <HistoryDrawer+ brandId="b1"+ item={{ ...item, outcome: 'mixed', results: [], primaryMetric: 'citations' }}+ onOpenChange={() => {}}+ />,+ );+ await act(async () => {});+ const result = under('Result');+ expect(result).toMatch(/Judged by \S.*, its main metric\./);+ expect(result).toContain(+ 'some metrics moved up and others down, or only some of its pages pass',+ );+ });++ it('says a dismissed action was not measured, not that nothing could be read', async () => {+ getActionSignals.mockResolvedValue([]);+ for (const outcome of ['not_measurable', 'pending_measurement'] as const) {+ render(+ <HistoryDrawer+ brandId="b1"+ item={{ ...item, status: 'dismissed', outcome }}+ onOpenChange={() => {}}+ />,+ );+ await act(async () => {});+ const result = under('Result');+ expect(result).toContain(+ 'Not measured: it was dismissed, and only a completed action is measured.',+ );+ expect(result).not.toContain('could be read');+ expect(result).not.toContain('fill in once validation runs');+ }+ });+it('keeps the general sentences when the signals cannot be read', async () => {getActionSignals.mockRejectedValue(new Error('offline'));render(<HistoryDrawer brandId="b1" item={item} onOpenChange={() => {}} />);diff --git a/web/src/components/action-center/history-drawer.tsx b/web/src/components/action-center/history-drawer.tsxindex 601de6853..2da44506d 100644--- a/web/src/components/action-center/history-drawer.tsx+++ b/web/src/components/action-center/history-drawer.tsx@@ -208,6 +208,11 @@ export function HistoryDrawer({<section><p className="text-xs font-medium text-muted-foreground">{t('drawer.result')}</p>+ {item.primaryMetric && (+ <p className="mt-1 text-xs text-muted-foreground">+ {t('drawer.primary', { metric: tRegistry(`${item.primaryMetric}.name`) })}+ </p>+ )}{item.measuredOn && (<p className="mt-1 text-xs text-muted-foreground">{t('drawer.measuredOn', { ...item.measuredOn })}@@ -230,7 +235,9 @@ export function HistoryDrawer({// line is recorded; the effect is not, because nothing re-reads// these metrics after an action closes.<p className="mt-1 text-xs text-muted-foreground">- {t(`outcomeExplain.${item.outcome}`)}+ {item.status === 'dismissed'+ ? t('dismissedResult.explain')+ : t(`outcomeExplain.${item.outcome}`)}</p>)}<div className="mt-2 grid grid-cols-2 gap-2">diff --git a/web/src/components/action-center/history-table.test.tsx b/web/src/components/action-center/history-table.test.tsxindex 2e4166a6c..26546705e 100644--- a/web/src/components/action-center/history-table.test.tsx+++ b/web/src/components/action-center/history-table.test.tsx@@ -109,6 +109,25 @@ describe('HistoryTable', () => {expect(cells[headers.indexOf('Affected')]?.textContent).toBe(text);await act(async () => root.unmount());});++ // Only a completed action is measured; one dismissed before 00084 reads+ // not measurable, one since pending: neither is what happened.+ it.each(['not_measurable', 'pending_measurement'] as const)(+ 'says a dismissed action (%s) was not measured because it was dismissed',+ async (outcome) => {+ const root = await render(+ <HistoryTable+ items={[item({ status: 'dismissed', outcome })]}+ selectedId={null}+ onSelect={() => {}}+ />,+ );+ const headers = Array.from(document.body.querySelectorAll('th')).map((th) => th.textContent);+ const cells = document.body.querySelectorAll('tbody td');+ expect(cells[headers.indexOf('Result')]?.textContent).toBe('Not measureddismissed');+ await act(async () => root.unmount());+ },+ );});describe('HistoryDrawer', () => {diff --git a/web/src/components/action-center/history-table.tsx b/web/src/components/action-center/history-table.tsxindex 8c6c193bf..c4d4327bb 100644--- a/web/src/components/action-center/history-table.tsx+++ b/web/src/components/action-center/history-table.tsx@@ -100,6 +100,17 @@ function ResultCell({ item }: { item: ActionHistoryItem }) {if (position) return <div className="space-y-0.5">{position}</div>;+ // Only a completed action is measured. A dismissed one's outcome reads+ // pending, or not measurable from before (00084): neither says why.+ if (item.status === 'dismissed') {+ return (+ <div className="space-y-0.5">+ <p className="text-xs text-muted-foreground">{t('dismissedResult.label')}</p>+ <p className="text-[11px] text-muted-foreground/70">{t('dismissedResult.hint')}</p>+ </div>+ );+ }+return (<div className="space-y-0.5"><p className="text-xs text-muted-foreground">{tOutcome(item.outcome)}</p>diff --git a/web/src/lib/action-center/history.ts b/web/src/lib/action-center/history.tsindex c44074924..686782b1b 100644--- a/web/src/lib/action-center/history.ts+++ b/web/src/lib/action-center/history.ts@@ -122,6 +122,8 @@ export interface ActionHistoryItem {* A1), with the brand-wide figures kept as a second line.*/measuredOn?: { entity: 'prompts' | 'pages'; count: number } | null;+ /** The metric its result is judged by (learning A4); absent before it was measured. */+ primaryMetric?: string | null;/** A Site Audit fix's pages audited again since it closed, and how many pass (learning A2). */auditAfter?: { pages: number; audited: number; passed: number } | null;brandWideResults?: ActionResultMetric[];diff --git a/web/src/lib/action-center/registry.ts b/web/src/lib/action-center/registry.tsindex b33d489e2..290b00b35 100644--- a/web/src/lib/action-center/registry.ts+++ b/web/src/lib/action-center/registry.ts@@ -32,6 +32,8 @@ export type ActionStatus = 'new' | 'in_progress' | 'on_hold' | 'completed' | 'diexport type ActionOutcome =| 'pending_measurement'| 'improved'+ // One metric up and another down, or a fix's pages only partly passing (learning A4).+ | 'mixed'| 'no_meaningful_change'| 'declined'| 'not_measurable';@@ -149,6 +151,7 @@ export const OPEN_ACTION_STATUSES: readonly ActionStatus[] = ['new', 'in_progresexport const ACTION_OUTCOMES: readonly ActionOutcome[] = ['pending_measurement','improved',+ 'mixed','no_meaningful_change','declined','not_measurable',diff --git a/web/src/lib/actions/action-history.ts b/web/src/lib/actions/action-history.tsindex f231fed4d..c2496c1dd 100644--- a/web/src/lib/actions/action-history.ts+++ b/web/src/lib/actions/action-history.ts@@ -75,6 +75,8 @@ interface ValidationSnapshot {brandWide?: ValidationSnapshot['metrics'];/** A Site Audit fix's pages audited again (learning A2). */audit?: { pages?: number; audited?: number; passed?: number };+ /** The metric its result is judged by (learning A4). */+ primary?: string;}/** A Site Audit fix's pages audited again, when the sweep read them. */@@ -311,6 +313,10 @@ export async function getActionHistory(signalsAfter: signalsFrom(row.validation),measuredOn: measuredOnFrom(row.validation),auditAfter: auditFrom(row.validation),+ // Shown only when it was measured: a main metric with no pair says nothing.+ primaryMetric: resultsFrom(row.validation).some((m) => m.metric === row.validation?.primary)+ ? (row.validation?.primary ?? null)+ : null,brandWideResults: resultsFrom(row.validation?.brandWide ? { ...row.validation, metrics: row.validation.brandWide } : null,),diff --git a/web/src/lib/mcp/server.ts b/web/src/lib/mcp/server.tsindex b6d6a4b38..0ab8ed315 100644--- a/web/src/lib/mcp/server.ts+++ b/web/src/lib/mcp/server.ts@@ -1263,7 +1263,7 @@ export function createMcpServer(auth: McpAuthContext): McpServer {'list_action_history',{description:- 'List closed Action Center actions (completed or dismissed) for a brand with their measured result, most recently closed first. `outcome` is the verdict (improved, no_meaningful_change, declined, not_measurable, or pending_measurement while the after-window is still open) and `results` holds the before/after values the validation sweep measured. Use this to answer "did what we did last month work?".',+ 'List closed Action Center actions (completed or dismissed) for a brand with their measured result, most recently closed first. `outcome` is the verdict (improved, mixed when its metrics moved both ways or only some of a fix\u2019s pages pass, no_meaningful_change, declined, not_measurable, or pending_measurement while the after-window is still open) and `results` holds the before/after values the validation sweep measured. Use this to answer "did what we did last month work?".',inputSchema: {brand_id: relaxedUuid.describe('Brand UUID, from list_brands.'),limit: z