Skip to content

fix(reports): rank prompt/topic performance by visibility rate, not diluted average - #568

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
arambu1a:fix/reports-visibility-rate
Jul 31, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
arambu1a:fix/reports-visibility-rate

Conversation

@arambu1a

@arambu1a arambu1a commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • getPromptPerformance and getTopicPerformance now rank/report by prompt-level Visibility Rate (share of runs with a mention or citation) instead of an all-runs average visibility_score, which let zero-visibility runs dilute heavily-mentioned prompts/topics into misleading single digits — the same class of bug #562 fixed for the All Prompts tab. Rate uses the same rounding as getPromptVisibilitySummaries.
  • Both scans were un-paginated, so PostgREST silently capped them at 1000 rows on busy brands (the #430/#464 defect family). Both now page in 1000-row batches, same pattern as the existing citation-evidence scan.
  • Report detail page and PDF render the rate with a % sign, but fall back to the legacy avgVisibility/100 cell for reports generated before this shipped (reports are immutable snapshots) — mirroring the competitor table's existing visibilityRate fallback dance.
  • Updated the AI executive-summary system prompt so generated prose also treats avgVisibility as a raw score, not a percentage, and prefers visibilityRate when present.

Closes #564

Test plan

  • yarn lint passes
  • yarn typecheck passes
  • yarn format:check passes
  • Manually generate a new report and confirm best/worst prompts and topics are ranked by visibility rate and labeled with %
  • Open an older stored report and confirm it still renders without errors, showing NN/100 (no %) for legacy payloads

…iluted average

getPromptPerformance and getTopicPerformance averaged visibility_score over
all runs, letting zero-visibility runs dilute heavily-mentioned prompts/topics
into misleading single digits — the same defect ansvisor#562 already fixed for the
All Prompts tab. Both now rank/report by visibility rate (share of runs with
a mention or citation), matching getPromptVisibilitySummaries' rounding.

Both scans were also un-paginated, so PostgREST silently capped them at 1000
rows on busy brands (the ansvisor#430/ansvisor#464 defect family); they now page in 1000-row
batches like the existing citation-evidence scan.

Rendering (detail page + PDF) shows the rate with a % sign, falling back to
the legacy avgVisibility/100 cell for reports generated before this shipped —
mirroring the competitor table's existing visibilityRate fallback. The AI
executive-summary prompt is updated with the same distinction so generated
prose doesn't misquote avgVisibility as a percentage.

Closes ansvisor#564

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@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 — recipe followed to the letter, and updating the LLM summary prompt so it quotes the rate correctly was a genuinely sharp catch beyond the issue's scope. 🙌

@gkhngyk
gkhngyk merged commit 5fd84ab into ansvisor:main Jul 31, 2026
4 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.

Reports: prompt/topic performance still rank by the zero-diluted average score (shown with a % sign)

2 participants