Keep delimited signatures for mail_evidence: a sign_off column and a backlog #85
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#85
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?
Follows #84 (#78, ADR 0008 §2 as amended there). Blocks richer cards in dev/peoplemind-mcp#6.
Filed under: operator word "go" sha256:4cd0e21a9a07
Problem
mail_evidencecannot return a delimited signature. Ingest storesbody_textafter the blade'strim_quoted, which cuts everything from a--or--line onward, together with the quoted text (imap_blade_mcp/mime.py,trim_quoted). For this mail:the evidence is
Thanks, / Alice. The title, the company and the phone are not in the mirror.Proposal
sign_offcolumn. At ingest, the source still has the untrimmed text. It stores the block below the last--delimiter that comes before any quoted text. The block is at most 8 lines and 600 characters, sanitised, and cut at 8 lines: a declared signature holds no body text.body_text,mail_read, FTS and embeddings do not change.mail_evidencereadssign_offfirst and falls back to the rule of ADR 0008 §2 as amended in #84. The address redaction applies to both.per_passmessages a pass. It uses the attachment backlog's byte path: the held raw message, then the bucket (blob_key), then the server. Without the backlog, only new mail gets the column.mailmind evidence-stats --days 30counts recent messages by how their sign-off was found:delimited,closing,name,none. The rule can then be tuned on a live instance without anyone reading mail.Open questions
Acceptance
--signature gives its delimited block inmail_evidence, on IMAP (GreenMail) and JMAP (Stalwart).body_textandmail_readoutput do not change.evidence-statsprints counts only: no address, name, subject or text.Human act (done 2026-11-04)
ruling: the operator accepts the ADR 0008 amendment that stores a delimited sign-off block in the mirror (ADR-0008)
Done: PR #175 merged as
2c81e44(ADR 0008 §2 amended, §11 added). The build is agent work; see the brief addendum.Brief (ready-for-human)
Category: enhancement
Summary: Store a delimited sign-off block per message at ingest, and backfill it for the last 365 days, so
mail_evidencecan return a--signature.Why a human holds this. It stores more third-party personal data in the mirror, and it changes the schema and the closed field contract of ADR 0008. The operator agreed the terms below on 2026-11-01. The remaining human act is the ruling on the written ADR 0008 amendment, which must carry these terms. Once that amendment merges, this issue can move to
ready-for-agentwith this brief as its contract.Operator rulings (2026-11-01). Where this brief differs from the issue body, the brief holds.
backlog_days = 0turns the backlog off. Newest first, at mostper_passmessages a pass, and it stops at the window.BODY.PEEKof that section. On JMAP, useEmail/getwithfetchTextBodyValuesandmaxBodyValueBytes.mail_evidenceanyway.[address]when the column is written, not when it is read. The column never holds an address.Already decided:
evidence-statsand every log carry counts only.Current behavior:
body_textafter the blade'strim_quoted, which cuts at the first--or--line. Text below a delimiter is never mirrored.mail_evidencefinds a sign-off only above a delimiter, by the ADR 0008 §2 rule.Desired behavior:
--delimiter that comes before any quoted text, within the bounds above, in a newsign_offcolumn.mail_evidencereadssign_offfirst and falls back to the §2 rule.body_text,mail_read, FTS and embeddings do not change.mailmind evidence-stats --days 30counts recent received messages by how their sign-off was found: delimited, closing, name, none.Acceptance criteria:
--signature gives its delimited block inmail_evidence, on IMAP (GreenMail) and on JMAP (Stalwart).[address]in the column.body_textandmail_readoutput do not change.backlog_days = 0fetches nothing.evidence-statsprints counts only: no address, name, subject or text.Out of scope:
trim_quotedor tobody_text.mail_evidencefield beyond the signature it already returns.Brief addendum (2026-11-04)
The ruling has landed: PR #175 merged as
2c81e44. ADR 0008 §11 is the contract for this build. Where §11 and the 2026-11-01 brief above differ, §11 holds. The operator chose to keep this as one unit, not three sub-issues.Changes to the brief:
store.py:38), not v8.ALTER TABLE … ADD COLUMNwith a NULL default; nothing else is rebuilt.--once trailing white space is removed, the testtrim_quoteduses at pin v0.1.2 (imap_blade_mcp/mime.py:175,:186). Not--only.[sign_off]section withbacklog_days = 365andper_pass = 100.mail_evidenceandmail_peer_evidence_v1both read the column, through thesignaturefield only. The field list does not change.changesrow and no peer event (ADR 0012). The FTS update trigger (store.py:70-71) does not fire for it.Expected files. This is about 10 primary files, at the CONV-40 rule 2 limit:
src/mail_mind_mcp/:store.py(schema, column, backlog select, both evidence reads),ingest.pyandjmap.py(capture at ingest, partial server fetch),source.py(backlog after each pass),evidence.py(the block extractor),config.pyandcli.py(evidence-stats).config.example.toml,README.mdandSECURITY.md(its Evidence row describes the sign-off rule).Known runner constraints (from the SVD shortcomings register):
config.example.tomlmakes the PR T4 (dev/stables#1844). The operator hand-merges it, pinned to the gated head.CODEX_SVD_STAGE_TIMEOUT_SECONDS=9000.Added acceptance criteria:
--delimiter gives the same block as--.mail_peer_evidence_v1returns the delimited block insignature, and its closed field test is unchanged.changesrow and nopeer_eventsrow.SECURITY.mdEvidence row describes the delimited block.Filed under: operator word "one unit, go" sha256:cb982d9fd784
⏸ SVD architect gate: dev/mail-mind-mcp#85 keep-delimited-signatures-for-mail-evidence-a-sign-off-colum
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:
20261103T234804Z-7a3eb939Held because: CLEAN but 5 open risk(s) (1 verification · 4 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
grep -n '^SCHEMA_VERSION' src/mail_mind_mcp/store.pyon the dispatch base. It must printSCHEMA_VERSION: Final = 16(measured at2c81e44this session). If it prints 17 or more, another PR took v17; halt and re-spec to the next free version. [verification]Change: Slice 1 of 3 under #85. The full unit is about 26 files against the 16-file ceiling: 11 test files hard-code schema v16 in 25 lines. Schema v17: bump SCHEMA_VERSION (store.py:38), add
sign_off TEXTto the messages DDL after date_utc (:126) and to _ADDED_COLUMNS (:3413), so _add_columns runs ALTER TABLE ADD COLUMN; nothing else is rebuilt. Add a defaultedsign_off: str | None = Noneto MessageRecord and MessageRow and map it in _message_row (:3349-3381). In upsert_messages (:1206-1290), insert it and usesign_off = COALESCE(excluded.sign_off, messages.sign_off), mirroring blob_key at :1231. Add Store.set_sign_offs as a copy of set_attachment_flags (:1657-1664) with aWHERE id = ? AND sign_off IS NULLguard: no changes row, no _emit, and messages_au (:71) does not name the column. Add a pure evidence.delimited_block(text) -> str implementing ADR 0008 §11 with the blade's own _FORWARD_MARKER_RE/_QUOTE_HEADER_RE (mime.py:154-165): first--line (rstrip) before any quote, quote header (index>0) or forward marker; a forward marker or quote first gives ''. The block stops at the next delimiter, quote, quote header, forward marker or _BOILERPLATE line. Each line goes through _redact(sanitize_line(line)) as in evidence.py:84. Drop blank edges, cap at 8 lines, then at 600 characters at a line boundary; no 72-character stop. Bump the 25 test literals 16→17 at the listed lines (literal, because of the monkeypatch at test_store.py:428-432). Extend README.md:115 and :296 with the v17 first-start note. Slice 2 (ingest capture plus both readers plus SECURITY.md plus integration tests) and slice 3 (backlog, [sign_off] config, evidence-stats, config.example.toml) are planned in the note.Files:
src/mail_mind_mcp/store.py·src/mail_mind_mcp/evidence.py·tests/test_sign_off.py·tests/test_store.py·tests/test_mailbox_search.py·tests/test_peer_changes.py·tests/test_peer_snapshot.py·tests/test_embed_scans.py·tests/test_copy_collapse.py·tests/test_recipients.py·tests/test_evidence.py·tests/test_attachment_vectors.py·tests/test_utc_dates.py·tests/test_attachments.py·README.mdDecision: accept the 5 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-03-keep-delimited-signatures-for-mail-evidence-a-sign-off-colum.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-keep-delimited-signatures-for-mail-evidence-a-sign-off-colum.mdsvc-svd-writer referenced this issue2026-11-04 00:46:39 +00:00
spec-verify-dispatch Half B for dev/mail-mind-mcp#85 keep-delimited-signatures-for-mail-evidence-a-sign-off-colum completed integration verify.
7984f19555codex-svd ship --run-id 20261104T003713Z-9304eb4a --confirm-merge)⏸ SVD architect gate: dev/mail-mind-mcp#85 keep-delimited-signatures-for-mail-evidence-a-sign-off-colum
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:
20261104T021253Z-9b5b6385Held because: CLEAN but 2 open risk(s) (1 verification · 1 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
make greenmail-up stalwart-up: runMAILMIND_GREENMAIL=1 MAILMIND_STALWART=1 IMAP_BLADE_DIR=../imap-blade-mcp uv run python3 -m pytest -q -m integration -k delimited_signature tests/integration/test_greenmail.py tests/integration/test_stalwart.py; both new tests must pass. Then runmake test-integrationto confirm no existing integration test regressed. [verification]Change: Slice 2 of 3 under #85. ADR 0008 §11 is the contract; base is
fad5553.(1) evidence.py: add UNSCANNED_ROLES={'sent','drafts'}. Add ingest_block(role, text): None for Sent/Drafts, '' when no text was read, else delimited_block(text), which stays unchanged. Add stored_lines(stored, line_chars=None): None for NULL or '', drops blank lines, and with line_chars cuts a longer line to 71 characters plus '…'. Change signatures and signatures_bounded (evidence.py:204, :228) to take (text, name, stored) 3-tuples, using stored_lines(...) or sign_off(...). The peer path passes line_chars=72 and refuses a stored value over 4,096 bytes.
(2) store.py: append 'sign_off' to PEER_SAMPLE_TEXT (:564-576), which brings it under the existing SQL byte guard, and add PeerSample.sign_off (:579-590). Nothing else changes; no schema move.
(3) ingest.py: _record (:352-411) sets scanned=text after the HTML conversion and before trim_quoted, then sign_off=ingest_block(mailbox.role, scanned). _message_text (:597-626) also returns the untrimmed text, and _raw_record (:280-323) uses it when whole.
(4) jmap.py: _body_text (:1072-1087) returns (trimmed, untrimmed-or-None), with None when isTruncated or there is no text part. _record (:919) takes a role parameter. _add (:608-625) passes the role of names[0] from a path→role map.
(5) server.py:994 and peer.py:632 pass row.sign_off as the third element.
(6) SECURITY.md:11 Evidence row describes the delimited rule.
(7) Mechanical 3-tuple updates in tests/test_evidence.py:364-372 (closed field test untouched), tests/test_peer_evidence.py:302-305 and :436 (plus ('sign_off', 4097) in the oversize parametrisation at :310), and tests/test_peer_contract.py:204.
Mirror the subject cut at peer.py:638-639 and the GreenMail Papers create/append/delete pattern at test_greenmail.py:135-193.
Files:
src/mail_mind_mcp/evidence.py·src/mail_mind_mcp/ingest.py·src/mail_mind_mcp/jmap.py·src/mail_mind_mcp/server.py·src/mail_mind_mcp/peer.py·src/mail_mind_mcp/store.py·SECURITY.md·tests/test_sign_off.py·tests/test_evidence.py·tests/test_peer_evidence.py·tests/test_peer_contract.py·tests/integration/test_greenmail.py·tests/integration/test_stalwart.pyDecision: accept the 2 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-04-keep-delimited-signatures-for-mail-evidence-a-sign-off-colum.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-04-keep-delimited-signatures-for-mail-evidence-a-sign-off-colum.mdsvc-svd-writer referenced this issue2026-11-04 02:41:36 +00:00
spec-verify-dispatch Half B for dev/mail-mind-mcp#85 keep-delimited-signatures-for-mail-evidence-a-sign-off-colum completed integration verify.
77e62c029bcodex-svd ship --run-id 20261104T023247Z-c80b2494 --confirm-merge)spec-verify-dispatch Half B for dev/mail-mind-mcp#85 keep-delimited-signatures-for-mail-evidence-a-sign-off-colum completed integration verify.
spec-verify-dispatch Half B for dev/mail-mind-mcp#85 keep-delimited-signatures-for-mail-evidence-a-sign-off-colum completed integration verify.
ec5c1812bbuv run mypy srcanduv run --all-groups mypy srcfail with 'Failed to spawn: mypy'), somake checkstopped at the type step. ruff check and ruff format --check passed. The type check and the audit step are covered only by remote CI.codex-svd ship --run-id 20261104T023247Z-c80b2494 --confirm-merge)⏸ SVD architect gate: dev/mail-mind-mcp#85 keep-delimited-signatures-for-mail-evidence-a-sign-off-colum
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:
20261104T034632Z-cfdefc74Held because: CLEAN but 3 open risk(s) (1 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
Change: Slice 3 of 3 under #85 (base
bb5d252; the contract is ADR 0008 §11).(1) config.py: add SignOffConfig(backlog_days=365 ge0 le36500, per_pass=100 ge1 le500), shaped like AttachmentsConfig at :242-260. MailmindConfig.sign_off uses default_factory, so it is on by default.
(2) store.py: add a frozen UnscannedRow(id, account, mailbox, uidvalidity, uid, blob_key, source_id). Add Store.unscanned(account, since, limit), shaped like unextracted at :1643-1656: NULL sign_off, date_utc >= since, not in the sent/drafts roles, ordered date_utc DESC, id DESC. Add Store.sign_off_kinds(since), which groups like assessments at :1765-1780 and counts by evidence.sign_off_kind with fetchmany.
(3) evidence.py: add SIGN_OFF_KINDS and sign_off_kind(text, name, stored). It returns delimited when stored_lines is set, else closing or name from _CLOSING.match(block[0]) of the §2 block, else none.
(4) source.py: add SignOffBacklog, mirroring AttachmentBacklog at :205-377 (from_config is None when backlog_days=0; run never raises; bucket by blob_key, then server via FetchText). Add SIGN_OFF_FETCH_BYTES = 64 KB. No hold buffer. A pending latch clears when a run comes back short. Add _raw_text, copied from ingest._message_text at :604-622.
(5) ingest.py: wire the backlog after the attachment hook at :157-158. Add _fetch_text, mirroring _fetch_parts at :460-476: examine_for, BODYSTRUCTURE, choose_body_part, fetch_section(section, 0, 65536), part_to_text(partial).
(6) jmap.py: wire the backlog after :445-446. Split _body_text at :1077-1093 into _first_text without changing its result. Add _fetch_text: Email/get of textBody and bodyValues with fetchTextBodyValues and maxBodyValueBytes=65536. It scans truncated text and never downloads the raw message.
(7) cli.py: add an evidence-stats --days 1..365 (default 30) command, shaped like cmd_replay at :151-178. It prints counts only.
(8) Docs: config.example.toml [sign_off]; a README config row, CLI line and note; one sentence in the SECURITY.md:11 Evidence row.
Files:
src/mail_mind_mcp/config.py·src/mail_mind_mcp/store.py·src/mail_mind_mcp/evidence.py·src/mail_mind_mcp/source.py·src/mail_mind_mcp/ingest.py·src/mail_mind_mcp/jmap.py·src/mail_mind_mcp/cli.py·config.example.toml·README.md·SECURITY.md·tests/test_sign_off_backlog.py·tests/integration/test_greenmail.py·tests/integration/test_stalwart.pyDecision: accept the 3 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-04-keep-delimited-signatures-for-mail-evidence-a-sign-off-colum-slice-3.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-04-keep-delimited-signatures-for-mail-evidence-a-sign-off-colum-slice-3.mdspec-verify-dispatch Half B for dev/mail-mind-mcp#85 keep-delimited-signatures-for-mail-evidence-a-sign-off-colum completed integration verify.
ff87fb1c14codex-svd ship --run-id 20261104T041012Z-fc122044 --confirm-merge)