Repository navigation
feat(mail): type: and reach: fields in mail search - #3372
Merged
Merged
Conversation
memo searches mail only through cli-core's search, and a filter after the search returns short pages, so the type and reach filters run inside the query's SQL. - type: takes one of the 16 mail types, reach: direct, group or broadcast (enum fields, terms only, mail only; tg and max refuse them). - A search that names either field first types the mail the store has not typed yet (storeMailTypes, 5,000 per write), outside the search's read and its 2 s time limit. The compiler itself never writes: when types are not current (a read-only open, or rankings and statistics that skip the fill) it works the untyped mail out in memory, checking the time limit between batches. A search without these fields types nothing. - Email hits carry mailType and reach (mail_type and reach in --json, and on the text line); untyped hits get theirs worked out in memory for the page. - SENDER_BOT_PREFIX is exported from ./store, MAIL_TYPES, MailType, REACHES and Reach from ./store/areas. - The emails.ts line limit goes 1033 -> 1038 for the batched hit typing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour
added a commit
to WireCatLabs/cli-testing
that referenced
this pull request
Nov 25, 2026
…415) Adds a "Search by type and reach" section and `search.mjs` to `performance/mail/types`, for [cli-core#3372](WireCatLabs/cli-core#3372). It times 100,000 synthetic emails, one run at a load average of 22–28: - **First search on a writable open:** 18.4 s. This search types every email first. - **First search on a read-only open:** 1.5–1.8 s, close to the 2 s search limit. Nothing is kept. - **Warm searches:** 33–105 ms, against 40 ms for a plain word. 🤖 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
Let memo filter mail by type and reach. memo searches mail only through cli-core's search (
memo search mail), and a filter after the search would return short pages, so the filter has to run inside the query's SQL. Follows #3358 (store version 76:mailType,reach,typeSignalper email) and #3366 (sorting rules).Why
The query language had no
typeorreachfield. memo also had to copySENDER_BOT_PREFIXandMAIL_TYPES, because cli-core 1.1.0 does not export them.What
Query fields (
src/search/lucene/registry.ts). Both are enum fields that take terms only and work in mail only. tg and max refuse them as mail fields (MAIL_FIELDS).type:takes one of the 16 mail types:type:order OR type:bill,invoice -type:promotion.reach:takesdirect,grouporbroadcast:reach:direct.Untyped mail. Types are kept lazily, so a search can meet emails that have no stored type yet.
mailIndexedinsrc/store/queries.tsrunsstoreMailTypesnext todrainEmailIndex, but only when the query namestype:orreach:. This is feat(mail): each email gets its own type and reach (store version 76) #3358's fill, 5,000 emails per write. It runs outside the search's read and outside its 2 s time limit. A search without these fields types nothing.src/store/sqlite/lucene-fields.ts) only reads, through the newtypeCondition(src/store/sqlite/email-types.ts).typeWhereis now that function plus the fill.emails_by_mail_type).Output.
MailFields.mailTypeandMailFields.reach.--jsonthey appear asemail.mail_typeandemail.reach, the snake_case output keys. They also appear on mail's text hit line.withTypesinemailHitsByPk).ENTITIESpast what tsc will write into a declaration (TS7056).Exports.
SENDER_BOT_PREFIXfrom@wirecat/cli-core/store.MAIL_TYPES,MailType,REACHESandReachfrom@wirecat/cli-core/store/areas(experimental).Docs. The search reference (generated table, mail paragraph, local-only list), mail's help, and the glossary rows for mail type and reach.
Line limit.
emails.tsgroup 1033 to 1038, for the batched hit typing.No schema change.
Testing
New test in
src/services/mail-search.test.ts:type:order OR type:BILLwith no stored type and keeps none;reach:group, negation with a word, a word with a type, hits carryingmailType/reach, wrong values, and tg refusingtype:.Local checks, one or two workers:
src/mailandsrc/services: 187 files, 2,389 tests.src/store,src/cli/messengerand command lint: 370 files, 3,382 tests.src/search,src/entities, the mail-types and version-76 tests: 19 files, 1,159 tests.pnpm typecheck, biome on the changed files,pnpm docs:check,cli-dev api-report --check.Timings on 100,000 synthetic emails, one run at load average 22–28:
type:orderhello reach:directtype:orderon a writable open (types all 100,000)type:ordertype:order OR type:billreach:broadcasthello type:personalorder -type:promotionhello, no type field (baseline)The page and script are in cli-testing,
performance/mail/types. The read-only first search is close to the 2 s limit, and on a larger untyped store it may stop with "out of time". One search on a writable open fixes it for good.🤖 Generated with Claude Code