Add semantic and hybrid modes and similar_to to mail_search #48
No reviewers
Labels
No labels
bug
enhancement
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:go
svd:hold
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/mail-mind-mcp!48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/semantic-search"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #44. Part of #9. Decision: ADR 0005 §6 and §8.
Summary
mail_searchgains two parameters:mode:keyword(the default, unchanged),semanticorhybrid.similar_to: a message id.totalcounts the ranked candidates. Every filter applies in every mode.ServerState.embedder()loads the pinned model on the first semantic call, under a lock, and keeps it. The query is embedded in memory, then never stored or logged.semantic.top_kscans the vectors of the filtered rows in chunks of 2048 (about 3 MB each) and keeps the best k in a heap.rank. Meaning comes first, so it breaks ties.similar_touses the stored vector of that message. It leaves out the message and every copy with its Message-ID. It refuses aqueryandmode="hybrid", and answersnot_foundwhen the message has no vector yet.[embed], the new modes andsimilar_toanswerError: code=invalid_argument, and the message names[embed]._filters()is factored out ofsearch(), so every mode shares one set of filter terms.keyword_ranked,vector_chunks(keyset pages, the lock held per chunk),vector,copies,messages_by_ids.syncandapimemory limits rise from 512Mi to 768Mi.Test plan
make check: 130 passed, mypy strict clean, pip-audit clean.similar_toleaving out its own message;imap_mailmind_mcplogs.top_kkeeps the best across chunks and honours the exclusions.fuseorder.make model): the query "when must I pay the utility invoice" ranks the water-rates mail ("water bill … Payment is due") first. It ranks above three mails whose subject contains the word "Invoice".[embed], both new paths are refused.🤖 Generated with Claude Code