Skip to content

feat(action-center): measure a night-engine action on the prompts or pages it names, brand-wide beside (learning A1) - #1688

Merged
gkhngyk merged 4 commits into
ansvisor:mainfrom
cihan-gyk:feature/outcome-target-basket
Oct 28, 2026
Merged

gkhngyk merged 4 commits into
ansvisor:mainfrom
cihan-gyk:feature/outcome-target-basket

Conversation

@cihan-gyk

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

Copy link
Copy Markdown
Collaborator

Summary

Learning phase A, A1: a night-engine action is measured on the prompts or pages it names, with the brand-wide figures beside.

Stacked on #1687. This PR's own commits: cc2031b and ac1b1af.

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. The targets were already in the payload.

  • An action whose payload's targetEntity is prompts or pages is measured on those targets. It uses the same basket measure as the actions sent from Content.
    • The basket counts every target (targetIds, else targets): prompt ids as uuids, and a page written as a path, read on the brand's primary domain.
    • The metrics are the basket KPIs 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 } records what the action was measured on.
  • If the basket measured nothing (no answers in either window), the action falls back to the brand-wide measure, as before. So does any other target type (competitors, sources…).
  • History's drawer:
    • under Result: "Measured on the 2 prompts it named.";
    • under the cards: "Brand-wide over the same days: Citations 100 → 104".
  • A4's review fix (feat(action-center): read a result by the action's main metric, and say "mixed" when its metrics moved both ways (learning A4) #1690) measures brand-wide when the targets can't read the action's main metric (e.g. citations for prompts).

Where people see it: Action Center › History › an action › Result.

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. cd server && npx vitest run src/lib/action-center/validate.test.js
  2. cd web && npx vitest run src/components/action-center/history-drawer.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 3 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]>
…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]>
@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 09f32c3.

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, with follow-ups.

Own change. cc2031b and ac1b1af on top of #1687 (origin/pr/1687..origin/pr/1688). Once #1687 is squashed, this PR's own change applies to main cleanly; GitHub will show conflicts in action-center.mdx until the branch takes main after that squash.

Checked

  • Targets. targetScope reads targetIds when the payload has them, else targets[].id. Prompts must be uuids. Pages must be http(s), or a path read on the brand's primary domain; a path with no domain is dropped rather than guessed. Any other targetEntity (competitors, sources, platforms) stays brand-wide, as before.
  • Measure. The basket goes through opportunity_basket_metrics with the same windows as the brand-wide measure. Empty prompt or page arrays read nothing there, not everything, so a pages basket can't read the whole brand's visibility. The brand-wide figures over the same windows are kept as brandWide, and scope.kind: 'targets' tells them apart from content baskets, so opportunity-reopen.js (which reads kind === 'basket') doesn't pick these up.
  • Web. measuredOnFrom shows the line only for kind: 'targets' with a count above 0, and the brand-wide line goes through resultsFrom, so a half-measured pair is dropped there too.
  • Tests. On this PR's tree, validate.test.js passes (26) and history-drawer.test.tsx passes (6). They also pass with the stack and main squashed together.

Follow-ups

  1. A pages basket always "measures" citations. basketValues returns citations as a number whenever there are pages (basket-metrics.js:71), 0 when nobody cites them. So the check at validate.js:383 is true for every pages basket, and the brand-wide fallback never runs for pages. For a Site Audit fix with no success metric (F03, F10…), the result moves from "Not measurable" to "No meaningful change" on Citations 0 → 0, and with #1690 citations become the main metric of a pages target. Treat a pages basket with no citations in either window (and no GA) as measured nothing, so it falls back as the description says.
  2. Units on the brand-wide line. history-drawer.tsx:254 prints before → after as bare numbers, so AI Visibility and Share of Voice read "12.3 → 14.1" without the % the cards above show. Format them with the same helper the cards use.

Before the API deploy. Nothing shows. Both new lines need the deployed sweep's scope.kind: 'targets' and brandWide; actions measured before keep their result.

@gkhngyk
gkhngyk merged commit e61a1fd 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants