Skip to content

feat(action-center): read a result by the action's main metric, and say "mixed" when its metrics moved both ways (learning A4) - #1690

Merged
gkhngyk merged 11 commits into
ansvisor:mainfrom
cihan-gyk:feature/outcome-mixed-primary
Oct 28, 2026
Merged

gkhngyk merged 11 commits into
ansvisor:mainfrom
cihan-gyk:feature/outcome-mixed-primary

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Learning phase A, A4: a result is read by the action's main metric, and says "mixed" when the metrics it names moved both ways.

Stacked on #1689. This PR's own commits: bd5d0d8, 18e00bc, 5500708, c427343 and cc1f9c8. Migration 00365.

One metric up and another down read as "improved": the verdict counted any rise as the work paying off, which is the wrong lesson to learn from.

How the verdict is read now

  • deriveOutcome takes the action's main metric. When it's measured, it decides: up is improved, down is declined, still is no meaningful change, and mixed when another metric the action names moved the other way.
  • When the main metric isn't measured, the metrics the action names count, and movement both ways is mixed.
  • The main metric is the first success metric the action names; otherwise, what its targets are read in (citations for pages, visibility for prompts). It's kept as validation.primary.
  • A Site Audit fix whose pages only partly pass when audited again (A2) reads mixed.

Migration 00365: adds 'mixed' to actions_outcome_check, with notify pgrst. Applied on the dev database; schema.sql rebuilt.

Web:

  • the outcome type and list;
  • "Mixed" in the labels, hints, explanation and History line;
  • the drawer line "Judged by Citations, its main metric.";
  • the MCP list_action_history description names mixed.

Pre-push review fixes:

  • 18e00bc: only the metrics the action names (kpi_keys) and its main metric count. Before, a basket's other metrics drifting the other way (e.g. visibility 20 → 30 with the competitor lead 0.4 → 0.3) made it "mixed". The others stay in validation.metrics, to see.
  • 5500708: when an action's targets can't read its main metric (e.g. citations for prompts), the whole result comes from the brand-wide measure (scope: { kind: 'brand', reason: 'primary_not_in_basket' }). Before, it was judged by another metric.
  • c427343: a dismissed action reads "Not measured: it was dismissed, and only a completed action is measured." in History. Before, it read either "nothing it aims at could be read" or "fills in once validation runs".
  • cc1f9c8: notify pgrst in 00365.

Follow-up: the coach skills' outcome list (skills/ansvisor-aeo-coach/SKILL.md) needs mixed, in a separate docs PR.

Where people see it: Action Center › History: the Result column and the drawer.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Apply 00365.
  2. cd server && npx vitest run src/lib/action-center/validate.test.js
  3. cd web && npx vitest run src/components/action-center/history-drawer.test.tsx src/components/action-center/history-table.test.tsx

Related issue

