Skip to content

feat(signals): record what a lost citation rests on and show it - #1061

Merged
gkhngyk merged 35 commits into
ansvisor:mainfrom
cihan-gyk:feature/lost-citation-evidence
Oct 17, 2026
Merged

gkhngyk merged 35 commits into
ansvisor:mainfrom
cihan-gyk:feature/lost-citation-evidence

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Part two of AC-001, for lost citations. Stacked on #1060, which is on #1059 and #1058. Please review the fourth commit, feat(signals): record what a lost citation rests on and show it, or merge those first.

A lost citation was recorded with its prompt only. The drawer from #1060 could therefore only say "Not available" for the page that lost its citation and for who is cited now, and could not say where it was lost. The spec's example: "Citation lost on ChatGPT for '…'", with the lost URL, the URLs cited now with their position, and "Cited in runs 5/5 → 0/6".

Server: record the evidence

server/src/lib/signals/lost-citation-evidence.js runs in the recorder for the prompts the pulse found lost. Its reads:

  • the prompts' answers over the detector's 14 days (columns only);
  • the brand's domains;
  • the citations of the answers that matter: per platform, the latest one citing the brand and the newest two quiet ones.

It writes, in the signal's payload:

Field Meaning
platforms, regions Where it was lost: those that cited the brand before. None of the quiet answers cite it anywhere, or the signal would not exist.
lostUrls The brand's pages in the latest citing answers, with position, last cited date and platforms. A page is one page whatever its spelling (www, slash, query).
citedNow Pages the quiet answers cite instead, with best position, answers and answersRead. The panel says "in 3 of 4 latest answers", so a sample never reads as all of them.
citedDays, days, quietDays Cited on 9 of the 11 earlier result days, on none of the latest 3: the detector's own buckets.

How it behaves:

  • Best effort: a failed read logs and records the signal as before.
  • Keeps earlier evidence: a night whose read fails keeps the evidence an earlier night recorded (keepRecordedEvidence), instead of wiping it on refresh.
  • Existing open signals get their evidence on the next nightly pass, since the refresh rewrites the payload.
  • Shared rule: ownDomainMatcher is the rule countOwnDomainCitations already applied, now shared rather than copied.

Web: show it

  • Where:
  • What changed: "Cited days · earlier days 9 / 11 → latest days 0 / 3", with the period "Days with answers in the last 14 days".
  • Title and row:
    • A loss on one platform says so: "Citations lost on ChatGPT for '…'".
    • The description names the page: "acme-coffee.example.com/blog/… is no longer cited on ChatGPT."
    • A group of copies names a platform only if every copy recorded the same one.
  • MCP list_signals returns the same:
    • where.lost_url and where.cited_now with position, last_cited_at, answers, answers_read;
    • change with cited_days and of.
  • Older rows keep the generic copy and "Not available".

Review

I ran a code review before opening this. Fixed:

  • a failed read wiping earlier evidence;
  • "in N answers" not saying it is a sample;
  • a group titled from one copy's platform;
  • quadratic grouping;
  • the same page listed twice under different spellings;
  • no test of the recorder step.

Left as is: the evidence step reads the lost prompts' answers again after the detector's scan, a few thousand rows at most per pass. Having the pulse return platform and region from its own scan would save that read, but would widen the pulse's shared output.

Related issue

None. Product spec AC-001 (Action Center), part 2 for lost citations. Competitor positions and mention details are next.

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. Run a signal pass for a brand with a lost citation, or wait for the nightly one.
  2. The lost-citation row says which page is no longer cited and where.
  3. Open it:
    • Platforms and Locations;
    • "Your page cited before" with position and last cited date;
    • "Cited now" with position and "in N of M latest answers";
    • Cited days earlier → latest.
  4. Call MCP list_signals: where.lost_url, where.cited_now, and change with cited_days.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): 0 errors; the 7 warnings are in files this PR doesn't touch
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run:

  • server: npm run format, npm run lint (clean), and npm test 1184/1184. New tests:
    • lost-citation-evidence.test.js: the summary, page de-duplication, the sample count, and which answers are read back.
    • record-evidence.test.js: evidence attached, a failed read, evidence kept from an earlier night.
  • web: yarn test 601/601 (detail, display, where, group, drawer blocks) and yarn build.
  • Against the dev database (read-only): ran lostCitationEvidence for a demo prompt. The queries work on the real schema, and the platforms, regions, day counts and cited-now pages came back.
    • The demo seed has citation_count > 0 without the brand's domain in citations, so lostUrls was empty there, as it should be.
  • In the browser: the drawer with recorded evidence, in light and dark mode, at 1440px and 1024px.

🤖 Generated with Claude Code

cihan-gyk and others added 4 commits October 15, 2026 14:20
…ls by platform

