Repository navigation
feat(action-center): detect platform and citation gaps - #826
Merged
Merged
Conversation
Phase 3b of #818. Two detectors, and the definitions that consume them, for the two families that had one apiece. `platform_gap`. A brand ranks well on one engine and poorly on another. The gap alone is not the finding — platforms differ for everyone, and the spread between a brand's best and worst averages 12 points across live brands, so reporting every gap would report the normal state. What makes it actionable is the pair: visibility already proven achievable somewhere, and materially absent somewhere else. Without the proven half, a brand weak on every engine would be told it has a platform opportunity when what it has is a visibility problem — a different signal, and a different action. Twenty points above a floor of twenty-five reports about one brand in five. `competitor_citation_gap`. A competitor cited by a multiple rather than merely ahead. Being behind on citations is ordinary: a competitor leads two thirds of brands in any given week. Being behind by a multiple says the gap will not close on its own and that there is a body of citations to go after. The absolute floor keeps the multiple honest — twice as many can mean four against two, which is not a finding. Reports about one brand in four. `expand_platform_visibility` gives Growth a second definition, and `close_citation_gap` gives Compete one. The second is deliberately distinct from close_competitor_gap: that one is about who ranks, this one about who gets cited, and earning references is not the same work as ranking answers. Both decisions sit in exported pure functions rather than inside the fetch that feeds them, following classifyVisibilityFall from the previous phase. Ten tests pin the boundaries — including the two cases that matter most, a typical spread staying silent and a large multiple over small numbers staying silent. Every threshold was measured against production before being chosen: the average platform spread, how often a competitor leads on citations, and the resulting signal volume for each rule. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj
8 tasks done
This was referenced Sep 22, 2026
gkhngyk
added a commit
that referenced
this pull request
Sep 26, 2026
#829 moved the nightly path's wide windows onto the daily rollups because `ai_visibility_aggregates` rescans everything a brand has ever collected and crosses the database's 8s statement timeout once a brand is large enough. It missed one call site — the competitor citation gap detector, added in #826 with its own direct call. That site was worse placed than the ones that were fixed. The pulse reads through a helper that retries a timeout; this called the client directly, so the first timeout threw and took the whole nightly pass with it. On the largest brand it did so every night: 8.2s to fail here against 0.13s to succeed from the rollup. The visible result was that the brand #829 was written for still had no signals this morning, on the first night the fix was live. Twenty-two brands recorded a pass; this one recorded none, for the same reason as before, one layer further in. A grep test now guards the convention, because the alternative failed twice. It checks that no module in the nightly path calls the three raw aggregate RPCs by name, allowing the routed `daily(name, window)` form that picks the rollup for a whole-day window and the raw RPC only for the 24-hour run-anchored one that no day window can express. Verified against the exact regression: restoring the old call fails it. Separately, the platform gap detector read up to 20,000 rows and judged whatever came back. The largest brand uses 8,032 of that, so nothing is truncated today — but a brand that reached the ceiling would have had its platform rates computed from an arbitrary subset and reported a gap that was an artefact of where the read stopped. It now says so and declines rather than answering confidently from part of the data. Refs #818 Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
Phase 3b of #818. Two detectors, and the definitions that consume them, for the two families that had one apiece.
platform_gap→ GrowthA brand ranks well on one engine and poorly on another.
The gap alone is not the finding. Platforms differ for everyone — measured across live brands, the spread between a brand's best and worst engine averages 12 points — so reporting every gap would report the normal state.
What makes it actionable is the pair: visibility already proven achievable somewhere, and materially absent somewhere else. Without the proven half, a brand weak on every engine would be told it has a platform opportunity, when what it has is a visibility problem — a different signal, and a different action.
competitor_citation_gap→ CompeteA competitor cited by a multiple, not merely ahead.
Being behind on citations is ordinary: a competitor leads 13 of 20 brands in any given week. Being behind by a multiple says the gap will not close on its own and that there is a body of citations to go after.
The absolute floor keeps the multiple honest — twice as many can mean four against two, which is not a finding.
The definitions
expand_platform_visibilitygives Growth a second definition.close_citation_gapgives Compete one — deliberately distinct fromclose_competitor_gap, which is about who ranks; this one is about who gets cited, and earning references is not the same work as ranking answers.Definitions go from 6 to 8. Growth and Compete each have two.
Structure
Both decisions sit in exported pure functions rather than inside the fetch that feeds them, following
classifyVisibilityFallfrom the previous phase. The fetch gathers; the function decides; the test exercises the decision without a database.Ten tests pin the boundaries. The two that matter most are the silences:
Calibration
Every threshold was measured against production before being chosen — the average platform spread, how often a competitor leads on citations, and the resulting signal volume for each candidate rule. The numbers in the tables above are counts from the live database, not estimates.
Related issue
Phase 3b of #818. Remaining in that phase: query fan-out coverage, third-party source presence, and entity consistency — all three need data the product does not collect yet, so they wait behind that collection rather than behind this PR.
Country-level gap detection stays dropped: exactly one brand tracks two or more regions.
Type of change
feat— New featureDatabase
None.
How to test
The classifiers are pure, so the boundaries are directly checkable:
platform_gap; a typical 12-point spread reports nothing.competitor_citation_gap; a competitor merely ahead reports nothing.expand_platform_visibilityunder Growth,close_citation_gapunder Compete.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — 0 errorsyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)🤖 Generated with Claude Code
https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj