mail_draft_edit on IMAP: tool, edit action kind, guard and undo #195
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#195
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?
Part of epic #187. Implements ADR 0013 item 8 for IMAP.
Read
docs/adr/0013-trash-forward-and-draft-edits.mdand ADR 0004 first. ADR 0013 is the contract. If the code shows that a ruling cannot work, stop and report; do not change the ruling here.Standing rules: tools only queue to the outbox and never call a mail server. The sync worker applies each action through the existing source
applyinterface. Logs carry counts, roles and error codes only. Secrets are files. Add no new test seam: use the tools over HTTP with the stand-in worker, the sourceapplyinterface with the fake IMAP session or the fake JMAP server, and the GreenMail and Stalwart integration targets.What to build
mail_draft_edit(action_id, to, body, cc, subject). Scopewrite. It queues aneditaction. Schema v18 from the IMAP trash issue already admits the kind; add no schema change here.draftoreditaction that holds the live draft this service created. A replaced, undone or failed action isinvalid_argument, refused before it queues.\Draftand its recorded size. Write the new draft first, then remove the old one. A crash between the two leaves two drafts, never none. The new UID gives a new draft id, returned in the result.mail_undoof a draft or edit that a later edit replaced is refused before it queues withinvalid_argument.drafts_per_day.editaction on a JMAP account is refused withunsupported.mail_undoand the action detail, and themail_actionsdisplay for the new kind.Notes from the earlier issues (#192, #194)
edit(PR #199). A test pins that the IMAP worker refuses aneditaction withinvalid_argument. Replace that test.forward, in the same shape asreply_to(PR #201). The quoted text is never in the params; each source loads the mirror row at apply time and calls the shared composition. An edit keeps thereply_toorforwardreference of the action it replaces, so the new draft is composed the same way with the newto,cc,subjectandbody.Acceptance criteria
editaction. An edit of a replaced, undone, failed or foreign action isinvalid_argumentand queues nothing.In-Reply-ToandReferences. An edit of a forward keeps the forward block.drafts_per_day.make checkpasses.Out of scope
JMAP edits. Edits of drafts that this service did not write.
Blocked by
⏸ SVD architect gate: dev/mail-mind-mcp#195 mail-draft-edit-on-imap-tool-edit-action-kind-guard-and-undo
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:
20261112T205047Z-e3b32389Held because: CLEAN but 5 open risk(s) (1 verification · 4 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
Change: Edit params are {action: target id, to, cc, subject, body} plus the target's reply_to or forward ref, copied verbatim. draft_from (outbox.py:175) therefore composes drafts and edits the same way. An edit's inverse is the new draft's location, in the same {mailbox, uidvalidity, uid, size} shape _draft returns (actions.py:245), so the existing _undo_draft guard (actions.py:471-485) applies to edits unchanged.
IMAP runner (actions.py):
source.py: add edit_target, mirroring undo_target (source.py:120-133). It refuses an undone or replaced target, using the queued-earlier race rule. undo_target also refuses a replaced draft or edit.
store.py: add Store.edits_of, mirroring undos_of (store.py:3367) with json_extract(params,'$.action'). _day_count_sql and both of its call sites count kind IN ('draft','edit').
config.py: WritesConfig.cap('edit') returns drafts_per_day.
jmap.py: the edit kind is refused with unsupported.
server.py:
Files:
src/mail_mind_mcp/server.py·src/mail_mind_mcp/actions.py·src/mail_mind_mcp/source.py·src/mail_mind_mcp/store.py·src/mail_mind_mcp/config.py·src/mail_mind_mcp/jmap.py·tests/test_actions.py·tests/test_write_tools.py·tests/test_store.py·tests/test_jmap.py·tests/test_server.py·tests/test_config.py·tests/integration/test_greenmail_writes.pyDecision: 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-12-mail-draft-edit-on-imap-tool-edit-action-kind-guard-and-undo.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-draft-edit-on-imap-tool-edit-action-kind-guard-and-undo.md✅ SVD architect gate: dev/mail-mind-mcp#195 mail-draft-edit-on-imap-tool-edit-action-kind-guard-and-undo
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
unclassified· dispatch effortunclassifiedRun:
20261112T205047Z-e3b32389Files:
src/mail_mind_mcp/server.py·src/mail_mind_mcp/actions.py·src/mail_mind_mcp/source.py·src/mail_mind_mcp/store.py·src/mail_mind_mcp/config.py·src/mail_mind_mcp/jmap.py·tests/test_actions.py·tests/test_write_tools.py·tests/test_store.py·tests/test_jmap.py·tests/test_server.py·tests/test_config.py·tests/integration/test_greenmail_writes.pyWrite-set divergence: present table wins. 0 sourceHashes vs 20-row table.
Decision: dispatch this spec (
svd:go)?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-12-mail-draft-edit-on-imap-tool-edit-action-kind-guard-and-undo.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-draft-edit-on-imap-tool-edit-action-kind-guard-and-undo.mdspec-verify-dispatch Half B for dev/mail-mind-mcp#195 mail-draft-edit-on-imap-tool-edit-action-kind-guard-and-undo completed integration verify.
94a82883f4codex-svd ship --run-id 20261112T211050Z-d2d9eeb4 --confirm-merge)