Epic: Write v2: Trash, forward drafts and draft edits (no SMTP) #187
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/mail-mind-mcp#187
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?
Problem Statement
The owner's agent needs a complete write path that never sends mail. Four capabilities exist since 0.2.0 (ADR 0004): drafts, flags, moves, and undo with an audit log. Three things the owner asks for in ordinary triage are missing:
mail_moverefuses Trash, and ADR 0004 requires a new ADR before any delete.Solution
This epic covers every write the service offers. Four capabilities already exist and need no code change. Three are new. All stay reversible, capped and audited through the outbox of ADR 0004. The service still never sends mail and never expunges a message it did not create.
mail_draftmail_flagmail_movemail_undo,mail_actionsmail_draftwithforward_idmail_draft_editmail_trashUser Stories
Drafts (exists)
Flags (exists)
unsupportedwhen a mailbox keeps no keywords, so that I can tell the owner a colour is not possible there.Moves (exists)
mail_undoto move them back, so that a wrong filing costs one call.Trash (new)
mail_undoto move trashed messages back to their mailbox, so that a mistake costs one call.mail_trashto take up to 100 ids in one mailbox, so that it matchesmail_flagandmail_move.unsupportedwhen the account has no single Trash mailbox, so that I can tell the owner why.invalid_argumentwhen a message is already in Trash, so that I do not spend the cap.mail_trashto carry the destructive hint, so that I can ask the owner to confirm.delor amovechange, as the owner's own action would, so that my consumer needs no new event kind.Forward (new)
Fwd:and the original subject, so that it reads as a normal forward.invalid_argumentwhen I name both a reply and a forward, so that the draft has one purpose.Edit (new)
mail_undoof an edit to restore the previous text, so that every action stays reversible.draft_id, so that I can read the draft back.invalid_argumentwhen I name an action whose draft a later action replaced, so that I act on the newest one.Operation and audit
trash_per_dayin[writes], so that I can tune or zero the cap.drafts_per_day, so that there is no new cap to tune.mail_actionsto list trash and edit rows with counts and mailbox names only, so that the audit log carries no content.SECURITY.mdand the README to state exactly what a leaked write token can now do, so that the risk statement is true.Implementation Decisions
Decision record
Baseline (exists)
Trash
mail_trash(message_ids)and a new action kindtrash.mail_movekeeps refusing Trash and Junk, so the two intents stay separate in the tool list, the caps and the audit log.trashrole, whether or not the mirror includes that mailbox. Zero or several such mailboxes isunsupported.unsupported, because undo would be a guess.Email/setofmailboxIdswithifInState. The inverse stores each message's previousmailboxIds.not_foundand nothing changes.trash_per_day, default 20, counted in messages. Every other cap still counts requests. A request that would pass the cap is refused whole withrate_limitedand queues nothing.Forward
mail_draftgainsforward_id. It is exclusive withreply_to_idand implies the account.In-Reply-Toand noReferences.Edit
mail_draft_edit(action_id, to, body, cc, subject)and a new action kindedit. The arguments replace the whole draft. Threading headers and forward context come from the action that is replaced.draftoreditaction that holds the live draft. A replaced, undone or failed action isinvalid_argument.drafts_per_day.Shared
trashandeditbehind the existing sourceapplyinterface. The tools still only queue.mail_actionsgains detail text for the two kinds: counts and mailbox names only.Testing Decisions
A good test states what a caller or the mail server observes: the tool's answer, the action row, the mirror and the mailbox. It does not assert on private helpers.
Four seams, all existing. No new seam.
apply, per source. Apply then undo fortrashandedit, the guards, theunsupportedpaths. Prior art: the action tests with the fake IMAP session, and the JMAP tests with the fake JMAP server.Baseline acceptance: the existing unit and integration tests for drafts, flags, colours, moves and undo pass unchanged. Any story from 1 to 13 without a test gets one at seam 1 or seam 2.
The test that the server imports no mail source must still pass.
Out of Scope
Further Notes
Sub-issues
mail_trashon IMAP: tool, trash action kind, schema v18, cap, undo and mirror effect. Blocked by #188.mail_trashon JMAP. Blocked by #192.forward_idinmail_draft. Blocked by #188.mail_draft_editon IMAP. Blocked by #192 (schema v18) and #194 (forward context).mail_draft_editon JMAP. Blocked by #195.All 8 sub-issues are closed. Release 0.14.0 is tagged (
v0.14.0on3ba9d20). Closing the epic.