trim_quoted keeps a forwarded message after a forward marker #3
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/imap-blade-mcp#3
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?
This is the blade half of dev/mail-mind-mcp#113. Triage ruled on 2026-11-02: fix
trim_quotedhere, then bump the pin in mail-mind-mcp. The operator ruled the marker list on 2026-11-03 (below).Agent Brief
Category: bug
Summary:
trim_quotedcuts a forwarded message at its header block, so the forwarded content is lost.Current behavior:
trim_quotedinsrc/imap_blade_mcp/mime.pycuts at the first line, after line 0, that matches_QUOTE_HEADER_RE. That pattern includesFrom: …. A forward readsBegin forwarded message:, then a header block that startsFrom:. Sotrim_quotedkeeps the text above the header block and drops the forwarded headers and body.Desired behavior:
After an unambiguous forward marker line,
trim_quoteddoes not cut at the header block that follows. It keeps the header block and the forwarded body. The forward markers are a closed list. Each marker matches with surrounding whitespace, case-insensitively:Begin forwarded message:(Apple Mail)---------- Forwarded message ---------(Gmail; any run of two or more dashes on each side)Inside the forwarded part, the existing rules still apply:
>quote prefixes,On … wrote:,--signatures and the other_QUOTE_HEADER_REmarkers still cut. Only the header block directly after the forward marker is exempt.Ruled out (operator, 2026-11-03):
-----Original Message-----and-------- Original Message --------are not forward markers. Outlook writes them on replies and on forwards alike, so they stay reply cuts, as today. Residual: an Outlook forward still loses its body.Key interfaces:
trim_quoted(text: str) -> tuple[str, int]keeps the same signature.omitted_charsstays exactlylen(text) - len(kept).Acceptance criteria:
Hi\n\nBegin forwarded message:\n\nFrom: a@example.test\nSubject: x\n\nbodykeeps every line, andomittedis 0.---------- Forwarded message ---------with aFrom:header block.Thanks\n\nOn Mon, X wrote:\n> quotedstill cuts at theOn … wrote:line.On … wrote:or>), not before the forwarded headers.Body\n-----Original Message-----\nFrom: xstill cuts at-----Original Message-----(existing test intests/test_mime.py).trim_quotedtests intests/test_mime.pystay green, andmake checkpasses.Out of scope:
v0.1.2after merge.mail_readtest (dev/mail-mind-mcp#113).Blocks
⏸ SVD architect gate: dev/imap-blade-mcp#3 trim-quoted-keeps-a-forwarded-message-after-a-forward-marker
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
additive· dispatch effortlowRun:
20261103T005914Z-a98ad411Held because: CLEAN but 2 open risk(s) (1 verification · 1 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
Change: In src/imap_blade_mcp/mime.py add two module-level Final regexes below _QUOTE_HEADER_RE (mime.py:154-158), mirroring its style. _FORWARD_MARKER_RE is ^\s*(?:Begin forwarded message:|-{2,}\sForwarded message\s-{2,})\s*
with IGNORECASE. _HEADER_FIELD_RE is ^[A-Za-z][A-Za-z0-9-]{0,40}:(?:\s|). In trim_quoted (mime.py:161-175), add header_block/seen_header state ahead of the existing checks. A marker line arms the exemption and continues. While the exemption is armed, header-shaped lines continue, and blank lines before the first header continue. The first other line disarms it and falls through to the unchanged '>'/'-- ' and _QUOTE_HEADER_RE cuts. The return expression is unchanged, so omitted == len(text) - len(kept). This was prototyped in memory against the base tree: all acceptance cases, the existing TestTrimQuoted inputs and the test_tools.py mail_read fixture produced the expected results. Add the new test methods to class TestTrimQuoted in tests/test_mime.py:113-128.Files:
src/imap_blade_mcp/mime.py·tests/test_mime.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-03-trim-quoted-keeps-a-forwarded-message-after-a-forward-marker.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-03-trim-quoted-keeps-a-forwarded-message-after-a-forward-marker.mdspec-verify-dispatch Half B for dev/imap-blade-mcp#3 trim-quoted-keeps-a-forwarded-message-after-a-forward-marker completed integration verify.
44a72dcb8244a72dc: no Forgejo commit statuses (absent). Local: 178 passed, ruff, format and mypy --strict clean.44a72dc, so remote CI has not reported.44a72dcreturn an empty list; no CI run in history for this commit. — reported as absent, not blocking (gh#633)codex-svd ship --run-id 20261103T021640Z-1aa7cbaf --confirm-merge)