Repository navigation
fix(traffic): hold the uncrawled-pages alert until bot data covers its 30 days - #1225
Conversation
…s 30 days The "cited pages no search bot read in 30 days" list checked only the ends of its window: the first bot day 30 days back, and a live connection that sent in the last 2 days. A connection revoked on day -25 with a new one made yesterday passed both, and every page crawled less often than the new data's one day was listed. 00190 redefines ai_bot_report so the alert also needs rows on 28 of the 30 days, or a live connection made 29+ days ago that still sends (a site bots don't read every day); otherwise it is 'stale', which also pauses the cited_page_uncrawled signals. A partial index on the '(other)' rows makes the gate's other check a probe. The connect dialog kept the last connections only while a read was in flight; a read that failed after a change took it down with the new secret. The section now keeps the last connections read without an error. The bot counters are by UTC day, so the 24h range reads yesterday and today; the section says so instead of "last 24 hours". Follow-up to ansvisor#1182's review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk This covers #1182's four remaining notes:
Migration 00190 is on the dev DB, and it is independent of #1222–#1224. One choice to check: for 24h I relabelled instead of reading |
gkhngyk
left a comment
There was a problem hiding this comment.
The (other) index and the 24h label are done, and the report section keeps its last good info.
One change before merge, plus one smaller fix:
1. The connection-age exception reopens the gap (00190, the not exists (... created_at <= now() - interval '29 days' ...) branch). Any live connection over 29 days old that sent in the last two days skips the 28-of-30 check, and that is every long-lived connection.
- A drain made in August hits the raw cap on Oct 10. Its files are then only counted: no
ai_bot_dailyrows, andlast_event_atstops. - On Nov 1 reading resumes. The brand has rows on 9 of the last 30 days, but the exception makes the gate
on. uncrawledthen lists every cited page not read on those 9 days, and the signals raisecited_page_uncrawledfor them.- The same happens with a Worker route removed for three weeks, or a Logpush job paused and resumed.
The new alertStale copy promises this case is caught. Instead of the exception, use the same 30 probes to find the longest run of empty days, and read stale when it is longer than a few days (3–7). Sparse sites still pass, and multi-week holes don't. Please add both cases to the dev-DB check.
2. The sources strip still loses the secret (_bots-connect.tsx, BotsSource). A failed refetch after create sets info to {error} and returns before the <BotsDialog>, so the dialog unmounts with the one-time secret. Keep the last good info there too, as BotsReportSection now does.
…owups # Conflicts: # supabase/schema.sql
…owups # Conflicts: # supabase/schema.sql
…bot data 00190's exception for a live connection made 29+ days ago let every long-lived connection skip the 28-of-30 check, so a sender past the month's raw cap, a Worker route taken down for weeks or a paused Logpush job reopened the gap the gate was meant to close. The gate now finds the longest run of days without rows over the same 30 probes and reads 'stale' past 7: a site bots read once a week still passes, a hole of weeks doesn't. The sources strip's AI bots card also keeps the last connections it read when a later read fails, as the report section does, so a failed read after a create no longer takes down the dialog with the new connection's one-time secret. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk thanks, both fixed in 65f3913: 1. The connection-age exception is gone (00190). The gate now takes the same 30 probes, finds the longest run of days without rows (gaps and islands over them), and reads
2. The sources strip keeps the secret (
|
ansvisor#1252 and this branch each added a test to _bots-connect.test.tsx at the same place: both are kept, and this branch's failed-read test takes ansvisor#1252's connection shape (workerSecretName, a Worker without the secret). Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
left a comment
There was a problem hiding this comment.
Thanks, both points are fixed:
- The gate. It now finds the longest run of empty days and reads 'stale' past 7, whatever the connection's age.
- The dialog.
BotsSourcekeeps the last good connections, so a failed read after a create keeps the dialog and its secret. The new test covers it.
I checked 00190 on production in a rolled-back transaction, on the largest citation brand, with a live connection and synthetic bot rows:
- Weekly crawl: rows every 7th day give a longest gap of 6, so the alert stays
on. - Hole: dropping two of those days leaves a 20-day hole, and the alert reads
stale. - Speed, as an org member: the report takes 1.97 s cold over 30 days, with 73 uncrawled pages, and 0.23 s over all time.
- Another org: a member of another organization gets null.
00190 is now applied to production. Your merge of main resolves _bots-connect.test.tsx the same way I did; it only changes the order of the two tests.
Nit for a follow-up: the comment on function text still describes the old rule ("rows on 28 of them, or a live connection 29+ days old"). It should say no run of more than 7 empty days.
#1216 conflicts with this in _bots-report.tsx. I'll resolve that on top and keep lastInfo.
Resolves _bots-report.tsx against ansvisor#1224 and ansvisor#1225: the connections keep their own read, and they keep ansvisor#1225's lastInfo so a failed read after a create doesn't close the dialog and lose the new secret. ansvisor#1224's logsPausedUntil import stays. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
Summary
These are the four notes left from #1182's review: 30-day coverage, the dialog unmount, the
(other)index and the 24h range.1. 30-day coverage (migration 00190,
ai_bot_reportredefined; the rest is unchanged from 00185)v_first30 days back;'stale'. That also keepscited_page_uncrawledsignals as unread rather than resolving them (feat(action-center): raise AI Traffic alerts as signals: weekly drop, new platform, broken links, unread cited pages #1195).(brand_id, day), not a scan; the runs come from those probes (gaps and islands).alertStaletext now names the gap case.2. Dialog unmount
getBotConnectionsfailed,loaded.infobecame null and the dialog still unmounted with the new secret.lastInfo, the last connections read without an error, through a functional state update. The dialog falls back to it.BotsSource) does the same now: a failed read keeps the last connections read (per brand), the card says "couldn't be read", and the dialog stays up with the secret. Its new test also fails on the old code.3. The
(other)indexai_bot_daily_other_idx (brand_id, day) where page = '(other)'.existsuses it (Index Scan, 1 row).create index concurrentlyfirst, as 00158/00164 note.4. The 24h range
ai_bot_events, which stops at the event cap.Deploy: apply 00190 (web only otherwise). Numbering: 00188 is #1210's and 00189 is #1223's.
schema.sqlhere is built without them; whichever merges later needsbuild-schema.shagain.Related issue
Follow-up to #1182 (review of 2026-10-19 17:39 UTC).
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
I applied 00190 to the dev DB and ran
ai_bot_reportas the service role. Each case was in a transaction, rolled back:alert_statestale(00185 saidon)onon):stalestaleonstaleIn the browser (web on :3002 with the branch's API on :8082):
I checked it in light and dark mode, at 1440 and 1024 px.
Unit tests:
_bots-report.test.tsxand_bots-connect.test.tsx. After a failed refetch, the dialog still shows the new secret. In the browser I also blocked the reads right after a create: the card said "couldn't be read" and the dialog kept the Vercel drain's header with the secret.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): 0 errors, only the existing warningsyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(1776 passed);yarn buildwith the CI placeholder env;bash supabase/build-schema.sh.🤖 Generated with Claude Code