Skip to content

fix(tracking): read more fan-out shapes and report an engine whose fan-out stops - #1056

Merged
gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:fix/fanout-capture-alerts
Oct 16, 2026
Merged

gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:fix/fanout-capture-alerts

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

The Query Fan-out page on app.ansvisor.com shows only Copilot, although the account tracks ChatGPT, Google AI Overviews, AI Mode and Gemini too. I checked it read-only in the app, without running queries on the production database. There are two causes.

1. ChatGPT's fan-out stopped on 2026-09-30

Counts of distinct sub-queries in the app's High-frequency view for our brand:

Window Copilot ChatGPT Perplexity AIO / AI Mode / Gemini
24h 175 0 0 0
7d 706 0 28 0
30d 2,374 2,691 8,423 0

ChatGPT sub-queries by day: Sep 22: 326, Sep 24: 315, Sep 26: 207, Sep 27: 71, Sep 28: 337, Sep 29: 72, Sep 30 to today: 0.

ChatGPT is still searching: its answer on Oct 15 cites 28 sources. Only the searchQueries field stopped arriving, or arrives in a shape we drop. Ruled out:

  • Parser: unchanged since 2026-08-24.
  • Sep 30 change: our only change that day (dc4a5af, run settlement) doesn't touch the request or the parse.
  • Cloro changelog: has nothing about it.

Still to do: a raw ChatGPT response from Cloro will tell whether the field is emptied or reshaped. That needs the production CLORO_API_KEY. See the script below.

2. AI Overviews, AI Mode and Gemini never had fan-out

Cloro documents no fan-out field for them. For Gemini there may be something in an undocumented rawResponse. This is not a bug, and the UI follow-up will say so.

What this PR changes

Parser (cloro-scraper.js):

  • Fan-out entries are read as strings or { query } objects in every field. A shape change can no longer empty a field silently, which is one of the two candidates for ChatGPT.
  • ChatGPT's mapSearchQueries (searches on its map) is kept, with engine: 'maps'.
  • An empty search_model_queries no longer hides a populated searchQueries.

Daily health report, new section "Query fan-out":

  • What it shows: each platform's share of answers with fan-out over the last 24h and over the 3 days before. It is read by the new fanout_coverage_by_platform RPC (migration 00140): one aggregate over the window, service role only.
  • What gets flagged:
    • An engine that Cloro documents fan-out for (ChatGPT, Copilot, Perplexity) and that had none on any answer for a whole day, however long it has been silent. Today's report would flag ChatGPT.
    • Any other platform whose share falls below a quarter of what it was before.
    • Platforms that never fan out (AIO, AI Mode, Gemini) are not flagged.

server/src/scripts/probe-cloro-fanout.js: sends one Cloro task for a platform: the production request plus rawResponse where the endpoint takes it. It prints:

  • every query-like field (raw stream included);
  • what we would store;
  • the path of a file with the full response.

Run:

node src/scripts/probe-cloro-fanout.js chatgpt-web

It needs CLORO_API_KEY and costs about 9 credits for ChatGPT.

Related issue

None. Found while checking the Query Fan-out page on production.

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 supabase/migrations/00140_fanout_coverage_by_platform.sql.
  2. Run select * from fanout_coverage_by_platform(now() - interval '1 day', now()); to see answers and answers with fan-out per platform.
  3. With production data, the next daily health report should list "chatgpt-web returned no query fan-out on any of its N answers in the last 24h …" under Needs attention.
  4. With CLORO_API_KEY set, run node src/scripts/probe-cloro-fanout.js chatgpt-web from server/. Check whether searchQueries / mapSearchQueries are empty or reshaped, and whether queryLikeKeys shows queries elsewhere.

Checklist

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

Also run:

  • Server: npm run format, npm run lint and npm test, 1182/1182. New tests:
    • Parser: { query } objects, map searches, an empty search_model_queries.
    • Health report: the shares and windows, the silent-engine rule (ChatGPT flagged, Gemini not), a partial collapse, too few answers, a failing check.
  • Schema: supabase/build-schema.sh regenerated schema.sql.
  • Dev database: migration 00140 applied there. The RPC returns the seeded split: Copilot and Perplexity answers all have fan-out, the rest none.
  • Script: stops before calling Cloro when the key is missing. I couldn't run it against Cloro: the local key is empty.

Review

I ran a code review before opening this. It found 4 things; 3 are fixed:

  • the first version compared the last day with the week before only, so it would not have reported ChatGPT's two-week outage. It now flags an expected engine that is silent for a day, whatever came before;
  • the baseline window is 3 days instead of 7, to halve the scan;
  • a small non-zero share reads "<1%", not "0%".

Left as is: map searches are stored as fan-out (tagged engine: 'maps') and are not yet labelled in the UI. The fan-out page follow-up will show them.

🤖 Generated with Claude Code

…n-out stops

ChatGPT's query fan-out has come back empty since 2026-09-30, while its
answers still carry sources. Our parser hasn't changed since August, and
nothing noticed for two weeks: an empty field reads like an answer that ran
no search.

- Parser: read string or { query } entries in every fan-out field, add
  ChatGPT's mapSearchQueries (engine 'maps'), and stop an empty
  search_model_queries from hiding a populated searchQueries.
- Daily health report: each platform's share of answers with fan-out over
  the last day and the 3 days before (fanout_coverage_by_platform, 00140).
  An engine Cloro documents fan-out for (ChatGPT, Copilot, Perplexity) with
  none for a whole day is flagged however long it has been silent; any other
  platform is flagged when its share falls below a quarter of before.
- src/scripts/probe-cloro-fanout.js: one Cloro task for a platform, printing
  its raw fan-out fields and what we would store, to tell an emptied field
  from one that changed shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 15, 2026
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk ChatGPT's query fan-out has been empty since Sep 30 (Copilot-only on the Fan-out page). This PR makes the parser tolerant of a shape change, adds a fan-out section to the daily health report, and adds src/scripts/probe-cloro-fanout.js. Could you run node src/scripts/probe-cloro-fanout.js chatgpt-web on the server (needs CLORO_API_KEY, ~9 credits) and share the summary? It will tell whether Cloro emptied the field or changed its shape. Migration 00140 needs applying in production.

@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. 00140 is applied on production; execute is revoked from authenticated and anon. Over the last 24h it reads ChatGPT 0 of 1,310 answers with fan-out and Copilot 1,031 of 1,036, so the new section would flag ChatGPT today. Planned generically, the 4-day window takes 2.1 s over 20,972 rows on idx_prompt_results_created_at, fine for a once-a-day report. On the tree merged with main, schema.sql matches build-schema.sh and server tests pass (1285).

@gkhngyk
gkhngyk merged commit 3670918 into ansvisor:main Oct 16, 2026
5 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