The Signals list never said which AI platform or location a signal was
about, and named platforms by their raw ids ("Visibility dropped on
gemini-web", "Weak in JP"). Part one of AC-002:

- Each row's Affected cell gets a line with the engines and locations the
  signal is about: from the payload for platform and country signals, and
  from the prompts' tracked platforms and locations for prompt and topic
  signals. A line rather than a column keeps the table within the page
  beside a pinned sidebar.
- Platforms and locations read as people know them ("Gemini", "Japan").
- Descriptions carry the measured fact instead of a generic sentence, e.g.
  "Your mention rate fell from 34% to 18% against the week before."
- A Platform filter, search over platform and location names, and
  platforms and locations columns in the CSV export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A brand can track the same prompt text as several prompts, and the
detectors write one signal per prompt: on production one pass wrote ten
identical "Citations lost for '…'" rows, which read as duplicates and
inflated every count. Part two of AC-002:

- Signals of one kind, about one prompt text (case, spacing and the
  closing "?" ignored), found in one pass are one row with a "×N grouped"
  toggle. Opened, it lists each copy with its topic, place and status; each
  copy keeps its own drawer and menu, and the group's menu acts on the
  copies it applies to.
- The category tabs, the tab badge and the summary cards count groups.
  Migration 00141 adds signal_group_key (the same rule as
  lib/signals/group.ts), counts signals_summary over groups, where a group
  is resolved only once every copy is, and adds signals_new_count for the
  badge.
- A drawer opened from a link to a copy opens its group.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hat it rests on

The signal drawer showed bare numbers ("0 → 251 +167") and no platform,
location, page or action. Part one of AC-001: the drawer has three blocks.

- Where: the fields the spec asks per category (prompt, topic, platforms,
  locations, domain, competitor, pages, queries, and for a lost citation
  the page cited before and who is cited now). A field no detector records
  yet says "Not available"; platforms read from a signal's prompts say
  "Tracked on".
- What changed: every figure with its metric, whose or which window, and
  unit, over its period: "Mention rate · previous 7 days 34% → last 7 days
  18%, −16 pts". A source domain's three counts are named instead of read
  as a before and after. A fall in the brand's own numbers is red, a
  competitor's rise too (the old colouring showed drops as good news).
- Evidence and links: the page behind the signal (the prompt's answers, the
  topic, Citations…), first and last detection, and the actions using it.

MCP list_signals returns the same detail per signal (where, change,
evidence, used_by_actions) beside the raw row, from lib/signals/detail.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A lost citation was recorded with its prompt only, so the drawer could not
say which page lost its citation, where, or who replaced it. Part two of
AC-001, for lost citations:

- The recorder reads the lost prompts' answers back (server
  signals/lost-citation-evidence.js) and writes, with the signal: the
  platforms and locations it was lost on, the brand's page cited before
  with its position and last cited date, the pages cited in the quiet
  answers with their position and how many of the answers read cite them,
  and its cited days before and since. Best effort, and a night whose read
  fails keeps the evidence an earlier night recorded.
- The drawer shows them: Platforms and Locations (where it was lost),
  "Your page cited before", "Cited now", and "Cited days · earlier 9 / 11
  → latest 0 / 3". A loss on one platform names it in the title ("Citations
  lost on ChatGPT for …"), and the row says which page is no longer cited.
- MCP list_signals returns the same evidence.
- ownDomainMatcher is the own-domain rule countOwnDomainCitations already
  used, now shared.

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

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Part 2 of AC-001 for lost citations, stacked on #1060 → #1059 → #1058 (please review the fourth commit or merge those first). The recorder now writes, with each lost citation, the platforms and locations it was lost on, the brand's page cited before (position, last cited date), who is cited now (position, how many of the latest answers), and its cited days before and since; the drawer, row copy and MCP list_signals show them. Existing open signals pick it up on the next nightly pass.

cihan-gyk and others added 13 commits October 16, 2026 12:31
…ure/signals-grouping

# Conflicts:
#	supabase/schema.sql
…ure/signals-grouping

# Conflicts:
#	supabase/schema.sql
…on-evidence

# Conflicts:
#	supabase/schema.sql
…on-evidence

# Conflicts:
#	supabase/schema.sql
…-evidence

main carries ansvisor#1058 and ansvisor#1059 as squashes; this branch keeps ansvisor#1060's commit and its own on top.
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 17, 2026
gkhngyk
gkhngyk previously approved these changes Oct 17, 2026

@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.

Thanks, approving. I merged main into the branch so it keeps only its own commit on top of #1060. The ownDomainMatcher split leaves the own-domain count unchanged, and the evidence reads stay bounded by the lost prompts and the window. CI is green.

…-evidence

main now carries ansvisor#1060 as a squash; the tree is unchanged.
@gkhngyk
gkhngyk dismissed their stale review October 17, 2026 10:16

The merge-base changed after approval.

@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.

Re-approving after merging the new main (with #1060) into the branch; the tree is the one CI passed.

@gkhngyk
gkhngyk merged commit 4685e49 into ansvisor:main Oct 17, 2026
5 checks passed
gkhngyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 17, 2026
…gnal-evidence

main carries ansvisor#1058 through ansvisor#1061 as squashes; this branch keeps only its own commit on top, with schema.sql regenerated.
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