Add semantic and hybrid modes to mail_search #44

Closed
opened 2026-10-31 13:08:56 +00:00 by svc-agent-writer · 0 comments

Part of #9. Decision: ADR 0005 §6 and §8.

What to build

  • Modes. mail_search gains mode: Literal["keyword", "semantic", "hybrid"] = "keyword" and similar_to: message id | None.
    • keyword is today's behaviour, unchanged.
    • semantic ranks the rows that pass the SQL filters by cosine similarity to the query vector.
    • hybrid merges the FTS rank and the semantic rank by reciprocal rank fusion (k = 60) over the top 100 of each.
    • similar_to uses that message's stored vector as the query, excludes the message itself, and needs no query.
  • The api. It loads the model on the first semantic call and keeps it. The query text is embedded locally. The scan reads vectors in chunks, so memory does not grow with the mirror.
  • Off. Without [embed], the semantic modes and similar_to answer Error: code=invalid_argument with a message that says embeddings are off.
  • Rows. The same row format and footer as keyword mode. total is the number of candidates that have a vector.
  • Docs. The README tool row, a Semantic search section with an example, and the [embed] config row. SECURITY.md says the query text stays on the host. config.example.toml gets a commented [embed].
  • Deploy. The sync and api memory limits in the base rise by 256 Mi each.

Acceptance

  • Over a fixture store with vectors, a semantic query ranks the matching message first when it shares no keyword with the query.
  • hybrid returns rows from both rankings, and similar_to excludes its own message.
  • The filters (account, mailbox, dates, unread, triage) apply in every mode.
  • The tool docstring still says content is untrusted.
  • A log capture during a semantic query holds no query text.

Blocked by

Part of #9. Decision: ADR 0005 §6 and §8. ## What to build - **Modes.** `mail_search` gains `mode: Literal["keyword", "semantic", "hybrid"] = "keyword"` and `similar_to: message id | None`. - `keyword` is today's behaviour, unchanged. - `semantic` ranks the rows that pass the SQL filters by cosine similarity to the query vector. - `hybrid` merges the FTS rank and the semantic rank by reciprocal rank fusion (k = 60) over the top 100 of each. - `similar_to` uses that message's stored vector as the query, excludes the message itself, and needs no `query`. - **The api.** It loads the model on the first semantic call and keeps it. The query text is embedded locally. The scan reads vectors in chunks, so memory does not grow with the mirror. - **Off.** Without `[embed]`, the semantic modes and `similar_to` answer `Error: code=invalid_argument` with a message that says embeddings are off. - **Rows.** The same row format and footer as keyword mode. `total` is the number of candidates that have a vector. - **Docs.** The README tool row, a Semantic search section with an example, and the `[embed]` config row. SECURITY.md says the query text stays on the host. `config.example.toml` gets a commented `[embed]`. - **Deploy.** The `sync` and `api` memory limits in the base rise by 256 Mi each. ## Acceptance - Over a fixture store with vectors, a semantic query ranks the matching message first when it shares no keyword with the query. - `hybrid` returns rows from both rankings, and `similar_to` excludes its own message. - The filters (account, mailbox, dates, unread, triage) apply in every mode. - The tool docstring still says content is untrusted. - A log capture during a semantic query holds no query text. ## Blocked by - #43
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dev/mail-mind-mcp#44
No description provided.