Skip to content

Send each user a daily digest of their new alerts - #1610

Draft
epompeii wants to merge 1 commit into
u/ep/digest/emailfrom
u/ep/digest/job
Draft

epompeii wants to merge 1 commit into
u/ep/digest/emailfrom
u/ep/digest/job

Conversation

@epompeii

@epompeii epompeii commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

The API server now sends the alert digest. A background task wakes at the top of every UTC hour, selects the users whose digest is due, sends each one their email, and moves each user's mark past what their digest covered. This is the change that makes the digest user-visible: from here on, every user who has not turned it off gets one email a day, at their hour, on any day with a new alert. The alert digest is in the Bencher Plus build. A Bencher Self-Hosted server sends it only when it has smtp configured. No plan or license gates it.

What changes

  • The task. The API server owns one task for the digest, as it owns the commit title and changepoint tasks: it takes the server's shutdown signal and keeps its handle, and nothing is detached. It wakes at the top of every UTC hour and sends to the users whose local hour it is, which also spreads the sends over the day.
  • No SMTP, no task. A server whose messenger is stdout starts no task and sends no digest. A digest written to a log is noise. The test server starts none either.
  • The sends. The task sends each due digest one after another, and awaits each send. Sending one at a time bounds the send rate with no limiter to tune. Sign-in and other email are unchanged.
  • The mark. After a digest goes out, the task moves the user's digest_through to the end of the window it covered. The write takes the later of the two, so it never moves the mark back past a return to the digest or an unlock that happened during the wake. A user with no new alert gets no email, and their mark still moves, so the next wake does not read that window again. A second wake in the same hour, as after a restart, finds the digest sent and sends nothing.
  • Failures. A 5xx reply refuses that one message for good, so the mark moves, the failure is logged as an error, and it is not sent again. A 4xx reply, or a message that cannot be written, leaves the mark, and the next hourly wake sends the same digest. A 4xx or 5xx reply is about one message, so the wake goes on to the next user. A transport, TLS, timeout, authentication, or setup failure would fail every send the same way, so the wake stops and leaves every remaining mark for the next wake. A failed selection is logged and ends the wake. A failed mark write is logged, and the wake goes on; that digest went out, but its mark did not move, so the next wake sends it again.
  • Shutdown. The shutdown signal cuts the wait for the next hour, the wait for a read connection, and the wait for the writer lock when no digest was sent. It stops the wake before the next user. A send in progress gets 3 more seconds to finish and move its mark, so a restart does not send that digest again; a send and its mark share those 3 seconds. A send cut at the grace logs a warning by user UUID, and its mark stays, so the next start may send it again. The server drains the digest task after the rate limit save.
  • Config. No new setting. The task uses the server's existing smtp, console URL, and token key.
  • Dependencies. smtp-proto joins the workspace, and bencher_schema takes it and jsonwebtoken as dev-dependencies, for the tests' SMTP replies and tokens.
  • Docs. A new Alert Digest page in every docs language, at /docs/explanation/alert-digest/, between Thresholds and Benchmark Harness Adapters. It covers what the digest lists, who gets it, when it sends, how to change it or turn it off, and the Self-Hosted note that it is sent only with smtp configured. The Thresholds page and the Alert entry on the Benchmarking page link to it. The glossary defines the Alert Digest, and says that "Digest" alone still means the OCI content hash. The changelog announces the digest, its settings, its unsubscribe link, and the smtp requirement.

Tests

lib/bencher_schema/src/context/alert_digests.rs runs the task on a database in a file with a mailbox that answers for SMTP, on tokio's paused clock. It covers: an empty day that moves the mark and sends nothing; a sent digest that moves the mark; a 5xx that moves it; a 4xx, an I/O error, and a failed authentication that leave it; a reply that goes on to the next user; a shared failure, including TLS, that stops the wake; a message that cannot be written; a mark that never moves backwards; two wakes in one hour that send once; a task that wakes at the top of each hour; and only SMTP starting the task. For shutdown it covers a send in progress that finishes and moves its mark; a long send cut at the grace; the cut waits for the hour, a read, and the writer lock; a wake stopped before the next user; a sent digest that waits for the writer lock until the grace; and a send and its mark sharing one grace.

This PR is the last of four for the alert digest. It sits on #1609, which writes the email and its unsubscribe link, and the stack sits on top of the changepoint layers (stack #1536).

@bencher-cloud

bencher-cloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

🐰 Bencher Report

ProjectBencher
Branchu/ep/digest/job
Testbedintel-v1

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymicroseconds (µs)
Adapter::Json📈 view plot
⚠️ NO THRESHOLD
5.22 µs
Adapter::Magic (JSON)📈 view plot
⚠️ NO THRESHOLD
5.08 µs
Adapter::Magic (Rust)📈 view plot
⚠️ NO THRESHOLD
7.81 µs
Adapter::Rust📈 view plot
⚠️ NO THRESHOLD
4.60 µs
Adapter::RustBench📈 view plot
⚠️ NO THRESHOLD
4.58 µs
🐰 View full continuous benchmarking report in Bencher

This branch was successfully deployed

1 active deployment
Cloudflare — 09705225 Deployed Dec 2, 2026 by epompeii via Build / Build API Docker #3738
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant