Embed attachment text and rank it in semantic search #79
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/mail-mind-mcp#79
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Parent: #9 (Phase 4). Decision: ADR 0007 §8, which amends ADR 0005 §3.
Embed extracted attachment text, and rank it in the semantic and hybrid modes of
mail_search.Scope
[attachments] embed_chunks(default 4) inconfig.py.attachment_embeddings(message_id, part, chunk, model, vec)in a new schema step, v8. #73 shippedattachment_textas v7 in 0.6.0. A deleted message loses its vectors in the same transaction. A moved message keeps or copies them, as the attachment text rows do: by the #59 key, in any account (#86).embed.py: cut each extracted attachment into chunks of 512 tokens with the pinned tokenizer, at mostembed_chunks, from the start. Embed the file name and the chunk text. New messages come first, attachment chunks second.store.pyandserver.py: semantic mode scores each message by its best cosine over its message vector and its chunk vectors. Hybrid mode fuses that ranking with the keyword ranking, as today. When an attachment chunk gives the best match, the snippet line starts with[attachment <part>]and shows the start of the chunk.similar_tocompares the given message vector with every vector.mail_statusshows the count of embedded attachment chunks.mail_searchrow and the[attachments]row.Acceptance
embed_chunksbound;[attachment <part>]snippet;[embed]absent, or[attachments]absent, no chunk is embedded.make model: a query that matches only words in an attachment ranks that message first in semantic mode.make checkpasses.Blocked by
Filed under: operator word "amend 77. I want semantic attachment search" sha256:b1a874f89ad1
⏸ SVD architect gate: dev/imap-mailmind-mcp#79 embed-attachment-text-and-rank-it-in-semantic-search
Status: CLEAN after 1 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity
substrate· dispatch efforthighRun:
20261101T084957Z-7f9da49aHeld because: CLEAN but 4 open risk(s) (2 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
make model && uv run python3 -m pytest -q tests/test_semantic.py -k attachment_onlyand confirm it passes (not skipped), then runmake checkagainst the re-measured base failure set. [verification]Change: The spec adds
[attachments] embed_chunks(default 4, ge=1, le=16) toAttachmentsConfig(config.py:203-219). Schema v8 creates theattachment_embeddingstable and its delete trigger in the shape ofembeddings(store.py:209-218). Three new methods mirrorunembedded/copy_embeddings/set_embeddings(store.py:821-857)._copy_attachment_text(store.py:1834-1844) also copies vectors.attachment_vector_chunksshares a WHERE helper withvector_chunks(store.py:1383-1412). In embed.py, asplit_tokenshelper, a second tokenizer with no truncation, andEmbedder.chunksdo the chunking, andEmbedWorker._account(embed.py:133-154) embeds new messages before attachment chunks. semantic.py getsbest_k. It does NOT keep theargsort(-scores)[: k + len(exclude)]prefilter (semantic.py:32). Each page is walked innp.lexsort((ids, -scores))order, keeping each id's first (best) vector and skipping excluded ids, until k distinct ids are taken. Those are then merged into a min-heap of (score, -id) as at semantic.py:27,36-40, with amembersdict holding scores and sources. The result is the exact top k by per-id maximum, even when one id repeats up to 800 times in a page.top_kbecomes a wrapper. server.py_ranked(270-302) chains the chunk streams when[attachments]is set;_chunk_snippetadds the[attachment N]prefix, andmail_statusgainsattachment_chunks=. README, config.example.toml and CLAUDE.md doc rows are updated.Files:
src/imap_mailmind_mcp/config.py·src/imap_mailmind_mcp/store.py·src/imap_mailmind_mcp/embed.py·src/imap_mailmind_mcp/semantic.py·src/imap_mailmind_mcp/server.py·README.md·config.example.toml·CLAUDE.md·tests/test_embed.py·tests/test_semantic.py·tests/test_store.py·tests/test_attachments.py·tests/test_attachment_vectors.pyDecision: accept the 4 open risk(s) above and dispatch this spec (
svd:go), or park (svd:skip) / re-spec (svd:respec)?Your call (when this issue is held at the gate via
svd:hold):svd:go— approve; Half-B dispatch accepts exactly this spec (open risks accepted)svd:firebesidesvd:go— approve AND authorise the Half-B fire from the phone; never on its ownsvd:skip— park it; dispatch refuses it and the issue stays for a humansvd:respec— discard this spec; the next Half-A run re-produces it with this record as prior-attempt contextSpec:
/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-01-embed-attachment-text-and-rank-it-in-semantic-search.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-01-embed-attachment-text-and-rank-it-in-semantic-search.mdspec-verify-dispatch Half B for dev/imap-mailmind-mcp#79 embed-attachment-text-and-rank-it-in-semantic-search completed integration verify.
5a82ba837f5a82ba8are empty and the repo has no CI config. Local: 386 unit tests passed, model test passed (4, none skipped), ruff clean.5a82ba8are empty and the repo has no .woodpecker directory (CI files are added by the architect).codex-svd ship --run-id 20261101T093929Z-ff75e4d3 --confirm-merge)