Repository navigation
feat(mail): subscriptions read, List-Unsubscribe targets, bots by what they send - #3379
Merged
Merged
Conversation
Member
Author
|
Timings page: WireCatLabs/cli-testing#417 |
leemour
added a commit
to WireCatLabs/cli-testing
that referenced
this pull request
Nov 26, 2026
) Adds `performance/mail/subscriptions` with `bench.mjs`, for [cli-core#3379](WireCatLabs/cli-core#3379) (issue #3371). The run uses 100,000 synthetic emails, 60,000 of them broadcast in 1,600 groups, at a load average of 19 to 22: - **Warm Subscriptions page:** 162 ms for the first 50, 132 ms for the first 500. With a type filter it takes 62 ms. For comparison, `mailSenders` takes 398 ms. - **First read:** 20.5 s on a writable open, because it types every email first. A read-only open takes 0.9 s and keeps nothing. - **Bots filter by what they send:** 48 to 52 ms warm, 3 ms for messenger bots. - **No store version needed.** One query-plan trap was found and fixed: a unary `+` on the List-Id expression, which cut a page of 500 from 3.5 s. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…t they send Closes the gaps of #3371 for WireCat Desktop's Subscriptions view and Bots filters (owner's rulings, 2026-11-25). - store.mail.subscriptions: broadcast mail grouped by List-Id, else by the sender, newest group first, grouped, counted and paged in SQL. Each group gives its key, List-Id, name, sender ref and address, mail count, newest email and unsubscribe target (https, mailto, oneClick). The target is looked up for the page's groups only, through emails_by_list_id or the sender's identities. - mailHeadersOf keeps list-unsubscribe-https and list-unsubscribe-mailto, only under the From domain's passing DKIM signature that covers List-Unsubscribe. list-unsubscribe and list-unsubscribe-post are unchanged. - people.listBots takes sends: alerts, receipts, newsletters, marketing, messenger, mapped to mail types in BOT_SENDS, filtered in SQL. No store version: the targets live in emails.headers, and the read stays fast on the existing indexes (cli-testing performance/mail/subscriptions). Nothing unsubscribes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour
force-pushed
the
feat/subscriptions-read
branch
from
November 26, 2026 00:46
43f0714 to
0e1b712
Compare
leemour
added a commit
that referenced
this pull request
Nov 26, 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.
Task
Close the gaps in #3371, so WireCat Desktop can build its Subscriptions view and the Bots filters (owner's rulings of 2026-11-25; Desktop PR WireCatLabs/wirecat-desktop#482 lists what it could not read).
Why
List-Id, else by sender, with a mail count, the newest mail and an unsubscribe action.mailSendersgroups by sender only, pages in JavaScript, and the store keptlist-unsubscribeonly astrue.listBotstook onlyqueryandorganization, and Desktop never filters a list in the browser.What
store.mail.subscriptions({ accountIds, since, until, types, limit, offset })(experimental). Broadcast mail grouped byList-Id, else by the sender (sender-bot:<id>,person:<id>oraddress:<address>), newest group first. Grouping, counting and paging run in SQL. Each group gives:key,listId,name, and thesenderref andaddressof its newest email;emails, the count;newest: id, Message-ID, subject and time;unsubscribe:https,mailto,oneClickand the email it came from, ornull.The target is the newest one the list or the sender named. It is looked up for the page's groups only, through
emails_by_list_idor the sender's identities.List-Unsubscribe targets.
mailHeadersOfnow also keepslist-unsubscribe-httpsandlist-unsubscribe-mailto(the first of each scheme). It keeps them only when the From domain's DKIM signature that Gmail passed coversList-Unsubscribe: a forged target would send the owner's unsubscribe somewhere else.list-unsubscribe: trueandlist-unsubscribe-poststay as they are, because the mail types and the bot rules read them.people.listBots({ sends }):alerts(security,system_alert,account_notice),receipts(order,bill,shipping),newsletters,marketing(promotion) andmessenger(a bot with an account other than email). Several names are joined with OR, in SQL, asEXISTSsubqueries. The map isBOT_SENDSinsrc/store/sqlite/bot-sends.ts, exported withBotSendsfrom./storeand./store/areas. An unknown name is refused withsender-bot.unknown-sends.A store opened read-only works the mail types out in memory for both reads, as the type filters already do.
No store version
The brief asked for the next store version (79, after #3374's 78). None is needed:
emails.headers.So mail stored before this change has no target until mail sync stores it again. A group shows
unsubscribe: nulluntil a newer issue arrives. Reserving 79 would also block this pull request on #3374, which is a major.Not done
Unsubscribing. Nothing here sends anything. A one-click unsubscribe (RFC 8058) would need:
httpstarget, andList-UnsubscribeandList-Unsubscribe-Postboth covered by the From domain's passing DKIM signature, which is whatoneClickchecks;POSTto that URL with the bodyList-Unsubscribe=One-Click(application/x-www-form-urlencoded), with no cookies, no credentials and no redirects followed;A mailto target needs a sent email from the account that received the list, which is the mail CLI's job.
Channels in Subscriptions. The ruling says mail and channels. This read covers mail. Messenger channels are chats, not emails.
Timings
100,000 synthetic emails, 60,000 of them broadcast, in 1,600 groups. Load average 19 to 22. Each warm step is the median of 5 runs. Full page: cli-testing
performance/mail/subscriptions(PR linked in a comment).types: [promotion]. For comparison,mailSenderstakes 398 ms.listBots sends: 48 to 52 ms, and 3 ms formessenger.emails_by_list_id, and most mail has no List-Id. That cost 10 ms a group, and 3.5 s for a page of 500. A unary+keeps it onemails_by_from_identity_id.Testing
src/store/mail-subscriptions.test.ts: groups, newest and target, a forged target refused, paging and total,typesandaccountIds, a read-only open of an untyped store that writes nothing, and bots bysends(alerts, receipts, messenger, OR, unknown name).src/mail/headers.test.ts: targets kept only under the From domain's signature.pnpm typecheck,pnpm lint, the related store and mail tests with one worker,pnpm docs:checkparts,pnpm schema:check,pnpm check:dist,cli-dev api-report.🤖 Generated with Claude Code