Use attachment text in triage and wakes: local signals first, Jev payload after an ADR 0003 amendment #87

Closed
opened 2026-11-01 04:34:44 +00:00 by svc-agent-writer · 3 comments

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

  • Extraction is done (#73, ADR 0007): pypdf for PDF, MarkItDown for DOCX, PPTX, .msg and HTML, a stdlib reader for XLSX, in a limited child. Text goes in attachment_text and the FTS5 index. Docling is out of scope; so is any other extractor.
  • mail_attachment and the attachment status in mail_read are #74. Attachment chunk vectors and [attachment <part>] snippets in semantic and hybrid search are #79. This issue adds nothing to either.
  • The assessor already sends attachment names and types in both fields modes, asks one Choice (class) and one Score (wake level) per message, and stores triage_class and wake_score on the row. mailmind replay reports counts per day and the wakes the [wake] rule would have raised.
  • A moved message copies its triage, its vectors and its attachment text rows by Message-ID. There is no content hash.

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

  1. Attachment signals in code. A pure function in a new module (or in 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 within N days 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 column attachment_flags, written by the sync worker after the attachment backlog of each pass.
  2. Attachment-aware wake rule. [wake] gains attachment_boost (default 0): a float added to the Jev wake score when attachment_flags contains invoice or deadline, before the threshold test. The rule still runs in code (ADR 0003 §3). The default keeps today's behaviour.
  3. Search filter. mail_search gains attachment_flag: Literal[...] | None, like the triage filter. Scope read, like the rest of mail_search.
  4. Replay. mailmind replay gains one column per flag and a boosted column: wakes raised only because of the boost. Counts only, never content, as today.
  5. Content hash. attachment_text gains sha256 of the bytes. A moved message whose Message-ID copy has the same hashes copies its rows, as today. A re-extraction (a new max_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.
  6. Confidence column, if Jev gives one. The Jev reply parser keeps only choice and score. If the System One reply carries a probability for the Choice, store it as triage_confidence and show it after the class in mail_read and mail_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 fields mode, attachments: the full fields plus, per extracted attachment, the file name, type and the first attachment_excerpt_chars characters (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:

  • Noul: "Does messages[i] or one of its attachments ask the owner to pay, sign or meet a deadline?"
  • Choice: document kind of the attachments: invoice, contract, report, form, other, none.

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)

  • Unit tests: the flag function over fixture texts, including no false invoice on 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.py still passes: no mail-server call in server.py.
  • The ADR 0003 field test is unchanged by A.
  • Logs carry flag counts only, never a file name or text.
  • make check passes.
  • README: the [wake] row, the mail_search row, the replay section.

Blocked by

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 - Extraction is done (#73, ADR 0007): pypdf for PDF, MarkItDown for DOCX, PPTX, `.msg` and HTML, a stdlib reader for XLSX, in a limited child. Text goes in `attachment_text` and the FTS5 index. Docling is out of scope; so is any other extractor. - `mail_attachment` and the attachment status in `mail_read` are #74. Attachment chunk vectors and `[attachment <part>]` snippets in semantic and hybrid search are #79. This issue adds nothing to either. - The assessor already sends attachment names and types in both `fields` modes, asks one Choice (class) and one Score (wake level) per message, and stores `triage_class` and `wake_score` on the row. `mailmind replay` reports counts per day and the wakes the `[wake]` rule would have raised. - A moved message copies its triage, its vectors and its attachment text rows by Message-ID. There is no content hash. ## 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 1. **Attachment signals in code.** A pure function in a new module (or in `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 within `N` days 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 column `attachment_flags`, written by the sync worker after the attachment backlog of each pass. 2. **Attachment-aware wake rule.** `[wake]` gains `attachment_boost` (default 0): a float added to the Jev wake score when `attachment_flags` contains `invoice` or `deadline`, before the threshold test. The rule still runs in code (ADR 0003 §3). The default keeps today's behaviour. 3. **Search filter.** `mail_search` gains `attachment_flag: Literal[...] | None`, like the `triage` filter. Scope `read`, like the rest of `mail_search`. 4. **Replay.** `mailmind replay` gains one column per flag and a `boosted` column: wakes raised only because of the boost. Counts only, never content, as today. 5. **Content hash.** `attachment_text` gains `sha256` of the bytes. A moved message whose Message-ID copy has the same hashes copies its rows, as today. A re-extraction (a new `max_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. 6. **Confidence column, if Jev gives one.** The Jev reply parser keeps only `choice` and `score`. If the System One reply carries a probability for the Choice, store it as `triage_confidence` and show it after the class in `mail_read` and `mail_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 `fields` mode, `attachments`: the `full` fields plus, per extracted attachment, the file name, type and the first `attachment_excerpt_chars` characters (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: - Noul: "Does `messages[i]` or one of its attachments ask the owner to pay, sign or meet a deadline?" - Choice: document kind of the attachments: invoice, contract, report, form, other, none. 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) - Unit tests: the flag function over fixture texts, including no false `invoice` on 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.py` still passes: no mail-server call in `server.py`. - The ADR 0003 field test is unchanged by A. - Logs carry flag counts only, never a file name or text. - `make check` passes. - README: the `[wake]` row, the `mail_search` row, the replay section. ## Blocked by - #74 - #79
Author
Member

This was generated by AI during triage.

Agent Brief

Category: enhancement
Summary: Tranche A only: compute attachment flags on the host, let the wake rule and mail_search use 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.

  1. Tranche B moved to #98. That issue is ready-for-human and blocked by this one. This issue closes when Tranche A merges.
  2. Item 6 stays in. Its premise is checked: a Jev Choice answer carries confidence (TypeSafe docs, confidence.md; the fake server in tests/test_assess.py:165 already sends it). Store it. No cascade to another model.
  3. The deadline window is a constant of 14 days in the new module. It is not a config key.
  4. Schema: take the next version after main's at dispatch time. #79 plans v8 and lands first, so expect v9. Do not assume a number.
  5. Re-extraction key: a hash alone cannot tell a new max_chars or a new extractor pin. So store a sha256 of the attachment bytes and an extractor string. The string holds a version constant in extract.py, bumped when an extractor pin changes, plus the max_chars in 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 stores triage_class and a wake_score scaled 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_search has triage and has_attachment filters (Store._filters, store.py). It has no attachment-flag filter.

Desired behavior:

  1. Flags. A pure module with no I/O, in the style of evidence.py. It reads one message's stored attachment text and names, and returns a subset of the closed set invoice, deadline, contract, form. It uses regexes and word lists, no model.
    • invoice needs both an amount with a currency and an invoice word, such as invoice, total due or payment.
    • deadline needs a date within 14 days after the message's date.
    • The sync worker stores the flags in messages.attachment_flags, a comma-separated column, after the attachment backlog of each pass.
    • The copy paths that copy attachment text (#86) copy the flags too.
  2. Wake boost. [wake] attachment_boost, a float, default 0. would_wake adds it to the score when the flags hold invoice or deadline, 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.
  3. Search filter. mail_search gains attachment_flag: Literal["invoice", "deadline", "contract", "form"] | None, which works like triage. Read scope. It works with the #59 collapse.
  4. Replay. mailmind replay gains one count column per flag, and a boosted column: the wakes raised only because of the boost. It shows counts only.
  5. Content hash. attachment_text gains sha256 and extractor, filled at extraction. The copy rule of ADR 0007 §6 compares hashes, not attachment lists. Amend §6 with one dated line.
  6. Confidence. Store the class confidence as messages.triage_confidence, a float, null when Jev gives none. Copy it wherever triage_class is copied. Show it after the class in mail_read and in the mail_status assessor line, for example class=needs-reply (0.91).

Key interfaces:

  • A new flags module, 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:

  • Unit tests for the flag function over fixture texts. They include no invoice flag for a newsletter that shows a price, and a deadline at 14 days but not at 15.
  • Unit tests for the boost and its default of 0, the search filter alone and with copies, the replay columns, the hash skip, a re-extraction after an extractor change, and the copy of the flags and the hash.
  • A unit test for triage_confidence: stored when given, null when absent, and copied with the class.
  • The ADR 0003 field test (tests/test_assess.py) is unchanged: the payload keys are the same in both modes.
  • Logs carry flag counts only, never a file name and never text.
  • tests/test_source.py passes: there is no mail-server call in server.py.
  • README: the [wake] row, the mail_search row and the replay section.
  • make check passes.

Out of scope:

  • Anything in Jev's payload, and every item of #98.
  • A local classifier or a local LLM, any escalation path, and any change to the six classes.

Blocked by

> *This was generated by AI during triage.* ## Agent Brief **Category:** enhancement **Summary:** Tranche A only: compute attachment flags on the host, let the wake rule and `mail_search` use 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. 1. **Tranche B moved to #98.** That issue is `ready-for-human` and blocked by this one. This issue closes when Tranche A merges. 2. **Item 6 stays in.** Its premise is checked: a Jev Choice answer carries `confidence` (TypeSafe docs, `confidence.md`; the fake server in `tests/test_assess.py:165` already sends it). Store it. No cascade to another model. 3. **The deadline window is a constant of 14 days** in the new module. It is not a config key. 4. **Schema:** take the next version after main's at dispatch time. #79 plans v8 and lands first, so expect v9. Do not assume a number. 5. **Re-extraction key:** a hash alone cannot tell a new `max_chars` or a new extractor pin. So store a `sha256` of the attachment bytes and an `extractor` string. The string holds a version constant in `extract.py`, bumped when an extractor pin changes, plus the `max_chars` in 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 stores `triage_class` and a `wake_score` scaled 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_search` has `triage` and `has_attachment` filters (`Store._filters`, `store.py`). It has no attachment-flag filter. **Desired behavior:** 1. **Flags.** A pure module with no I/O, in the style of `evidence.py`. It reads one message's stored attachment text and names, and returns a subset of the closed set `invoice`, `deadline`, `contract`, `form`. It uses regexes and word lists, no model. - `invoice` needs both an amount with a currency and an invoice word, such as invoice, total due or payment. - `deadline` needs a date within 14 days after the message's date. - The sync worker stores the flags in `messages.attachment_flags`, a comma-separated column, after the attachment backlog of each pass. - The copy paths that copy attachment text (#86) copy the flags too. 2. **Wake boost.** `[wake] attachment_boost`, a float, default 0. `would_wake` adds it to the score when the flags hold `invoice` or `deadline`, 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. 3. **Search filter.** `mail_search` gains `attachment_flag: Literal["invoice", "deadline", "contract", "form"] | None`, which works like `triage`. Read scope. It works with the #59 collapse. 4. **Replay.** `mailmind replay` gains one count column per flag, and a `boosted` column: the wakes raised only because of the boost. It shows counts only. 5. **Content hash.** `attachment_text` gains `sha256` and `extractor`, filled at extraction. The copy rule of ADR 0007 §6 compares hashes, not attachment lists. Amend §6 with one dated line. 6. **Confidence.** Store the class confidence as `messages.triage_confidence`, a float, null when Jev gives none. Copy it wherever `triage_class` is copied. Show it after the class in `mail_read` and in the `mail_status` assessor line, for example `class=needs-reply (0.91)`. **Key interfaces:** - A new flags module, `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:** - [ ] Unit tests for the flag function over fixture texts. They include no `invoice` flag for a newsletter that shows a price, and a `deadline` at 14 days but not at 15. - [ ] Unit tests for the boost and its default of 0, the search filter alone and with copies, the replay columns, the hash skip, a re-extraction after an `extractor` change, and the copy of the flags and the hash. - [ ] A unit test for `triage_confidence`: stored when given, null when absent, and copied with the class. - [ ] The ADR 0003 field test (`tests/test_assess.py`) is unchanged: the payload keys are the same in both modes. - [ ] Logs carry flag counts only, never a file name and never text. - [ ] `tests/test_source.py` passes: there is no mail-server call in `server.py`. - [ ] README: the `[wake]` row, the `mail_search` row and the replay section. - [ ] `make check` passes. **Out of scope:** - Anything in Jev's payload, and every item of #98. - A local classifier or a local LLM, any escalation path, and any change to the six classes. ## Blocked by - #79
Collaborator

⏸ 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 effort high

Run: 20261101T101546Z-1367865c

Held because: CLEAN but 7 open risk(s) (2 verification · 5 decision) — HOLD-ALL parks everything. The risks, verbatim:

Open risks:

  1. Brief item 5 says the ADR 0007 §6 copy rule should compare hashes, not attachment lists. That cannot work as a copy key: the copy target has no bytes and no attachment_text rows at copy time, and the stored attachment list holds only filename, mimetype and size (ingest.py:400,617-619; jmap.py:923-925). Lean: keep the #59 key plus the attachment list as the copy key; copies carry sha256, extractor and flags; the hash comparison happens at extraction time, where any row with the same (sha256, extractor) is reused instead of parsed. Question: accept this reading of item 5? [decision]
  2. Rows extracted before v9 have extractor NULL. Lean: they are never re-selected for re-extraction, which avoids a mass re-fetch and re-embed on upgrade, but a later max_chars change will not reach them. Question: accept this, or treat NULL as stale so the upgrade re-extracts the whole backlog once (bounded by per_pass)? [decision]
  3. Brief item 6 asks to show the confidence in the mail_status assessor line ('class=needs-reply (0.91)'), but mail_status has no per-message class: its line is 'assess: fields=… model=…' (server.py:657). Lean: show the confidence in mail_read only and leave mail_status unchanged. Question: is that enough, or should Store.status()/mail_status add a per-account aggregate such as low_confidence=N (confidence < 0.5)? [decision]
  4. The flag word lists narrow the issue's literal wording to avoid false positives: a bare 'payment' is not an invoice word; deadline needs a cue word (due, by, before, deadline, expires…) before the date and skips numeric d/m/y; contract needs both an agreement word and a signing word, not a bare 'terms'. Question: accept these as the v1 rules? Only invoice and deadline feed the boost, and the default boost is 0. [decision]
  5. The scope ceiling is met exactly at 16 files, so CLAUDE.md:15-21 (the module map) does not get its line for the new attachment_flags.py. Question: accept a one-line follow-up PR, or swap a file at the gate? cli.py is the cheapest to drop, at the cost of losing replay --attachment-boost. [decision]
  6. The boost applies only if flags exist when the assessor scores the message. Same-pass extraction guarantees that for new mail, because the flag pass runs inside run_pass before the nudge (source.py:396-398). Mail past per_pass, or assessed on a poll tick before extraction, is never boosted. Post-deploy check with [attachments] and [assess] on: sqlite3 "SELECT COUNT(*) FROM messages m JOIN mailboxes b ON b.account=m.account AND b.name=m.mailbox WHERE b.role='inbox' AND m.has_attachments=1 AND m.triage_class IS NOT NULL AND m.attachment_flags IS NULL AND julianday(m.synced_at) > julianday('now','-1 day')" should stay near 0 at steady state. [verification]
  7. make check and the filtered suites could not run in the Half-A sandbox (.venv/bin/python: Operation not permitted). Re-measure make check and 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.py

Decision: 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):

  • add label svd:go — approve; Half-B dispatch accepts exactly this spec (open risks accepted)
  • add label svd:fire beside svd:go — approve AND authorise the Half-B fire from the phone; never on its own
  • add label svd:skip — park it; dispatch refuses it and the issue stays for a human
  • add label svd:respec — discard this spec; the next Half-A run re-produces it with this record as prior-attempt context

Spec: /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.md

### ⏸ 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 effort `high` **Run:** `20261101T101546Z-1367865c` **Held because:** CLEAN but 7 open risk(s) (2 verification · 5 decision) — HOLD-ALL parks everything. The risks, verbatim: **Open risks:** 1. Brief item 5 says the ADR 0007 §6 copy rule should compare hashes, not attachment lists. That cannot work as a copy key: the copy target has no bytes and no attachment_text rows at copy time, and the stored attachment list holds only filename, mimetype and size (ingest.py:400,617-619; jmap.py:923-925). Lean: keep the #59 key plus the attachment list as the copy key; copies carry sha256, extractor and flags; the hash comparison happens at extraction time, where any row with the same (sha256, extractor) is reused instead of parsed. Question: accept this reading of item 5? [decision] 2. Rows extracted before v9 have extractor NULL. Lean: they are never re-selected for re-extraction, which avoids a mass re-fetch and re-embed on upgrade, but a later max_chars change will not reach them. Question: accept this, or treat NULL as stale so the upgrade re-extracts the whole backlog once (bounded by per_pass)? [decision] 3. Brief item 6 asks to show the confidence in the mail_status assessor line ('class=needs-reply (0.91)'), but mail_status has no per-message class: its line is 'assess: fields=… model=…' (server.py:657). Lean: show the confidence in mail_read only and leave mail_status unchanged. Question: is that enough, or should Store.status()/mail_status add a per-account aggregate such as low_confidence=N (confidence < 0.5)? [decision] 4. The flag word lists narrow the issue's literal wording to avoid false positives: a bare 'payment' is not an invoice word; deadline needs a cue word (due, by, before, deadline, expires…) before the date and skips numeric d/m/y; contract needs both an agreement word and a signing word, not a bare 'terms'. Question: accept these as the v1 rules? Only invoice and deadline feed the boost, and the default boost is 0. [decision] 5. The scope ceiling is met exactly at 16 files, so CLAUDE.md:15-21 (the module map) does not get its line for the new attachment_flags.py. Question: accept a one-line follow-up PR, or swap a file at the gate? cli.py is the cheapest to drop, at the cost of losing replay --attachment-boost. [decision] 6. The boost applies only if flags exist when the assessor scores the message. Same-pass extraction guarantees that for new mail, because the flag pass runs inside run_pass before the nudge (source.py:396-398). Mail past per_pass, or assessed on a poll tick before extraction, is never boosted. Post-deploy check with [attachments] and [assess] on: sqlite3 <db> "SELECT COUNT(*) FROM messages m JOIN mailboxes b ON b.account=m.account AND b.name=m.mailbox WHERE b.role='inbox' AND m.has_attachments=1 AND m.triage_class IS NOT NULL AND m.attachment_flags IS NULL AND julianday(m.synced_at) > julianday('now','-1 day')" should stay near 0 at steady state. [verification] 7. make check and the filtered suites could not run in the Half-A sandbox (.venv/bin/python: Operation not permitted). Re-measure `make check` and 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: <class> (<conf>) 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.py` **Decision:** 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`): - add label `svd:go` — approve; Half-B dispatch accepts exactly this spec (open risks accepted) - add label `svd:fire` **beside** `svd:go` — approve AND authorise the Half-B fire from the phone; never on its own - add label `svd:skip` — park it; dispatch refuses it and the issue stays for a human - add label `svd:respec` — discard this spec; the next Half-A run re-produces it with this record as prior-attempt context <sub>Spec: `/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.md`</sub>
Collaborator

spec-verify-dispatch Half B for dev/imap-mailmind-mcp#87 use-attachment-text-in-triage-and-wakes-local-signals-first completed integration verify.

  • PR: dev/imap-mailmind-mcp#100
  • Branch: feat/svd-dev-imap-mailmind-mcp-87-use-attachment-text-in-tria-4ba1e161
  • Commit: b3ad0fd940
  • Build: none
  • Test: green
  • Reader audit clean: True
  • Spec fidelity: True
  • Ready for merge: False
  • Check forgejo-commit-statuses: absent
  • Checks: PR #100 head b3ad0fd: no Forgejo commit statuses (absent). Local: 62 + 222 targeted tests passed; make check passed (439 passed, 8 skipped; mypy, ruff and pip-audit clean).
  • Warning: No remote CI statuses exist on PR head b3ad0fd. Local make check is the only integration evidence.
  • Warning: Schema moves v8 to v9, as the spec planned. Existing deployments migrate on first open.
  • Warning: Integration tests (GreenMail, Stalwart) were not run. They are outside the spec's prescribed commands.
  • Warning: no CI for forgejo-commit-statuses: The Forgejo statuses endpoint for PR head b3ad0fd returned 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)
  • Decision: resolve the blockers above and rerun integrate, or park this PR for a human?
spec-verify-dispatch Half B for dev/imap-mailmind-mcp#87 use-attachment-text-in-triage-and-wakes-local-signals-first completed integration verify. - PR: https://git.groupthink.asia/dev/imap-mailmind-mcp/pulls/100 - Branch: feat/svd-dev-imap-mailmind-mcp-87-use-attachment-text-in-tria-4ba1e161 - Commit: b3ad0fd940597615d353b7b21dac4dce20853c1e - Build: none - Test: green - Reader audit clean: True - Spec fidelity: True - Ready for merge: False - Check forgejo-commit-statuses: absent - Checks: PR #100 head b3ad0fd: no Forgejo commit statuses (absent). Local: 62 + 222 targeted tests passed; make check passed (439 passed, 8 skipped; mypy, ruff and pip-audit clean). - Warning: No remote CI statuses exist on PR head b3ad0fd. Local make check is the only integration evidence. - Warning: Schema moves v8 to v9, as the spec planned. Existing deployments migrate on first open. - Warning: Integration tests (GreenMail, Stalwart) were not run. They are outside the spec's prescribed commands. - Warning: no CI for forgejo-commit-statuses: The Forgejo statuses endpoint for PR head b3ad0fd returned 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) - Decision: resolve the blockers above and rerun integrate, or park this PR for a human?
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#87
No description provided.