Use attachment text in triage and wakes: local signals first, Jev payload after an ADR 0003 amendment #87
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#87
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). Touches ADR 0003 (Jev boundary) and ADR 0007 (attachment text).
Make the Jev triage of ADR 0003 and the attachment text of ADR 0007 work together, so a wake and a search can use what a message's documents say, not only its headers and body.
What the repo already has
.msgand HTML, a stdlib reader for XLSX, in a limited child. Text goes inattachment_textand the FTS5 index. Docling is out of scope; so is any other extractor.mail_attachmentand the attachment status inmail_readare #74. Attachment chunk vectors and[attachment <part>]snippets in semantic and hybrid search are #79. This issue adds nothing to either.fieldsmodes, asks one Choice (class) and one Score (wake level) per message, and storestriage_classandwake_scoreon the row.mailmind replayreports counts per day and the wakes the[wake]rule would have raised.The boundary
ADR 0003 §1: "Never the full body, never attachments." ADR 0007 §9: "Attachment text in the assessor's payload is a new decision." Tranche B below is that decision. Tranche A needs no amendment: every new signal in it is computed on the host from stored text, and Jev's payload does not change.
Tranche A: local signals, no ADR change
outbox.py's style: pure, no I/O) reads the stored attachment text and names and returns a closed set of flags per message:invoice(an amount with a currency and words such as invoice, total due, payment),deadline(a date withinNdays of receipt),contract(signature, agreement, terms),form. Rules are regexes and word lists, no model. Store the flags on the message row as a comma-separated columnattachment_flags, written by the sync worker after the attachment backlog of each pass.[wake]gainsattachment_boost(default 0): a float added to the Jev wake score whenattachment_flagscontainsinvoiceordeadline, before the threshold test. The rule still runs in code (ADR 0003 §3). The default keeps today's behaviour.mail_searchgainsattachment_flag: Literal[...] | None, like thetriagefilter. Scoperead, like the rest ofmail_search.mailmind replaygains one column per flag and aboostedcolumn: wakes raised only because of the boost. Counts only, never content, as today.attachment_textgainssha256of the bytes. A moved message whose Message-ID copy has the same hashes copies its rows, as today. A re-extraction (a newmax_chars, a new extractor pin) skips an attachment whose hash and extractor version match. This replaces the attachment-list comparison of ADR 0007 §6 with a stricter one and needs a one-line amendment to §6.choiceandscore. If the System One reply carries a probability for the Choice, store it astriage_confidenceand show it after the class inmail_readandmail_status. If the API gives no probability, record that finding in this issue and drop this item. No cascade to another model: that is a separate issue once the column exists and the replay shows how often confidence is low.Out of scope for A: a local classifier, a local LLM, any escalation path, any change to the six classes.
Tranche B: attachment text in the Jev payload (needs a decision first)
Blocked by an amendment to ADR 0003 §1 and ADR 0007 §9, accepted in its own issue, plus owner consent under ADR 0003 §8 on each instance before the field is enabled.
The amendment, if accepted, would add a third
fieldsmode,attachments: thefullfields plus, per extracted attachment, the file name, type and the firstattachment_excerpt_charscharacters (default 500, like the body excerpt) of its text. Never the whole text, never bytes. With that mode, two questions per message join the existing two:messages[i]or one of its attachments ask the owner to pay, sign or meet a deadline?"Both answers are advisory, stored as columns, and feed the same code-side wake rule and search filter as Tranche A, so Tranche A's columns and filters are the same with or without B. The ADR 0003 field test grows by one mode.
B does not start until A has shipped and a replay over at least one week shows what A's rules alone catch. If A catches the cases that matter, B may be closed unbuilt.
Acceptance (Tranche A)
invoiceon a newsletter with a price; the boost and its default; the search filter; the replay columns; the hash skip; the move copy.tests/test_source.pystill passes: no mail-server call inserver.py.make checkpasses.[wake]row, themail_searchrow, the replay section.Blocked by
Agent Brief
Category: enhancement
Summary: Tranche A only: compute attachment flags on the host, let the wake rule and
mail_searchuse them, show them in replay, skip unchanged re-extractions by content hash, and store Jev's class confidence. Jev's payload does not change.Operator rulings (2026-11-01). Where this brief differs from the issue body, the brief holds.
ready-for-humanand blocked by this one. This issue closes when Tranche A merges.confidence(TypeSafe docs,confidence.md; the fake server intests/test_assess.py:165already sends it). Store it. No cascade to another model.max_charsor a new extractor pin. So store asha256of the attachment bytes and anextractorstring. The string holds a version constant inextract.py, bumped when an extractor pin changes, plus themax_charsin force. A re-extraction skips a part whose hash and extractor string both match.Current behavior:
read_answers(src/imap_mailmind_mcp/assess.py:114) keeps only the choice and the score. It storestriage_classand awake_scorescaled to 0..1.would_wake(assess.py:312) tests the Jev score against[wake] threshold, and then against the per-thread and per-day caps.attachment_text(message_id, part, status, text)(store.py:222) has no hash. ADR 0007 §6 (docs/adr/0007-attachment-text.md:62) copies text from a row with the #59 key and the same attachment list.mail_searchhastriageandhas_attachmentfilters (Store._filters,store.py). It has no attachment-flag filter.Desired behavior:
evidence.py. It reads one message's stored attachment text and names, and returns a subset of the closed setinvoice,deadline,contract,form. It uses regexes and word lists, no model.invoiceneeds both an amount with a currency and an invoice word, such as invoice, total due or payment.deadlineneeds a date within 14 days after the message's date.messages.attachment_flags, a comma-separated column, after the attachment backlog of each pass.[wake] attachment_boost, a float, default 0.would_wakeadds it to the score when the flags holdinvoiceordeadline, before the threshold test. The rule still runs in code (ADR 0003 §3,docs/adr/0003-data-boundaries-for-external-judgement.md:19). With the default, behaviour is unchanged.mail_searchgainsattachment_flag: Literal["invoice", "deadline", "contract", "form"] | None, which works liketriage. Read scope. It works with the #59 collapse.mailmind replaygains one count column per flag, and aboostedcolumn: the wakes raised only because of the boost. It shows counts only.attachment_textgainssha256andextractor, filled at extraction. The copy rule of ADR 0007 §6 compares hashes, not attachment lists. Amend §6 with one dated line.messages.triage_confidence, a float, null when Jev gives none. Copy it wherevertriage_classis copied. Show it after the class inmail_readand in themail_statusassessor line, for exampleclass=needs-reply (0.91).Key interfaces:
store.py(schema step, columns, filters, copy paths),source.py(the run after the backlog),extract.py(the version constant and the hash),assess.py(read_answers,would_wake, replay),config.py(WakeConfig.attachment_boost),server.py(the filter and the confidence display), ADR 0007 §6, and the README.Acceptance criteria:
invoiceflag for a newsletter that shows a price, and adeadlineat 14 days but not at 15.extractorchange, and the copy of the flags and the hash.triage_confidence: stored when given, null when absent, and copied with the class.tests/test_assess.py) is unchanged: the payload keys are the same in both modes.tests/test_source.pypasses: there is no mail-server call inserver.py.[wake]row, themail_searchrow and the replay section.make checkpasses.Out of scope:
Blocked by
⏸ SVD architect gate: dev/imap-mailmind-mcp#87 use-attachment-text-in-triage-and-wakes-local-signals-first
Status: CLEAN after 0 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity
substrate· dispatch efforthighRun:
20261101T101546Z-1367865cHeld because: CLEAN but 7 open risk(s) (2 verification · 5 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
make checkand both uv run python3 -m pytest commands from the spec on the pristine base before the first edit, then assert that the failure set is unchanged apart from the new tests passing. [verification]Change: Tranche A only (the brief's operator rulings hold). (1) Add a new pure module src/imap_mailmind_mcp/attachment_flags.py in the style of evidence.py:1-60: AttachmentFlag Literal, FLAGS, WAKE_FLAGS={invoice,deadline}, DEADLINE_DAYS=14, flags_of(texts, names, sent), encode/decode. The rules are regexes and closed word lists: invoice = currency amount AND invoice word; deadline = cue word + a date 0..14 days after sent; contract = agreement word AND signing word; form = form word AND field marker. (2) Schema v9 (main+1) in store.py, following v7's attached_text step. Add messages.attachment_flags TEXT, messages.triage_confidence REAL, attachment_text.sha256 and attachment_text.extractor. _ADDED_COLUMNS gains a type element so the confidence column is REAL. Add an index on (sha256, extractor). MessageRow and Assessment gain defaulted trailing fields. The SearchParams.attachment_flag branch in _filters mirrors triage (store.py:1355-1357), so the #59 collapse works for free. Add unflagged/set_attachment_flags. set_attachment_texts gains keyword-only hashes/extractor and resets attachment_flags to NULL. The new attachment_hashes and text_by_hash leave the 3-tuple attachment_texts contract as is. unextracted(extractor=) re-selects only v9+ rows with a stale extractor. _copy_attachment_text copies sha256, extractor and flags; copy_assessments copies triage_confidence. set_assessments takes confidence=. raise_wakes calls decide(row, score, ...). (3) extract.py: EXTRACTOR_VERSION and extractor_id(max_chars). (4) source.py AttachmentBacklog: sha256 per fetched part; reuse by (sha256, extractor) instead of parsing; a FLAG_BATCH flag pass at the end of run(), which runs inside run_pass before the assessor nudge; the single 'attachments extracted' log line gains reused and flag counts only. (5) assess.py: read_answers unchanged plus a new read_confidence; would_wake(flags=()) adds rule.attachment_boost before the threshold for invoice or deadline; the wake row keeps Jev's score; replay adds per-flag and boosted columns. message_state and payload are untouched. (6) config.py: WakeConfig.attachment_boost (0..1, default 0). cli.py: replay --attachment-boost. (7) server.py: mail_search attachment_flag in read scope; mail_read shows 'triage: () wake=…'. (8) Docs: an ADR 0007 §6 dated line, README rows, config.example.toml.
Files:
src/imap_mailmind_mcp/attachment_flags.py·src/imap_mailmind_mcp/store.py·src/imap_mailmind_mcp/source.py·src/imap_mailmind_mcp/extract.py·src/imap_mailmind_mcp/assess.py·src/imap_mailmind_mcp/config.py·src/imap_mailmind_mcp/server.py·src/imap_mailmind_mcp/cli.py·docs/adr/0007-attachment-text.md·README.md·config.example.toml·tests/test_attachment_signals.py·tests/test_replay.py·tests/test_attachments.py·tests/test_store.py·tests/test_attachment_vectors.pyDecision: accept the 7 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-use-attachment-text-in-triage-and-wakes-local-signals-first.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-01-use-attachment-text-in-triage-and-wakes-local-signals-first.mdspec-verify-dispatch Half B for dev/imap-mailmind-mcp#87 use-attachment-text-in-triage-and-wakes-local-signals-first completed integration verify.
b3ad0fd940b3ad0fd: no Forgejo commit statuses (absent). Local: 62 + 222 targeted tests passed; make check passed (439 passed, 8 skipped; mypy, ruff and pip-audit clean).b3ad0fd. Local make check is the only integration evidence.b3ad0fdreturned an empty list. No CI run exists for this commit. The repo's CI files (.woodpecker/*) are architect-owned. — reported as absent, not blocking (gh#633)