Repository navigation
feat(ops): daily health report email - #949
Merged
Merged
Conversation
Every morning at 06:00 UTC the server times the dashboard's heaviest reads on a reference brand against their 8 s budget (health_probe runs each as an organization member), checks the night's tracking runs (failed, stuck, brands with no completed run, runs killed by a restart) and long-pending Cloro tasks, and emails a short report flagged [OK] or [ISSUES]. Recipients, reference brand and member come from env. Resend sending is pulled into lib/email.js and shared with the Daily Pulse.
… run Run with row security bypassed, the Competitors read planned differently and ran past 120 s against 6.9 s as the page runs it. health_probe is now security invoker and switches to the authenticated role for its transaction before setting the member's claims.
gkhngyk
force-pushed
the
feature/daily-health-report
branch
from
October 6, 2026 15:19
69addd7 to
435f63d
Compare
This was referenced Oct 6, 2026
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
A daily health email so slow pages and broken nightly runs are caught by us, not by users. In one day, two such problems were found only after someone hit them: nightly runs left
waiting, and a Citations read past the 8 s timeout.Every day at 06:00 UTC (Vercel cron →
POST /api/internal/health-report,CRON_SECRET), the server checks four things and emails a report whose subject starts with[OK]or[ISSUES]:waiting/activefor more than 2 h, brands that ran nightly in the past week but have no completed run, and runs failed by a server restart.The report only reports; it never repairs anything. A check that fails shows up as "could not check" instead of suppressing the email, so a silent day always means the job itself did not run.
health_probe(00108) runs one whitelisted read exactly as the page does: as theauthenticatedrole with a given member's claims, for its own transaction only, and returns the seconds it took. Onlyservice_rolemay execute it. The role matters: with row security bypassed, the Competitors read planned differently and ran past 120 s, against 6.9 s as the page runs it. Already applied to the hosted database.Resend sending moves to
lib/email.jsand is shared with the Daily Pulse, which keeps itsList-Unsubscribeheader.Config (server env, not in the repo):
Without recipients no email is sent. Without the probe brand or user, the timing section reports itself skipped.
First measurements on the largest brand, run one at a time:
So the first report will already be
[ISSUES]:citations_urls(30 d) is past the budget, and Competitors and Topics are close to it.Not covered yet:
Related issue
None.
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
curl -X POST <server>/api/internal/health-report -H "Authorization: Bearer $CRON_SECRET". It returns202, and the email arrives within a minute or two.npx vitest run src/lib/healthfromserver/(8 tests). The full server suite passes (998).Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)🤖 Generated with Claude Code