Add JMAP writes for the outbox #57

Closed
opened 2026-10-31 14:05:11 +00:00 by svc-agent-writer · 1 comment

Parent: #51 (Phase 6). Decision: ADR 0006. §10.

The five action kinds of ADR 0004 for a JMAP account:

  • draft: the bytes from compose_draft, uploaded and created with Email/import into Drafts, keywords $draft and $seen;
  • flag and move: Email/set patches on keywords and mailboxIds, each with ifInState;
  • undo: the stored inverse patch; a draft is destroyed only while it has $draft and the same blob id.

EmailSubmission is never called.

Acceptance

  • GreenMail-equivalent coverage on Stalwart: draft, flag, move and the undo of each.
  • A concurrent change on the server fails the action with a code, not an overwrite.
  • Caps and the audit log behave as for IMAP.

Live use waits on the write token for the deploying estate (ADR 0004 §9).

Blocked by

Human act

ruling: the operator rules that the JMAP write path may be built (CONV-40)

Parent: #51 (Phase 6). Decision: ADR 0006. §10. The five action kinds of ADR 0004 for a JMAP account: - draft: the bytes from `compose_draft`, uploaded and created with `Email/import` into Drafts, keywords `$draft` and `$seen`; - flag and move: `Email/set` patches on `keywords` and `mailboxIds`, each with `ifInState`; - undo: the stored inverse patch; a draft is destroyed only while it has `$draft` and the same blob id. `EmailSubmission` is never called. ## Acceptance - GreenMail-equivalent coverage on Stalwart: draft, flag, move and the undo of each. - A concurrent change on the server fails the action with a code, not an overwrite. - Caps and the audit log behave as for IMAP. Live use waits on the write token for the deploying estate (ADR 0004 §9). ## Blocked by - #55 ## Human act ruling: the operator rules that the JMAP write path may be built (CONV-40)
piers referenced this issue from a commit 2026-10-31 22:36:34 +00:00
Author
Member

This was generated by AI during triage.

Triage

Route: CONV-40 rule 3. This issue changes what the service writes to a mail server, so it is ready-for-human. The operator gave the ruling on 2026-11-01 ("proceed 57"). The build follows.

Already decided:

  • ADR 0006 §10 (docs/adr/0006-pluggable-mail-sources.md:55-60) fixes the shape of each write: a draft through blob upload and Email/import with $draft and $seen; flags and moves as Email/set patches with ifInState; an undo that replays the stored inverse; a draft destroyed only while it keeps $draft and its blob id; never EmailSubmission.
  • ADR 0004 rules hold unchanged: reversible only, caps, the audit log, and Trash and Junk refused as move targets.

Premises to verify during the build:

  • Stalwart 0.16 serves an upload URL, Email/import and ifInState on Email/set. The integration tests prove each one.
  • A JMAP draft needs from_address in the account config. Identity/get needs the submission scope, which a JMAP token must not carry (ADR 0006 §10).

Defaults taken (cheap to reverse):

  • ifInState is the account's Email state, read just before the patch. A concurrent change fails the action with the code conflict. The action is failed, not refused, so the client can ask again. The service does not retry by itself.
  • A JMAP draft gets $seen, as the ADR says. An IMAP draft gets \Draft only. The difference stays visible to the owner as an unread draft on IMAP only.
  • A move removes the source mailbox and adds the target. A message that was already in the target (a Fastmail label) keeps the target on undo.

Human act

ruling: the operator rules that the JMAP write path may be built (CONV-40)

> *This was generated by AI during triage.* ## Triage Route: CONV-40 rule 3. This issue changes what the service writes to a mail server, so it is `ready-for-human`. The operator gave the ruling on 2026-11-01 ("proceed 57"). The build follows. **Already decided:** - ADR 0006 §10 (`docs/adr/0006-pluggable-mail-sources.md:55-60`) fixes the shape of each write: a draft through blob upload and `Email/import` with `$draft` and `$seen`; flags and moves as `Email/set` patches with `ifInState`; an undo that replays the stored inverse; a draft destroyed only while it keeps `$draft` and its blob id; never `EmailSubmission`. - ADR 0004 rules hold unchanged: reversible only, caps, the audit log, and Trash and Junk refused as move targets. **Premises to verify during the build:** - Stalwart 0.16 serves an upload URL, `Email/import` and `ifInState` on `Email/set`. The integration tests prove each one. - A JMAP draft needs `from_address` in the account config. `Identity/get` needs the submission scope, which a JMAP token must not carry (ADR 0006 §10). **Defaults taken (cheap to reverse):** - `ifInState` is the account's Email state, read just before the patch. A concurrent change fails the action with the code `conflict`. The action is `failed`, not `refused`, so the client can ask again. The service does not retry by itself. - A JMAP draft gets `$seen`, as the ADR says. An IMAP draft gets `\Draft` only. The difference stays visible to the owner as an unread draft on IMAP only. - A move removes the source mailbox and adds the target. A message that was already in the target (a Fastmail label) keeps the target on undo. ## Human act ruling: the operator rules that the JMAP write path may be built (CONV-40)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#57
No description provided.