Extract attachment text in the sync worker, in a limited child process #82
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!82
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/attachment-text"
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 #73. Decision: ADR 0007.
Summary
With
[attachments]set, the sync worker extracts the text of each attachment after every pass. It stores the text, never the bytes.mail_searchin keyword mode then matches a word that occurs only in an attachment.The child for each attachment:
PATHonly, cwd/, stderr to/dev/null;Evidence
mail_search(query="quokkapdf")on a message whose PDF holds the word:total=0.After: one row, on GreenMail (IMAP) and on Stalwart (JMAP), for a PDF and a DOCX each.
make check: lint,mypy --strict, 251 unit tests, pip-audit clean.make test-integration: 18 passed.Measured on the image (native arm64; RLIMIT_AS is not enforced under amd64 emulation on the Mac, so these stand in for amd64):
Deviations from ADR 0007 and #73
synccontainer is limited to 768Mi. One child at the 19 MB ceiling (676 MiB resident) beside the sync process and the embedder could get the container OOM-killed. At 512 MiB that file ends asfailedin 5.8 s, and a document part up to about 10 MB still gives text. To keep those files, raise thesynclimit indeploy/k8s/baseand the address-space limit together.defusedxml, not stdlibiterparse. ruff S314 flags the stdlib parser on hostile XML. This adds one small dependency.olefile/olefile2.pyis excluded fromcompileall. It is Python 2 source that nothing imports, and it broke the image build.Known limits
timeout, because SIGKILL is also the hard CPU limit's signal.per_passis checked per message, so one pass can go past it by up toper_message - 1.Merge Danger
Door: one-way, for the mirror file
The first start moves the SQLite file to schema v7: a new table, a new column, and a dropped and rebuilt FTS index. No test opens a v7 file with 0.5.1. A rollback should restore the Litestream backup or re-mirror. Without
[attachments], nothing else changes at run time.Blast Radius: sync
apiwaits for the new schema version.[attachments]set, thesynccontainer fetches attachment bytes from the mail server when there is no bucket. It also runs one child at a time, using up to 512 MiB.[attachments], so the feature stays off until an operator adds it.🤖 Generated with Claude Code