Repository navigation
fix(signals): move the last raw aggregate call off the raw scan - #834
Merged
Merged
Conversation
#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 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj
7 tasks done
gkhngyk
added a commit
that referenced
this pull request
Sep 26, 2026
…ons (#839) The V1 specification asks for 62 action definitions (19 Growth, 10 Protect, 11 Recover, 13 Fix, 9 Compete) and a shared library of 62 task primitives. The seven phases of #818 built the engine and stopped at 8 definitions and 24 tasks, on a decision — add definitions as their detectors land — that was never put to the person who wrote the specification. This delivers the library. Definitions. All 62 are registered, with the specification's stable codes (G01…C09), signal mappings, required and optional sources, and the task plan the Task Library specification gives each. 58 are enabled. Four stay registered but off, each saying which data it is waiting for: brand associations and brand-information consistency need attribute extraction the product does not do (and the specification rules out an LLM judging truth); organic-page expansion needs page-level Search Console data, which the sync does not store; broken citation targets need URL health checks, which do not exist. Detectors. 47 new signal kinds across twelve families, each reading a compact summary through a new `ae_*` Postgres function rather than scanning from the server — the shape that took the nightly pass down twice (#829, #834). Every read was measured on the largest brand; the slowest runs in 1.6s. Each family is isolated: a failed read costs that family's signals for the night, and its kinds are reported unread so the recorder does not take the silence for recovery. Three conditions I earlier said had no data do: fan-out queries are stored on every result, entity signals are Site Audit checks, and Search Console queries are synced. Tasks. The 62 primitives, in the specification's vocabulary — SYSTEM, AGENT, HUMAN, HUMAN_OR_AGENT; READ, WRITE, EXECUTE — with its dependency rules and structured outputs. Plans branch the way the specification says: an existing page is optimised, a missing one is briefed and drafted, never both. Publishing falls to a person when no publishing tool exists, rather than blocking the action. The 23 tasks raised before the library remain resolvable and runnable; no definition may plan them. Titles name their targets throughout — actions, tasks and signals — per the specification: "Recover lost citations on 7 prompts", not "Recover citations". Dry run across the 23 brands tracked in the last two days, before any write: 267 definitions have a finding, and tonight opens 110 actions, five per brand — the specification's daily limit. The rest queue and open as slots free. Two things done carefully. The signal categories are pinned to the database check constraint by a test, because one rejected insert throws a brand's whole pass. And the task vocabulary migration was applied before this code is deployed, so a transition migration keeps the old values valid until it is; a follow-up drops them. Refs #818 Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj Co-authored-by: Claude Opus 5.5 <[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.
Summary
#829 moved the nightly path's wide windows onto the daily rollups, because
ai_visibility_aggregatesrescans everything a brand has ever collected andcrosses 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, has its own direct call — and it is 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.
Measured on the largest brand this morning:
How it showed up
Last night was the first run with #829, #830 and #831 live, and it went well
everywhere except one place:
That one brand is the brand #829 was written for. It recorded no pass for the
same reason as before, one layer further in. Its last signal is still six days
old.
The guard
A grep test now checks that no module in the nightly path calls the three raw
aggregate RPCs by name. It allows the routed
daily(name, window)form, whichpicks 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.
A grep is a blunt instrument and I would not normally add one. It is here
because the alternative — a convention held by comments — failed twice from
the same cause, the second time after being written down. It is verified
against the exact regression: restoring the old call makes it fail.
Also
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 logs and declines rather than answering
confidently from part of the data.
Related issue
Refs #818
Type of change
fix— Bug fixHow to test
The affected brand picks its signals back up on the next nightly run, or
immediately via
node src/scripts/backfill-signals.js <brandId>.No migration.
Checklist
fix/)yarn lintpassesyarn format:checkpasses🤖 Generated with Claude Code
https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj