Repository navigation
fix(server): page prompt_visibility_summaries reads past the 1000-row cap - #1096
Merged
Merged
Conversation
… cap
PostgREST returns at most 1000 rows per request (max_rows) and drops the
rest without an error. prompt_visibility_summaries returns one row per
prompt, so a brand with more than 1000 prompts lost the rest from the
weekly pulse's movers and from the uncited-mention signal.
Add lib/rpc-pages.js (readAllRpcRows), the server's copy of the web's
paging loop: ordered .range() pages of 1000 until a short page, capped at
100 pages with a warning, returning { data, error }. The pulse keeps its
timeout retry, which now restarts the paged read from its first page, and
the uncited-mention signal counts prompts by id so a row repeated at a
page boundary is counted once.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
approved these changes
Oct 16, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Thanks, approving. On the tree merged with main server tests pass (1265). On production the largest brand has 709 prompts, so prompt_visibility_summaries stays one page everywhere for now. The paging costs nothing today and covers a brand past 1000 prompts.
gkhngyk
added a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Oct 17, 2026
…l-evidence main carries the stack below as squashes. uncitedMentionCandidates keeps ansvisor#1096's one-row-per-prompt dedupe and this branch's most-mentioned-first order, and promptIds takes the rows' ids.
7 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PostgREST returns at most 1000 rows per request (
max_rows = 1000insupabase/config.toml) and drops the rest without an error — the same cap that cost the Tracked Prompts page most of its Positions at 30d/90d on 2026-10-16 (web fix: #1094).prompt_visibility_summariesreturns one row per prompt, and the server read it unpaged in two places, so a brand with more than 1000 prompts silently lost the rest from:promptScoresinserver/src/lib/pulse/metrics.js);uncitedMentionCandidatesinserver/src/lib/signals/record.js).Changes:
server/src/lib/rpc-pages.js(new):readAllRpcRows(name, page), the server's copy of the web'sreadAllRpcRowsfrom fix(prompts): read every page of the position and visibility summaries #1094. It asks for ordered.range()pages of 1000 until a short page, stops after 100 pages with alogger.warn, and returns supabase-js's{ data, error }(likechunked-in.js). A failing page returns the error and discards the partial read.retried(name, read)helper shared byrpcand a newrpcRows, so a paged read is still retried (from its first page).promptScoresreadsprompt_visibility_summariesthroughrpcRows, ordered byprompt_id.uncitedMentionCandidatespages the same RPC ordered byprompt_idand counts prompts by id, so a row repeated at a page boundary (a write landing between two pages) is counted once.fetchAllPendingRowsis intracking-worker.js.Other server RPC reads, checked against the migrations — none of them needs paging:
prompt_visibility_summaries(pulse movers, uncited-mention signal)ga_page_ai_visibility(page-opportunities.js)gsc_candidate_queries(LIMIT 200),content_opportunity_aggregates(one row),claim_opportunity_usage(at most one request's slot count),citation_url_ids(one row per distinct URL of a single answer)jsonb/scalar value (not subject tomax_rows)ae_*insignals/library/detect.js,*_aggregates_daily,tracked_prompt_count_daily,brand_landing_page_sessions,brand_prompt_opportunity_metrics,brand_prompt_fanout_queries,opportunity_basket_metrics,delete_brand_results_batch,health_probe,refresh_*,replace_prompt_clustersRelated issue
Server-side counterpart of #1094.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
No UI change: both reads run in the nightly signal pass and the weekly pulse.
cd server && npm test. The new tests serve the RPC through a small PostgREST stand-in that never returns more than 1000 rows per response:src/lib/rpc-pages.test.js: paging, exactly-full last page, empty page, failing page, page limit + warning, andRPC_PAGE_SIZEnever abovemax_rowsinsupabase/config.toml.src/lib/pulse/prompt-scores.test.js: 2500 prompts are all scored over 3 ordered pages; a timed-out page is retried from the first page.src/lib/signals/uncited-mentions.test.js: 1500 uncited prompts are counted past the first 1000; a prompt repeated at a page boundary is counted once.metrics.jsandrecord.jsreverted tomain(only theexportadded), 6 of the new tests fail: the unpaged read stops at 1000 rows.server/:npm run format(no changes),npm run lintandnpm test(82 files, 1207 tests) pass.npm run version:checkat the root fails onmaintoo (docker-compose images still at 0.2.0 against 0.3.0), and this PR doesn't touch versions.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — not run:web/is unchangedyarn typecheckpasses (run fromweb/) — not run:web/is unchangedyarn format:checkpasses (run fromweb/) — not run:web/is unchanged🤖 Generated with Claude Code