Agentic learning report (artifact; draft in the maintainers' notes), phase A: "measure correctly". No GitHub issue. Learning stays within one brand (product decision).

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Full checks at the top of the phase A stack (A5, 596dba6):

  • server format, lint and npm test (no SUPABASE_* env, as in CI): 3,359 tests passed. content-people.test.js timed out under load and passed alone (32/32).
  • web format, lint (0 errors; 7 warnings already on main), typecheck, vitest (444 files, 4,348 tests) and build: all pass.

A pre-push review of the six branches was run, and its before-merge findings are fixed in the stack (A4: 18e00bc, 5500708, c427343, cc1f9c8; A6: 381f5c6, 52a34fb; A5: 639c3a17). Only new measurements change. Actions already measured keep their result; there's no backfill.

🤖 Generated with Claude Code

cihan-gyk and others added 10 commits October 28, 2026 08:48
… measured result

Learning phase A, A3 (the agentic learning report, gaps 2 and 4). An
action's result compared its metrics before and after, but never asked
the question closest to its own aim: did the signals that raised it end?
Signals close as resolved (the condition gone) or resolved with
`supersededBy` (still there, as another kind), and that never reached
the outcome.

- validate.js: when an action is measured, signalOutcome reads its
  signals through action_signals and keeps the counts in
  `validation.signals`: total, ended, replaced, dismissed, open. An action
  with no metric to measure keeps them too (its validation was null). An
  action no signal raised (sent from Content, Insights…) has none.
- History's drawer says it under Result: "Of the 4 signals that raised it,
  when measured: 2 ended, 1 turned into another, 1 still open."
- The Action Center guide says so.

The outcome itself is unchanged; A4 decides what counts as improved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pages it names, brand-wide beside

Learning phase A, A1 (the report's gap 2). The night engine's actions
were measured on the whole brand's figures, so "recover 6 prompts" was
judged by every prompt the brand tracks, and a small real effect drowned
in the rest. Their targets are in the payload already.

- validate.js: an action whose payload's targetEntity is 'prompts' or
  'pages' (targetScope) is measured on those targets with the basket
  measure the actions sent from Content use: every target it counts
  (targetIds, else targets), prompt ids as uuids, a page written as a
  path read on the brand's primary domain. The metrics are its basket
  KPIs that the action names (all six when it names none). The brand-wide
  figures over the same windows are kept as `brandWide`, and
  `scope: { kind: 'targets', entity, prompts, pages }` says what it was.
- A basket that measured nothing (no answers in either window) leaves the
  action to the brand-wide measure, as before; so does any other target
  (competitors, sources…).
- History's drawer: "Measured on the 2 prompts it named." under Result, and
  "Brand-wide over the same days: Citations 100 → 104" under the cards.
- The guide says so.

Stacked on feature/outcome-signals-resolved (A3): both change
validateAction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n since it closed

Learning phase A, A2 (the report's gap 3). F01, F03 and F10 had no metric
to measure (their signals name none), so their result always read "could
not be measured", and the audit's own answer was never asked: does the
page pass now? (A1 already measures them on their pages' citations and AI
sessions, which rarely move in a week for a technical fix.)

- audit-recheck.js: for each page target that names the checks that
  raised it (F03, F10…), the latest audit of the page since the action
  closed, by the address asked for or ended at; it passes when every named
  check does (validity's warn still fails, as the page check reads it). A
  low-scored page (F01) passes once its score is past the line its signal
  is raised under. `{ pages, audited, passed }`, kept as validation.audit.
- validate.js: a fix with pages audited again is judged by them: all or
  some passing reads improved, none no meaningful change (A4 will say
  mixed for some). With none audited again, the metrics judge, as before.
  validateAction's four writes now go through one `finish`, which keeps
  the signals (A3) and the audit beside the metrics.
- History's drawer: "Audited again since it closed: 1 of 2 pages pass.",
  or that none was yet and the result is from the metrics.
- The guide says so.

Stacked on feature/outcome-target-basket (A1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…akes

The A1 drawer test built its metrics with unit 'count', which
ActionResultMetric doesn't take: tsc failed on the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ay "mixed" when its metrics moved both ways

Learning phase A, A4 (the report's gap 4). One metric up and another down
read as "improved": the verdict counted any rise as the work paying off,
which is the wrong lesson to learn from.

- deriveOutcome takes the action's main metric. Measured, it decides: up
  improved, down declined, still no meaningful change, and `mixed` when
  another metric moved the other way. Without it measured, every metric
  counts and movement both ways is `mixed`.
- The main metric is the first success metric the action names (its
  signals' first; a basket's first it reads), else what its targets read
  in (citations for pages, visibility for prompts). It's kept as
  validation.primary.
- A Site Audit fix whose pages only partly pass when audited again (A2)
  reads `mixed` too.
- 00365 adds 'mixed' to actions_outcome_check (applied on the dev DB;
  schema.sql rebuilt).
- Web: the outcome type and list, "Mixed" in the outcome labels, hints,
  explanation and History line, and the drawer's "Judged by Citations, its
  main metric." The MCP list_action_history description names mixed. The
  not_measurable explanation and hint said "this action was dismissed"; they
  say nothing it aims at could be read.
- The guide says so.

Stacked on feature/outcome-audit-kinds (A2).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of learning A4. A basket reads every metric it can: visibility,
share of voice, the lead over the top competitor, mentions, citations and
AI sessions. Any one of them drifting the other way made the result
"mixed", though the action never aimed at it: visibility 20 → 30 with the
lead 0.4 → 0.3 read mixed for an action that names visibility alone.

- deriveOutcome takes the action's aims (its kpi_keys): given them, only
  those and its main metric count. The others stay in validation.metrics,
  to see. None of them read is not measurable.
- A basket sent from Content, Insights, Mentions, AI Traffic or the
  editor is judged by its kpi_keys; a night-engine action measured on its
  targets by the ones a basket reads. The brand-wide measure reads only
  its kpi_keys already.
- finish derives the verdict from the validation it keeps.
- The guide says other metrics show beside but don't count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… read its main metric

Review of learning A4. A night-engine action measured on the prompts it
names was judged by whatever its basket could read. One whose main metric
is citations (G02: citations, then mentions) reads no citations on
prompts, which have no pages to count them on, so its mentions decided:
"improved" while the citations it aims at fell brand-wide.

- validate.js: the targets decide only when their basket reads the main
  metric. Otherwise the whole result goes to the brand-wide measure, by
  the brand's main metric (its first kpi_key), reusing the brand-wide
  figures already read. validation.scope says why: kind 'brand', reason
  'primary_not_in_basket', with the targets' entity and counts.
- A basket that read nothing still leaves it brand-wide as before.
- The guide says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of learning A4. Only a completed action is measured. 00084 set the
dismissed ones of the time to not_measurable, which History now explains
as "Measured after this action closed; nothing it aims at could be
read." A dismissal since then stays pending_measurement, read as "The
metrics below fill in once validation runs." Neither is what happened.

- History's Result column and drawer read a dismissed action's status,
  not its outcome: "Not measured", dismissed; and in the drawer "Not
  measured: it was dismissed, and only a completed action is measured."
  A dismissed action that was measured first keeps its figures.
- The guide no longer says a dismissed action is Not measurable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of learning A4: 00365 ended without the notify every recent
migration ends with. schema.sql rebuilt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 0ee9db5.

Approve preview

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

What I checked:

  • Own change. bd5d0d8, 18e00bc, 5500708, c427343 and cc1f9c8, on top of #1689 (origin/pr/1689..origin/pr/1690). It needs #1687–#1689 merged first. On today's main (b591947) only supabase/schema.sql conflicts; bash supabase/build-schema.sh resolves it. 00365 is the only open PR using that number.
  • 00365. It drops and re-adds actions_outcome_check with mixed added. The old constraint (00084) is the only one with that name, and nothing else changes it. Running it twice is harmless. The add constraint scans actions once under a short exclusive lock, which is fine at that table's size. No grants or policies change.
  • deriveOutcome. The main metric decides when it was read. Without it, movement both ways reads mixed. Given aims, only the named metrics and the main one count, so a basket's extra metrics can't make a result mixed. When asked is empty on the targets path, only the main metric counts, which is the intent. The fallback to the brand-wide measure (primary_not_in_basket) reuses the brand figures it already read: two RPCs, not four.
  • Site Audit fix. A partial pass reads mixed, and all pass reads improved.
  • Web. mixed is in the outcome type, ACTION_OUTCOMES, the labels, hints and explanation, the event line and the MCP description. A dismissed row reads "Not measured · dismissed" in both the table and the drawer. That's web-only, and it's right before the API ships too.
  • Order. 00365 must be on the database before the API with this change goes out: until then, writing mixed fails the check, and the action stays pending and is retried the next night. Nothing is lost, but apply it first. The web can go out before the API.
  • Tests. On the PR's tree the action-center server tests pass, except three that read web/messages/en.json (they need the web folder beside them). On the stack merged with main, with the web laid out beside it, all 635 action-center server tests pass, and so do the History, drawer, registry and MCP web tests.

@gkhngyk
gkhngyk merged commit 517ced3 into ansvisor:main Oct 28, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants