Repository navigation
feat(organizations): domain-list data pack, more free-mail domains, clearable sectors - #3359
Merged
Merged
Conversation
…learable sectors - domain-lists update/list (domainListsCommand, experimental): a versioned pack on the GitHub release `domain-lists`, each file checked by sha256 through installFiles like models download, the pack folder swapped whole. - scripts/domain-lists.ts builds UT1 sectors (CC BY-SA, own file), FDIC banks and UT1 malware/cryptojacking hosts; Stop Forum Spam toxic domains are fetched from the source by each computer (no redistribution, non-commercial). - Each source carries licence, credit and class (commercial-ok / non-commercial); --commercial-only leaves non-commercial lists out. - .github/workflows/domain-lists.yml builds and publishes the pack weekly or by hand. - About 23,000 free-mail providers (microlink free-email-domains, MIT) never make an organization, less those Wikidata calls an organization. - A rule's sector is marked sector_by=rules and is changed or cleared when a newer table or pack no longer gives it; the owner's sector stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… hosts and the listed sources Use hostFetch with declared hosts instead of the global fetch (command lint raw-network), and regenerate docs/reasons.md for domain-lists.offline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…domain from making an organization The pack's UT1 webmail list is its own source with signal `freemail`, held in memory and checked by companyDomainOf, as the plan says free mail is never an organization. Organizations made earlier on such a domain stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour
force-pushed
the
feat/domain-data-pack
branch
from
November 25, 2026 20:39
747170c to
8077575
Compare
This was referenced Nov 25, 2026
leemour
added a commit
that referenced
this pull request
Nov 25, 2026
## Task Follow-up to #3359, found by running `domain-lists update` against the first published pack (release `domain-lists-2026-11-25`). ## Why `hostFetch` refuses a host list that names a host twice. The manifest URL and every release asset are on `github.com`, which was also in the fixed release hosts, so every real update stopped with `"github.com" is listed twice`. The tests inject `fetch`, so they never built the host list. ## What `packHosts` builds the list with each host once; both `hostFetch` calls use it. ## Testing - New unit test for `packHosts`. - Real run from the built package into a throwaway folder: all five sources installed (UT1 sectors 802,669 lines, UT1 webmail 189, UT1 bad 260,838, FDIC 4,090, Stop Forum Spam 87,188 fetched from its source); lookups gave `pokerstars.com` gaming_gambling, `amazon.fr` shop, `bankofamerica.com` bank, and `laposte.net` free mail. - typecheck, biome, the domain-lists tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
leemour
added a commit
that referenced
this pull request
Nov 25, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour
added a commit
that referenced
this pull request
Nov 25, 2026
…rsion 77) (#3366) ## Task Contact-kinds plan (#3323, section "Mail categories"; research note `2026-11-25-contact-kinds-mail-products.md`, IDEA-3 and IDEA-4, the SaneBox and Inbox Zero notes). Owner's rulings, 2026-11-25: domain rules on free-mail domains are allowed but never made by accident, the domain scope is not offered first, preview before apply, every correction names its scope and whether it covers past mail, corrections can be undone and a sender's manual sorting reset. ## Why #3358 gives each email a type from its headers. The owner needs to correct it: "this mail is a receipt", "everything from this address is a newsletter", "this whole domain is a bot". A correction must say how far it reaches, and must never sort strangers on `gmail.com` together by accident. **Not `mail_rules`.** That table decides how one account's sync stores mail (skip, envelope, tags) before an email exists, matches domains by `endsWith`, and has no levels or authors. Sorting rules are cross-account, decide what stored mail is, and need a fixed order. So they get their own table and API (`store.mail.sorting`, beside the storage `store.mail.rules`). ## What **Order** (`src/mail/sort-rules.ts`, pure): the first scope that has a rule wins. | # | Scope | Value kept | |---|---|---| | 1 | `mail` | the email's id | | 2 | `list` or `subject` | the List-Id (as `listIdOf` keeps it), or a subject pattern (any case; any number matches any number) | | 3 | `address` | the lower-case address, matched whole: `ann@` never matches `joann@` | | 4 | `domain` | the registrable domain (Public Suffix List), matched on a label boundary: `shop.example` matches `mail.shop.example`, never `myshop.example` | | 5 | — | the header classifier of #3358 | - Within a scope the owner's rule beats the program's, then the newest wins (the IDEA-3 reading: owner-over-program holds within a level, not across levels). - A domain rule with `overAddresses` beats the address rules at its domain (SaneBox's "override training"). - `applyTo: "new"` is a cutoff on the rule, checked against the mail's own date, so a backfill of old mail counts as past and a later trigger clear never retypes past mail with it. - Outgoing mail is never typed by a rule. **Actions.** A rule sets any of: - the mail type; - `sender: "bot" | "person"`, through `moveToBot` / `moveToPerson` only, for the sender's whole history. Owner only, address or domain scope only. An address rule that moves a sender refuses `applyTo: "new"`. A domain rule with `applyTo: "new"` logs the domain's known senders as left, and moves only senders first seen later. Mail sync settles the senders of each saved batch when such a rule exists; - `organization: "organization:<id>"`, through `holdAddress` (method `sort-rule`), owner only. What a rule did to each sender is logged in `mail_sort_effects` (`before` and `after`). A removal puts each sender back, then lets the rules still live settle it. **Free-mail guard.** `isSharedMailDomain` = `FREE_MAIL` or the data pack's `isFreeMailDomain` / `isPackFreeMailDomain` (#3359) or `isDisposableDomain`. - A domain rule there is the owner's only (a program's is refused: `mail-sort.free-mail-program`). - It is set only with the `confirm` of a dry run. The confirm is a hash of the rule and its counts, so a dry run gone stale (new mail arrived) is refused (`mail-sort.confirm`). - No call widens a scope on its own: every add names its scope. `scopes(email)` lists mail, list, address, domain in that order, the domain last and flagged `freeMail`. **API** (experimental), `store.mail.sorting`: - `add(input, by, { dryRun?, confirm? })` → `{ applied, preview, rule? }`. `preview` = `{ scope, value, label, applyTo, freeMail, addresses, emails, retyped, senders, confirm }`. - `rules({ scope?, removed? })`, `scopes(emailId)`, `remove(id, by)` (a program removes only its own). - `undo(by)`: the owner's newest add or removal not yet undone. Repeated undo walks back; it does not toggle. - `reset(sender, by)`: removes one sender's address and one-mail rules (an address, `person:` or `sender-bot:`). Domain and list rules stay. A direct `people.moveToBot` the owner made outside rules is not reset by it. - An email a rule typed has `typeSignal: "rule:<id>"`. **Storage, store version 77** (reserved in #3360): `mail_sort_rules`, `mail_sort_effects` (an identity's rows dropped with it by a trigger), `emails.sort_checked` with the partial index `emails_sort_to_check`, and a trigger that nulls it with `mail_type`. - The upgrade marks every type already kept as checked (no rules existed). - A build before 77 that types mail writes no mark. Once a rule exists, the next writable typed read works those emails out again. No trigger on the old build's write path, so its own type loop still ends. - Added only, forward-only, `minCompatible` stays 73. - A rule change clears exactly the emails whose winning rule changes, inside the same write. Also: `listIdOf` exported from `mail/headers.ts` (reused, not copied); 16 `mail-sort.*` reasons; GLOSSARY "sorting rule"; biome line limits raised as v72–v76 did (`spec.mjs` 1902→1908, `schema.ts` 3265→3269, the `emails.ts` group 1024→1033). ## Timings 100,000 synthetic emails from 20,000 senders, load 6–17 ([cli-testing page and script](WireCatLabs/cli-testing#412, `performance/mail/rules`)): - **Rule check:** 50 rules add about 0.35 s per 100,000 emails typed in memory (560 → 915 ms). The first typed read is 7–18 s either way; the commit's disk sync dominates. - **Domain rule, company domain** (7 addresses, 35 emails): 0.3–0.7 s to add, 0.2–0.4 s for the next typed read. - **`gmail.com` rule** (6,000 addresses, 30,000 emails): dry run 0.14–0.19 s, add 1.0–1.2 s, next typed read 1.5–2.1 s. Undo costs the same. - **500 senders moved to bots** by one domain rule: 4–6 s when done in one write (8–12 ms per `moveToBot`), past another writer's 5 s wait. So the rule and its type clears are one write, and the senders then move 100 per write (about 1 s of lock each; 5.6 s in total). Moved back in 0.4–0.9 s. ## Testing - New: `src/store/mail-sorting.test.ts` (10, through the store), `src/mail/sort-rules.test.ts` (6: order, authors, override, anchoring, cutoff, values), `src/store/version-77.test.ts` (upgrade from 76). - `pnpm typecheck`, `biome check` (no errors), `schema:check`, the docs checks, `cli-dev api-report --check` (stable API unchanged), full vitest suite before the chunking change: 996 files, 13,773 tests; after it, the sorting tests (17). ## Not in this PR - A memo command (store API only, as asked). - A sender rule over a free-mail domain with 6,000 senders would take about a minute in total, in writes of 100 (an estimate from 8–12 ms per move, not measured). Removal and undo still move senders back in one write. - **Removal leaves the owner's mark.** Moving a sender back goes through `moveToPerson` / `moveToBot`, which log `author = 'owner'`. So a sender a removed rule moved back counts as one the owner kept, and the kind pass will not make it a bot by its own rules again. - **A build that speaks 76 (cli-core 1.1.0)** types mail without the rules and does not settle new senders under a sender rule. Types it keeps are worked out again (`sort_checked`); senders it saves are settled only on the next save by a build that speaks 77. - **A subdomain value becomes its registrable domain.** `mail.shop.example` is kept as `shop.example`, as the plan says. The preview's `value` and `label` show it before apply. - `reset` does not release a direct `people.moveToBot` / `moveToPerson`. Those keep the owner's mark. - Program rules set types only; no program-made sender rules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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
Build the domain-list data pack the owner chose in NEED-115 A (plan
docs/dev/plans/2026-11-24-contact-kinds.mdon #3323, open questions 4 and 6): a small permissive core in the package, and a versioned pack on a WireCat release for lists that are big, updated often or share-alike.Why
Organizations got a sector only from the Wikidata table (#3350). UT1 and FDIC know many more banks, shops, news sites and gambling sites, but UT1 is CC BY-SA and big, so it must not be merged into the package. A sector was also never cleared, so a list that dropped a domain left a stale sector.
What
scripts/free-mail-domains.ts), registrable domains only, less the 38 that Wikidata calls an organization (sky.com,orange.fr,facebook.com…). They never make an organization.FREE_MAILinsrc/mail/score.tsis untouched. Organizations already made on a domain that is now free mail stay as they are.scripts/domain-lists.tsbuilds one gzip file per source andmanifest.json..github/workflows/domain-lists.yml(weekly, or by hand) publishes them on the releasedomain-lists-<date>and replacesmanifest.jsonon the releasedomain-lists, which the CLIs read. Neither release is marked Latest.domainListsCommand(experimental):domain-lists update [--commercial-only] [--offline]anddomain-lists list. Downloads go throughinstallFiles, the same sha256 check asmodels download; the pack folder is swapped whole, so a failed download keeps the old pack. Downstream CLIs must mount it (memo next). The first pack is published by running the workflow by hand after merge.commercial-okornon-commercial.--commercial-onlyleaves the non-commercial ones out, andlookupDomains(…, { commercialOnly: true })skips them where installed.freemail; it is held in memory and keeps such a domain from making an organization at all, as the plan says.upstream); its sha256 is recorded as it came.metadata.sector_by = 'rules'and is changed or removed when a newer list no longer gives it; any othersector_byis the owner's.store_settingskeyorganizations.sectors_fromrecords which lists were applied; when it changes, the next kind pass works every organization out again. No migration.Pack built locally on 2026-11-25 (not published)
Not in the pack, and why
Testing
pnpm typecheck,pnpm lint, the full vitest suite,pnpm docs:check.--commercial-only, a tampered file keeping the old pack, a bad source id refused; the store taking pack sectors, the table winning, a newer pack clearing a rule's sector and keeping the owner's; a free-mail provider, built in or from the pack, making no organization; the command against thedomain_listschema.🤖 Generated with Claude Code